From 8f22417244c2683b7c8bd6c64a7501ab7efe0b72 Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 22 Apr 2009 14:52:35 +0200 Subject: [PATCH 01/17] Refactoring: Move QtVersionManager to ProjectExplorer. The Debugger, cmake and Qt4 plugin all need it. More refactoring to it coming. --- .../ProjectExplorer.pluginspec | 1 + .../projectexplorer/projectexplorer.pro | 10 +- .../projectexplorer_dependencies.pri | 1 + .../projectexplorerconstants.h | 5 +- .../qtversionmanager.cpp | 228 +++++++++--------- .../qtversionmanager.h | 22 +- .../qtversionmanager.ui | 4 +- .../showbuildlog.ui | 0 src/plugins/qt4projectmanager/makestep.cpp | 3 +- src/plugins/qt4projectmanager/makestep.h | 5 +- .../qt4projectmanager/profilereader.cpp | 2 + src/plugins/qt4projectmanager/profilereader.h | 5 +- .../qt4projectmanager/projectloadwizard.cpp | 4 +- .../qt4projectmanager/projectloadwizard.h | 10 +- src/plugins/qt4projectmanager/qmakestep.cpp | 2 +- src/plugins/qt4projectmanager/qt4nodes.cpp | 1 + src/plugins/qt4projectmanager/qt4project.cpp | 2 +- src/plugins/qt4projectmanager/qt4project.h | 4 +- .../qt4projectconfigwidget.cpp | 6 +- .../qt4projectmanager/qt4projectmanager.cpp | 4 +- .../qt4projectmanager/qt4projectmanager.h | 4 +- .../qt4projectmanager/qt4projectmanager.pro | 8 +- .../qt4projectmanagerconstants.h | 5 - .../qt4projectmanagerplugin.cpp | 3 +- .../qt4projectmanagerplugin.h | 9 +- .../qt4projectmanager/qt4runconfiguration.cpp | 1 + 26 files changed, 185 insertions(+), 164 deletions(-) rename src/plugins/{qt4projectmanager => projectexplorer}/qtversionmanager.cpp (86%) rename src/plugins/{qt4projectmanager => projectexplorer}/qtversionmanager.h (95%) rename src/plugins/{qt4projectmanager => projectexplorer}/qtversionmanager.ui (97%) rename src/plugins/{qt4projectmanager => projectexplorer}/showbuildlog.ui (100%) diff --git a/src/plugins/projectexplorer/ProjectExplorer.pluginspec b/src/plugins/projectexplorer/ProjectExplorer.pluginspec index eb8ea81324e..a9390c57afa 100644 --- a/src/plugins/projectexplorer/ProjectExplorer.pluginspec +++ b/src/plugins/projectexplorer/ProjectExplorer.pluginspec @@ -21,6 +21,7 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 5df19ebb034..d6b1c8c8b43 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -58,7 +58,8 @@ HEADERS += projectexplorer.h \ buildparserfactory.h\ gccparser.h\ msvcparser.h\ - filewatcher.h + filewatcher.h\ + qtversionmanager.h SOURCES += projectexplorer.cpp \ projectwindow.cpp \ buildmanager.cpp \ @@ -105,7 +106,8 @@ SOURCES += projectexplorer.cpp \ buildparserfactory.cpp \ gccparser.cpp\ msvcparser.cpp\ - filewatcher.cpp + filewatcher.cpp\ + qtversionmanager.cpp FORMS += dependenciespanel.ui \ buildsettingspropertiespage.ui \ processstep.ui \ @@ -114,7 +116,9 @@ FORMS += dependenciespanel.ui \ sessiondialog.ui \ projectwizardpage.ui \ buildstepspage.ui \ - removefiledialog.ui + removefiledialog.ui\ + qtversionmanager.ui\ + showbuildlog.ui win32 { SOURCES += applicationlauncher_win.cpp \ winguiprocess.cpp diff --git a/src/plugins/projectexplorer/projectexplorer_dependencies.pri b/src/plugins/projectexplorer/projectexplorer_dependencies.pri index 674c8bbb362..b4bb9a43826 100644 --- a/src/plugins/projectexplorer/projectexplorer_dependencies.pri +++ b/src/plugins/projectexplorer/projectexplorer_dependencies.pri @@ -3,3 +3,4 @@ include(../../plugins/quickopen/quickopen.pri) include(../../plugins/find/find.pri) include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/texteditor/texteditor.pri) +include(../../plugins/help/help.pri) diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 77ea8d8292e..0a749cc7bd5 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -177,7 +177,10 @@ const char * const RESOURCE_MIMETYPE = "application/vnd.nokia.xml.qt.resource"; const char * const BUILD_PARSER_MSVC = "BuildParser.MSVC"; const char * const BUILD_PARSER_GCC = "BuildParser.Gcc"; - +//Qt4 settings pages +const char * const QT_CATEGORY = "Qt4"; +const char * const QTVERSION_PAGE = "Qt Versions"; +const char * const BUILD_ENVIRONMENT_PAGE = "Build Environments"; } // namespace Constants } // namespace ProjectExplorer diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/projectexplorer/qtversionmanager.cpp similarity index 86% rename from src/plugins/qt4projectmanager/qtversionmanager.cpp rename to src/plugins/projectexplorer/qtversionmanager.cpp index 4b3a2b344ad..0e8c7bc7edf 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/projectexplorer/qtversionmanager.cpp @@ -29,8 +29,9 @@ #include "qtversionmanager.h" -#include "qt4projectmanagerconstants.h" +#include "projectexplorerconstants.h" #include "ui_showbuildlog.h" +#include "ui_qtversionmanager.h" #include #include @@ -56,9 +57,8 @@ #include #include -using namespace Qt4ProjectManager::Internal; - -using ProjectExplorer::Environment; +using namespace ProjectExplorer; +using namespace ProjectExplorer::Internal; static const char *QtVersionsSectionName = "QtVersions"; static const char *defaultQtVersionKey = "DefaultQtVersion"; @@ -391,18 +391,19 @@ QtDirWidget::QtDirWidget(QWidget *parent, QList versions, int defau } - m_ui.setupUi(this); - m_ui.qtPath->setExpectedKind(Core::Utils::PathChooser::Directory); - m_ui.qtPath->setPromptDialogTitle(tr("Select QTDIR")); - m_ui.mingwPath->setExpectedKind(Core::Utils::PathChooser::Directory); - m_ui.qtPath->setPromptDialogTitle(tr("Select the Qt Directory")); + m_ui = new Internal::Ui::QtVersionManager(); + m_ui->setupUi(this); + m_ui->qtPath->setExpectedKind(Core::Utils::PathChooser::Directory); + m_ui->qtPath->setPromptDialogTitle(tr("Select QTDIR")); + m_ui->mingwPath->setExpectedKind(Core::Utils::PathChooser::Directory); + m_ui->qtPath->setPromptDialogTitle(tr("Select the Qt Directory")); - m_ui.addButton->setIcon(QIcon(Core::Constants::ICON_PLUS)); - m_ui.delButton->setIcon(QIcon(Core::Constants::ICON_MINUS)); + m_ui->addButton->setIcon(QIcon(Core::Constants::ICON_PLUS)); + m_ui->delButton->setIcon(QIcon(Core::Constants::ICON_MINUS)); for (int i = 0; i < m_versions.count(); ++i) { const QtVersion * const version = m_versions.at(i); - QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.qtdirList); + QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList); item->setText(0, version->name()); item->setText(1, QDir::toNativeSeparators(version->path())); item->setData(0, Qt::UserRole, version->uniqueId()); @@ -416,41 +417,41 @@ QtDirWidget::QtDirWidget(QWidget *parent, QList versions, int defau item->setData(2, Qt::DecorationRole, QIcon()); } - m_ui.defaultCombo->addItem(version->name()); + m_ui->defaultCombo->addItem(version->name()); if (i == m_defaultVersion) - m_ui.defaultCombo->setCurrentIndex(i); + m_ui->defaultCombo->setCurrentIndex(i); } - connect(m_ui.nameEdit, SIGNAL(textEdited(const QString &)), + connect(m_ui->nameEdit, SIGNAL(textEdited(const QString &)), this, SLOT(updateCurrentQtName())); - connect(m_ui.qtPath, SIGNAL(changed()), + connect(m_ui->qtPath, SIGNAL(changed()), this, SLOT(updateCurrentQtPath())); - connect(m_ui.mingwPath, SIGNAL(changed()), + connect(m_ui->mingwPath, SIGNAL(changed()), this, SLOT(updateCurrentMingwDirectory())); - connect(m_ui.addButton, SIGNAL(clicked()), + connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addQtDir())); - connect(m_ui.delButton, SIGNAL(clicked()), + connect(m_ui->delButton, SIGNAL(clicked()), this, SLOT(removeQtDir())); - connect(m_ui.qtPath, SIGNAL(browsingFinished()), + connect(m_ui->qtPath, SIGNAL(browsingFinished()), this, SLOT(onQtBrowsed())); - connect(m_ui.mingwPath, SIGNAL(browsingFinished()), + connect(m_ui->mingwPath, SIGNAL(browsingFinished()), this, SLOT(onMingwBrowsed())); - connect(m_ui.qtdirList, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), + connect(m_ui->qtdirList, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(versionChanged(QTreeWidgetItem *, QTreeWidgetItem *))); - connect(m_ui.defaultCombo, SIGNAL(currentIndexChanged(int)), + connect(m_ui->defaultCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(defaultChanged(int))); - connect(m_ui.msvcComboBox, SIGNAL(currentIndexChanged(int)), + connect(m_ui->msvcComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(msvcVersionChanged())); - connect(m_ui.rebuildButton, SIGNAL(clicked()), + connect(m_ui->rebuildButton, SIGNAL(clicked()), this, SLOT(buildDebuggingHelper())); - connect(m_ui.showLogButton, SIGNAL(clicked()), + connect(m_ui->showLogButton, SIGNAL(clicked()), this, SLOT(showDebuggingBuildLog())); showEnvironmentPage(0); @@ -460,43 +461,44 @@ QtDirWidget::QtDirWidget(QWidget *parent, QList versions, int defau void QtDirWidget::buildDebuggingHelper() { // Find the qt version for this button.. - QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem(); + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); if (!currentItem) return; - int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem); + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); QtVersion *version = m_versions[currentItemIndex]; QString result = m_versions.at(currentItemIndex)->buildDebuggingHelperLibrary(); currentItem->setData(2, Qt::UserRole, result); if (version->hasDebuggingHelper()) { - m_ui.debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png")); } else { - m_ui.debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png")); } - m_ui.showLogButton->setEnabled(true); + m_ui->showLogButton->setEnabled(true); } void QtDirWidget::showDebuggingBuildLog() { - QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem(); + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); if (!currentItem) return; - int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem); + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); QDialog dlg; Ui_ShowBuildLog ui; ui.setupUi(&dlg); - ui.log->setPlainText(m_ui.qtdirList->topLevelItem(currentItemIndex)->data(2, Qt::UserRole).toString()); + ui.log->setPlainText(m_ui->qtdirList->topLevelItem(currentItemIndex)->data(2, Qt::UserRole).toString()); dlg.exec(); } QtDirWidget::~QtDirWidget() { qDeleteAll(m_versions); + delete m_ui; } void QtDirWidget::addQtDir() @@ -504,31 +506,31 @@ void QtDirWidget::addQtDir() QtVersion *newVersion = new QtVersion(m_specifyNameString, m_specifyPathString); m_versions.append(newVersion); - QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.qtdirList); + QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList); item->setText(0, newVersion->name()); item->setText(1, QDir::toNativeSeparators(newVersion->path())); item->setData(0, Qt::UserRole, newVersion->uniqueId()); item->setData(2, Qt::DecorationRole, QIcon()); - m_ui.qtdirList->setCurrentItem(item); + m_ui->qtdirList->setCurrentItem(item); - m_ui.nameEdit->setText(newVersion->name()); - m_ui.qtPath->setPath(newVersion->path()); - m_ui.defaultCombo->addItem(newVersion->name()); - m_ui.nameEdit->setFocus(); - m_ui.nameEdit->selectAll(); + m_ui->nameEdit->setText(newVersion->name()); + m_ui->qtPath->setPath(newVersion->path()); + m_ui->defaultCombo->addItem(newVersion->name()); + m_ui->nameEdit->setFocus(); + m_ui->nameEdit->selectAll(); } void QtDirWidget::removeQtDir() { - QTreeWidgetItem *item = m_ui.qtdirList->currentItem(); - int index = m_ui.qtdirList->indexOfTopLevelItem(item); + QTreeWidgetItem *item = m_ui->qtdirList->currentItem(); + int index = m_ui->qtdirList->indexOfTopLevelItem(item); if (index < 0) return; - for (int i = 0; i < m_ui.defaultCombo->count(); ++i) { - if (m_ui.defaultCombo->itemText(i) == item->text(0)) { - m_ui.defaultCombo->removeItem(i); + for (int i = 0; i < m_ui->defaultCombo->count(); ++i) { + if (m_ui->defaultCombo->itemText(i) == item->text(0)) { + m_ui->defaultCombo->removeItem(i); break; } } @@ -541,83 +543,83 @@ void QtDirWidget::removeQtDir() void QtDirWidget::updateState() { - bool enabled = (m_ui.qtdirList->currentItem() != 0); + bool enabled = (m_ui->qtdirList->currentItem() != 0); bool isSystemVersion = (enabled - && m_versions.at(m_ui.qtdirList->indexOfTopLevelItem(m_ui.qtdirList->currentItem()))->isSystemVersion()); - m_ui.delButton->setEnabled(enabled && !isSystemVersion); - m_ui.nameEdit->setEnabled(enabled && !isSystemVersion); - m_ui.qtPath->setEnabled(enabled && !isSystemVersion); - m_ui.mingwPath->setEnabled(enabled); + && m_versions.at(m_ui->qtdirList->indexOfTopLevelItem(m_ui->qtdirList->currentItem()))->isSystemVersion()); + m_ui->delButton->setEnabled(enabled && !isSystemVersion); + m_ui->nameEdit->setEnabled(enabled && !isSystemVersion); + m_ui->qtPath->setEnabled(enabled && !isSystemVersion); + m_ui->mingwPath->setEnabled(enabled); - bool hasLog = enabled && !m_ui.qtdirList->currentItem()->data(2, Qt::UserRole).toString().isEmpty(); - m_ui.showLogButton->setEnabled(hasLog); + bool hasLog = enabled && !m_ui->qtdirList->currentItem()->data(2, Qt::UserRole).toString().isEmpty(); + m_ui->showLogButton->setEnabled(hasLog); QtVersion *version = 0; if (enabled) - version = m_versions.at(m_ui.qtdirList->indexOfTopLevelItem(m_ui.qtdirList->currentItem())); + version = m_versions.at(m_ui->qtdirList->indexOfTopLevelItem(m_ui->qtdirList->currentItem())); if (version) { - m_ui.rebuildButton->setEnabled(version->isValid()); + m_ui->rebuildButton->setEnabled(version->isValid()); if (version->hasDebuggingHelper()) - m_ui.debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); else - m_ui.debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); } else { - m_ui.rebuildButton->setEnabled(false); - m_ui.debuggingHelperStateLabel->setPixmap(QPixmap()); + m_ui->rebuildButton->setEnabled(false); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap()); } } void QtDirWidget::makeMingwVisible(bool visible) { - m_ui.mingwLabel->setVisible(visible); - m_ui.mingwPath->setVisible(visible); + m_ui->mingwLabel->setVisible(visible); + m_ui->mingwPath->setVisible(visible); } void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item) { - m_ui.msvcComboBox->setVisible(false); + m_ui->msvcComboBox->setVisible(false); if (item) { - int index = m_ui.qtdirList->indexOfTopLevelItem(item); - m_ui.errorLabel->setText(""); + int index = m_ui->qtdirList->indexOfTopLevelItem(item); + m_ui->errorLabel->setText(""); ProjectExplorer::ToolChain::ToolChainType t = m_versions.at(index)->toolchainType(); if (t == ProjectExplorer::ToolChain::MinGW) { - m_ui.msvcComboBox->setVisible(false); + m_ui->msvcComboBox->setVisible(false); makeMingwVisible(true); - m_ui.mingwPath->setPath(m_versions.at(index)->mingwDirectory()); + m_ui->mingwPath->setPath(m_versions.at(index)->mingwDirectory()); } else if (t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE){ - m_ui.msvcComboBox->setVisible(false); + m_ui->msvcComboBox->setVisible(false); makeMingwVisible(false); QStringList msvcEnvironments = ProjectExplorer::ToolChain::availableMSVCVersions(); if (msvcEnvironments.count() == 0) { } else if (msvcEnvironments.count() == 1) { } else { - m_ui.msvcComboBox->setVisible(true); - bool block = m_ui.msvcComboBox->blockSignals(true); - m_ui.msvcComboBox->clear(); + m_ui->msvcComboBox->setVisible(true); + bool block = m_ui->msvcComboBox->blockSignals(true); + m_ui->msvcComboBox->clear(); foreach(const QString &msvcenv, msvcEnvironments) { - m_ui.msvcComboBox->addItem(msvcenv); + m_ui->msvcComboBox->addItem(msvcenv); if (msvcenv == m_versions.at(index)->msvcVersion()) { - m_ui.msvcComboBox->setCurrentIndex(m_ui.msvcComboBox->count() - 1); + m_ui->msvcComboBox->setCurrentIndex(m_ui->msvcComboBox->count() - 1); } } - m_ui.msvcComboBox->blockSignals(block); + m_ui->msvcComboBox->blockSignals(block); } } else if (t == ProjectExplorer::ToolChain::INVALID) { - m_ui.msvcComboBox->setVisible(false); + m_ui->msvcComboBox->setVisible(false); makeMingwVisible(false); if (!m_versions.at(index)->isInstalled()) - m_ui.errorLabel->setText(tr("The Qt Version %1 is not installed. Run make install") + m_ui->errorLabel->setText(tr("The Qt Version %1 is not installed. Run make install") .arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); else - m_ui.errorLabel->setText(tr("%1 is not a valid qt directory").arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); + m_ui->errorLabel->setText(tr("%1 is not a valid qt directory").arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); } else { //ProjectExplorer::ToolChain::GCC - m_ui.msvcComboBox->setVisible(false); + m_ui->msvcComboBox->setVisible(false); makeMingwVisible(false); - m_ui.errorLabel->setText(tr("Found Qt version %1, using mkspec %2") + m_ui->errorLabel->setText(tr("Found Qt version %1, using mkspec %2") .arg(m_versions.at(index)->qtVersionString(), m_versions.at(index)->mkspec())); } } else { - m_ui.msvcComboBox->setVisible(false); + m_ui->msvcComboBox->setVisible(false); makeMingwVisible(false); } } @@ -625,14 +627,14 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item) void QtDirWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old) { if (old) { - fixQtVersionName(m_ui.qtdirList->indexOfTopLevelItem(old)); + fixQtVersionName(m_ui->qtdirList->indexOfTopLevelItem(old)); } if (item) { - m_ui.nameEdit->setText(item->text(0)); - m_ui.qtPath->setPath(item->text(1)); + m_ui->nameEdit->setText(item->text(0)); + m_ui->qtPath->setPath(item->text(1)); } else { - m_ui.nameEdit->clear(); - m_ui.qtPath->setPath(""); // clear() + m_ui->nameEdit->clear(); + m_ui->qtPath->setPath(""); // clear() } showEnvironmentPage(item); updateState(); @@ -640,15 +642,15 @@ void QtDirWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old) void QtDirWidget::onQtBrowsed() { - const QString dir = m_ui.qtPath->path(); + const QString dir = m_ui->qtPath->path(); if (dir.isEmpty()) return; updateCurrentQtPath(); - if (m_ui.nameEdit->text().isEmpty() || m_ui.nameEdit->text() == m_specifyNameString) { + if (m_ui->nameEdit->text().isEmpty() || m_ui->nameEdit->text() == m_specifyNameString) { QStringList dirSegments = dir.split(QDir::separator(), QString::SkipEmptyParts); if (!dirSegments.isEmpty()) - m_ui.nameEdit->setText(dirSegments.last()); + m_ui->nameEdit->setText(dirSegments.last()); updateCurrentQtName(); } updateState(); @@ -656,7 +658,7 @@ void QtDirWidget::onQtBrowsed() void QtDirWidget::onMingwBrowsed() { - const QString dir = m_ui.mingwPath->path(); + const QString dir = m_ui->mingwPath->path(); if (dir.isEmpty()) return; @@ -666,8 +668,8 @@ void QtDirWidget::onMingwBrowsed() void QtDirWidget::defaultChanged(int) { - for (int i=0; icount(); ++i) { - if (m_versions.at(i)->name() == m_ui.defaultCombo->currentText()) { + for (int i=0; idefaultCombo->count(); ++i) { + if (m_versions.at(i)->name() == m_ui->defaultCombo->currentText()) { m_defaultVersion = i; return; } @@ -678,20 +680,20 @@ void QtDirWidget::defaultChanged(int) void QtDirWidget::updateCurrentQtName() { - QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem(); + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); Q_ASSERT(currentItem); - int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem); - m_versions[currentItemIndex]->setName(m_ui.nameEdit->text()); + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); + m_versions[currentItemIndex]->setName(m_ui->nameEdit->text()); currentItem->setText(0, m_versions[currentItemIndex]->name()); - m_ui.defaultCombo->setItemText(currentItemIndex, m_versions[currentItemIndex]->name()); + m_ui->defaultCombo->setItemText(currentItemIndex, m_versions[currentItemIndex]->name()); } void QtDirWidget::finish() { - if (QTreeWidgetItem *item = m_ui.qtdirList->currentItem()) - fixQtVersionName(m_ui.qtdirList->indexOfTopLevelItem(item)); + if (QTreeWidgetItem *item = m_ui->qtdirList->currentItem()) + fixQtVersionName(m_ui->qtdirList->indexOfTopLevelItem(item)); } /* Checks that the qt version name is unique @@ -715,8 +717,8 @@ void QtDirWidget::fixQtVersionName(int index) } // set new name m_versions[index]->setName(name); - m_ui.qtdirList->topLevelItem(index)->setText(0, name); - m_ui.defaultCombo->setItemText(index, name); + m_ui->qtdirList->topLevelItem(index)->setText(0, name); + m_ui->defaultCombo->setItemText(index, name); // Now check again... fixQtVersionName(index); @@ -727,12 +729,12 @@ void QtDirWidget::fixQtVersionName(int index) void QtDirWidget::updateCurrentQtPath() { - QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem(); + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); Q_ASSERT(currentItem); - int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem); - if (m_versions[currentItemIndex]->path() == m_ui.qtPath->path()) + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); + if (m_versions[currentItemIndex]->path() == m_ui->qtPath->path()) return; - m_versions[currentItemIndex]->setPath(m_ui.qtPath->path()); + m_versions[currentItemIndex]->setPath(m_ui->qtPath->path()); currentItem->setText(1, QDir::toNativeSeparators(m_versions[currentItemIndex]->path())); showEnvironmentPage(currentItem); @@ -742,32 +744,32 @@ void QtDirWidget::updateCurrentQtPath() bool hasHelper = m_versions[currentItemIndex]->hasDebuggingHelper(); if (hasHelper) { currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png")); - m_ui.debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); } else { currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png")); - m_ui.debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); } - m_ui.showLogButton->setEnabled(hasLog); + m_ui->showLogButton->setEnabled(hasLog); } else { currentItem->setData(2, Qt::DecorationRole, QIcon()); - m_ui.debuggingHelperStateLabel->setPixmap(QPixmap()); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap()); } } void QtDirWidget::updateCurrentMingwDirectory() { - QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem(); + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); Q_ASSERT(currentItem); - int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem); - m_versions[currentItemIndex]->setMingwDirectory(m_ui.mingwPath->path()); + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); + m_versions[currentItemIndex]->setMingwDirectory(m_ui->mingwPath->path()); } void QtDirWidget::msvcVersionChanged() { - const QString &msvcVersion = m_ui.msvcComboBox->currentText(); - QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem(); + const QString &msvcVersion = m_ui->msvcComboBox->currentText(); + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); Q_ASSERT(currentItem); - int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem); + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); m_versions[currentItemIndex]->setMsvcVersion(msvcVersion); } diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/projectexplorer/qtversionmanager.h similarity index 95% rename from src/plugins/qt4projectmanager/qtversionmanager.h rename to src/plugins/projectexplorer/qtversionmanager.h index 867f24875ed..f69e61bc75a 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/projectexplorer/qtversionmanager.h @@ -30,22 +30,26 @@ #ifndef QTVERSIONMANAGER_H #define QTVERSIONMANAGER_H -#include "ui_qtversionmanager.h" +#include "projectexplorer.h" +#include "toolchain.h" #include -#include -#include #include #include #include -namespace Qt4ProjectManager { +namespace ProjectExplorer { + namespace Internal { +namespace Ui { +class QtVersionManager; +} +} class QtDirWidget; -class QtVersion +class PROJECTEXPLORER_EXPORT QtVersion { friend class QtDirWidget; //for changing name and path friend class QtVersionManager; @@ -141,7 +145,7 @@ private: void showEnvironmentPage(QTreeWidgetItem * item); void fixQtVersionName(int index); int indexForWidget(QWidget *debuggingHelperWidget) const; - Ui::QtVersionManager m_ui; + Internal::Ui::QtVersionManager *m_ui; QList m_versions; int m_defaultVersion; QString m_specifyNameString; @@ -164,7 +168,7 @@ private slots: void showDebuggingBuildLog(); }; -class QtVersionManager : public Core::IOptionsPage +class PROJECTEXPLORER_EXPORT QtVersionManager : public Core::IOptionsPage { Q_OBJECT @@ -222,8 +226,6 @@ private: QMap m_uniqueIdToIndex; int m_idcount; }; - -} // namespace Internal -} // namespace Qt4ProjectManager +} // namespace ProjectExplorer #endif // QTVERSIONMANAGER_H diff --git a/src/plugins/qt4projectmanager/qtversionmanager.ui b/src/plugins/projectexplorer/qtversionmanager.ui similarity index 97% rename from src/plugins/qt4projectmanager/qtversionmanager.ui rename to src/plugins/projectexplorer/qtversionmanager.ui index 2dd168325ce..dd8b252299d 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.ui +++ b/src/plugins/projectexplorer/qtversionmanager.ui @@ -1,7 +1,7 @@ - Qt4ProjectManager::Internal::QtVersionManager - + ProjectExplorer::Internal::QtVersionManager + 0 diff --git a/src/plugins/qt4projectmanager/showbuildlog.ui b/src/plugins/projectexplorer/showbuildlog.ui similarity index 100% rename from src/plugins/qt4projectmanager/showbuildlog.ui rename to src/plugins/projectexplorer/showbuildlog.ui diff --git a/src/plugins/qt4projectmanager/makestep.cpp b/src/plugins/qt4projectmanager/makestep.cpp index 95bdd4febfd..c3d9b595752 100644 --- a/src/plugins/qt4projectmanager/makestep.cpp +++ b/src/plugins/qt4projectmanager/makestep.cpp @@ -43,6 +43,7 @@ using ProjectExplorer::IBuildParserFactory; using ProjectExplorer::BuildParserInterface; using ProjectExplorer::Environment; +using ProjectExplorer::QtVersion; using ExtensionSystem::PluginManager; using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; @@ -64,7 +65,7 @@ MakeStep::~MakeStep() m_buildParser = 0; } -ProjectExplorer::BuildParserInterface *MakeStep::buildParser(const QtVersion * const version) +ProjectExplorer::BuildParserInterface *MakeStep::buildParser(const QtVersion *const version) { QString buildParser; ProjectExplorer::ToolChain::ToolChainType type = version->toolchainType(); diff --git a/src/plugins/qt4projectmanager/makestep.h b/src/plugins/qt4projectmanager/makestep.h index e59711786c3..91af6a69eca 100644 --- a/src/plugins/qt4projectmanager/makestep.h +++ b/src/plugins/qt4projectmanager/makestep.h @@ -30,16 +30,17 @@ #ifndef MAKESTEP_H #define MAKESTEP_H -#include "qtversionmanager.h" #include "ui_makestep.h" #include #include +#include namespace ProjectExplorer { class BuildStep; class IBuildStepFactory; class Project; +class QtVersion; } namespace Qt4ProjectManager { @@ -81,7 +82,7 @@ private slots: void addDirectory(const QString &dir); void removeDirectory(const QString &dir); private: - ProjectExplorer::BuildParserInterface *buildParser(const Internal::QtVersion * const version); + ProjectExplorer::BuildParserInterface *buildParser(const ProjectExplorer::QtVersion *const version); Qt4Project *m_project; ProjectExplorer::BuildParserInterface *m_buildParser; bool m_skipMakeClean; diff --git a/src/plugins/qt4projectmanager/profilereader.cpp b/src/plugins/qt4projectmanager/profilereader.cpp index 32b600cd288..109a3ffd918 100644 --- a/src/plugins/qt4projectmanager/profilereader.cpp +++ b/src/plugins/qt4projectmanager/profilereader.cpp @@ -35,6 +35,8 @@ using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; +using ProjectExplorer::QtVersion; + ProFileReader::ProFileReader() { } diff --git a/src/plugins/qt4projectmanager/profilereader.h b/src/plugins/qt4projectmanager/profilereader.h index eef60c5d153..79833c02dff 100644 --- a/src/plugins/qt4projectmanager/profilereader.h +++ b/src/plugins/qt4projectmanager/profilereader.h @@ -31,7 +31,7 @@ #define PROFILEREADER_H #include "profileevaluator.h" -#include "qtversionmanager.h" +#include #include #include @@ -39,7 +39,6 @@ namespace Qt4ProjectManager { namespace Internal { - class ProFileReader : public QObject, public ProFileEvaluator { Q_OBJECT @@ -48,7 +47,7 @@ public: ProFileReader(); ~ProFileReader(); - void setQtVersion(QtVersion *qtVersion); + void setQtVersion(ProjectExplorer::QtVersion *qtVersion); bool readProFile(const QString &fileName); QList includeFiles() const; diff --git a/src/plugins/qt4projectmanager/projectloadwizard.cpp b/src/plugins/qt4projectmanager/projectloadwizard.cpp index acd6c764124..15dcb6f4cf3 100644 --- a/src/plugins/qt4projectmanager/projectloadwizard.cpp +++ b/src/plugins/qt4projectmanager/projectloadwizard.cpp @@ -43,10 +43,12 @@ using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; +using ProjectExplorer::QtVersion; + ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::WindowFlags flags) : QWizard(parent, flags), m_project(project), m_importVersion(0), m_temporaryVersion(false) { - QtVersionManager * vm = project->qt4ProjectManager()->versionManager(); + ProjectExplorer::QtVersionManager * vm = project->qt4ProjectManager()->versionManager(); QString directory = QFileInfo(project->file()->fileName()).absolutePath(); QString importVersion = vm->findQtVersionFromMakefile(directory); diff --git a/src/plugins/qt4projectmanager/projectloadwizard.h b/src/plugins/qt4projectmanager/projectloadwizard.h index b6d886fe150..add96b6e7a9 100644 --- a/src/plugins/qt4projectmanager/projectloadwizard.h +++ b/src/plugins/qt4projectmanager/projectloadwizard.h @@ -30,7 +30,7 @@ #ifndef PROJECTLOADWIZARD_H #define PROJECTLOADWIZARD_H -#include "qtversionmanager.h" +#include #include @@ -57,14 +57,14 @@ public: void execDialog(); private: - void addBuildConfiguration(QString name, QtVersion *qtversion, QtVersion::QmakeBuildConfig buildConfiguration); - void setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfig buildConfig); + void addBuildConfiguration(QString name, ProjectExplorer::QtVersion *qtversion, ProjectExplorer::QtVersion::QmakeBuildConfig buildConfiguration); + void setupImportPage(ProjectExplorer::QtVersion *version, ProjectExplorer::QtVersion::QmakeBuildConfig buildConfig); Qt4Project *m_project; // Only used for imported stuff - QtVersion *m_importVersion; - QtVersion::QmakeBuildConfig m_importBuildConfig; + ProjectExplorer::QtVersion *m_importVersion; + ProjectExplorer::QtVersion::QmakeBuildConfig m_importBuildConfig; // Those that we might add bool m_temporaryVersion; diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp index 514feb9f371..b333016c0eb 100644 --- a/src/plugins/qt4projectmanager/qmakestep.cpp +++ b/src/plugins/qt4projectmanager/qmakestep.cpp @@ -33,10 +33,10 @@ #include "qt4projectmanagerconstants.h" #include "qt4projectmanager.h" #include "makestep.h" -#include "qtversionmanager.h" #include #include +#include #include #include diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index 66c32661c35..ac790dbfa10 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -64,6 +64,7 @@ using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; +using ProjectExplorer::QtVersion; namespace { bool debug = false; diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index ee4b5da2693..3b4f43f3226 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -36,7 +36,6 @@ #include "qmakestep.h" #include "deployhelper.h" #include "qt4runconfiguration.h" -#include "qtversionmanager.h" #include "qt4nodes.h" #include "qt4projectconfigwidget.h" #include "qt4buildenvironmentwidget.h" @@ -51,6 +50,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/qt4projectmanager/qt4project.h b/src/plugins/qt4projectmanager/qt4project.h index 3351d148134..c27be2be3fb 100644 --- a/src/plugins/qt4projectmanager/qt4project.h +++ b/src/plugins/qt4projectmanager/qt4project.h @@ -30,7 +30,6 @@ #ifndef QT4PROJECT_H #define QT4PROJECT_H -#include "qtversionmanager.h" #include "qt4nodes.h" #include "qmakestep.h" #include "makestep.h" @@ -39,6 +38,7 @@ #include #include #include +#include #include #include @@ -148,7 +148,7 @@ public: //returns the qtVersion, if the project is set to use the default qt version, then // that is returned // to check wheter the project uses the default qt version use qtVersionId - Internal::QtVersion *qtVersion(const QString &buildConfiguration) const; + ProjectExplorer::QtVersion *qtVersion(const QString &buildConfiguration) const; // returns the id of the qt version, if the project is using the default qt version // this function returns 0 diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp index ee217479507..a286f2d76cf 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp @@ -38,9 +38,13 @@ #include #include +#include #include +using ProjectExplorer::QtVersionManager; +using ProjectExplorer::QtVersion; + namespace { bool debug = false; } @@ -91,7 +95,7 @@ Qt4ProjectConfigWidget::~Qt4ProjectConfigWidget() void Qt4ProjectConfigWidget::manageQtVersions() { Core::ICore *core = Core::ICore::instance(); - core->showOptionsDialog(Constants::QT_CATEGORY, Constants::QTVERSION_PAGE); + core->showOptionsDialog(ProjectExplorer::Constants::QT_CATEGORY, ProjectExplorer::Constants::QTVERSION_PAGE); } diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index 0f460242b11..0e8e238ac5a 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -34,7 +34,6 @@ #include "qt4nodes.h" #include "qt4project.h" #include "profilereader.h" -#include "qtversionmanager.h" #include "qmakestep.h" #include @@ -47,6 +46,7 @@ #include #include #include +#include #include #include @@ -68,6 +68,8 @@ using ProjectExplorer::SourceType; using ProjectExplorer::FormType; using ProjectExplorer::ResourceType; using ProjectExplorer::UnknownFileType; +using ProjectExplorer::QtVersion; +using ProjectExplorer::QtVersionManager; // Known file types of a Qt 4 project static const char* qt4FileTypes[] = { diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.h b/src/plugins/qt4projectmanager/qt4projectmanager.h index d33c5b4b740..8099569fc62 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.h +++ b/src/plugins/qt4projectmanager/qt4projectmanager.h @@ -43,6 +43,7 @@ class PluginManager; namespace ProjectExplorer { class Project; class ProjectExplorerPlugin; +class QtVersionManager; } namespace Qt4ProjectManager { @@ -51,7 +52,6 @@ namespace Internal { class Qt4Builder; class ProFileEditor; class Qt4ProjectManagerPlugin; -class QtVersionManager; } class Qt4Project; @@ -85,7 +85,7 @@ public: void setContextProject(ProjectExplorer::Project *project); ProjectExplorer::Project *contextProject() const; - Internal::QtVersionManager *versionManager() const; + ProjectExplorer::QtVersionManager *versionManager() const; // Return the id string of a file static QString fileTypeId(ProjectExplorer::FileType type); diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.pro b/src/plugins/qt4projectmanager/qt4projectmanager.pro index 7f5bf334f38..dcaa34fc61f 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.pro +++ b/src/plugins/qt4projectmanager/qt4projectmanager.pro @@ -5,7 +5,6 @@ include(../../qworkbenchplugin.pri) include(qt4projectmanager_dependencies.pri) HEADERS = qt4projectmanagerplugin.h \ qt4projectmanager.h \ - qtversionmanager.h \ qt4project.h \ qt4nodes.h \ profileeditor.h \ @@ -36,7 +35,6 @@ HEADERS = qt4projectmanagerplugin.h \ projectloadwizard.h SOURCES = qt4projectmanagerplugin.cpp \ qt4projectmanager.cpp \ - qtversionmanager.cpp \ qt4project.cpp \ qt4nodes.cpp \ profileeditor.cpp \ @@ -63,16 +61,14 @@ SOURCES = qt4projectmanagerplugin.cpp \ qt4projectconfigwidget.cpp \ qt4buildenvironmentwidget.cpp \ projectloadwizard.cpp -FORMS = qtversionmanager.ui \ - envvariablespage.ui \ +FORMS = envvariablespage.ui \ enveditdialog.ui \ proeditorcontainer.ui \ makestep.ui \ qmakestep.ui \ qt4projectconfigwidget.ui \ embeddedpropertiespage.ui \ - qt4buildenvironmentwidget.ui \ - showbuildlog.ui + qt4buildenvironmentwidget.ui RESOURCES = qt4projectmanager.qrc \ wizards/wizards.qrc include(../../shared/proparser/proparser.pri) diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h index 14f77bdbbb6..5da496dde9c 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h +++ b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h @@ -37,11 +37,6 @@ namespace Constants { const char * const C_PROFILEEDITOR = ".pro File Editor"; const char * const C_PROFILEEDITOR_PANEL = ".pro File Editor (embedded)"; -//settings pages -const char * const QT_CATEGORY = "Qt4"; -const char * const QTVERSION_PAGE = "Qt Versions"; -const char * const BUILD_ENVIRONMENT_PAGE = "Build Environments"; - // kinds const char * const PROJECT_KIND = "Qt4"; const char * const PROFILE_EDITOR = ".pro File Editor"; diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp index fa43c9133bb..f25df616aaa 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp @@ -36,7 +36,6 @@ #include "profileeditorfactory.h" #include "qt4projectmanagerconstants.h" #include "qt4project.h" -#include "qtversionmanager.h" #include "embeddedpropertiespage.h" #include "qt4runconfiguration.h" #include "profilereader.h" @@ -48,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +64,7 @@ using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager; using ProjectExplorer::Project; +using ProjectExplorer::QtVersionManager; Qt4ProjectManagerPlugin::~Qt4ProjectManagerPlugin() { diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h index a274d531fd5..7d049c15c0b 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h +++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h @@ -33,6 +33,10 @@ #include #include +namespace ProjectExplorer { + class QtVersionManager; +} + namespace Qt4ProjectManager { class Qt4Manager; @@ -46,7 +50,6 @@ class QMakeStepFactory; class MakeStepFactory; class GccParserFactory; class MsvcParserFactory; -class QtVersionManager; class EmbeddedPropertiesPage; class Qt4ProjectManagerPlugin : public ExtensionSystem::IPlugin @@ -59,7 +62,7 @@ public: void extensionsInitialized(); int projectContext() const { return m_projectContext; } - QtVersionManager *versionManager() const; + ProjectExplorer::QtVersionManager *versionManager() const; private slots: @@ -77,7 +80,7 @@ private: ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; ProFileEditorFactory *m_proFileEditorFactory; Qt4Manager *m_qt4ProjectManager; - QtVersionManager *m_qtVersionManager; + ProjectExplorer::QtVersionManager *m_qtVersionManager; EmbeddedPropertiesPage *m_embeddedPropertiesPage; int m_projectContext; diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp index 7cb7578cb79..3741b8a20fc 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp @@ -51,6 +51,7 @@ using namespace Qt4ProjectManager; using ProjectExplorer::ApplicationRunConfiguration; using ProjectExplorer::PersistentSettingsReader; using ProjectExplorer::PersistentSettingsWriter; +using ProjectExplorer::QtVersion; Qt4RunConfiguration::Qt4RunConfiguration(Qt4Project *pro, const QString &proFilePath) : ApplicationRunConfiguration(pro), From 8f738dfcc840bdf331993d4e62ca97e4a8ef3a0e Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 22 Apr 2009 15:06:58 +0200 Subject: [PATCH 02/17] Add the *.pluginspec to OTHER_FILES so that we can use Locator for them Hopefully i didn't miss a plugin. --- src/plugins/bineditor/bineditor.pro | 2 ++ src/plugins/bookmarks/bookmarks.pro | 2 ++ src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro | 2 ++ src/plugins/coreplugin/coreplugin.pro | 2 ++ src/plugins/cppeditor/cppeditor.pro | 2 ++ src/plugins/cpptools/cpptools.pro | 2 ++ src/plugins/debugger/debugger.pro | 2 ++ src/plugins/designer/designer.pro | 2 ++ src/plugins/fakevim/fakevim.pro | 2 ++ src/plugins/find/find.pro | 2 ++ src/plugins/genericprojectmanager/genericprojectmanager.pro | 2 ++ src/plugins/git/git.pro | 2 ++ src/plugins/help/help.pro | 2 ++ src/plugins/perforce/perforce.pro | 2 ++ src/plugins/projectexplorer/projectexplorer.pro | 2 ++ src/plugins/qt4projectmanager/qt4projectmanager.pro | 2 ++ src/plugins/quickopen/quickopen.pro | 2 ++ src/plugins/resourceeditor/resourceeditor.pro | 2 ++ src/plugins/subversion/subversion.pro | 2 ++ src/plugins/texteditor/texteditor.pro | 2 ++ src/plugins/vcsbase/vcsbase.pro | 2 ++ 21 files changed, 42 insertions(+) diff --git a/src/plugins/bineditor/bineditor.pro b/src/plugins/bineditor/bineditor.pro index 08a67fdf05f..976e701ff4a 100644 --- a/src/plugins/bineditor/bineditor.pro +++ b/src/plugins/bineditor/bineditor.pro @@ -11,3 +11,5 @@ SOURCES += bineditorplugin.cpp \ bineditor.cpp RESOURCES += bineditor.qrc + +OTHER_FILES += BinEditor.pluginspec diff --git a/src/plugins/bookmarks/bookmarks.pro b/src/plugins/bookmarks/bookmarks.pro index 1fcbffff7b4..d061d5fa76d 100644 --- a/src/plugins/bookmarks/bookmarks.pro +++ b/src/plugins/bookmarks/bookmarks.pro @@ -16,3 +16,5 @@ SOURCES += bookmarksplugin.cpp \ bookmarkmanager.cpp RESOURCES += bookmarks.qrc + +OTHER_FILES += Bookmarks.pluginspec diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index c5e260b8e9b..e2d02bba527 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -19,3 +19,5 @@ SOURCES = cmakeproject.cpp \ cmakeopenprojectwizard.cpp RESOURCES += cmakeproject.qrc FORMS += + +OTHER_FILES += CMakeProjectManager.pluginspec diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index c3606c1f1bd..6ef8c970728 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -169,3 +169,5 @@ linux-* { INSTALLS += images } + +OTHER_FILES += Core.pluginspec diff --git a/src/plugins/cppeditor/cppeditor.pro b/src/plugins/cppeditor/cppeditor.pro index 2ea6fb53245..2fbf3b46e48 100644 --- a/src/plugins/cppeditor/cppeditor.pro +++ b/src/plugins/cppeditor/cppeditor.pro @@ -22,3 +22,5 @@ SOURCES += cppplugin.cpp \ cppfilewizard.cpp \ cppclasswizard.cpp RESOURCES += cppeditor.qrc + +OTHER_FILES += CppEditor.pluginspec diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro index 2094a0edf64..5a5763f6af4 100644 --- a/src/plugins/cpptools/cpptools.pro +++ b/src/plugins/cpptools/cpptools.pro @@ -37,3 +37,5 @@ SOURCES += completionsettingspage.cpp \ FORMS += completionsettingspage.ui \ cppfilesettingspage.ui + +OTHER_FILES += CppTools.pluginspec diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index 8d0cb9ddbdd..3d364762c64 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -98,3 +98,5 @@ win32 { include(win/win.pri) include(cdb/cdb.pri) } + +OTHER_FILES += Debugger.pluginspec diff --git a/src/plugins/designer/designer.pro b/src/plugins/designer/designer.pro index 444eb2e7949..7fc73987566 100644 --- a/src/plugins/designer/designer.pro +++ b/src/plugins/designer/designer.pro @@ -50,3 +50,5 @@ SOURCES += formeditorplugin.cpp \ formwizarddialog.cpp RESOURCES += designer.qrc + +OTHER_FILES += Designer.pluginspec diff --git a/src/plugins/fakevim/fakevim.pro b/src/plugins/fakevim/fakevim.pro index 10a89dfeae0..890f047cfa4 100644 --- a/src/plugins/fakevim/fakevim.pro +++ b/src/plugins/fakevim/fakevim.pro @@ -25,3 +25,5 @@ HEADERS += \ FORMS += \ fakevimoptions.ui + +OTHER_FILES += FakeVim.pluginspec diff --git a/src/plugins/find/find.pro b/src/plugins/find/find.pro index 77a6193801c..52c93f30233 100644 --- a/src/plugins/find/find.pro +++ b/src/plugins/find/find.pro @@ -31,3 +31,5 @@ SOURCES += findtoolwindow.cpp \ FORMS += findwidget.ui \ finddialog.ui RESOURCES += find.qrc + +OTHER_FILES += Find.pluginspec diff --git a/src/plugins/genericprojectmanager/genericprojectmanager.pro b/src/plugins/genericprojectmanager/genericprojectmanager.pro index 9ffb539b88b..eb00ccc16e4 100644 --- a/src/plugins/genericprojectmanager/genericprojectmanager.pro +++ b/src/plugins/genericprojectmanager/genericprojectmanager.pro @@ -21,3 +21,5 @@ SOURCES = genericproject.cpp \ genericmakestep.cpp RESOURCES += genericproject.qrc FORMS += genericmakestep.ui + +OTHER_FILES += GenericProjectManager.pluginspec diff --git a/src/plugins/git/git.pro b/src/plugins/git/git.pro index 2bd1d00d9c4..c038852a2dc 100644 --- a/src/plugins/git/git.pro +++ b/src/plugins/git/git.pro @@ -41,3 +41,5 @@ FORMS += changeselectiondialog.ui \ settingspage.ui \ gitsubmitpanel.ui \ branchdialog.ui + +OTHER_FILES += ScmGit.pluginspec diff --git a/src/plugins/help/help.pro b/src/plugins/help/help.pro index 6fd810634b5..750afe0e445 100644 --- a/src/plugins/help/help.pro +++ b/src/plugins/help/help.pro @@ -35,3 +35,5 @@ include(../../shared/help/help.pri) contains(QT_CONFIG, webkit) { QT += webkit } + +OTHER_FILES += Help.pluginspec diff --git a/src/plugins/perforce/perforce.pro b/src/plugins/perforce/perforce.pro index 992777f1723..e386aba34c1 100644 --- a/src/plugins/perforce/perforce.pro +++ b/src/plugins/perforce/perforce.pro @@ -36,3 +36,5 @@ FORMS += settingspage.ui \ submitpanel.ui RESOURCES += perforce.qrc + +OTHER_FILES += Perforce.pluginspec diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index d6b1c8c8b43..3b3a4316df4 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -127,3 +127,5 @@ win32 { else:unix:SOURCES += applicationlauncher_x11.cpp RESOURCES += projectexplorer.qrc DEFINES += PROJECTEXPLORER_LIBRARY + +OTHER_FILES += ProjectExplorer.pluginspec diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.pro b/src/plugins/qt4projectmanager/qt4projectmanager.pro index dcaa34fc61f..d471edb8cc0 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.pro +++ b/src/plugins/qt4projectmanager/qt4projectmanager.pro @@ -73,3 +73,5 @@ RESOURCES = qt4projectmanager.qrc \ wizards/wizards.qrc include(../../shared/proparser/proparser.pri) DEFINES += QT_NO_CAST_TO_ASCII + +OTHER_FILES += Qt4ProjectManager.pluginspec diff --git a/src/plugins/quickopen/quickopen.pro b/src/plugins/quickopen/quickopen.pro index dbacef6df53..f5a7dd9ce01 100644 --- a/src/plugins/quickopen/quickopen.pro +++ b/src/plugins/quickopen/quickopen.pro @@ -29,3 +29,5 @@ FORMS += settingspage.ui \ filesystemfilter.ui \ directoryfilter.ui RESOURCES += quickopen.qrc + +OTHER_FILES += QuickOpen.pluginspec diff --git a/src/plugins/resourceeditor/resourceeditor.pro b/src/plugins/resourceeditor/resourceeditor.pro index 5df0d635e57..c90cafffe53 100644 --- a/src/plugins/resourceeditor/resourceeditor.pro +++ b/src/plugins/resourceeditor/resourceeditor.pro @@ -22,3 +22,5 @@ resourcewizard.cpp \ resourceeditorw.cpp RESOURCES += resourceeditor.qrc + +OTHER_FILES += ResourceEditor.pluginspec diff --git a/src/plugins/subversion/subversion.pro b/src/plugins/subversion/subversion.pro index 993d22eb6a3..270693347c3 100644 --- a/src/plugins/subversion/subversion.pro +++ b/src/plugins/subversion/subversion.pro @@ -29,3 +29,5 @@ SOURCES += annotationhighlighter.cpp \ FORMS += settingspage.ui RESOURCES += subversion.qrc + +OTHER_FILES += Subversion.pluginspec diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro index 61f8477dd80..a16a898b1d7 100644 --- a/src/plugins/texteditor/texteditor.pro +++ b/src/plugins/texteditor/texteditor.pro @@ -59,3 +59,5 @@ FORMS += behaviorsettingspage.ui \ displaysettingspage.ui \ fontsettingspage.ui RESOURCES += texteditor.qrc + +OTHER_FILES += TextEditor.pluginspec diff --git a/src/plugins/vcsbase/vcsbase.pro b/src/plugins/vcsbase/vcsbase.pro index 58bbc0dd4e8..510dbf59826 100644 --- a/src/plugins/vcsbase/vcsbase.pro +++ b/src/plugins/vcsbase/vcsbase.pro @@ -37,3 +37,5 @@ RESOURCES += vcsbase.qrc FORMS += vcsbasesettingspage.ui \ nicknamedialog.ui + +OTHER_FILES += VCSBase.pluginspec From b6c05a334c400e030d5682e73c269304abdbfb59 Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 22 Apr 2009 16:51:38 +0200 Subject: [PATCH 03/17] Refactoring: Move QtVersionManager instance() into the ProjectExplorer And add a instance() method to it. --- src/plugins/projectexplorer/projectexplorer.cpp | 9 +++++++++ src/plugins/projectexplorer/projectexplorer.h | 4 ++++ src/plugins/projectexplorer/qtversionmanager.cpp | 16 ++++++++++------ src/plugins/projectexplorer/qtversionmanager.h | 6 +++--- .../qt4projectmanager/projectloadwizard.cpp | 9 ++++++--- src/plugins/qt4projectmanager/qt4project.cpp | 16 ++++++++++------ .../qt4projectmanager/qt4projectconfigwidget.cpp | 15 ++++++++++----- .../qt4projectmanager/qt4projectmanager.cpp | 5 ----- .../qt4projectmanager/qt4projectmanager.h | 2 -- .../qt4projectmanagerplugin.cpp | 11 ----------- .../qt4projectmanager/qt4projectmanagerplugin.h | 4 ---- 11 files changed, 52 insertions(+), 45 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index e7a00ad4f22..6fbb3cc32b8 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -56,6 +56,7 @@ #include "session.h" #include "sessiondialog.h" #include "buildparserfactory.h" +#include "qtversionmanager.h" #include #include @@ -194,6 +195,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er connect(m_buildManager, SIGNAL(tasksChanged()), this, SLOT(updateTaskActions())); + m_versionManager = new QtVersionManager(); + addAutoReleasedObject(m_versionManager); + addAutoReleasedObject(new CoreListenerCheckingForRunningBuild(m_buildManager)); m_outputPane = new OutputPane; @@ -1905,4 +1909,9 @@ void ProjectExplorerPlugin::setSession(QAction *action) m_session->loadSession(session); } +QtVersionManager *ProjectExplorerPlugin::qtVersionManager() const +{ + return m_versionManager; +} + Q_EXPORT_PLUGIN(ProjectExplorerPlugin) diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 987cb323fb6..b18545a9c39 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -64,6 +64,7 @@ class RunConfiguration; class RunControl; class SessionManager; class IRunConfigurationRunner; +class QtVersionManager; namespace Internal { class ApplicationOutput; @@ -104,6 +105,8 @@ public: void showContextMenu(const QPoint &globalPos, Node *node); + QtVersionManager *qtVersionManager() const; + //PluginInterface bool initialize(const QStringList &arguments, QString *error_message); void extensionsInitialized(); @@ -246,6 +249,7 @@ private: Node *m_currentNode; BuildManager *m_buildManager; + QtVersionManager *m_versionManager; QList m_fileFactories; QStringList m_profileMimeTypes; diff --git a/src/plugins/projectexplorer/qtversionmanager.cpp b/src/plugins/projectexplorer/qtversionmanager.cpp index 0e8c7bc7edf..67a8ffbb658 100644 --- a/src/plugins/projectexplorer/qtversionmanager.cpp +++ b/src/plugins/projectexplorer/qtversionmanager.cpp @@ -32,12 +32,14 @@ #include "projectexplorerconstants.h" #include "ui_showbuildlog.h" #include "ui_qtversionmanager.h" +#include "cesdkhandler.h" +#include "toolchain.h" + +#include "projectexplorer.h" #include #include #include -#include -#include #include #include @@ -113,6 +115,11 @@ QtVersionManager::~QtVersionManager() m_emptyVersion = 0; } +QtVersionManager::QtVersionManager *instance() +{ + return ProjectExplorerPlugin::instance()->qtVersionManager(); +} + void QtVersionManager::addVersion(QtVersion *version) { m_versions.append(version); @@ -162,8 +169,6 @@ QString QtVersionManager::trCategory() const QWidget *QtVersionManager::createPage(QWidget *parent) { - if (m_widget) - delete m_widget; m_widget = new QtDirWidget(parent, m_versions, m_defaultVersion); return m_widget; } @@ -1354,8 +1359,7 @@ int QtVersion::uniqueId() const int QtVersion::getUniqueId() { - QtVersionManager *vm = ExtensionSystem::PluginManager::instance()->getObject(); - return vm->getUniqueId(); + return QtVersionManager::instance()->getUniqueId(); } bool QtVersion::isValid() const diff --git a/src/plugins/projectexplorer/qtversionmanager.h b/src/plugins/projectexplorer/qtversionmanager.h index f69e61bc75a..1721719c1a2 100644 --- a/src/plugins/projectexplorer/qtversionmanager.h +++ b/src/plugins/projectexplorer/qtversionmanager.h @@ -171,11 +171,12 @@ private slots: class PROJECTEXPLORER_EXPORT QtVersionManager : public Core::IOptionsPage { Q_OBJECT - public: QtVersionManager(); ~QtVersionManager(); + static QtVersionManager *instance(); + QString id() const; QString trName() const; QString category() const; @@ -210,7 +211,6 @@ signals: void defaultQtVersionChanged(); void qtVersionsChanged(); private: - void addNewVersionsFromInstaller(); void updateSystemVersion(); void updateDocumentation(); @@ -218,7 +218,7 @@ private: static int indexOfVersionInList(const QtVersion * const version, const QList &list); void updateUniqueIdToIndexMap(); - QPointer m_widget; + QtDirWidget *m_widget; QtVersion *m_emptyVersion; int m_defaultVersion; diff --git a/src/plugins/qt4projectmanager/projectloadwizard.cpp b/src/plugins/qt4projectmanager/projectloadwizard.cpp index 15dcb6f4cf3..2d943a019c0 100644 --- a/src/plugins/qt4projectmanager/projectloadwizard.cpp +++ b/src/plugins/qt4projectmanager/projectloadwizard.cpp @@ -34,6 +34,8 @@ #include "qmakestep.h" #include "makestep.h" +#include + #include #include #include @@ -48,7 +50,7 @@ using ProjectExplorer::QtVersion; ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::WindowFlags flags) : QWizard(parent, flags), m_project(project), m_importVersion(0), m_temporaryVersion(false) { - ProjectExplorer::QtVersionManager * vm = project->qt4ProjectManager()->versionManager(); + ProjectExplorer::QtVersionManager * vm = ProjectExplorer::QtVersionManager::instance(); QString directory = QFileInfo(project->file()->fileName()).absolutePath(); QString importVersion = vm->findQtVersionFromMakefile(directory); @@ -127,6 +129,7 @@ void ProjectLoadWizard::addBuildConfiguration(QString name, QtVersion *qtversion void ProjectLoadWizard::done(int result) { + ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance(); QWizard::done(result); // This normally happens on showing the final page, but since we // don't show it anymore, do it here @@ -135,7 +138,7 @@ void ProjectLoadWizard::done(int result) if (m_importVersion && importCheckbox->isChecked()) { // Importing if (m_temporaryVersion) - m_project->qt4ProjectManager()->versionManager()->addVersion(m_importVersion); + vm->addVersion(m_importVersion); // Import the existing stuff // qDebug()<<"Creating m_buildconfiguration entry from imported stuff"; // qDebug()<<((m_importBuildConfig& QtVersion::BuildAll)? "debug_and_release" : "")<<((m_importBuildConfig & QtVersion::DebugBuild)? "debug" : "release"); @@ -158,7 +161,7 @@ void ProjectLoadWizard::done(int result) delete m_importVersion; // Create default bool buildAll = false; - QtVersion *defaultVersion = m_project->qt4ProjectManager()->versionManager()->version(0); + QtVersion *defaultVersion = vm->version(0); if (defaultVersion && defaultVersion->isValid() && (defaultVersion->defaultBuildConfig() & QtVersion::BuildAll)) buildAll = true; if (buildAll) { diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 3b4f43f3226..a97303cf323 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -236,9 +236,11 @@ Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) : { m_manager->registerProject(this); - connect(qt4ProjectManager()->versionManager(), SIGNAL(defaultQtVersionChanged()), + ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance(); + + connect(vm, SIGNAL(defaultQtVersionChanged()), this, SLOT(defaultQtVersionChanged())); - connect(qt4ProjectManager()->versionManager(), SIGNAL(qtVersionsChanged()), + connect(vm, SIGNAL(qtVersionsChanged()), this, SLOT(qtVersionsChanged())); m_updateCodeModelTimer.setSingleShot(true); @@ -266,8 +268,9 @@ void Qt4Project::defaultQtVersionChanged() void Qt4Project::qtVersionsChanged() { + QtVersionManager *vm = QtVersionManager::instance(); foreach (QString bc, buildConfigurations()) { - if (!qt4ProjectManager()->versionManager()->version(qtVersionId(bc))->isValid()) { + if (!vm->version(qtVersionId(bc))->isValid()) { setQtVersion(bc, 0); if (bc == activeBuildConfiguration()) m_rootProjectNode->update(); @@ -740,18 +743,19 @@ QString Qt4Project::qtDir(const QString &buildConfiguration) const QtVersion *Qt4Project::qtVersion(const QString &buildConfiguration) const { - return m_manager->versionManager()->version(qtVersionId(buildConfiguration)); + return QtVersionManager::instance()->version(qtVersionId(buildConfiguration)); } int Qt4Project::qtVersionId(const QString &buildConfiguration) const { + QtVersionManager *vm = QtVersionManager::instance(); if (debug) qDebug()<<"Looking for qtVersion ID of "<versionManager()->version(id)->isValid()) { + if (vm->version(id)->isValid()) { return id; } else { const_cast(this)->setValue(buildConfiguration, "QtVersionId", 0); @@ -763,7 +767,7 @@ int Qt4Project::qtVersionId(const QString &buildConfiguration) const if (debug) qDebug()<<" Backward compatibility reading QtVersion"< &versions = m_manager->versionManager()->versions(); + const QList &versions = vm->versions(); foreach (const QtVersion * const version, versions) { if (version->name() == vname) { if (debug) diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp index a286f2d76cf..9e7fd93e778 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -83,7 +84,9 @@ Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project) connect(m_ui->manageQtVersionPushButtons, SIGNAL(clicked()), this, SLOT(manageQtVersions())); - connect(m_pro->qt4ProjectManager()->versionManager(), SIGNAL(qtVersionsChanged()), + ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance(); + + connect(vm, SIGNAL(qtVersionsChanged()), this, SLOT(setupQtVersionsComboBox())); } @@ -143,7 +146,7 @@ void Qt4ProjectConfigWidget::setupQtVersionsComboBox() m_ui->invalidQtWarningLabel->setVisible(false); } // Add Qt Versions to the combo box - QtVersionManager *vm = m_pro->qt4ProjectManager()->versionManager(); + QtVersionManager *vm = QtVersionManager::instance(); const QList &versions = vm->versions(); for (int i = 0; i < versions.size(); ++i) { m_ui->qtVersionComboBox->addItem(versions.at(i)->name(), versions.at(i)->uniqueId()); @@ -181,7 +184,8 @@ void Qt4ProjectConfigWidget::updateImportLabel() { m_ui->importLabel->setVisible(false); if (m_ui->shadowBuildCheckBox->isChecked()) { - QString qtPath = m_pro->qt4ProjectManager()->versionManager()->findQtVersionFromMakefile(m_ui->shadowBuildDirEdit->path()); + ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance(); + QString qtPath = vm->findQtVersionFromMakefile(m_ui->shadowBuildDirEdit->path()); if (!qtPath.isEmpty()) { m_ui->importLabel->setVisible(true); } @@ -215,7 +219,7 @@ void Qt4ProjectConfigWidget::importLabelClicked() if (m_ui->shadowBuildCheckBox->isChecked()) { QString directory = m_ui->shadowBuildDirEdit->path(); if (!directory.isEmpty()) { - QtVersionManager *vm = m_pro->qt4ProjectManager()->versionManager(); + QtVersionManager *vm = QtVersionManager::instance(); QString qtPath = vm->findQtVersionFromMakefile(directory); if (!qtPath.isEmpty()) { QtVersion *version = vm->qtVersionForDirectory(qtPath); @@ -265,7 +269,8 @@ void Qt4ProjectConfigWidget::qtVersionComboBoxCurrentIndexChanged(const QString } else { newQtVersion = m_ui->qtVersionComboBox->itemData(m_ui->qtVersionComboBox->currentIndex()).toInt(); } - bool isValid = m_pro->qt4ProjectManager()->versionManager()->version(newQtVersion)->isValid(); + ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance(); + bool isValid = vm->version(newQtVersion)->isValid(); m_ui->invalidQtWarningLabel->setVisible(!isValid); if (newQtVersion != m_pro->qtVersionId(m_buildConfiguration)) { m_pro->setQtVersion(m_buildConfiguration, newQtVersion); diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index 0e8e238ac5a..697deb5025c 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -189,11 +189,6 @@ ProjectExplorer::Project *Qt4Manager::contextProject() const return m_contextProject; } -QtVersionManager *Qt4Manager::versionManager() const -{ - return m_plugin->versionManager(); -} - void Qt4Manager::runQMake() { runQMake(m_projectExplorer->currentProject()); diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.h b/src/plugins/qt4projectmanager/qt4projectmanager.h index 8099569fc62..43b64937cfe 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.h +++ b/src/plugins/qt4projectmanager/qt4projectmanager.h @@ -85,8 +85,6 @@ public: void setContextProject(ProjectExplorer::Project *project); ProjectExplorer::Project *contextProject() const; - ProjectExplorer::QtVersionManager *versionManager() const; - // Return the id string of a file static QString fileTypeId(ProjectExplorer::FileType type); diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp index f25df616aaa..22db266f46c 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp @@ -71,9 +71,6 @@ Qt4ProjectManagerPlugin::~Qt4ProjectManagerPlugin() //removeObject(m_embeddedPropertiesPage); //delete m_embeddedPropertiesPage; - removeObject(m_qtVersionManager); - delete m_qtVersionManager; - removeObject(m_proFileEditorFactory); delete m_proFileEditorFactory; removeObject(m_qt4ProjectManager); @@ -125,9 +122,6 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString * addAutoReleasedObject(new QMakeStepFactory); addAutoReleasedObject(new MakeStepFactory); - m_qtVersionManager = new QtVersionManager; - addObject(m_qtVersionManager); - addAutoReleasedObject(new Qt4RunConfigurationFactory); addAutoReleasedObject(new Qt4RunConfigurationFactoryUser); @@ -191,11 +185,6 @@ void Qt4ProjectManagerPlugin::updateContextMenu(Project *project, } } -QtVersionManager *Qt4ProjectManagerPlugin::versionManager() const -{ - return m_qtVersionManager; -} - void Qt4ProjectManagerPlugin::currentProjectChanged() { m_runQMakeAction->setEnabled(!m_projectExplorer->buildManager()->isBuilding(m_projectExplorer->currentProject())); diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h index 7d049c15c0b..7dce30081e9 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h +++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h @@ -62,8 +62,6 @@ public: void extensionsInitialized(); int projectContext() const { return m_projectContext; } - ProjectExplorer::QtVersionManager *versionManager() const; - private slots: void updateContextMenu(ProjectExplorer::Project *project, @@ -80,8 +78,6 @@ private: ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; ProFileEditorFactory *m_proFileEditorFactory; Qt4Manager *m_qt4ProjectManager; - ProjectExplorer::QtVersionManager *m_qtVersionManager; - EmbeddedPropertiesPage *m_embeddedPropertiesPage; int m_projectContext; From 095337836ad9b947d3e7d61ae0948537d2517285 Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 22 Apr 2009 18:05:55 +0200 Subject: [PATCH 04/17] Refactoring: Split up QtVersionManager into gui and non gui The settings page does not need to be exported and should be seperate from the actual manager. This also makes further refactorings of QtVersionManager easier and of QtDirWidget. More to come. --- .../projectexplorer/projectexplorer.cpp | 2 + .../projectexplorer/qtversionmanager.cpp | 147 ++++++++++-------- .../projectexplorer/qtversionmanager.h | 41 ++--- 3 files changed, 108 insertions(+), 82 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 6fbb3cc32b8..af4beb1ecbc 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -198,6 +198,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er m_versionManager = new QtVersionManager(); addAutoReleasedObject(m_versionManager); + addAutoReleasedObject(new QtOptionsPage()); + addAutoReleasedObject(new CoreListenerCheckingForRunningBuild(m_buildManager)); m_outputPane = new OutputPane; diff --git a/src/plugins/projectexplorer/qtversionmanager.cpp b/src/plugins/projectexplorer/qtversionmanager.cpp index 67a8ffbb658..acaa49e359b 100644 --- a/src/plugins/projectexplorer/qtversionmanager.cpp +++ b/src/plugins/projectexplorer/qtversionmanager.cpp @@ -115,7 +115,7 @@ QtVersionManager::~QtVersionManager() m_emptyVersion = 0; } -QtVersionManager::QtVersionManager *instance() +QtVersionManager *QtVersionManager::instance() { return ProjectExplorerPlugin::instance()->qtVersionManager(); } @@ -147,32 +147,6 @@ int QtVersionManager::getUniqueId() return m_idcount++; } -QString QtVersionManager::id() const -{ - return QLatin1String(Constants::QTVERSION_PAGE); -} - -QString QtVersionManager::trName() const -{ - return tr(Constants::QTVERSION_PAGE); -} - -QString QtVersionManager::category() const -{ - return Constants::QT_CATEGORY; -} - -QString QtVersionManager::trCategory() const -{ - return tr(Constants::QT_CATEGORY); -} - -QWidget *QtVersionManager::createPage(QWidget *parent) -{ - m_widget = new QtDirWidget(parent, m_versions, m_defaultVersion); - return m_widget; -} - void QtVersionManager::updateUniqueIdToIndexMap() { m_uniqueIdToIndex.clear(); @@ -180,40 +154,6 @@ void QtVersionManager::updateUniqueIdToIndexMap() m_uniqueIdToIndex.insert(m_versions.at(i)->uniqueId(), i); } -void QtVersionManager::apply() -{ - m_widget->finish(); - QList newVersions = m_widget->versions(); - bool versionPathsChanged = m_versions.size() != newVersions.size(); - if (!versionPathsChanged) { - for (int i = 0; i < m_versions.size(); ++i) { - if (m_versions.at(i)->path() != newVersions.at(i)->path()) { - versionPathsChanged = true; - break; - } - } - } - qDeleteAll(m_versions); - m_versions.clear(); - foreach(QtVersion *version, m_widget->versions()) - m_versions.append(new QtVersion(*version)); - if (versionPathsChanged) - updateDocumentation(); - updateUniqueIdToIndexMap(); - - bool emitDefaultChanged = false; - if (m_defaultVersion != m_widget->defaultVersion()) { - m_defaultVersion = m_widget->defaultVersion(); - emitDefaultChanged = true; - } - - emit qtVersionsChanged(); - if (emitDefaultChanged) - emit defaultQtVersionChanged(); - - writeVersionsIntoSettings(); -} - void QtVersionManager::writeVersionsIntoSettings() { QSettings *s = Core::ICore::instance()->settings(); @@ -383,10 +323,91 @@ QtVersion *QtVersionManager::currentQtVersion() const return m_emptyVersion; } +void QtVersionManager::setNewQtVersions(QList newVersions, int newDefaultVersion) +{ + bool versionPathsChanged = m_versions.size() != newVersions.size(); + if (!versionPathsChanged) { + for (int i = 0; i < m_versions.size(); ++i) { + if (m_versions.at(i)->path() != newVersions.at(i)->path()) { + versionPathsChanged = true; + break; + } + } + } + qDeleteAll(m_versions); + m_versions.clear(); + foreach(QtVersion *version, newVersions) + m_versions.append(new QtVersion(*version)); + if (versionPathsChanged) + updateDocumentation(); + updateUniqueIdToIndexMap(); + + bool emitDefaultChanged = false; + if (m_defaultVersion != newDefaultVersion) { + m_defaultVersion = newDefaultVersion; + emitDefaultChanged = true; + } + + emit qtVersionsChanged(); + if (emitDefaultChanged) + emit defaultQtVersionChanged(); + + writeVersionsIntoSettings(); +} + +/// +// QtOptionsPage +/// + +QtOptionsPage::QtOptionsPage() +{ + +} + +QtOptionsPage::~QtOptionsPage() +{ + +} + +QString QtOptionsPage::id() const +{ + return QLatin1String(Constants::QTVERSION_PAGE); +} + +QString QtOptionsPage::trName() const +{ + return tr(Constants::QTVERSION_PAGE); +} + +QString QtOptionsPage::category() const +{ + return Constants::QT_CATEGORY; +} + +QString QtOptionsPage::trCategory() const +{ + return tr(Constants::QT_CATEGORY); +} + +QWidget *QtOptionsPage::createPage(QWidget *parent) +{ + QtVersionManager *vm = QtVersionManager::instance(); + m_widget = new QtDirWidget(parent, vm->versions(), vm->currentQtVersion()); + return m_widget; +} + +void QtOptionsPage::apply() +{ + m_widget->finish(); + + QtVersionManager *vm = QtVersionManager::instance(); + vm->setNewQtVersions(m_widget->versions(), m_widget->defaultVersion()); +} + //----------------------------------------------------- -QtDirWidget::QtDirWidget(QWidget *parent, QList versions, int defaultVersion) +QtDirWidget::QtDirWidget(QWidget *parent, QList versions, QtVersion *defaultVersion) : QWidget(parent) - , m_defaultVersion(defaultVersion) + , m_defaultVersion(versions.indexOf(defaultVersion)) , m_specifyNameString(tr("")) , m_specifyPathString(tr("")) { diff --git a/src/plugins/projectexplorer/qtversionmanager.h b/src/plugins/projectexplorer/qtversionmanager.h index 1721719c1a2..c1db4c5a2b2 100644 --- a/src/plugins/projectexplorer/qtversionmanager.h +++ b/src/plugins/projectexplorer/qtversionmanager.h @@ -135,7 +135,7 @@ class QtDirWidget : public QWidget { Q_OBJECT public: - QtDirWidget(QWidget *parent, QList versions, int defaultVersion); + QtDirWidget(QWidget *parent, QList versions, QtVersion *defaultVersion); ~QtDirWidget(); QList versions() const; int defaultVersion() const; @@ -168,45 +168,33 @@ private slots: void showDebuggingBuildLog(); }; -class PROJECTEXPLORER_EXPORT QtVersionManager : public Core::IOptionsPage +class PROJECTEXPLORER_EXPORT QtVersionManager : public QObject { Q_OBJECT public: + static QtVersionManager *instance(); QtVersionManager(); ~QtVersionManager(); - - static QtVersionManager *instance(); - - QString id() const; - QString trName() const; - QString category() const; - QString trCategory() const; - - QWidget *createPage(QWidget *parent); - void apply(); - void finish() { } - void writeVersionsIntoSettings(); QList versions() const; QtVersion * version(int id) const; QtVersion * currentQtVersion() const; - // internal int getUniqueId(); QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig); QString findQtVersionFromMakefile(const QString &directory); QtVersion *qtVersionForDirectory(const QString &directory); - // Used by the projectloadwizard void addVersion(QtVersion *version); - + // returns something like qmake4, qmake, qmake-qt4 or whatever distributions have chosen (used by QtVersion) static QStringList possibleQMakeCommands(); // return true if the qmake at qmakePath is qt4 (used by QtVersion) static QString qtVersionForQMake(const QString &qmakePath); + void setNewQtVersions(QList newVersions, int newDefaultVersion); signals: void defaultQtVersionChanged(); void qtVersionsChanged(); @@ -218,14 +206,29 @@ private: static int indexOfVersionInList(const QtVersion * const version, const QList &list); void updateUniqueIdToIndexMap(); - QtDirWidget *m_widget; - QtVersion *m_emptyVersion; int m_defaultVersion; QList m_versions; QMap m_uniqueIdToIndex; int m_idcount; }; + +class PROJECTEXPLORER_EXPORT QtOptionsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + QtOptionsPage(); + ~QtOptionsPage(); + QString id() const; + QString trName() const; + QString category() const; + QString trCategory() const; + QWidget *createPage(QWidget *parent); + void apply(); + void finish() { } +private: + QtDirWidget *m_widget; +}; } // namespace ProjectExplorer #endif // QTVERSIONMANAGER_H From 4274156bdb92d479306771959f4e44452b9d1000 Mon Sep 17 00:00:00 2001 From: dt Date: Thu, 23 Apr 2009 12:52:51 +0200 Subject: [PATCH 05/17] Refactoring: Split up qtversionmanager.(h|cpp) into two files QtOptionsPage now has its own page. --- .../projectexplorer/projectexplorer.cpp | 1 + .../projectexplorer/projectexplorer.pro | 29 +- src/plugins/projectexplorer/qtoptionspage.cpp | 464 +++++++++++++++++ src/plugins/projectexplorer/qtoptionspage.h | 107 ++++ .../projectexplorer/qtversionmanager.cpp | 466 ------------------ .../projectexplorer/qtversionmanager.h | 71 +-- 6 files changed, 592 insertions(+), 546 deletions(-) create mode 100644 src/plugins/projectexplorer/qtoptionspage.cpp create mode 100644 src/plugins/projectexplorer/qtoptionspage.h diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index af4beb1ecbc..320b89de503 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -57,6 +57,7 @@ #include "sessiondialog.h" #include "buildparserfactory.h" #include "qtversionmanager.h" +#include "qtoptionspage.h" #include #include diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 3b3a4316df4..c9d0f4dce59 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -54,12 +54,13 @@ HEADERS += projectexplorer.h \ projectmodels.h \ currentprojectfind.h \ toolchain.h \ - cesdkhandler.h\ - buildparserfactory.h\ - gccparser.h\ - msvcparser.h\ - filewatcher.h\ - qtversionmanager.h + cesdkhandler.h \ + buildparserfactory.h \ + gccparser.h \ + msvcparser.h \ + filewatcher.h \ + qtversionmanager.h \ + qtoptionspage.h SOURCES += projectexplorer.cpp \ projectwindow.cpp \ buildmanager.cpp \ @@ -102,12 +103,13 @@ SOURCES += projectexplorer.cpp \ projectmodels.cpp \ currentprojectfind.cpp \ toolchain.cpp \ - cesdkhandler.cpp\ + cesdkhandler.cpp \ buildparserfactory.cpp \ - gccparser.cpp\ - msvcparser.cpp\ - filewatcher.cpp\ - qtversionmanager.cpp + gccparser.cpp \ + msvcparser.cpp \ + filewatcher.cpp \ + qtversionmanager.cpp \ + qtoptionspage.cpp FORMS += dependenciespanel.ui \ buildsettingspropertiespage.ui \ processstep.ui \ @@ -116,8 +118,8 @@ FORMS += dependenciespanel.ui \ sessiondialog.ui \ projectwizardpage.ui \ buildstepspage.ui \ - removefiledialog.ui\ - qtversionmanager.ui\ + removefiledialog.ui \ + qtversionmanager.ui \ showbuildlog.ui win32 { SOURCES += applicationlauncher_win.cpp \ @@ -127,5 +129,4 @@ win32 { else:unix:SOURCES += applicationlauncher_x11.cpp RESOURCES += projectexplorer.qrc DEFINES += PROJECTEXPLORER_LIBRARY - OTHER_FILES += ProjectExplorer.pluginspec diff --git a/src/plugins/projectexplorer/qtoptionspage.cpp b/src/plugins/projectexplorer/qtoptionspage.cpp new file mode 100644 index 00000000000..88d38b1b0f7 --- /dev/null +++ b/src/plugins/projectexplorer/qtoptionspage.cpp @@ -0,0 +1,464 @@ +#include "qtoptionspage.h" +#include "ui_showbuildlog.h" +#include "ui_qtversionmanager.h" +#include "projectexplorerconstants.h" +#include "qtversionmanager.h" +#include + +#include + +using namespace ProjectExplorer; +using namespace ProjectExplorer::Internal; +/// +// QtOptionsPage +/// + +QtOptionsPage::QtOptionsPage() +{ + +} + +QtOptionsPage::~QtOptionsPage() +{ + +} + +QString QtOptionsPage::id() const +{ + return QLatin1String(Constants::QTVERSION_PAGE); +} + +QString QtOptionsPage::trName() const +{ + return tr(Constants::QTVERSION_PAGE); +} + +QString QtOptionsPage::category() const +{ + return Constants::QT_CATEGORY; +} + +QString QtOptionsPage::trCategory() const +{ + return tr(Constants::QT_CATEGORY); +} + +QWidget *QtOptionsPage::createPage(QWidget *parent) +{ + QtVersionManager *vm = QtVersionManager::instance(); + m_widget = new QtDirWidget(parent, vm->versions(), vm->currentQtVersion()); + return m_widget; +} + +void QtOptionsPage::apply() +{ + m_widget->finish(); + + QtVersionManager *vm = QtVersionManager::instance(); + vm->setNewQtVersions(m_widget->versions(), m_widget->defaultVersion()); +} + +//----------------------------------------------------- +QtDirWidget::QtDirWidget(QWidget *parent, QList versions, QtVersion *defaultVersion) + : QWidget(parent) + , m_defaultVersion(versions.indexOf(defaultVersion)) + , m_specifyNameString(tr("")) + , m_specifyPathString(tr("")) +{ + // Initialize m_versions + foreach(QtVersion *version, versions) { + m_versions.append(new QtVersion(*version)); + } + + + m_ui = new Internal::Ui::QtVersionManager(); + m_ui->setupUi(this); + m_ui->qtPath->setExpectedKind(Core::Utils::PathChooser::Directory); + m_ui->qtPath->setPromptDialogTitle(tr("Select QTDIR")); + m_ui->mingwPath->setExpectedKind(Core::Utils::PathChooser::Directory); + m_ui->qtPath->setPromptDialogTitle(tr("Select the Qt Directory")); + + m_ui->addButton->setIcon(QIcon(Core::Constants::ICON_PLUS)); + m_ui->delButton->setIcon(QIcon(Core::Constants::ICON_MINUS)); + + for (int i = 0; i < m_versions.count(); ++i) { + const QtVersion * const version = m_versions.at(i); + QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList); + item->setText(0, version->name()); + item->setText(1, QDir::toNativeSeparators(version->path())); + item->setData(0, Qt::UserRole, version->uniqueId()); + + if (version->isValid()) { + if (version->hasDebuggingHelper()) + item->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png")); + else + item->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png")); + } else { + item->setData(2, Qt::DecorationRole, QIcon()); + } + + m_ui->defaultCombo->addItem(version->name()); + if (i == m_defaultVersion) + m_ui->defaultCombo->setCurrentIndex(i); + } + + connect(m_ui->nameEdit, SIGNAL(textEdited(const QString &)), + this, SLOT(updateCurrentQtName())); + + + connect(m_ui->qtPath, SIGNAL(changed()), + this, SLOT(updateCurrentQtPath())); + connect(m_ui->mingwPath, SIGNAL(changed()), + this, SLOT(updateCurrentMingwDirectory())); + + connect(m_ui->addButton, SIGNAL(clicked()), + this, SLOT(addQtDir())); + connect(m_ui->delButton, SIGNAL(clicked()), + this, SLOT(removeQtDir())); + + connect(m_ui->qtPath, SIGNAL(browsingFinished()), + this, SLOT(onQtBrowsed())); + connect(m_ui->mingwPath, SIGNAL(browsingFinished()), + this, SLOT(onMingwBrowsed())); + + connect(m_ui->qtdirList, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), + this, SLOT(versionChanged(QTreeWidgetItem *, QTreeWidgetItem *))); + connect(m_ui->defaultCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(defaultChanged(int))); + + connect(m_ui->msvcComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(msvcVersionChanged())); + + connect(m_ui->rebuildButton, SIGNAL(clicked()), + this, SLOT(buildDebuggingHelper())); + connect(m_ui->showLogButton, SIGNAL(clicked()), + this, SLOT(showDebuggingBuildLog())); + + showEnvironmentPage(0); + updateState(); +} + +void QtDirWidget::buildDebuggingHelper() +{ + // Find the qt version for this button.. + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); + if (!currentItem) + return; + + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); + QtVersion *version = m_versions[currentItemIndex]; + + QString result = m_versions.at(currentItemIndex)->buildDebuggingHelperLibrary(); + currentItem->setData(2, Qt::UserRole, result); + + if (version->hasDebuggingHelper()) { + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); + currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png")); + } else { + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); + currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png")); + } + m_ui->showLogButton->setEnabled(true); +} + +void QtDirWidget::showDebuggingBuildLog() +{ + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); + if (!currentItem) + return; + + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); + QDialog dlg; + Ui_ShowBuildLog ui; + ui.setupUi(&dlg); + ui.log->setPlainText(m_ui->qtdirList->topLevelItem(currentItemIndex)->data(2, Qt::UserRole).toString()); + dlg.exec(); +} + +QtDirWidget::~QtDirWidget() +{ + qDeleteAll(m_versions); + delete m_ui; +} + +void QtDirWidget::addQtDir() +{ + QtVersion *newVersion = new QtVersion(m_specifyNameString, m_specifyPathString); + m_versions.append(newVersion); + + QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList); + item->setText(0, newVersion->name()); + item->setText(1, QDir::toNativeSeparators(newVersion->path())); + item->setData(0, Qt::UserRole, newVersion->uniqueId()); + item->setData(2, Qt::DecorationRole, QIcon()); + + m_ui->qtdirList->setCurrentItem(item); + + m_ui->nameEdit->setText(newVersion->name()); + m_ui->qtPath->setPath(newVersion->path()); + m_ui->defaultCombo->addItem(newVersion->name()); + m_ui->nameEdit->setFocus(); + m_ui->nameEdit->selectAll(); +} + +void QtDirWidget::removeQtDir() +{ + QTreeWidgetItem *item = m_ui->qtdirList->currentItem(); + int index = m_ui->qtdirList->indexOfTopLevelItem(item); + if (index < 0) + return; + + for (int i = 0; i < m_ui->defaultCombo->count(); ++i) { + if (m_ui->defaultCombo->itemText(i) == item->text(0)) { + m_ui->defaultCombo->removeItem(i); + break; + } + } + + delete item; + + delete m_versions.takeAt(index); + updateState(); +} + +void QtDirWidget::updateState() +{ + bool enabled = (m_ui->qtdirList->currentItem() != 0); + bool isSystemVersion = (enabled + && m_versions.at(m_ui->qtdirList->indexOfTopLevelItem(m_ui->qtdirList->currentItem()))->isSystemVersion()); + m_ui->delButton->setEnabled(enabled && !isSystemVersion); + m_ui->nameEdit->setEnabled(enabled && !isSystemVersion); + m_ui->qtPath->setEnabled(enabled && !isSystemVersion); + m_ui->mingwPath->setEnabled(enabled); + + bool hasLog = enabled && !m_ui->qtdirList->currentItem()->data(2, Qt::UserRole).toString().isEmpty(); + m_ui->showLogButton->setEnabled(hasLog); + + QtVersion *version = 0; + if (enabled) + version = m_versions.at(m_ui->qtdirList->indexOfTopLevelItem(m_ui->qtdirList->currentItem())); + if (version) { + m_ui->rebuildButton->setEnabled(version->isValid()); + if (version->hasDebuggingHelper()) + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); + else + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); + } else { + m_ui->rebuildButton->setEnabled(false); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap()); + } +} +void QtDirWidget::makeMingwVisible(bool visible) +{ + m_ui->mingwLabel->setVisible(visible); + m_ui->mingwPath->setVisible(visible); +} + +void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item) +{ + m_ui->msvcComboBox->setVisible(false); + if (item) { + int index = m_ui->qtdirList->indexOfTopLevelItem(item); + m_ui->errorLabel->setText(""); + ProjectExplorer::ToolChain::ToolChainType t = m_versions.at(index)->toolchainType(); + if (t == ProjectExplorer::ToolChain::MinGW) { + m_ui->msvcComboBox->setVisible(false); + makeMingwVisible(true); + m_ui->mingwPath->setPath(m_versions.at(index)->mingwDirectory()); + } else if (t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE){ + m_ui->msvcComboBox->setVisible(false); + makeMingwVisible(false); + QStringList msvcEnvironments = ProjectExplorer::ToolChain::availableMSVCVersions(); + if (msvcEnvironments.count() == 0) { + } else if (msvcEnvironments.count() == 1) { + } else { + m_ui->msvcComboBox->setVisible(true); + bool block = m_ui->msvcComboBox->blockSignals(true); + m_ui->msvcComboBox->clear(); + foreach(const QString &msvcenv, msvcEnvironments) { + m_ui->msvcComboBox->addItem(msvcenv); + if (msvcenv == m_versions.at(index)->msvcVersion()) { + m_ui->msvcComboBox->setCurrentIndex(m_ui->msvcComboBox->count() - 1); + } + } + m_ui->msvcComboBox->blockSignals(block); + } + } else if (t == ProjectExplorer::ToolChain::INVALID) { + m_ui->msvcComboBox->setVisible(false); + makeMingwVisible(false); + if (!m_versions.at(index)->isInstalled()) + m_ui->errorLabel->setText(tr("The Qt Version %1 is not installed. Run make install") + .arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); + else + m_ui->errorLabel->setText(tr("%1 is not a valid qt directory").arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); + } else { //ProjectExplorer::ToolChain::GCC + m_ui->msvcComboBox->setVisible(false); + makeMingwVisible(false); + m_ui->errorLabel->setText(tr("Found Qt version %1, using mkspec %2") + .arg(m_versions.at(index)->qtVersionString(), + m_versions.at(index)->mkspec())); + } + } else { + m_ui->msvcComboBox->setVisible(false); + makeMingwVisible(false); + } +} + +void QtDirWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old) +{ + if (old) { + fixQtVersionName(m_ui->qtdirList->indexOfTopLevelItem(old)); + } + if (item) { + m_ui->nameEdit->setText(item->text(0)); + m_ui->qtPath->setPath(item->text(1)); + } else { + m_ui->nameEdit->clear(); + m_ui->qtPath->setPath(""); // clear() + } + showEnvironmentPage(item); + updateState(); +} + +void QtDirWidget::onQtBrowsed() +{ + const QString dir = m_ui->qtPath->path(); + if (dir.isEmpty()) + return; + + updateCurrentQtPath(); + if (m_ui->nameEdit->text().isEmpty() || m_ui->nameEdit->text() == m_specifyNameString) { + QStringList dirSegments = dir.split(QDir::separator(), QString::SkipEmptyParts); + if (!dirSegments.isEmpty()) + m_ui->nameEdit->setText(dirSegments.last()); + updateCurrentQtName(); + } + updateState(); +} + +void QtDirWidget::onMingwBrowsed() +{ + const QString dir = m_ui->mingwPath->path(); + if (dir.isEmpty()) + return; + + updateCurrentMingwDirectory(); + updateState(); +} + +void QtDirWidget::defaultChanged(int) +{ + for (int i=0; idefaultCombo->count(); ++i) { + if (m_versions.at(i)->name() == m_ui->defaultCombo->currentText()) { + m_defaultVersion = i; + return; + } + } + + m_defaultVersion = 0; +} + +void QtDirWidget::updateCurrentQtName() +{ + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); + Q_ASSERT(currentItem); + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); + m_versions[currentItemIndex]->setName(m_ui->nameEdit->text()); + currentItem->setText(0, m_versions[currentItemIndex]->name()); + + m_ui->defaultCombo->setItemText(currentItemIndex, m_versions[currentItemIndex]->name()); +} + + +void QtDirWidget::finish() +{ + if (QTreeWidgetItem *item = m_ui->qtdirList->currentItem()) + fixQtVersionName(m_ui->qtdirList->indexOfTopLevelItem(item)); +} + +/* Checks that the qt version name is unique + * and otherwise changes the name + * + */ +void QtDirWidget::fixQtVersionName(int index) +{ + int count = m_versions.count(); + for (int i = 0; i < count; ++i) { + if (i != index) { + if (m_versions.at(i)->name() == m_versions.at(index)->name()) { + // Same name, find new name + QString name = m_versions.at(index)->name(); + QRegExp regexp("^(.*)\\((\\d)\\)$"); + if (regexp.exactMatch(name)) { + // Alreay in Name (#) format + name = regexp.cap(1) + "(" + QString().setNum(regexp.cap(2).toInt() + 1) + ")"; + } else { + name = name + " (2)"; + } + // set new name + m_versions[index]->setName(name); + m_ui->qtdirList->topLevelItem(index)->setText(0, name); + m_ui->defaultCombo->setItemText(index, name); + + // Now check again... + fixQtVersionName(index); + } + } + } +} + +void QtDirWidget::updateCurrentQtPath() +{ + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); + Q_ASSERT(currentItem); + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); + if (m_versions[currentItemIndex]->path() == m_ui->qtPath->path()) + return; + m_versions[currentItemIndex]->setPath(m_ui->qtPath->path()); + currentItem->setText(1, QDir::toNativeSeparators(m_versions[currentItemIndex]->path())); + + showEnvironmentPage(currentItem); + + if (m_versions[currentItemIndex]->isValid()) { + bool hasLog = !currentItem->data(2, Qt::UserRole).toString().isEmpty(); + bool hasHelper = m_versions[currentItemIndex]->hasDebuggingHelper(); + if (hasHelper) { + currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png")); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); + } else { + currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png")); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); + } + m_ui->showLogButton->setEnabled(hasLog); + } else { + currentItem->setData(2, Qt::DecorationRole, QIcon()); + m_ui->debuggingHelperStateLabel->setPixmap(QPixmap()); + } +} + +void QtDirWidget::updateCurrentMingwDirectory() +{ + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); + Q_ASSERT(currentItem); + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); + m_versions[currentItemIndex]->setMingwDirectory(m_ui->mingwPath->path()); +} + +void QtDirWidget::msvcVersionChanged() +{ + const QString &msvcVersion = m_ui->msvcComboBox->currentText(); + QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); + Q_ASSERT(currentItem); + int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); + m_versions[currentItemIndex]->setMsvcVersion(msvcVersion); +} + +QList QtDirWidget::versions() const +{ + return m_versions; +} + +int QtDirWidget::defaultVersion() const +{ + return m_defaultVersion; +} diff --git a/src/plugins/projectexplorer/qtoptionspage.h b/src/plugins/projectexplorer/qtoptionspage.h new file mode 100644 index 00000000000..776a6cda010 --- /dev/null +++ b/src/plugins/projectexplorer/qtoptionspage.h @@ -0,0 +1,107 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +**************************************************************************/ +#ifndef QTOPTIONSPAGE_H +#define QTOPTIONSPAGE_H + +#include + +#include + +QT_BEGIN_NAMESPACE +class QTreeWidgetItem; +QT_END_NAMESPACE + +namespace ProjectExplorer { + +class QtVersion; + +namespace Internal { +namespace Ui { +class QtVersionManager; +} + +class QtDirWidget : public QWidget +{ + Q_OBJECT +public: + QtDirWidget(QWidget *parent, QList versions, QtVersion *defaultVersion); + ~QtDirWidget(); + QList versions() const; + int defaultVersion() const; + void finish(); + +private: + void showEnvironmentPage(QTreeWidgetItem * item); + void fixQtVersionName(int index); + int indexForWidget(QWidget *debuggingHelperWidget) const; + Internal::Ui::QtVersionManager *m_ui; + QList m_versions; + int m_defaultVersion; + QString m_specifyNameString; + QString m_specifyPathString; + +private slots: + void versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old); + void addQtDir(); + void removeQtDir(); + void updateState(); + void makeMingwVisible(bool visible); + void onQtBrowsed(); + void onMingwBrowsed(); + void defaultChanged(int index); + void updateCurrentQtName(); + void updateCurrentQtPath(); + void updateCurrentMingwDirectory(); + void msvcVersionChanged(); + void buildDebuggingHelper(); + void showDebuggingBuildLog(); +}; + +class QtOptionsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + QtOptionsPage(); + ~QtOptionsPage(); + QString id() const; + QString trName() const; + QString category() const; + QString trCategory() const; + QWidget *createPage(QWidget *parent); + void apply(); + void finish() { } +private: + QtDirWidget *m_widget; +}; + +} //namespace Internal +} //namespace ProjectExplorer + + +#endif // QTOPTIONSPAGE_H diff --git a/src/plugins/projectexplorer/qtversionmanager.cpp b/src/plugins/projectexplorer/qtversionmanager.cpp index acaa49e359b..87577b2c27f 100644 --- a/src/plugins/projectexplorer/qtversionmanager.cpp +++ b/src/plugins/projectexplorer/qtversionmanager.cpp @@ -30,34 +30,20 @@ #include "qtversionmanager.h" #include "projectexplorerconstants.h" -#include "ui_showbuildlog.h" -#include "ui_qtversionmanager.h" #include "cesdkhandler.h" -#include "toolchain.h" #include "projectexplorer.h" #include -#include #include #include #include -#include #include #include -#include #include - -#include -#include -#include -#include -#include #include #include -#include -#include using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; @@ -355,459 +341,7 @@ void QtVersionManager::setNewQtVersions(QList newVersions, int newD writeVersionsIntoSettings(); } -/// -// QtOptionsPage -/// -QtOptionsPage::QtOptionsPage() -{ - -} - -QtOptionsPage::~QtOptionsPage() -{ - -} - -QString QtOptionsPage::id() const -{ - return QLatin1String(Constants::QTVERSION_PAGE); -} - -QString QtOptionsPage::trName() const -{ - return tr(Constants::QTVERSION_PAGE); -} - -QString QtOptionsPage::category() const -{ - return Constants::QT_CATEGORY; -} - -QString QtOptionsPage::trCategory() const -{ - return tr(Constants::QT_CATEGORY); -} - -QWidget *QtOptionsPage::createPage(QWidget *parent) -{ - QtVersionManager *vm = QtVersionManager::instance(); - m_widget = new QtDirWidget(parent, vm->versions(), vm->currentQtVersion()); - return m_widget; -} - -void QtOptionsPage::apply() -{ - m_widget->finish(); - - QtVersionManager *vm = QtVersionManager::instance(); - vm->setNewQtVersions(m_widget->versions(), m_widget->defaultVersion()); -} - -//----------------------------------------------------- -QtDirWidget::QtDirWidget(QWidget *parent, QList versions, QtVersion *defaultVersion) - : QWidget(parent) - , m_defaultVersion(versions.indexOf(defaultVersion)) - , m_specifyNameString(tr("")) - , m_specifyPathString(tr("")) -{ - // Initialize m_versions - foreach(QtVersion *version, versions) { - m_versions.append(new QtVersion(*version)); - } - - - m_ui = new Internal::Ui::QtVersionManager(); - m_ui->setupUi(this); - m_ui->qtPath->setExpectedKind(Core::Utils::PathChooser::Directory); - m_ui->qtPath->setPromptDialogTitle(tr("Select QTDIR")); - m_ui->mingwPath->setExpectedKind(Core::Utils::PathChooser::Directory); - m_ui->qtPath->setPromptDialogTitle(tr("Select the Qt Directory")); - - m_ui->addButton->setIcon(QIcon(Core::Constants::ICON_PLUS)); - m_ui->delButton->setIcon(QIcon(Core::Constants::ICON_MINUS)); - - for (int i = 0; i < m_versions.count(); ++i) { - const QtVersion * const version = m_versions.at(i); - QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList); - item->setText(0, version->name()); - item->setText(1, QDir::toNativeSeparators(version->path())); - item->setData(0, Qt::UserRole, version->uniqueId()); - - if (version->isValid()) { - if (version->hasDebuggingHelper()) - item->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png")); - else - item->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png")); - } else { - item->setData(2, Qt::DecorationRole, QIcon()); - } - - m_ui->defaultCombo->addItem(version->name()); - if (i == m_defaultVersion) - m_ui->defaultCombo->setCurrentIndex(i); - } - - connect(m_ui->nameEdit, SIGNAL(textEdited(const QString &)), - this, SLOT(updateCurrentQtName())); - - - connect(m_ui->qtPath, SIGNAL(changed()), - this, SLOT(updateCurrentQtPath())); - connect(m_ui->mingwPath, SIGNAL(changed()), - this, SLOT(updateCurrentMingwDirectory())); - - connect(m_ui->addButton, SIGNAL(clicked()), - this, SLOT(addQtDir())); - connect(m_ui->delButton, SIGNAL(clicked()), - this, SLOT(removeQtDir())); - - connect(m_ui->qtPath, SIGNAL(browsingFinished()), - this, SLOT(onQtBrowsed())); - connect(m_ui->mingwPath, SIGNAL(browsingFinished()), - this, SLOT(onMingwBrowsed())); - - connect(m_ui->qtdirList, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), - this, SLOT(versionChanged(QTreeWidgetItem *, QTreeWidgetItem *))); - connect(m_ui->defaultCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(defaultChanged(int))); - - connect(m_ui->msvcComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(msvcVersionChanged())); - - connect(m_ui->rebuildButton, SIGNAL(clicked()), - this, SLOT(buildDebuggingHelper())); - connect(m_ui->showLogButton, SIGNAL(clicked()), - this, SLOT(showDebuggingBuildLog())); - - showEnvironmentPage(0); - updateState(); -} - -void QtDirWidget::buildDebuggingHelper() -{ - // Find the qt version for this button.. - QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); - if (!currentItem) - return; - - int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); - QtVersion *version = m_versions[currentItemIndex]; - - QString result = m_versions.at(currentItemIndex)->buildDebuggingHelperLibrary(); - currentItem->setData(2, Qt::UserRole, result); - - if (version->hasDebuggingHelper()) { - m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); - currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png")); - } else { - m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); - currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png")); - } - m_ui->showLogButton->setEnabled(true); -} - -void QtDirWidget::showDebuggingBuildLog() -{ - QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); - if (!currentItem) - return; - - int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); - QDialog dlg; - Ui_ShowBuildLog ui; - ui.setupUi(&dlg); - ui.log->setPlainText(m_ui->qtdirList->topLevelItem(currentItemIndex)->data(2, Qt::UserRole).toString()); - dlg.exec(); -} - -QtDirWidget::~QtDirWidget() -{ - qDeleteAll(m_versions); - delete m_ui; -} - -void QtDirWidget::addQtDir() -{ - QtVersion *newVersion = new QtVersion(m_specifyNameString, m_specifyPathString); - m_versions.append(newVersion); - - QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList); - item->setText(0, newVersion->name()); - item->setText(1, QDir::toNativeSeparators(newVersion->path())); - item->setData(0, Qt::UserRole, newVersion->uniqueId()); - item->setData(2, Qt::DecorationRole, QIcon()); - - m_ui->qtdirList->setCurrentItem(item); - - m_ui->nameEdit->setText(newVersion->name()); - m_ui->qtPath->setPath(newVersion->path()); - m_ui->defaultCombo->addItem(newVersion->name()); - m_ui->nameEdit->setFocus(); - m_ui->nameEdit->selectAll(); -} - -void QtDirWidget::removeQtDir() -{ - QTreeWidgetItem *item = m_ui->qtdirList->currentItem(); - int index = m_ui->qtdirList->indexOfTopLevelItem(item); - if (index < 0) - return; - - for (int i = 0; i < m_ui->defaultCombo->count(); ++i) { - if (m_ui->defaultCombo->itemText(i) == item->text(0)) { - m_ui->defaultCombo->removeItem(i); - break; - } - } - - delete item; - - delete m_versions.takeAt(index); - updateState(); -} - -void QtDirWidget::updateState() -{ - bool enabled = (m_ui->qtdirList->currentItem() != 0); - bool isSystemVersion = (enabled - && m_versions.at(m_ui->qtdirList->indexOfTopLevelItem(m_ui->qtdirList->currentItem()))->isSystemVersion()); - m_ui->delButton->setEnabled(enabled && !isSystemVersion); - m_ui->nameEdit->setEnabled(enabled && !isSystemVersion); - m_ui->qtPath->setEnabled(enabled && !isSystemVersion); - m_ui->mingwPath->setEnabled(enabled); - - bool hasLog = enabled && !m_ui->qtdirList->currentItem()->data(2, Qt::UserRole).toString().isEmpty(); - m_ui->showLogButton->setEnabled(hasLog); - - QtVersion *version = 0; - if (enabled) - version = m_versions.at(m_ui->qtdirList->indexOfTopLevelItem(m_ui->qtdirList->currentItem())); - if (version) { - m_ui->rebuildButton->setEnabled(version->isValid()); - if (version->hasDebuggingHelper()) - m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); - else - m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); - } else { - m_ui->rebuildButton->setEnabled(false); - m_ui->debuggingHelperStateLabel->setPixmap(QPixmap()); - } -} -void QtDirWidget::makeMingwVisible(bool visible) -{ - m_ui->mingwLabel->setVisible(visible); - m_ui->mingwPath->setVisible(visible); -} - -void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item) -{ - m_ui->msvcComboBox->setVisible(false); - if (item) { - int index = m_ui->qtdirList->indexOfTopLevelItem(item); - m_ui->errorLabel->setText(""); - ProjectExplorer::ToolChain::ToolChainType t = m_versions.at(index)->toolchainType(); - if (t == ProjectExplorer::ToolChain::MinGW) { - m_ui->msvcComboBox->setVisible(false); - makeMingwVisible(true); - m_ui->mingwPath->setPath(m_versions.at(index)->mingwDirectory()); - } else if (t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE){ - m_ui->msvcComboBox->setVisible(false); - makeMingwVisible(false); - QStringList msvcEnvironments = ProjectExplorer::ToolChain::availableMSVCVersions(); - if (msvcEnvironments.count() == 0) { - } else if (msvcEnvironments.count() == 1) { - } else { - m_ui->msvcComboBox->setVisible(true); - bool block = m_ui->msvcComboBox->blockSignals(true); - m_ui->msvcComboBox->clear(); - foreach(const QString &msvcenv, msvcEnvironments) { - m_ui->msvcComboBox->addItem(msvcenv); - if (msvcenv == m_versions.at(index)->msvcVersion()) { - m_ui->msvcComboBox->setCurrentIndex(m_ui->msvcComboBox->count() - 1); - } - } - m_ui->msvcComboBox->blockSignals(block); - } - } else if (t == ProjectExplorer::ToolChain::INVALID) { - m_ui->msvcComboBox->setVisible(false); - makeMingwVisible(false); - if (!m_versions.at(index)->isInstalled()) - m_ui->errorLabel->setText(tr("The Qt Version %1 is not installed. Run make install") - .arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); - else - m_ui->errorLabel->setText(tr("%1 is not a valid qt directory").arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); - } else { //ProjectExplorer::ToolChain::GCC - m_ui->msvcComboBox->setVisible(false); - makeMingwVisible(false); - m_ui->errorLabel->setText(tr("Found Qt version %1, using mkspec %2") - .arg(m_versions.at(index)->qtVersionString(), - m_versions.at(index)->mkspec())); - } - } else { - m_ui->msvcComboBox->setVisible(false); - makeMingwVisible(false); - } -} - -void QtDirWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old) -{ - if (old) { - fixQtVersionName(m_ui->qtdirList->indexOfTopLevelItem(old)); - } - if (item) { - m_ui->nameEdit->setText(item->text(0)); - m_ui->qtPath->setPath(item->text(1)); - } else { - m_ui->nameEdit->clear(); - m_ui->qtPath->setPath(""); // clear() - } - showEnvironmentPage(item); - updateState(); -} - -void QtDirWidget::onQtBrowsed() -{ - const QString dir = m_ui->qtPath->path(); - if (dir.isEmpty()) - return; - - updateCurrentQtPath(); - if (m_ui->nameEdit->text().isEmpty() || m_ui->nameEdit->text() == m_specifyNameString) { - QStringList dirSegments = dir.split(QDir::separator(), QString::SkipEmptyParts); - if (!dirSegments.isEmpty()) - m_ui->nameEdit->setText(dirSegments.last()); - updateCurrentQtName(); - } - updateState(); -} - -void QtDirWidget::onMingwBrowsed() -{ - const QString dir = m_ui->mingwPath->path(); - if (dir.isEmpty()) - return; - - updateCurrentMingwDirectory(); - updateState(); -} - -void QtDirWidget::defaultChanged(int) -{ - for (int i=0; idefaultCombo->count(); ++i) { - if (m_versions.at(i)->name() == m_ui->defaultCombo->currentText()) { - m_defaultVersion = i; - return; - } - } - - m_defaultVersion = 0; -} - -void QtDirWidget::updateCurrentQtName() -{ - QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); - Q_ASSERT(currentItem); - int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); - m_versions[currentItemIndex]->setName(m_ui->nameEdit->text()); - currentItem->setText(0, m_versions[currentItemIndex]->name()); - - m_ui->defaultCombo->setItemText(currentItemIndex, m_versions[currentItemIndex]->name()); -} - - -void QtDirWidget::finish() -{ - if (QTreeWidgetItem *item = m_ui->qtdirList->currentItem()) - fixQtVersionName(m_ui->qtdirList->indexOfTopLevelItem(item)); -} - -/* Checks that the qt version name is unique - * and otherwise changes the name - * - */ -void QtDirWidget::fixQtVersionName(int index) -{ - int count = m_versions.count(); - for (int i = 0; i < count; ++i) { - if (i != index) { - if (m_versions.at(i)->name() == m_versions.at(index)->name()) { - // Same name, find new name - QString name = m_versions.at(index)->name(); - QRegExp regexp("^(.*)\\((\\d)\\)$"); - if (regexp.exactMatch(name)) { - // Alreay in Name (#) format - name = regexp.cap(1) + "(" + QString().setNum(regexp.cap(2).toInt() + 1) + ")"; - } else { - name = name + " (2)"; - } - // set new name - m_versions[index]->setName(name); - m_ui->qtdirList->topLevelItem(index)->setText(0, name); - m_ui->defaultCombo->setItemText(index, name); - - // Now check again... - fixQtVersionName(index); - } - } - } -} - -void QtDirWidget::updateCurrentQtPath() -{ - QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); - Q_ASSERT(currentItem); - int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); - if (m_versions[currentItemIndex]->path() == m_ui->qtPath->path()) - return; - m_versions[currentItemIndex]->setPath(m_ui->qtPath->path()); - currentItem->setText(1, QDir::toNativeSeparators(m_versions[currentItemIndex]->path())); - - showEnvironmentPage(currentItem); - - if (m_versions[currentItemIndex]->isValid()) { - bool hasLog = !currentItem->data(2, Qt::UserRole).toString().isEmpty(); - bool hasHelper = m_versions[currentItemIndex]->hasDebuggingHelper(); - if (hasHelper) { - currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png")); - m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png")); - } else { - currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png")); - m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png")); - } - m_ui->showLogButton->setEnabled(hasLog); - } else { - currentItem->setData(2, Qt::DecorationRole, QIcon()); - m_ui->debuggingHelperStateLabel->setPixmap(QPixmap()); - } -} - -void QtDirWidget::updateCurrentMingwDirectory() -{ - QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); - Q_ASSERT(currentItem); - int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); - m_versions[currentItemIndex]->setMingwDirectory(m_ui->mingwPath->path()); -} - -void QtDirWidget::msvcVersionChanged() -{ - const QString &msvcVersion = m_ui->msvcComboBox->currentText(); - QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); - Q_ASSERT(currentItem); - int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem); - m_versions[currentItemIndex]->setMsvcVersion(msvcVersion); -} - -QList QtDirWidget::versions() const -{ - return m_versions; -} - -int QtDirWidget::defaultVersion() const -{ - return m_defaultVersion; -} /// /// QtVersion diff --git a/src/plugins/projectexplorer/qtversionmanager.h b/src/plugins/projectexplorer/qtversionmanager.h index c1db4c5a2b2..bfd26b95b57 100644 --- a/src/plugins/projectexplorer/qtversionmanager.h +++ b/src/plugins/projectexplorer/qtversionmanager.h @@ -30,28 +30,21 @@ #ifndef QTVERSIONMANAGER_H #define QTVERSIONMANAGER_H -#include "projectexplorer.h" +#include "environment.h" #include "toolchain.h" +#include "projectexplorer_export.h" -#include - -#include -#include -#include +#include namespace ProjectExplorer { namespace Internal { -namespace Ui { -class QtVersionManager; -} -} - class QtDirWidget; +} class PROJECTEXPLORER_EXPORT QtVersion { - friend class QtDirWidget; //for changing name and path + friend class Internal::QtDirWidget; //for changing name and path friend class QtVersionManager; public: QtVersion(const QString &name, const QString &path); @@ -130,44 +123,6 @@ private: bool m_hasDebuggingHelper; }; - -class QtDirWidget : public QWidget -{ - Q_OBJECT -public: - QtDirWidget(QWidget *parent, QList versions, QtVersion *defaultVersion); - ~QtDirWidget(); - QList versions() const; - int defaultVersion() const; - void finish(); - -private: - void showEnvironmentPage(QTreeWidgetItem * item); - void fixQtVersionName(int index); - int indexForWidget(QWidget *debuggingHelperWidget) const; - Internal::Ui::QtVersionManager *m_ui; - QList m_versions; - int m_defaultVersion; - QString m_specifyNameString; - QString m_specifyPathString; - -private slots: - void versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old); - void addQtDir(); - void removeQtDir(); - void updateState(); - void makeMingwVisible(bool visible); - void onQtBrowsed(); - void onMingwBrowsed(); - void defaultChanged(int index); - void updateCurrentQtName(); - void updateCurrentQtPath(); - void updateCurrentMingwDirectory(); - void msvcVersionChanged(); - void buildDebuggingHelper(); - void showDebuggingBuildLog(); -}; - class PROJECTEXPLORER_EXPORT QtVersionManager : public QObject { Q_OBJECT @@ -213,22 +168,6 @@ private: int m_idcount; }; -class PROJECTEXPLORER_EXPORT QtOptionsPage : public Core::IOptionsPage -{ - Q_OBJECT -public: - QtOptionsPage(); - ~QtOptionsPage(); - QString id() const; - QString trName() const; - QString category() const; - QString trCategory() const; - QWidget *createPage(QWidget *parent); - void apply(); - void finish() { } -private: - QtDirWidget *m_widget; -}; } // namespace ProjectExplorer #endif // QTVERSIONMANAGER_H From b6114dfa4957736b7b260895c9922933a4cc8add Mon Sep 17 00:00:00 2001 From: dt Date: Thu, 23 Apr 2009 13:23:46 +0200 Subject: [PATCH 06/17] Refactoring: Rename QtDirWidget to QtOptionsPageWidget More accurate name. --- src/plugins/projectexplorer/qtoptionspage.cpp | 44 +++++++++---------- src/plugins/projectexplorer/qtoptionspage.h | 8 ++-- .../projectexplorer/qtversionmanager.h | 4 +- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/plugins/projectexplorer/qtoptionspage.cpp b/src/plugins/projectexplorer/qtoptionspage.cpp index 88d38b1b0f7..c0ebf08ee18 100644 --- a/src/plugins/projectexplorer/qtoptionspage.cpp +++ b/src/plugins/projectexplorer/qtoptionspage.cpp @@ -46,7 +46,7 @@ QString QtOptionsPage::trCategory() const QWidget *QtOptionsPage::createPage(QWidget *parent) { QtVersionManager *vm = QtVersionManager::instance(); - m_widget = new QtDirWidget(parent, vm->versions(), vm->currentQtVersion()); + m_widget = new QtOptionsPageWidget(parent, vm->versions(), vm->currentQtVersion()); return m_widget; } @@ -59,7 +59,7 @@ void QtOptionsPage::apply() } //----------------------------------------------------- -QtDirWidget::QtDirWidget(QWidget *parent, QList versions, QtVersion *defaultVersion) +QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList versions, QtVersion *defaultVersion) : QWidget(parent) , m_defaultVersion(versions.indexOf(defaultVersion)) , m_specifyNameString(tr("")) @@ -138,7 +138,7 @@ QtDirWidget::QtDirWidget(QWidget *parent, QList versions, QtVersion updateState(); } -void QtDirWidget::buildDebuggingHelper() +void QtOptionsPageWidget::buildDebuggingHelper() { // Find the qt version for this button.. QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); @@ -161,7 +161,7 @@ void QtDirWidget::buildDebuggingHelper() m_ui->showLogButton->setEnabled(true); } -void QtDirWidget::showDebuggingBuildLog() +void QtOptionsPageWidget::showDebuggingBuildLog() { QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); if (!currentItem) @@ -175,13 +175,13 @@ void QtDirWidget::showDebuggingBuildLog() dlg.exec(); } -QtDirWidget::~QtDirWidget() +QtOptionsPageWidget::~QtOptionsPageWidget() { qDeleteAll(m_versions); delete m_ui; } -void QtDirWidget::addQtDir() +void QtOptionsPageWidget::addQtDir() { QtVersion *newVersion = new QtVersion(m_specifyNameString, m_specifyPathString); m_versions.append(newVersion); @@ -201,7 +201,7 @@ void QtDirWidget::addQtDir() m_ui->nameEdit->selectAll(); } -void QtDirWidget::removeQtDir() +void QtOptionsPageWidget::removeQtDir() { QTreeWidgetItem *item = m_ui->qtdirList->currentItem(); int index = m_ui->qtdirList->indexOfTopLevelItem(item); @@ -221,7 +221,7 @@ void QtDirWidget::removeQtDir() updateState(); } -void QtDirWidget::updateState() +void QtOptionsPageWidget::updateState() { bool enabled = (m_ui->qtdirList->currentItem() != 0); bool isSystemVersion = (enabled @@ -248,13 +248,13 @@ void QtDirWidget::updateState() m_ui->debuggingHelperStateLabel->setPixmap(QPixmap()); } } -void QtDirWidget::makeMingwVisible(bool visible) +void QtOptionsPageWidget::makeMingwVisible(bool visible) { m_ui->mingwLabel->setVisible(visible); m_ui->mingwPath->setVisible(visible); } -void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item) +void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item) { m_ui->msvcComboBox->setVisible(false); if (item) { @@ -304,7 +304,7 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item) } } -void QtDirWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old) +void QtOptionsPageWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old) { if (old) { fixQtVersionName(m_ui->qtdirList->indexOfTopLevelItem(old)); @@ -320,7 +320,7 @@ void QtDirWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old) updateState(); } -void QtDirWidget::onQtBrowsed() +void QtOptionsPageWidget::onQtBrowsed() { const QString dir = m_ui->qtPath->path(); if (dir.isEmpty()) @@ -336,7 +336,7 @@ void QtDirWidget::onQtBrowsed() updateState(); } -void QtDirWidget::onMingwBrowsed() +void QtOptionsPageWidget::onMingwBrowsed() { const QString dir = m_ui->mingwPath->path(); if (dir.isEmpty()) @@ -346,7 +346,7 @@ void QtDirWidget::onMingwBrowsed() updateState(); } -void QtDirWidget::defaultChanged(int) +void QtOptionsPageWidget::defaultChanged(int) { for (int i=0; idefaultCombo->count(); ++i) { if (m_versions.at(i)->name() == m_ui->defaultCombo->currentText()) { @@ -358,7 +358,7 @@ void QtDirWidget::defaultChanged(int) m_defaultVersion = 0; } -void QtDirWidget::updateCurrentQtName() +void QtOptionsPageWidget::updateCurrentQtName() { QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); Q_ASSERT(currentItem); @@ -370,7 +370,7 @@ void QtDirWidget::updateCurrentQtName() } -void QtDirWidget::finish() +void QtOptionsPageWidget::finish() { if (QTreeWidgetItem *item = m_ui->qtdirList->currentItem()) fixQtVersionName(m_ui->qtdirList->indexOfTopLevelItem(item)); @@ -380,7 +380,7 @@ void QtDirWidget::finish() * and otherwise changes the name * */ -void QtDirWidget::fixQtVersionName(int index) +void QtOptionsPageWidget::fixQtVersionName(int index) { int count = m_versions.count(); for (int i = 0; i < count; ++i) { @@ -407,7 +407,7 @@ void QtDirWidget::fixQtVersionName(int index) } } -void QtDirWidget::updateCurrentQtPath() +void QtOptionsPageWidget::updateCurrentQtPath() { QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); Q_ASSERT(currentItem); @@ -436,7 +436,7 @@ void QtDirWidget::updateCurrentQtPath() } } -void QtDirWidget::updateCurrentMingwDirectory() +void QtOptionsPageWidget::updateCurrentMingwDirectory() { QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); Q_ASSERT(currentItem); @@ -444,7 +444,7 @@ void QtDirWidget::updateCurrentMingwDirectory() m_versions[currentItemIndex]->setMingwDirectory(m_ui->mingwPath->path()); } -void QtDirWidget::msvcVersionChanged() +void QtOptionsPageWidget::msvcVersionChanged() { const QString &msvcVersion = m_ui->msvcComboBox->currentText(); QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); @@ -453,12 +453,12 @@ void QtDirWidget::msvcVersionChanged() m_versions[currentItemIndex]->setMsvcVersion(msvcVersion); } -QList QtDirWidget::versions() const +QList QtOptionsPageWidget::versions() const { return m_versions; } -int QtDirWidget::defaultVersion() const +int QtOptionsPageWidget::defaultVersion() const { return m_defaultVersion; } diff --git a/src/plugins/projectexplorer/qtoptionspage.h b/src/plugins/projectexplorer/qtoptionspage.h index 776a6cda010..4d7df925343 100644 --- a/src/plugins/projectexplorer/qtoptionspage.h +++ b/src/plugins/projectexplorer/qtoptionspage.h @@ -46,12 +46,12 @@ namespace Ui { class QtVersionManager; } -class QtDirWidget : public QWidget +class QtOptionsPageWidget : public QWidget { Q_OBJECT public: - QtDirWidget(QWidget *parent, QList versions, QtVersion *defaultVersion); - ~QtDirWidget(); + QtOptionsPageWidget(QWidget *parent, QList versions, QtVersion *defaultVersion); + ~QtOptionsPageWidget(); QList versions() const; int defaultVersion() const; void finish(); @@ -97,7 +97,7 @@ public: void apply(); void finish() { } private: - QtDirWidget *m_widget; + QtOptionsPageWidget *m_widget; }; } //namespace Internal diff --git a/src/plugins/projectexplorer/qtversionmanager.h b/src/plugins/projectexplorer/qtversionmanager.h index bfd26b95b57..31cbe85cdbc 100644 --- a/src/plugins/projectexplorer/qtversionmanager.h +++ b/src/plugins/projectexplorer/qtversionmanager.h @@ -39,12 +39,12 @@ namespace ProjectExplorer { namespace Internal { -class QtDirWidget; +class QtOptionsPageWidget; } class PROJECTEXPLORER_EXPORT QtVersion { - friend class Internal::QtDirWidget; //for changing name and path + friend class Internal::QtOptionsPageWidget; //for changing name and path friend class QtVersionManager; public: QtVersion(const QString &name, const QString &path); From 707476938766a0f7d44eef9c0f540ef9d4440ae7 Mon Sep 17 00:00:00 2001 From: dt Date: Thu, 23 Apr 2009 13:48:05 +0200 Subject: [PATCH 07/17] Remove setPrependPath() and prependPath() from qtversion They aren't used anymore. --- src/plugins/projectexplorer/qtversionmanager.cpp | 14 -------------- src/plugins/projectexplorer/qtversionmanager.h | 4 ++-- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/plugins/projectexplorer/qtversionmanager.cpp b/src/plugins/projectexplorer/qtversionmanager.cpp index 87577b2c27f..e46d6472c2c 100644 --- a/src/plugins/projectexplorer/qtversionmanager.cpp +++ b/src/plugins/projectexplorer/qtversionmanager.cpp @@ -78,7 +78,6 @@ QtVersionManager::QtVersionManager() id, s->value("IsSystemVersion", false).toBool()); version->setMingwDirectory(s->value("MingwDirectory").toString()); - version->setPrependPath(s->value("PrependPath").toString()); version->setMsvcVersion(s->value("msvcVersion").toString()); m_versions.append(version); } @@ -151,7 +150,6 @@ void QtVersionManager::writeVersionsIntoSettings() s->setValue("Path", m_versions.at(i)->path()); s->setValue("Id", m_versions.at(i)->uniqueId()); s->setValue("MingwDirectory", m_versions.at(i)->mingwDirectory()); - s->setValue("PrependPath", m_versions.at(i)->prependPath()); s->setValue("msvcVersion", m_versions.at(i)->msvcVersion()); s->setValue("IsSystemVersion", m_versions.at(i)->isSystemVersion()); } @@ -202,8 +200,6 @@ void QtVersionManager::addNewVersionsFromInstaller() QtVersion *version = new QtVersion(newVersionData[0], newVersionData[1], m_idcount++ ); if (newVersionData.count() >= 3) version->setMingwDirectory(newVersionData[2]); - if (newVersionData.count() >= 4) - version->setPrependPath(newVersionData[3]); bool versionWasAlreadyInList = false; foreach(const QtVersion * const it, m_versions) { @@ -871,16 +867,6 @@ void QtVersion::setMingwDirectory(const QString &directory) m_mingwDirectory = directory; } -QString QtVersion::prependPath() const -{ - return m_prependPath; -} - -void QtVersion::setPrependPath(const QString &directory) -{ - m_prependPath = directory; -} - QString QtVersion::msvcVersion() const { return m_msvcVersion; diff --git a/src/plugins/projectexplorer/qtversionmanager.h b/src/plugins/projectexplorer/qtversionmanager.h index 31cbe85cdbc..cece3e33a87 100644 --- a/src/plugins/projectexplorer/qtversionmanager.h +++ b/src/plugins/projectexplorer/qtversionmanager.h @@ -71,12 +71,11 @@ public: QString mingwDirectory() const; void setMingwDirectory(const QString &directory); - QString prependPath() const; - void setPrependPath(const QString &string); QString msvcVersion() const; QString wincePlatform() const; void setMsvcVersion(const QString &version); void addToEnvironment(ProjectExplorer::Environment &env); + bool hasDebuggingHelper() const; // Builds a debugging library // returns the output of the commands @@ -95,6 +94,7 @@ public: QString dumperLibrary() const; private: static int getUniqueId(); + // Also used by QtOptionsPageWidget void setName(const QString &name); void setPath(const QString &path); void updateSourcePath(); From 71cff0702ba9b6916a2fc3c106872d822b87610d Mon Sep 17 00:00:00 2001 From: dt Date: Thu, 23 Apr 2009 14:23:30 +0200 Subject: [PATCH 08/17] Refactroring: Small change to make the function more readeable --- src/plugins/projectexplorer/qtversionmanager.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/qtversionmanager.cpp b/src/plugins/projectexplorer/qtversionmanager.cpp index e46d6472c2c..dae9faddca4 100644 --- a/src/plugins/projectexplorer/qtversionmanager.cpp +++ b/src/plugins/projectexplorer/qtversionmanager.cpp @@ -476,7 +476,6 @@ void QtVersion::updateSourcePath() // QtVersion *QtVersionManager::qtVersionForDirectory(const QString directory); QString QtVersionManager::findQtVersionFromMakefile(const QString &directory) { - QString result = QString::null; bool debugAdding = false; QFile makefile(directory + "/Makefile" ); if (makefile.exists() && makefile.open(QFile::ReadOnly)) { @@ -492,14 +491,12 @@ QString QtVersionManager::findQtVersionFromMakefile(const QString &directory) QString qtDir = binDir.absolutePath(); if (debugAdding) qDebug() << "#~~ QtDir:"< Date: Thu, 23 Apr 2009 14:25:47 +0200 Subject: [PATCH 09/17] Make the public interface of QtVersionManager smaller Move 3 functions to private, declare 2 which don't need any instance to staic methods. --- .../projectexplorer/qtversionmanager.h | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/plugins/projectexplorer/qtversionmanager.h b/src/plugins/projectexplorer/qtversionmanager.h index cece3e33a87..381cbec3562 100644 --- a/src/plugins/projectexplorer/qtversionmanager.h +++ b/src/plugins/projectexplorer/qtversionmanager.h @@ -126,34 +126,39 @@ private: class PROJECTEXPLORER_EXPORT QtVersionManager : public QObject { Q_OBJECT + // for getUniqueId(); + friend class QtVersion; + friend class QtOptionsPage; public: static QtVersionManager *instance(); QtVersionManager(); ~QtVersionManager(); - void writeVersionsIntoSettings(); QList versions() const; - QtVersion * version(int id) const; - QtVersion * currentQtVersion() const; - // internal - int getUniqueId(); + QtVersion *version(int id) const; + QtVersion *currentQtVersion() const; - QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig); - QString findQtVersionFromMakefile(const QString &directory); QtVersion *qtVersionForDirectory(const QString &directory); // Used by the projectloadwizard void addVersion(QtVersion *version); + // Static Methods // returns something like qmake4, qmake, qmake-qt4 or whatever distributions have chosen (used by QtVersion) static QStringList possibleQMakeCommands(); // return true if the qmake at qmakePath is qt4 (used by QtVersion) static QString qtVersionForQMake(const QString &qmakePath); - void setNewQtVersions(QList newVersions, int newDefaultVersion); + static QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig); + static QString findQtVersionFromMakefile(const QString &directory); signals: void defaultQtVersionChanged(); void qtVersionsChanged(); private: + // Used by QtOptionsPage + void setNewQtVersions(QList newVersions, int newDefaultVersion); + // Used by QtVersion + int getUniqueId(); + void writeVersionsIntoSettings(); void addNewVersionsFromInstaller(); void updateSystemVersion(); void updateDocumentation(); From 37e382b3bdca45d29cb737ec748fe52a86cb504f Mon Sep 17 00:00:00 2001 From: dt Date: Thu, 23 Apr 2009 14:36:47 +0200 Subject: [PATCH 10/17] Don't use the QtVersionManger::instance() where it isn't needed. Allows removing getting the instance once. --- src/plugins/qt4projectmanager/projectloadwizard.cpp | 4 ++-- src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/plugins/qt4projectmanager/projectloadwizard.cpp b/src/plugins/qt4projectmanager/projectloadwizard.cpp index 2d943a019c0..31c0da2cde1 100644 --- a/src/plugins/qt4projectmanager/projectloadwizard.cpp +++ b/src/plugins/qt4projectmanager/projectloadwizard.cpp @@ -52,7 +52,7 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W { ProjectExplorer::QtVersionManager * vm = ProjectExplorer::QtVersionManager::instance(); QString directory = QFileInfo(project->file()->fileName()).absolutePath(); - QString importVersion = vm->findQtVersionFromMakefile(directory); + QString importVersion = ProjectExplorer::QtVersionManager::findQtVersionFromMakefile(directory); if (!importVersion.isNull()) { // This also means we have a build in there @@ -65,7 +65,7 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W } m_importBuildConfig = m_importVersion->defaultBuildConfig(); - m_importBuildConfig= vm->scanMakefileForQmakeConfig(directory, m_importBuildConfig); + m_importBuildConfig= ProjectExplorer::QtVersionManager::scanMakefileForQmakeConfig(directory, m_importBuildConfig); } // So now we have the version and the configuration for that version diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp index 9e7fd93e778..a50d23bd98c 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp @@ -184,8 +184,7 @@ void Qt4ProjectConfigWidget::updateImportLabel() { m_ui->importLabel->setVisible(false); if (m_ui->shadowBuildCheckBox->isChecked()) { - ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance(); - QString qtPath = vm->findQtVersionFromMakefile(m_ui->shadowBuildDirEdit->path()); + QString qtPath = ProjectExplorer::QtVersionManager::findQtVersionFromMakefile(m_ui->shadowBuildDirEdit->path()); if (!qtPath.isEmpty()) { m_ui->importLabel->setVisible(true); } @@ -219,16 +218,16 @@ void Qt4ProjectConfigWidget::importLabelClicked() if (m_ui->shadowBuildCheckBox->isChecked()) { QString directory = m_ui->shadowBuildDirEdit->path(); if (!directory.isEmpty()) { - QtVersionManager *vm = QtVersionManager::instance(); - QString qtPath = vm->findQtVersionFromMakefile(directory); + QString qtPath = QtVersionManager::findQtVersionFromMakefile(directory); if (!qtPath.isEmpty()) { + QtVersionManager *vm = QtVersionManager::instance(); QtVersion *version = vm->qtVersionForDirectory(qtPath); if (!version) { version = new QtVersion(QFileInfo(qtPath).baseName(), qtPath); vm->addVersion(version); } QtVersion::QmakeBuildConfig qmakeBuildConfig = version->defaultBuildConfig(); - qmakeBuildConfig = vm->scanMakefileForQmakeConfig(directory, qmakeBuildConfig); + qmakeBuildConfig = QtVersionManager::scanMakefileForQmakeConfig(directory, qmakeBuildConfig); // So we got all the information now apply it... m_pro->setQtVersion(m_buildConfiguration, version->uniqueId()); From 160247834acdb77953bfb254e8c587c694346f61 Mon Sep 17 00:00:00 2001 From: jasplin Date: Thu, 23 Apr 2009 14:41:55 +0200 Subject: [PATCH 11/17] Revert "Workaround backspace issue for now" This reverts commit ebfcd35ace30e902e64fb027e0395107f41e28ce. Qt 4.5 commit b51dd5a7b328291c5dbda540ce228e7d867662cb eliminates the need for this workaround for now. --- src/plugins/texteditor/basetexteditor.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 76df5c71d18..9724ccf0b7f 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -1034,10 +1034,7 @@ bool BaseTextEditor::event(QEvent *e) d->m_contentsChanged = false; switch (e->type()) { case QEvent::ShortcutOverride: - if (static_cast(e)->key() == Qt::Key_Backspace) - e->accept(); - else - e->ignore(); // we are a really nice citizen + e->ignore(); // we are a really nice citizen return true; default: break; From 94512b82a4c73bd3bc75edcbc15f662aad5227b9 Mon Sep 17 00:00:00 2001 From: con Date: Thu, 23 Apr 2009 16:13:26 +0200 Subject: [PATCH 12/17] Compile. --- src/plugins/projectexplorer/qtversionmanager.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/qtversionmanager.h b/src/plugins/projectexplorer/qtversionmanager.h index 381cbec3562..990214769fb 100644 --- a/src/plugins/projectexplorer/qtversionmanager.h +++ b/src/plugins/projectexplorer/qtversionmanager.h @@ -40,6 +40,7 @@ namespace ProjectExplorer { namespace Internal { class QtOptionsPageWidget; +class QtOptionsPage; } class PROJECTEXPLORER_EXPORT QtVersion @@ -128,7 +129,7 @@ class PROJECTEXPLORER_EXPORT QtVersionManager : public QObject Q_OBJECT // for getUniqueId(); friend class QtVersion; - friend class QtOptionsPage; + friend class Internal::QtOptionsPage; public: static QtVersionManager *instance(); QtVersionManager(); From f933f52111afc6a99b5b00f7b701c8c0f383b30c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Apr 2009 16:49:55 +0200 Subject: [PATCH 13/17] use pixel font sizes the qt layout system is pixel-based, so using point sizes doesn't work for anyone with a different resolution (DPI) than me --- src/plugins/coreplugin/welcomemode.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/coreplugin/welcomemode.ui b/src/plugins/coreplugin/welcomemode.ui index 41686e7fb85..d9514d9f18f 100644 --- a/src/plugins/coreplugin/welcomemode.ui +++ b/src/plugins/coreplugin/welcomemode.ui @@ -26,7 +26,7 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 *, * *, * * *, * * * *, * * * * * { font-family: Arial, Trebuchet, Lucida, sans-serif; -font-size: 9pt; +font-size: 12px; color: #5e5e5e; } @@ -118,7 +118,7 @@ border-width: 8 8 8 8; <style> h1 { - font-size: 2em; + font-size: 24px; font-weight: normal; color: #4d4d4d; margin-top: 0px; From a71436649c2ec4bdd3732ee81cacd4165b1d8c00 Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 23 Apr 2009 17:28:53 +0200 Subject: [PATCH 14/17] removed the folding ribbon from the default configuration, instead turned a new block highlighting mechanism on. --- src/plugins/texteditor/basetexteditor.cpp | 141 ++++++++++++++++++--- src/plugins/texteditor/basetexteditor.h | 4 + src/plugins/texteditor/basetexteditor_p.h | 16 +++ src/plugins/texteditor/displaysettings.cpp | 8 +- 4 files changed, 150 insertions(+), 19 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 9724ccf0b7f..081d343764a 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -188,6 +188,10 @@ BaseTextEditor::BaseTextEditor(QWidget *parent) d->m_parenthesesMatchingTimer->setSingleShot(true); connect(d->m_parenthesesMatchingTimer, SIGNAL(timeout()), this, SLOT(_q_matchParentheses())); + d->m_highlightBlocksTimer = new QTimer(this); + d->m_highlightBlocksTimer->setSingleShot(true); + connect(d->m_highlightBlocksTimer, SIGNAL(timeout()), this, SLOT(_q_highlightBlocks())); + d->m_searchResultFormat.setBackground(QColor(0xffef0b)); @@ -429,6 +433,23 @@ bool DocumentMarker::addMark(TextEditor::ITextMark *mark, int line) return false; } +int BaseTextEditorPrivate::visualIndent(const QTextBlock &block) const +{ + if (!block.isValid()) + return 0; + const QTextDocument *document = block.document(); + int i = 0; + while (i < block.length()) { + if (!document->characterAt(block.position() + i).isSpace()) { + QTextCursor cursor(block); + cursor.setPosition(block.position() + i); + return q->cursorRect(cursor).x(); + } + ++i; + } + + return 0; +} TextEditor::TextMarks DocumentMarker::marksAt(int line) const { @@ -1198,8 +1219,11 @@ bool BaseTextEditor::lineSeparatorsAllowed() const void BaseTextEditor::setHighlightBlocks(bool b) { - d->m_highlightBlocks = b & d->m_codeFoldingSupported; - viewport()->update(); + if (d->m_highlightBlocks == b) + return; + d->m_highlightBlocks = b; + d->m_highlightBlocksInfo = BaseTextEditorPrivateHighlightBlocks(); + _q_highlightBlocks(); } bool BaseTextEditor::highlightBlocks() const @@ -1755,22 +1779,28 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) QTextBlock visibleCollapsedBlock; QPointF visibleCollapsedBlockOffset; + + while (block.isValid()) { QRectF r = blockBoundingRect(block).translated(offset); if (d->m_highlightBlocks) { - QTextBlock previousBlock = block.previous(); - if (previousBlock.isValid()){ - int thisBraceDepth = block.userState(); - if (thisBraceDepth >= 0) - thisBraceDepth >>= 8; - int braceDepth = block.previous().userState(); - if (braceDepth >= 0) - braceDepth >>= 8; - int minBraceDepth = qMin(thisBraceDepth, braceDepth); - if (minBraceDepth > 0) { - painter.fillRect(r, calcBlendColor(baseColor, minBraceDepth)); + + int n = block.blockNumber(); + int depth = 0; + foreach (int i, d->m_highlightBlocksInfo.open) + if (n >= i) + ++depth; + foreach (int i, d->m_highlightBlocksInfo.close) + if (n > i) + --depth; + + int count = d->m_highlightBlocksInfo.visualIndent.size(); + if (count) { + for(int i = 0; i <= depth; ++i) { + int vi = i > 0 ? d->m_highlightBlocksInfo.visualIndent.at(i-1) : 0; + painter.fillRect(r.adjusted(vi, 0, 0, 0), calcBlendColor(baseColor, count - i)); } } } @@ -1814,7 +1844,7 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) else selections.append(o); } else if (!range.cursor.hasSelection() && range.format.hasProperty(QTextFormat::FullWidthSelection) - && block.contains(range.cursor.position())) { + && block.contains(range.cursor.position())) { // for full width selections we don't require an actual selection, just // a position to specify the line. that's more convenience in usage. QTextLayout::FormatRange o; @@ -1881,7 +1911,6 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) // invisible blocks do have zero line count block = doc->findBlockByLineNumber(block.firstLineNumber()); } - } if (backgroundVisible() && !block.isValid() && offset.y() <= er.bottom() @@ -2390,6 +2419,10 @@ void BaseTextEditor::slotCursorPositionChanged() } setExtraSelections(CurrentLineSelection, extraSelections); + + if (d->m_highlightBlocks) { + d->m_highlightBlocksTimer->start(100); + } } void BaseTextEditor::slotUpdateBlockNotify(const QTextBlock &block) @@ -3139,6 +3172,67 @@ bool TextBlockUserData::findNextClosingParenthesis(QTextCursor *cursor, bool sel return false; } +bool TextBlockUserData::findPreviousBlockOpenParenthesis(QTextCursor *cursor) +{ + QTextBlock block = cursor->block(); + int position = cursor->position(); + int ignore = 0; + while (block.isValid()) { + Parentheses parenList = TextEditDocumentLayout::parentheses(block); + if (!parenList.isEmpty() && !TextEditDocumentLayout::ifdefedOut(block)) { + for (int i = parenList.count()-1; i >= 0; --i) { + Parenthesis paren = parenList.at(i); + if (paren.chr != QLatin1Char('{') && paren.chr != QLatin1Char('}') + && paren.chr != QLatin1Char('+') && paren.chr != QLatin1Char('-')) + continue; + if (block == cursor->block() && + (position - block.position() <= paren.pos)) + continue; + if (paren.type == Parenthesis::Closed) { + ++ignore; + } else if (ignore > 0) { + --ignore; + } else { + cursor->setPosition(block.position() + paren.pos); + return true; + } + } + } + block = block.previous(); + } + return false; +} + +bool TextBlockUserData::findNextBlockClosingParenthesis(QTextCursor *cursor) +{ + QTextBlock block = cursor->block(); + int position = cursor->position(); + int ignore = 0; + while (block.isValid()) { + Parentheses parenList = TextEditDocumentLayout::parentheses(block); + if (!parenList.isEmpty() && !TextEditDocumentLayout::ifdefedOut(block)) { + for (int i = 0; i < parenList.count(); ++i) { + Parenthesis paren = parenList.at(i); + if (paren.chr != QLatin1Char('{') && paren.chr != QLatin1Char('}') + && paren.chr != QLatin1Char('+') && paren.chr != QLatin1Char('-')) + continue; + if (block == cursor->block() && position - block.position() >= paren.pos) + continue; + if (paren.type == Parenthesis::Opened) { + ++ignore; + } else if (ignore > 0) { + --ignore; + } else { + cursor->setPosition(block.position() + paren.pos+1); + return true; + } + } + } + block = block.next(); + } + return false; +} + TextBlockUserData::MatchType TextBlockUserData::matchCursorBackward(QTextCursor *cursor) { cursor->clearSelection(); @@ -3274,6 +3368,23 @@ void BaseTextEditor::_q_matchParentheses() setExtraSelections(ParenthesesMatchingSelection, extraSelections); } +void BaseTextEditor::_q_highlightBlocks() +{ + QTextCursor cursor = textCursor(); + QTextCursor closeCursor = cursor; + BaseTextEditorPrivateHighlightBlocks highlightBlocksInfo; + while (TextBlockUserData::findPreviousBlockOpenParenthesis(&cursor)) { + highlightBlocksInfo.open.prepend(cursor.blockNumber()); + highlightBlocksInfo.visualIndent.prepend(d->visualIndent(cursor.block())); + if (TextBlockUserData::findNextBlockClosingParenthesis(&closeCursor)) + highlightBlocksInfo.close.append(closeCursor.blockNumber()); + } + if (d->m_highlightBlocksInfo != highlightBlocksInfo) { + d->m_highlightBlocksInfo = highlightBlocksInfo; + viewport()->update(); + } +} + void BaseTextEditor::setActionHack(QObject *hack) { d->m_actionHack = hack; diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 19ce6b36799..f0669a71046 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -167,6 +167,9 @@ public: static bool findPreviousOpenParenthesis(QTextCursor *cursor, bool select = false); static bool findNextClosingParenthesis(QTextCursor *cursor, bool select = false); + static bool findPreviousBlockOpenParenthesis(QTextCursor *cursor); + static bool findNextBlockClosingParenthesis(QTextCursor *cursor); + private: TextMarks m_marks; @@ -464,6 +467,7 @@ private: // parentheses matcher private slots: void _q_matchParentheses(); + void _q_highlightBlocks(); void slotSelectionChanged(); }; diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h index 74f158dab5e..9bff3da0f41 100644 --- a/src/plugins/texteditor/basetexteditor_p.h +++ b/src/plugins/texteditor/basetexteditor_p.h @@ -114,6 +114,17 @@ private: //================BaseTextEditorPrivate============== +struct BaseTextEditorPrivateHighlightBlocks +{ + QList open; + QList close; + QList visualIndent; + inline bool operator==(const BaseTextEditorPrivateHighlightBlocks &o) const { + return (open == o.open && close == o.close && visualIndent == o.visualIndent); + } + inline bool operator!=(const BaseTextEditorPrivateHighlightBlocks &o) const { return !(*this == o); } +}; + class BaseTextEditorPrivate { BaseTextEditorPrivate(const BaseTextEditorPrivate &); @@ -219,6 +230,11 @@ public: QTextCursor m_selectBlockAnchor; void moveCursorVisible(bool ensureVisible = true); + + int visualIndent(const QTextBlock &block) const; + BaseTextEditorPrivateHighlightBlocks m_highlightBlocksInfo; + QTimer *m_highlightBlocksTimer; + }; } // namespace Internal diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp index 47e9ad4d474..27480d3dcc5 100644 --- a/src/plugins/texteditor/displaysettings.cpp +++ b/src/plugins/texteditor/displaysettings.cpp @@ -39,9 +39,9 @@ static const char * const textWrappingKey = "TextWrapping"; static const char * const showWrapColumnKey = "ShowWrapColumn"; static const char * const wrapColumnKey = "WrapColumn"; static const char * const visualizeWhitespaceKey = "VisualizeWhitespace"; -static const char * const displayFoldingMarkersKey = "DisplayFoldingMarkers"; +static const char * const displayFoldingMarkersKey = "DisplayFoldingMarkersV2"; static const char * const highlightCurrentLineKey = "HighlightCurrentLineKey"; -static const char * const highlightBlocksKey = "HighlightBlocksKey"; +static const char * const highlightBlocksKey = "HighlightBlocksKeyV2"; static const char * const groupPostfix = "DisplaySettings"; namespace TextEditor { @@ -52,9 +52,9 @@ DisplaySettings::DisplaySettings() : m_showWrapColumn(false), m_wrapColumn(80), m_visualizeWhitespace(false), - m_displayFoldingMarkers(true), + m_displayFoldingMarkers(false), m_highlightCurrentLine(true), - m_highlightBlocks(false) + m_highlightBlocks(true) { } From 840cf145f3e0f8205f81d9817543067d1021573e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Apr 2009 17:30:23 +0200 Subject: [PATCH 15/17] don't oversize sessions frame when it is smaller than the projects frame --- src/plugins/coreplugin/welcomemode.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/welcomemode.ui b/src/plugins/coreplugin/welcomemode.ui index d9514d9f18f..c4189e142df 100644 --- a/src/plugins/coreplugin/welcomemode.ui +++ b/src/plugins/coreplugin/welcomemode.ui @@ -206,7 +206,7 @@ p { 0 - + From a180345b169e9efea9ee2a9b106bca0914581275 Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 23 Apr 2009 19:24:57 +0200 Subject: [PATCH 16/17] make move line up/down only move the selected line if the end of the selection is at the beginning of the next block. Join the undo commands for subsequent moves. --- src/plugins/texteditor/basetexteditor.cpp | 12 +++++++++--- src/plugins/texteditor/basetexteditor_p.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 081d343764a..7dcfcf5679c 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -714,7 +714,10 @@ void BaseTextEditor::moveLineUpDown(bool up) { QTextCursor cursor = textCursor(); QTextCursor move = cursor; - move.beginEditBlock(); + if (d->m_moveLineUndoHack) + move.joinPreviousEditBlock(); + else + move.beginEditBlock(); bool hasSelection = cursor.hasSelection(); @@ -722,7 +725,7 @@ void BaseTextEditor::moveLineUpDown(bool up) move.setPosition(cursor.selectionStart()); move.movePosition(QTextCursor::StartOfBlock); move.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor); - move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); + move.movePosition(move.atBlockStart() ? QTextCursor::Left: QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); } else { move.movePosition(QTextCursor::StartOfBlock); move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); @@ -760,6 +763,7 @@ void BaseTextEditor::moveLineUpDown(bool up) move.endEditBlock(); setTextCursor(move); + d->m_moveLineUndoHack = true; } void BaseTextEditor::cleanWhitespace() @@ -769,6 +773,7 @@ void BaseTextEditor::cleanWhitespace() void BaseTextEditor::keyPressEvent(QKeyEvent *e) { + d->m_moveLineUndoHack = false; d->clearVisibleCollapsedBlock(); QKeyEvent *original_e = e; @@ -1305,7 +1310,8 @@ BaseTextEditorPrivate::BaseTextEditorPrivate() m_actionHack(0), m_inBlockSelectionMode(false), m_lastEventWasBlockSelectionEvent(false), - m_blockSelectionExtraX(0) + m_blockSelectionExtraX(0), + m_moveLineUndoHack(false) { } diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h index 9bff3da0f41..844d3777689 100644 --- a/src/plugins/texteditor/basetexteditor_p.h +++ b/src/plugins/texteditor/basetexteditor_p.h @@ -225,6 +225,7 @@ public: void clearBlockSelection(); QString copyBlockSelection(); void removeBlockSelection(const QString &text = QString()); + bool m_moveLineUndoHack; QTextCursor m_findScope; QTextCursor m_selectBlockAnchor; From dfd2c5dbc381ae4bb630e888a5f03fd39926a54b Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 23 Apr 2009 20:11:00 +0200 Subject: [PATCH 17/17] small block highlighting cleanup for the no-wrapping case with overlong lines --- src/plugins/texteditor/basetexteditor.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 7dcfcf5679c..e821bce1239 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -1746,11 +1746,11 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) painter.fillRect(QRectF(lineX, 0, viewportRect.width() - lineX, viewportRect.height()), blendColor); } - // keep right margin clean from full-width selection - int maxX = offset.x() + qMax((qreal)viewportRect.width(), documentLayout->documentSize().width()) - - doc->documentMargin(); - er.setRight(qMin(er.right(), maxX)); - painter.setClipRect(er); +// // keep right margin clean from full-width selection +// int maxX = offset.x() + qMax((qreal)viewportRect.width(), documentLayout->documentSize().width()) +// - doc->documentMargin(); +// er.setRight(qMin(er.right(), maxX)); +// painter.setClipRect(er); bool editable = !isReadOnly(); @@ -1804,9 +1804,11 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) int count = d->m_highlightBlocksInfo.visualIndent.size(); if (count) { + QRectF rr = r; + rr.setWidth(viewport()->width()); for(int i = 0; i <= depth; ++i) { int vi = i > 0 ? d->m_highlightBlocksInfo.visualIndent.at(i-1) : 0; - painter.fillRect(r.adjusted(vi, 0, 0, 0), calcBlendColor(baseColor, count - i)); + painter.fillRect(rr.adjusted(vi, 0, -8*i, 0), calcBlendColor(baseColor, count - i)); } } }