diff --git a/.gitignore b/.gitignore index 5e98e99..5a4095a 100644 --- a/.gitignore +++ b/.gitignore @@ -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____ diff --git a/src/taomi/client.cpp b/src/taomi/client.cpp index ed8fa32..a1c0bdd 100644 --- a/src/taomi/client.cpp +++ b/src/taomi/client.cpp @@ -27,7 +27,7 @@ Client::~Client() void Client::sendOrder() { - quint16 seatNO = 1; // 暂时定义 + quint16 seatNO = getSeatNO(); block = new QByteArray(); QDataStream out(block, QIODevice::WriteOnly); @@ -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; + } +} diff --git a/src/taomi/client.h b/src/taomi/client.h index b3639de..99f8111 100644 --- a/src/taomi/client.h +++ b/src/taomi/client.h @@ -25,6 +25,9 @@ private slots: void connectionClosedByServer(); void error(); +public: + quint16 getSeatNO(); + private: void connectToServer(const QString & serverIP); void connectToServer(const QHostAddress & address); diff --git a/src/taomi/images/wether.png b/src/taomi/images/wether.png old mode 100755 new mode 100644 diff --git a/src/taomi/ordermanager.cpp b/src/taomi/ordermanager.cpp index ebf22c9..63f1302 100644 --- a/src/taomi/ordermanager.cpp +++ b/src/taomi/ordermanager.cpp @@ -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(); +} + diff --git a/src/taomi/ordermanager.h b/src/taomi/ordermanager.h index 973bf4f..e1b53b0 100644 --- a/src/taomi/ordermanager.h +++ b/src/taomi/ordermanager.h @@ -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(); @@ -21,6 +22,7 @@ class OrderManager : public QObject signals: void orderNOChanged(); + void seatNOChanged(); void send(); void clearShopcar(); @@ -28,9 +30,12 @@ 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 diff --git a/src/taomi/qml/ScrollBar.qml b/src/taomi/qml/ScrollBar.qml old mode 100755 new mode 100644 diff --git a/src/taomi/qml/SeatGrid.qml b/src/taomi/qml/SeatGrid.qml index 8676700..f4569fe 100644 --- a/src/taomi/qml/SeatGrid.qml +++ b/src/taomi/qml/SeatGrid.qml @@ -40,6 +40,7 @@ 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); @@ -47,7 +48,7 @@ GridView { else { seatView.model.setProperty(i, "active", 0); } - } + } } } } @@ -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++; + } + } + ) + }*/ } } diff --git a/src/taomi/qml/SeatView.qml b/src/taomi/qml/SeatView.qml index 0042750..322b929 100644 --- a/src/taomi/qml/SeatView.qml +++ b/src/taomi/qml/SeatView.qml @@ -35,7 +35,6 @@ Item { onChangeSeatType: { seatView.source = ""; timer3.running = true; - //seatView.source = "qrc:/qml/SeatGrid.qml"; } } diff --git a/src/taomi/qml/ShopcarView.qml b/src/taomi/qml/ShopcarView.qml index c30830a..dd05d17 100644 --- a/src/taomi/qml/ShopcarView.qml +++ b/src/taomi/qml/ShopcarView.qml @@ -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; } } } diff --git a/src/taomi/taomi.pro.user b/src/taomi/taomi.pro.user index 3c9814f..e742efd 100644 --- a/src/taomi/taomi.pro.user +++ b/src/taomi/taomi.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -14,63 +14,24 @@ Cpp - false - CppGlobal - true - false - true - false - false - false - true - true - false - true - false - false - false - true - false + CppGlobal - 1 + + QmlJS + + QmlJSGlobal + + + 2 System - Global + false 4 true 1 true - false + 0 true - - Cpp - - true - false - CppGlobal - 4 - 1 - false - true - 0 - 8 - - - - QmlJS - - true - false - QmlJSGlobal - 4 - 1 - false - true - 0 - 8 - - - 2 0 8 true @@ -81,13 +42,17 @@ false + + ProjectExplorer.Project.PluginSettings + + ProjectExplorer.Project.Target.0 桌面 桌面 Qt4ProjectManager.Target.DesktopTarget - 1 + 0 0 0 @@ -132,12 +97,12 @@ 2 false - Desktop Qt 4.7.4 for GCC (Qt SDK) 发布 + Desktop Qt 4.8.1 for GCC (Qt SDK) 发布 Qt4ProjectManager.Qt4BuildConfiguration 0 - /home/gao/taomi/src/taomi-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK____ - 2 + /home/gao/taomi/src/taomi-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK____ + 3 true @@ -182,12 +147,12 @@ 2 false - Desktop Qt 4.7.4 for GCC (Qt SDK) 调试 + Desktop Qt 4.8.1 for GCC (Qt SDK) 调试 Qt4ProjectManager.Qt4BuildConfiguration 2 - /home/gao/taomi/src/taomi-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK____ - 2 + /home/gao/taomi/src/taomi-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK____ + 3 true 2 @@ -291,7 +256,7 @@ ProjectExplorer.Project.Updater.EnvironmentId - {e0b7db84-7ff5-4b6a-a1b7-9ab294b418ec} + {77633432-79b8-46ff-a7a8-fbbf07693cb9} ProjectExplorer.Project.Updater.FileVersion