TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent), m_ui(new Ui::TabWidget) { m_ui->setupUi(this); connect(m_ui->pushButton_upload, SIGNAL(clicked()), this, SLOT(uploadDialog())); connect(m_ui->pushButton_clear, SIGNAL(clicked()), this, SLOT(clearTableView())); uploadings_model = new QStandardItemModel(0,2); m_ui->tableView->setModel(uploadings_model); connect(m_ui->pushButton_control, SIGNAL(clicked()), this, SLOT(controlUpload())); suffixes << "B" << "KB" << "MB" << "GB" << "TB" << "PB"; loadOptions(); connect(&Listener::instance(), SIGNAL(UploadingsReceived()), this, SLOT(newUpload())); connect(&Window::instance(), SIGNAL(UploadingsReceived()), this, SLOT(newUpload())); connect(m_ui->checkBox_api, SIGNAL(stateChanged(int)), this, SLOT(toggleApiKey(int))); connect(m_ui->lineEdit_api,SIGNAL(editingFinished()), this, SLOT(updateApiKey())); connect(m_ui->checkBox_systemtray, SIGNAL(stateChanged(int)), this, SLOT(toggleSystemTray(int))); newUpload(); }
void StorgeSelect::selectFun() { createList(); clearTableView(); QSqlQuery query; QString select_sql; int i=0; int condition=selectComboBox->currentIndex(); QString conditionStr1; switch(condition) { case 0: { //goodsstorage storagecount storagprice storagetotal goodsid goodsname //goodsid goodsname goodsformat goodsclass goodsunit goodssave goodsprice goodsremarks goodsstatus goodsstatusid conditionStr1=selectLineEdit->text(); select_sql = "select goodsstorage.goodsid,goodsstorage.goodsname,goodsstorage.storagecount,\ goodsstorage.storagprice,goodsstorage.storagetotal,\ goods.goodssave,goods.goodsstatus from goodsstorage,goods where goods.goodsname in(select goodsname from goodsstorage \ where goodsname=:conditionStr1 ) and goods.goodsname=goodsstorage.goodsname"; if(conditionStr1.isEmpty()) { QMessageBox::warning(this,"警告","请输入查询的商品名字!"); return ; } query.prepare(select_sql); query.bindValue(":conditionStr1",conditionStr1); break; } case 1: { conditionStr1=selectLineEdit->text(); select_sql = "select goodsstorage.goodsid,goodsstorage.goodsname,goodsstorage.storagecount,\ goodsstorage.storagprice,goodsstorage.storagetotal,\ goods.goodssave,goods.goodsstatus from goodsstorage,goods where goods.goodsid in(select goodsid from goodsstorage \ where goodsname=:conditionStr1 ) and goods.goodsid=goodsstorage.goodsid"; if(conditionStr1.isEmpty()) { QMessageBox::warning(this,"警告","请输入查询的商品编号!"); return ; } query.prepare(select_sql); query.bindValue(":conditionStr1",conditionStr1); break; } } if(!query.exec()) { qDebug()<<query.lastError(); } else { //goodsid ,goodsname,inputcount,inputprice,inputtotal,inputtype,inputtime,customsid storgeList.clear(); storgeList.append("产品编号"); storgeList.append("产品名称"); storgeList.append("库存量"); storgeList.append("产品单价"); storgeList.append("产品总价"); storgeList.append("安全库存"); storgeList.append("产品状态"); while(query.next()) { tableModel->setItem(i,0,new QStandardItem(query.value("goodsid").toString())); storgeList.append(query.value("goodsid").toString()); tableModel->setItem(i,1,new QStandardItem(query.value("goodsname").toString())); storgeList.append(query.value("goodsname").toString()); tableModel->setItem(i,2,new QStandardItem(query.value("storagecount").toString())); storgeList.append(query.value("storagecount").toString()); tableModel->setItem(i,3,new QStandardItem(query.value("storagprice").toString())); storgeList.append(query.value("storagprice").toString()); tableModel->setItem(i,4,new QStandardItem(query.value("storagetotal").toString())); storgeList.append(query.value("storagetotal").toString()); tableModel->setItem(i,5,new QStandardItem(query.value("goodssave").toString())); storgeList.append(query.value("goodssave").toString()); tableModel->setItem(i,6,new QStandardItem(query.value("goodsstatus").toString())); storgeList.append(query.value("goodsstatus").toString()); if(query.value("goodsstatus").toString()=="停用") { tableModel->item(i,6)->setBackground(QBrush(QColor(255,0, 0))); } else { tableModel->item(i,6)->setBackground(QBrush(QColor(255, 255, 255))); } i++; } } }