~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/plugins/projectexplorer/projectexplorer.cpp

  • Committer: Timo Jyrinki
  • Date: 2013-12-02 09:16:15 UTC
  • mfrom: (1.1.29)
  • Revision ID: timo.jyrinki@canonical.com-20131202091615-xbj1os1f604ber1m
New upstream release candidate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
#include <coreplugin/fileutils.h>
116
116
#include <coreplugin/removefiledialog.h>
117
117
#include <texteditor/findinfiles.h>
 
118
#include <utils/fileutils.h>
 
119
#include <utils/parameteraction.h>
118
120
#include <utils/qtcassert.h>
119
 
#include <utils/parameteraction.h>
120
121
 
121
122
#include <QtPlugin>
122
123
#include <QDebug>
1000
1001
    VariableManager::registerVariable(Constants::VAR_CURRENTKIT_ID, tr("The currently active kit's id."));
1001
1002
    VariableManager::registerVariable(Constants::VAR_CURRENTBUILD_NAME, tr("The currently active build configuration's name."));
1002
1003
    VariableManager::registerVariable(Constants::VAR_CURRENTBUILD_TYPE, tr("The currently active build configuration's type."));
 
1004
    VariableManager::registerFileVariables(Constants::VAR_CURRENTSESSION_PREFIX, tr("File where current session is saved."));
 
1005
    VariableManager::registerVariable(Constants::VAR_CURRENTSESSION_NAME, tr("Name of current session."));
1003
1006
 
1004
1007
    connect(VariableManager::instance(), SIGNAL(variableUpdateRequested(QByteArray)),
1005
1008
            this, SLOT(updateVariable(QByteArray)));
1148
1151
        } else {
1149
1152
            VariableManager::remove(variable);
1150
1153
        }
 
1154
    } else if (variable == Constants::VAR_CURRENTSESSION_NAME) {
 
1155
        if (!SessionManager::activeSession().isEmpty())
 
1156
            VariableManager::insert(variable, SessionManager::activeSession());
 
1157
        else
 
1158
            VariableManager::remove(variable);
 
1159
    } else if (Core::VariableManager::isFileVariable(
 
1160
                   variable, ProjectExplorer::Constants::VAR_CURRENTSESSION_PREFIX)) {
 
1161
        if (!SessionManager::activeSession().isEmpty()) {
 
1162
            VariableManager::insert(variable, Core::VariableManager::fileVariableValue(variable,
 
1163
                 ProjectExplorer::Constants::VAR_CURRENTSESSION_PREFIX,
 
1164
                 SessionManager::sessionNameToFileName(SessionManager::activeSession()).toFileInfo()));
 
1165
        } else {
 
1166
            VariableManager::remove(variable);
 
1167
        }
1151
1168
    } else {
1152
1169
        QString projectName;
1153
1170
        QString projectFilePath;
1159
1176
                projectFilePath = doc->filePath();
1160
1177
            if (Target *target = project->activeTarget()) {
1161
1178
                kit = target->kit();
1162
 
                if (BuildConfiguration *buildConfiguration = target->activeBuildConfiguration()) {
 
1179
                if (BuildConfiguration *buildConfiguration = target->activeBuildConfiguration())
1163
1180
                    buildConfigurationName = buildConfiguration->displayName();
1164
 
                }
1165
1181
            }
1166
1182
        }
1167
1183
        ProjectMacroExpander expander(projectFilePath, projectName, kit, buildConfigurationName);
1339
1355
        QTC_ASSERT(!fileName.isEmpty(), continue);
1340
1356
 
1341
1357
        QFileInfo fi = QFileInfo(fileName);
1342
 
        QString canonicalFilePath = fi.canonicalFilePath();
 
1358
        QString filePath = fileName;
 
1359
        if (fi.exists()) // canonicalFilePath will be empty otherwise!
 
1360
            filePath = fi.canonicalFilePath();
1343
1361
        bool found = false;
1344
1362
        foreach (Project *pi, SessionManager::projects()) {
1345
 
            if (canonicalFilePath == pi->projectFilePath()) {
 
1363
            if (filePath == pi->projectFilePath()) {
1346
1364
                found = true;
1347
1365
                break;
1348
1366
            }
1358
1376
            foreach (IProjectManager *manager, projectManagers) {
1359
1377
                if (manager->mimeType() == mt.type()) {
1360
1378
                    QString tmp;
1361
 
                    if (Project *pro = manager->openProject(canonicalFilePath, &tmp)) {
 
1379
                    if (Project *pro = manager->openProject(filePath, &tmp)) {
1362
1380
                        if (pro->restoreSettings()) {
1363
1381
                            connect(pro, SIGNAL(fileListChanged()), this, SIGNAL(fileListChanged()));
1364
1382
                            SessionManager::addProject(pro);
1660
1678
 
1661
1679
void ProjectExplorerPlugin::showRunErrorMessage(const QString &errorMessage)
1662
1680
{
1663
 
    if (errorMessage.isNull()) {
1664
 
        // a error occured, but message was not set
1665
 
        QMessageBox::critical(ICore::mainWindow(), tr("Unknown error"), errorMessage);
1666
 
    } else if (errorMessage.isEmpty()) {
1667
 
        // a error, but the message was set to empty
1668
 
        // hack for qml observer warning, show nothing at all
1669
 
    } else {
1670
 
        QMessageBox::critical(ICore::mainWindow(), tr("Could Not Run"), errorMessage);
1671
 
    }
 
1681
    // Empty, non-null means 'canceled' (custom executable dialog for libraries), whereas
 
1682
    // empty, null means an error occurred, but message was not set
 
1683
    if (!errorMessage.isEmpty() || errorMessage.isNull())
 
1684
        QMessageBox::critical(ICore::mainWindow(), errorMessage.isNull() ? tr("Unknown error") : tr("Could Not Run"), errorMessage);
1672
1685
}
1673
1686
 
1674
1687
void ProjectExplorerPlugin::startRunControl(RunControl *runControl, RunMode runMode)