void StocksDialog::createDataPage () { QWidget *w = new QWidget(this); Q3VBoxLayout *vbox = new Q3VBoxLayout(w); vbox->setMargin(5); vbox->setSpacing(0); barEdit = new BarEdit(w); QString s = tr("Open"); QString s2 = "Open"; barEdit->createField(s, s2, FALSE); s = tr("High"); s2 = "High"; barEdit->createField(s, s2, FALSE); s = tr("Low"); s2 = "Low"; barEdit->createField(s, s2, FALSE); s = tr("Close"); s2 = "Close"; barEdit->createField(s, s2, FALSE); s = tr("Volume"); s2 = "Volume"; barEdit->createField(s, s2, FALSE); connect(barEdit, SIGNAL(signalDeleteRecord()), this, SLOT(deleteRecord())); connect(barEdit, SIGNAL(signalSaveRecord()), this, SLOT(saveRecord())); connect(barEdit, SIGNAL(signalSearch(QDateTime)), this, SLOT(slotDateSearch(QDateTime))); connect(barEdit, SIGNAL(signalFirstRecord()), this, SLOT(slotFirstRecord())); connect(barEdit, SIGNAL(signalLastRecord()), this, SLOT(slotLastRecord())); connect(barEdit, SIGNAL(signalPrevRecord()), this, SLOT(slotPrevRecord())); connect(barEdit, SIGNAL(signalNextRecord()), this, SLOT(slotNextRecord())); vbox->addWidget(barEdit); addTab(w, tr("Data")); }
void FuturesDialog::saveChart () { QString s = title->text(); DBIndexItem item; index->getIndexItem(symbol, item); item.setTitle(s); index->setIndexItem(symbol, item); if (barEdit->getSaveFlag()) { int rc = QMessageBox::warning(this, tr("Warning"), tr("Record has been modified.\nSave changes?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton); if (rc == QMessageBox::Yes) saveRecord(); } reloadFlag = TRUE; accept(); }
void ProductWidget::createActions() { m_addAct = new QAction(QIcon(":/add"), tr("Add"), this); m_deleteAct = new QAction(QIcon(":/delete"), tr("Delete"), this); m_modifyAct = new QAction(QIcon(":/edit"), tr("Modify"), this); m_saveAct = new QAction(QIcon(":/ok"), tr("Save"), this); m_cancelAct = new QAction(QIcon(":/cancel"), tr("Cancel"), this); m_deleteAct->setDisabled(true); m_modifyAct->setDisabled(true); m_saveAct->setDisabled(true); m_cancelAct->setDisabled(true); connect(m_addAct, SIGNAL(triggered()), this, SLOT(addRecord())); connect(m_deleteAct, SIGNAL(triggered()), this, SLOT(deleteRecord())); connect(m_modifyAct, SIGNAL(triggered()), this, SLOT(modifyRecord())); connect(m_saveAct, SIGNAL(triggered()), this, SLOT(saveRecord())); connect(m_cancelAct, SIGNAL(triggered()), this, SLOT(cancelModifiedRecord())); }
SizPostForm::SizPostForm(QString id, QWidget *parent, bool onlyForRead) : QDialog(parent) { exchangeFile.setFileName("Message.txt"); if(!exchangeFile.isOpen()){ exchangeFile.open(QIODevice::ReadWrite); } QSettings settings("AO_Batrakov_Inc.", "EmployeeClient"); QString newIndexTemp = settings.value("PostSizID").toString(); QString copyDoc = settings.value("CopyPostSiz").toString(); indexTemp = id; addIntoTable = false; labelPostSIZ = new QLabel(trUtf8("Наименование:")); editPostSIZ = new LineEdit; savePushButton = new QPushButton(trUtf8("Записать")); connect(savePushButton,SIGNAL(clicked()),this,SLOT(saveRecord())); savePushButton->setToolTip(trUtf8("Save And Close Button")); cancelPushButton = new QPushButton(trUtf8("Отмена")); cancelPushButton->setDefault(true); cancelPushButton->setStyleSheet("QPushButton:hover {color: red}"); connect(cancelPushButton,SIGNAL(clicked()),this,SLOT(cancelRecord())); cancelPushButton->setToolTip(trUtf8("Cancel Button")); buttonBox = new QDialogButtonBox; buttonBox->addButton(cancelPushButton,QDialogButtonBox::ActionRole); buttonBox->addButton(savePushButton,QDialogButtonBox::ActionRole); postView = new QTableWidget(0,3); postView->setHorizontalHeaderLabels(QStringList()<<trUtf8("ID")<<trUtf8("postID")<<trUtf8("Профессия по кадрам")); postView->hideColumn(0); postView->hideColumn(1); postView->setColumnWidth(2,300); postView->setAlternatingRowColors(true); QHeaderView *headPost = postView->horizontalHeader(); headPost->setStretchLastSection(true); postView->setSelectionMode(QAbstractItemView::SingleSelection); postView->setSelectionBehavior(QAbstractItemView::SelectRows); postView->setEditTriggers(QAbstractItemView::NoEditTriggers); sizView = new QTableWidget(0,6); sizView->setHorizontalHeaderLabels(QStringList()<<trUtf8("ID")<<trUtf8("postID")<<trUtf8("Наименование СИЗ")<< trUtf8("Характеристика")<<trUtf8("Количество")<<trUtf8("Срок эксп.(мес)")); sizView->hideColumn(0); sizView->hideColumn(1); sizView->setColumnWidth(2,300); sizView->setColumnWidth(3,300); sizView->setAlternatingRowColors(true); QHeaderView *headSiz = sizView->horizontalHeader(); headSiz->setStretchLastSection(true); sizView->setSelectionMode(QAbstractItemView::SingleSelection); sizView->setSelectionBehavior(QAbstractItemView::SelectRows); sizView->setEditTriggers(QAbstractItemView::NoEditTriggers); if(indexTemp != ""){ QSqlQuery query; query.prepare("SELECT postsizname FROM postsiz WHERE postsizid = ?"); query.addBindValue(indexTemp); query.exec(); while(query.next()){ editPostSIZ->setText(query.value(0).toString()); QSqlQuery query; query.prepare("SELECT * FROM postsizlist WHERE postsizid = :postsizid"); query.bindValue(":postsizid",indexTemp); query.exec(); int rowCount = 0; while(query.next()){ postView->insertRow(rowCount); QTableWidgetItem *itemID = new QTableWidgetItem; postView->setItem(rowCount,0,itemID); postView->item(rowCount,0)->setText(query.value(0).toString()); QTableWidgetItem *itemPostID = new QTableWidgetItem; postView->setItem(rowCount,1,itemPostID); postView->item(rowCount,1)->setText(query.value(1).toString()); QSqlQuery queryName; queryName.prepare("SELECT postname FROM post WHERE postid = :postid"); queryName.bindValue(":postid",query.value(2).toString()); queryName.exec(); queryName.next(); QTableWidgetItem *itemPostSiz = new QTableWidgetItem; postView->setItem(rowCount,2,itemPostSiz); postView->item(rowCount,2)->setText(queryName.value(0).toString()); ++rowCount; } updateSiz(); if(copyDoc == "1"){ indexTemp = newIndexTemp; QString tt = editPostSIZ->text(); tt += " (1)"; editPostSIZ->setText(tt); } updateRecord = true; } }else{ editPostSIZ->clear(); NumPrefix numPrefix; indexTemp = numPrefix.getPrefix("postsiz"); updateRecord = false; } connect(postView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(editRecordOfTablePost())); connect(sizView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(editRecordOfTableSiz())); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(labelPostSIZ,0,0); mainLayout->addWidget(editPostSIZ,0,1); mainLayout->addWidget(postView,1,0,3,2); mainLayout->addWidget(sizView,5,0,5,2); if(!onlyForRead){ mainLayout->addWidget(buttonBox,10,1); editPostSIZ->selectAll(); } sizView->setHorizontalHeaderLabels(QStringList()<<trUtf8("ID")<<trUtf8("postID")<<trUtf8("Наименование СИЗ")<< trUtf8("Характеристика")<<trUtf8("Количество")<<trUtf8("Срок эксп.(мес)")); setLayout(mainLayout); setWindowTitle(trUtf8("Профессия по нормам СИЗ")); readSettings(); createContextMenuPost(); createContextMenuSiz(); }
PostSizTableForm::PostSizTableForm(QString id, QWidget *parent, bool onlyForRead) : QDialog(parent) { exchangeFile.setFileName("Message.txt"); if(!exchangeFile.isOpen()){ exchangeFile.open(QIODevice::ReadWrite); } indexTemp = id; addIntoTable = false; QFile file(":/ToolButtonStyle.txt"); file.open(QFile::ReadOnly); QVBoxLayout *labelLayout = new QVBoxLayout; QVBoxLayout *editLayout = new QVBoxLayout; //********************************************************** //SIZ //********************************************************** labelPostSIZ = new QLabel(trUtf8("PostSIZ Name:")); editPostSIZ = new LineEdit; editPostSIZ->setReadOnly(onlyForRead); QRegExp regExpFamiliya("[\\x0410-\\x044f 0-9 \" -]{150}"); editPostSIZ->setValidator(new QRegExpValidator(regExpFamiliya,this)); labelPostSIZ->setBuddy(editPostSIZ); labelLayout->addWidget(labelPostSIZ); editLayout->addWidget(editPostSIZ); savePushButton = new QPushButton(trUtf8("Save")); connect(savePushButton,SIGNAL(clicked()),this,SLOT(saveRecord())); savePushButton->setToolTip(trUtf8("Save And Close Button")); cancelPushButton = new QPushButton(trUtf8("Cancel")); cancelPushButton->setDefault(true); cancelPushButton->setStyleSheet("QPushButton:hover {color: red}"); connect(cancelPushButton,SIGNAL(clicked()),this,SLOT(cancelRecord())); cancelPushButton->setToolTip(trUtf8("Cancel Button")); buttonBox = new QDialogButtonBox; buttonBox->addButton(cancelPushButton,QDialogButtonBox::ActionRole); buttonBox->addButton(savePushButton,QDialogButtonBox::ActionRole); QPushButton *addTableButton = new QPushButton(trUtf8("Add")); QPixmap pixAdd(":/add.png"); addTableButton->setIcon(pixAdd); connect(addTableButton,SIGNAL(clicked()),this,SLOT(addRecordOfTable())); QPushButton *deleteTableButton = new QPushButton(trUtf8("Delete")); QPixmap pixDelete(":/delete.png"); deleteTableButton->setIcon(pixDelete); connect(deleteTableButton,SIGNAL(clicked()),this,SLOT(deleteRecordOfTable())); QPushButton *editTableButton = new QPushButton(trUtf8("Edit")); QPixmap pixEdit(":/edit.png"); editTableButton->setIcon(pixEdit); connect(editTableButton,SIGNAL(clicked()),this,SLOT(editRecordOfTable())); QHBoxLayout *buttonTableBox = new QHBoxLayout; buttonTableBox->addWidget(addTableButton); buttonTableBox->addWidget(deleteTableButton); buttonTableBox->addWidget(editTableButton); buttonTableBox->addStretch(); //***************************************************** //SIZ TableView //***************************************************** sizView = new QTableWidget(0,6); sizView->setHorizontalHeaderLabels(QStringList()<<trUtf8("ID")<<trUtf8("P")<<trUtf8("Наименование СИЗ")<< trUtf8("Характеристика")<<trUtf8("Количество")<<trUtf8("Срок")); sizView->hideColumn(0); sizView->hideColumn(1); sizView->setColumnWidth(2,300); sizView->setColumnWidth(3,300); sizView->setAlternatingRowColors(true); QHeaderView *head = sizView->horizontalHeader(); head->setStretchLastSection(true); sizView->setSelectionMode(QAbstractItemView::SingleSelection); sizView->setSelectionBehavior(QAbstractItemView::SelectRows); sizView->setEditTriggers(QAbstractItemView::NoEditTriggers); if(indexTemp != ""){ QSqlQuery query; query.prepare("SELECT postsizname FROM postsiz WHERE postsizid = :postsizid"); query.bindValue(":postsizid",indexTemp); query.exec(); query.next(); editPostSIZ->setText(query.value(0).toString()); //editPostSIZ->setReadOnly(true); QSqlQuery queryTable; queryTable.prepare("SELECT(SELECT siznaim.siznaimname FROM siznaim WHERE siznaim.siznaimid =" " postsiztable.siznaimid),(SELECT har.harname FROM har WHERE har.harid = " "postsiztable.harid), kolvo, srok FROM postsiztable WHERE " "postsiztable.postsizid = :postsizid"); queryTable.bindValue(":postsizid",indexTemp); queryTable.exec(); int rowCount = 0; while(queryTable.next()){ sizView->insertRow(rowCount); QTableWidgetItem *itemName = new QTableWidgetItem; sizView->setItem(rowCount,2,itemName); sizView->item(rowCount,2)->setText(queryTable.value(0).toString()); QTableWidgetItem *itemHar = new QTableWidgetItem; sizView->setItem(rowCount,3,itemHar); sizView->item(rowCount,3)->setText(queryTable.value(1).toString()); QTableWidgetItem *itemKol = new QTableWidgetItem; sizView->setItem(rowCount,4,itemKol); sizView->item(rowCount,4)->setText(queryTable.value(2).toString()); QTableWidgetItem *itemSrok = new QTableWidgetItem; sizView->setItem(rowCount,5,itemSrok); sizView->item(rowCount,5)->setText(queryTable.value(3).toString()); } }else{ editPostSIZ->clear(); NumPrefix numPrefix; indexTemp = numPrefix.getPrefix("postsiz"); updateRecord = false; } QGridLayout *mainLayout = new QGridLayout; mainLayout->addLayout(labelLayout,0,0); mainLayout->addLayout(editLayout,0,1); mainLayout->addLayout(buttonTableBox,2,0,1,2); mainLayout->addWidget(sizView,3,0,1,2); if(!onlyForRead){ mainLayout->addWidget(buttonBox,4,1); editPostSIZ->selectAll(); } setLayout(mainLayout); setWindowTitle(trUtf8("Нормы СИЗ")); readSettings(); }