bool DBBrowserDB::close() { if(_db) { if (getDirty()) { QMessageBox::StandardButton reply = QMessageBox::question(0, QApplication::applicationName(), QObject::tr("Do you want to save the changes " "made to the database file %1?").arg(curDBFilename), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); // If the user clicked the cancel button stop here and return false if(reply == QMessageBox::Cancel) return false; // If he didn't it was either yes or no if(reply == QMessageBox::Yes) saveAll(); else revertAll(); //not really necessary, I think... but will not hurt. } sqlite3_close(_db); } _db = 0; objMap.clear(); savepointList.clear(); emit dbChanged(getDirty()); // Return true to tell the calling function that the closing wasn't cancelled by the user return true; }
PropertyModel::PropertyModel(TracksModel *database, QObject *parent): QAbstractItemModel(parent), mDatabase(database), mRecord(NULL) { connect(mDatabase, SIGNAL(dbChanged()), this, SLOT(updateRowList())); connect(mDatabase, SIGNAL(recordChanged()), this, SLOT(updateRecord())); connect(mDatabase, SIGNAL(recordSelected(Record*)), this, SLOT(setRecord(Record*))); updateRowList(); }
bool DBBrowserDB::save(const QString& pointname) { if(!isOpen() || savepointList.contains(pointname) == false) return false; if(_db) { QString query = QString("RELEASE %1;").arg(pointname); sqlite3_exec(_db, query.toUtf8(), NULL,NULL,NULL); savepointList.removeAll(pointname); emit dbChanged(getDirty()); } return true; }
bool DBBrowserDB::setRestorePoint(const QString& pointname) { if(!isOpen()) return false; if(savepointList.contains(pointname)) return true; if(_db) { QString query = QString("SAVEPOINT %1;").arg(pointname); sqlite3_exec(_db, query.toUtf8(), NULL, NULL, NULL); savepointList.append(pointname); emit dbChanged(getDirty()); } return true; }
int DB::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: dbChanged(); break; case 1: { bool _r = addRow((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 2: { QString _r = dictName((*reinterpret_cast< QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 3: removeRow((*reinterpret_cast< QString(*)>(_a[1]))); break; default: ; } _id -= 4; } return _id; }
void ViewToolBar::dbComboModified(int indx) { if(indx > 0) emit dbChanged(dbSelect->currentText()); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), mSelected(NULL) { ui->setupUi(this); connect(ui->findButton, SIGNAL(clicked(bool)), this, SLOT(onLeftButton())); connect(ui->infoButton, SIGNAL(clicked(bool)), this, SLOT(onRightButton())); connect(ui->filterTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onFilterSelected())); connect(ui->filterComboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(onFilterChanged())); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(onFilterChanged())); QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("database.sqlite"); db.open(); mProgress = new QProgressDialog(this); mProgress->setWindowTitle(tr("Resistance is futile")); mPrinter = new PrintHelper(this); mPrintDialog = new PrintSelectDialog(this); mTracks = new TracksModel(this); mFiles = new FilesModel(mTracks, this); mProperties = new PropertyModel(mTracks, this); mTags = new TagsModel(mTracks, this); mFilter = new FilterModel(mTracks, this); mFilter->setSourceModel(mTracks); mSettings = new SettingsDialog(mTracks, this); connect(mTracks, SIGNAL(progressStart(int,QString)), this, SLOT(onProgressInit(int,QString))); connect(mTracks, SIGNAL(progress(int)), mProgress, SLOT(setValue(int))); connect(mTracks, SIGNAL(progressEnd()), mProgress, SLOT(reset())); ui->dbView->setModel(mFilter); connect(ui->dbView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(onTrackSelected(QModelIndex))); connect(mTracks, SIGNAL(recordSelected(Record*)), this, SLOT(onSelected(Record*))); connect(mTracks, SIGNAL(dbChanged()), this, SLOT(onDBChanged())); connect(mTracks, SIGNAL(tagsChanged()), this, SLOT(onTagsChanged())); connect(mTracks, SIGNAL(recordChanged()), this, SLOT(onRecordChanged())); connect(mTracks, SIGNAL(recordSelected(Record*)), this, SLOT(onRecordChanged())); connect(ui->filesView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onFileActivated(QModelIndex))); connect(ui->actionSaveTrack, SIGNAL(triggered(bool)), mTracks, SLOT(saveRecord())); connect(ui->actionNewTrack, SIGNAL(triggered(bool)), mTracks, SLOT(newRecord())); connect(ui->actionCancelChanges, SIGNAL(triggered(bool)), mTracks, SLOT(revertRecord())); connect(ui->actionPlayTrack, SIGNAL(triggered(bool)), this, SLOT(onPlayPlus())); connect(ui->actionPlayTrackMinus, SIGNAL(triggered(bool)), this, SLOT(onPlayMinus())); connect(ui->actionPrint, SIGNAL(triggered(bool)), this, SLOT(onPrint())); connect(ui->actionAddFolder, SIGNAL(triggered(bool)), this, SLOT(onSetStorage())); connect(ui->actionExport, SIGNAL(triggered(bool)), this, SLOT(onExport())); connect(ui->actionImport, SIGNAL(triggered(bool)), this, SLOT(onImport())); connect(ui->actionSettings, SIGNAL(triggered(bool)), this, SLOT(onSettings())); connect(ui->actionFilterFilesOnly, SIGNAL(toggled(bool)), this, SLOT(onFFilter(bool))); connect(ui->actionFilterFullInfo, SIGNAL(toggled(bool)), this, SLOT(onIFFilter(bool))); connect(ui->actionFilterInfoOnly, SIGNAL(toggled(bool)), this, SLOT(onIFilter(bool))); connect(ui->addTagButton, SIGNAL(clicked(bool)), this, SLOT(onAddTag())); connect(ui->removeTagButton, SIGNAL(clicked(bool)), this, SLOT(onRemoveTag())); connect(ui->addFileButton, SIGNAL(clicked(bool)), this, SLOT(onAddFile())); connect(ui->deleteFileButton, SIGNAL(clicked(bool)), this, SLOT(onDeleteFile())); connect(ui->moveFileButton, SIGNAL(clicked(bool)), this, SLOT(onMoveFile())); connect(ui->autoFileButton, SIGNAL(clicked(bool)), this, SLOT(onAutoFile())); // no logic yet ui->moveFileButton->setVisible(false); ui->filesView->setModel(mFiles); ui->propertyView->setModel(mProperties); ui->propertyView->setItemDelegateForColumn( PropertyModel::valueColumn, new ComboCheckBoxDelegate(this, ", ")); ui->tagsView->setModel(mTags); load(); }
// Remember which database is selected void QgsSpatiaLiteSourceSelect::on_cmbConnections_activated( int ) { dbChanged(); }
void ClientSocket::readOrder(QDataStream &in) { quint32 orderNO = 0; quint16 seatNO = 0; QString mac; QDate date; QTime time; qreal discount = 0; qreal total = 0; QString name; qreal price; quint16 num; QSqlQuery query; in >> orderNO >>seatNO >> mac; qDebug() << QString("%1").arg(orderNO) << QString("%1").arg(seatNO); QDateTime *datatime=new QDateTime(QDateTime::currentDateTime()); date = datatime->date(); time = datatime->time(); quint32 flag; while(in >> flag, flag != 0xFFFF) { in >> name >> price >> num; total += price * num; qDebug() << QString("%1").arg(name) << QString("%1").arg(price) << QString("%1").arg(num); query.exec("CREATE TABLE IF NOT EXISTS orderItems(orderNO INTEGER key, name TEXT, price REAL, num INTEGER)"); query.prepare("INSERT INTO orderItems(orderNO, name, price, num) VALUES (?, ?, ?, ?)"); query.addBindValue(orderNO); query.addBindValue(name); query.addBindValue(price); query.addBindValue(num); query.exec(); } query.exec("CREATE TABLE IF NOT EXISTS orderList(orderNO INTEGER key, seatNO INTEGER, mac TEXT, date DATE, time TIME, discount REAL, total REAL, pay INTEGER)"); query.prepare("SELECT * FROM orderList WHERE orderNO = ?"); query.addBindValue(orderNO); query.exec(); if (query.next()) { qreal preTotal = query.value(6).toReal(); total += preTotal; query.prepare("UPDATE orderList SET total = ? WHERE orderNO = ?"); query.addBindValue(total); query.addBindValue(orderNO); query.exec(); } else { query.prepare("INSERT INTO orderList(orderNO, seatNO, mac, date, time, discount, total, pay) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); query.addBindValue(orderNO); query.addBindValue(seatNO); query.addBindValue(mac); query.addBindValue(date); query.addBindValue(time); query.addBindValue(discount); query.addBindValue(total); query.addBindValue(0); query.exec(); } emit dbChanged(); }