void MainController::load(QString filename) { LoadController zeus(filename); int athena = zeus.exec(); switch(athena) { case -1: QMessageBox::warning(0, tr("Error"), tr("FILE: Unable to open ") + filename); break; case -2: QMessageBox::warning(0, tr("Error"), tr("XML: Document not well formed") + filename); break; case -3: { QMessageBox::information(0, tr("Connection error"), tr("Guest user connect")); UserSPointer hermes(new User); hermes->setUsername("Guest"); hermes->setType(User::Viewer); } default: m_mw->setCategoryList(categories().keys()); if(categories().keys().size() > 0) setCurrentTable(categories().keys().first()); m_mw->setUserOk(UserController::currentUser()->type()); m_currentFile = filename; userChange(); break; } }
void MainController::save(QString filename) { if(filename.isEmpty()) filename = m_currentFile; else m_currentFile = filename; if(!filename.isEmpty()) { SaveController zeus(filename); int athena = zeus.exec(); switch(athena) { case -1: QMessageBox::warning(0, tr("Error"), tr("FILE: Unable to open ") + filename); break; default: QMessageBox::information(0,tr("Save"), tr("File ") + QFileInfo(m_currentFile).fileName() + tr(" saved")); break; } userChange(); } else { QMessageBox::warning(0, tr("Saving error"), tr("Enter a filename")); m_mw->saveAs(); } }
//------------------------------------------------------------------------------ // Write a value in response to user editing the widget // Request confirmation if required. // void QEGenericEdit::writeValue( qcaobject::QCaObject *, QVariant newValue ) { // If required, get confirmation from the user as to what to do int confirm = QMessageBox::Yes; if( confirmWrite ) { messageDialogPresent = true; confirm = QMessageBox::warning( this, "Confirm write", "Do you want to write this value?", QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes ); messageDialogPresent = false; } // Perform the required action. Either write the value (the default) or what ever the user requested switch( confirm ) { // Write the value and inform any derived class case QMessageBox::Yes: // Write the value { QString error; // Write the value - writeData is dispatching hook function if( !writeData( newValue, error ) ) { // write failed // Flag what dialog activity is going on so spurious 'editing finished' signals can be ignored messageDialogPresent = true; writeFailMessageDialogPresent = true; // warn user QMessageBox::warning( this, QString( "Write failed" ), error, QMessageBox::Cancel ); setFocus(); // Clear flag indicating 'editing finished' signals are due to message dialog messageDialogPresent = false; } // Write ok else { // Manage notifying user changes emit userChange( newValue, lastUserValue, lastValue ); // Clear 'isModified' flag setText( text() ); } } break; // Abort the write, revert to latest value case QMessageBox::No: // Revert the text. Note, also clears 'isModified' flag // setValue is dispatching hook function // setValue( lastValue ); break; // Don't write the value, keep editing the field case QMessageBox::Cancel: // Do nothing break; } }
void MainController::newBase() { clean(); foreach(auto hermes, UserController::users()) hermes->setType(User::Viewer); UserController::currentUser()->setType(User::Admin); m_mw->setUserOk(User::Admin); userChange(); }
/* The user has changed the spin box. */ void QESpinBox::userValueChanged( double value ) { // If the user is not changing the value, or not writing on change, do nothing if( programaticValueChange || !writeOnChange ) { return; } // Get the variable to write to QEFloating* qca = (QEFloating*)getQcaItem(0); // If a QCa object is present (if there is a variable to write to) // then write the value if( qca ) { // Write the value qca->writeFloating( value ); // Manage notifying user changes emit userChange( text(), lastUserValue, QString("%1").arg( lastValue ) ); } }