diff --git a/dist/changes-1.1.1 b/dist/changes-1.1.1 new file mode 100644 index 0000000000000000000000000000000000000000..d9c4f33cdf8603fba2a4baabc195fb71a1709387 --- /dev/null +++ b/dist/changes-1.1.1 @@ -0,0 +1,7 @@ +The QtCreator 1.1.1 release is a pure bug fix release for the Windows platform. + +Platform Specific + +Windows + * Fixed performance problem on Windows machines that are part of a + windows domain diff --git a/src/libs/utils/qstringbuilder.h b/src/libs/utils/qstringbuilder.h index c32f2dae3f372f5ec11926ab8023dd3f7e50d4c6..30a5a53e3a2cca85020b60cd383051eff172cca6 100644 --- a/src/libs/utils/qstringbuilder.h +++ b/src/libs/utils/qstringbuilder.h @@ -59,11 +59,11 @@ public: inline int size() const { return m_size; } inline const char *data() const { return m_data; } - void append(QChar *&out) const + void appendTo(QChar *&out) const { const char *s = m_data; for (int i = m_size; --i >= 0;) - *out++ = *s++; + *out++ = QLatin1Char(*s++); } operator QString() const @@ -75,7 +75,7 @@ public: s.resize(m_size); #endif QChar *d = s.data(); - append(d); + appendTo(d); return s; } @@ -100,7 +100,7 @@ public: s.resize(this->size()); #endif QChar *d = s.data(); - this->append(d); + this->appendTo(d); return s; } @@ -114,7 +114,7 @@ public: inline int size() const { return a->size(); } - inline void append(QChar *&out) const + inline void appendTo(QChar *&out) const { const int n = a->size(); memcpy(out, (char*)a->constData(), sizeof(QChar) * n); @@ -133,12 +133,23 @@ int qStringBuilderSize(const A a) { return a.size(); } inline int qStringBuilderSize(const char) { return 1; } +inline int qStringBuilderSize(const QLatin1Char) { return 1; } + +inline int qStringBuilderSize(const QLatin1String a) { return qstrlen(a.latin1()); } template <typename A> -inline void qStringBuilderAppend(const A a, QChar *&out) { a.append(out); } +inline void qStringBuilderAppend(const A a, QChar *&out) { a.appendTo(out); } inline void qStringBuilderAppend(char c, QChar *&out) { *out++ = QLatin1Char(c); } +inline void qStringBuilderAppend(QLatin1Char c, QChar *&out) { *out++ = c; } + +inline void qStringBuilderAppend(QLatin1String a, QChar *&out) +{ + for (const char *s = a.latin1(); *s; ) + *out++ = QLatin1Char(*s++); +} + template <typename A, typename B> class QStringBuilderPair @@ -151,7 +162,7 @@ public: return qStringBuilderSize(a) + qStringBuilderSize(b); } - inline void append(QChar *&out) const + inline void appendTo(QChar *&out) const { qStringBuilderAppend(a, out); qStringBuilderAppend(b, out); diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 89674ba002bb17d882a7428d333d3fd8e03134af..c2e53063c347866fbb343bbd3726639b840cc368 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -278,6 +278,8 @@ public: QToolBar *toolBar() { return m_toolBar; } + bool temporaryEditor() const { return false; } + signals: void changed(); diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index a12773dfe191e4f5e74228435f18f0f79131676a..77dc18c5d300a5a4a0c349579e5e82bed2c931a2 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -185,7 +185,7 @@ void CMakeRunner::run(QFutureInterface<void> &fi) m_mutex.lock(); m_supportsQtCreator = response.contains(QLatin1String("QtCreator")); m_version = versionRegexp.cap(1); - if (!versionRegexp.capturedTexts().size()>3) + if (!(versionRegexp.capturedTexts().size() > 3)) m_version += QLatin1Char('.') + versionRegexp.cap(3); m_cacheUpToDate = true; m_mutex.unlock(); diff --git a/src/plugins/coreplugin/coreimpl.cpp b/src/plugins/coreplugin/coreimpl.cpp index 69e650ff581f7a57ded95ad1be3d5f91920d8a13..3d444ef1acfb5a3d30d5b8b5baefbe04b93ea394 100644 --- a/src/plugins/coreplugin/coreimpl.cpp +++ b/src/plugins/coreplugin/coreimpl.cpp @@ -129,6 +129,11 @@ QSettings *CoreImpl::settings() const return m_mainwindow->settings(); } +SettingsDatabase *CoreImpl::settingsDatabase() const +{ + return m_mainwindow->settingsDatabase(); +} + QPrinter *CoreImpl::printer() const { return m_mainwindow->printer(); diff --git a/src/plugins/coreplugin/coreimpl.h b/src/plugins/coreplugin/coreimpl.h index f821a5af531b63911fb1e92e700667c45d0ff621..a6602c355c3236369d82e7086f6110f52bf9617c 100644 --- a/src/plugins/coreplugin/coreimpl.h +++ b/src/plugins/coreplugin/coreimpl.h @@ -64,6 +64,7 @@ public: MimeDatabase *mimeDatabase() const; QSettings *settings() const; + SettingsDatabase *settingsDatabase() const; QPrinter *printer() const; QString resourcePath() const; diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index 9f9176ea962d6c5e6c0b621b2f7457a7a61f1cc0..f36875126c088795b280bb0188813b799c3cc136 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -4,7 +4,8 @@ DEFINES += CORE_LIBRARY QT += xml \ network \ script \ - svg + svg \ + sql include(../../qtcreatorplugin.pri) include(../../libs/utils/utils.pri) include(../../shared/scriptwrapper/scriptwrapper.pri) @@ -77,7 +78,8 @@ SOURCES += mainwindow.cpp \ icore.cpp \ editormanager/ieditor.cpp \ dialogs/ioptionspage.cpp \ - dialogs/iwizard.cpp + dialogs/iwizard.cpp \ + settingsdatabase.cpp HEADERS += mainwindow.h \ welcomemode.h \ welcomemode_p.h \ @@ -156,7 +158,8 @@ HEADERS += mainwindow.h \ rightpane.h \ sidebar.h \ fileiconprovider.h \ - mimedatabase.h + mimedatabase.h \ + settingsdatabase.h FORMS += dialogs/newdialog.ui \ dialogs/settingsdialog.ui \ dialogs/shortcutsettings.ui \ diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 0007f7296d1e988d6a1e8c14edaa19191247174f..407f6a42d6275b99d7ad0739765bbff3d1cf6296 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -47,6 +47,7 @@ #include <coreplugin/editormanager/iexternaleditor.h> #include <coreplugin/baseview.h> #include <coreplugin/imode.h> +#include <coreplugin/settingsdatabase.h> #include <extensionsystem/pluginmanager.h> @@ -694,7 +695,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA //ask whether to save modified files if (askAboutModifiedEditors) { bool cancelled = false; - QList<IFile*> list = ICore::instance()->fileManager()-> + QList<IFile*> list = m_d->m_core->fileManager()-> saveModifiedFiles(filesForEditors(acceptedEditors), &cancelled); if (cancelled) return false; @@ -958,7 +959,8 @@ template <class EditorFactoryLike> inline EditorFactoryLike *findByKind(ExtensionSystem::PluginManager *pm, const QString &kind) { - foreach(EditorFactoryLike *efl, pm->getObjects<EditorFactoryLike>()) + const QList<EditorFactoryLike *> factories = pm->template getObjects<EditorFactoryLike>(); + foreach(EditorFactoryLike *efl, factories) if (kind == efl->kind()) return efl; return 0; @@ -1010,7 +1012,9 @@ void EditorManager::addEditor(IEditor *editor, bool isDuplicate) m_d->m_editorModel->addEditor(editor, isDuplicate); if (!isDuplicate) { m_d->m_core->fileManager()->addFile(editor->file()); - m_d->m_core->fileManager()->addToRecentFiles(editor->file()->fileName()); + if (!editor->temporaryEditor()) { + m_d->m_core->fileManager()->addToRecentFiles(editor->file()->fileName()); + } } m_d->m_editorHistory.removeAll(editor); @@ -1275,7 +1279,7 @@ bool EditorManager::saveFile(IEditor *editor) m_d->m_core->fileManager()->unblockFileChange(file); } - if (success) + if (success && !editor->temporaryEditor()) m_d->m_core->fileManager()->addToRecentFiles(editor->file()->fileName()); return success; @@ -1370,7 +1374,7 @@ bool EditorManager::saveFileAs(IEditor *editor) m_d->m_core->fileManager()->unblockFileChange(editor->file()); editor->file()->checkPermissions(); - if (success) + if (success && !editor->temporaryEditor()) m_d->m_core->fileManager()->addToRecentFiles(editor->file()->fileName()); updateActions(); @@ -1684,21 +1688,36 @@ bool EditorManager::restoreState(const QByteArray &state) return true; } -void EditorManager::saveSettings(QSettings *settings) +static const char * const documentStatesKey = "EditorManager/DocumentStates"; +static const char * const externalEditorKey = "EditorManager/ExternalEditorCommand"; + +void EditorManager::saveSettings() { - settings->setValue(QLatin1String("EditorManager/DocumentStates"), - m_d->m_editorStates); - settings->setValue(QLatin1String("EditorManager/ExternalEditorCommand"), - m_d->m_externalEditor); + SettingsDatabase *settings = m_d->m_core->settingsDatabase(); + settings->setValue(QLatin1String(documentStatesKey), m_d->m_editorStates); + settings->setValue(QLatin1String(externalEditorKey), m_d->m_externalEditor); } -void EditorManager::readSettings(QSettings *settings) +void EditorManager::readSettings() { - if (settings->contains(QLatin1String("EditorManager/DocumentStates"))) - m_d->m_editorStates = settings->value(QLatin1String("EditorManager/DocumentStates")) + // Backward compatibility to old locations for these settings + QSettings *qs = m_d->m_core->settings(); + if (qs->contains(QLatin1String(documentStatesKey))) { + m_d->m_editorStates = qs->value(QLatin1String(documentStatesKey)) + .value<QMap<QString, QVariant> >(); + qs->remove(QLatin1String(documentStatesKey)); + } + if (qs->contains(QLatin1String(externalEditorKey))) { + m_d->m_externalEditor = qs->value(QLatin1String(externalEditorKey)).toString(); + qs->remove(QLatin1String(externalEditorKey)); + } + + SettingsDatabase *settings = m_d->m_core->settingsDatabase(); + if (settings->contains(QLatin1String(documentStatesKey))) + m_d->m_editorStates = settings->value(QLatin1String(documentStatesKey)) .value<QMap<QString, QVariant> >(); - if (settings->contains(QLatin1String("EditorManager/ExternalEditorCommand"))) - m_d->m_externalEditor = settings->value(QLatin1String("EditorManager/ExternalEditorCommand")).toString(); + if (settings->contains(QLatin1String(externalEditorKey))) + m_d->m_externalEditor = settings->value(QLatin1String(externalEditorKey)).toString(); } @@ -1800,7 +1819,7 @@ void EditorManager::openInExternalEditor() return; if (editor->file()->isModified()) { bool cancelled = false; - QList<IFile*> list = ICore::instance()->fileManager()-> + QList<IFile*> list = m_d->m_core->fileManager()-> saveModifiedFiles(QList<IFile*>() << editor->file(), &cancelled); if (cancelled) return; diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 77ee052227b95b319cb4ddbc3d2cbc6346ff929b..60276f9f92beb87c4c072abd15054ceaedc55c2b 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -149,8 +149,8 @@ public: IEditor *restoreEditor(QString fileName, QString editorKind, EditorGroup *group); - void saveSettings(QSettings *settings); - void readSettings(QSettings *settings); + void saveSettings(); + void readSettings(); Internal::OpenEditorsWindow *windowPopup() const; void showWindowPopup() const; diff --git a/src/plugins/coreplugin/editormanager/ieditor.h b/src/plugins/coreplugin/editormanager/ieditor.h index 789863cce39b9084030ed4991501d451ee39cc11..df6abdeca642e9cff82bd5c5b3552c6d097063e1 100644 --- a/src/plugins/coreplugin/editormanager/ieditor.h +++ b/src/plugins/coreplugin/editormanager/ieditor.h @@ -63,6 +63,8 @@ public: virtual int currentLine() const { return 0; } virtual int currentColumn() const { return 0; } + virtual bool temporaryEditor() const = 0; + virtual QToolBar *toolBar() = 0; signals: diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index da43f02e090de98770a896b9b8eee22e33470480..b8385f15734321c1027b7ff41d613e747efac14c 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -179,6 +179,19 @@ You can use it to retrieve or set application wide settings (in contrast to session or project specific settings). + + \see settingsDatabase() +*/ + +/*! + \fn SettingsDatabase *ICore::settingsDatabase() const + \brief Returns the application's settings database. + + The settings database is meant as an alternative to the regular settings + object. It is more suitable for storing large amounts of data. The settings + are application wide. + + \see SettingsDatabase */ /*! @@ -186,7 +199,7 @@ \brief Returns the application's printer object. Always use this printer object for printing, so the different parts of the - application re-use it's settings. + application re-use its settings. */ /*! @@ -251,7 +264,7 @@ \brief Registers an additional \a context object. After registration this context object gets automatically the - current context object whenever it's widget gets focus. + current context object whenever its widget gets focus. \sa ICore::removeContextObject() \sa ICore::addAdditionalContext() @@ -324,11 +337,11 @@ /*! \fn void ICore::contextAboutToChange(Core::IContext *context) \brief Sent just before a new \a context becomes the current context - (meaning that it's widget got focus). + (meaning that its widget got focus). */ /*! \fn void ICore::contextChanged(Core::IContext *context) \brief Sent just after a new \a context became the current context - (meaning that it's widget got focus). + (meaning that its widget got focus). */ diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h index 950222a15bd8ba3e2268362d594a17ff29eaec2c..973f2b97b32c58fbd7569ea2758da290c17e6eab 100644 --- a/src/plugins/coreplugin/icore.h +++ b/src/plugins/coreplugin/icore.h @@ -52,6 +52,7 @@ class MimeDatabase; class ModeManager; class ProgressManager; class ScriptManager; +class SettingsDatabase; class UniqueIDManager; class VariableManager; class VCSManager; @@ -87,6 +88,7 @@ public: virtual MimeDatabase *mimeDatabase() const = 0; virtual QSettings *settings() const = 0; + virtual SettingsDatabase *settingsDatabase() const = 0; virtual QPrinter *printer() const = 0; virtual QString resourcePath() const = 0; diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index a334518f3ff494833af7a94d5956a69dd9a9450b..07ff1132942d1e89c3d634dfe263438db15c69c2 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -66,6 +66,7 @@ #include "ioutputpane.h" #include <coreplugin/findplaceholder.h> +#include <coreplugin/settingsdatabase.h> #include <utils/pathchooser.h> #include <extensionsystem/pluginmanager.h> @@ -111,7 +112,11 @@ MainWindow::MainWindow() : m_uniqueIDManager(new UniqueIDManager()), m_globalContext(QList<int>() << Constants::C_GLOBAL_ID), m_additionalContexts(m_globalContext), - m_settings(new QSettings(QSettings::IniFormat, QSettings::UserScope, QLatin1String("Nokia"), QLatin1String("QtCreator"), this)), + m_settings(new QSettings(QSettings::IniFormat, QSettings::UserScope, + QLatin1String("Nokia"), QLatin1String("QtCreator"), this)), + m_settingsDatabase(new SettingsDatabase(QFileInfo(m_settings->fileName()).path(), + QLatin1String("QtCreator"), + this)), m_printer(0), m_actionManager(new ActionManagerPrivate(this)), m_editorManager(0), @@ -760,7 +765,7 @@ void MainWindow::registerDefaultActions() void MainWindow::newFile() { - showNewItemDialog(tr("New", "Title of dialog"), IWizard::allWizards()); + showNewItemDialog(tr("New...", "Title of dialog"), IWizard::allWizards()); } void MainWindow::openFile() @@ -1099,7 +1104,7 @@ void MainWindow::readSettings() m_settings->endGroup(); - m_editorManager->readSettings(m_settings); + m_editorManager->readSettings(); m_navigationWidget->restoreSettings(m_settings); m_rightPaneWidget->readSettings(m_settings); } @@ -1124,7 +1129,7 @@ void MainWindow::writeSettings() m_fileManager->saveRecentFiles(); m_viewManager->saveSettings(m_settings); m_actionManager->saveSettings(m_settings); - m_editorManager->saveSettings(m_settings); + m_editorManager->saveSettings(); m_navigationWidget->saveSettings(m_settings); } diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h index c28984e98f6daf998cb61ea57d67a83fd2cb4a51..7886d7795d1c311ab285ef6124f834e671faa835 100644 --- a/src/plugins/coreplugin/mainwindow.h +++ b/src/plugins/coreplugin/mainwindow.h @@ -60,6 +60,7 @@ class ModeManager; class ProgressManager; class RightPaneWidget; class ScriptManager; +class SettingsDatabase; class UniqueIDManager; class VariableManager; class VCSManager; @@ -109,6 +110,7 @@ public: VCSManager *vcsManager() const; inline QSettings *settings() const { return m_settings; } + inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; } virtual QPrinter *printer() const; IContext * currentContextObject() const; QStatusBar *statusBar() const; @@ -169,6 +171,7 @@ private: QList<int> m_globalContext; QList<int> m_additionalContexts; QSettings *m_settings; + SettingsDatabase *m_settingsDatabase; mutable QPrinter *m_printer; ActionManagerPrivate *m_actionManager; EditorManager *m_editorManager; diff --git a/src/plugins/coreplugin/settingsdatabase.cpp b/src/plugins/coreplugin/settingsdatabase.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b26cb188f3a66a74895cb09ec596d674cdc0864e --- /dev/null +++ b/src/plugins/coreplugin/settingsdatabase.cpp @@ -0,0 +1,239 @@ +/************************************************************************** +** +** 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. +** +**************************************************************************/ + +#include "settingsdatabase.h" + +#include <QtCore/QMap> +#include <QtSql/QSqlDatabase> +#include <QtSql/QSqlQuery> +#include <QDebug> + +/*! + \class Core::SettingsDatabase + \brief An alternative to the application-wide QSettings that is more + suitable for storing large amounts of data. + + The settings database is SQLite based, and lazily retrieves data when it + is asked for. It also does incremental updates of the database rather than + rewriting the whole file each time one of the settings change. + + The SettingsDatabase API mimics that of QSettings. +*/ + +using namespace Core; +using namespace Core::Internal; + +enum { debug_settings = 0 }; + +namespace Core { +namespace Internal { + +typedef QMap<QString, QVariant> SettingsMap; + +class SettingsDatabasePrivate +{ +public: + QString effectiveGroup() const + { + return m_groups.join(QLatin1String("/")); + } + + QString effectiveKey(const QString &key) const + { + QString g = effectiveGroup(); + if (!g.isEmpty() && !key.isEmpty()) + g += QLatin1Char('/'); + g += key; + return g; + } + + SettingsMap m_settings; + + QStringList m_groups; + QStringList m_dirtyKeys; + + QSqlDatabase m_db; +}; + +} // namespace Internal +} // namespace Core + +SettingsDatabase::SettingsDatabase(const QString &path, + const QString &application, + QObject *parent) + : QObject(parent) + , d(new SettingsDatabasePrivate) +{ + const QLatin1Char slash('/'); + + // TODO: Don't rely on a path, but determine automatically + QString fileName = path; + if (!fileName.endsWith(slash)) + fileName += slash; + fileName += application; + fileName += QLatin1String(".db"); + + d->m_db = QSqlDatabase::addDatabase("QSQLITE", QLatin1String("settings")); + d->m_db.setDatabaseName(fileName); + if (!d->m_db.open()) + qWarning() << "Warning: Failed to open settings database!"; + + // Create the settings table if it doesn't exist yet + QSqlQuery query(d->m_db); + query.prepare(QLatin1String("CREATE TABLE IF NOT EXISTS settings (" + "key PRIMARY KEY ON CONFLICT REPLACE, " + "value)")); + if (d->m_db.isOpen() && !query.exec()) + qWarning() << "Warning: Failed to prepare settings database!"; + + // Retrieve all available keys (values are retrieved lazily) + if (query.exec(QLatin1String("SELECT key FROM settings"))) { + while (query.next()) { + d->m_settings.insert(query.value(0).toString(), QVariant()); + } + } +} + +SettingsDatabase::~SettingsDatabase() +{ + sync(); + + delete d; + QSqlDatabase::removeDatabase(QLatin1String("settings")); +} + +void SettingsDatabase::setValue(const QString &key, const QVariant &value) +{ + const QString effectiveKey = d->effectiveKey(key); + + // Add to cache + d->m_settings.insert(effectiveKey, value); + + // Instant apply (TODO: Delay writing out settings) + QSqlQuery query(d->m_db); + query.prepare(QLatin1String("INSERT INTO settings VALUES (?, ?)")); + query.addBindValue(effectiveKey); + query.addBindValue(value); + query.exec(); + + if (debug_settings) + qDebug() << "Stored:" << effectiveKey << "=" << value; +} + +QVariant SettingsDatabase::value(const QString &key, const QVariant &defaultValue) const +{ + const QString effectiveKey = d->effectiveKey(key); + QVariant value = defaultValue; + + SettingsMap::const_iterator i = d->m_settings.constFind(effectiveKey); + if (i != d->m_settings.constEnd() && i.value().isValid()) { + value = i.value(); + } else { + // Try to read the value from the database + QSqlQuery query(d->m_db); + query.prepare(QLatin1String("SELECT value FROM settings WHERE key = ?")); + query.addBindValue(effectiveKey); + query.exec(); + if (query.next()) { + value = query.value(0); + + if (debug_settings) + qDebug() << "Retrieved:" << effectiveKey << "=" << value; + } + + // Cache the result + d->m_settings.insert(effectiveKey, value); + } + + return value; +} + +bool SettingsDatabase::contains(const QString &key) const +{ + return d->m_settings.contains(d->effectiveKey(key)); +} + +void SettingsDatabase::remove(const QString &key) +{ + const QString effectiveKey = d->effectiveKey(key); + + // Delete keys from the database + QSqlQuery query(d->m_db); + query.prepare(QLatin1String("DELETE FROM settings WHERE key = ? OR key LIKE ?")); + query.addBindValue(effectiveKey); + query.addBindValue(effectiveKey + QLatin1String("/%")); + query.exec(); + + // Remove keys from the cache + foreach (const QString &k, d->m_settings.keys()) { + // Either it's an exact match, or it matches up to a / + if (k.startsWith(effectiveKey) + && (k.length() == effectiveKey.length() + || k.at(effectiveKey.length()) == QLatin1Char('/'))) + { + d->m_settings.remove(k); + } + } +} + +void SettingsDatabase::beginGroup(const QString &prefix) +{ + d->m_groups.append(prefix); +} + +void SettingsDatabase::endGroup() +{ + d->m_groups.removeLast(); +} + +QString SettingsDatabase::group() const +{ + return d->effectiveGroup(); +} + +QStringList SettingsDatabase::childKeys() const +{ + QStringList childs; + + const QString g = group(); + QMapIterator<QString, QVariant> i(d->m_settings); + while (i.hasNext()) { + const QString &key = i.next().key(); + if (key.startsWith(g) && key.indexOf(QLatin1Char('/'), g.length() + 1) == -1) { + childs.append(key.mid(g.length() + 1)); + } + } + + return childs; +} + +void SettingsDatabase::sync() +{ + // TODO: Delay writing of dirty keys and save them here +} diff --git a/src/plugins/coreplugin/settingsdatabase.h b/src/plugins/coreplugin/settingsdatabase.h new file mode 100644 index 0000000000000000000000000000000000000000..36f1ebd8a8149ec6856932cd2d1f0a6304059a65 --- /dev/null +++ b/src/plugins/coreplugin/settingsdatabase.h @@ -0,0 +1,70 @@ +/************************************************************************** +** +** 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 SETTINGSDATABASE_H +#define SETTINGSDATABASE_H + +#include "core_global.h" + +#include <QtCore/QObject> +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QVariant> + +namespace Core { + +namespace Internal { +class SettingsDatabasePrivate; +} + +class CORE_EXPORT SettingsDatabase : public QObject +{ +public: + SettingsDatabase(const QString &path, const QString &application, QObject *parent = 0); + ~SettingsDatabase(); + + void setValue(const QString &key, const QVariant &value); + QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const; + bool contains(const QString &key) const; + void remove(const QString &key); + + void beginGroup(const QString &prefix); + void endGroup(); + QString group() const; + QStringList childKeys() const; + + void sync(); + +private: + Internal::SettingsDatabasePrivate *d; +}; + +} // namespace Core + +#endif // SETTINGSDATABASE_H diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 526faff87a7e01f7bd36f0073164a97bb7b6816f..cea426aaa5b26b7c2a0bcf080aa882c1ecccac79 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -69,6 +69,8 @@ public: Core::IEditor *duplicate(QWidget *parent); const char *kind() const; + bool temporaryEditor() const { return false; } + private: QList<int> m_context; }; diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp index 9e17083c2190fba27b2e796a25074c5a35f48034..318f3f0b51a3053ed2ba21182393fccd3a185cd0 100644 --- a/src/plugins/cppeditor/cppplugin.cpp +++ b/src/plugins/cppeditor/cppplugin.cpp @@ -165,11 +165,11 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess wizardParameters.setCategory(QLatin1String("C++")); wizardParameters.setTrCategory(tr("C++")); - wizardParameters.setDescription(tr("Creates a new C++ header file.")); + wizardParameters.setDescription(tr("Creates a C++ header file.")); wizardParameters.setName(tr("C++ Header File")); addAutoReleasedObject(new CppFileWizard(wizardParameters, Header, core)); - wizardParameters.setDescription(tr("Creates a new C++ source file.")); + wizardParameters.setDescription(tr("Creates a C++ source file.")); wizardParameters.setName(tr("C++ Source File")); addAutoReleasedObject(new CppFileWizard(wizardParameters, Source, core)); diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index ba16c92ff170704febe240088f7507be863b6cbb..1e32bc5074b2115a46ecad881582b34775945cc6 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -184,6 +184,9 @@ void DebuggerManager::init() m_modulesHandler = 0; m_registerHandler = 0; + m_locked = true; + m_handleDockVisibilityChanges = false; + m_statusLabel = new QLabel; // FIXME: Do something to show overly long messages at least partially //QSizePolicy policy = m_statusLabel->sizePolicy(); @@ -479,18 +482,22 @@ QDockWidget *DebuggerManager::createDockForWidget(QWidget *widget) { QDockWidget *dockWidget = new QDockWidget(widget->windowTitle(), m_mainWindow); dockWidget->setObjectName(widget->windowTitle()); - dockWidget->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); - dockWidget->setTitleBarWidget(new QWidget(dockWidget)); dockWidget->setWidget(widget); connect(dockWidget->toggleViewAction(), SIGNAL(triggered()), this, SLOT(dockActionTriggered()), Qt::QueuedConnection); + connect(dockWidget, SIGNAL(visibilityChanged(bool)), + this, SLOT(onDockVisibilityChange(bool))); + connect(dockWidget, SIGNAL(topLevelChanged(bool)), + this, SLOT(onTopLevelChanged())); m_dockWidgets.append(dockWidget); - m_dockWidgetActiveState.append(false); + m_dockWidgetActiveState.append(true); + updateDockWidget(dockWidget); return dockWidget; } void DebuggerManager::setSimpleDockWidgetArrangement() { + m_handleDockVisibilityChanges = false; foreach (QDockWidget *dockWidget, m_dockWidgets) m_mainWindow->removeDockWidget(dockWidget); @@ -514,44 +521,60 @@ void DebuggerManager::setSimpleDockWidgetArrangement() m_disassemblerDock->hide(); m_modulesDock->hide(); m_outputDock->hide(); + for (int i = 0; i < m_dockWidgets.size(); ++i) + m_dockWidgetActiveState[i] = m_dockWidgets[i]->isVisible(); + m_handleDockVisibilityChanges = true; } -void DebuggerManager::updateDockWidgetActiveStates() +void DebuggerManager::onDockVisibilityChange(bool visible) { - for (int i = 0; i < m_dockWidgets.size(); ++i) { - m_dockWidgetActiveState[i] = m_dockWidgets.at(i)->isVisible(); - } + if (!m_handleDockVisibilityChanges) + return; + QDockWidget *dockWidget = qobject_cast<QDockWidget *>(sender()); + int index = m_dockWidgets.indexOf(dockWidget); + m_dockWidgetActiveState[index] = visible; } -void DebuggerManager::setFloatingDockWidgetsVisible(bool visible) +void DebuggerManager::modeVisibilityChanged(bool visible) { + m_handleDockVisibilityChanges = false; for (int i = 0; i < m_dockWidgets.size(); ++i) { QDockWidget *dockWidget = m_dockWidgets.at(i); - if (dockWidget->isFloating() && m_dockWidgetActiveState.at(i)) { - dockWidget->setVisible(visible); + if (dockWidget->isFloating()) { + dockWidget->setVisible(visible && m_dockWidgetActiveState.at(i)); } } if (visible) - updateDockWidgetActiveStates(); // we can't do that earlier, because the dock widgets are not visible at startup + m_handleDockVisibilityChanges = true; +} + +void DebuggerManager::onTopLevelChanged() +{ + updateDockWidget(qobject_cast<QDockWidget*>(sender())); } void DebuggerManager::setLocked(bool locked) +{ + m_locked = locked; + foreach (QDockWidget *dockWidget, m_dockWidgets) { + updateDockWidget(dockWidget); + } +} + +void DebuggerManager::updateDockWidget(QDockWidget *dockWidget) { const QDockWidget::DockWidgetFeatures features = - (locked) ? QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable : + (m_locked) ? QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable : QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable; - - foreach (QDockWidget *dockWidget, m_dockWidgets) { - QWidget *titleBarWidget = dockWidget->titleBarWidget(); - if (locked && !titleBarWidget) - titleBarWidget = new QWidget(dockWidget); - else if (!locked && titleBarWidget) { - delete titleBarWidget; - titleBarWidget = 0; - } - dockWidget->setTitleBarWidget(titleBarWidget); - dockWidget->setFeatures(features); + QWidget *titleBarWidget = dockWidget->titleBarWidget(); + if (m_locked && !titleBarWidget && !dockWidget->isFloating()) + titleBarWidget = new QWidget(dockWidget); + else if ((!m_locked || dockWidget->isFloating()) && titleBarWidget) { + delete titleBarWidget; + titleBarWidget = 0; } + dockWidget->setTitleBarWidget(titleBarWidget); + dockWidget->setFeatures(features); } void DebuggerManager::dockActionTriggered() @@ -560,9 +583,6 @@ void DebuggerManager::dockActionTriggered() if (dw) { if (dw->isVisible()) dw->raise(); - int index = m_dockWidgets.indexOf(dw); - if (index >= 0) - m_dockWidgetActiveState[index] = dw->isVisible(); } } diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 22cd9e3c8bb7fa039b347024b014d0666cd6da19..c9fd72d2ec92c6128709a56a7e26b8e62ab7741b 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -217,9 +217,8 @@ public slots: void setSimpleDockWidgetArrangement(); void setLocked(bool locked); - void setFloatingDockWidgetsVisible(bool visible); - void updateDockWidgetActiveStates(); void dockActionTriggered(); + void modeVisibilityChanged(bool visible); void setBusyCursor(bool on); void queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **ed); @@ -378,6 +377,9 @@ private: void runTest(const QString &fileName); QDockWidget *createDockForWidget(QWidget *widget); Q_SLOT void createNewDock(QWidget *widget); + void updateDockWidget(QDockWidget *dockWidget); + Q_SLOT void onDockVisibilityChange(bool visible); + Q_SLOT void onTopLevelChanged(); void shutdown(); @@ -402,6 +404,8 @@ private: QDockWidget *m_watchDock; QList<QDockWidget*> m_dockWidgets; QList<bool> m_dockWidgetActiveState; + bool m_locked; + bool m_handleDockVisibilityChanges; BreakHandler *m_breakHandler; DisassemblerHandler *m_disassemblerHandler; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 6e90b5cd54c9a112fc12090e795ae60c24bd1072..8d796060649b81f63ebdfde9f07c6952a86ebef9 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1037,15 +1037,16 @@ void DebuggerPlugin::readSettings() s->endGroup(); m_manager->mainWindow()->restoreState(ba); + m_manager->setLocked(m_toggleLockedAction->isChecked()); } void DebuggerPlugin::onModeChanged(IMode *mode) { if (mode != m_debugMode) { - m_manager->setFloatingDockWidgetsVisible(false); + m_manager->modeVisibilityChanged(false); return; } - m_manager->setFloatingDockWidgetsVisible(true); + m_manager->modeVisibilityChanged(true); EditorManager *editorManager = EditorManager::instance(); diff --git a/src/plugins/designer/formeditorplugin.cpp b/src/plugins/designer/formeditorplugin.cpp index 39b1e17775b74561a41411f00d9ea9d5b500372b..8962f2f714abfea35cfd88f86c1afb2609621989 100644 --- a/src/plugins/designer/formeditorplugin.cpp +++ b/src/plugins/designer/formeditorplugin.cpp @@ -148,14 +148,14 @@ bool FormEditorPlugin::initializeTemplates(QString *error) wizardParameters.setTrCategory(tr("Qt")); const QString formFileType = QLatin1String(Constants::FORM_FILE_TYPE); wizardParameters.setName(tr("Qt Designer Form")); - wizardParameters.setDescription(tr("This creates a new Qt Designer form file.")); + wizardParameters.setDescription(tr("Creates a Qt Designer form file (.ui).")); m_formWizard = new FormWizard(wizardParameters, this); addObject(m_formWizard); #ifdef CPP_ENABLED wizardParameters.setKind(Core::IWizard::ClassWizard); wizardParameters.setName(tr("Qt Designer Form Class")); - wizardParameters.setDescription(tr("This creates a new Qt Designer form class.")); + wizardParameters.setDescription(tr("Creates a Qt Designer form file (.ui) with a matching class.")); m_formClassWizard = new FormClassWizard(wizardParameters, this); addObject(m_formClassWizard); #endif diff --git a/src/plugins/designer/formwindoweditor.h b/src/plugins/designer/formwindoweditor.h index d5727c9f8deb538093aaea7de370bd8e726b51b8..950c2b53417fde34231cd3ef1b1272ed981f43bd 100644 --- a/src/plugins/designer/formwindoweditor.h +++ b/src/plugins/designer/formwindoweditor.h @@ -79,6 +79,7 @@ public: QToolBar *toolBar(); QByteArray saveState() const; bool restoreState(const QByteArray &state); + virtual bool temporaryEditor() const { return false; } // ContextInterface virtual QList<int> context() const; diff --git a/src/plugins/duieditor/duieditor.h b/src/plugins/duieditor/duieditor.h index c43530c996786a5aef6e9093a967eb418dc9851a..c331e212174e317f69069ea076d15676bc1b2478 100644 --- a/src/plugins/duieditor/duieditor.h +++ b/src/plugins/duieditor/duieditor.h @@ -64,6 +64,7 @@ public: bool duplicateSupported() const { return true; } Core::IEditor *duplicate(QWidget *parent); const char *kind() const; + bool temporaryEditor() const { return false; } private: QList<int> m_context; diff --git a/src/plugins/duieditor/duieditorplugin.cpp b/src/plugins/duieditor/duieditorplugin.cpp index 09898aaaf7df204a59a8cf01b586b6d9a72f869a..45216ebe846eb4f51d7fc583fe96ad211d4bbafa 100644 --- a/src/plugins/duieditor/duieditorplugin.cpp +++ b/src/plugins/duieditor/duieditorplugin.cpp @@ -95,7 +95,7 @@ bool DuiEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err addObject(m_editor); Core::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); - wizardParameters.setDescription(tr("Qt QML File")); + wizardParameters.setDescription(tr("Creates a Qt QML file.")); wizardParameters.setName(tr("Qt QML File")); wizardParameters.setCategory(QLatin1String("Qt")); wizardParameters.setTrCategory(tr("Qt")); diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.h b/src/plugins/genericprojectmanager/genericprojectfileseditor.h index a3aed60f561d1a77873988860f9da8b467ee9ab4..184e47e71251611545d6722064a02e38526c1ba2 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.h +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.h @@ -80,6 +80,8 @@ public: virtual bool duplicateSupported() const; virtual Core::IEditor *duplicate(QWidget *parent); + virtual bool temporaryEditor() const { return false; } + private: QList<int> m_context; }; diff --git a/src/plugins/qmlprojectmanager/qmlprojectfileseditor.h b/src/plugins/qmlprojectmanager/qmlprojectfileseditor.h index 4b189a379b37a1661159e756e7d48de35d8f46a5..619494671623c27c309a2bd2281056537f5618ca 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectfileseditor.h +++ b/src/plugins/qmlprojectmanager/qmlprojectfileseditor.h @@ -79,6 +79,7 @@ public: virtual bool duplicateSupported() const; virtual Core::IEditor *duplicate(QWidget *parent); + virtual bool temporaryEditor() const { return false; } private: QList<int> m_context; diff --git a/src/plugins/qt4projectmanager/profileeditor.h b/src/plugins/qt4projectmanager/profileeditor.h index ba7c70b734c338613bb1d5f24e18c57e5dbbcf8a..95e997afabb62465d0d7f629a693595ba313245f 100644 --- a/src/plugins/qt4projectmanager/profileeditor.h +++ b/src/plugins/qt4projectmanager/profileeditor.h @@ -62,6 +62,7 @@ public: bool duplicateSupported() const { return true; } Core::IEditor *duplicate(QWidget *parent); const char *kind() const; + bool temporaryEditor() const { return false; } private: QList<int> m_context; }; diff --git a/src/plugins/qtscripteditor/qtscripteditor.h b/src/plugins/qtscripteditor/qtscripteditor.h index 8042185796b71e59de102e1fd8d2e50c7873623c..727b3f18302f503daf7f1959fd7bd7420c65731c 100644 --- a/src/plugins/qtscripteditor/qtscripteditor.h +++ b/src/plugins/qtscripteditor/qtscripteditor.h @@ -58,6 +58,8 @@ public: Core::IEditor *duplicate(QWidget *parent); const char *kind() const; + bool temporaryEditor() const { return false; } + private: QList<int> m_context; }; diff --git a/src/plugins/qtscripteditor/qtscripteditorplugin.cpp b/src/plugins/qtscripteditor/qtscripteditorplugin.cpp index eadf2711ea8c691abc5138d79318e1e223c30b96..c37e1a5ec018ae842c1f698b2bb7f0807b15ca42 100644 --- a/src/plugins/qtscripteditor/qtscripteditorplugin.cpp +++ b/src/plugins/qtscripteditor/qtscripteditorplugin.cpp @@ -94,7 +94,7 @@ bool QtScriptEditorPlugin::initialize(const QStringList & /*arguments*/, QString addObject(m_editor); Core::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); - wizardParameters.setDescription(tr("Qt Script file")); + wizardParameters.setDescription(tr("Creates a Qt Script file.")); wizardParameters.setName(tr("Qt Script file")); wizardParameters.setCategory(QLatin1String("Qt")); wizardParameters.setTrCategory(tr("Qt")); diff --git a/src/plugins/quickopen/quickopenplugin.cpp b/src/plugins/quickopen/quickopenplugin.cpp index d8834b3bdfea7c27a27eacd683292c99569a5d30..ae64e8dfe5132640f30b703565dc107fd2bb703f 100644 --- a/src/plugins/quickopen/quickopenplugin.cpp +++ b/src/plugins/quickopen/quickopenplugin.cpp @@ -37,13 +37,14 @@ #include "directoryfilter.h" #include "settingspage.h" -#include <QtCore/QtPlugin> #include <QtCore/QSettings> +#include <QtCore/QtPlugin> #include <QtCore/QFuture> #include <QtCore/QFutureWatcher> #include <coreplugin/baseview.h> #include <coreplugin/coreconstants.h> +#include <coreplugin/settingsdatabase.h> #include <coreplugin/icore.h> #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> @@ -143,46 +144,70 @@ void QuickOpenPlugin::startSettingsLoad() connect(&m_loadWatcher, SIGNAL(finished()), this, SLOT(settingsLoaded())); } -void QuickOpenPlugin::loadSettings() +namespace QuickOpen { +namespace Internal { + +template <typename S> +static void loadSettingsHelper(QuickOpenPlugin *p, S *settings) { - QSettings settings; - settings.beginGroup("QuickOpen"); - m_refreshTimer.setInterval(settings.value("RefreshInterval", 60).toInt()*60000); - foreach (IQuickOpenFilter *filter, m_filters) { - if (settings.contains(filter->name())) { - const QByteArray state = settings.value(filter->name()).toByteArray(); + settings->beginGroup("QuickOpen"); + p->m_refreshTimer.setInterval(settings->value("RefreshInterval", 60).toInt() * 60000); + + foreach (IQuickOpenFilter *filter, p->m_filters) { + if (settings->contains(filter->name())) { + const QByteArray state = settings->value(filter->name()).toByteArray(); if (!state.isEmpty()) filter->restoreState(state); } } - settings.beginGroup("CustomFilters"); + settings->beginGroup("CustomFilters"); QList<IQuickOpenFilter *> customFilters; - foreach (const QString &key, settings.childKeys()) { + foreach (const QString &key, settings->childKeys()) { IQuickOpenFilter *filter = new DirectoryFilter; - filter->restoreState(settings.value(key).toByteArray()); - m_filters.append(filter); + filter->restoreState(settings->value(key).toByteArray()); + p->m_filters.append(filter); customFilters.append(filter); } - setCustomFilters(customFilters); - settings.endGroup(); - settings.endGroup(); + p->setCustomFilters(customFilters); + settings->endGroup(); + settings->endGroup(); +} + +} // namespace Internal +} // namespace QuickOpen + +void QuickOpenPlugin::loadSettings() +{ + Core::ICore *core = Core::ICore::instance(); + QSettings *qs = core->settings(); + + // Backwards compatibility to old settings location + if (qs->contains("QuickOpen/FiltersFilter")) { + loadSettingsHelper(this, qs); + } else { + Core::SettingsDatabase *settings = core->settingsDatabase(); + loadSettingsHelper(this, settings); + } + + qs->remove("QuickOpen"); } void QuickOpenPlugin::settingsLoaded() { m_quickOpenToolWindow->updateFilterList(); m_quickOpenToolWindow->setEnabled(true); - m_refreshTimer.start(); + if (m_refreshTimer.interval() > 0) + m_refreshTimer.start(); } void QuickOpenPlugin::saveSettings() { Core::ICore *core = Core::ICore::instance(); - if (core && core->settings()) { - QSettings *s = core->settings(); + if (core && core->settingsDatabase()) { + Core::SettingsDatabase *s = core->settingsDatabase(); s->beginGroup("QuickOpen"); - s->setValue("Interval", m_refreshTimer.interval() / 60000); s->remove(""); + s->setValue("RefreshInterval", refreshInterval()); foreach (IQuickOpenFilter *filter, m_filters) { if (!m_customFilters.contains(filter)) s->setValue(filter->name(), filter->saveState()); @@ -232,7 +257,7 @@ void QuickOpenPlugin::setCustomFilters(QList<IQuickOpenFilter *> filters) int QuickOpenPlugin::refreshInterval() { - return m_refreshTimer.interval()/60000; + return m_refreshTimer.interval() / 60000; } void QuickOpenPlugin::setRefreshInterval(int interval) @@ -242,7 +267,7 @@ void QuickOpenPlugin::setRefreshInterval(int interval) m_refreshTimer.setInterval(0); return; } - m_refreshTimer.setInterval(interval*60000); + m_refreshTimer.setInterval(interval * 60000); m_refreshTimer.start(); } @@ -252,7 +277,9 @@ void QuickOpenPlugin::refresh(QList<IQuickOpenFilter*> filters) filters = m_filters; QFuture<void> task = QtConcurrent::run(&IQuickOpenFilter::refresh, filters); Core::FutureProgress *progress = Core::ICore::instance() - ->progressManager()->addTask(task, tr("Indexing"), QuickOpen::Constants::TASK_INDEX, Core::ProgressManager::CloseOnSuccess); + ->progressManager()->addTask(task, tr("Indexing"), + QuickOpen::Constants::TASK_INDEX, + Core::ProgressManager::CloseOnSuccess); connect(progress, SIGNAL(finished()), this, SLOT(saveSettings())); } diff --git a/src/plugins/quickopen/quickopenplugin.h b/src/plugins/quickopen/quickopenplugin.h index fc62cb84ca031524d7384cea3996319466d4ae22..e2898333b5b60eab2f94a9532f2be2a875c92eff 100644 --- a/src/plugins/quickopen/quickopenplugin.h +++ b/src/plugins/quickopen/quickopenplugin.h @@ -86,6 +86,9 @@ private: OpenDocumentsFilter *m_openDocumentsFilter; FileSystemFilter *m_fileSystemFilter; QFutureWatcher<void> m_loadWatcher; + + template <typename S> + friend void loadSettingsHelper(QuickOpenPlugin *p, S *settings); }; } // namespace Internal diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp index bb04c71cda218d38ecf4bbf0452a534659633023..826553f2d532868bc0fd388a7dc1d61d11e35dfa 100644 --- a/src/plugins/resourceeditor/resourceeditorplugin.cpp +++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp @@ -74,8 +74,8 @@ bool ResourceEditorPlugin::initialize(const QStringList &arguments, QString *err addObject(m_editor); Core::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); - wizardParameters.setDescription(tr("Resource file")); - wizardParameters.setName(tr("Resource file")); + wizardParameters.setDescription(tr("Create a Qt Resource file (.qrc).")); + wizardParameters.setName(tr("Qt Resource file")); wizardParameters.setCategory(QLatin1String("Qt")); wizardParameters.setTrCategory(tr("Qt")); diff --git a/src/plugins/resourceeditor/resourceeditorw.h b/src/plugins/resourceeditor/resourceeditorw.h index de341d90c2cacfe7ba3de9dafb269154636480d6..089c1ccedcf9e26063d5ef980157d9a835444d55 100644 --- a/src/plugins/resourceeditor/resourceeditorw.h +++ b/src/plugins/resourceeditor/resourceeditorw.h @@ -105,6 +105,7 @@ public: QWidget *widget(); void setSuggestedFileName(const QString &fileName); + bool temporaryEditor() const { return false; } private slots: void dirtyChanged(bool); diff --git a/src/plugins/texteditor/plaintexteditor.h b/src/plugins/texteditor/plaintexteditor.h index 8271d1fc37ae49627558b64f5a214aa3ae4f9854..630c487eaee1b84c3669ff2819f13b03550b9217 100644 --- a/src/plugins/texteditor/plaintexteditor.h +++ b/src/plugins/texteditor/plaintexteditor.h @@ -47,6 +47,7 @@ public: bool duplicateSupported() const { return true; } Core::IEditor *duplicate(QWidget *parent); const char *kind() const; + bool temporaryEditor() const { return false; } private: QList<int> m_context; }; diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index d1e4ce5c8fd4546a2294f63992b43e6ad5ffd55e..0eab66e3008bb77e0a938222975a68ce2101bf1f 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -90,7 +90,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe return false; Core::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); - wizardParameters.setDescription(tr("This creates a new text file (.txt)")); + wizardParameters.setDescription(tr("Creates a text file (.txt).")); wizardParameters.setName(tr("Text File")); wizardParameters.setCategory(QLatin1String("General")); wizardParameters.setTrCategory(tr("General")); diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 3675999266e9d1b2e03891bdee26153f855d8dd0..ad2112187f82997914eb3b0c76a26c6c746c0237 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -75,6 +75,8 @@ public: Core::IEditor *duplicate(QWidget * /*parent*/) { return 0; } const char *kind() const { return m_kind; } + bool temporaryEditor() const { return true; } + private: const char *m_kind; QList<int> m_context; @@ -104,6 +106,8 @@ public: virtual QToolBar *toolBar() { return m_toolBar; } QComboBox *diffFileBrowseComboBox() const { return m_diffFileBrowseComboBox; } + bool temporaryEditor() const { return true; } + private: QComboBox *m_diffFileBrowseComboBox; QToolBar *m_toolBar; diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.h b/src/plugins/vcsbase/vcsbasesubmiteditor.h index 3cd2e62bcba6785a61eaef47450695cd737f9bde..6b0138df396c2d4e4a8089672ceb1c6214d425e8 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.h +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.h @@ -159,6 +159,8 @@ public: // be restricted to them static QStringList currentProjectFiles(bool nativeSeparators, QString *name = 0); + bool temporaryEditor() const { return true; } + signals: void diffSelectedFiles(const QStringList &files); diff --git a/tests/benchmarks/qstringbuilder/main.cpp b/tests/benchmarks/qstringbuilder/main.cpp index 0967e1682e4238ab48eebe364e483aa2c6a5a588..c4a832c7049ac37c28c597fcabb04a4b2b6d2df0 100644 --- a/tests/benchmarks/qstringbuilder/main.cpp +++ b/tests/benchmarks/qstringbuilder/main.cpp @@ -10,140 +10,211 @@ #define COMPARE(a, b) QCOMPARE(a, b) //#define COMPARE(a, b) -#define SEP(s) qDebug() << "\n------- " s " ----------"; +#define SEP(s) qDebug() << "\n\n-------- " s " ---------"; +#define L(s) QLatin1String(s) class tst_qstringbuilder : public QObject { Q_OBJECT public: - tst_qstringbuilder(); + tst_qstringbuilder() + : l1literal("some string literal"), + l1string("some string literal"), + string(l1string), + achar('c') + {} + + +public: + enum { N = 10000 }; + + int run_traditional() + { + int s = 0; + for (int i = 0; i < N; ++i) { +#if 0 + s += QString(l1string + l1string).size(); + s += QString(l1string + l1string + l1string).size(); + s += QString(l1string + l1string + l1string + l1string).size(); + s += QString(l1string + l1string + l1string + l1string + l1string).size(); +#endif + s += QString(achar + l1string + achar).size(); + } + return s; + } + + int run_builder() + { + int s = 0; + for (int i = 0; i < N; ++i) { +#if 0 + s += QString(l1literal % l1literal).size(); + s += QString(l1literal % l1literal % l1literal).size(); + s += QString(l1literal % l1literal % l1literal % l1literal).size(); + s += QString(l1literal % l1literal % l1literal % l1literal % l1literal).size(); +#endif + s += QString(achar % l1literal % achar).size(); + } + return s; + } private slots: - void separator_2() { SEP("string + string (builder first)"); } - void b_2_l1literal(); - void s_2_l1string(); - void separator_3() { SEP("3 strings"); } - void b_3_l1literal(); - void s_3_l1string(); + void separator_0() { + qDebug() << "\nIn each block the QStringBuilder based result appear first, " + "QStringBased second.\n"; + } - void separator_4() { SEP("4 strings"); } - void b_4_l1literal(); - void s_4_l1string(); + void separator_1() { SEP("literal + literal (builder first)"); } - void separator_5() { SEP("5 strings"); } - void b_5_l1literal(); - void s_5_l1string(); + void b_2_l1literal() { + QBENCHMARK { r = l1literal % l1literal; } + COMPARE(r, l1string + l1string); + } + void s_2_l1string() { + QBENCHMARK { r = l1string + l1string; } + COMPARE(r, QString(l1literal % l1literal)); + } - void separator_6() { SEP("4 chars"); } - void b_string_4_char(); - void s_string_4_char(); - void separator_7() { SEP("char + string + char"); } - void b_char_string_char(); - void s_char_string_char(); + void separator_2() { SEP("2 strings"); } -private: - const QLatin1Literal l1literal; - const QLatin1String l1string; - const QString string; - const char achar; -}; + void b_2_string() { + QBENCHMARK { r = string % string; } + COMPARE(r, string + string); + } + void s_2_string() { + QBENCHMARK { r = string + string; } + COMPARE(r, QString(string % string)); + } -tst_qstringbuilder::tst_qstringbuilder() - : l1literal("some literal"), - l1string("some literal"), - string(l1string), - achar('c') -{} + void separator_2b() { SEP("3 strings"); } -void tst_qstringbuilder::b_2_l1literal() -{ - QString result; - QBENCHMARK { result = l1literal % l1literal; } - COMPARE(result, l1string + l1string); -} + void b_3_string() { + QBENCHMARK { r = string % string % string; } + COMPARE(r, string + string + string); + } + void s_3_string() { + QBENCHMARK { r = string + string + string; } + COMPARE(r, QString(string % string % string)); + } -void tst_qstringbuilder::b_3_l1literal() -{ - QString result; - QBENCHMARK { result = l1literal % l1literal % l1literal; } - COMPARE(result, l1string + l1string + l1string); -} -void tst_qstringbuilder::b_4_l1literal() -{ - QString result; - QBENCHMARK { result = l1literal % l1literal % l1literal % l1literal; } - COMPARE(result, l1string + l1string + l1string + l1string); -} + void separator_2a() { SEP("string + literal (builder first)"); } -void tst_qstringbuilder::b_5_l1literal() -{ - QString result; - QBENCHMARK { result = l1literal % l1literal % l1literal % l1literal %l1literal; } - COMPARE(result, l1string + l1string + l1string + l1string + l1string); -} + void b_string_l1literal() { + QBENCHMARK { r = string % l1literal; } + COMPARE(r, string + l1string); + } + void b_string_l1string() { + QBENCHMARK { r = string % l1string; } + COMPARE(r, string + l1literal); + } + void s_string_l1literal() { + QBENCHMARK { r = string + l1literal; } + COMPARE(r, QString(string % l1string)); + } + void s_string_l1string() { + QBENCHMARK { r = string + l1string; } + COMPARE(r, QString(string % l1literal)); + } -void tst_qstringbuilder::b_string_4_char() -{ - QString result; - QBENCHMARK { result = string + achar + achar + achar + achar; } - COMPARE(result, QString(string % achar % achar % achar % achar)); -} -void tst_qstringbuilder::b_char_string_char() -{ - QString result; - QBENCHMARK { result = achar + string + achar; } - COMPARE(result, QString(achar % string % achar)); -} + void separator_3() { SEP("3 literals"); } + void b_3_l1literal() { + QBENCHMARK { r = l1literal % l1literal % l1literal; } + COMPARE(r, l1string + l1string + l1string); + } + void s_3_l1string() { + QBENCHMARK { r = l1string + l1string + l1string; } + COMPARE(r, QString(l1literal % l1literal % l1literal)); + } -void tst_qstringbuilder::s_2_l1string() -{ - QString result; - QBENCHMARK { result = l1string + l1string; } - COMPARE(result, QString(l1literal % l1literal)); -} -void tst_qstringbuilder::s_3_l1string() -{ - QString result; - QBENCHMARK { result = l1string + l1string + l1string; } - COMPARE(result, QString(l1literal % l1literal % l1literal)); -} + void separator_4() { SEP("4 literals"); } -void tst_qstringbuilder::s_4_l1string() -{ - QString result; - QBENCHMARK { result = l1string + l1string + l1string + l1string; } - COMPARE(result, QString(l1literal % l1literal % l1literal % l1literal)); -} + void b_4_l1literal() { + QBENCHMARK { r = l1literal % l1literal % l1literal % l1literal; } + COMPARE(r, l1string + l1string + l1string + l1string); + } + void s_4_l1string() { + QBENCHMARK { r = l1string + l1string + l1string + l1string; } + COMPARE(r, QString(l1literal % l1literal % l1literal % l1literal)); + } -void tst_qstringbuilder::s_5_l1string() -{ - QString result; - QBENCHMARK { result = l1string + l1string + l1string + l1string + l1string; } - COMPARE(result, QString(l1literal % l1literal % l1literal % l1literal % l1literal)); -} -void tst_qstringbuilder::s_string_4_char() -{ - QString result; - QBENCHMARK { result = string + achar + achar + achar + achar; } - COMPARE(result, QString(string % achar % achar % achar % achar)); -} + void separator_5() { SEP("5 literals"); } + + void b_5_l1literal() { + QBENCHMARK { r = l1literal % l1literal % l1literal % l1literal %l1literal; } + COMPARE(r, l1string + l1string + l1string + l1string + l1string); + } + + void s_5_l1string() { + QBENCHMARK { r = l1string + l1string + l1string + l1string + l1string; } + COMPARE(r, QString(l1literal % l1literal % l1literal % l1literal % l1literal)); + } + + + void separator_6() { SEP("4 chars"); } + + void b_string_4_char() { + QBENCHMARK { r = string + achar + achar + achar + achar; } + COMPARE(r, QString(string % achar % achar % achar % achar)); + } + + void s_string_4_char() { + QBENCHMARK { r = string + achar + achar + achar + achar; } + COMPARE(r, QString(string % achar % achar % achar % achar)); + } + + + void separator_7() { SEP("char + string + char"); } + + void b_char_string_char() { + QBENCHMARK { r = achar + string + achar; } + COMPARE(r, QString(achar % string % achar)); + } + + void s_char_string_char() { + QBENCHMARK { r = achar + string + achar; } + COMPARE(r, QString(achar % string % achar)); + } + +private: + const QLatin1Literal l1literal; + const QLatin1String l1string; + const QString string; + const QLatin1Char achar; + + QString r; +}; + -void tst_qstringbuilder::s_char_string_char() +int main(int argc, char *argv[]) { - QString result; - QBENCHMARK { result = achar + string + achar; } - COMPARE(result, QString(achar % string % achar)); + if (argc == 2 && (argv[1] == L("--run-builder") || argv[1] == L("-b"))) { + tst_qstringbuilder test; + return test.run_builder(); + } + + if (argc == 2 && (argv[1] == L("--run-traditional") || argv[1] == L("-t"))) { + tst_qstringbuilder test; + return test.run_traditional(); + } + + if (argc == 1) { + QCoreApplication app(argc, argv); + QStringList args = app.arguments(); + tst_qstringbuilder test; + return QTest::qExec(&test, argc, argv); + } + + qDebug() << "Usage: " << argv[0] << " [--run-builder|-r|--run-traditional|-t]"; } -QTEST_MAIN(tst_qstringbuilder) #include "main.moc" diff --git a/tests/benchmarks/qstringbuilder/qstringbuilder.pro b/tests/benchmarks/qstringbuilder/qstringbuilder.pro index 578ca1d3ac7a68dd1c1bec21195d2323c3940f30..870f2e26bba9584bfd69e7c7967fc7c9a3b915ee 100644 --- a/tests/benchmarks/qstringbuilder/qstringbuilder.pro +++ b/tests/benchmarks/qstringbuilder/qstringbuilder.pro @@ -4,6 +4,9 @@ TARGET = tst_qstringbuilder STRINGBUILDERDIR = ../../../src/libs/utils INCLUDEPATH += $$STRINGBUILDERDIR +QMAKE_CXXFLAGS += -g +QMAKE_CFLAGS += -g + QT -= gui CONFIG += release