void MultiLayer::closeEvent( QCloseEvent *e )
{
if (confirmClose())
 {
 switch( QMessageBox::information(0,tr("QtiPlot"),
				      tr("Do you want to hide or delete <p><b>'"
					   + QString(name()) +"'</b> ?"),
				      "Delete", "Hide", "Cancel",
				      0,2) ) 
	{
    case 0:	
	 emit closedPlot(this);
	 e->accept(); 
	break;

    case 1:
	 emit hidePlot(this);
     e->ignore();
	break;

	case 2:
	  e->ignore();
	break;
    }  
	}
else
	{
	emit closedPlot(this);
	e->accept(); 
	}
}
示例#2
0
void WndDeckEditor::closeEvent(QCloseEvent *event)
{
	if (confirmClose()) {
		event->accept();
		deleteLater();
	} else
		event->ignore();
}
示例#3
0
void WndDeckEditor::actNewDeck()
{
	if (!confirmClose())
		return;

	deckModel->cleanList();
	nameEdit->setText(QString());
	commentsEdit->setText(QString());
	lastFileName = QString();
}
void TabDeckEditor::actNewDeck()
{
    if (!confirmClose())
        return;

    deckModel->cleanList();
    nameEdit->setText(QString());
    commentsEdit->setText(QString());
    hashLabel->setText(QString());
    setModified(false);
}
示例#5
0
void WndDeckEditor::actLoadDeckFromClipboard()
{
	if (!confirmClose())
		return;
	
	DlgLoadDeckFromClipboard dlg;
	if (!dlg.exec())
		return;
	
	setDeck(dlg.getDeckList());
	setWindowModified(true);
}
示例#6
0
void WndDeckEditor::actLoadDeck()
{
	if (!confirmClose())
		return;

	QFileDialog dialog(this, tr("Load deck"));
	dialog.setDirectory(settingsCache->getDeckPath());
	dialog.setNameFilters(DeckList::fileNameFilters);
	if (!dialog.exec())
		return;

	QString fileName = dialog.selectedFiles().at(0);
	DeckList::FileFormat fmt = DeckList::getFormatFromNameFilter(dialog.selectedNameFilter());
	DeckList *l = new DeckList;
	if (l->loadFromFile(fileName, fmt))
		setDeck(l, fileName, fmt);
	else
		delete l;
}
void TabDeckEditor::closeRequest()
{
    if (confirmClose())
        deleteLater();
}
void TableEditor::setupLayout()
{
    // set up agents tab
    agentsModel = new QSqlTableModel(this);
    agentsModel->setTable("agents");
    if (!tableFilter.isEmpty())
        agentsModel->setFilter(tableFilter);
    agentsModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
    agentsModel->select();

    agentsTable = new QTableView(this);
    agentsTable->setModel(agentsModel);
    agentsTable->resizeColumnsToContents();
    agentsTable->sortByColumn(0,Qt::AscendingOrder);
    agentsTable->setSortingEnabled(true);

    // set up determinations tab
    determinationsModel = new QSqlTableModel(this);
    determinationsModel->setTable("determinations");
    if (!tableFilter.isEmpty())
        determinationsModel->setFilter(tableFilter);
    determinationsModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
    determinationsModel->select();

    determinationsTable = new QTableView(this);
    determinationsTable->setModel(determinationsModel);
    determinationsTable->resizeColumnsToContents();
    determinationsTable->sortByColumn(0,Qt::AscendingOrder);
    determinationsTable->setSortingEnabled(true);

    // set up images tab
    imagesModel = new QSqlTableModel(this);
    imagesModel->setTable("images");
    if (!tableFilter.isEmpty())
        imagesModel->setFilter(tableFilter);
    imagesModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
    imagesModel->select();

    imagesTable = new QTableView(this);
    imagesTable->setModel(imagesModel);
    imagesTable->resizeColumnsToContents();
    imagesTable->sortByColumn(19,Qt::AscendingOrder);
    imagesTable->setSortingEnabled(true);

    // set up taxa tab
    taxaModel = new QSqlTableModel(this);
    taxaModel->setTable("taxa");
    if (!tableFilter.isEmpty())
        taxaModel->setFilter(tableFilter);
    taxaModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
    taxaModel->select();

    taxaTable = new QTableView(this);
    taxaTable->setModel(taxaModel);
    taxaTable->resizeColumnsToContents();
    taxaTable->sortByColumn(1,Qt::AscendingOrder);
    taxaTable->setSortingEnabled(true);

    // set up organisms tab
    organismsModel = new QSqlTableModel(this);
    organismsModel->setTable("organisms");
    if (!tableFilter.isEmpty())
        organismsModel->setFilter(tableFilter);
    organismsModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
    organismsModel->select();

    organismsTable = new QTableView(this);
    organismsTable->setModel(organismsModel);
    organismsTable->resizeColumnsToContents();
    organismsTable->sortByColumn(0,Qt::AscendingOrder);
    organismsTable->setSortingEnabled(true);

    // set up sensu tab
    sensuModel = new QSqlTableModel(this);
    sensuModel->setTable("sensu");
    if (!tableFilter.isEmpty())
        sensuModel->setFilter(tableFilter);
    sensuModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
    sensuModel->select();

    sensuTable = new QTableView(this);
    sensuTable->setModel(sensuModel);
    sensuTable->resizeColumnsToContents();
    sensuTable->sortByColumn(0,Qt::AscendingOrder);
    sensuTable->setSortingEnabled(true);

    tabWidget = new QTabWidget(this);
    tabWidget->addTab(agentsTable,"Agents");
    tabWidget->addTab(determinationsTable,"Determinations");
    tabWidget->addTab(imagesTable,"Images");
    tabWidget->addTab(taxaTable,"Names");
    tabWidget->addTab(organismsTable,"Organisms");
    tabWidget->addTab(sensuTable,"Sensu");

    submitButton = new QPushButton(tr("&Save changes"));
    submitButton->setDefault(true);
    refreshButton = new QPushButton(tr("&Revert unsaved changes\nand refresh database"));
    deleteButton = new QPushButton(tr("&Delete selected rows"));
    quitButton = new QPushButton(tr("&Close"));

    buttonBox = new QDialogButtonBox(Qt::Vertical);
    buttonBox->addButton(submitButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(deleteButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(refreshButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(quitButton, QDialogButtonBox::ActionRole);

    connect(submitButton, SIGNAL(clicked()), this, SLOT(submit())); // this needs to save (submit) all changes from all tables
    connect(refreshButton, SIGNAL(clicked()), this, SLOT(refreshAll())); // this needs to refresh all tables to their current database values
    connect(deleteButton, SIGNAL(clicked()), this, SLOT(removeSelectedRows())); // this needs to remove selected rows ONLY from current tab
    connect(quitButton, SIGNAL(clicked()), this, SLOT(confirmClose()));

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

    setWindowTitle("Table view");

    QSqlDatabase db = QSqlDatabase::database();
    db.transaction();

    QSqlQuery qry;
    qry.prepare("SELECT value FROM settings WHERE setting = (?)");
    qry.addBindValue("view.table.location");
    qry.exec();
    if (qry.next())
        restoreGeometry(qry.value(0).toByteArray());

    bool wasMaximized = false;
    qry.prepare("SELECT value FROM settings WHERE setting = (?)");
    qry.addBindValue("view.table.fullscreen");
    qry.exec();
    if (qry.next())
        wasMaximized = qry.value(0).toBool();

    if (!db.commit())
    {
        qDebug() << "Problem committing changes to database in TableEditor::setupLayout()";
        db.rollback();
    }

    if (wasMaximized)
        this->showMaximized();
}
MultiplotWidget::~MultiplotWidget() {
  confirmClose();
  
  delete ui_;
}