bool CommandExportToXml::finalize()
{
    // any errors?
    if ( m_error ) {
        showCritical( tr( "Error exporting Database to XML" ), tr("The database could not be exported:\n%1" ).arg( m_errorString ) );
    }
    return !m_error;
}
Esempio n. 2
0
void ApplicationCore::enterConnectingState()
{
    try {
        if (!m_controller.initializeBackEnd(CHARM_SQLITE_BACKEND_DESCRIPTOR))
            QCoreApplication::quit();
    } catch (const CharmException &e) {
        showCritical(tr("Database Backend Error"),
                     tr("The backend could not be initialized: %1").arg(e.what()));
        slotQuitApplication();
        return;
    }
    // tell storage to connect to database
    CONFIGURATION.failure = false;
    try
    {
        if (m_controller.connectToBackend()) {
            // delay switch to Connected state a bit to show the start screen:
            QTimer::singleShot(0, this, SLOT(slotGoToConnectedState()));
        } else {
            // go back to StartingUp state and reconfigure
            emit goToState(StartingUp);
        }
    } catch (const UnsupportedDatabaseVersionException &e) {
        qDebug() << e.what();
        QFileInfo info(Configuration::instance().localStorageDatabase);
        QString message = QObject::tr("<html><body>"
                                      "<p>Your current Charm database is not supported by this version. "
                                      "The error message is: %1."
                                      "You have two options here:</p><ul>"
                                      "<li>Start over with an empty database by moving or deleting your %2 folder "
                                      "then re-running this version of Charm.</li>"
                                      "<li>Load an older version of Charm that supports your current database and select "
                                      "File->Export, and save that file somewhere. Then, either rename or delete your "
                                      "%2 folder and restart this version of Charm and select File->Import from "
                                      "previous export and select the file you saved in the previous step.</li>"
                                      "</ul></body></html>").arg(
            e.what().toHtmlEscaped(), info.absoluteDir().path());
        showCritical(QObject::tr("Charm Database Error"), message);
        slotQuitApplication();
        return;
    }
}
Esempio n. 3
0
void ExcitationThread::run()
{
    emit showStatus("Generating excitation...");
    try {
        Excitation::generate( this->wrkDir, this->cfg);
        emit generated();
    } catch(QLE e) {
        emit showCritical(e.msg);
        emit showStatus("Excitation generating failed!", 2000);
        return;
    }
    emit showStatus("Excitation and inverse filter are generated!", 2000);
}
Esempio n. 4
0
void ExcitationWidget::setWorkDir(const QString& dir)
{
    this->workDir = dir;
    this->qlCfg = new QLCfg(this->workDir);
    try {
        this->lastCfg = this->qlCfg->getExcit();
        this->newCfg = this->lastCfg;
        this->mapCfgToControls();
    } catch(QLE e) {
        emit showCritical(e.msg);
        return;
    }

    emit excitInfoChanged(this->getInfoString());
}
Esempio n. 5
0
void ApplicationCore::setState(State state)
{
    if (m_state == state)
        return;
    qDebug() << "ApplicationCore::setState: going from" << StateNames[m_state]
             << "to" << StateNames[state];
    State previous = m_state;

    try {
        switch (m_state) {
        case Constructed:
            break; // ignore, but this state is never re-entered
        case StartingUp:
            leaveStartingUpState();
            break;
        case Configuring:
            leaveConfiguringState();
            break;
        case Connecting:
            leaveConnectingState();
            break;
        case Connected:
            leaveConnectedState();
            break;
        case Disconnecting:
            leaveDisconnectingState();
            break;
        case ShuttingDown:
            leaveShuttingDownState();
            break;
        default:
            Q_ASSERT_X(false, "ApplicationCore::setState",
                       "Unknown previous application state");
        }

        m_state = state;
        Q_FOREACH (auto e, m_uiElements)
            e->stateChanged(m_state);

        switch (m_state) {
        case StartingUp:
            m_model.charmDataModel()->stateChanged(previous, state);
            m_controller.stateChanged(previous, state);
            // FIXME unnecessary?
            // m_mainWindow.stateChanged(previous);
            // m_timeTracker.stateChanged( previous );
            enterStartingUpState();
            break;
        case Configuring:
            enterConfiguringState();
            break;
        case Connecting:
            m_model.charmDataModel()->stateChanged(previous, state);
            m_controller.stateChanged(previous, state);
            // FIXME unnecessary?
            // m_mainWindow.stateChanged(previous);
            // m_timeTracker.stateChanged( previous );
            enterConnectingState();
            break;
        case Connected:
            m_model.charmDataModel()->stateChanged(previous, state);
            m_controller.stateChanged(previous, state);
            // FIXME unnecessary?
            // m_mainWindow.stateChanged(previous);
            // m_timeTracker.stateChanged( previous );
            enterConnectedState();
            break;
        case Disconnecting:
            // FIXME unnecessary?
            // m_timeTracker.stateChanged( previous );
            // m_mainWindow.stateChanged(previous);
            m_model.charmDataModel()->stateChanged(previous, state);
            m_controller.stateChanged(previous, state);
            enterDisconnectingState();
            break;
        case ShuttingDown:
            // FIXME unnecessary?
            // m_timeTracker.stateChanged( previous );
            // m_mainWindow.stateChanged(previous);
            m_model.charmDataModel()->stateChanged(previous, state);
            m_controller.stateChanged(previous, state);
            enterShuttingDownState();
            break;
        default:
            Q_ASSERT_X(false, "ApplicationCore::setState",
                       "Unknown new application state");
        }
    } catch (const CharmException &e) {
        showCritical(tr("Critical Charm Problem"), e.what());
        QCoreApplication::quit();
    }
}