コード例 #1
0
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;
}
コード例 #2
0
ファイル: NewJoinWidget.cpp プロジェクト: lixinstar/xylms
void NewJoinWidget::createUserItem()
{
	// TODO 数据表列表
	stuComboBox = new QComboBox();
	stuComboBox->addItem("2012级信息");
	stuComboBox->setCurrentIndex(0);
	stuComboBox->setEnabled(false);
	connect(stuComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(refresh()));
	
	stuLayout = new QVBoxLayout();
	stuLayout->addWidget(stuComboBox);
	
	// 组装数据浏览 GroupBox
	stuGroupBox = new QGroupBox(tr("当前显示"));
	stuGroupBox->setLayout(stuLayout);
	
	seniorCheckBox = new QCheckBox(tr("启用自由编辑"));
	connect(seniorCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setSeniorButtonState(int)));
	submitButton = new QPushButton(tr("提交修改"));
	submitButton->setEnabled(false);
	connect(submitButton, SIGNAL(clicked()), this, SLOT(submitDataChange()));
	restoreButton = new QPushButton(tr("撤销修改"));
	restoreButton->setEnabled(false);
	connect(restoreButton, SIGNAL(clicked()), sqlModel, SLOT(revertAll()));

	seniorLayout = new QVBoxLayout();
	seniorLayout->addWidget(seniorCheckBox);
	seniorLayout->addWidget(submitButton);
	seniorLayout->addWidget(restoreButton);
	
	// TODO 组装高级操作选项的 GroupBox
	seniorGroupBox = new QGroupBox(tr("高级操作 [请谨慎]"));
	seniorGroupBox->setLayout(seniorLayout);

	addButton = new QPushButton(tr("增加成员"));
	connect(addButton, SIGNAL(clicked()), this, SLOT(addInfo()));
	changeButton = new QPushButton(tr("修改选中"));
	connect(changeButton, SIGNAL(clicked()), this, SLOT(changeInfo()));
	delButton = new QPushButton(tr("删除选中"));
	connect(delButton, SIGNAL(clicked()), this, SLOT(delInfo()));
	refreshButton = new QPushButton(tr("刷新数据"));
	connect(refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));

	buttonLayout = new QVBoxLayout();
	buttonLayout->addWidget(addButton);
	buttonLayout->addStretch();
	buttonLayout->addWidget(changeButton);
	buttonLayout->addStretch();
	buttonLayout->addWidget(delButton);
	buttonLayout->addStretch();
	buttonLayout->addWidget(refreshButton);
	
	// 组装数据操作 GroupBox
	buttonGroupBox = new QGroupBox(tr("数据操作"));
	buttonGroupBox->setLayout(buttonLayout);
}
コード例 #3
0
TableEditor::TableEditor(QWidget *parent): Editor(parent)
{
    QVBoxLayout *layout = new QVBoxLayout(this);
    setLayout(layout);

    // toolbar
    _toolbar = new QWidget(this);
    layout->addWidget(_toolbar);
    _ui_toolbar = new Ui::TableEditorToolbar;
    _ui_toolbar->setupUi(_toolbar);
    _ui_toolbar->firstPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/allLeft")));
    _ui_toolbar->previousPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/left")));
    _ui_toolbar->nextPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/right")));
    _ui_toolbar->lastPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/allRight")));

    _ui_toolbar->refreshButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/refresh")));

    _ui_toolbar->addRowButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/general/add")));
    _ui_toolbar->deleteRowButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/general/remove")));

    _ui_toolbar->commitButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/checked")));
    _ui_toolbar->rollbackButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/rollback")));

    _ui_toolbar->dumpDataButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/export")));

    _tableView = new QTableView(this);
    _tableModel = new QSqlTableModel(_tableView /* TODO database connection */);
    _tableView->setModel(_tableModel);
    layout->addWidget(_tableView);

    // connections
    connect(_ui_toolbar->commitButton, SIGNAL(clicked()), _tableModel, SLOT(submitAll()));
    connect(_ui_toolbar->rollbackButton, SIGNAL(clicked()), _tableModel, SLOT(revertAll()));
    connect(_ui_toolbar->addRowButton, SIGNAL(clicked()), this, SLOT(addRow()));
    connect(_ui_toolbar->deleteRowButton, SIGNAL(clicked()), this, SLOT(deleteRows()));
    connect(_ui_toolbar->refreshButton, SIGNAL(clicked()), _tableModel, SLOT(select()));



    connect(_ui_toolbar->toolButtonExportImage, SIGNAL(clicked()),_imageView, SLOT(exportImage()));
    connect(_ui_toolbar->toolButtonZoomIn, SIGNAL(clicked()),_imageView,SLOT(zoomIn()));
    connect(_ui_toolbar->toolButtonZoomOut, SIGNAL(clicked()),_imageView, SLOT(zoomOut()));
    connect(_ui_toolbar->toolButtonFitToScreen, SIGNAL(clicked()),_imageView, SLOT(fitToScreen()));
    connect(_ui_toolbar->toolButtonOriginalSize, SIGNAL(clicked()),_imageView, SLOT(resetToOriginalSize()));
    connect(_ui_toolbar->toolButtonBackground, SIGNAL(toggled()),_imageView, SLOT(setViewBackground()));
    connect(_ui_toolbar->toolButtonOutline, SIGNAL(toggled()),_imageView, SLOT(setViewOutline()));
    connect(_ui_toolbar->toolButtonPlayPause, SIGNAL(clicked()),this, SLOT(playToggled()));
    connect(_file, SIGNAL(imageSizeChanged()),this, SLOT(imageSizeUpdated()));
    connect(_file, SIGNAL(openFinished()),_imageView, SLOT(createScene()));
    connect(_file, SIGNAL(openFinished()),this, SLOT(updateToolButtons()));
    connect(_file, SIGNAL(aboutToReload()),_imageView, SLOT(reset()));
    connect(_file, SIGNAL(reloadFinished()),_imageView, SLOT(createScene()));
    connect(_file, SIGNAL(isPausedChanged()),this, SLOT(updatePauseAction()));
    connect(_imageView, SIGNAL(scaleFactorChanged()),this, SLOT(scaleFactorUpdate()));
}
コード例 #4
0
TableEditor::TableEditor(const QString& sConnectionName, const QString& sDataName, QWidget *parent)
   : QDialog(parent)
{
   QHBoxLayout *mainLayout = new QHBoxLayout;

   model = new QSqlTableModel( this, QSqlDatabase::database(sConnectionName) );
   model->setTable(sDataName);
   model->setEditStrategy(QSqlTableModel::OnManualSubmit);
   model->select();
   //!@todo There is a parameter definition in the system already.  Need to
   //!      get that into here and populate the nice names as the column 
   //!      headers.
   //! model->setHeaderData(0, Qt::Horizontal, tr("Nice Name"));
   QTableView *view = new QTableView;
   view->setModel(model);
   // Resizing takes a lot of time...
   //view->resizeColumnsToContents();
   mainLayout->addWidget(view);

#  if defined(USE_MODIFICATION_BUTTONS)
   {
      submitButton = new QPushButton(tr("Submit"));
      submitButton->setDefault(true);
      insertRowButton = new QPushButton(tr("&Insert Row"));
      revertButton = new QPushButton(tr("&Revert"));
      quitButton = new QPushButton(tr("Quit"));

      buttonBox = new QDialogButtonBox(Qt::Vertical);
      buttonBox->addButton(submitButton, QDialogButtonBox::ActionRole);
      buttonBox->addButton(revertButton, QDialogButtonBox::ActionRole);
      buttonBox->addButton(insertRowButton, QDialogButtonBox::ActionRole);
      buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
      mainLayout->addWidget(buttonBox);

      connect(submitButton, SIGNAL(clicked()), this, SLOT(submit()));
      connect(revertButton, SIGNAL(clicked()), model, SLOT(revertAll()));
      connect(insertRowButton, SIGNAL(clicked()), this, SLOT(insertRow()));
      connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
   }
#  endif

   setLayout(mainLayout);

   setWindowTitle(tr("Cached Table"));
}
コード例 #5
0
ファイル: qsqltablemodel.cpp プロジェクト: Fale/qtmoko
/*!
    Populates the model with data from the table that was set via setTable(), using the
    specified filter and sort condition, and returns true if successful; otherwise
    returns false.

    \sa setTable(), setFilter(), selectStatement()
*/
bool QSqlTableModel::select()
{
    Q_D(QSqlTableModel);
    QString query = selectStatement();
    if (query.isEmpty())
        return false;

    revertAll();
    QSqlQuery qu(query, d->db);
    setQuery(qu);

    if (!qu.isActive()) {
        // something went wrong - revert to non-select state
        d->initRecordAndPrimaryIndex();
        return false;
    }
    return true;
}
コード例 #6
0
ファイル: tableeditor.cpp プロジェクト: Afreeca/qt
//! [0]
TableEditor::TableEditor(const QString &tableName, QWidget *parent)
    : QWidget(parent)
{
    model = new QSqlTableModel(this);
    model->setTable(tableName);
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    model->select();

    model->setHeaderData(0, Qt::Horizontal, tr("ID"));
    model->setHeaderData(1, Qt::Horizontal, tr("First name"));
    model->setHeaderData(2, Qt::Horizontal, tr("Last name"));

//! [0] //! [1]
    QTableView *view = new QTableView;
    view->setModel(model);
    view->resizeColumnsToContents();
//! [1]

//! [2]
    submitButton = new QPushButton(tr("Submit"));
    submitButton->setDefault(true);
    revertButton = new QPushButton(tr("&Revert"));
    quitButton = new QPushButton(tr("Quit"));

    buttonBox = new QDialogButtonBox(Qt::Vertical);
    buttonBox->addButton(submitButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(revertButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
//! [2]

//! [3]
    connect(submitButton, SIGNAL(clicked()), this, SLOT(submit()));
    connect(revertButton, SIGNAL(clicked()), model, SLOT(revertAll()));
    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
//! [3]

//! [4]
    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(view);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

    setWindowTitle(tr("Cached Table"));
}
コード例 #7
0
ファイル: tableeditor.cpp プロジェクト: l0ner/neurohelper
TableEditor::TableEditor(const QString &tableName, QWidget *parent) : QDialog(parent) {
    model = new QSqlTableModel(this);
    model->setTable(tableName);
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    model->select();

    view = new QTableView;
    view->setModel(model);
    view->setSelectionBehavior( QAbstractItemView::SelectRows );
    // view->hideColumn(1);

    quitButton = new QPushButton(tr("Quit"));
    submitButton = new QPushButton(tr("Submit"));
    submitButton->setDefault(true);
    addrowButton = new QPushButton(tr("Add Record"));
    delrowButton = new QPushButton(tr("Remove Record"));
    revertButton = new QPushButton(tr("&Revert"));

    buttonBox = new QDialogButtonBox(Qt::Vertical);
    buttonBox->addButton(addrowButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(delrowButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(revertButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(submitButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);

    connect(submitButton, SIGNAL(clicked()), this, SLOT(submit()));
    connect(addrowButton, SIGNAL(clicked()), this, SLOT(addRow()));
    connect(delrowButton, SIGNAL(clicked()), this, SLOT(delRow()));
    connect(revertButton, SIGNAL(clicked()), model, SLOT(revertAll()));
    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(view);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

    setWindowTitle(tr("Table view: ") + tableName );
}
コード例 #8
0
ファイル: qsqltablemodel.cpp プロジェクト: Fale/qtmoko
/*!
    Sets the strategy for editing values in the database to \a
    strategy.

    This will revert any pending changes.

    \sa editStrategy(), revertAll()
*/
void QSqlTableModel::setEditStrategy(EditStrategy strategy)
{
    Q_D(QSqlTableModel);
    revertAll();
    d->strategy = strategy;
}
コード例 #9
0
ファイル: qsqltablemodel.cpp プロジェクト: Fale/qtmoko
/*!
    This reimplemented slot is called by the item delegates when the
    user canceled editing the current row.

    Reverts the changes if the model's strategy is set to
    OnRowChange. Does nothing for the other edit strategies.

    Use revertAll() to revert all pending changes for the
    OnManualSubmit strategy or revertRow() to revert a specific row.

    \sa submit(), submitAll(), revertRow(), revertAll()
*/
void QSqlTableModel::revert()
{
    Q_D(QSqlTableModel);
    if (d->strategy == OnRowChange)
        revertAll();
}
コード例 #10
0
ファイル: dialogvibsotr.cpp プロジェクト: roandbox/profimax
void DialogVibSotr::submitAll(){
	if (!model->submitAll()){
		revertAll();
		QMessageBox::critical(0,"",tr("Ошибка ввода данных"));
	}
}