예제 #1
0
// ============================================================
//  QERECIPE METHODS
// ============================================================
QERecipe::QERecipe(QWidget *pParent):QWidget(pParent), QEWidget(this)
{

    qLabelRecipeDescription = new QLabel(this);
    qComboBoxRecipeList = new QComboBox(this);
    qPushButtonNew = new QPushButton(this);
    qPushButtonSave = new QPushButton(this);
    qPushButtonDelete = new QPushButton(this);
    qPushButtonApply = new QPushButton(this);
    qPushButtonRead = new QPushButton(this);
    qEConfiguredLayoutRecipeFields = new QEConfiguredLayout(this, false);


    qComboBoxRecipeList->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    qComboBoxRecipeList->setToolTip("Select recipe");
    QObject::connect(qComboBoxRecipeList, SIGNAL(currentIndexChanged(int)), this, SLOT(comboBoxRecipeSelected(int)));

    qPushButtonNew->setText("New");
    qPushButtonNew->setToolTip("Create new recipe");
    QObject::connect(qPushButtonNew, SIGNAL(clicked()), this, SLOT(buttonNewClicked()));

    qPushButtonSave->setText("Save");
    qPushButtonSave->setToolTip("Save values in the selected recipe");
    qPushButtonSave->setEnabled(false);
    QObject::connect(qPushButtonSave, SIGNAL(clicked()), this, SLOT(buttonSaveClicked()));

    qPushButtonDelete->setText("Delete");
    qPushButtonDelete->setToolTip("Delete selected recipe");
    qPushButtonDelete->setEnabled(false);
    QObject::connect(qPushButtonDelete, SIGNAL(clicked()), this, SLOT(buttonDeleteClicked()));

    qPushButtonApply->setText("Apply");
    qPushButtonApply->setToolTip("Apply values to process variables");
    qPushButtonApply->setEnabled(false);
    QObject::connect(qPushButtonApply, SIGNAL(clicked()), this, SLOT(buttonApplyClicked()));

    qPushButtonRead->setText("Read");
    qPushButtonRead->setToolTip("Read values from process variables");
    QObject::connect(qPushButtonRead, SIGNAL(clicked()), this, SLOT(buttonReadClicked()));

    qEConfiguredLayoutRecipeFields->setShowItemList(false);

    setRecipeFile("");
    setConfigurationFile("");
    setConfigurationText("");
    setConfigurationType(FROM_FILE);
    setShowRecipeList(true);
    setOptionsLayout(TOP);
    setCurrentUserType(getUserLevel());

}
예제 #2
0
// A save or restore has been requested (Probably by QEGui itself)
void saveRestoreManager::saveRestore( SaveRestoreSignal::saveRestoreOptions option )
{
    PersistanceManager* pm = profile.getPersistanceManager();

    switch( option )
    {
        // Save the application data
        case SaveRestoreSignal::SAVE:
            {
                // Start with the top level element - the QEGui application
                PMElement appElement =  pm->addNamedConfiguration( SAVERESTORE_NAME );

                // Note the number of main windows. This will determine how many main windows are expected on restore
                appElement.addValue( "MainWindows", app->getMainWindowCount() );

                // Note the current user level
                userLevelTypes meta;
                appElement.addValue ("UserLevel", QEUtilities::enumToString( meta, "userLevels", getUserLevel() ));
            }
            break;

        // First restore phase.
        // This application will create the main windows and the GUIs they contain
        case SaveRestoreSignal::RESTORE_APPLICATION:
            {
                // Get the data for this application
                PMElement QEGuiData = pm->getNamedConfiguration( SAVERESTORE_NAME );

                // If none, do nothing
                if( QEGuiData.isNull() )
                {
                    return;
                }

                // Note the current user level
                QString levelString;
                QEGuiData.getValue( "UserLevel", levelString );
                userLevelTypes meta;
                userLevelTypes::userLevels levelInt;
                bool ok;
                levelInt = (userLevelTypes::userLevels)QEUtilities::stringToEnum( meta, "userLevels", levelString, &ok );
                if( ok )
                {
                    setUserLevel( levelInt );
                }

                // Get the number of expected main windows
                int numMainWindows = 0;
                QEGuiData.getValue( "MainWindows", numMainWindows );

                // Create the main windows. They will restore themselves
                setupProfile( NULL, app->getParams()->pathList, "", app->getParams()->substitutions );
                for( int i = 0; i < numMainWindows; i++ )
                {
                    MainWindow* mw = new MainWindow( app, "", "", "", QEFormMapper::nullHandle(), false );
                    mw->show();
                }

                releaseProfile();
            }
            break;

        // Second resore phase.
        // This application has done it's work. The widgets that have been created will be able to act on the second phase
        case SaveRestoreSignal::RESTORE_QEFRAMEWORK:
            break;

    }

}