Skip to content

Commit

Permalink
Issue #10: 完善SeatView
Browse files Browse the repository at this point in the history
  • Loading branch information
gaolinjie committed Apr 22, 2012
1 parent 74d9c57 commit 5d48cf5
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 72 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/src/taomi-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK____/
/src/taomi-android-build--Necessitas_Qt_4_8_0_for_Android_armv5_Release/
/src/taomi-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK____
16 changes: 15 additions & 1 deletion src/taomi/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Client::~Client()

void Client::sendOrder()
{
quint16 seatNO = 1; // 暂时定义
quint16 seatNO = getSeatNO();

block = new QByteArray();
QDataStream out(block, QIODevice::WriteOnly);
Expand Down Expand Up @@ -122,3 +122,17 @@ void Client::closeConnection()
{
tcpSocket.close();
}

quint16 Client::getSeatNO()
{
QSqlQuery query;
query.exec("SELECT * FROM currentSeatModel");
if (query.next()) {
quint16 s = query.value(0).toUInt();
return s;
}
else {
qDebug() << TAG << "Not set seatNO yet" << __FILE__ << __LINE__;
return -1;
}
}
3 changes: 3 additions & 0 deletions src/taomi/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ private slots:
void connectionClosedByServer();
void error();

public:
quint16 getSeatNO();

private:
void connectToServer(const QString & serverIP);
void connectToServer(const QHostAddress & address);
Expand Down
Empty file modified src/taomi/images/wether.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/taomi/ordermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,28 @@ bool OrderManager::isHaveNewOrder()
}
}

qint16 OrderManager::getSeatNO() const
{
QSqlQuery query;
query.exec("SELECT * FROM currentSeatModel");
if (query.next()) {
qint16 s = query.value(0).toUInt();
return s;
}
else {
qDebug() << TAG << "Not set seatNO yet" << __FILE__ << __LINE__;
return -1;
}
}

void OrderManager::setSeatNO(const quint16 &s)
{
QSqlQuery query;
query.exec("DROP TABLE currentSeatModel");
query.exec("CREATE TABLE IF NOT EXISTS currentSeatModel(sid INTEGER key)");
query.prepare("INSERT INTO currentSeatModel(sid) VALUES (?)");
query.addBindValue(s);
query.exec();
}


5 changes: 5 additions & 0 deletions src/taomi/ordermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class OrderManager : public QObject
{
Q_OBJECT
Q_PROPERTY(quint32 orderNO READ getOrderNO WRITE setOrderNO NOTIFY orderNOChanged)
Q_PROPERTY(quint16 seatNO READ getSeatNO WRITE setSeatNO NOTIFY seatNOChanged)
public:
explicit OrderManager(QObject *parent = 0);
~OrderManager();
Expand All @@ -21,16 +22,20 @@ class OrderManager : public QObject

signals:
void orderNOChanged();
void seatNOChanged();
void send();
void clearShopcar();

public slots:
void sendOrder();
void payOrder(quint32 orderNO);
bool isHaveNewOrder();
void setSeatNO(const quint16 &s);
qint16 getSeatNO() const;

private:
quint32 mOrderNO;
quint16 mSeatNO;
};

#endif // ORDERMANAGER_H
Empty file modified src/taomi/qml/ScrollBar.qml
100755 → 100644
Empty file.
19 changes: 18 additions & 1 deletion src/taomi/qml/SeatGrid.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ GridView {
anchors.fill: parent

onClicked: {
orderManager.setSeatNO(sid);
for (var i = 0; i < seatView.model.count; i++) {
if (seatView.model.get(i).sid == sid) {
seatView.model.setProperty(i, "active", 1);
}
else {
seatView.model.setProperty(i, "active", 0);
}
}
}
}
}
}
Expand Down Expand Up @@ -244,5 +245,21 @@ GridView {
}
)
}
/*
function saveItemsData() {
var db = openDatabaseSync("DemoDB", "1.0", "Demo Model SQL", 50000);
db.transaction(
function(tx) {
tx.executeSql('DROP TABLE seatCategoryModel');
tx.executeSql('CREATE TABLE IF NOT EXISTS seatModel(sid INTEGER key, cid INTEGER, seat TEXT, active INTEGER)');
var index = 0;
while (index < seatModel.count) {
var item = seatModel.get(index);
tx.executeSql('INSERT INTO seatModel VALUES(?,?,?,?)', [item.sid, item.cid, item.seat, item.active]);
index++;
}
}
)
}*/
}
}
1 change: 0 additions & 1 deletion src/taomi/qml/SeatView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Item {
onChangeSeatType: {
seatView.source = "";
timer3.running = true;
//seatView.source = "qrc:/qml/SeatGrid.qml";
}
}

