diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index 735afc37989b1d565369b5ea7f42d3c2374fad3e..86b5d889dbdb523daf06f333286c9ed79901e206 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -563,7 +563,7 @@ TextEditor::ITextEditor *BookmarkManager::currentTextEditor() const } /* Returns the current session. */ -SessionManager* BookmarkManager::sessionManager() const +SessionManager *BookmarkManager::sessionManager() const { ExtensionSystem::PluginManager *pm = m_core->pluginManager(); ProjectExplorerPlugin *pe = pm->getObject<ProjectExplorerPlugin>(); diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 0f5029c8eaf1bc68675ef4b44a66fe454b5e7e10..effe432e36ade9e953ae7eceace894c7221feba0 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -215,11 +215,6 @@ ProjectExplorer::IProjectManager *CMakeProject::projectManager() const return m_manager; } -QList<Core::IFile *> CMakeProject::dependencies() -{ - return QList<Core::IFile *>(); -} - QList<ProjectExplorer::Project *> CMakeProject::dependsOn() { return QList<Project *>(); diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index cdabdf1d0845d1bb77b732352fbed79df44a48d1..a71ca7c8b008d477be1fad35bf59eeeb38e61d61 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -73,7 +73,6 @@ public: virtual Core::IFile *file() const; virtual ProjectExplorer::IProjectManager *projectManager() const; - virtual QList<Core::IFile *> dependencies(); //NBS TODO remove virtual QList<ProjectExplorer::Project *> dependsOn(); //NBS TODO implement dependsOn virtual bool isApplication() const; diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 06bb2755a8c6d8078d5d7edea13c6565b7ccb0e6..f5677c4964a2bc5cbecab5cac7193ca5af512446 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -433,6 +433,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand) if (!dotCommand.isEmpty()) m_dotCommand = "c" + dotCommand; QString text = recordRemoveSelectedText(); + qDebug() << "CHANGING TO INSERT MODE" << text; m_registers[m_register] = text; m_mode = InsertMode; m_submode = NoSubMode; @@ -949,7 +950,12 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, } else if (key == control('v')) { enterVisualMode(VisualBlockMode); } else if (key == 'w') { - moveToNextWord(false); + // Special case: "cw" and "cW" work the same as "ce" and "cE" if the + // cursor is on a non-blank. + if (m_submode == ChangeSubMode) + moveToWordBoundary(false, true); + else + moveToNextWord(false); finishMovement("w"); } else if (key == 'W') { moveToNextWord(true); @@ -1513,15 +1519,15 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward) int repeat = count(); QTextDocument *doc = m_tc.document(); int n = forward ? lastPositionInDocument() - 1 : 0; - int lastClass = 0; + int lastClass = -1; while (true) { - m_tc.movePosition(forward ? Right : Left, KeepAnchor, 1); + forward ? moveRight() : moveLeft(); QChar c = doc->characterAt(m_tc.position()); int thisClass = charClass(c, simple); if (thisClass != lastClass && lastClass != 0) --repeat; if (repeat == -1) { - m_tc.movePosition(forward ? Left : Right, KeepAnchor, 1); + forward ? moveLeft() : moveRight(); break; } lastClass = thisClass; @@ -1586,7 +1592,7 @@ void FakeVimHandler::Private::moveToNextWord(bool simple) if (repeat == 0) break; lastClass = thisClass; - m_tc.movePosition(Right, KeepAnchor, 1); + moveRight(); if (m_tc.position() == n) break; } @@ -1799,11 +1805,13 @@ void FakeVimHandler::Private::recordEndGroup() QString FakeVimHandler::Private::recordRemoveSelectedText() { EditOperation op; + //qDebug() << "1 POS: " << position() << " ANCHOR: " << anchor() << m_tc.anchor(); m_tc.setPosition(anchor(), KeepAnchor); op.m_position = qMin(position(), anchor()); + //qDebug() << "2 POS: " << position() << " ANCHOR: " << anchor() << m_tc.anchor(); op.m_from = m_tc.selection().toPlainText(); recordOperation(op); - m_tc.removeSelectedText(); + m_tc.deleteChar(); return op.m_from; } diff --git a/src/plugins/projectexplorer/buildparserinterface.h b/src/plugins/projectexplorer/buildparserinterface.h index 6dba4dfec00199f5cec6be02780764073be88cad..2857926e18dfc4d3abe39d14cb6b41fd20874bef 100644 --- a/src/plugins/projectexplorer/buildparserinterface.h +++ b/src/plugins/projectexplorer/buildparserinterface.h @@ -66,7 +66,7 @@ class PROJECTEXPLORER_EXPORT IBuildParserFactory Q_OBJECT public: - IBuildParserFactory() {}; + IBuildParserFactory() {} virtual ~IBuildParserFactory(); virtual bool canCreate(const QString & name) const = 0; virtual BuildParserInterface * create(const QString & name) const = 0; diff --git a/src/plugins/projectexplorer/dependenciesdialog.cpp b/src/plugins/projectexplorer/dependenciesdialog.cpp deleted file mode 100644 index 9c78de543ad66f862ccf3865edf58b00a2a4fd26..0000000000000000000000000000000000000000 --- a/src/plugins/projectexplorer/dependenciesdialog.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/*************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Qt Software Information (qt-info@nokia.com) -** -** -** Non-Open Source Usage -** -** Licensees may use this file in accordance with the Qt Beta Version -** License Agreement, Agreement version 2.2 provided with the Software or, -** alternatively, in accordance with the terms contained in a written -** agreement between you and Nokia. -** -** GNU General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the packaging -** of this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt GPL Exception -** version 1.3, included in the file GPL_EXCEPTION.txt in this package. -** -***************************************************************************/ - -#include "dependenciesdialog.h" -#include "project.h" -#include "session.h" - -#include <QtCore/QVector> -#include <QtCore/QDebug> -#include <QtCore/QAbstractTableModel> -#include <QtGui/QPushButton> -#include <QtGui/QHeaderView> - -namespace ProjectExplorer { -namespace Internal { - -// ------ DependencyModel - -class DependencyModel : public QAbstractTableModel { -public: - typedef ProjectExplorer::Project Project; - typedef DependenciesDialog::ProjectList ProjectList; - - DependencyModel(SessionManager *sln, const ProjectList &projectList, QObject * parent = 0); - - virtual int rowCount(const QModelIndex&) const { return m_projects.size(); } - virtual int columnCount(const QModelIndex&) const { return m_projects.size(); } - - virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; - bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); - - virtual Qt::ItemFlags flags ( const QModelIndex & index ) const; - - QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; - - // Apply changed items - unsigned apply(SessionManager *sln) const; - - void resetDependencies(); - -private: - - struct Entry { - Entry(SessionManager *sln, Project *rootProject, Project *dependentProject); - Entry() : m_dependentProject(0), m_dependent(false), m_defaultValue(false), m_canAddDependency(false) {} - Project* m_dependentProject; - bool m_dependent; - bool m_defaultValue; - bool m_canAddDependency; - }; - - // column - typedef QVector<Entry> ProjectDependencies; - typedef QList<ProjectDependencies> Projects; - Projects m_projects; - ProjectList m_projectList; -}; - -DependencyModel::Entry::Entry(SessionManager *sln, - Project *rootProject, - Project *dependentProject) : - m_dependentProject(dependentProject), - m_dependent(sln->hasDependency(rootProject, dependentProject)), - m_defaultValue(m_dependent), - m_canAddDependency(sln->canAddDependency(rootProject, dependentProject)) -{ -} - -DependencyModel::DependencyModel(SessionManager *sln, - const ProjectList &projectList, - QObject * parent) : - QAbstractTableModel(parent), - m_projectList(projectList) -{ - const int count = projectList.size(); - for (int p = 0; p < count; p++) { - Project *rootProject = projectList.at(p); - ProjectDependencies dependencies; - dependencies.reserve(count); - for (int d = 0; d < count ; d++) - dependencies.push_back(p == d ? Entry() : Entry(sln, rootProject, projectList.at(d))); - - m_projects += dependencies; - } -} - -QVariant DependencyModel::data ( const QModelIndex & index, int role ) const -{ - static const QVariant empty = QVariant(QString()); - // TO DO: find a checked icon - static const QVariant checked = QVariant(QString(QLatin1Char('x'))); - - const int p = index.column(); - const int d = index.row(); - switch (role) { - case Qt::EditRole: - return QVariant(m_projects[p][d].m_dependent); - case Qt::DisplayRole: - return m_projects[p][d].m_dependent ? checked : empty; - default: - break; - } - return QVariant(); -} - -bool DependencyModel::setData ( const QModelIndex & index, const QVariant & value, int role) -{ - switch (role) { - case Qt::EditRole: { - const int p = index.column(); - const int d = index.row(); - if (d == p) - return false; - Entry &e(m_projects[p][d]); - e.m_dependent = value.toBool(); - emit dataChanged(index, index); - } - return true; - default: - break; - } - return false; -} - -Qt::ItemFlags DependencyModel::flags ( const QModelIndex & index ) const -{ - const int p = index.column(); - const int d = index.row(); - - if (d == p) - return 0; - - const Entry &e(m_projects[p][d]); - Qt::ItemFlags rc = Qt::ItemIsEnabled|Qt::ItemIsUserCheckable | Qt::ItemIsSelectable; - if (e.m_canAddDependency) - rc |= Qt::ItemIsEditable; - return rc; -} - -QVariant DependencyModel::headerData ( int section, Qt::Orientation , int role ) const -{ - switch (role) { - case Qt::DisplayRole: - return QVariant(m_projectList.at(section)->name()); - default: - break; - } - return QVariant(); -} - -void DependencyModel::resetDependencies() -{ - if (const int count = m_projectList.size()) { - for (int p = 0; p < count; p++) - for (int d = 0; d < count; d++) - m_projects[p][d].m_dependent = false; - reset(); - } -} - -unsigned DependencyModel::apply(SessionManager *sln) const -{ - unsigned rc = 0; - const int count = m_projectList.size(); - for (int p = 0; p < count; p++) { - Project *rootProject = m_projectList.at(p); - for (int d = 0; d < count; d++) { - if (d != p) { - const Entry &e(m_projects[p][d]); - if (e.m_dependent != e. m_defaultValue) { - rc++; - if (e.m_dependent) { - sln->addDependency(rootProject, e.m_dependentProject); - } else { - sln->removeDependency(rootProject, e.m_dependentProject); - } - } - } - } - } - return rc; -} - -// ------ DependenciesDialog -DependenciesDialog::DependenciesDialog(QWidget *parent, SessionManager *sln) : - QDialog(parent), - m_sln(sln), - m_projectList(m_sln->projects()), - m_model(new DependencyModel(sln, m_projectList)) -{ - m_ui.setupUi(this); - m_ui.buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); - QPushButton *resetButton = m_ui.buttonBox->addButton (QDialogButtonBox::Reset); - connect(resetButton, SIGNAL(clicked()), this, SLOT(reset())); - - m_ui.dependencyTable->setModel(m_model); -} - -void DependenciesDialog::accept() -{ - m_model->apply(m_sln); - QDialog::accept(); -} - -void DependenciesDialog::reset() -{ - m_model->resetDependencies(); -} - -DependenciesDialog::~DependenciesDialog() -{ -} - -} -} diff --git a/src/plugins/projectexplorer/dependenciesdialog.ui b/src/plugins/projectexplorer/dependenciesdialog.ui deleted file mode 100644 index 31a70dae9832c5d27b5eac73cbfe44665201aac8..0000000000000000000000000000000000000000 --- a/src/plugins/projectexplorer/dependenciesdialog.ui +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ProjectExplorer::Internal::DependenciesDialog</class> - <widget class="QDialog" name="ProjectExplorer::Internal::DependenciesDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>492</width> - <height>435</height> - </rect> - </property> - <property name="windowTitle"> - <string>Project Dependencies</string> - </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>9</number> - </property> - <item> - <widget class="QTableView" name="dependencyTable"> - <property name="selectionMode"> - <enum>QAbstractItemView::SingleSelection</enum> - </property> - </widget> - </item> - <item> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ProjectExplorer::Internal::DependenciesDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>142</x> - <y>285</y> - </hint> - <hint type="destinationlabel"> - <x>142</x> - <y>155</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ProjectExplorer::Internal::DependenciesDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>142</x> - <y>285</y> - </hint> - <hint type="destinationlabel"> - <x>142</x> - <y>155</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/plugins/projectexplorer/dependenciespanel.cpp b/src/plugins/projectexplorer/dependenciespanel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bc83f7408a46c6253efacbb6399a96aee01fa3e7 --- /dev/null +++ b/src/plugins/projectexplorer/dependenciespanel.cpp @@ -0,0 +1,217 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.3, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ + +#include "dependenciespanel.h" +#include "project.h" +#include "session.h" + +#include <coreplugin/fileiconprovider.h> + +#include <QtCore/QVector> +#include <QtCore/QDebug> +#include <QtCore/QAbstractListModel> +#include <QtGui/QHeaderView> +#include <QtGui/QMessageBox> +#include <QtGui/QPushButton> + +namespace ProjectExplorer { +namespace Internal { + +/// +/// DependenciesModel +/// + +class DependenciesModel : public QAbstractListModel +{ +public: + DependenciesModel(SessionManager *session, Project *project, QObject *parent = 0); + + int rowCount(const QModelIndex &index) const; + int columnCount(const QModelIndex &index) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + Qt::ItemFlags flags(const QModelIndex &index) const; + +private: + SessionManager *m_session; + Project *m_project; + QList<Project *> m_projects; +}; + +DependenciesModel::DependenciesModel(SessionManager *session, + Project *project, + QObject *parent) + : QAbstractListModel(parent) + , m_session(session) + , m_project(project) + , m_projects(session->projects()) +{ + // We can't select ourselves as a dependency + m_projects.removeAll(m_project); +} + +int DependenciesModel::rowCount(const QModelIndex &index) const +{ + return index.isValid() ? 0 : m_projects.size(); +} + +int DependenciesModel::columnCount(const QModelIndex &index) const +{ + return index.isValid() ? 0 : 1; +} + +QVariant DependenciesModel::data(const QModelIndex &index, int role) const +{ + const Project *p = m_projects.at(index.row()); + + switch (role) { + case Qt::DisplayRole: + return p->name(); + case Qt::CheckStateRole: + return m_session->hasDependency(m_project, p) ? Qt::Checked : Qt::Unchecked; + case Qt::DecorationRole: + return Core::FileIconProvider::instance()->icon(QFileInfo(p->file()->fileName())); + default: + return QVariant(); + } +} + +bool DependenciesModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + qDebug() << index << value << role << value.toBool(); + + if (role == Qt::CheckStateRole) { + const Project *p = m_projects.at(index.row()); + const Qt::CheckState c = static_cast<Qt::CheckState>(value.toInt()); + + if (c == Qt::Checked) { + if (m_session->addDependency(m_project, p)) { + emit dataChanged(index, index); + return true; + } else { + QMessageBox::warning(0, tr("Unable to add dependency"), + tr("This would create a circular dependency.")); + } + } else if (c == Qt::Unchecked) { + if (m_session->hasDependency(m_project, p)) { + m_session->removeDependency(m_project, p); + emit dataChanged(index, index); + return true; + } + } + } + return false; +} + +Qt::ItemFlags DependenciesModel::flags(const QModelIndex &index) const +{ + Qt::ItemFlags rc = QAbstractListModel::flags(index); + if (index.column() == 0) + rc |= Qt::ItemIsUserCheckable | Qt::ItemIsEditable; + return rc; +} + +/// +/// DependenciesWidget +/// + +class DependenciesWidget : public QWidget +{ +public: + DependenciesWidget(SessionManager *session, Project *project, + QWidget *parent = 0); + +private: + Ui::DependenciesWidget m_ui; + SessionManager *m_session; + DependenciesModel *m_model; +}; + +DependenciesWidget::DependenciesWidget(SessionManager *session, + Project *project, + QWidget *parent) + : QWidget(parent) + , m_session(session) + , m_model(new DependenciesModel(session, project, this)) +{ + m_ui.setupUi(this); + m_ui.dependenciesView->setModel(m_model); + m_ui.dependenciesView->setHeaderHidden(true); +} + +/// +/// DependenciesPanel +/// + +DependenciesPanel::DependenciesPanel(SessionManager *session, Project *project) + : PropertiesPanel() + , m_widget(new DependenciesWidget(session, project)) +{ +} + +DependenciesPanel::~DependenciesPanel() +{ + delete m_widget; +} + +QString DependenciesPanel::name() const +{ + return tr("Dependencies"); +} + +QWidget *DependenciesPanel::widget() +{ + return m_widget; +} + +/// +/// DependenciesPanelFactory +/// + +DependenciesPanelFactory::DependenciesPanelFactory(SessionManager *session) + : m_session(session) +{ +} + +bool DependenciesPanelFactory::supports(Project * /* project */) +{ + return true; +} + +PropertiesPanel *DependenciesPanelFactory::createPanel(Project *project) +{ + return new DependenciesPanel(m_session, project); +} + +} // namespace Internal +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/dependenciesdialog.h b/src/plugins/projectexplorer/dependenciespanel.h similarity index 73% rename from src/plugins/projectexplorer/dependenciesdialog.h rename to src/plugins/projectexplorer/dependenciespanel.h index 1dd8621a1ed6ddf77c0885128f9bdff4ddd94e6d..73c7755620c8f89ae708ab1a0f24ece196d902e7 100644 --- a/src/plugins/projectexplorer/dependenciesdialog.h +++ b/src/plugins/projectexplorer/dependenciespanel.h @@ -34,9 +34,10 @@ #ifndef DEPENDENCIESDIALOG_H #define DEPENDENCIESDIALOG_H -#include "ui_dependenciesdialog.h" +#include "iprojectproperties.h" +#include "ui_dependenciespanel.h" -#include <QtGui/QDialog> +#include <QtGui/QWidget> namespace ProjectExplorer { @@ -45,27 +46,32 @@ class SessionManager; namespace Internal { -class DependencyModel; +class DependenciesWidget; -// NBS kill DependenciesDialog? -class DependenciesDialog : public QDialog +class DependenciesPanelFactory : public IPanelFactory { - Q_OBJECT public: - typedef QList<ProjectExplorer::Project *> ProjectList; + DependenciesPanelFactory(SessionManager *session); + + bool supports(Project *project); + PropertiesPanel *createPanel(Project *project); + +private: + SessionManager *m_session; +}; - DependenciesDialog(QWidget *parent, SessionManager *sln); - virtual ~DependenciesDialog(); -public slots: - virtual void accept(); - void reset(); +class DependenciesPanel : public PropertiesPanel +{ + Q_OBJECT +public: + DependenciesPanel(SessionManager *session, Project *project); + ~DependenciesPanel(); + QString name() const; + QWidget *widget(); private: - Ui::DependenciesDialog m_ui; - SessionManager *m_sln; - ProjectList m_projectList; - DependencyModel *m_model; + DependenciesWidget *m_widget; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/dependenciespanel.ui b/src/plugins/projectexplorer/dependenciespanel.ui new file mode 100644 index 0000000000000000000000000000000000000000..83fc95b1a3bde674cd6fca9c4cb168370dc5a969 --- /dev/null +++ b/src/plugins/projectexplorer/dependenciespanel.ui @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ProjectExplorer::Internal::DependenciesWidget</class> + <widget class="QWidget" name="ProjectExplorer::Internal::DependenciesWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>502</width> + <height>375</height> + </rect> + </property> + <property name="windowTitle"> + <string>Project Dependencies</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="1" column="0"> + <widget class="QTreeView" name="dependenciesView"/> + </item> + <item row="1" column="1"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="0" colspan="2"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Project Dependencies:</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/plugins/projectexplorer/editorsettingspropertiespage.h b/src/plugins/projectexplorer/editorsettingspropertiespage.h index 3be9f229c4f6a0697beec86a6b7c349379463721..45da481767592c1997084a0e69d0c18f30647bec 100644 --- a/src/plugins/projectexplorer/editorsettingspropertiespage.h +++ b/src/plugins/projectexplorer/editorsettingspropertiespage.h @@ -73,7 +73,6 @@ private slots: void currentEncodingChanged(int index); private: - Ui::EditorSettingsPropertiesPage m_ui; Project *m_project; QList<QTextCodec *> m_codecs; diff --git a/src/plugins/projectexplorer/iprojectproperties.h b/src/plugins/projectexplorer/iprojectproperties.h index aab3b5043315a47a3cceb202296e6f34bb14794b..aa823f49010bddeff7b8ebba90b5c36d3f96ff36 100644 --- a/src/plugins/projectexplorer/iprojectproperties.h +++ b/src/plugins/projectexplorer/iprojectproperties.h @@ -39,8 +39,6 @@ #include <coreplugin/icontext.h> -#include <QtGui/QWidget> - namespace ProjectExplorer { class PropertiesPanel; @@ -57,7 +55,7 @@ class PROJECTEXPLORER_EXPORT PropertiesPanel : public Core::IContext { Q_OBJECT public: - virtual void finish() {}; + virtual void finish() {} virtual QString name() const = 0; // IContext diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index 3f377b52a11c9502a07efd56bfcb89d9850e68c3..961ad1a77084ef921f647688a70f0e73880e97e1 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -46,7 +46,6 @@ #include <QtCore/QTextCodec> using namespace ProjectExplorer; -using ExtensionSystem::PluginManager; Project::Project() : m_activeRunConfiguration(0), @@ -54,6 +53,14 @@ Project::Project() { } +Project::~Project() +{ + qDeleteAll(m_buildSteps); + qDeleteAll(m_cleanSteps); + qDeleteAll(m_buildConfigurationValues); + delete m_editorConfiguration; +} + void Project::insertBuildStep(int position, BuildStep *step) { m_buildSteps.insert(position, step); @@ -508,14 +515,3 @@ void Project::setDisplayNameFor(const QString &buildConfiguration, const QString } emit buildConfigurationDisplayNameChanged(buildConfiguration); } - - -Project::~Project() -{ - qDeleteAll(m_buildSteps); - qDeleteAll(m_cleanSteps); - qDeleteAll(m_buildConfigurationValues); - delete m_editorConfiguration; -} - - diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index 2a30a0e20f3be4d7a546f3f7b349ef0328f9fa30..9a8c7bf0cbe962504176ec9e4c285428f422e11b 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -31,7 +31,6 @@ ** ***************************************************************************/ - #ifndef PROJECT_H #define PROJECT_H @@ -50,7 +49,7 @@ #include <QtGui/QIcon> namespace Core { - class IFile; +class IFile; } namespace ProjectExplorer { @@ -68,8 +67,7 @@ class PROJECTEXPLORER_EXPORT Project Q_OBJECT public: - // Roles to be implemented by all models that are exported - // via model() + // Roles to be implemented by all models that are exported via model() enum ModelRoles { // Absolute file path FilePathRole = QFileSystemModel::FilePathRole @@ -82,12 +80,11 @@ public: virtual Core::IFile *file() const = 0; virtual IProjectManager *projectManager() const = 0; - virtual QList<Core::IFile *> dependencies() = 0; //NBS TODO remove virtual QList<Project *> dependsOn() = 0; //NBS TODO implement dependsOn virtual bool isApplication() const = 0; - //Build/Clean Step functions + // Build/Clean Step functions QList<BuildStep *> buildSteps() const; void insertBuildStep(int position, BuildStep *step); void removeBuildStep(int position); @@ -97,7 +94,7 @@ public: void insertCleanStep(int position, BuildStep *step); void removeCleanStep(int position); - //Build configuration + // Build configuration void addBuildConfiguration(const QString &name); void removeBuildConfiguration(const QString &name); void copyBuildConfiguration(const QString &source, const QString &dest); @@ -133,8 +130,9 @@ public: virtual BuildStepConfigWidget *createConfigWidget() = 0; virtual QList<BuildStepConfigWidget*> subConfigWidgets(); - // This method is called for new build configurations - // You should probably set some default values in this method + /* This method is called for new build configurations. You should probably + * set some default values in this method. + */ virtual void newBuildConfiguration(const QString &buildConfiguration) = 0; virtual ProjectNode *rootProjectNode() const = 0; @@ -150,19 +148,22 @@ signals: void buildConfigurationDisplayNameChanged(const QString &buildConfiguraiton); protected: - // This method is called when the project .user file is saved. - // Simply call writer.saveValue() for each value you want to save - // Make sure to always call your base class implementation - // Note: All the values from the project/buildsteps and buildconfigurations - // are automatically stored. + /* This method is called when the project .user file is saved. Simply call + * writer.saveValue() for each value you want to save. Make sure to always + * call your base class implementation. + * + * Note: All the values from the project/buildsteps and buildconfigurations + * are automatically stored. + */ virtual void saveSettingsImpl(PersistentSettingsWriter &writer); - // This method is called when the project is opened - // You can retrieve all the values you saved in saveSettingsImpl() - // in this method. - // Note: This function is also called if there is no .user file - // You should probably add some default build and run settings to the project - // so that it can be build and run + /* This method is called when the project is opened. You can retrieve all + * the values you saved in saveSettingsImpl() in this method. + * + * Note: This function is also called if there is no .user file. You should + * probably add some default build and run settings to the project so that + * it can be build and run. + */ virtual void restoreSettingsImpl(PersistentSettingsReader &reader); private: @@ -181,4 +182,4 @@ private: } // namespace ProjectExplorer -#endif // PROJECTINTERFACE_H +#endif // PROJECT_H diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 5e41913db026ed37aeb7cce03ed6915458055849..20e4e15fc8a9ae6b98d3593a18caf3757558ebf6 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -34,12 +34,13 @@ #include "applicationrunconfiguration.h" #include "allprojectsfilter.h" #include "allprojectsfind.h" -#include "currentprojectfind.h" #include "buildmanager.h" #include "buildsettingspropertiespage.h" -#include "editorsettingspropertiespage.h" +#include "currentprojectfind.h" #include "currentprojectfilter.h" #include "customexecutablerunconfiguration.h" +#include "editorsettingspropertiespage.h" +#include "dependenciespanel.h" #include "foldernavigationwidget.h" #include "iprojectmanager.h" #include "metatypedeclarations.h" @@ -215,6 +216,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin addAutoReleasedObject(new BuildSettingsPanelFactory); addAutoReleasedObject(new RunSettingsPanelFactory); addAutoReleasedObject(new EditorSettingsPanelFactory); + addAutoReleasedObject(new DependenciesPanelFactory(m_session)); ProcessStepFactory *processStepFactory = new ProcessStepFactory; addAutoReleasedObject(processStepFactory); @@ -485,11 +487,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin mbuild->addAction(cmd, Constants::G_BUILD_SESSION); msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD); - // dependencies action - m_dependenciesAction = new QAction(tr("Edit Dependencies..."), this); - cmd = am->registerAction(m_dependenciesAction, Constants::DEPENDENCIES, globalcontext); - mbuild->addAction(cmd, Constants::G_BUILD_SESSION); - // build action m_buildAction = new QAction(tr("Build Project"), this); cmd = am->registerAction(m_buildAction, Constants::BUILD, globalcontext); @@ -622,7 +619,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin connect(m_runActionContextMenu, SIGNAL(triggered()), this, SLOT(runProjectContextMenu())); connect(m_cancelBuildAction, SIGNAL(triggered()), this, SLOT(cancelBuild())); connect(m_debugAction, SIGNAL(triggered()), this, SLOT(debugProject())); - connect(m_dependenciesAction, SIGNAL(triggered()), this, SLOT(editDependencies())); connect(m_unloadAction, SIGNAL(triggered()), this, SLOT(unloadProject())); connect(m_clearSession, SIGNAL(triggered()), this, SLOT(clearSession())); connect(m_taskAction, SIGNAL(triggered()), this, SLOT(goToTaskWindow())); @@ -701,7 +697,7 @@ void ProjectExplorerPlugin::unloadProject() QList<Core::IFile*> filesToSave; filesToSave << fi; - filesToSave << m_currentProject->dependencies(); + // FIXME: What we want here is to check whether we need to safe any of the pro/pri files in this project // check the number of modified files int readonlycount = 0; @@ -1203,13 +1199,13 @@ void ProjectExplorerPlugin::updateActions() m_rebuildSessionAction->setEnabled(hasProjects && !building); m_cleanSessionAction->setEnabled(hasProjects && !building); m_cancelBuildAction->setEnabled(building); - m_dependenciesAction->setEnabled(hasProjects && !building); updateRunAction(); updateTaskActions(); } + // NBS TODO check projectOrder() // what we want here is all the projects pro depends on QStringList ProjectExplorerPlugin::allFilesWithDependencies(Project *pro) @@ -1467,14 +1463,6 @@ void ProjectExplorerPlugin::cancelBuild() m_buildManager->cancel(); } -void ProjectExplorerPlugin::editDependencies() -{ - if (debug) - qDebug() << "ProjectExplorerPlugin::editDependencies"; - - m_session->editDependencies(); -} - void ProjectExplorerPlugin::addToRecentProjects(const QString &fileName) { if (debug) diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index ff58e7ba8c667c25e369bf221c45ede7bbd3d78e..94e25159928c66cb77fd1a4a6086eeb6867410e5 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -138,7 +138,6 @@ private slots: void cleanSession(); void cancelBuild(); void debugProject(); - void editDependencies(); void loadAction(); void unloadProject(); void clearSession(); @@ -228,7 +227,6 @@ private: QAction *m_runActionContextMenu; QAction *m_cancelBuildAction; QAction *m_debugAction; - QAction *m_dependenciesAction; QAction *m_taskAction; QAction *m_addNewFileAction; QAction *m_addExistingFilesAction; diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index bbb8a4c74d9304ee40bf1f9c47141bbd4eb349ef..e345ff1c1cea37f8884e4b1843cdf2d9e80b5adc 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -15,7 +15,7 @@ HEADERS += projectexplorer.h \ persistentsettings.h \ projectfilewizardextension.h \ session.h \ - dependenciesdialog.h \ + dependenciespanel.h \ allprojectsfilter.h \ buildparserinterface.h \ projectexplorerconstants.h \ @@ -62,7 +62,7 @@ SOURCES += projectexplorer.cpp \ persistentsettings.cpp \ projectfilewizardextension.cpp \ session.cpp \ - dependenciesdialog.cpp \ + dependenciespanel.cpp \ allprojectsfilter.cpp \ currentprojectfilter.cpp \ scriptwrappers.cpp \ @@ -94,7 +94,7 @@ SOURCES += projectexplorer.cpp \ nodesvisitor.cpp \ projectmodels.cpp \ currentprojectfind.cpp -FORMS += dependenciesdialog.ui \ +FORMS += dependenciespanel.ui \ buildsettingspropertiespage.ui \ processstep.ui \ editorsettingspropertiespage.ui \ diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index ef848ff178b157c3458116a8fffd201d0df77883..f5b83d162cd2be7e07f2aacbd21dbf83a761fa5d 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -33,7 +33,6 @@ #include "session.h" -#include "dependenciesdialog.h" #include "project.h" #include "projectexplorer.h" #include "projectexplorerconstants.h" @@ -59,6 +58,7 @@ #include <QtCore/QFuture> #include <QtCore/QSettings> +#include <QtGui/QApplication> #include <QtGui/QMainWindow> #include <QtGui/QMessageBox> @@ -118,7 +118,6 @@ private: using namespace ProjectExplorer; using Internal::SessionFile; -using Internal::DependenciesDialog; void SessionFile::sessionLoadingProgress() @@ -452,7 +451,28 @@ bool SessionManager::recursiveDependencyCheck(const QString &newDep, const QStri return true; } -bool SessionManager::hasDependency(Project *project, Project *depProject) const +/* + * TODO: The dependency management exposes an interface based on projects, but + * is internally purely string based. This is suboptimal. Probably it would be + * nicer to map the filenames to projects on load and only map it back to + * filenames when saving. + */ + +QList<Project *> SessionManager::dependencies(const Project *project) const +{ + const QString &proName = project->file()->fileName(); + const QStringList &proDeps = m_file->m_depMap.value(proName); + + QList<Project *> projects; + foreach (const QString &dep, proDeps) { + if (Project *pro = projectForFile(dep)) + projects += pro; + } + + return projects; +} + +bool SessionManager::hasDependency(const Project *project, const Project *depProject) const { const QString &proName = project->file()->fileName(); const QString &depName = depProject->file()->fileName(); @@ -461,7 +481,7 @@ bool SessionManager::hasDependency(Project *project, Project *depProject) const return proDeps.contains(depName); } -bool SessionManager::canAddDependency(Project *project, Project *depProject) const +bool SessionManager::canAddDependency(const Project *project, const Project *depProject) const { const QString &newDep = project->file()->fileName(); const QString &checkDep = depProject->file()->fileName(); @@ -469,7 +489,7 @@ bool SessionManager::canAddDependency(Project *project, Project *depProject) con return recursiveDependencyCheck(newDep, checkDep); } -bool SessionManager::addDependency(Project *project, Project *depProject) +bool SessionManager::addDependency(const Project *project, const Project *depProject) { const QString &proName = project->file()->fileName(); const QString &depName = depProject->file()->fileName(); @@ -487,6 +507,20 @@ bool SessionManager::addDependency(Project *project, Project *depProject) return true; } +void SessionManager::removeDependency(const Project *project, const Project *depProject) +{ + const QString &proName = project->file()->fileName(); + const QString &depName = depProject->file()->fileName(); + + QStringList proDeps = m_file->m_depMap.value(proName); + proDeps.removeAll(depName); + if (proDeps.isEmpty()) { + m_file->m_depMap.remove(proName); + } else { + m_file->m_depMap[proName] = proDeps; + } +} + void SessionManager::setStartupProject(Project *startupProject) { if (debug) @@ -505,21 +539,6 @@ Project *SessionManager::startupProject() const return m_file->m_startupProject; } -void SessionManager::removeDependency(Project *project, - Project *depProject) -{ - const QString &proName = project->file()->fileName(); - const QString &depName = depProject->file()->fileName(); - - QStringList proDeps = m_file->m_depMap.value(proName); - proDeps.removeAll(depName); - if (proDeps.isEmpty()) { - m_file->m_depMap.remove(proName); - } else { - m_file->m_depMap[proName] = proDeps; - } -} - void SessionManager::addProject(Project *project) { addProjects(QList<Project*>() << project); @@ -702,12 +721,6 @@ bool SessionManager::clear() return success; } -void SessionManager::editDependencies() -{ - DependenciesDialog dlg(0, this); - dlg.exec(); -} - const QList<Project *> &SessionManager::projects() const { return m_file->m_projects; diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index 49d15b7e8df43b52cc6eb99d5a03a4c9d48b4e41..f8768ab468bb57087f4edcd09626ffaf5169b4f6 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -123,16 +123,13 @@ public: void removeProject(Project *project); void removeProjects(QList<Project *> remove); - void editDependencies(); void setStartupProject(Project *startupProject); - // NBS think about dependency management again. - // Probably kill these here - bool canAddDependency(Project *project, Project *depProject) const; - bool hasDependency(Project *project, Project *depProject) const; - // adds the 'requiredProject' as a dependency to 'project' - bool addDependency(Project *project, Project *depProject); - void removeDependency(Project *project, Project *depProject); + QList<Project *> dependencies(const Project *project) const; + bool hasDependency(const Project *project, const Project *depProject) const; + bool canAddDependency(const Project *project, const Project *depProject) const; + bool addDependency(const Project *project, const Project *depProject); + void removeDependency(const Project *project, const Project *depProject); Core::IFile *file() const; Project *startupProject() const; diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 611d4930b407c062d9ed982442e521eb48440fd4..cb5d99a642b5ceea1fd4c91f69d8f5aa35d669a0 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -569,17 +569,6 @@ QStringList Qt4Project::files(FilesMode fileMode) const return files; } -QList<Core::IFile *> Qt4Project::dependencies() -{ - QList<Core::IFile *> result; - // TODO profile cache is no longer -// ProFileCache *cache = m_manager->proFileCache(); -// foreach (const QString &file, cache->dependencies(m_rootProjectNode)) { -// result << cache->fileInterface(file); -// } - return result; -} - QList<ProjectExplorer::Project*> Qt4Project::dependsOn() { // NBS implement dependsOn diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index 792ae2aed45bf374a616f6810511c1264326c52f..c589d2eb8651f66b975a44f0e8a5bc2c462d979a 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -74,7 +74,12 @@ using ProjectExplorer::ResourceType; using ProjectExplorer::UnknownFileType; // Known file types of a Qt 4 project -static const char* qt4FileTypes[] = {"CppHeaderFiles", "CppSourceFiles", "Qt4FormFiles", "Qt4ResourceFiles" }; +static const char* qt4FileTypes[] = { + "CppHeaderFiles", + "CppSourceFiles", + "Qt4FormFiles", + "Qt4ResourceFiles" +}; Qt4Manager::Qt4Manager(Qt4ProjectManagerPlugin *plugin, Core::ICore *core) : m_mimeType(QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE)),