Expand Down
32 changes: 21 additions & 11 deletions src/taomi/qml/ShopcarView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -100,30 +100,40 @@ Item {
onPressed: {
if (orderManager.isHaveNewOrder())
{
sendButton.color = Global.hotColor
sendButton.color = Global.hotColor;
}
}
onClicked: {
if (orderManager.isHaveNewOrder())
if (orderManager.getSeatNO() == -1)
{
foreground.visible = true;
dialogAlert.visible = true;
dialogAlert.content = " 您还未选择座位,请先选择座位再试!";
dialogAlert.y = 275;
return;
}

if (orderManager.isHaveNewOrder())
{
if (deviceManager.isRegistered()) {
foreground.visible = true
dialogSend.visible = true
dialogSend.y = 275
sendButton.color = "grey"
foreground.visible = true;
dialogSend.visible = true;
dialogAlert.content = " 服务器未能连接,请稍后再试!";
dialogSend.y = 275;
sendButton.color = "grey";
}
else {
foreground.visible = true
dialogAlert.visible = true
dialogAlert.y = 275
deviceManager.registerDevice()
foreground.visible = true;
dialogAlert.visible = true;
dialogAlert.y = 275;
deviceManager.registerDevice();
}
}
}
onReleased: {
if (orderManager.isHaveNewOrder())
{
sendButton.color = Global.rectColor
sendButton.color = Global.rectColor;
}
}
}
Expand Down
81 changes: 23 additions & 58 deletions src/taomi/taomi.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.3.0, 2012-04-21T01:43:42. -->
<!-- Written by Qt Creator 2.4.1, 2012-04-23T00:44:09. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
Expand All @@ -14,63 +14,24 @@
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="bool" key="AlignAssignments">false</value>
<value type="QString" key="CurrentFallback">CppGlobal</value>
<value type="bool" key="ExtraPaddingForConditionsIfConfusingAlign">true</value>
<value type="bool" key="IndentAccessSpecifiers">false</value>
<value type="bool" key="IndentBlockBody">true</value>
<value type="bool" key="IndentBlockBraces">false</value>
<value type="bool" key="IndentBlocksRelativeToSwitchLabels">false</value>
<value type="bool" key="IndentClassBraces">false</value>
<value type="bool" key="IndentControlFlowRelativeToSwitchLabels">true</value>
<value type="bool" key="IndentDeclarationsRelativeToAccessSpecifiers">true</value>
<value type="bool" key="IndentEnumBraces">false</value>
<value type="bool" key="IndentFunctionBody">true</value>
<value type="bool" key="IndentFunctionBraces">false</value>
<value type="bool" key="IndentNamespaceBody">false</value>
<value type="bool" key="IndentNamespaceBraces">false</value>
<value type="bool" key="IndentStatementsRelativeToSwitchLabels">true</value>
<value type="bool" key="IndentSwitchLabels">false</value>
<value type="QString" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">1</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">System</value>
<value type="QString" key="EditorConfiguration.CurrentFallback">Global</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.SmartBackspace">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.Tab.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="bool" key="AutoIndent">true</value>
<value type="bool" key="AutoSpacesForTabs">false</value>
<value type="QString" key="CurrentFallback">CppGlobal</value>
<value type="int" key="IndentSize">4</value>
<value type="int" key="PaddingMode">1</value>
<value type="bool" key="SmartBackspace">false</value>
<value type="bool" key="SpacesForTabs">true</value>
<value type="int" key="TabKeyBehavior">0</value>
<value type="int" key="TabSize">8</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.Tab.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="bool" key="AutoIndent">true</value>
<value type="bool" key="AutoSpacesForTabs">false</value>
<value type="QString" key="CurrentFallback">QmlJSGlobal</value>
<value type="int" key="IndentSize">4</value>
<value type="int" key="PaddingMode">1</value>
<value type="bool" key="SmartBackspace">false</value>
<value type="bool" key="SpacesForTabs">true</value>
<value type="int" key="TabKeyBehavior">0</value>
<value type="int" key="TabSize">8</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.Tab.Count">2</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
Expand All @@ -81,13 +42,17 @@
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
Expand Down Expand Up @@ -132,12 +97,12 @@
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 4.7.4 for GCC (Qt SDK) 发布</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 4.8.1 for GCC (Qt SDK) 发布</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/gao/taomi/src/taomi-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK____</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/gao/taomi/src/taomi-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK____</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">3</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
Expand Down Expand Up @@ -182,12 +147,12 @@
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 4.7.4 for GCC (Qt SDK) 调试</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 4.8.1 for GCC (Qt SDK) 调试</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/gao/taomi/src/taomi-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK____</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/gao/taomi/src/taomi-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK____</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">3</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
Expand Down Expand Up @@ -291,7 +256,7 @@
</data>
<data>
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
<value type="QString">{e0b7db84-7ff5-4b6a-a1b7-9ab294b418ec}</value>
<value type="QString">{77633432-79b8-46ff-a7a8-fbbf07693cb9}</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
Expand Down

0 comments on commit 5d48cf5

Please sign in to comment.