diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp index 7a304607b6ccbeb506ed3d9096733bf5cf8f8b4e..5b9b36d1282cec5e5bbc943e1d72f52b8f19b621 100644 --- a/bin/gdbmacros/gdbmacros.cpp +++ b/bin/gdbmacros/gdbmacros.cpp @@ -36,24 +36,42 @@ // this relies on contents copied from qobject_p.h #define PRIVATE_OBJECT_ALLOWED 1 -#include <QDateTime> -#include <QDebug> -#include <QDir> -#include <QFile> -#include <QFileInfo> -#include <QHash> -#include <QLinkedList> -#include <QLocale> -#include <QMap> -#include <QMetaObject> -#include <QMetaProperty> -#include <QModelIndex> -#include <QObject> -#include <QPointer> -#include <QString> -#include <QTextCodec> -#include <QVector> +#include <QtCore/QDateTime> +#include <QtCore/QDebug> +#include <QtCore/QDir> +#include <QtCore/QFile> +#include <QtCore/QFileInfo> +#include <QtCore/QHash> +#include <QtCore/QLinkedList> +#include <QtCore/QLocale> +#include <QtCore/QMap> +#include <QtCore/QMetaObject> +#include <QtCore/QMetaProperty> +#include <QtCore/QModelIndex> +#include <QtCore/QObject> +#include <QtCore/QPointer> +#include <QtCore/QString> +#include <QtCore/QTextCodec> +#include <QtCore/QVector> +int qtGhVersion = QT_VERSION; + +#ifdef QT_GUI_LIB +# include <QtGui/QPixmap> +# include <QtGui/QImage> +#endif + +#include <list> +#include <map> +#include <string> +#include <vector> + +#include <ctype.h> +#include <stdio.h> + +#ifdef Q_OS_WIN +# include <windows.h> +#endif /*! \class QDumper @@ -91,7 +109,7 @@ 'P(d, name, value)' roughly expands to: - d << (name) << "=\"" << value << "\""; + d << (name) << "='" << value << "'"; Useful (i.e. understood by the IDE) names include: @@ -117,25 +135,6 @@ */ -int qtGhVersion = QT_VERSION; - -#ifdef QT_GUI_LIB -# include <QPixmap> -# include <QImage> -#endif - -#include <list> -#include <map> -#include <string> -#include <vector> - -#include <ctype.h> -#include <stdio.h> - -#ifdef Q_OS_WIN -# include <windows.h> -#endif - #undef NS #ifdef QT_NAMESPACE # define STRINGIFY0(s) #s @@ -216,7 +215,8 @@ QT_END_NAMESPACE // this can be mangled typenames of nested templates, each char-by-char // comma-separated integer list static char qDumpInBuffer[10000]; -static char qDumpBuffer[1000]; +static char qDumpOutBuffer[100000]; +static char qDumpSize[20]; namespace { @@ -385,7 +385,6 @@ struct QDumper { explicit QDumper(); ~QDumper(); - void flush(); void checkFill(); QDumper &operator<<(long c); QDumper &operator<<(int i); @@ -407,8 +406,6 @@ struct QDumper void beginHash(); // start of data hash output void endHash(); // start of data hash output - void write(const void *buf, int len); // raw write to stdout - // the dumper arguments int protocolVersion; // dumper protocol version int token; // some token to show on success @@ -427,6 +424,7 @@ struct QDumper // internal state bool success; // are we finished? + bool full; int pos; int extraInt[4]; @@ -436,34 +434,16 @@ struct QDumper QDumper::QDumper() { success = false; - pos = 0; + full = false; + qDumpOutBuffer[0] = 'f'; // marks output as 'wrong' + pos = 1; } QDumper::~QDumper() { - flush(); - - char buf[30]; - int len = qsnprintf(buf, sizeof(buf) - 1, "%d^done\n", token); - write(buf, len); -} - -void QDumper::write(const void *buf, int len) -{ - ::fwrite(buf, len, 1, stdout); - ::fflush(stdout); -} - -void QDumper::flush() -{ - if (pos != 0) { - char buf[30]; - int len = qsnprintf(buf, sizeof(buf) - 1, "%d#%d,", token, pos); - write(buf, len); - write(qDumpBuffer, pos); - write("\n", 1); - pos = 0; - } + qDumpOutBuffer[pos++] = '\0'; + if (success) + qDumpOutBuffer[0] = (full ? '+' : 't'); } void QDumper::setupTemplateParameters() @@ -489,49 +469,49 @@ void QDumper::setupTemplateParameters() QDumper &QDumper::operator<<(unsigned long long c) { checkFill(); - pos += sprintf(qDumpBuffer + pos, "%llu", c); + pos += sprintf(qDumpOutBuffer + pos, "%llu", c); return *this; } QDumper &QDumper::operator<<(unsigned long c) { checkFill(); - pos += sprintf(qDumpBuffer + pos, "%lu", c); + pos += sprintf(qDumpOutBuffer + pos, "%lu", c); return *this; } QDumper &QDumper::operator<<(float d) { checkFill(); - pos += sprintf(qDumpBuffer + pos, "%f", d); + pos += sprintf(qDumpOutBuffer + pos, "%f", d); return *this; } QDumper &QDumper::operator<<(double d) { checkFill(); - pos += sprintf(qDumpBuffer + pos, "%f", d); + pos += sprintf(qDumpOutBuffer + pos, "%f", d); return *this; } QDumper &QDumper::operator<<(unsigned int i) { checkFill(); - pos += sprintf(qDumpBuffer + pos, "%u", i); + pos += sprintf(qDumpOutBuffer + pos, "%u", i); return *this; } QDumper &QDumper::operator<<(long c) { checkFill(); - pos += sprintf(qDumpBuffer + pos, "%ld", c); + pos += sprintf(qDumpOutBuffer + pos, "%ld", c); return *this; } QDumper &QDumper::operator<<(int i) { checkFill(); - pos += sprintf(qDumpBuffer + pos, "%d", i); + pos += sprintf(qDumpOutBuffer + pos, "%d", i); return *this; } @@ -555,22 +535,23 @@ QDumper &QDumper::operator<<(const void *p) void QDumper::checkFill() { - if (pos >= int(sizeof(qDumpBuffer)) - 100) - flush(); + if (pos >= int(sizeof(qDumpOutBuffer)) - 100) + full = true; } void QDumper::put(char c) { checkFill(); - qDumpBuffer[pos++] = c; + if (!full) + qDumpOutBuffer[pos++] = c; } void QDumper::addCommaIfNeeded() { if (pos == 0) return; - char c = qDumpBuffer[pos - 1]; - if (c == '}' || c == '"' || c == ']') + char c = qDumpOutBuffer[pos - 1]; + if (c == '}' || c == '\'' || c == ']') put(','); } @@ -632,7 +613,6 @@ QDumper &QDumper::operator<<(const QString &str) void QDumper::disarm() { - flush(); success = true; } @@ -650,7 +630,7 @@ void QDumper::endHash() void QDumper::putEllipsis() { addCommaIfNeeded(); - *this << "{name=\"<incomplete>\",value=\"\",type=\"" << innertype << "\"}"; + *this << "{name='<incomplete>',value='',type='" << innertype << "'}"; } // @@ -662,7 +642,7 @@ void QDumper::putEllipsis() #define P(dumper,name,value) \ do { \ dumper.addCommaIfNeeded(); \ - dumper << (name) << "=\"" << value << "\""; \ + dumper << (name) << "='" << value << "'"; \ } while (0) // simple string property @@ -760,7 +740,7 @@ static void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr return; case 'B': if (isEqual(type, "QByteArray")) { - d << key << "encoded=\"1\","; + d << key << "encoded='1',"; P(d, key, *(QByteArray*)addr); } return; @@ -789,7 +769,7 @@ static void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr return; case 'S': if (isEqual(type, "QString")) { - d << key << "encoded=\"1\","; + d << key << "encoded='1',"; P(d, key, *(QString*)addr); } return; @@ -856,7 +836,7 @@ static void qDumpQByteArray(QDumper &d) char buf[20]; for (int i = 0; i != ba.size(); ++i) { unsigned char c = ba.at(i); - unsigned char u = isprint(c) && c != '"' ? c : '?'; + unsigned char u = (isprint(c) && c != '\'' && c != '"') ? c : '?'; sprintf(buf, "%02x (%u '%c')", c, c, u); d.beginHash(); P(d, "name", "[" << i << "]"); @@ -2028,7 +2008,7 @@ static void qDumpQVariantHelper(const void *data, QString *value, *numchild = 0; break; case QVariant::String: - *value = QLatin1Char('"') + v.toString() + QLatin1Char('"'); + *value = QLatin1Char('\'') + v.toString() + QLatin1Char('\''); *numchild = 0; break; case QVariant::StringList: @@ -2260,9 +2240,9 @@ static void qDumpStdString(QDumper &d) qCheckAccess(str.c_str() + str.size() - 1); } - d << ",value=\""; + d << ",value='"; d.putBase64Encoded(str.c_str(), str.size()); - d << "\""; + d << "'"; P(d, "valueencoded", "1"); P(d, "type", "std::string"); P(d, "numchild", "0"); @@ -2279,9 +2259,9 @@ static void qDumpStdWString(QDumper &d) qCheckAccess(str.c_str() + str.size() - 1); } - d << "value=\""; + d << "value='"; d.putBase64Encoded((const char *)str.c_str(), str.size() * sizeof(wchar_t)); - d << "\""; + d << "'"; P(d, "valueencoded", (sizeof(wchar_t) == 2 ? "2" : "3")); P(d, "type", "std::wstring"); P(d, "numchild", "0"); @@ -2502,54 +2482,54 @@ void qDumpObjectData440( // They are mentioned here nevertheless. For types that not listed // here, dumpers won't be used. d << "dumpers=[" - "\""NS"QByteArray\"," - "\""NS"QDateTime\"," - "\""NS"QDir\"," - "\""NS"QFile\"," - "\""NS"QFileInfo\"," - "\""NS"QHash\"," - "\""NS"QHashNode\"," - "\""NS"QImage\"," - "\""NS"QLinkedList\"," - "\""NS"QList\"," - "\""NS"QLocale\"," - "\""NS"QMap\"," - "\""NS"QMapNode\"," - "\""NS"QModelIndex\"," + "'"NS"QByteArray'," + "'"NS"QDateTime'," + "'"NS"QDir'," + "'"NS"QFile'," + "'"NS"QFileInfo'," + "'"NS"QHash'," + "'"NS"QHashNode'," + "'"NS"QImage'," + "'"NS"QLinkedList'," + "'"NS"QList'," + "'"NS"QLocale'," + "'"NS"QMap'," + "'"NS"QMapNode'," + "'"NS"QModelIndex'," #if QT_VERSION >= 0x040500 - "\""NS"QMultiMap\"," + "'"NS"QMultiMap'," #endif - "\""NS"QObject\"," - "\""NS"QObjectMethodList\"," // hack to get nested properties display - "\""NS"QObjectPropertyList\"," + "'"NS"QObject'," + "'"NS"QObjectMethodList'," // hack to get nested properties display + "'"NS"QObjectPropertyList'," #if PRIVATE_OBJECT_ALLOWED - "\""NS"QObjectSignal\"," - "\""NS"QObjectSignalList\"," - "\""NS"QObjectSlot\"," - "\""NS"QObjectSlotList\"," + "'"NS"QObjectSignal'," + "'"NS"QObjectSignalList'," + "'"NS"QObjectSlot'," + "'"NS"QObjectSlotList'," #endif // PRIVATE_OBJECT_ALLOWED - // << "\""NS"QRegion\"," - "\""NS"QSet\"," - "\""NS"QString\"," - "\""NS"QStringList\"," - "\""NS"QTextCodec\"," - "\""NS"QVariant\"," - "\""NS"QVector\"," - "\""NS"QWidget\"," - "\"string\"," - "\"wstring\"," - "\"std::basic_string\"," - "\"std::list\"," - "\"std::map\"," - "\"std::string\"," - "\"std::vector\"," - "\"std::wstring\"," + // << "'"NS"QRegion'," + "'"NS"QSet'," + "'"NS"QString'," + "'"NS"QStringList'," + "'"NS"QTextCodec'," + "'"NS"QVariant'," + "'"NS"QVector'," + "'"NS"QWidget'," + "'string'," + "'wstring'," + "'std::basic_string'," + "'std::list'," + "'std::map'," + "'std::string'," + "'std::vector'," + "'std::wstring'," "]"; d << ",qtversion=[" - "\"" << ((QT_VERSION >> 16) & 255) << "\"," - "\"" << ((QT_VERSION >> 8) & 255) << "\"," - "\"" << ((QT_VERSION) & 255) << "\"]"; - d << ",namespace=\""NS"\""; + "'" << ((QT_VERSION >> 16) & 255) << "'," + "'" << ((QT_VERSION >> 8) & 255) << "'," + "'" << ((QT_VERSION) & 255) << "']"; + d << ",namespace='"NS"'"; d.disarm(); } diff --git a/doc/coding-style.qdoc b/doc/coding-style.qdoc index c2e886c85b3fb355e5b568cc741672f63725598d..fff5a4bd0fd308693c15b040cdda0493d0182689 100644 --- a/doc/coding-style.qdoc +++ b/doc/coding-style.qdoc @@ -265,6 +265,7 @@ Whitespace Always use only one blank line Always use a single space after a keyword, and before a curly brace. +\code // Wrong if(foo){ } @@ -272,18 +273,24 @@ Whitespace // Correct if (foo) { } +\endcode For pointers or references, always use a single space before '*' or '&', but never after. Avoid C-style casts when possible. +\code // Wrong char* blockOfMemory = (char* ) malloc(data.size()); // Correct char *blockOfMemory = (char *)malloc(data.size()); char *blockOfMemory = reinterpret_cast<char *>(malloc(data.size())); +\endcode + Of course, in this particulare case, using \c new might be an even better + option. Braces As a base rule, the left curly brace goes on the same line as the start of the statement: +\code // Wrong if (codec) { @@ -292,8 +299,10 @@ Braces // Correct if (codec) { } +\endcode Exception: Function implementations and class declarations always have the left brace on the start of a line: +\code static void foo(int g) { qDebug("foo: %i", g); @@ -302,8 +311,10 @@ Braces class Moo { }; +\endcode Use curly braces when the body of a conditional statement contains more than one line, and also if a single line statement is somewhat complex. +\code // Wrong if (address.isEmpty()) { return false; @@ -319,15 +330,19 @@ Braces for (int i = 0; i < 10; ++i) qDebug("%i", i); +\endcode Exception 1: Use braces also if the parent statement covers several lines / wraps +\code // Correct if (address.isEmpty() || !isValid() || !codec) { return false; } +\endcode Exception 2: Use braces also in if-then-else blocks where either the if-code or the else-code covers several lines +\code // Wrong if (address.isEmpty()) --it; @@ -358,16 +373,20 @@ Braces else ... } +\endcode Use curly braces when the body of a conditional statement is empty +\code // Wrong while (a); // Correct while (a) {} +\endcode Parentheses Use parentheses to group expressions: +\code // Wrong if (a && b || c) @@ -379,10 +398,12 @@ Parentheses // Correct (a + b) & c +\endcode Line breaks Keep lines shorter than 100 characters; insert line breaks if necessary. Commas go at the end of a broken line; operators start at the beginning of the new line. The operator is at the end of the line to avoid having to scroll if your editor is too narrow. +\code // Wrong if (longExpression + otherLongExpression + @@ -394,10 +415,7 @@ Line breaks + otherLongExpression + otherOtherLongExpression) { } - - - - +\endcode \section2 Declarations @@ -424,6 +442,32 @@ Line breaks If you create a new file, the top of the file should include a header comment equal to the one found in other source files of Qt Creator. +\section2 Include order + + Always go from less general to more general. In a typical implementation + file that would look like +\code + #include "myownheader.h" + ... + #include "other_headers_from_my_own_plugin.h" + ... + #include <other_plugin/headers_from_other_plugin.h> + ... + #include <QtCore/QSomeCoreClass> + ... + #include <QtGui/QSomeGuiClass> + ... + #include <some_system_C++_header> + ... + #include <some_system_C_header> +\endcode + This order ensures that the headers are self-contained. + + Using <...> instead of "..." for headers from other plugins helps + spotting plugin-external dependencies in the sources. + + Using empty lines between blocks of "peer" headers are encouraged. + \section2 Documentation The documentation is generated from source and header files. diff --git a/doc/qtcreator-session-manager.png b/doc/qtcreator-session-manager.png new file mode 100644 index 0000000000000000000000000000000000000000..66f387ac5dab659b0160db05834958112db37ede Binary files /dev/null and b/doc/qtcreator-session-manager.png differ diff --git a/doc/qtcreator-session-menu.png b/doc/qtcreator-session-menu.png new file mode 100644 index 0000000000000000000000000000000000000000..eaae9ef1465d8dbc2ecfbc76ed50cc987808c0d0 Binary files /dev/null and b/doc/qtcreator-session-menu.png differ diff --git a/doc/qtcreator.qdoc b/doc/qtcreator.qdoc index 91c433596bbaa6f518df68e0e8a3bd83d68e0a4d..4f393ec9dc186c3e6a6d4d989d7e861b43a83f3b 100644 --- a/doc/qtcreator.qdoc +++ b/doc/qtcreator.qdoc @@ -20,9 +20,9 @@ \table \row - \o \inlineimage qtcreator-screenshots.png + \o \inlineimage qtcreator-screenshots.png \row - \o Qt Creator includes a wide range of useful features. Among them are: + \o Qt Creator includes a wide range of useful features. Among them are: \list 1 \o \bold{Smart Code Editor}: The code editor provides syntax highlighting as well as code completion. @@ -157,21 +157,20 @@ \section1 Session Management in Qt Creator - ### screenshot - In Qt Creator, a session is a collection of loaded projects, opened files, editor settings, and so on. When you run Qt Creator, you have a default session. You can create a new session using the \gui{Session Manager...}, available in the \gui{File -> Session} menu. + + \image qtcreator-session-manager.png + + To switch between sessions, select \gui{File -> Session}. If you do not create and select any session, Qt Creator will always use the default session. -\omit - session management can also store project dependencies, thorbjorn is - currently working on it -\endomit + \image qtcreator-session-menu.png \section1 Qt Help Integration diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 6ed55492e50479b8531474d28971bf17ddd4afbe..e7d3011a7677ff132f46378e1d99538a201614d1 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -963,7 +963,21 @@ void Preprocessor::processElif(TokenIterator firstToken, TokenIterator lastToken } else if (iflevel == 0 && !skipping()) { // std::cerr << "*** WARNING #else without #if" << std::endl; } else if (!_true_test[iflevel] && !_skipping[iflevel - 1]) { - const Value result = evalExpression(tk.dot(), lastToken, _source); + + const char *first = startOfToken(*tk); + const char *last = startOfToken(*lastToken); + + MacroExpander expandCondition (env); + QByteArray condition; + condition.reserve(256); + expandCondition(first, last, &condition); + + QVector<Token> tokens = tokenize(condition); + + const Value result = evalExpression(tokens.constBegin(), + tokens.constEnd() - 1, + condition); + _true_test[iflevel] = ! result.is_zero (); _skipping[iflevel] = result.is_zero (); } else { diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 883459ba7d7c88f471516929e57e5c7a0f15af83..7d7e3c9f7e01147aa9fceffa727845ebdc4afa67 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -35,22 +35,23 @@ #include "bineditor.h" #include "bineditorconstants.h" +#include <QtCore/QFile> #include <QtCore/QFileInfo> #include <QtGui/QMenu> #include <QtGui/QAction> #include <QtGui/QMainWindow> #include <QtGui/QHBoxLayout> -#include <QtCore/QFile> -#include <coreplugin/icore.h> +#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/coreconstants.h> +#include <coreplugin/editormanager/editormanager.h> +#include <coreplugin/icore.h> #include <coreplugin/mimedatabase.h> #include <coreplugin/uniqueidmanager.h> -#include <coreplugin/actionmanager/actionmanager.h> -#include <coreplugin/editormanager/editormanager.h> -#include <texteditor/texteditorsettings.h> -#include <texteditor/fontsettings.h> +#include <extensionsystem/pluginmanager.h> #include <find/ifindsupport.h> +#include <texteditor/fontsettings.h> +#include <texteditor/texteditorsettings.h> #include <utils/linecolumnlabel.h> #include <utils/reloadpromptutils.h> @@ -204,7 +205,7 @@ public: break; } - switch (Core::Utils::reloadPrompt(fileName, BinEditorPlugin::core()->mainWindow())) { + switch (Core::Utils::reloadPrompt(fileName, Core::ICore::instance()->mainWindow())) { case Core::Utils::ReloadCurrent: open(fileName); break; @@ -230,12 +231,14 @@ class BinEditorInterface : public Core::IEditor { Q_OBJECT public: - BinEditorInterface(BinEditor *parent ) : Core::IEditor(parent) { + BinEditorInterface(BinEditor *parent) + : Core::IEditor(parent) + { + Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); m_editor = parent; m_file = new BinEditorFile(parent); - m_context << BinEditorPlugin::core()->uniqueIDManager()-> - uniqueIdentifier(Core::Constants::K_DEFAULT_BINARY_EDITOR); - m_context << BinEditorPlugin::core()->uniqueIDManager()->uniqueIdentifier(Constants::C_BINEDITOR); + m_context << uidm->uniqueIdentifier(Core::Constants::K_DEFAULT_BINARY_EDITOR); + m_context << uidm->uniqueIdentifier(Constants::C_BINEDITOR); m_cursorPositionLabel = new Core::Utils::LineColumnLabel; QHBoxLayout *l = new QHBoxLayout; @@ -272,10 +275,10 @@ public: void setDisplayName(const QString &title) { m_displayName = title; emit changed(); } bool duplicateSupported() const { return false; } - IEditor *duplicate(QWidget */*parent*/) { return 0; } + IEditor *duplicate(QWidget * /* parent */) { return 0; } - QByteArray saveState() const { return QByteArray();} // TODO - bool restoreState(const QByteArray &/*state*/) {return false;} // TODO + QByteArray saveState() const { return QByteArray(); } // TODO + bool restoreState(const QByteArray & /* state */) { return false; } // TODO QToolBar *toolBar() { return m_toolBar; } @@ -316,7 +319,8 @@ QString BinEditorFactory::kind() const Core::IFile *BinEditorFactory::open(const QString &fileName) { - Core::IEditor *iface = m_owner->m_core->editorManager()->openEditor(fileName, kind()); + Core::EditorManager *em = Core::EditorManager::instance(); + Core::IEditor *iface = em->openEditor(fileName, kind()); return iface ? iface->file() : 0; } @@ -334,35 +338,19 @@ QStringList BinEditorFactory::mimeTypes() const ///////////////////////////////// BinEditorPlugin ////////////////////////////////// -BinEditorPlugin *BinEditorPlugin::m_instance = 0; - -BinEditorPlugin::BinEditorPlugin() : - m_core(0) +BinEditorPlugin::BinEditorPlugin() { m_undoAction = m_redoAction = m_copyAction = m_selectAllAction = 0; - m_instance = this; } BinEditorPlugin::~BinEditorPlugin() { - m_instance = 0; -} - -BinEditorPlugin *BinEditorPlugin::instance() -{ - return m_instance; -} - -Core::ICore *BinEditorPlugin::core() -{ - return m_instance->m_core; } QAction *BinEditorPlugin::registerNewAction(const QString &id, const QString &title) { - QAction *result = new QAction(title, this); - m_core->actionManager()->registerAction(result, id, m_context); + Core::ICore::instance()->actionManager()->registerAction(result, id, m_context); return result; } @@ -385,7 +373,8 @@ void BinEditorPlugin::initializeEditor(BinEditor *editor) QObject::connect(editor, SIGNAL(modificationChanged(bool)), editorInterface, SIGNAL(changed())); editor->setEditorInterface(editorInterface); - m_context << BinEditorPlugin::core()->uniqueIDManager()->uniqueIdentifier(Constants::C_BINEDITOR); + Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); + m_context << uidm->uniqueIdentifier(Constants::C_BINEDITOR); if (!m_undoAction) { m_undoAction = registerNewAction(QLatin1String(Core::Constants::UNDO), this, SLOT(undoAction()), @@ -415,13 +404,16 @@ void BinEditorPlugin::initializeEditor(BinEditor *editor) aggregate->add(editor); } -bool BinEditorPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) +bool BinEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage) { - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - if (!m_core->mimeDatabase()->addMimeTypes(QLatin1String(":/bineditor/BinEditor.mimetypes.xml"), errorMessage)) + Q_UNUSED(arguments); + Q_UNUSED(errorMessage); + + Core::ICore *core = Core::ICore::instance(); + if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/bineditor/BinEditor.mimetypes.xml"), errorMessage)) return false; - connect(m_core, SIGNAL(contextAboutToChange(Core::IContext *)), + connect(core, SIGNAL(contextAboutToChange(Core::IContext *)), this, SLOT(updateCurrentEditor(Core::IContext *))); addAutoReleasedObject(new BinEditorFactory(this)); diff --git a/src/plugins/bineditor/bineditorplugin.h b/src/plugins/bineditor/bineditorplugin.h index 51ff129dd6259de65c085116b4116302e647433b..a7c782697075fa7a1c7c467afee3a58bf8e511db 100644 --- a/src/plugins/bineditor/bineditorplugin.h +++ b/src/plugins/bineditor/bineditorplugin.h @@ -43,7 +43,6 @@ #include <QtGui/QAction> namespace Core { -class ICore; class IWizard; } @@ -61,9 +60,6 @@ public: BinEditorPlugin(); ~BinEditorPlugin(); - static BinEditorPlugin *instance(); - static Core::ICore *core(); - bool initialize(const QStringList &arguments, QString *error_message = 0); void extensionsInitialized(); @@ -78,6 +74,7 @@ private slots: void updateActions(); void updateCurrentEditor(Core::IContext *object); + private: QList<int> m_context; QAction *registerNewAction(const QString &id, const QString &title = QString()); @@ -91,9 +88,6 @@ private: friend class BinEditorFactory; Core::IEditor *createEditor(QWidget *parent); - static BinEditorPlugin *m_instance; - - Core::ICore *m_core; typedef QList<Core::IWizard *> WizardList; WizardList m_wizards; BinEditorFactory *m_factory; diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index 86b5d889dbdb523daf06f333286c9ed79901e206..fa8eaefa55c1b30e8bc3e709e4eeb4d352d62945 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -37,9 +37,10 @@ #include "bookmarksplugin.h" #include "bookmarks_global.h" -#include <coreplugin/icore.h> #include <coreplugin/editormanager/editormanager.h> +#include <coreplugin/icore.h> #include <coreplugin/uniqueidmanager.h> +#include <extensionsystem/pluginmanager.h> #include <projectexplorer/projectexplorer.h> #include <texteditor/basetexteditor.h> #include <utils/qtcassert.h> @@ -57,6 +58,7 @@ Q_DECLARE_METATYPE(Bookmarks::Internal::Bookmark*) using namespace Bookmarks; using namespace Bookmarks::Internal; using namespace ProjectExplorer; +using namespace Core; BookmarkDelegate::BookmarkDelegate(QObject *parent) : QStyledItemDelegate(parent), m_normalPixmap(0), m_selectedPixmap(0) @@ -213,8 +215,7 @@ BookmarkView::BookmarkView(QWidget *parent) this, SLOT(gotoBookmark(const QModelIndex &))); m_bookmarkContext = new BookmarkContext(this); - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - core->addContextObject(m_bookmarkContext); + ICore::instance()->addContextObject(m_bookmarkContext); setItemDelegate(new BookmarkDelegate(this)); setFrameStyle(QFrame::NoFrame); @@ -224,8 +225,7 @@ BookmarkView::BookmarkView(QWidget *parent) BookmarkView::~BookmarkView() { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - core->removeContextObject(m_bookmarkContext); + ICore::instance()->removeContextObject(m_bookmarkContext); } void BookmarkView::contextMenuEvent(QContextMenuEvent *event) @@ -245,13 +245,11 @@ void BookmarkView::contextMenuEvent(QContextMenuEvent *event) connect(removeAll, SIGNAL(triggered()), this, SLOT(removeAll())); - menu.exec(mapToGlobal(event->pos())); } void BookmarkView::removeFromContextMenu() { - removeBookmark(m_contextMenuIndex); } @@ -295,8 +293,7 @@ void BookmarkView::gotoBookmark(const QModelIndex &index) BookmarkContext::BookmarkContext(BookmarkView *widget) : m_bookmarkView(widget) { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - m_context << core->uniqueIDManager()->uniqueIdentifier(Constants::BOOKMARKS_CONTEXT); + m_context << UniqueIDManager::instance()->uniqueIdentifier(Constants::BOOKMARKS_CONTEXT); } QList<int> BookmarkContext::context() const @@ -314,15 +311,14 @@ QWidget *BookmarkContext::widget() //// BookmarkManager::BookmarkManager() : - m_core(BookmarksPlugin::core()), m_bookmarkIcon(QIcon(QLatin1String(":/bookmarks/images/bookmark.png"))) { m_selectionModel = new QItemSelectionModel(this, this); - connect(m_core, SIGNAL(contextChanged(Core::IContext*)), + connect(Core::ICore::instance(), SIGNAL(contextChanged(Core::IContext*)), this, SLOT(updateActionStatus())); - ExtensionSystem::PluginManager *pm = m_core->pluginManager(); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ProjectExplorerPlugin *projectExplorer = pm->getObject<ProjectExplorerPlugin>(); connect(projectExplorer->session(), SIGNAL(sessionLoaded()), @@ -512,7 +508,8 @@ void BookmarkManager::documentPrevNext(bool next) nextLine = markLine; } - m_core->editorManager()->addCurrentPositionToNavigationHistory(true); + Core::EditorManager *em = Core::EditorManager::instance(); + em->addCurrentPositionToNavigationHistory(true); if (next) { if (nextLine == -1) editor->gotoLine(firstLine); @@ -524,7 +521,7 @@ void BookmarkManager::documentPrevNext(bool next) else editor->gotoLine(prevLine); } - m_core->editorManager()->addCurrentPositionToNavigationHistory(); + em->addCurrentPositionToNavigationHistory(); } void BookmarkManager::next() @@ -556,7 +553,8 @@ void BookmarkManager::prev() TextEditor::ITextEditor *BookmarkManager::currentTextEditor() const { - Core::IEditor *currEditor = m_core->editorManager()->currentEditor(); + Core::EditorManager *em = Core::EditorManager::instance(); + Core::IEditor *currEditor = em->currentEditor(); if (!currEditor) return 0; return qobject_cast<TextEditor::ITextEditor *>(currEditor); @@ -565,7 +563,7 @@ TextEditor::ITextEditor *BookmarkManager::currentTextEditor() const /* Returns the current session. */ SessionManager *BookmarkManager::sessionManager() const { - ExtensionSystem::PluginManager *pm = m_core->pluginManager(); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ProjectExplorerPlugin *pe = pm->getObject<ProjectExplorerPlugin>(); return pe->session(); } diff --git a/src/plugins/bookmarks/bookmarkmanager.h b/src/plugins/bookmarks/bookmarkmanager.h index 1763b4e52605dde5c5dd3a2b43ac92dc0817d4d9..0a422e5b2393871d6c3f1082655109b4a1915c25 100644 --- a/src/plugins/bookmarks/bookmarkmanager.h +++ b/src/plugins/bookmarks/bookmarkmanager.h @@ -48,7 +48,6 @@ class SessionManager; } namespace Core { -class ICore; class IEditor; } @@ -131,7 +130,6 @@ private: typedef QMap<QString, FileNameBookmarksMap *> DirectoryFileBookmarksMap; DirectoryFileBookmarksMap m_bookmarksMap; - Core::ICore *m_core; QIcon m_bookmarkIcon; diff --git a/src/plugins/bookmarks/bookmarksplugin.cpp b/src/plugins/bookmarks/bookmarksplugin.cpp index 55b28ec82a3a8f2cec7a6c4ab709e9de71858a27..d7051fab068429fd18bffe645be56afa5d9ccb2e 100644 --- a/src/plugins/bookmarks/bookmarksplugin.cpp +++ b/src/plugins/bookmarks/bookmarksplugin.cpp @@ -35,16 +35,17 @@ #include "bookmarkmanager.h" #include "bookmarks_global.h" -#include <texteditor/texteditorconstants.h> -#include <texteditor/itexteditor.h> #include <coreplugin/icore.h> #include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/coreconstants.h> #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> +#include <extensionsystem/pluginmanager.h> +#include <texteditor/itexteditor.h> +#include <texteditor/texteditorconstants.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QDebug> #include <QtGui/QMenu> @@ -56,7 +57,7 @@ using namespace TextEditor; BookmarksPlugin *BookmarksPlugin::m_instance = 0; BookmarksPlugin::BookmarksPlugin() - : m_bookmarkManager(0), m_core(0) + : m_bookmarkManager(0) { m_instance = this; } @@ -67,13 +68,13 @@ void BookmarksPlugin::extensionsInitialized() bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *) { - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - Core::ActionManager *am = m_core->actionManager(); + Core::ICore *core = Core::ICore::instance(); + Core::ActionManager *am = core->actionManager(); - QList<int> context = QList<int>() << m_core->uniqueIDManager()-> + QList<int> context = QList<int>() << core->uniqueIDManager()-> uniqueIdentifier(Constants::BOOKMARKS_CONTEXT); QList<int> textcontext, globalcontext; - textcontext << m_core->uniqueIDManager()-> + textcontext << core->uniqueIDManager()-> uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); globalcontext << Core::Constants::C_GLOBAL_ID; @@ -171,7 +172,7 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *) this, SLOT(bookmarkMarginActionTriggered())); // EditorManager - QObject *editorManager = m_core->editorManager(); + QObject *editorManager = core->editorManager(); connect(editorManager, SIGNAL(editorAboutToClose(Core::IEditor*)), this, SLOT(editorAboutToClose(Core::IEditor*))); connect(editorManager, SIGNAL(editorOpened(Core::IEditor*)), diff --git a/src/plugins/bookmarks/bookmarksplugin.h b/src/plugins/bookmarks/bookmarksplugin.h index f4853c48cb89f1b9d1d88ad9bde02dcded293471..ef3cfbe0236b25f8b98750df672d4f6917e59e24 100644 --- a/src/plugins/bookmarks/bookmarksplugin.h +++ b/src/plugins/bookmarks/bookmarksplugin.h @@ -45,7 +45,6 @@ class QMenu; QT_END_NAMESPACE namespace Core { -class ICore; class IEditor; } @@ -67,7 +66,6 @@ public: ~BookmarksPlugin(); static BookmarksPlugin *instance() { return m_instance; } - static Core::ICore *core() { return m_instance->m_core; } bool initialize(const QStringList &arguments, QString *error_message); void extensionsInitialized(); @@ -85,7 +83,6 @@ private slots: private: static BookmarksPlugin *m_instance; BookmarkManager *m_bookmarkManager; - Core::ICore *m_core; QAction *m_toggleAction; QAction *m_prevAction; diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index 1f4bc59e9efb04170f759024f6dd5a1244de86bd..845255eda5d8c1e0be6481fe7aa1804e7e7db28e 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -36,8 +36,6 @@ #include "cmakeproject.h" #include "cmakeprojectconstants.h" -#include <coreplugin/icore.h> -#include <extensionsystem/pluginmanager.h> #include <coreplugin/uniqueidmanager.h> #include <projectexplorer/projectexplorerconstants.h> @@ -45,9 +43,9 @@ using namespace CMakeProjectManager::Internal; CMakeManager::CMakeManager() { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - m_projectContext = core->uniqueIDManager()->uniqueIdentifier(CMakeProjectManager::Constants::PROJECTCONTEXT); - m_projectLanguage = core->uniqueIDManager()->uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX); + Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); + m_projectContext = uidm->uniqueIdentifier(CMakeProjectManager::Constants::PROJECTCONTEXT); + m_projectLanguage = uidm->uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX); } int CMakeManager::projectContext() const diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index e1b2b1279b61697701dea9d3dee90b4b8d65d2c3..29ad08ec5f1501ee5ec58c5a62f1fb72673a4f68 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -40,7 +40,7 @@ #include <coreplugin/icore.h> #include <coreplugin/mimedatabase.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QDebug> @@ -56,7 +56,7 @@ CMakeProjectPlugin::~CMakeProjectPlugin() bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":cmakeproject/CMakeProject.mimetypes.xml"), errorMessage)) return false; addAutoReleasedObject(new CMakeManager()); diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp index bf2d49826c0189fdd28503f94b0279118dcb9c69..d8c7a1930c41e06b849327a3ca4e81d276efcfdc 100644 --- a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp +++ b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp @@ -35,7 +35,6 @@ #include "actionmanager_p.h" #include "command_p.h" -#include "coreimpl.h" #include "coreconstants.h" #include "uniqueidmanager.h" @@ -150,15 +149,13 @@ bool ActionContainerPrivate::hasState(ContainerState state) const void ActionContainerPrivate::appendGroup(const QString &group) { - UniqueIDManager *idmanager = CoreImpl::instance()->uniqueIDManager(); - int gid = idmanager->uniqueIdentifier(group); + int gid = UniqueIDManager::instance()->uniqueIdentifier(group); m_groups << gid; } QAction *ActionContainerPrivate::insertLocation(const QString &group) const { - UniqueIDManager *idmanager = CoreImpl::instance()->uniqueIDManager(); - int grpid = idmanager->uniqueIdentifier(group); + int grpid = UniqueIDManager::instance()->uniqueIdentifier(group); int prevKey = 0; int pos = ((grpid << 16) | 0xFFFF); return beforeAction(pos, &prevKey); @@ -181,7 +178,7 @@ void ActionContainerPrivate::addAction(Command *action, const QString &group) } a->setStateFlags(a->stateFlags() | CommandPrivate::CS_Initialized); } else { - UniqueIDManager *idmanager = CoreImpl::instance()->uniqueIDManager(); + UniqueIDManager *idmanager = UniqueIDManager::instance(); int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO); if (!group.isEmpty()) grpid = idmanager->uniqueIdentifier(group); @@ -208,7 +205,7 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group } mc->setState(ActionContainerPrivate::CS_Initialized); } else { - UniqueIDManager *idmanager = CoreImpl::instance()->uniqueIDManager(); + UniqueIDManager *idmanager = UniqueIDManager::instance(); int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO); if (!group.isEmpty()) grpid = idmanager->uniqueIdentifier(group); diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp index 3932d42598b6cd2b466a993a9b131863d9173297..b5a1e5cc0c6c76520189008116db3625701ae9bb 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp +++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp @@ -61,7 +61,7 @@ namespace { You get the only implementation of this class from the core interface ICore::actionManager() method, e.g. \code - ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->actionManager() + Core::ICore::instance()->actionManager() \endcode The main reasons for the need of this class is to provide a central place where the user @@ -80,8 +80,7 @@ namespace { So to register a globally active action "My Action" put the following in your plugin's IPlugin::initialize method: \code - Core::ActionManager *am = ExtensionSystem::PluginManager::instance() - ->getObject<Core::ICore>()->actionManager(); + Core::ActionManager *am = Core::ICore::instance()->actionManager(); QAction *myAction = new QAction(tr("My Action"), this); Core::Command *cmd = am->registerAction(myAction, "myplugin.myaction", @@ -223,7 +222,7 @@ ActionManagerPrivate::~ActionManagerPrivate() qDeleteAll(m_idContainerMap.values()); } -ActionManagerPrivate* ActionManagerPrivate::instance() +ActionManagerPrivate *ActionManagerPrivate::instance() { return m_instance; } diff --git a/src/plugins/coreplugin/actionmanager/actionmanager_p.h b/src/plugins/coreplugin/actionmanager/actionmanager_p.h index 31513276ec1368e873249f79939bf64f21e81911..f1e106c4bf743702b98e8fa2d26ed6e38e99b142 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager_p.h +++ b/src/plugins/coreplugin/actionmanager/actionmanager_p.h @@ -69,7 +69,7 @@ public: ~ActionManagerPrivate(); void setContext(const QList<int> &context); - static ActionManagerPrivate* instance(); + static ActionManagerPrivate *instance(); void saveSettings(QSettings *settings); QList<int> defaultGroups() const; diff --git a/src/plugins/coreplugin/actionmanager/commandsfile.cpp b/src/plugins/coreplugin/actionmanager/commandsfile.cpp index abdecf43660d9c8be14d4a9b67c72e22789d5b48..8fc086079bbd113d40057800535abe4b871e77f1 100644 --- a/src/plugins/coreplugin/actionmanager/commandsfile.cpp +++ b/src/plugins/coreplugin/actionmanager/commandsfile.cpp @@ -31,7 +31,6 @@ ** ***************************************************************************/ -#include "coreimpl.h" #include "commandsfile.h" #include "shortcutsettings.h" #include "command_p.h" @@ -100,7 +99,7 @@ QMap<QString, QKeySequence> CommandsFile::importCommands() const */ bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items) { - UniqueIDManager *idmanager = CoreImpl::instance()->uniqueIDManager(); + UniqueIDManager *idmanager = UniqueIDManager::instance(); QFile file(m_filename); if (!file.open(QIODevice::WriteOnly)) @@ -110,8 +109,7 @@ bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items) QDomElement root = doc.createElement("mapping"); doc.appendChild(root); - for (int i=0; i<items.count(); ++i) { - ShortcutItem *item = items.at(i); + foreach (const ShortcutItem *item, items) { QDomElement ctag = doc.createElement("shortcut"); ctag.setAttribute(QLatin1String("id"), idmanager->stringForUniqueIdentifier(item->m_cmd->id())); root.appendChild(ctag); diff --git a/src/plugins/coreplugin/basefilewizard.cpp b/src/plugins/coreplugin/basefilewizard.cpp index aad82af6677679758db01335d57134af0bb5f07d..7a7279cfe49edc6b6a26caaf966775d64e9c02b2 100644 --- a/src/plugins/coreplugin/basefilewizard.cpp +++ b/src/plugins/coreplugin/basefilewizard.cpp @@ -38,6 +38,7 @@ #include <coreplugin/icore.h> #include <coreplugin/coreconstants.h> #include <coreplugin/ifilewizardextension.h> +#include <extensionsystem/pluginmanager.h> #include <utils/filewizarddialog.h> #include <QtCore/QDir> @@ -345,28 +346,19 @@ void WizardEventLoop::rejected() // ---------------- BaseFileWizardPrivate struct BaseFileWizardPrivate { - explicit BaseFileWizardPrivate(const Core::BaseFileWizardParameters ¶meters, - Core::ICore *core); + explicit BaseFileWizardPrivate(const Core::BaseFileWizardParameters ¶meters) + : m_parameters(parameters), m_wizardDialog(0) + {} const Core::BaseFileWizardParameters m_parameters; QWizard *m_wizardDialog; - Core::ICore *m_core; }; -Core::BaseFileWizardPrivate::BaseFileWizardPrivate(const BaseFileWizardParameters ¶meters, - Core::ICore *core) : - m_parameters(parameters), - m_wizardDialog(0), - m_core(core) -{ -} - // ---------------- Wizard BaseFileWizard::BaseFileWizard(const BaseFileWizardParameters ¶meters, - Core::ICore *core, QObject *parent) : IWizard(parent), - m_d(new BaseFileWizardPrivate(parameters, core)) + m_d(new BaseFileWizardPrivate(parameters)) { } @@ -517,13 +509,14 @@ bool BaseFileWizard::postGenerateFiles(const GeneratedFiles &l, QString *errorMe { // File mode: open the editors in file mode and ensure editor pane const Core::GeneratedFiles::const_iterator cend = l.constEnd(); + Core::EditorManager *em = Core::EditorManager::instance(); for (Core::GeneratedFiles::const_iterator it = l.constBegin(); it != cend; ++it) { - if (!m_d->m_core->editorManager()->openEditor(it->path(), it->editorKind())) { + if (!em->openEditor(it->path(), it->editorKind())) { *errorMessage = tr("Failed to open an editor for %1").arg(it->path()); return false; } } - m_d->m_core->editorManager()->ensureEditorManagerVisible(); + em->ensureEditorManagerVisible(); return true; } @@ -534,7 +527,6 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l if (debugWizard) qDebug() << Q_FUNC_INFO << location << files; - bool existingFilesFound = false; bool oddStuffFound = false; @@ -581,7 +573,7 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l const QString messageFormat = tr("The following files already exist in the directory %1:\n" "%2.\nWould you like to overwrite them?"); const QString message = messageFormat.arg(location).arg(fileNamesMsgPart); - const bool yes = (QMessageBox::question(core()->mainWindow(), + const bool yes = (QMessageBox::question(Core::ICore::instance()->mainWindow(), tr("Existing files"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) @@ -589,11 +581,6 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l return yes ? OverwriteOk : OverwriteCanceled; } -Core::ICore *BaseFileWizard::core() const -{ - return m_d->m_core; -} - QList<IWizard*> BaseFileWizard::allWizards() { return ExtensionSystem::PluginManager::instance()->getObjects<IWizard>(); @@ -636,19 +623,18 @@ QString BaseFileWizard::buildFileName(const QString &path, QString BaseFileWizard::preferredSuffix(const QString &mimeType) const { - const QString rc = m_d->m_core->mimeDatabase()->preferredSuffixByType(mimeType); + const QString rc = Core::ICore::instance()->mimeDatabase()->preferredSuffixByType(mimeType); if (rc.isEmpty()) qWarning("%s: WARNING: Unable to find a preferred suffix for %s.", Q_FUNC_INFO, mimeType.toUtf8().constData()); return rc; } -// ------------- StandardFileWizard( +// ------------- StandardFileWizard StandardFileWizard::StandardFileWizard(const BaseFileWizardParameters ¶meters, - Core::ICore *core, QObject *parent) : - BaseFileWizard(parameters, core, parent) + BaseFileWizard(parameters, parent) { } diff --git a/src/plugins/coreplugin/basefilewizard.h b/src/plugins/coreplugin/basefilewizard.h index 40e98793cb9f57e310fbd62b75906d90846ceb72..5f0a1ec9b555f44d24f0f7eca64cc54e773d7848 100644 --- a/src/plugins/coreplugin/basefilewizard.h +++ b/src/plugins/coreplugin/basefilewizard.h @@ -50,7 +50,6 @@ QT_END_NAMESPACE namespace Core { -class ICore; class IEditor; class IFileWizardExtension; @@ -69,7 +68,7 @@ public: GeneratedFile(); explicit GeneratedFile(const QString &path); GeneratedFile(const GeneratedFile &); - GeneratedFile &operator=(const GeneratedFile&); + GeneratedFile &operator=(const GeneratedFile &); ~GeneratedFile(); // Full path of the file should be created, or the suggested file name @@ -107,19 +106,19 @@ public: void setKind(IWizard::Kind k); QIcon icon() const; - void setIcon(const QIcon&); + void setIcon(const QIcon &icon); QString description() const; - void setDescription(const QString &); + void setDescription(const QString &description); QString name() const; - void setName(const QString &); + void setName(const QString &name); QString category() const; - void setCategory(const QString &); + void setCategory(const QString &category); QString trCategory() const; - void setTrCategory(const QString &); + void setTrCategory(const QString &trCategory); private: QSharedDataPointer<BaseFileWizardParameterData> m_d; @@ -172,7 +171,7 @@ public: protected: typedef QList<QWizardPage *> WizardPageList; - explicit BaseFileWizard(const BaseFileWizardParameters ¶meters, Core::ICore *core, QObject *parent = 0); + explicit BaseFileWizard(const BaseFileWizardParameters ¶meters, QObject *parent = 0); // Overwrite to create the wizard dialog on the parent, adding // the extension pages. @@ -197,8 +196,6 @@ protected: OverwriteResult promptOverwrite(const QString &location, const QStringList &files, QString *errorMessage) const; - Core::ICore *core() const; - private: BaseFileWizardPrivate *m_d; }; @@ -213,7 +210,7 @@ class CORE_EXPORT StandardFileWizard : public BaseFileWizard Q_OBJECT protected: - explicit StandardFileWizard(const BaseFileWizardParameters ¶meters, Core::ICore *core, QObject *parent = 0); + explicit StandardFileWizard(const BaseFileWizardParameters ¶meters, QObject *parent = 0); // Implemented to create a Core::Utils::FileWizardDialog virtual QWizard *createWizardDialog(QWidget *parent, diff --git a/src/plugins/coreplugin/coreconstants.h b/src/plugins/coreplugin/coreconstants.h index 06d4d70085d16c3d026aad14358e20805ef4797e..469727c18441f1dbddce794fa1ea093859a7ac66 100644 --- a/src/plugins/coreplugin/coreconstants.h +++ b/src/plugins/coreplugin/coreconstants.h @@ -120,6 +120,7 @@ const char * const EXIT = "QtCreator.Exit"; const char * const OPTIONS = "QtCreator.Options"; const char * const TOGGLE_SIDEBAR = "QtCreator.ToggleSidebar"; +const char * const TOGGLE_FULLSCREEN = "QtCreator.ToggleFullScreen"; const char * const MINIMIZE_WINDOW = "QtCreator.MinimizeWindow"; const char * const ZOOM_WINDOW = "QtCreator.ZoomWindow"; @@ -173,11 +174,18 @@ const char * const G_FILE_OTHER = "QtCreator.Group.File.Other"; const char * const G_EDIT_UNDOREDO = "QtCreator.Group.Edit.UndoRedo"; const char * const G_EDIT_COPYPASTE = "QtCreator.Group.Edit.CopyPaste"; const char * const G_EDIT_SELECTALL = "QtCreator.Group.Edit.SelectAll"; -const char * const G_EDIT_FORMAT = "QtCreator.Group.Edit.Format"; +const char * const G_EDIT_ADVANCED = "QtCreator.Group.Edit.Advanced"; const char * const G_EDIT_FIND = "QtCreator.Group.Edit.Find"; const char * const G_EDIT_OTHER = "QtCreator.Group.Edit.Other"; +// advanced edit menu groups + +const char * const G_EDIT_FORMAT = "QtCreator.Group.Edit.Format"; +const char * const G_EDIT_COLLAPSING = "QtCreator.Group.Edit.Collapsing"; +const char * const G_EDIT_FONT = "QtCreator.Group.Edit.Font"; +const char * const G_EDIT_EDITOR = "QtCreator.Group.Edit.Editor"; + // window menu groups const char * const G_WINDOW_SIZE = "QtCreator.Group.Window.Size"; const char * const G_WINDOW_PANES = "QtCreator.Group.Window.Panes"; @@ -187,6 +195,7 @@ const char * const G_WINDOW_NAVIGATE = "QtCreator.Group.Window.Navigate"; const char * const G_WINDOW_NAVIGATE_GROUPS = "QtCreator.Group.Window.Navigate.Groups"; const char * const G_WINDOW_OTHER = "QtCreator.Group.Window.Other"; const char * const G_WINDOW_LIST = "QtCreator.Group.Window.List"; +const char * const G_WINDOW_FULLSCREEN = "QtCreator.Group.Window.Fullscreen"; // help groups (global) const char * const G_HELP_HELP = "QtCreator.Group.Help.Help"; diff --git a/src/plugins/coreplugin/coreimpl.cpp b/src/plugins/coreplugin/coreimpl.cpp index 63521ce6f0ac4a90b1a65abbeb0dcf2414fdb363..9f8ec24b576b20712c6447f3d5c04317c26f3d92 100644 --- a/src/plugins/coreplugin/coreimpl.cpp +++ b/src/plugins/coreplugin/coreimpl.cpp @@ -36,12 +36,21 @@ #include <QtCore/QDir> #include <QtCore/QCoreApplication> +namespace Core { +namespace Internal { + +// The Core Singleton +static CoreImpl *m_instance = 0; + +} // namespace Internal +} // namespace Core + + using namespace Core; using namespace Core::Internal; -CoreImpl *CoreImpl::m_instance = 0; -CoreImpl *CoreImpl::instance() +ICore* ICore::instance() { return m_instance; } diff --git a/src/plugins/coreplugin/coreimpl.h b/src/plugins/coreplugin/coreimpl.h index b09de4101f6a13262d7e0e0cc66e4ac08aee8889..a845a4b99056c679dd89e3e1faef964256acf55f 100644 --- a/src/plugins/coreplugin/coreimpl.h +++ b/src/plugins/coreplugin/coreimpl.h @@ -45,8 +45,6 @@ class CoreImpl : public ICore Q_OBJECT public: - static CoreImpl *instance(); - CoreImpl(MainWindow *mainwindow); ~CoreImpl() {} @@ -93,8 +91,6 @@ public: private: MainWindow *m_mainwindow; friend class MainWindow; - - static CoreImpl *m_instance; }; } // namespace Internal diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 4b18570037a82aec00ab52461f4ce885d970a18f..c6bc596b282d8e33e07c793d981c848477809bc2 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -39,7 +39,9 @@ #include "modemanager.h" #include "fileiconprovider.h" -#include <QtCore/qplugin.h> +#include <extensionsystem/pluginmanager.h> + +#include <QtCore/QtPlugin> #if !defined(QT_NO_WEBKIT) #include <QtGui/QApplication> #include <QtWebKit/QWebSettings> @@ -83,7 +85,7 @@ bool CorePlugin::initialize(const QStringList & /*arguments*/, QString *error_me m_welcomeMode = new WelcomeMode; addObject(m_welcomeMode); - EditorManager *editorManager = qobject_cast<EditorManager*>(m_mainWindow->editorManager()); + EditorManager *editorManager = m_mainWindow->editorManager(); m_editMode = new EditMode(editorManager); addObject(m_editMode); } diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp index 669ea09bf928639f4164f26584e064fd96d0b22b..7e48417d2ce0df5391e519e188ec8fbd8ef6ad31 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -32,7 +32,8 @@ ***************************************************************************/ #include "settingsdialog.h" -#include "coreimpl.h" + +#include <extensionsystem/pluginmanager.h> #include <QtGui/QHeaderView> #include <QtGui/QPushButton> @@ -58,7 +59,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory, QMap<QString, QTreeWidgetItem *> categories; QList<IOptionsPage*> pages = - CoreImpl::instance()->pluginManager()->getObjects<IOptionsPage>(); + ExtensionSystem::PluginManager::instance()->getObjects<IOptionsPage>(); int index = 0; foreach (IOptionsPage *page, pages) { diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp index 3d51e00b874ce2c6b0b02edde29a83b277e37377..b245d5ced5962ebf9d22578d9ea5d330fa6677ff 100644 --- a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp +++ b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp @@ -34,14 +34,13 @@ #include "shortcutsettings.h" #include "ui_shortcutsettings.h" #include "actionmanager_p.h" +#include "actionmanager/command.h" #include "command_p.h" -#include "coreconstants.h" -#include "coreimpl.h" #include "commandsfile.h" +#include "coreconstants.h" #include "filemanager.h" - -#include <coreplugin/uniqueidmanager.h> -#include <coreplugin/actionmanager/command.h> +#include "icore.h" +#include "uniqueidmanager.h" #include <QtGui/QKeyEvent> #include <QtGui/QShortcut> @@ -232,11 +231,10 @@ void ShortcutSettings::removeKeySequence() void ShortcutSettings::importAction() { - UniqueIDManager *uidm = - CoreImpl::instance()->uniqueIDManager(); + UniqueIDManager *uidm = UniqueIDManager::instance(); QString fileName = QFileDialog::getOpenFileName(0, tr("Import Keyboard Mapping Scheme"), - CoreImpl::instance()->resourcePath() + "/schemes/", + ICore::instance()->resourcePath() + "/schemes/", tr("Keyboard Mapping Scheme (*.kms)")); if (!fileName.isEmpty()) { CommandsFile cf(fileName); @@ -266,9 +264,9 @@ void ShortcutSettings::defaultAction() void ShortcutSettings::exportAction() { - QString fileName = CoreImpl::instance()->fileManager()->getSaveFileNameWithExtension( + QString fileName = ICore::instance()->fileManager()->getSaveFileNameWithExtension( tr("Export Keyboard Mapping Scheme"), - CoreImpl::instance()->resourcePath() + "/schemes/", + ICore::instance()->resourcePath() + "/schemes/", tr("Keyboard Mapping Scheme (*.kms)"), ".kms"); if (!fileName.isEmpty()) { @@ -279,16 +277,11 @@ void ShortcutSettings::exportAction() void ShortcutSettings::initialize() { - QMap<QString, QTreeWidgetItem *> categories; - m_am = ActionManagerPrivate::instance(); - UniqueIDManager *uidm = - CoreImpl::instance()->uniqueIDManager(); + UniqueIDManager *uidm = UniqueIDManager::instance(); - QList<CommandPrivate *> cmds = m_am->commands(); - for (int i = 0; i < cmds.size(); ++i) { - CommandPrivate *c = cmds.at(i); - if (c->hasAttribute(CommandPrivate::CA_NonConfigureable)) + foreach (Command *c, m_am->commands()) { + if (c->hasAttribute(Command::CA_NonConfigureable)) continue; if (c->action() && c->action()->isSeparator()) continue; @@ -296,24 +289,15 @@ void ShortcutSettings::initialize() QTreeWidgetItem *item = 0; ShortcutItem *s = new ShortcutItem; m_scitems << s; - if (c->category().isEmpty()) { - item = new QTreeWidgetItem(m_page->commandList); - } else { - if (!categories.contains(c->category())) { - QTreeWidgetItem *cat = new QTreeWidgetItem(m_page->commandList); - cat->setText(0, c->category()); - categories.insert(c->category(), cat); - cat->setExpanded(true); - } - item = new QTreeWidgetItem(categories.value(c->category())); - } + item = new QTreeWidgetItem(m_page->commandList); s->m_cmd = c; s->m_item = item; item->setText(0, uidm->stringForUniqueIdentifier(c->id())); if (c->action()) { - QString text = c->hasAttribute(CommandPrivate::CA_UpdateText) && !c->defaultText().isNull() ? c->defaultText() : c->action()->text(); + QString text = c->hasAttribute(Command::CA_UpdateText) && !c->defaultText().isNull() ? c->defaultText() : c->action()->text(); + text.remove(QRegExp("&(?!&)")); s->m_key = c->action()->shortcut(); item->setText(1, text); } else { diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.ui b/src/plugins/coreplugin/dialogs/shortcutsettings.ui index f1cc3f795a5e17d3e6a2fa89f8c75bf46a957166..867b021f94ea5e882d12e6034dfbe68e32ca122f 100644 --- a/src/plugins/coreplugin/dialogs/shortcutsettings.ui +++ b/src/plugins/coreplugin/dialogs/shortcutsettings.ui @@ -36,6 +36,9 @@ </item> <item> <widget class="QTreeWidget" name="commandList"> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> <property name="uniformRowHeights"> <bool>true</bool> </property> diff --git a/src/plugins/coreplugin/editmode.cpp b/src/plugins/coreplugin/editmode.cpp index dacb31e355c74fa66da52cdb6124d52fce8e9b66..e5de7124485d1be0ed65f464107256d0dc2aa3e5 100644 --- a/src/plugins/coreplugin/editmode.cpp +++ b/src/plugins/coreplugin/editmode.cpp @@ -34,7 +34,6 @@ #include "editmode.h" #include "editormanager.h" #include "coreconstants.h" -#include "coreimpl.h" #include "modemanager.h" #include "uniqueidmanager.h" #include "minisplitter.h" @@ -122,9 +121,9 @@ const char* EditMode::uniqueModeName() const QList<int> EditMode::context() const { static QList<int> contexts = QList<int>() << - CoreImpl::instance()->uniqueIDManager()->uniqueIdentifier(Constants::C_EDIT_MODE) << - CoreImpl::instance()->uniqueIDManager()->uniqueIdentifier(Constants::C_EDITORMANAGER) << - CoreImpl::instance()->uniqueIDManager()->uniqueIdentifier(Constants::C_NAVIGATION_PANE); + UniqueIDManager::instance()->uniqueIdentifier(Constants::C_EDIT_MODE) << + UniqueIDManager::instance()->uniqueIdentifier(Constants::C_EDITORMANAGER) << + UniqueIDManager::instance()->uniqueIdentifier(Constants::C_NAVIGATION_PANE); return contexts; } diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 8a135183579470d0b09f5a85c8c2535cd50e9954..77092e343eb577dabc6fc09226e3c45129980b92 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -32,19 +32,19 @@ ***************************************************************************/ #include "editormanager.h" +#include "editorgroup.h" #include "editorsplitter.h" +#include "openeditorsview.h" #include "openeditorswindow.h" #include "openwithdialog.h" #include "filemanager.h" -#include "tabpositionindicator.h" -#include "saveitemsdialog.h" -#include "vcsmanager.h" +#include "icore.h" #include "iversioncontrol.h" -#include "openeditorsview.h" -#include "editorgroup.h" #include "mimedatabase.h" +#include "saveitemsdialog.h" +#include "tabpositionindicator.h" +#include "vcsmanager.h" -#include <coreplugin/coreimpl.h> #include <coreplugin/coreconstants.h> #include <coreplugin/modemanager.h> #include <coreplugin/uniqueidmanager.h> @@ -53,6 +53,8 @@ #include <coreplugin/baseview.h> #include <coreplugin/imode.h> +#include <extensionsystem/pluginmanager.h> + #include <utils/qtcassert.h> #include <QtCore/QDebug> @@ -66,6 +68,7 @@ #include <QtGui/QApplication> #include <QtGui/QFileDialog> #include <QtGui/QLayout> +#include <QtGui/QMainWindow> #include <QtGui/QMenu> #include <QtGui/QMessageBox> #include <QtGui/QPushButton> @@ -76,6 +79,11 @@ using namespace Core::Internal; enum { debugEditorManager=0 }; +static inline ExtensionSystem::PluginManager *pluginManager() +{ + return ExtensionSystem::PluginManager::instance(); +} + //===================EditorManager===================== EditorManagerPlaceHolder *EditorManagerPlaceHolder::m_current = 0; @@ -194,6 +202,16 @@ EditorManagerPrivate::~EditorManagerPrivate() EditorManager *EditorManager::m_instance = 0; +static Command *createSeparator(ActionManager *am, QObject *parent, + const QString &name, + const QList<int> &context) +{ + QAction *tmpaction = new QAction(parent); + tmpaction->setSeparator(true); + Command *cmd = am->registerAction(tmpaction, name, context); + return cmd; +} + EditorManager::EditorManager(ICore *core, QWidget *parent) : QWidget(parent), m_d(new EditorManagerPrivate(core, parent)) @@ -317,12 +335,24 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) : ActionContainer *medit = am->actionContainer(Constants::M_EDIT); ActionContainer *advancedMenu = am->createMenu(Constants::M_EDIT_ADVANCED); - medit->addMenu(advancedMenu, Constants::G_EDIT_FORMAT); + medit->addMenu(advancedMenu, Constants::G_EDIT_ADVANCED); advancedMenu->menu()->setTitle(tr("&Advanced")); + advancedMenu->appendGroup(Constants::G_EDIT_FORMAT); + advancedMenu->appendGroup(Constants::G_EDIT_COLLAPSING); + advancedMenu->appendGroup(Constants::G_EDIT_FONT); + advancedMenu->appendGroup(Constants::G_EDIT_EDITOR); + + // Advanced menu separators + cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Collapsing"), editManagerContext); + advancedMenu->addAction(cmd, Constants::G_EDIT_COLLAPSING); + cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Font"), editManagerContext); + advancedMenu->addAction(cmd, Constants::G_EDIT_FONT); + cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Editor"), editManagerContext); + advancedMenu->addAction(cmd, Constants::G_EDIT_EDITOR); cmd = am->registerAction(m_d->m_openInExternalEditorAction, Constants::OPEN_IN_EXTERNAL_EDITOR, editManagerContext); cmd->setDefaultKeySequence(QKeySequence(tr("Alt+V,Alt+I"))); - advancedMenu->addAction(cmd); + advancedMenu->addAction(cmd, Constants::G_EDIT_EDITOR); connect(m_d->m_openInExternalEditorAction, SIGNAL(triggered()), this, SLOT(openInExternalEditor())); @@ -350,11 +380,12 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) : EditorManager::~EditorManager() { if (m_d->m_core) { + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); if (m_d->m_coreListener) { - m_d->m_core->pluginManager()->removeObject(m_d->m_coreListener); + pm->removeObject(m_d->m_coreListener); delete m_d->m_coreListener; } - m_d->m_core->pluginManager()->removeObject(m_d->m_openEditorsFactory); + pm->removeObject(m_d->m_openEditorsFactory); delete m_d->m_openEditorsFactory; } delete m_d; @@ -366,10 +397,11 @@ void EditorManager::init() context << m_d->m_core->uniqueIDManager()->uniqueIdentifier("QtCreator.OpenDocumentsView"); m_d->m_coreListener = new EditorClosingCoreListener(this); - m_d->m_core->pluginManager()->addObject(m_d->m_coreListener); + + pluginManager()->addObject(m_d->m_coreListener); m_d->m_openEditorsFactory = new OpenEditorsViewFactory(); - m_d->m_core->pluginManager()->addObject(m_d->m_openEditorsFactory); + pluginManager()->addObject(m_d->m_openEditorsFactory); } QSize EditorManager::minimumSizeHint() const @@ -567,8 +599,7 @@ QList<IEditor*> return found.toList(); } -QList<IFile *> - EditorManager::filesForEditors(QList<IEditor *> editors) const +QList<IFile *> EditorManager::filesForEditors(QList<IEditor *> editors) const { QSet<IEditor *> handledEditors; QList<IFile *> files; @@ -600,7 +631,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA QList<IEditor*> acceptedEditors; //ask all core listeners to check whether the editor can be closed const QList<ICoreListener *> listeners = - m_d->m_core->pluginManager()->getObjects<ICoreListener>(); + pluginManager()->getObjects<ICoreListener>(); foreach (IEditor *editor, editorsToClose) { bool editorAccepted = true; foreach (ICoreListener *listener, listeners) { @@ -618,7 +649,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA //ask whether to save modified files if (askAboutModifiedEditors) { bool cancelled = false; - QList<IFile*> list = CoreImpl::instance()->fileManager()-> + QList<IFile*> list = ICore::instance()->fileManager()-> saveModifiedFiles(filesForEditors(acceptedEditors), &cancelled); if (cancelled) return false; @@ -716,7 +747,7 @@ EditorManager::EditorFactoryList EditorManager::editorFactories(const MimeType &mimeType, bool bestMatchOnly) const { EditorFactoryList rc; - const EditorFactoryList allFactories = m_d->m_core->pluginManager()->getObjects<IEditorFactory>(); + const EditorFactoryList allFactories = pluginManager()->getObjects<IEditorFactory>(); mimeTypeFactoryRecursion(m_d->m_core->mimeDatabase(), mimeType, allFactories, bestMatchOnly, &rc); if (debugEditorManager) qDebug() << Q_FUNC_INFO << mimeType.type() << " returns " << rc; @@ -743,7 +774,7 @@ IEditor *EditorManager::createEditor(const QString &editorKind, factories = editorFactories(mimeType, true); } else { // Find by editor kind - const EditorFactoryList allFactories = m_d->m_core->pluginManager()->getObjects<IEditorFactory>(); + const EditorFactoryList allFactories = pluginManager()->getObjects<IEditorFactory>(); const EditorFactoryList::const_iterator acend = allFactories.constEnd(); for (EditorFactoryList::const_iterator ait = allFactories.constBegin(); ait != acend; ++ait) { if (editorKind == (*ait)->kind()) { @@ -893,9 +924,8 @@ QStringList EditorManager::getOpenFileNames() const void EditorManager::ensureEditorManagerVisible() { - if (!isVisible()) { + if (!isVisible()) m_d->m_core->modeManager()->activateMode(Constants::MODE_EDIT); - } } IEditor *EditorManager::newFile(const QString &editorKind, @@ -1518,7 +1548,7 @@ void EditorManager::openInExternalEditor() return; if (editor->file()->isModified()) { bool cancelled = false; - QList<IFile*> list = CoreImpl::instance()->fileManager()-> + QList<IFile*> list = ICore::instance()->fileManager()-> saveModifiedFiles(QList<IFile*>() << editor->file(), &cancelled); if (cancelled) return; diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index 63950714942614906292639f3cac9297ec00dc83..a7119c74547eb427c3da7b1797456593a1e69f51 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -34,7 +34,7 @@ #include "openeditorsview.h" #include "editorgroup.h" #include "editormanager.h" -#include "coreimpl.h" +#include "icore.h" #include <coreplugin/coreconstants.h> #include <coreplugin/filemanager.h> @@ -218,13 +218,12 @@ void OpenEditorsWidget::closeEditors() selectedEditors.append(item->data(0, Qt::UserRole).value<IEditor *>()); selectedFiles.append(item->data(0, Qt::UserRole).value<IEditor *>()->file()); } - ICore *core = CoreImpl::instance(); + ICore *core = ICore::instance(); bool cancelled = false; core->fileManager()->saveModifiedFiles(selectedFiles, &cancelled); if (cancelled) return; - core->editorManager()-> - closeEditors(selectedEditors); + core->editorManager()->closeEditors(selectedEditors); updateEditorList(); } diff --git a/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp b/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp index edceea70002712d342657739f987dd1bed05ea89..08e63b2773e0f7418e90208f451868539eb8fe4c 100644 --- a/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp +++ b/src/plugins/coreplugin/editormanager/stackededitorgroup.cpp @@ -33,7 +33,6 @@ #include "stackededitorgroup.h" #include "editormanager.h" -#include "coreimpl.h" #include <utils/qtcassert.h> @@ -79,6 +78,7 @@ StackedEditorGroup::StackedEditorGroup(QWidget *parent) : tl->setMargin(0); { m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_editorList->setSizeAdjustPolicy(QComboBox::AdjustToContents); m_editorList->setMinimumContentsLength(20); m_proxyModel.setSourceModel(model()); m_proxyModel.sort(0); @@ -296,9 +296,9 @@ void StackedEditorGroup::setCurrentEditor(IEditor *editor) void StackedEditorGroup::checkEditorStatus() { - IEditor *editor = qobject_cast<IEditor *>(sender()); - if (editor == currentEditor()) - updateEditorStatus(editor); + IEditor *editor = qobject_cast<IEditor *>(sender()); + if (editor == currentEditor()) + updateEditorStatus(editor); } void StackedEditorGroup::updateEditorStatus(IEditor *editor) @@ -354,7 +354,7 @@ QList<IEditor *> StackedEditorGroup::editorsInNaturalOrder() const void StackedEditorGroup::makeEditorWritable() { - CoreImpl::instance()->editorManager()->makeEditorWritable(currentEditor()); + EditorManager::instance()->makeEditorWritable(currentEditor()); } void StackedEditorGroup::listSelectionChanged(int index) diff --git a/src/plugins/coreplugin/filemanager.cpp b/src/plugins/coreplugin/filemanager.cpp index c4f515547a11bb6017068b3cdb9d7ab1b0401464..c503dbd7dd827d7a7b102bb1d3a6f70d673a5f37 100644 --- a/src/plugins/coreplugin/filemanager.cpp +++ b/src/plugins/coreplugin/filemanager.cpp @@ -85,18 +85,17 @@ using namespace Core::Internal; static const char *settingsGroup = "RecentFiles"; static const char *filesKey = "Files"; -FileManager::FileManager(Core::ICore *core, MainWindow *mw) : - QObject(mw), - m_core(core), +FileManager::FileManager(MainWindow *mw) + : QObject(mw), m_mainWindow(mw), m_fileWatcher(new QFileSystemWatcher(this)), m_blockActivated(false) { - connect(m_fileWatcher, SIGNAL(fileChanged(const QString&)), - this, SLOT(changedFile(const QString&))); + connect(m_fileWatcher, SIGNAL(fileChanged(QString)), + this, SLOT(changedFile(QString))); connect(m_mainWindow, SIGNAL(windowActivated()), this, SLOT(mainWindowActivated())); - connect(m_core, SIGNAL(contextChanged(Core::IContext*)), + connect(Core::ICore::instance(), SIGNAL(contextChanged(Core::IContext*)), this, SLOT(syncWithEditor(Core::IContext*))); QSettings *s = m_mainWindow->settings(); @@ -440,7 +439,7 @@ QString FileManager::getSaveAsFileName(IFile *file) } QString filterString; QString preferredSuffix; - if (const MimeType mt = m_core->mimeDatabase()->findByFile(fi)) { + if (const MimeType mt = Core::ICore::instance()->mimeDatabase()->findByFile(fi)) { filterString = mt.filterString(); preferredSuffix = mt.preferredSuffix(); } @@ -510,7 +509,7 @@ void FileManager::syncWithEditor(Core::IContext *context) if (!context) return; - Core::IEditor *editor = m_core->editorManager()->currentEditor(); + Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); if (editor && (editor->widget() == context->widget())) setCurrentFile(editor->file()->fileName()); } diff --git a/src/plugins/coreplugin/filemanager.h b/src/plugins/coreplugin/filemanager.h index bffbb088355ad422a79450f0b40f9e3b20733c6f..5b6b861b4a4eb6aa1f2764d4458cfa53995dfe1f 100644 --- a/src/plugins/coreplugin/filemanager.h +++ b/src/plugins/coreplugin/filemanager.h @@ -69,7 +69,7 @@ class CORE_EXPORT FileManager : public QObject }; public: - FileManager(Core::ICore *core, Internal::MainWindow *ew); + explicit FileManager(Internal::MainWindow *ew); // file pool to monitor bool addFiles(const QList<IFile *> &files); @@ -99,10 +99,9 @@ public: QString getSaveAsFileName(IFile *file); QList<IFile *> saveModifiedFilesSilently(const QList<IFile *> &files); - QList<IFile *> saveModifiedFiles( - const QList<IFile *> &files, - bool *cancelled = 0, - const QString &message = QString()); + QList<IFile *> saveModifiedFiles(const QList<IFile *> &files, + bool *cancelled = 0, + const QString &message = QString()); signals: void currentFileChanged(const QString &filePath); @@ -130,7 +129,6 @@ private: QString m_currentFile; - Core::ICore *m_core; Internal::MainWindow *m_mainWindow; QFileSystemWatcher *m_fileWatcher; QList<QPointer<IFile> > m_changedFiles; diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 5d6d32741778dee6d1a526db4e83f4bb75be5552..5654c885758b8430dc34e4ccecc44428f1708cd0 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -51,10 +51,7 @@ You should never create a subclass of this interface. The one and only instance is created by the Core plugin. You can access this instance - from your plugin via the plugin manager, e.g. - \code - ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - \endcode + from your plugin through \c{Core::instance()}. \mainclass */ diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h index 7244782b495a3b613494628bdd22e7f28a0ccb9c..565b8589345643bd1bb8a6d08d5d7bec10bed47d 100644 --- a/src/plugins/coreplugin/icore.h +++ b/src/plugins/coreplugin/icore.h @@ -35,36 +35,30 @@ #define ICORE_H #include "core_global.h" -#include <extensionsystem/pluginmanager.h> #include <QtCore/QObject> -#include <QtCore/QList> QT_BEGIN_NAMESPACE -class QSettings; -class QStatusBar; -class QFocusEvent; class QMainWindow; class QPrinter; +class QSettings; +template <class T> class QList; QT_END_NAMESPACE namespace Core { -// forward declarations class ActionManager; -class IFile; +class EditorManager; class FileManager; +class IContext; +class IWizard; class MessageManager; -class IEditor; -class UniqueIDManager; -class EditorManager; +class MimeDatabase; +class ModeManager; class ProgressManager; class ScriptManager; +class UniqueIDManager; class VariableManager; -class IContext; class VCSManager; -class ModeManager; -class IWizard; -class MimeDatabase; class CORE_EXPORT ICore : public QObject { @@ -74,6 +68,8 @@ public: ICore() {} virtual ~ICore() {} + static ICore *instance(); + virtual QStringList showNewItemDialog(const QString &title, const QList<IWizard *> &wizards, const QString &defaultLocation = QString()) = 0; @@ -85,7 +81,6 @@ public: virtual FileManager *fileManager() const = 0; virtual UniqueIDManager *uniqueIDManager() const = 0; virtual MessageManager *messageManager() const = 0; - virtual ExtensionSystem::PluginManager *pluginManager() const = 0; virtual EditorManager *editorManager() const = 0; virtual ProgressManager *progressManager() const = 0; virtual ScriptManager *scriptManager() const = 0; diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 9dc93c0133d60349871c4a7ef28fae90786aacb7..93e2cb0b991679502e69f6ff856451d6b7b4fd8e 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -70,22 +70,23 @@ #include "basefilewizard.h" #include <coreplugin/findplaceholder.h> +#include <extensionsystem/pluginmanager.h> -#include <QtCore/qplugin.h> #include <QtCore/QDebug> +#include <QtCore/QFileInfo> #include <QtCore/QSettings> #include <QtCore/QTimer> -#include <QtCore/QFileInfo> +#include <QtCore/QtPlugin> -#include <QtGui/QMenu> -#include <QtGui/QToolBar> #include <QtGui/QApplication> -#include <QtGui/QPixmap> #include <QtGui/QCloseEvent> -#include <QtGui/QShortcut> +#include <QtGui/QMenu> +#include <QtGui/QPixmap> #include <QtGui/QPrinter> -#include <QtGui/QWizard> +#include <QtGui/QShortcut> #include <QtGui/QStatusBar> +#include <QtGui/QToolBar> +#include <QtGui/QWizard> /* #ifdef Q_OS_UNIX @@ -93,7 +94,7 @@ extern "C" void handleSigInt(int sig) { Q_UNUSED(sig); - Core::Internal::CoreImpl::instance()->exit(); + Core::ICore::instance()->exit(); qDebug() << "SIGINT caught. Shutting down."; } #endif @@ -117,7 +118,7 @@ MainWindow::MainWindow() : m_printer(0), m_actionManager(new ActionManagerPrivate(this, m_uniqueIDManager)), m_editorManager(0), - m_fileManager(new FileManager(m_coreImpl, this)), + m_fileManager(new FileManager(this)), m_progressManager(new ProgressManagerPrivate()), m_scriptManager(new ScriptManagerPrivate(this, m_coreImpl)), m_variableManager(new VariableManager(this)), @@ -142,6 +143,7 @@ MainWindow::MainWindow() : m_exitAction(0), m_optionsAction(0), m_toggleSideBarAction(0), + m_toggleFullScreenAction(0), #ifdef Q_OS_MAC m_minimizeAction(0), m_zoomAction(0), @@ -201,23 +203,22 @@ MainWindow::MainWindow() : statusBar()->setProperty("p_styled", true); } -void MainWindow::toggleNavigation() +void MainWindow::setSidebarVisible(bool visible) { if (NavigationWidgetPlaceHolder::current()) { - if (m_navigationWidget->isSuppressed()) { + if (m_navigationWidget->isSuppressed() && visible) { m_navigationWidget->setShown(true); m_navigationWidget->setSuppressed(false); } else { - m_navigationWidget->setShown(!m_navigationWidget->isShown()); + m_navigationWidget->setShown(visible); } } } void MainWindow::setSuppressNavigationWidget(bool suppress) { - if (NavigationWidgetPlaceHolder::current()) { + if (NavigationWidgetPlaceHolder::current()) m_navigationWidget->setSuppressed(suppress); - } } MainWindow::~MainWindow() @@ -317,7 +318,7 @@ void MainWindow::extensionsInitialized() m_viewManager->extensionsInitalized(); m_messageManager->init(m_pluginManager); - m_outputPane->init(m_coreImpl, m_pluginManager); + m_outputPane->init(m_pluginManager); m_actionManager->initialize(); readSettings(); @@ -400,7 +401,7 @@ void MainWindow::registerDefaultContainers() medit->appendGroup(Constants::G_EDIT_UNDOREDO); medit->appendGroup(Constants::G_EDIT_COPYPASTE); medit->appendGroup(Constants::G_EDIT_SELECTALL); - medit->appendGroup(Constants::G_EDIT_FORMAT); + medit->appendGroup(Constants::G_EDIT_ADVANCED); medit->appendGroup(Constants::G_EDIT_FIND); medit->appendGroup(Constants::G_EDIT_OTHER); @@ -430,9 +431,9 @@ void MainWindow::registerDefaultContainers() ac->appendGroup(Constants::G_HELP_ABOUT); } -static Command *createSeparator(ActionManagerPrivate *am, QObject *parent, - const QString &name, - const QList<int> &context) +static Command *createSeparator(ActionManager *am, QObject *parent, + const QString &name, + const QList<int> &context) { QAction *tmpaction = new QAction(parent); tmpaction->setSeparator(true); @@ -447,7 +448,6 @@ void MainWindow::registerDefaultActions() ActionContainer *medit = am->actionContainer(Constants::M_EDIT); ActionContainer *mtools = am->actionContainer(Constants::M_TOOLS); ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW); - Q_UNUSED(mwindow) ActionContainer *mhelp = am->actionContainer(Constants::M_HELP); // File menu separators @@ -464,7 +464,7 @@ void MainWindow::registerDefaultActions() mfile->addAction(cmd, Constants::G_FILE_OTHER); // Edit menu separators - cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.CopyPaste"), m_globalContext); + cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.CopyPaste"), m_globalContext); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.SelectAll"), m_globalContext); @@ -473,8 +473,8 @@ void MainWindow::registerDefaultActions() cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Find"), m_globalContext); medit->addAction(cmd, Constants::G_EDIT_FIND); - cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Format"), m_globalContext); - medit->addAction(cmd, Constants::G_EDIT_FORMAT); + cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Advanced"), m_globalContext); + medit->addAction(cmd, Constants::G_EDIT_ADVANCED); //Tools menu separators cmd = createSeparator(am, this, QLatin1String("QtCreator.Tools.Sep.Options"), m_globalContext); @@ -627,7 +627,7 @@ void MainWindow::registerDefaultActions() // Toggle Sidebar Action m_toggleSideBarAction = new QAction(QIcon(Constants::ICON_TOGGLE_SIDEBAR), - tr("Toggle Sidebar"), this); + tr("Show Sidebar"), this); m_toggleSideBarAction->setCheckable(true); cmd = am->registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR, m_globalContext); #ifdef Q_OS_MAC @@ -635,11 +635,24 @@ void MainWindow::registerDefaultActions() #else cmd->setDefaultKeySequence(QKeySequence("Alt+0")); #endif - connect(m_toggleSideBarAction, SIGNAL(triggered()), this, SLOT(toggleNavigation())); + connect(m_toggleSideBarAction, SIGNAL(triggered(bool)), this, SLOT(setSidebarVisible(bool))); m_toggleSideBarButton->setDefaultAction(cmd->action()); mwindow->addAction(cmd, Constants::G_WINDOW_PANES); m_toggleSideBarAction->setEnabled(false); +#if !defined(Q_OS_MAC) + // Toggle Full Screen + m_toggleFullScreenAction = new QAction(tr("Toggle Fullscreen"), this); + m_toggleFullScreenAction->setCheckable(true); + m_toggleFullScreenAction->setChecked(false); + cmd = am->registerAction(m_toggleFullScreenAction, + Constants::TOGGLE_FULLSCREEN, m_globalContext); + cmd->setDefaultKeySequence(QKeySequence("Ctrl+Shift+F11")); + mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); + connect(m_toggleFullScreenAction, SIGNAL(triggered(bool)), + this, SLOT(setFullScreen(bool))); +#endif + //About IDE Action #ifdef Q_OS_MAC tmpaction = new QAction(tr("About &Qt Creator"), this); // it's convention not to add dots to the about menu @@ -684,8 +697,8 @@ void MainWindow::openFile() static QList<IFileFactory*> getNonEditorFileFactories() { - const ICore *core = CoreImpl::instance(); - const QList<IFileFactory*> allFileFactories = core->pluginManager()->getObjects<IFileFactory>(); + const QList<IFileFactory*> allFileFactories = + ExtensionSystem::PluginManager::instance()->getObjects<IFileFactory>(); QList<IFileFactory*> nonEditorFileFactories; foreach (IFileFactory *factory, allFileFactories) { if (!qobject_cast<IEditorFactory *>(factory)) @@ -916,13 +929,18 @@ void MainWindow::changeEvent(QEvent *e) qDebug() << "main window activated"; emit windowActivated(); } -#ifdef Q_OS_MAC } else if (e->type() == QEvent::WindowStateChange) { +#ifdef Q_OS_MAC bool minimized = isMinimized(); if (debugMainWindow) qDebug() << "main window state changed to minimized=" << minimized; m_minimizeAction->setEnabled(!minimized); m_zoomAction->setEnabled(!minimized); +#else + QWindowStateChangeEvent *ev = + static_cast<QWindowStateChangeEvent *>(e); + bool isFullScreen = (ev->oldState() & Qt::WindowFullScreen) != 0; + m_toggleFullScreenAction->setChecked(!isFullScreen); #endif } } @@ -1112,3 +1130,19 @@ QPrinter *MainWindow::printer() const m_printer = new QPrinter(QPrinter::HighResolution); return m_printer; } + +void MainWindow::setFullScreen(bool on) +{ + if (bool(windowState() & Qt::WindowFullScreen) == on) + return; + + if (on) { + setWindowState(windowState() | Qt::WindowFullScreen); + //statusBar()->hide(); + //menuBar()->hide(); + } else { + setWindowState(windowState() & ~Qt::WindowFullScreen); + //menuBar()->show(); + //statusBar()->show(); + } +} diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h index 4a1c08f16efb5ffa31a85df67bd335e070fd49ac..e1fb1d9c6626aeb7466c66ce919881fe4c10965e 100644 --- a/src/plugins/coreplugin/mainwindow.h +++ b/src/plugins/coreplugin/mainwindow.h @@ -137,6 +137,7 @@ public slots: void newFile(); void openFileWith(); void exit(); + void setFullScreen(bool on); QStringList showNewItemDialog(const QString &title, const QList<IWizard *> &wizards, @@ -157,7 +158,7 @@ private slots: void aboutQtCreator(); void aboutPlugins(); void updateFocusWidget(QWidget *old, QWidget *now); - void toggleNavigation(); + void setSidebarVisible(bool visible); void destroyVersionDialog(); private: @@ -213,6 +214,7 @@ private: QAction *m_exitAction; QAction *m_optionsAction; QAction *m_toggleSideBarAction; + QAction *m_toggleFullScreenAction; #ifdef Q_OS_MAC QAction *m_minimizeAction; QAction *m_zoomAction; diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp index 579881a215d885d8bacc5875749dee73b55a692c..64006ff723609143d507643a2c9a7ba01c965ac4 100644 --- a/src/plugins/coreplugin/modemanager.cpp +++ b/src/plugins/coreplugin/modemanager.cpp @@ -42,10 +42,11 @@ #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/command.h> #include <coreplugin/coreconstants.h> -#include <coreplugin/coreimpl.h> #include <coreplugin/imode.h> #include <coreplugin/uniqueidmanager.h> +#include <extensionsystem/pluginmanager.h> + #include <utils/qtcassert.h> #include <QtCore/QObject> @@ -215,7 +216,7 @@ void ModeManager::currentTabChanged(int index) // FIXME: This hardcoded context update is required for the Debug and Edit modes, since // they use the editor widget, which is already a context widget so the main window won't // go further up the parent tree to find the mode context. - CoreImpl *core = CoreImpl::instance(); + ICore *core = ICore::instance(); foreach (const int context, m_addedContexts) core->removeAdditionalContext(context); diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 41b5116ba54e60a369b7d725288bf27c829481f6..1141909aa0cf611cd26a3c32fb16f3874955d7e0 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -39,14 +39,16 @@ #include <coreplugin/modemanager.h> #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> +#include <extensionsystem/pluginmanager.h> + +#include <QtCore/QDebug> +#include <QtCore/QSettings> #include <QtGui/QAction> #include <QtGui/QHBoxLayout> -#include <QtGui/QToolButton> -#include <QtGui/QToolBar> #include <QtGui/QResizeEvent> -#include <QtCore/QDebug> -#include <QtCore/QSettings> +#include <QtGui/QToolBar> +#include <QtGui/QToolButton> Q_DECLARE_METATYPE(Core::INavigationWidgetFactory *) @@ -314,8 +316,8 @@ void NavigationWidget::objectAdded(QObject * obj) if (!factory) return; - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - Core::ActionManager *am = core->actionManager(); + ICore *core = ICore::instance(); + ActionManager *am = core->actionManager(); QList<int> navicontext = QList<int>() << core->uniqueIDManager()-> uniqueIdentifier(Core::Constants::C_NAVIGATION_PANE); @@ -397,9 +399,8 @@ NavigationSubWidget::~NavigationSubWidget() void NavigationSubWidget::setCurrentIndex(int index) { // Remove toolbutton - foreach (QWidget *w, m_additionalToolBarWidgets) { + foreach (QWidget *w, m_additionalToolBarWidgets) delete w; - } // Remove old Widget delete m_navigationWidget; @@ -464,8 +465,7 @@ void NavigationSubWidget::setFactory(INavigationWidgetFactory *factory) void NavigationSubWidget::setFactory(const QString &name) { - for (int i = 0; i < m_navigationComboBox->count(); ++i) - { + for (int i = 0; i < m_navigationComboBox->count(); ++i) { INavigationWidgetFactory *factory = m_navigationComboBox->itemData(i).value<INavigationWidgetFactory *>(); if (factory->displayName() == name) diff --git a/src/plugins/coreplugin/outputpane.cpp b/src/plugins/coreplugin/outputpane.cpp index 36fc9de9cf8b846f7ef31a5436c91a374153c110..d85ecd2579db29046ca7fb32472491527f7e280a 100644 --- a/src/plugins/coreplugin/outputpane.cpp +++ b/src/plugins/coreplugin/outputpane.cpp @@ -42,12 +42,13 @@ #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editorgroup.h> +#include <extensionsystem/pluginmanager.h> + #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QComboBox> #include <QtGui/QFocusEvent> #include <QtGui/QHBoxLayout> -#include <QtGui/QLineEdit> #include <QtGui/QMenu> #include <QtGui/QPainter> #include <QtGui/QPushButton> @@ -155,7 +156,6 @@ OutputPane::OutputPane(const QList<int> &context, QWidget *parent) : m_closeButton(new QToolButton), m_closeAction(0), m_pluginManager(0), - m_core(0), m_lastIndex(-1), m_outputWidgetPane(new QStackedWidget), m_opToolBarWidgets(new QStackedWidget) @@ -205,12 +205,11 @@ QWidget *OutputPane::buttonsWidget() return m_buttonsWidget; } -void OutputPane::init(ICore *core, ExtensionSystem::PluginManager *pm) +void OutputPane::init(ExtensionSystem::PluginManager *pm) { m_pluginManager = pm; - m_core = core; - ActionManager *am = m_core->actionManager(); + ActionManager *am = Core::ICore::instance()->actionManager(); ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW); // Window->Output Panes @@ -394,8 +393,7 @@ void OutputPane::showPage(int idx, bool focus) if (!OutputPanePlaceHolder::m_current) { // In this mode we don't have a placeholder // switch to the output mode and switch the page - ICore *core = m_pluginManager->getObject<ICore>(); - core->modeManager()->activateMode(Constants::MODE_OUTPUT); + ICore::instance()->modeManager()->activateMode(Constants::MODE_OUTPUT); ensurePageVisible(idx); } else { // else we make that page visible @@ -410,14 +408,13 @@ void OutputPane::showPage(int idx, bool focus) void OutputPane::togglePage(bool focus) { int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender())); - if(OutputPanePlaceHolder::m_current + if (OutputPanePlaceHolder::m_current && OutputPanePlaceHolder::m_current->isVisible() && m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx) { slotHide(); } else { showPage(idx, focus); } - } void OutputPane::setCloseable(bool b) diff --git a/src/plugins/coreplugin/outputpane.h b/src/plugins/coreplugin/outputpane.h index 5a7c928a5467e56c6d249308c32c818d68adccc4..8505b34bfa8981b6f22e74fa1ad2c2a282ec8cf3 100644 --- a/src/plugins/coreplugin/outputpane.h +++ b/src/plugins/coreplugin/outputpane.h @@ -51,7 +51,6 @@ namespace ExtensionSystem { class PluginManager; } namespace Core { -class ICore; class IMode; class IOutputPane; @@ -89,7 +88,7 @@ class OutputPane public: OutputPane(const QList<int> &context, QWidget *parent = 0); ~OutputPane(); - void init(Core::ICore *core, ExtensionSystem::PluginManager *pm); + void init(ExtensionSystem::PluginManager *pm); static OutputPane *instance(); const QList<int> &context() const { return m_context; } void setCloseable(bool b); @@ -123,7 +122,6 @@ private: QAction *m_closeAction; ExtensionSystem::PluginManager *m_pluginManager; - Core::ICore *m_core; QMap<int, Core::IOutputPane*> m_pageMap; int m_lastIndex; diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp index 968d2bb9fc8774a230fcd5fad33ac34b6f271494..392e8aafa8d951ac5d011d66953a2440808ce7d4 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp @@ -33,10 +33,9 @@ #include "progressmanager_p.h" #include "progressview.h" -#include "coreimpl.h" #include "baseview.h" - #include "coreconstants.h" +#include "icore.h" #include "uniqueidmanager.h" #include <utils/qtcassert.h> @@ -48,7 +47,7 @@ ProgressManagerPrivate::ProgressManagerPrivate(QObject *parent) : ProgressManager(parent) { m_progressView = new ProgressView; - ICore *core = CoreImpl::instance(); + ICore *core = ICore::instance(); connect(core, SIGNAL(coreAboutToClose()), this, SLOT(cancelAllRunningTasks())); } diff --git a/src/plugins/coreplugin/uniqueidmanager.h b/src/plugins/coreplugin/uniqueidmanager.h index 0a8ed6fcd07febed01adae9713d18773e45fea48..eff119762d749b6f4c1ef0be6390deb126f0c7f4 100644 --- a/src/plugins/coreplugin/uniqueidmanager.h +++ b/src/plugins/coreplugin/uniqueidmanager.h @@ -47,7 +47,7 @@ public: UniqueIDManager(); ~UniqueIDManager(); - static UniqueIDManager* instance() { return m_instance; } + static UniqueIDManager *instance() { return m_instance; } bool hasUniqueIdentifier(const QString &id) const; int uniqueIdentifier(const QString &id); diff --git a/src/plugins/coreplugin/versiondialog.cpp b/src/plugins/coreplugin/versiondialog.cpp index a61e29e50d7c193bbc2e922e2aaec0e06b1ad084..5ce821a8147573bfd728231a17c596fe773f7617 100644 --- a/src/plugins/coreplugin/versiondialog.cpp +++ b/src/plugins/coreplugin/versiondialog.cpp @@ -34,7 +34,7 @@ #include "versiondialog.h" #include "coreconstants.h" -#include "coreimpl.h" +#include "icore.h" #include <utils/qtcassert.h> @@ -121,7 +121,7 @@ void VersionDialog::popupLicense() layout->addWidget(buttonBox); // Read file into string - ICore * core = CoreImpl::instance(); + ICore *core = ICore::instance(); QTC_ASSERT(core, return); QString fileName = core->resourcePath() + "/license.txt"; QFile file(fileName); diff --git a/src/plugins/coreplugin/viewmanager.cpp b/src/plugins/coreplugin/viewmanager.cpp index a7a2bf9a45ec0f7e0beb5335f9160632c82610d6..052e2dee522c3ad59d04b1d661d7df75dbf14042 100644 --- a/src/plugins/coreplugin/viewmanager.cpp +++ b/src/plugins/coreplugin/viewmanager.cpp @@ -41,19 +41,12 @@ #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/command.h> #include <aggregation/aggregate.h> +#include <extensionsystem/pluginmanager.h> #include <QtCore/QSettings> -#include <QtGui/QAction> -#include <QtGui/QActionGroup> -#include <QtGui/QComboBox> -#include <QtGui/QDockWidget> #include <QtGui/QHBoxLayout> #include <QtGui/QLabel> -#include <QtGui/QMenu> -#include <QtGui/QStackedWidget> #include <QtGui/QStatusBar> -#include <QtGui/QToolButton> -#include <QtGui/QVBoxLayout> using namespace Core; using namespace Core::Internal; diff --git a/src/plugins/coreplugin/welcomemode.cpp b/src/plugins/coreplugin/welcomemode.cpp index ee66ac7f33c2add780914a40d774df0d1f2ee1da..7cd17e3ddcd627a3c1d150e588890f0a343e0ecb 100644 --- a/src/plugins/coreplugin/welcomemode.cpp +++ b/src/plugins/coreplugin/welcomemode.cpp @@ -34,7 +34,6 @@ #include "welcomemode.h" #include "coreconstants.h" #include "uniqueidmanager.h" -#include "coreimpl.h" #include "modemanager.h" #if !defined(QT_NO_WEBKIT) @@ -193,7 +192,7 @@ const char* WelcomeMode::uniqueModeName() const QList<int> WelcomeMode::context() const { static QList<int> contexts = QList<int>() - << CoreImpl::instance()->uniqueIDManager()->uniqueIdentifier(Constants::C_WELCOME_MODE); + << UniqueIDManager::instance()->uniqueIdentifier(Constants::C_WELCOME_MODE); return contexts; } @@ -250,7 +249,7 @@ void WelcomeMode::updateWelcomePage(const WelcomePageData &welcomePageData) void WelcomeMode::linkClicked(const QUrl &url) { QString scheme = url.scheme(); - Core::ModeManager *modeManager = CoreImpl::instance()->modeManager(); + Core::ModeManager *modeManager = ModeManager::instance(); if (scheme.startsWith(QLatin1String("gh"))) { QString s = url.toString(QUrl::RemoveScheme); if (scheme == QLatin1String("gh")) { diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 1ab4daa0a4a9f3b8602aa7ddf8be9aaa5cfcecce..4558ccaae88e3ed544085ffdc24bec71574ac873 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -38,17 +38,18 @@ #include "splitter.h" #include "view.h" -#include <coreplugin/icore.h> +#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/coreconstants.h> +#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/filemanager.h> +#include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> +#include <coreplugin/messageoutputwindow.h> #include <coreplugin/uniqueidmanager.h> -#include <coreplugin/actionmanager/actionmanager.h> -#include <coreplugin/editormanager/editormanager.h> +#include <extensionsystem/pluginmanager.h> #include <texteditor/itexteditor.h> -#include <coreplugin/messageoutputwindow.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QDebug> #include <QtGui/QAction> #include <QtGui/QApplication> @@ -62,8 +63,6 @@ using namespace CodePaster; using namespace Core; using namespace TextEditor; -Core::ICore *gCoreInstance = NULL; - CodepasterPlugin::CodepasterPlugin() : m_settingsPage(0), m_fetcher(0), m_poster(0) { @@ -83,19 +82,16 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_m Q_UNUSED(arguments); Q_UNUSED(error_message); - gCoreInstance = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - // Create the globalcontext list to register actions accordingly QList<int> globalcontext; - globalcontext << gCoreInstance->uniqueIDManager()-> - uniqueIdentifier(Core::Constants::C_GLOBAL); + globalcontext << UniqueIDManager::instance()->uniqueIdentifier(Core::Constants::C_GLOBAL); // Create the settings Page m_settingsPage = new SettingsPage(); addObject(m_settingsPage); //register actions - Core::ActionManager *actionManager = gCoreInstance->actionManager(); + Core::ActionManager *actionManager = ICore::instance()->actionManager(); Core::ActionContainer *toolsContainer = actionManager->actionContainer(Core::Constants::M_TOOLS); @@ -132,7 +128,7 @@ void CodepasterPlugin::post() { if (m_poster) delete m_poster; - IEditor* editor = gCoreInstance->editorManager()->currentEditor(); + IEditor* editor = EditorManager::instance()->currentEditor(); ITextEditor* textEditor = qobject_cast<ITextEditor*>(editor); if (!textEditor) return; @@ -243,8 +239,7 @@ void CustomFetcher::customRequestFinished(int, bool error) QByteArray data = body(); if (!m_listWidget) { QString title = QString::fromLatin1("Code Paster: %1").arg(m_id); - gCoreInstance->editorManager()->newFile(Core::Constants::K_DEFAULT_TEXT_EDITOR - , &title, data); + EditorManager::instance()->newFile(Core::Constants::K_DEFAULT_TEXT_EDITOR, &title, data); } else { m_listWidget->clear(); QStringList lines = QString(data).split(QLatin1Char('\n')); @@ -283,7 +278,7 @@ void CustomPoster::customRequestFinished(int, bool error) if (!error) { if (m_copy) QApplication::clipboard()->setText(pastedUrl()); - gCoreInstance->messageManager()->printToOutputPane(pastedUrl(), m_output); + ICore::instance()->messageManager()->printToOutputPane(pastedUrl(), m_output); } else QMessageBox::warning(0, "Code Paster Error", "Some error occured while posting", QMessageBox::Ok); #if 0 // Figure out how to access diff --git a/src/plugins/cpaster/settingspage.cpp b/src/plugins/cpaster/settingspage.cpp index 333630636178df33155ff3acdab70eb3b7cb0fb7..1907d6eebea6ea9d7cde7b11e708ef8e3d2e0d4f 100644 --- a/src/plugins/cpaster/settingspage.cpp +++ b/src/plugins/cpaster/settingspage.cpp @@ -34,7 +34,6 @@ #include "settingspage.h" #include <coreplugin/icore.h> -#include <extensionsystem/pluginmanager.h> #include <QtCore/QSettings> #include <QtGui/QLineEdit> @@ -46,10 +45,7 @@ using namespace CodePaster; SettingsPage::SettingsPage() { - Core::ICore *coreIFace = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - if (coreIFace) - m_settings = coreIFace->settings(); - + m_settings = Core::ICore::instance()->settings(); if (m_settings) { m_settings->beginGroup("CodePaster"); m_username = m_settings->value("UserName", qgetenv("USER")).toString(); diff --git a/src/plugins/cppeditor/cppclasswizard.cpp b/src/plugins/cppeditor/cppclasswizard.cpp index ecdcc110197a22d4a02ba8eff9da4bf7b3d1bbcb..99db1ca123ad65aa4816fcd46ed77d8f97f182a6 100644 --- a/src/plugins/cppeditor/cppclasswizard.cpp +++ b/src/plugins/cppeditor/cppclasswizard.cpp @@ -42,9 +42,6 @@ #include <QtCore/QDir> #include <QtCore/QTextStream> -#include <QtGui/QCheckBox> -#include <QtGui/QComboBox> -#include <QtGui/QLabel> #include <QtGui/QVBoxLayout> #include <QtGui/QWizard> @@ -124,8 +121,8 @@ CppClassWizardParameters CppClassWizardDialog::parameters() const // ========= CppClassWizard ========= CppClassWizard::CppClassWizard(const Core::BaseFileWizardParameters ¶meters, - Core::ICore *core, QObject *parent) : - Core::BaseFileWizard(parameters, core, parent) + QObject *parent) + : Core::BaseFileWizard(parameters, parent) { } diff --git a/src/plugins/cppeditor/cppclasswizard.h b/src/plugins/cppeditor/cppclasswizard.h index b117dc7ad09ee2717f15cf2c89b8fed18e3dd257..987b6232d4386460c2266e6ccc776239636feb55 100644 --- a/src/plugins/cppeditor/cppclasswizard.h +++ b/src/plugins/cppeditor/cppclasswizard.h @@ -40,16 +40,13 @@ #include <QtGui/QWizardPage> #include <QtGui/QWizard> -QT_BEGIN_NAMESPACE -class QCheckBox; -class QComboBox; -QT_END_NAMESPACE - namespace Core { namespace Utils { - class NewClassWidget; -} -} + +class NewClassWidget; + +} // namespace Utils +} // namespace Core namespace CppEditor { namespace Internal { @@ -75,7 +72,8 @@ private: }; -struct CppClassWizardParameters { +struct CppClassWizardParameters +{ QString className; QString headerFile; QString sourceFile; @@ -83,9 +81,10 @@ struct CppClassWizardParameters { QString path; }; -class CppClassWizardDialog : public QWizard { - Q_DISABLE_COPY(CppClassWizardDialog) +class CppClassWizardDialog : public QWizard +{ Q_OBJECT + Q_DISABLE_COPY(CppClassWizardDialog) public: explicit CppClassWizardDialog(const QString &sourceSuffix, const QString &headerSuffix, @@ -104,7 +103,7 @@ class CppClassWizard : public Core::BaseFileWizard Q_OBJECT public: explicit CppClassWizard(const Core::BaseFileWizardParameters ¶meters, - Core::ICore *core, QObject *parent = 0); + QObject *parent = 0); protected: virtual QWizard *createWizardDialog(QWidget *parent, diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index c8e9a946b9095fd38ba564124df23ac85a21d5b7..87d229d6f4e57f58a6c350bef2b4240c1cd629a2 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -58,6 +58,7 @@ #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/editormanager.h> +#include <extensionsystem/pluginmanager.h> #include <projectexplorer/projectexplorerconstants.h> #include <texteditor/basetextdocument.h> #include <texteditor/fontsettings.h> @@ -65,21 +66,17 @@ #include <texteditor/textblockiterator.h> #include <indenter.h> -#include <QtCore/QFileInfo> -#include <QtCore/QTextStream> #include <QtCore/QDebug> #include <QtCore/QTime> #include <QtCore/QTimer> #include <QtGui/QAction> -#include <QtGui/QKeyEvent> +#include <QtGui/QHeaderView> #include <QtGui/QLayout> #include <QtGui/QMenu> #include <QtGui/QShortcut> #include <QtGui/QTextEdit> #include <QtGui/QComboBox> #include <QtGui/QTreeView> -#include <QtGui/QHeaderView> -#include <QtGui/QStringListModel> using namespace CPlusPlus; using namespace CppEditor::Internal; @@ -142,15 +139,14 @@ QualifiedNameId *qualifiedNameIdForSymbol(Symbol *s, const LookupContext &contex CPPEditorEditable::CPPEditorEditable(CPPEditor *editor) : BaseTextEditorEditable(editor) { - Core::ICore *core = CppPlugin::core(); - m_context << core->uniqueIDManager()->uniqueIdentifier(CppEditor::Constants::C_CPPEDITOR); - m_context << core->uniqueIDManager()->uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX); - m_context << core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); + Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); + m_context << uidm->uniqueIdentifier(CppEditor::Constants::C_CPPEDITOR); + m_context << uidm->uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX); + m_context << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); } -CPPEditor::CPPEditor(QWidget *parent) : - TextEditor::BaseTextEditor(parent), - m_core(CppPlugin::core()) +CPPEditor::CPPEditor(QWidget *parent) + : TextEditor::BaseTextEditor(parent) { setParenthesesMatchingEnabled(true); setMarksVisible(true); @@ -172,7 +168,8 @@ CPPEditor::CPPEditor(QWidget *parent) : /*ambiguousMember=*/ 0, Qt::WidgetShortcut); #endif - m_modelManager = m_core->pluginManager()->getObject<CppTools::CppModelManagerInterface>(); + m_modelManager = ExtensionSystem::PluginManager::instance() + ->getObject<CppTools::CppModelManagerInterface>(); if (m_modelManager) { connect(m_modelManager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)), @@ -337,10 +334,10 @@ void CPPEditor::jumpToMethod(int) if (! symbol) return; - m_core->editorManager()->addCurrentPositionToNavigationHistory(true); + Core::EditorManager::instance()->addCurrentPositionToNavigationHistory(true); int line = symbol->line(); gotoLine(line); - m_core->editorManager()->addCurrentPositionToNavigationHistory(); + Core::EditorManager::instance()->addCurrentPositionToNavigationHistory(); setFocus(); } @@ -658,7 +655,7 @@ void CPPEditor::contextMenuEvent(QContextMenuEvent *e) menu->removeAction(lastAction); Core::ActionContainer *mcontext = - m_core->actionManager()->actionContainer(CppEditor::Constants::M_CONTEXT); + Core::ICore::instance()->actionManager()->actionContainer(CppEditor::Constants::M_CONTEXT); QMenu *contextMenu = mcontext->menu(); foreach (QAction *action, contextMenu->actions()) diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 6773a5308ae783b50a6593dec0ef0a0af6a0ab9b..4f324b683406cb8178a24bc47a67fd67dcb97708 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -35,20 +35,14 @@ #define CPPEDITOR_H #include "cppeditorenums.h" + #include <cplusplus/CppDocument.h> #include <texteditor/basetexteditor.h> -#include <QtCore/QObject> QT_BEGIN_NAMESPACE -class QAction; class QComboBox; -class QStringListModel; QT_END_NAMESPACE -namespace Core { -class ICore; -} - namespace CPlusPlus { class OverviewModel; class Symbol; @@ -136,7 +130,6 @@ private: bool openEditorAt(CPlusPlus::Symbol *symbol); - Core::ICore *m_core; CppTools::CppModelManagerInterface *m_modelManager; QList<int> m_contexts; diff --git a/src/plugins/cppeditor/cppeditoractionhandler.cpp b/src/plugins/cppeditor/cppeditoractionhandler.cpp index f8f2510523b08a11da301d8d78f9744bbf5d3a42..0037f11756225208ec42b6fd4d41ab9997f93e52 100644 --- a/src/plugins/cppeditor/cppeditoractionhandler.cpp +++ b/src/plugins/cppeditor/cppeditoractionhandler.cpp @@ -38,10 +38,9 @@ using namespace CppEditor::Internal; -CPPEditorActionHandler::CPPEditorActionHandler(Core::ICore *core, - const QString &context, +CPPEditorActionHandler::CPPEditorActionHandler(const QString &context, uint optionalActions) - : TextEditor::TextEditorActionHandler(core, context, optionalActions) + : TextEditor::TextEditorActionHandler(context, optionalActions) { } CPPEditorActionHandler::~CPPEditorActionHandler() diff --git a/src/plugins/cppeditor/cppeditoractionhandler.h b/src/plugins/cppeditor/cppeditoractionhandler.h index 12428c3343e7147c600e19ffbfa910f49991a469..d98d7f765882be50a3e1d46bcf6ed04ac1238573 100644 --- a/src/plugins/cppeditor/cppeditoractionhandler.h +++ b/src/plugins/cppeditor/cppeditoractionhandler.h @@ -44,8 +44,7 @@ class CPPEditorActionHandler : public TextEditor::TextEditorActionHandler Q_OBJECT public: - CPPEditorActionHandler(Core::ICore *core, - const QString &context, + CPPEditorActionHandler(const QString &context, uint optionalActions = None); virtual ~CPPEditorActionHandler(); diff --git a/src/plugins/cppeditor/cppfilewizard.cpp b/src/plugins/cppeditor/cppfilewizard.cpp index d65fed176691080ab0b2c8f577459da6057e578c..795d9248c126465dc4ae3e447dbff5a957434218 100644 --- a/src/plugins/cppeditor/cppfilewizard.cpp +++ b/src/plugins/cppeditor/cppfilewizard.cpp @@ -46,9 +46,8 @@ enum { debugWizard = 0 }; CppFileWizard::CppFileWizard(const BaseFileWizardParameters ¶meters, FileType type, - Core::ICore *core, QObject *parent) : - Core::StandardFileWizard(parameters, core, parent), + Core::StandardFileWizard(parameters, parent), m_type(type) { } diff --git a/src/plugins/cppeditor/cppfilewizard.h b/src/plugins/cppeditor/cppfilewizard.h index 51c91d9465ce1c13dfa8d8956ac5de5eb70cccb3..e6328f2d32d0ff039fead7cef927ec9384b61292 100644 --- a/src/plugins/cppeditor/cppfilewizard.h +++ b/src/plugins/cppeditor/cppfilewizard.h @@ -48,9 +48,9 @@ class CppFileWizard : public Core::StandardFileWizard public: typedef Core::BaseFileWizardParameters BaseFileWizardParameters; - explicit CppFileWizard(const BaseFileWizardParameters ¶meters, - FileType type, - Core::ICore *core, QObject *parent = 0); + CppFileWizard(const BaseFileWizardParameters ¶meters, + FileType type, + QObject *parent = 0); protected: static QString toAlphaNum(const QString &s); diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp index febf86f6510624f69cf3a45b6a14f65b27741ef1..5059a92d8b1d290aacc69d462dff93b3d0ef9216 100644 --- a/src/plugins/cppeditor/cpphoverhandler.cpp +++ b/src/plugins/cppeditor/cpphoverhandler.cpp @@ -39,6 +39,7 @@ #include <coreplugin/uniqueidmanager.h> #include <coreplugin/editormanager/editormanager.h> #include <cpptools/cppmodelmanagerinterface.h> +#include <extensionsystem/pluginmanager.h> #include <texteditor/itexteditor.h> #include <texteditor/basetexteditor.h> #include <debugger/debuggerconstants.h> @@ -55,23 +56,27 @@ #include <cplusplus/TypeOfExpression.h> #include <cplusplus/SimpleLexer.h> +#include <QtCore/QDebug> +#include <QtCore/QDir> +#include <QtCore/QFileInfo> +#include <QtCore/QSettings> #include <QtGui/QToolTip> #include <QtGui/QTextCursor> #include <QtGui/QTextBlock> #include <QtHelp/QHelpEngineCore> -#include <QtCore/QtCore> using namespace CppEditor::Internal; using namespace CPlusPlus; +using namespace Core; CppHoverHandler::CppHoverHandler(QObject *parent) : QObject(parent) - , m_core(CppPlugin::core()) , m_helpEngineNeedsSetup(false) { - m_modelManager = m_core->pluginManager()->getObject<CppTools::CppModelManagerInterface>(); + m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>(); - QFileInfo fi(ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->settings()->fileName()); + ICore *core = ICore::instance(); + QFileInfo fi(core->settings()->fileName()); // FIXME shouldn't the help engine create the directory if it doesn't exist? QDir directory(fi.absolutePath()+"/qtcreator"); if (!directory.exists()) @@ -86,7 +91,7 @@ CppHoverHandler::CppHoverHandler(QObject *parent) m_helpEngineNeedsSetup = m_helpEngine->registeredDocumentations().count() == 0; // Listen for editor opened events in order to connect to tooltip/helpid requests - connect(m_core->editorManager(), SIGNAL(editorOpened(Core::IEditor *)), + connect(core->editorManager(), SIGNAL(editorOpened(Core::IEditor *)), this, SLOT(editorOpened(Core::IEditor *))); } @@ -95,7 +100,7 @@ void CppHoverHandler::updateContextHelpId(TextEditor::ITextEditor *editor, int p updateHelpIdAndTooltip(editor, pos); } -void CppHoverHandler::editorOpened(Core::IEditor *editor) +void CppHoverHandler::editorOpened(IEditor *editor) { CPPEditorEditable *cppEditor = qobject_cast<CPPEditorEditable *>(editor); if (!cppEditor) @@ -113,9 +118,10 @@ void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint if (!editor) return; - const int dbgcontext = m_core->uniqueIDManager()->uniqueIdentifier(Debugger::Constants::C_GDBDEBUGGER); + ICore *core = ICore::instance(); + const int dbgcontext = core->uniqueIDManager()->uniqueIdentifier(Debugger::Constants::C_GDBDEBUGGER); - if (m_core->hasContext(dbgcontext)) + if (core->hasContext(dbgcontext)) return; updateHelpIdAndTooltip(editor, pos); diff --git a/src/plugins/cppeditor/cpphoverhandler.h b/src/plugins/cppeditor/cpphoverhandler.h index 27daccc35d7e40c490842047408ac75e387a443f..6833c9f57430deab1fa243efed71e5f6ac151788 100644 --- a/src/plugins/cppeditor/cpphoverhandler.h +++ b/src/plugins/cppeditor/cpphoverhandler.h @@ -42,7 +42,6 @@ class QPoint; QT_END_NAMESPACE namespace Core { -class ICore; class IEditor; } @@ -74,7 +73,6 @@ private slots: private: void updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos); - Core::ICore *m_core; CppTools::CppModelManagerInterface *m_modelManager; QHelpEngineCore *m_helpEngine; QString m_helpId; diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp index 077bea902745043c8ddf9ac5617891b27060779a..e600de92c586d3eb7cdf445508d2a2296d504a68 100644 --- a/src/plugins/cppeditor/cppplugin.cpp +++ b/src/plugins/cppeditor/cppplugin.cpp @@ -40,6 +40,7 @@ #include "cppfilewizard.h" #include "cpphoverhandler.h" +#include <coreplugin/icore.h> #include <coreplugin/coreconstants.h> #include <coreplugin/mimedatabase.h> #include <coreplugin/uniqueidmanager.h> @@ -63,7 +64,7 @@ static const char *sourceSuffixKeyC = "CppEditor/SourceSuffix"; using namespace CppEditor::Internal; -///////////////////////////////// CppPluginEditorFactory ////////////////////////////////// +//////////////////////////// CppPluginEditorFactory ///////////////////////////// CppPluginEditorFactory::CppPluginEditorFactory(CppPlugin *owner) : m_kind(QLatin1String(CppEditor::Constants::CPPEDITOR_KIND)), @@ -87,7 +88,7 @@ QString CppPluginEditorFactory::kind() const Core::IFile *CppPluginEditorFactory::open(const QString &fileName) { - Core::IEditor *iface = m_owner->m_core->editorManager()->openEditor(fileName, kind()); + Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, kind()); return iface ? iface->file() : 0; } @@ -110,7 +111,6 @@ QStringList CppPluginEditorFactory::mimeTypes() const CppPlugin *CppPlugin::m_instance = 0; CppPlugin::CppPlugin() : - m_core(0), m_actionHandler(0), m_factory(0) { @@ -130,11 +130,6 @@ CppPlugin *CppPlugin::instance() return m_instance; } -Core::ICore *CppPlugin::core() -{ - return m_instance->m_core; -} - void CppPlugin::initializeEditor(CPPEditor *editor) { // common actions @@ -159,14 +154,13 @@ void CppPlugin::initializeEditor(CPPEditor *editor) // auto completion connect(editor, SIGNAL(requestAutoCompletion(ITextEditable*, bool)), - TextEditor::Internal::CompletionSupport::instance(core()), SLOT(autoComplete(ITextEditable*, bool))); + TextEditor::Internal::CompletionSupport::instance(), SLOT(autoComplete(ITextEditable*, bool))); } bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) { - typedef TextEditor::TextEditorActionHandler TextEditorActionHandler; - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - if (!m_core->mimeDatabase()->addMimeTypes(QLatin1String(":/cppeditor/CppEditor.mimetypes.xml"), errorMessage)) + Core::ICore *core = Core::ICore::instance(); + if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/cppeditor/CppEditor.mimetypes.xml"), errorMessage)) return false; m_factory = new CppPluginEditorFactory(this); @@ -180,21 +174,21 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess wizardParameters.setTrCategory(tr("C++")); wizardParameters.setDescription(tr("Creates a new C++ header file.")); wizardParameters.setName(tr("C++ Header File")); - addAutoReleasedObject(new CppFileWizard(wizardParameters, Header, m_core)); + addAutoReleasedObject(new CppFileWizard(wizardParameters, Header, core)); wizardParameters.setDescription(tr("Creates a new C++ source file.")); wizardParameters.setName(tr("C++ Source File")); - addAutoReleasedObject(new CppFileWizard(wizardParameters, Source, m_core)); + addAutoReleasedObject(new CppFileWizard(wizardParameters, Source, core)); wizardParameters.setKind(Core::IWizard::ClassWizard); wizardParameters.setName(tr("C++ Class")); wizardParameters.setDescription(tr("Creates a header and a source file for a new class.")); - addAutoReleasedObject(new CppClassWizard(wizardParameters, m_core)); + addAutoReleasedObject(new CppClassWizard(wizardParameters, core)); QList<int> context; - context << m_core->uniqueIDManager()->uniqueIdentifier(CppEditor::Constants::C_CPPEDITOR); + context << core->uniqueIDManager()->uniqueIdentifier(CppEditor::Constants::C_CPPEDITOR); - Core::ActionManager *am = m_core->actionManager(); + Core::ActionManager *am = core->actionManager(); am->createMenu(CppEditor::Constants::M_CONTEXT); Core::Command *cmd; @@ -217,22 +211,21 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd); am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd); - m_actionHandler = new CPPEditorActionHandler(m_core, - CppEditor::Constants::C_CPPEDITOR, + m_actionHandler = new CPPEditorActionHandler(CppEditor::Constants::C_CPPEDITOR, TextEditor::TextEditorActionHandler::Format | TextEditor::TextEditorActionHandler::UnCommentSelection | TextEditor::TextEditorActionHandler::UnCollapseAll); // Check Suffixes - if (const QSettings *settings = m_core->settings()) { + if (const QSettings *settings = core->settings()) { const QString headerSuffixKey = QLatin1String(headerSuffixKeyC); if (settings->contains(headerSuffixKey)) { const QString headerSuffix = settings->value(headerSuffixKey, QString()).toString(); if (!headerSuffix.isEmpty()) - m_core->mimeDatabase()->setPreferredSuffix(QLatin1String(Constants::CPP_HEADER_MIMETYPE), headerSuffix); + core->mimeDatabase()->setPreferredSuffix(QLatin1String(Constants::CPP_HEADER_MIMETYPE), headerSuffix); const QString sourceSuffix = settings->value(QLatin1String(sourceSuffixKeyC), QString()).toString(); if (!sourceSuffix.isEmpty()) - m_core->mimeDatabase()->setPreferredSuffix(QLatin1String(Constants::CPP_SOURCE_MIMETYPE), sourceSuffix); + core->mimeDatabase()->setPreferredSuffix(QLatin1String(Constants::CPP_SOURCE_MIMETYPE), sourceSuffix); } } return true; @@ -245,18 +238,18 @@ void CppPlugin::extensionsInitialized() void CppPlugin::switchDeclarationDefinition() { - CPPEditor *editor = qobject_cast<CPPEditor*>(m_core->editorManager()->currentEditor()->widget()); - if (editor) { + Core::EditorManager *em = Core::EditorManager::instance(); + CPPEditor *editor = qobject_cast<CPPEditor*>(em->currentEditor()->widget()); + if (editor) editor->switchDeclarationDefinition(); - } } void CppPlugin::jumpToDefinition() { - CPPEditor *editor = qobject_cast<CPPEditor*>(m_core->editorManager()->currentEditor()->widget()); - if (editor) { + Core::EditorManager *em = Core::EditorManager::instance(); + CPPEditor *editor = qobject_cast<CPPEditor*>(em->currentEditor()->widget()); + if (editor) editor->jumpToDefinition(); - } } Q_EXPORT_PLUGIN(CppPlugin) diff --git a/src/plugins/cppeditor/cppplugin.h b/src/plugins/cppeditor/cppplugin.h index 52655e6ae7060c40a46972c61e5afd5828949310..629a29e505c31aed8d2d8b02865822b2430decf9 100644 --- a/src/plugins/cppeditor/cppplugin.h +++ b/src/plugins/cppeditor/cppplugin.h @@ -34,17 +34,12 @@ #ifndef CPPPLUGIN_H #define CPPPLUGIN_H -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QStringList> #include <extensionsystem/iplugin.h> #include <coreplugin/editormanager/ieditorfactory.h> -namespace Core { -class ICore; -class IWizard; -} - namespace TextEditor { class TextEditorActionHandler; } // namespace TextEditor @@ -65,7 +60,6 @@ public: ~CppPlugin(); static CppPlugin *instance(); - static Core::ICore *core(); bool initialize(const QStringList &arguments, QString *error_message = 0); void extensionsInitialized(); @@ -83,7 +77,6 @@ private: static CppPlugin *m_instance; - Core::ICore *m_core; CPPEditorActionHandler *m_actionHandler; CppPluginEditorFactory *m_factory; }; diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 49e7cbfc7dbc324c316ace319977ff99468406b1..75f64fea5da9db750abf37ff1de1652a31e7c13e 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -51,6 +51,7 @@ #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/progressmanager/progressmanager.h> +#include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> #include <TranslationUnit.h> @@ -69,8 +70,6 @@ #include <QtCore/QMutexLocker> #include <QtCore/QTime> -//#include <QtGui/QPlainTextEdit> - using namespace CppTools; using namespace CppTools::Internal; using namespace CPlusPlus; @@ -434,10 +433,10 @@ Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc) modified within Workbench. */ -CppModelManager::CppModelManager(QObject *parent) : - CppModelManagerInterface(parent), - m_core(ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()) +CppModelManager::CppModelManager(QObject *parent) + : CppModelManagerInterface(parent) { + m_core = Core::ICore::instance(); // FIXME m_dirty = true; m_projectExplorer = ExtensionSystem::PluginManager::instance() diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h index ca1c57f86355a185a042a7bd4b4ef1828c79a7e5..849c3c691fd5c99da94186f497089b4939e7629c 100644 --- a/src/plugins/cpptools/cppmodelmanagerinterface.h +++ b/src/plugins/cpptools/cppmodelmanagerinterface.h @@ -46,7 +46,7 @@ namespace ProjectExplorer { namespace CppTools { -class CPPTOOLS_EXPORT CppModelManagerInterface: public QObject +class CPPTOOLS_EXPORT CppModelManagerInterface : public QObject { Q_OBJECT diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index 5ec67bf4a35fcfbb01341044b29c075e82dd457c..3a8c271a0989729f59d80d37b8957a9fabd592c3 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -48,8 +48,9 @@ #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/editormanager/editormanager.h> #include <cppeditor/cppeditorconstants.h> +#include <extensionsystem/pluginmanager.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QFileInfo> #include <QtCore/QDir> #include <QtCore/QDebug> @@ -64,10 +65,8 @@ enum { debug = 0 }; CppToolsPlugin *CppToolsPlugin::m_instance = 0; -CppToolsPlugin::CppToolsPlugin() : - m_core(0), - m_context(-1), - m_modelManager(0) +CppToolsPlugin::CppToolsPlugin() + : m_context(-1), m_modelManager(0) { m_instance = this; } @@ -78,21 +77,23 @@ CppToolsPlugin::~CppToolsPlugin() m_modelManager = 0; // deleted automatically } -bool CppToolsPlugin::initialize(const QStringList & /*arguments*/, QString *) +bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error) { - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - Core::ActionManager *am = m_core->actionManager(); + Q_UNUSED(arguments); + Q_UNUSED(error); + Core::ICore *core = Core::ICore::instance(); + Core::ActionManager *am = core->actionManager(); // Objects m_modelManager = new CppModelManager(this); addAutoReleasedObject(m_modelManager); - m_completion = new CppCodeCompletion(m_modelManager, m_core); + m_completion = new CppCodeCompletion(m_modelManager, core); addAutoReleasedObject(m_completion); CppQuickOpenFilter *quickOpenFilter = new CppQuickOpenFilter(m_modelManager, - m_core->editorManager()); + core->editorManager()); addAutoReleasedObject(quickOpenFilter); - addAutoReleasedObject(new CppClassesFilter(m_modelManager, m_core->editorManager())); - addAutoReleasedObject(new CppFunctionsFilter(m_modelManager, m_core->editorManager())); + addAutoReleasedObject(new CppClassesFilter(m_modelManager, core->editorManager())); + addAutoReleasedObject(new CppFunctionsFilter(m_modelManager, core->editorManager())); addAutoReleasedObject(new CompletionSettingsPage(m_completion)); // Menus @@ -104,7 +105,7 @@ bool CppToolsPlugin::initialize(const QStringList & /*arguments*/, QString *) mtools->addMenu(mcpptools); // Actions - m_context = m_core->uniqueIDManager()->uniqueIdentifier(CppEditor::Constants::C_CPPEDITOR); + m_context = core->uniqueIDManager()->uniqueIdentifier(CppEditor::Constants::C_CPPEDITOR); QList<int> context = QList<int>() << m_context; QAction *switchAction = new QAction(tr("Switch Header/Source"), this); @@ -114,7 +115,7 @@ bool CppToolsPlugin::initialize(const QStringList & /*arguments*/, QString *) connect(switchAction, SIGNAL(triggered()), this, SLOT(switchHeaderSource())); // Restore settings - QSettings *settings = m_core->settings(); + QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(QLatin1String("CppTools")); settings->beginGroup(QLatin1String("Completion")); const bool caseSensitive = settings->value(QLatin1String("CaseSensitive"), true).toBool(); @@ -134,7 +135,7 @@ void CppToolsPlugin::extensionsInitialized() void CppToolsPlugin::shutdown() { // Save settings - QSettings *settings = m_core->settings(); + QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(QLatin1String("CppTools")); settings->beginGroup(QLatin1String("Completion")); settings->setValue(QLatin1String("CaseSensitive"), m_completion->caseSensitivity() == Qt::CaseSensitive); @@ -146,14 +147,12 @@ void CppToolsPlugin::shutdown() void CppToolsPlugin::switchHeaderSource() { - if (!m_core) - return; - - Core::IEditor *editor = m_core->editorManager()->currentEditor(); + Core::EditorManager *editorManager = Core::EditorManager::instance(); + Core::IEditor *editor = editorManager->currentEditor(); QString otherFile = correspondingHeaderOrSource(editor->file()->fileName()); if (!otherFile.isEmpty()) { - m_core->editorManager()->openEditor(otherFile); - m_core->editorManager()->ensureEditorManagerVisible(); + editorManager->openEditor(otherFile); + editorManager->ensureEditorManagerVisible(); } } @@ -221,7 +220,7 @@ static QStringList matchingCandidateSuffixes(const Core::MimeDatabase *mimeDatas QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) const { - const Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + const Core::ICore *core = Core::ICore::instance(); const Core::MimeDatabase *mimeDatase = core->mimeDatabase(); ProjectExplorer::ProjectExplorerPlugin *explorer = ExtensionSystem::PluginManager::instance()->getObject<ProjectExplorer::ProjectExplorerPlugin>(); diff --git a/src/plugins/cpptools/cpptoolsplugin.h b/src/plugins/cpptools/cpptoolsplugin.h index 092de535b3ed2e318453f6405861055b479d6007..281fe1f708d2829656eb10ae7ba18f1381910e9e 100644 --- a/src/plugins/cpptools/cpptoolsplugin.h +++ b/src/plugins/cpptools/cpptoolsplugin.h @@ -42,10 +42,6 @@ class QFileInfo; class QDir; QT_END_NAMESPACE -namespace Core { -class ICore; -} - namespace CppTools { namespace Internal { @@ -75,7 +71,6 @@ private: QString correspondingHeaderOrSourceI(const QString &fileName) const; QFileInfo findFile(const QDir &dir, const QString &name, const ProjectExplorer::Project *project) const; - Core::ICore *m_core; int m_context; CppModelManager *m_modelManager; CppCodeCompletion *m_completion; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 204345a0220d35fa2ec4f00bed50dbf4f960b33b..07904b8efa3acd29d74d47ff61c27e6a9685921f 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -55,12 +55,12 @@ #include <coreplugin/rightpane.h> #include <coreplugin/uniqueidmanager.h> -#include <extensionsystem/pluginmanager.h> - #include <cplusplus/ExpressionUnderCursor.h> #include <cppeditor/cppeditorconstants.h> +#include <extensionsystem/pluginmanager.h> + #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/session.h> @@ -346,7 +346,7 @@ DebuggerPlugin::~DebuggerPlugin() static QSettings *settings() { - return ExtensionSystem::PluginManager::instance()->getObject<ICore>()->settings(); + return ICore::instance()->settings(); } void DebuggerPlugin::shutdown() @@ -387,7 +387,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes m_pm = ExtensionSystem::PluginManager::instance(); - ICore *core = m_pm->getObject<Core::ICore>(); + ICore *core = ICore::instance(); QTC_ASSERT(core, return false); Core::ActionManager *am = core->actionManager(); @@ -611,7 +611,6 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes splitter->setOrientation(Qt::Vertical); MiniSplitter *splitter2 = new MiniSplitter; - splitter2 = new MiniSplitter; splitter2->addWidget(new NavigationWidgetPlaceHolder(m_debugMode)); splitter2->addWidget(splitter); splitter2->setStretchFactor(0, 0); @@ -713,8 +712,7 @@ ProjectExplorer::ProjectExplorerPlugin *DebuggerPlugin::projectExplorer() const /*! Activates the previous mode when the current mode is the debug mode. */ void DebuggerPlugin::activatePreviousMode() { - ICore *core = m_pm->getObject<Core::ICore>(); - Core::ModeManager *const modeManager = core->modeManager(); + Core::ModeManager *const modeManager = ICore::instance()->modeManager(); if (modeManager->currentMode() == modeManager->mode(Constants::MODE_DEBUG) && !m_previousMode.isEmpty()) { @@ -725,18 +723,17 @@ void DebuggerPlugin::activatePreviousMode() void DebuggerPlugin::activateDebugMode() { - ICore *core = m_pm->getObject<Core::ICore>(); - Core::ModeManager *modeManager = core->modeManager(); + ModeManager *modeManager = ModeManager::instance(); m_previousMode = QLatin1String(modeManager->currentMode()->uniqueModeName()); modeManager->activateMode(QLatin1String(MODE_DEBUG)); } void DebuggerPlugin::queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **object) { - ICore *core = m_pm->getObject<Core::ICore>(); - if (!core || !core->editorManager()) + EditorManager *editorManager = EditorManager::instance(); + if (!editorManager) return; - Core::IEditor *editor = core->editorManager()->currentEditor(); + Core::IEditor *editor = editorManager->currentEditor(); ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor); if (!textEditor) return; @@ -872,7 +869,7 @@ void DebuggerPlugin::gotoLocation(const QString &fileName, int lineNumber, void DebuggerPlugin::changeStatus(int status) { bool startIsContinue = (status == DebuggerInferiorStopped); - ICore *core = m_pm->getObject<Core::ICore>(); + ICore *core = ICore::instance(); if (startIsContinue) { core->addAdditionalContext(m_gdbRunningContext); core->updateContext(); @@ -894,6 +891,7 @@ void DebuggerPlugin::writeSettings() const s->setValue("Locked", m_toggleLockedAction->isChecked()); s->setValue("Location", m->m_gdbCmd); s->setValue("Environment", m->m_gdbEnv); + s->setValue("ScriptFile", m->m_scriptFile); s->setValue("AutoRun", m->m_autoRun); s->setValue("AutoQuit", m->m_autoQuit); @@ -915,25 +913,24 @@ void DebuggerPlugin::readSettings() #if defined(Q_OS_WIN32) defaultCommand.append(".exe"); #endif - Core::ICore *coreIFace = m_pm->getObject<Core::ICore>(); - QString defaultScript = coreIFace->resourcePath() + + QString defaultScript = ICore::instance()->resourcePath() + QLatin1String("/gdb/qt4macros"); s->beginGroup(QLatin1String("DebugMode")); QByteArray ba = s->value("State", QByteArray()).toByteArray(); m_toggleLockedAction->setChecked(s->value("Locked", true).toBool()); - m->m_gdbCmd = s->value("Location", defaultCommand).toString(); - m->m_scriptFile= s->value("ScriptFile", defaultScript).toString(); - m->m_gdbEnv = s->value("Environment", "").toString(); - m->m_autoRun = s->value("AutoRun", true).toBool(); - m->m_autoQuit = s->value("AutoQuit", true).toBool(); - - m->m_skipKnownFrames = s->value("SkipKnownFrames", false).toBool(); - m->m_debugDumpers = s->value("DebugDumpers", false).toBool(); - m->m_useCustomDumpers = s->value("UseCustomDupers", false).toBool(); - m->m_useFastStart = s->value("UseFastStart", false).toBool(); - m->m_useToolTips = s->value("UseToolTips", false).toBool(); - m->m_useTerminal = s->value("UseTerminal", false).toBool(); + m->m_gdbCmd = s->value("Location", defaultCommand).toString(); + m->m_scriptFile = s->value("ScriptFile", defaultScript).toString(); + m->m_gdbEnv = s->value("Environment", "").toString(); + m->m_autoRun = s->value("AutoRun", true).toBool(); + m->m_autoQuit = s->value("AutoQuit", true).toBool(); + + m->m_skipKnownFrames = s->value("SkipKnownFrames", false).toBool(); + m->m_debugDumpers = s->value("DebugDumpers", false).toBool(); + m->m_useCustomDumpers = s->value("UseCustomDumpers", true).toBool(); + m->m_useFastStart = s->value("UseFastStart", false).toBool(); + m->m_useToolTips = s->value("UseToolTips", false).toBool(); + m->m_useTerminal = s->value("UseTerminal", false).toBool(); s->endGroup(); m_manager->mainWindow()->restoreState(ba); diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 79530908c770d8021941a660f865b9a99f0b961b..4b84c88cb7f239946978bbff2db487de492a2cd0 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -467,20 +467,6 @@ void GdbEngine::handleResponse() break; } - case '#': { - //qDebug() << "CUSTOM OUTPUT, TOKEN" << token; - QString str; - for (; from != to && *from >= '0' && *from <= '9'; ++from) - str += QLatin1Char(*from); - ++from; // skip the ' ' - int len = str.toInt(); - QByteArray ba(from, len); - from += len; - m_inbuffer = QByteArray(from, to - from); - m_customOutputForToken[token] += QString(ba); - break; - } - case '^': { GdbResultRecord record; @@ -696,7 +682,7 @@ void GdbEngine::sendCommand(const QString &command, int type, //qDebug() << ""; if (!command.isEmpty()) { - //qDebug() << qPrintable(currentTime()) << "RUNNING << cmd.command; + //qDebug() << qPrintable(currentTime()) << "RUNNING" << cmd.command; m_gdbProc.write(cmd.command.toLatin1() + "\r\n"); //emit gdbInputAvailable(QString(), " " + currentTime()); emit gdbInputAvailable(QString(), "[" + currentTime() + "] " + cmd.command); @@ -1520,6 +1506,7 @@ bool GdbEngine::startDebugger() #if 0 qDebug() << "Command: " << q->settings()->m_gdbCmd; qDebug() << "WorkingDirectory: " << m_gdbProc.workingDirectory(); + qDebug() << "ScriptFile: " << q->settings()->m_scriptFile; qDebug() << "Environment: " << m_gdbProc.environment(); qDebug() << "Arguments: " << gdbArgs; qDebug() << "BuildDir: " << q->m_buildDir; @@ -1561,6 +1548,7 @@ bool GdbEngine::startDebugger() //sendCommand("set confirm off"); //sendCommand("set pagination off"); sendCommand("set breakpoint pending on", BreakEnablePending); + sendCommand("set print elements 10000"); // one of the following is needed to prevent crashes in gdb on code like: // template <class T> T foo() { return T(0); } @@ -1599,6 +1587,22 @@ bool GdbEngine::startDebugger() "dyld \".*libobjc.*\" all " "dyld \".*CarbonDataFormatters.*\" all"); #endif + + QString scriptFileName = q->settings()->m_scriptFile; + if (!scriptFileName.isEmpty()) { + QFile scriptFile(scriptFileName); + if (scriptFile.open(QIODevice::ReadOnly)) { + sendCommand("source " + scriptFileName); + } else { + QMessageBox::warning(q->mainWindow(), + tr("Cannot find debugger initialization script"), + tr("The debugger settings point to a script file at '%1' " + "which is not accessible. If a script file is not needed, " + "consider clearing that entry to avoid this warning. " + ).arg(scriptFileName)); + } + } + if (q->startMode() == q->attachExternal) { sendCommand("attach " + QString::number(q->m_attachedPID)); } @@ -3061,14 +3065,11 @@ void GdbEngine::runCustomDumper(const WatchData & data0, bool dumpChildren) q->showStatusMessage( tr("Retrieving data for watch view (%1 requests pending)...") .arg(m_pendingRequests + 1), 10000); - // create response slot for socket data + + // retrieve response QVariant var; var.setValue(data); - sendSynchronizedCommand(QString(), WatchDumpCustomValue2, var); - - // this increases the probability that gdb spits out output it - // has collected so far - //sendCommand("p qDumpInBuffer"); + sendSynchronizedCommand("p (char*)qDumpOutBuffer", WatchDumpCustomValue2, var); } void GdbEngine::createGdbVariable(const WatchData &data) @@ -3301,14 +3302,17 @@ void GdbEngine::handleQueryDataDumper1(const GdbResultRecord &record) void GdbEngine::handleQueryDataDumper2(const GdbResultRecord &record) { - // is this the official gdb response. However, it won't contain - // interesting data other than the information that 'real' data - // either already arrived or is still in the pipe. So we do - // _not_ register this result for counting purposes, this will - // be done by the 'real' result (with resultClass == GdbResultCustomDone) //qDebug() << "DATA DUMPER TRIAL:" << record.toString(); - GdbMi output = record.data.findChild("customvaluecontents"); - GdbMi contents(output.data()); + GdbMi output = record.data.findChild("consolestreamoutput"); + QByteArray out = output.data(); + out = out.mid(out.indexOf('"') + 2); // + 1 is success marker + out = out.left(out.lastIndexOf('"')); + out = out.replace('\'', '"'); + out = "dummy={" + out + "}"; + //qDebug() << "OUTPUT: " << out; + + GdbMi contents; + contents.fromString(out); GdbMi simple = contents.findChild("dumpers"); m_namespace = contents.findChild("namespace").data(); GdbMi qtversion = contents.findChild("qtversion"); @@ -3320,8 +3324,7 @@ void GdbEngine::handleQueryDataDumper2(const GdbResultRecord &record) } else { m_qtVersion = 0; } - - //qDebug() << "OUTPUT: " << output.toString(); + //qDebug() << "CONTENTS: " << contents.toString(); //qDebug() << "SIMPLE DUMPERS: " << simple.toString(); m_availableSimpleDumpers.clear(); @@ -3462,7 +3465,7 @@ void GdbEngine::handleDumpCustomValue1(const GdbResultRecord &record, QString msg = record.data.findChild("msg").data(); //qDebug() << "CUSTOM DUMPER ERROR MESSAGE: " << msg; #ifdef QT_DEBUG - // Make debugging of dumers easier + // Make debugging of dumpers easier if (q->settings()->m_debugDumpers && msg.startsWith("The program being debugged stopped while") && msg.contains("qDumpObjectData440")) { @@ -3490,10 +3493,20 @@ void GdbEngine::handleDumpCustomValue2(const GdbResultRecord &record, //qDebug() << "CUSTOM VALUE RESULT: " << record.toString(); //qDebug() << "FOR DATA: " << data.toString() << record.resultClass; if (record.resultClass == GdbResultDone) { - GdbMi output = record.data.findChild("customvaluecontents"); - //qDebug() << "HANDLE VALUE CONTENTS: " << output.toString(true); - if (!output.isValid()) { - //qDebug() << "INVALID"; + GdbMi output = record.data.findChild("consolestreamoutput"); + QByteArray out = output.data(); + out = out.mid(out.indexOf('"') + 2); // + 1 is the 'success marker' + out = out.left(out.lastIndexOf('"')); + out = out.replace('\'', '"'); + out = "dummy={" + out + "}"; + //qDebug() << "OUTPUT: " << out; + + GdbMi contents; + contents.fromString(out); + //qDebug() << "CONTENTS" << contents.toString(true); + + if (!contents.isValid()) { + qDebug() << "INVALID"; // custom dumper produced no output if (data.isValueNeeded()) data.setValue("<unknown>"); @@ -3506,10 +3519,6 @@ void GdbEngine::handleDumpCustomValue2(const GdbResultRecord &record, data.setValueToolTip("<custom dumper produced no output>"); insertData(data); } else { - GdbMi contents; - //qDebug() << "OUTPUT" << output.toString(true); - contents.fromString(output.data()); - //qDebug() << "CONTENTS" << contents.toString(true); setWatchDataType(data, contents.findChild("type")); setWatchDataValue(data, contents.findChild("value"), contents.findChild("valueencoded").data().toInt()); @@ -4003,8 +4012,7 @@ void GdbEngine::tryLoadCustomDumpers() // retreive list of dumpable classes sendCommand("call qDumpObjectData440(1,%1+1,0,0,0,0,0,0)", GdbQueryDataDumper1); - // create response slot for socket data - sendCommand(QString(), GdbQueryDataDumper2); + sendCommand("p (char*)qDumpOutBuffer", GdbQueryDataDumper2); } diff --git a/src/plugins/debugger/gdbmi.cpp b/src/plugins/debugger/gdbmi.cpp index 88060d7b350fe4cea36e805ff69faf5a8ce45dca..d3fbeb4428123dd52aaea65a12e3080c98588b66 100644 --- a/src/plugins/debugger/gdbmi.cpp +++ b/src/plugins/debugger/gdbmi.cpp @@ -46,20 +46,20 @@ QTextStream & operator<<(QTextStream & os, const GdbMi & mi) return os << mi.toString(); } -//static void skipSpaces(const GdbMi::Char *&from, const GdbMi::Char *to) +//static void skipSpaces(const char *&from, const char *to) //{ // while (from != to && QChar(*from).isSpace()) // ++from; //} -void GdbMi::parseResultOrValue(const Char *&from, const Char *to) +void GdbMi::parseResultOrValue(const char *&from, const char *to) { //skipSpaces(from, to); while (from != to && QChar(*from).isSpace()) ++from; - //qDebug() << "parseResultOrValue: " << QByteArray::fromLatin1(from, to - from); + //qDebug() << "parseResultOrValue: " << QByteArray(from, to - from); parseValue(from, to); if (isValid()) { //qDebug() << "no valid result in " << QByteArray::fromLatin1(from, to - from); @@ -67,7 +67,7 @@ void GdbMi::parseResultOrValue(const Char *&from, const Char *to) } if (from == to || *from == '(') return; - const Char *ptr = from; + const char *ptr = from; while (ptr < to && *ptr != '=') { //qDebug() << "adding" << QChar(*ptr) << "to name"; ++ptr; @@ -80,7 +80,7 @@ void GdbMi::parseResultOrValue(const Char *&from, const Char *to) } } -QByteArray GdbMi::parseCString(const Char *&from, const Char *to) +QByteArray GdbMi::parseCString(const char *&from, const char *to) { QByteArray result; //qDebug() << "parseCString: " << QByteArray::fromUtf16(from, to - from); @@ -88,7 +88,7 @@ QByteArray GdbMi::parseCString(const Char *&from, const Char *to) qDebug() << "MI Parse Error, double quote expected"; return QByteArray(); } - const Char *ptr = from; + const char *ptr = from; ++ptr; while (ptr < to) { if (*ptr == '"') { @@ -115,7 +115,7 @@ QByteArray GdbMi::parseCString(const Char *&from, const Char *to) return result; } -void GdbMi::parseValue(const Char *&from, const Char *to) +void GdbMi::parseValue(const char *&from, const char *to) { //qDebug() << "parseValue: " << QByteArray::fromUtf16(from, to - from); switch (*from) { @@ -135,7 +135,7 @@ void GdbMi::parseValue(const Char *&from, const Char *to) } -void GdbMi::parseTuple(const Char *&from, const Char *to) +void GdbMi::parseTuple(const char *&from, const char *to) { //qDebug() << "parseTuple: " << QByteArray::fromUtf16(from, to - from); QTC_ASSERT(*from == '{', /**/); @@ -143,7 +143,7 @@ void GdbMi::parseTuple(const Char *&from, const Char *to) parseTuple_helper(from, to); } -void GdbMi::parseTuple_helper(const Char *&from, const Char *to) +void GdbMi::parseTuple_helper(const char *&from, const char *to) { //qDebug() << "parseTuple_helper: " << QByteArray::fromUtf16(from, to - from); m_type = Tuple; @@ -163,7 +163,7 @@ void GdbMi::parseTuple_helper(const Char *&from, const Char *to) } } -void GdbMi::parseList(const Char *&from, const Char *to) +void GdbMi::parseList(const char *&from, const char *to) { //qDebug() << "parseList: " << QByteArray::fromUtf16(from, to - from); QTC_ASSERT(*from == '[', /**/); @@ -267,8 +267,8 @@ QByteArray GdbMi::toString(bool multiline, int indent) const void GdbMi::fromString(const QByteArray &ba) { - const Char *from = ba.constBegin(); - const Char *to = ba.constEnd(); + const char *from = ba.constBegin(); + const char *to = ba.constEnd(); parseResultOrValue(from, to); } @@ -449,16 +449,16 @@ static struct Tester { } for (int i = from; i < to; ++i) { if (str[i] == '{') - result += "{\n" + QByteArray(2*++indent + 1, QChar(' ')); + result += "{\n" + QByteArray(2*++indent + 1, ' '); else if (str[i] == '}') { if (!result.isEmpty() && result[result.size() - 1] != '\n') result += "\n"; - result += QByteArray(2*--indent + 1, QChar(' ')) + "}\n"; + result += QByteArray(2*--indent + 1, ' ') + "}\n"; } else if (str[i] == ',') { if (true || !result.isEmpty() && result[result.size() - 1] != '\n') result += "\n"; - result += QByteArray(2*indent, QChar(' ')); + result += QByteArray(2*indent, ' '); } else result += str[i]; diff --git a/src/plugins/debugger/gdbmi.h b/src/plugins/debugger/gdbmi.h index 0e6c36e9756af2ee04dcf00a41234f5529130e15..21810eed40ea026e5d6e3ae9e0ce36e35a99e07b 100644 --- a/src/plugins/debugger/gdbmi.h +++ b/src/plugins/debugger/gdbmi.h @@ -34,8 +34,6 @@ #ifndef DEBUGGER_GDBMI_H #define DEBUGGER_GDBMI_H -#include <qglobal.h> - #include <QtCore/QByteArray> #include <QtCore/QList> @@ -125,8 +123,8 @@ public: inline const QList<GdbMi> &children() const { return m_children; } inline int childCount() const { return m_children.size(); } - const GdbMi & childAt(int index) const { return m_children[index]; } - GdbMi & childAt(int index) { return m_children[index]; } + const GdbMi &childAt(int index) const { return m_children[index]; } + GdbMi &childAt(int index) { return m_children[index]; } GdbMi findChild(const QByteArray &name) const; GdbMi findChild(const QByteArray &name, const QByteArray &defaultString) const; @@ -138,14 +136,12 @@ private: friend class GdbResultRecord; friend class GdbEngine; - //typedef ushort Char; - typedef char Char; - static QByteArray parseCString(const Char *&from, const Char *to); - void parseResultOrValue(const Char *&from, const Char *to); - void parseValue(const Char *&from, const Char *to); - void parseTuple(const Char *&from, const Char *to); - void parseTuple_helper(const Char *&from, const Char *to); - void parseList(const Char *&from, const Char *to); + static QByteArray parseCString(const char *&from, const char *to); + void parseResultOrValue(const char *&from, const char *to); + void parseValue(const char *&from, const char *to); + void parseTuple(const char *&from, const char *to); + void parseTuple_helper(const char *&from, const char *to); + void parseList(const char *&from, const char *to); void dumpChildren(QByteArray *str, bool multiline, int indent) const; }; @@ -171,8 +167,6 @@ public: int token; GdbResultClass resultClass; GdbMi data; -private: - friend class GdbMi; }; } // namespace Internal diff --git a/src/plugins/debugger/gdbtypemacros.cpp b/src/plugins/debugger/gdbtypemacros.cpp index d392a836f0e82961c0f32bfcd997c1c7e159a607..c586e6c3027e5d284169385f372f023374df98b1 100644 --- a/src/plugins/debugger/gdbtypemacros.cpp +++ b/src/plugins/debugger/gdbtypemacros.cpp @@ -35,7 +35,6 @@ #include "gdbengine.h" #include "imports.h" -#include <extensionsystem/pluginmanager.h> #include <coreplugin/icore.h> #include <QtCore/QSettings> @@ -49,9 +48,7 @@ TypeMacroPage::TypeMacroPage(GdbSettings *settings) m_pm = ExtensionSystem::PluginManager::instance(); m_settings = settings; - Core::ICore *coreIFace = m_pm->getObject<Core::ICore>(); - if (!coreIFace || !coreIFace->settings()) - return; + Core::ICore *coreIFace = ICore::instance(); QSettings *s = coreIFace->settings(); s->beginGroup("GdbOptions"); @@ -164,14 +161,11 @@ void TypeMacroPage::finished(bool accepted) m_settings->m_typeMacros.insert(item->text(0), data); } - Core::ICore *coreIFace = m_pm->getObject<Core::ICore>(); - if (coreIFace && coreIFace->settings()) { - QSettings *s = coreIFace->settings(); - s->beginGroup("GdbOptions"); - s->setValue("ScriptFile", m_settings->m_scriptFile); - s->setValue("TypeMacros", m_settings->m_typeMacros); - s->endGroup(); - } + QSettings *s = ICore::instance()->settings(); + s->beginGroup("GdbOptions"); + s->setValue("ScriptFile", m_settings->m_scriptFile); + s->setValue("TypeMacros", m_settings->m_typeMacros); + s->endGroup(); } void TypeMacroPage::onAddButton() diff --git a/src/plugins/designer/cpp/formclasswizard.cpp b/src/plugins/designer/cpp/formclasswizard.cpp index b4e618490d40a4a2d869635894f1c3b67d5b55dc..c480fc059fcf2dc0ab59f1f9b38d963bf913a63a 100644 --- a/src/plugins/designer/cpp/formclasswizard.cpp +++ b/src/plugins/designer/cpp/formclasswizard.cpp @@ -43,13 +43,11 @@ #include <QtCore/QDir> #include <QtCore/QDebug> -enum { debugFormClassWizard = 0 }; - using namespace Designer; using namespace Designer::Internal; -FormClassWizard::FormClassWizard(const BaseFileWizardParameters ¶meters, Core::ICore *core, QObject *parent) : - Core::BaseFileWizard(parameters, core, parent) +FormClassWizard::FormClassWizard(const BaseFileWizardParameters ¶meters, QObject *parent) + : Core::BaseFileWizard(parameters, parent) { } @@ -111,7 +109,7 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e sourceFile.setContents(source); headerFile.setContents(header); - if (debugFormClassWizard) + if (Designer::Constants::Internal::debug) qDebug() << Q_FUNC_INFO << '\n' << header << '\n' << source; return Core::GeneratedFiles() << headerFile << sourceFile << uiFile; diff --git a/src/plugins/designer/cpp/formclasswizard.h b/src/plugins/designer/cpp/formclasswizard.h index 39b99c92037d0e15ea3de360d377c5afde5b7776..f7b693440f327c354f20fbc1851fc1011e257c0f 100644 --- a/src/plugins/designer/cpp/formclasswizard.h +++ b/src/plugins/designer/cpp/formclasswizard.h @@ -38,10 +38,6 @@ #include <coreplugin/basefilewizard.h> -QT_BEGIN_NAMESPACE -class QWizard; -QT_END_NAMESPACE - namespace Designer { namespace Internal { @@ -55,7 +51,7 @@ class FormClassWizard : public Core::BaseFileWizard public: typedef Core::BaseFileWizardParameters BaseFileWizardParameters; - FormClassWizard(const BaseFileWizardParameters ¶meters, Core::ICore *core, QObject *parent); + FormClassWizard(const BaseFileWizardParameters ¶meters, QObject *parent); QString headerSuffix() const; QString sourceSuffix() const; diff --git a/src/plugins/designer/cpp/formclasswizardpage.cpp b/src/plugins/designer/cpp/formclasswizardpage.cpp index 6cc0ced4215266b741ae39fa2410c4066c4f99d1..389820750274ecb72d3e9c97e18911aeea441b50 100644 --- a/src/plugins/designer/cpp/formclasswizardpage.cpp +++ b/src/plugins/designer/cpp/formclasswizardpage.cpp @@ -42,8 +42,8 @@ #include <QtCore/QDir> #include <QtCore/QSettings> -#include <QtGui/QMessageBox> #include <QtGui/QAbstractButton> +#include <QtGui/QMessageBox> static const char *formClassWizardPageGroupC = "FormClassWizardPage"; static const char *translationKeyC = "RetranslationSupport"; @@ -175,7 +175,7 @@ bool FormClassWizardPage::validatePage() void FormClassWizardPage::saveSettings() { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); if (QSettings *settings = core->settings()) { settings->beginGroup(QLatin1String(formClassWizardPageGroupC)); settings->setValue(QLatin1String(translationKeyC), hasRetranslationSupport()); @@ -189,7 +189,7 @@ void FormClassWizardPage::restoreSettings() bool retranslationSupport = true; int embedding = PointerAggregatedUiClass; - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); if (QSettings *settings = core->settings()) { QString key = QLatin1String(formClassWizardPageGroupC); diff --git a/src/plugins/designer/designerconstants.h b/src/plugins/designer/designerconstants.h index 0f4024f2b9a00caa6b4a303d4e36e06a58ce6fec..f403f6322f2e238492e0207799e3587b8bf04909 100644 --- a/src/plugins/designer/designerconstants.h +++ b/src/plugins/designer/designerconstants.h @@ -67,6 +67,9 @@ enum EditModes NumEditModes }; +namespace Internal { + enum { debug = 0 }; +} } // Constants } // Designer diff --git a/src/plugins/designer/formeditorfactory.cpp b/src/plugins/designer/formeditorfactory.cpp index 81d910ee9df2cd0b7db0dfa385b3247674449039..df3c59adfa3f6a3fe06261e55f6bcb386548ab7b 100644 --- a/src/plugins/designer/formeditorfactory.cpp +++ b/src/plugins/designer/formeditorfactory.cpp @@ -46,11 +46,10 @@ using namespace Designer::Internal; using namespace Designer::Constants; -FormEditorFactory::FormEditorFactory(Core::ICore *core) : - Core::IEditorFactory(core), +FormEditorFactory::FormEditorFactory() + : Core::IEditorFactory(Core::ICore::instance()), m_kind(QLatin1String(C_FORMEDITOR)), - m_mimeTypes(QLatin1String(FORM_MIMETYPE)), - m_core(core) + m_mimeTypes(QLatin1String(FORM_MIMETYPE)) { Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); iconProvider->registerIconForSuffix(QIcon(":/formeditor/images/qt_ui.png"), @@ -64,7 +63,7 @@ QString FormEditorFactory::kind() const Core::IFile *FormEditorFactory::open(const QString &fileName) { - Core::IEditor *iface = m_core->editorManager()->openEditor(fileName, kind()); + Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, kind()); return iface ? iface->file() : 0; } diff --git a/src/plugins/designer/formeditorfactory.h b/src/plugins/designer/formeditorfactory.h index 5d13e45080a4fda240261dba166dd24d590389d5..4db6e3f8b12193d8631479cda2200eacf8725c1b 100644 --- a/src/plugins/designer/formeditorfactory.h +++ b/src/plugins/designer/formeditorfactory.h @@ -39,7 +39,6 @@ #include <QtCore/QStringList> namespace Core { -class ICore; class IEditor; class IFile; } @@ -52,10 +51,11 @@ class FormEditorFactory : public Core::IEditorFactory Q_OBJECT public: - FormEditorFactory(Core::ICore *core); + FormEditorFactory(); virtual QStringList mimeTypes() const; - //EditorFactory + + // IEditorFactory virtual QString kind() const; Core::IFile *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); @@ -63,7 +63,6 @@ public: private: const QString m_kind; const QStringList m_mimeTypes; - Core::ICore *m_core; }; } // namespace Internal diff --git a/src/plugins/designer/formeditorplugin.cpp b/src/plugins/designer/formeditorplugin.cpp index bc9f6a23337dc82a3e46ee1552d9a9a8fae44b93..823efb590d19d1be3a1ad12f6cf58247aad510e5 100644 --- a/src/plugins/designer/formeditorplugin.cpp +++ b/src/plugins/designer/formeditorplugin.cpp @@ -51,7 +51,7 @@ #include <coreplugin/coreconstants.h> #include <coreplugin/uniqueidmanager.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QDebug> #ifdef CPP_ENABLED @@ -89,25 +89,28 @@ FormEditorPlugin::~FormEditorPlugin() // INHERITED FROM ExtensionSystem::Plugin // //////////////////////////////////////////////////// -bool FormEditorPlugin::initialize(const QStringList & /*arguments*/, QString *error_message/* = 0*/) // =0; +bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error) { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/formeditor/Designer.mimetypes.xml"), error_message)) + Q_UNUSED(arguments); + Q_UNUSED(error); + + Core::ICore *core = Core::ICore::instance(); + if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/formeditor/Designer.mimetypes.xml"), error)) return false; - if (!initializeTemplates(error_message)) + if (!initializeTemplates(error)) return false; const int uid = core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR)); const QList<int> context = QList<int>() << uid; - m_factory = new FormEditorFactory(core); + m_factory = new FormEditorFactory; addObject(m_factory); // Make sure settings pages and action shortcuts are registered FormEditorW::ensureInitStage(FormEditorW::RegisterPlugins); - error_message->clear(); + error->clear(); return true; } @@ -121,24 +124,23 @@ void FormEditorPlugin::extensionsInitialized() // //////////////////////////////////////////////////// -bool FormEditorPlugin::initializeTemplates(QString * /* error_message */) +bool FormEditorPlugin::initializeTemplates(QString *error) { - - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Q_UNUSED(error); FormWizard::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); wizardParameters.setCategory(QLatin1String("Qt")); 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.")); - m_formWizard = new FormWizard(wizardParameters, core, this); + 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.")); - m_formClassWizard = new FormClassWizard(wizardParameters, core, this); + m_formClassWizard = new FormClassWizard(wizardParameters, this); addObject(m_formClassWizard); #endif return true; diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp index e302eabb3c154ad090156eff9d09f4dd2db95cb1..da8374091d5f17e6506570b6a7f122e725524287 100644 --- a/src/plugins/designer/formeditorw.cpp +++ b/src/plugins/designer/formeditorw.cpp @@ -43,6 +43,7 @@ #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/editormanager/editormanager.h> +#include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> #include <QtDesigner/QDesignerFormEditorPluginInterface> @@ -82,7 +83,6 @@ #include <QtCore/QDebug> #include <QtCore/QSettings> -enum { debugFormEditor = 0 }; enum { wantCodeGenerationAction = 0 }; static const char *editorWidgetStateKeyC = "editorWidgetState"; @@ -162,13 +162,13 @@ FormEditorW::FormEditorW() : m_formeditor(QDesignerComponents::createFormEditor(0)), m_integration(0), m_fwm(0), - m_core(ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()), + m_core(Core::ICore::instance()), m_initStage(RegisterPlugins), m_actionGroupEditMode(0), m_actionPrint(0), m_actionGenerateCode(0) { - if (debugFormEditor) + if (Designer::Constants::Internal::debug) qDebug() << Q_FUNC_INFO; QTC_ASSERT(!m_self, return); m_self = this; @@ -219,7 +219,7 @@ void FormEditorW::fullInit() { QTC_ASSERT(m_initStage == RegisterPlugins, return); QTime *initTime = 0; - if (debugFormEditor) { + if (Designer::Constants::Internal::debug) { initTime = new QTime; initTime->start(); } @@ -243,7 +243,7 @@ void FormEditorW::fullInit() } } - if (debugFormEditor) { + if (Designer::Constants::Internal::debug) { qDebug() << Q_FUNC_INFO << initTime->elapsed() << "ms"; delete initTime; } @@ -281,7 +281,7 @@ void FormEditorW::initDesignerSubWindows() void FormEditorW::ensureInitStage(InitializationStage s) { - if (debugFormEditor) + if (Designer::Constants::Internal::debug) qDebug() << Q_FUNC_INFO << s; if (!m_self) m_self = new FormEditorW; @@ -560,8 +560,9 @@ FormWindowEditor *FormEditorW::createFormWindowEditor(QWidget* parentWidget) QDesignerFormWindowInterface *form = m_fwm->createFormWindow(0); connect(form, SIGNAL(toolChanged(int)), this, SLOT(toolChanged(int))); qdesigner_internal::FormWindowBase::setupDefaultAction(form); - FormWindowEditor *fww = new FormWindowEditor(m_core, m_context, form, parentWidget); - // Store a pointer to all form windows so we can unselect all other formwindows except the active one. + FormWindowEditor *fww = new FormWindowEditor(m_context, form, parentWidget); + // Store a pointer to all form windows so we can unselect + // all other formwindows except the active one. m_formWindows.append(fww); connect(fww, SIGNAL(destroyed()), this, SLOT(editorDestroyed())); return fww; @@ -571,8 +572,8 @@ void FormEditorW::editorDestroyed() { QObject *source = sender(); - if (debugFormEditor) - qDebug() << "FormEditorW::editorDestroyed()" << source; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << source; for (EditorList::iterator it = m_formWindows.begin(); it != m_formWindows.end(); ) { if (*it == source) { @@ -586,8 +587,8 @@ void FormEditorW::editorDestroyed() void FormEditorW::currentEditorChanged(Core::IEditor *editor) { - if (debugFormEditor) - qDebug() << "FormEditorW::currentEditorChanged" << editor << " of " << m_fwm->formWindowCount(); + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << editor << " of " << m_fwm->formWindowCount(); // Deactivate Designer if a non-form is being edited if (editor && !qstrcmp(editor->kind(), Constants::C_FORMWINDOW)) { @@ -602,8 +603,8 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor) void FormEditorW::activeFormWindowChanged(QDesignerFormWindowInterface *afw) { - if (debugFormEditor) - qDebug() << "FormEditorW::activeFormWindowChanged" << afw << " of " << m_fwm->formWindowCount() << m_formWindows; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << afw << " of " << m_fwm->formWindowCount() << m_formWindows; m_fwm->closeAllPreviews(); @@ -715,7 +716,6 @@ void FormEditorW::print() painter.drawPixmap(0, 0, pixmap); m_core->mainWindow()->setCursor(oldCursor); -// m_core->statusBar()->showMessage(tr("Printed %1...").arg(QFileInfo(fw->fileName()).fileName())); } while (false); m_core->printer()->setFullPage(oldFullPage); m_core->printer()->setOrientation(oldOrientation); diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp index 1c142c483e0b086fc37c7dbbe19649c932d1ffe3..be6b763e61cdbbc0c9e13c764f4fcd05a074e26f 100644 --- a/src/plugins/designer/formwindoweditor.cpp +++ b/src/plugins/designer/formwindoweditor.cpp @@ -64,8 +64,6 @@ using ProjectExplorer::ProjectNode; using ProjectExplorer::FolderNode; using ProjectExplorer::FileNode; -enum { debugFormWindowEditor = 0 }; - class QrcFilesVisitor : public NodesVisitor { public: @@ -96,22 +94,21 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode) } -FormWindowEditor::FormWindowEditor(Core::ICore *core, - const QList<int> &context, +FormWindowEditor::FormWindowEditor(const QList<int> &context, QDesignerFormWindowInterface *form, - QObject *parent) : - Core::IEditor(parent), + QObject *parent) + : Core::IEditor(parent), m_context(context), m_formWindow(form), - m_file(new FormWindowFile(core, form, this)), + m_file(new FormWindowFile(form, this)), m_host(new FormWindowHost(form)), m_editorWidget(new EditorWidget(m_host)), m_toolBar(0), m_sessionNode(0), m_sessionWatcher(0) { - if (debugFormWindowEditor) - qDebug() << "FormWindowEditor::FormWindowEditor" << form << parent; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << form << parent; connect(m_file, SIGNAL(reload(QString)), this, SLOT(slotOpen(QString))); connect(m_file, SIGNAL(setDisplayName(QString)), this, SLOT(slotSetDisplayName(QString))); @@ -131,8 +128,8 @@ FormWindowEditor::~FormWindowEditor() delete m_toolBar; delete m_host; delete m_editorWidget; - if (debugFormWindowEditor) - qDebug() << "FormWindowEditor::~FormWindowEditor" << m_displayName; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << m_displayName; if (m_sessionNode && m_sessionWatcher) { m_sessionNode->unregisterWatcher(m_sessionWatcher); delete m_sessionWatcher; @@ -141,8 +138,8 @@ FormWindowEditor::~FormWindowEditor() bool FormWindowEditor::createNew(const QString &contents) { - if (debugFormWindowEditor) - qDebug() << "FormWindowEditor::createNew()" << contents.size() << "chars"; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << contents.size() << "chars"; if (!m_formWindow) return false; @@ -158,8 +155,8 @@ bool FormWindowEditor::createNew(const QString &contents) bool FormWindowEditor::open(const QString &fileName /*= QString()*/) { - if (debugFormWindowEditor) - qDebug() << "FormWindowEditor::open" << fileName; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << fileName; if (fileName.isEmpty()) { setDisplayName(tr("untitled")); @@ -241,8 +238,8 @@ void FormWindowEditor::slotOpen(const QString &fileName) void FormWindowEditor::slotSetDisplayName(const QString &title) { - if (debugFormWindowEditor) - qDebug() << "FormWindowEditor::slotSetDisplayName" << title; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << title; setDisplayName(title); } @@ -305,8 +302,8 @@ QWidget *FormWindowEditor::widget() bool FormWindowEditor::generateCode(QByteArray &header, QString &errorMessage) const { - if (debugFormWindowEditor) - qDebug() << "FormWindowEditor::generateCode"; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO; QString tempPattern = QDir::tempPath(); if (!tempPattern.endsWith(QDir::separator())) // platform-dependant diff --git a/src/plugins/designer/formwindoweditor.h b/src/plugins/designer/formwindoweditor.h index e448d8a6514367c1b54101e67040b03f3af36b69..6a449aeb96f2c444e9860d147504fb520b364b25 100644 --- a/src/plugins/designer/formwindoweditor.h +++ b/src/plugins/designer/formwindoweditor.h @@ -45,10 +45,6 @@ class QDesignerFormWindowManagerInterface; class QFile; QT_END_NAMESPACE -namespace Core { -class ICore; -} - namespace ProjectExplorer { class SessionNode; class NodesWatcher; @@ -60,6 +56,7 @@ namespace Internal { class FormWindowFile; class FormWindowHost; class EditorWidget; + // Master class maintaining a form window editor, // containing file and widget host @@ -68,8 +65,7 @@ class FormWindowEditor : public Core::IEditor Q_OBJECT public: - FormWindowEditor(Core::ICore *core, - const QList<int> &context, + FormWindowEditor(const QList<int> &context, QDesignerFormWindowInterface *form, QObject *parent = 0); ~FormWindowEditor(); @@ -85,7 +81,7 @@ public: void setDisplayName(const QString &title); QToolBar *toolBar(); QByteArray saveState() const; - bool restoreState(const QByteArray &/*state*/); + bool restoreState(const QByteArray &state); // ContextInterface QList<int> context() const; diff --git a/src/plugins/designer/formwindowfile.cpp b/src/plugins/designer/formwindowfile.cpp index 49387adb45b2448f99c13bb637c57ff6b7f925e9..f2d833642a40b9c668abbfe12e17fef7ad410bf5 100644 --- a/src/plugins/designer/formwindowfile.cpp +++ b/src/plugins/designer/formwindowfile.cpp @@ -53,20 +53,10 @@ using namespace Designer::Internal; using namespace Designer::Constants; using namespace SharedTools; -enum { debugFormWindowFile = 0 }; - - -FormWindowFile::FormWindowFile(Core::ICore *core, - QDesignerFormWindowInterface *form, - QObject *parent) : - Core::IFile(parent), +FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent) + : Core::IFile(parent), m_mimeType(QLatin1String(FORM_MIMETYPE)), - m_formWindow(form), - m_core(core) -{ -} - -FormWindowFile::~FormWindowFile() + m_formWindow(form) { } @@ -74,8 +64,8 @@ bool FormWindowFile::save(const QString &name /*= QString()*/) { const QString actualName = name.isEmpty() ? fileName() : name; - if (debugFormWindowFile) - qDebug() << "FormWindowFile::save" << name << "->" << actualName; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << name << "->" << actualName; if (actualName.isEmpty()) return false; @@ -125,8 +115,8 @@ bool FormWindowFile::isSaveAsAllowed() const void FormWindowFile::modified(Core::IFile::ReloadBehavior *behavior) { - if (debugFormWindowFile) - qDebug() << "FormWindowFile::modified" << m_fileName << *behavior; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << m_fileName << *behavior; switch (*behavior) { case Core::IFile::ReloadNone: @@ -141,7 +131,7 @@ void FormWindowFile::modified(Core::IFile::ReloadBehavior *behavior) break; } - switch (Core::Utils::reloadPrompt(m_fileName, m_core->mainWindow())) { + switch (Core::Utils::reloadPrompt(m_fileName, Core::ICore::instance()->mainWindow())) { case Core::Utils::ReloadCurrent: emit reload(m_fileName); break; @@ -164,8 +154,8 @@ QString FormWindowFile::defaultPath() const void FormWindowFile::setSuggestedFileName(const QString &fileName) { - if (debugFormWindowFile) - qDebug() << "FormWindowFile:setSuggestedFileName" << m_fileName << fileName; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << m_fileName << fileName; m_suggestedName = fileName; } @@ -182,8 +172,8 @@ QString FormWindowFile::mimeType() const bool FormWindowFile::writeFile(const QString &fileName, QString &errorString) const { - if (debugFormWindowFile) - qDebug() << "FormWindowFile::writeFile" << m_fileName << fileName; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << m_fileName << fileName; QFile file(fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { diff --git a/src/plugins/designer/formwindowfile.h b/src/plugins/designer/formwindowfile.h index c94e25da5b787db9f73faeba832aee5141d97759..6079cdf3251dcccd8a91fd351ca7c08c3781eb4d 100644 --- a/src/plugins/designer/formwindowfile.h +++ b/src/plugins/designer/formwindowfile.h @@ -41,31 +41,22 @@ QT_BEGIN_NAMESPACE class QDesignerFormWindowInterface; -class QDesignerFormWindowManagerInterface; class QFile; QT_END_NAMESPACE -namespace Core { -class ICore; -} - namespace Designer { namespace Internal { class FormWindowSelection; -class FormWindowFile - : public Core::IFile +class FormWindowFile : public Core::IFile { Q_OBJECT public: - FormWindowFile(Core::ICore *core, - QDesignerFormWindowInterface *form, - QObject *parent = 0); - ~FormWindowFile(); + FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent = 0); - //IFile + // IFile bool save(const QString &fileName = QString()); QString fileName() const; bool isModified() const; @@ -97,7 +88,6 @@ private: QString m_suggestedName; QDesignerFormWindowInterface *m_formWindow; - Core::ICore *m_core; }; } // namespace Internal diff --git a/src/plugins/designer/formwindowhost.cpp b/src/plugins/designer/formwindowhost.cpp index e1de87af80e7c5971caa037094ac23cf91d5cb57..a2f3da0f0f9b7b075eefb7ee3a3ceda7d1c22631 100644 --- a/src/plugins/designer/formwindowhost.cpp +++ b/src/plugins/designer/formwindowhost.cpp @@ -44,8 +44,6 @@ using namespace Designer::Internal; using namespace SharedTools; -enum { debugFormWindowHost = 0 }; - FormWindowHost::FormWindowHost(QDesignerFormWindowInterface *form, QWidget *parent) : WidgetHost(parent, form) @@ -57,14 +55,14 @@ FormWindowHost::FormWindowHost(QDesignerFormWindowInterface *form, FormWindowHost::~FormWindowHost() { - if (debugFormWindowHost) - qDebug() << "FormWindowHost::~FormWindowHost"; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO; } void FormWindowHost::formSizeChanged(int w, int h) { - if (debugFormWindowHost) - qDebug() << "FormWindowHost::formSizeChanged" << w << h; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << w << h; formWindow()->setDirty(true); static const QString geometry = QLatin1String("geometry"); diff --git a/src/plugins/designer/formwizard.cpp b/src/plugins/designer/formwizard.cpp index 4bb492ce354e49f8c7c50c97ae20cc4d416fb188..77029f6500aa18987c8d07c8916fd6383198f27c 100644 --- a/src/plugins/designer/formwizard.cpp +++ b/src/plugins/designer/formwizard.cpp @@ -36,18 +36,14 @@ #include "formwindoweditor.h" #include "designerconstants.h" -#include <coreplugin/icore.h> - #include <QtCore/QFile> #include <QtCore/QDebug> -enum { debugFormWizard = 0 }; - using namespace Designer; using namespace Designer::Internal; -FormWizard::FormWizard(const BaseFileWizardParameters ¶meters, Core::ICore *core, QObject *parent) : - Core::BaseFileWizard(parameters, core, parent) +FormWizard::FormWizard(const BaseFileWizardParameters ¶meters, QObject *parent) + : Core::BaseFileWizard(parameters, parent) { } @@ -55,7 +51,7 @@ QWizard *FormWizard::createWizardDialog(QWidget *parent, const QString &defaultPath, const WizardPageList &extensionPages) const { - FormFileWizardDialog *wizardDialog = new FormFileWizardDialog(core(), extensionPages, parent); + FormFileWizardDialog *wizardDialog = new FormFileWizardDialog(extensionPages, parent); wizardDialog->setPath(defaultPath); return wizardDialog; } diff --git a/src/plugins/designer/formwizard.h b/src/plugins/designer/formwizard.h index b49fea1eb7a838ef12653a428e637b86ef609cb4..588189dbb64ef7fd0da6fb8593acdd633cd0f430 100644 --- a/src/plugins/designer/formwizard.h +++ b/src/plugins/designer/formwizard.h @@ -36,15 +36,9 @@ #include <coreplugin/basefilewizard.h> -QT_BEGIN_NAMESPACE -class QWizard; -QT_END_NAMESPACE - namespace Designer { namespace Internal { -class FormFileWizardDialog; - class FormWizard : public Core::BaseFileWizard { Q_DISABLE_COPY(FormWizard) @@ -53,7 +47,7 @@ class FormWizard : public Core::BaseFileWizard public: typedef Core::BaseFileWizardParameters BaseFileWizardParameters; - explicit FormWizard(const BaseFileWizardParameters ¶meters, Core::ICore *core, QObject *parent); + FormWizard(const BaseFileWizardParameters ¶meters, QObject *parent); protected: virtual QWizard *createWizardDialog(QWidget *parent, diff --git a/src/plugins/designer/formwizarddialog.cpp b/src/plugins/designer/formwizarddialog.cpp index 67ed81601988220364a2b0c5f220c27389e01de7..d7905a56545df2b4befdc75f7941bcae857f71fd 100644 --- a/src/plugins/designer/formwizarddialog.cpp +++ b/src/plugins/designer/formwizarddialog.cpp @@ -50,12 +50,10 @@ namespace Designer { namespace Internal { // ----------------- FormWizardDialog -FormWizardDialog::FormWizardDialog(Core::ICore *core, - const WizardPageList &extensionPages, - QWidget *parent) : - QWizard(parent), - m_formPage(new FormTemplateWizardPagePage), - m_core(core) +FormWizardDialog::FormWizardDialog(const WizardPageList &extensionPages, + QWidget *parent) + : QWizard(parent), + m_formPage(new FormTemplateWizardPagePage) { init(extensionPages); } @@ -82,10 +80,9 @@ QString FormWizardDialog::templateContents() const } // ----------------- FormFileWizardDialog -FormFileWizardDialog::FormFileWizardDialog(Core::ICore *core, - const WizardPageList &extensionPages, - QWidget *parent) : - FormWizardDialog(core, extensionPages, parent), +FormFileWizardDialog::FormFileWizardDialog(const WizardPageList &extensionPages, + QWidget *parent) + : FormWizardDialog(extensionPages, parent), m_filePage(new Core::Utils::FileWizardPage) { setPage(FilePageId, m_filePage); diff --git a/src/plugins/designer/formwizarddialog.h b/src/plugins/designer/formwizarddialog.h index 52aaed4cd0226c8f420ef33e397ca573011799df..0ecd7274b1d1ce2fc7a3f49ff322e9a19e918f6b 100644 --- a/src/plugins/designer/formwizarddialog.h +++ b/src/plugins/designer/formwizarddialog.h @@ -37,10 +37,9 @@ #include <QtGui/QWizard> namespace Core { - class ICore; - namespace Utils { - class FileWizardPage; - } +namespace Utils { + class FileWizardPage; +} } namespace Designer { @@ -58,8 +57,7 @@ class FormWizardDialog : public QWizard public: typedef QList<QWizardPage *> WizardPageList; - explicit FormWizardDialog(Core::ICore *core, - const WizardPageList &extensionPages, + explicit FormWizardDialog(const WizardPageList &extensionPages, QWidget *parent = 0); QString templateContents() const; @@ -68,7 +66,6 @@ private: void init(const WizardPageList &extensionPages); FormTemplateWizardPagePage *m_formPage; - Core::ICore *m_core; mutable QString m_templateContents; }; @@ -82,8 +79,7 @@ class FormFileWizardDialog : public FormWizardDialog Q_OBJECT public: - explicit FormFileWizardDialog(Core::ICore *core, - const WizardPageList &extensionPages, + explicit FormFileWizardDialog(const WizardPageList &extensionPages, QWidget *parent = 0); QString path() const; diff --git a/src/plugins/designer/settingsmanager.cpp b/src/plugins/designer/settingsmanager.cpp index 3edad0921b84548b8825b778513a57a898f30dc1..a827ddf162aa6b0749c88658ed74b91f525cdfe3 100644 --- a/src/plugins/designer/settingsmanager.cpp +++ b/src/plugins/designer/settingsmanager.cpp @@ -32,26 +32,23 @@ ***************************************************************************/ #include "settingsmanager.h" +#include "designerconstants.h" #include <QtCore/QDebug> using namespace Designer::Internal; -namespace { - bool debug = false; -} - void SettingsManager::beginGroup(const QString &prefix) { - if (debug) - qDebug() << "Designer - beginning group " << addPrefix(prefix); + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << addPrefix(prefix); m_settings.beginGroup(addPrefix(prefix)); } void SettingsManager::endGroup() { - if (debug) - qDebug() << "Designer - end group"; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO; m_settings.endGroup(); } @@ -62,16 +59,16 @@ bool SettingsManager::contains(const QString &key) const void SettingsManager::setValue(const QString &key, const QVariant &value) { - if (debug) - qDebug() << "Designer - storing " << addPrefix(key) << ": " << value; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << addPrefix(key) << ": " << value; m_settings.setValue(addPrefix(key), value); } QVariant SettingsManager::value(const QString &key, const QVariant &defaultValue) const { QVariant result = m_settings.value(addPrefix(key), defaultValue); - if (debug) - qDebug() << "Designer - retrieving " << addPrefix(key) << ": " << result; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << addPrefix(key) << ": " << result; return result; } diff --git a/src/plugins/designer/workbenchintegration.cpp b/src/plugins/designer/workbenchintegration.cpp index 42043c3cd209e8e193fad67afb446ea23859c78b..6f699b838179db37ef2702cba9ab9764bfb9d957 100644 --- a/src/plugins/designer/workbenchintegration.cpp +++ b/src/plugins/designer/workbenchintegration.cpp @@ -48,6 +48,7 @@ #include <cplusplus/LookupContext.h> #include <coreplugin/icore.h> #include <coreplugin/editormanager/editormanager.h> +#include <extensionsystem/pluginmanager.h> #include <texteditor/basetexteditor.h> #include <texteditor/itexteditable.h> @@ -58,7 +59,6 @@ #include <QtCore/QFileInfo> #include <QtCore/QDebug> -enum { debugSlotNavigation = 0 }; enum { indentation = 4 }; using namespace Designer::Internal; @@ -78,8 +78,8 @@ static QString msgClassNotFound(const QString &uiClassName, const QList<Document static inline CppTools::CppModelManagerInterface *cppModelManagerInstance() { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - return core->pluginManager()->getObject<CppTools::CppModelManagerInterface>(); + return ExtensionSystem::PluginManager::instance() + ->getObject<CppTools::CppModelManagerInterface>(); } WorkbenchIntegration::WorkbenchIntegration(QDesignerFormEditorInterface *core, FormEditorW *parent) : @@ -148,7 +148,7 @@ static bool matchMemberClassName(const QString &needle, const QString &hayStack) // Find class definition in namespace static const Class *findClass(const Namespace *parentNameSpace, const QString &className, QString *namespaceName) { - if (debugSlotNavigation) + if (Designer::Constants::Internal::debug) qDebug() << Q_FUNC_INFO << className; const Overview o; @@ -486,7 +486,7 @@ static ClassDocumentPtrPair const Document::Ptr &doc, const QString &className, unsigned maxIncludeDepth, QString *namespaceName) { - if (debugSlotNavigation) + if (Designer::Constants::Internal::debug) qDebug() << Q_FUNC_INFO << doc->fileName() << maxIncludeDepth; // Check document if (const Class *cl = findClass(doc->globalNamespace(), className, namespaceName)) @@ -547,8 +547,8 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName, const CPlusPlus::Snapshot docTable = cppModelManagerInstance()->snapshot(); QList<Document::Ptr> docList = findDocumentsIncluding(docTable, uicedName, true); // change to false when we know the absolute path to generated ui_<>.h file - if (debugSlotNavigation) - qDebug() << objectName << signalSignature << "Looking for " << uicedName << " returned " << docList.size(); + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << objectName << signalSignature << "Looking for " << uicedName << " returned " << docList.size(); if (docList.isEmpty()) { *errorMessage = tr("No documents matching %1 could be found.").arg(uicedName); return false; @@ -558,7 +558,7 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName, const QString uiClass = uiClassName(fwi->mainContainer()->objectName()); - if (debugSlotNavigation) + if (Designer::Constants::Internal::debug) qDebug() << "Checking docs for " << uiClass; // Find the class definition in the file itself or in the directly @@ -586,8 +586,8 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName, const QString functionName = QLatin1String("on_") + objectName + QLatin1Char('_') + signalSignature; const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames); - if (debugSlotNavigation) - qDebug() << "Found " << uiClass << doc->fileName() << " checking " << functionName << functionNameWithParameterNames; + if (Designer::Constants::Internal::debug) + qDebug() << Q_FUNC_INFO << "Found " << uiClass << doc->fileName() << " checking " << functionName << functionNameWithParameterNames; int line = 0; Document::Ptr sourceDoc; diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 32663da298efff44ab69aaf9aa6371403fc7fd94..f6e9d7597087933bfe46bd44ca885dbac9c98f62 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -137,20 +137,20 @@ enum MoveType struct EditOperation { - EditOperation() : m_position(-1), m_itemCount(0) {} - int m_position; - int m_itemCount; // used to combine several operations - QString m_from; - QString m_to; + EditOperation() : position(-1), itemCount(0) {} + int position; + int itemCount; // used to combine several operations + QString from; + QString to; }; QDebug &operator<<(QDebug &ts, const EditOperation &op) { - if (op.m_itemCount > 0) { - ts << "\n EDIT BLOCK WITH " << op.m_itemCount << " ITEMS"; + if (op.itemCount > 0) { + ts << "\n EDIT BLOCK WITH " << op.itemCount << " ITEMS"; } else { - ts << "\n EDIT AT " << op.m_position - << "\n FROM " << op.m_from << "\n TO " << op.m_to; + ts << "\n EDIT AT " << op.position + << "\n FROM " << op.from << "\n TO " << op.to; } return ts; } @@ -367,6 +367,7 @@ bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev) quit(); return true; } + m_mode = CommandMode; return false; } @@ -1356,9 +1357,9 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0) m_tc.setPosition(positionForLine(beginLine)); EditOperation op; // FIXME: broken for "upward selection" - op.m_position = m_tc.position(); - op.m_from = text; - op.m_to = result; + op.position = m_tc.position(); + op.from = text; + op.to = result; recordOperation(op); enterCommandMode(); @@ -1748,60 +1749,52 @@ QWidget *FakeVimHandler::Private::editor() const void FakeVimHandler::Private::undo() { -#if 0 - EDITOR(undo()); -#else if (m_undoStack.isEmpty()) { showBlackMessage(tr("Already at oldest change")); } else { EditOperation op = m_undoStack.pop(); //qDebug() << "UNDO " << op; - if (op.m_itemCount > 0) { - for (int i = op.m_itemCount; --i >= 0; ) + if (op.itemCount > 0) { + for (int i = op.itemCount; --i >= 0; ) undo(); } else { - m_tc.setPosition(op.m_position, MoveAnchor); - if (!op.m_to.isEmpty()) { - m_tc.setPosition(op.m_position + op.m_to.size(), KeepAnchor); - m_tc.deleteChar(); + m_tc.setPosition(op.position, MoveAnchor); + if (!op.to.isEmpty()) { + m_tc.setPosition(op.position + op.to.size(), KeepAnchor); + m_tc.removeSelectedText(); } - if (!op.m_from.isEmpty()) - m_tc.insertText(op.m_from); - m_tc.setPosition(op.m_position, MoveAnchor); + if (!op.from.isEmpty()) + m_tc.insertText(op.from); + m_tc.setPosition(op.position, MoveAnchor); } m_redoStack.push(op); showBlackMessage(QString()); } -#endif } void FakeVimHandler::Private::redo() { -#if 0 - EDITOR(redo()); -#else if (m_redoStack.isEmpty()) { showBlackMessage(tr("Already at newest change")); } else { EditOperation op = m_redoStack.pop(); //qDebug() << "REDO " << op; - if (op.m_itemCount > 0) { - for (int i = op.m_itemCount; --i >= 0; ) + if (op.itemCount > 0) { + for (int i = op.itemCount; --i >= 0; ) redo(); } else { - m_tc.setPosition(op.m_position, MoveAnchor); - if (!op.m_from.isEmpty()) { - m_tc.setPosition(op.m_position + op.m_from.size(), KeepAnchor); - m_tc.deleteChar(); + m_tc.setPosition(op.position, MoveAnchor); + if (!op.from.isEmpty()) { + m_tc.setPosition(op.position + op.from.size(), KeepAnchor); + m_tc.removeSelectedText(); } - if (!op.m_to.isEmpty()) - m_tc.insertText(op.m_to); - m_tc.setPosition(op.m_position, MoveAnchor); + if (!op.to.isEmpty()) + m_tc.insertText(op.to); + m_tc.setPosition(op.position, MoveAnchor); } m_undoStack.push(op); showBlackMessage(QString()); } -#endif } void FakeVimHandler::Private::recordBeginGroup() @@ -1809,29 +1802,37 @@ void FakeVimHandler::Private::recordBeginGroup() //qDebug() << "PUSH"; m_undoGroupStack.push(m_undoStack.size()); EditOperation op; - op.m_position = m_tc.position(); + op.position = m_tc.position(); recordOperation(op); } void FakeVimHandler::Private::recordEndGroup() { + if (m_undoGroupStack.isEmpty()) { + qWarning("fakevim: undo groups not balanced.\n"); + return; + } EditOperation op; - op.m_itemCount = m_undoStack.size() - m_undoGroupStack.pop(); - //qDebug() << "POP " << op.m_itemCount; + op.itemCount = m_undoStack.size() - m_undoGroupStack.pop(); + //qDebug() << "POP " << op.itemCount << m_undoStack; recordOperation(op); } 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(); + //qDebug() << "POS: " << position() << " ANCHOR: " << anchor() << m_tc.anchor(); + int pos = m_tc.position(); + if (pos == anchor()) + return QString(); + m_tc.setPosition(anchor(), MoveAnchor); + m_tc.setPosition(pos, KeepAnchor); + op.position = qMin(pos, anchor()); + op.from = m_tc.selection().toPlainText(); + //qDebug() << "OP: " << op; recordOperation(op); - m_tc.deleteChar(); - return op.m_from; + m_tc.removeSelectedText(); + return op.from; } void FakeVimHandler::Private::recordRemoveNextChar() @@ -1844,15 +1845,20 @@ void FakeVimHandler::Private::recordRemoveNextChar() void FakeVimHandler::Private::recordInsertText(const QString &data) { EditOperation op; - op.m_position = m_tc.position(); - op.m_to = data; + op.position = m_tc.position(); + op.to = data; recordOperation(op); m_tc.insertText(data); } void FakeVimHandler::Private::recordOperation(const EditOperation &op) { - //qDebug() << "OP: " << op; + // No need to record operations that actually do not change anything. + if (op.from.isEmpty() && op.to.isEmpty() && op.itemCount == 0) + return; + // No need to create groups with only one member. + if (op.itemCount == 1) + return; m_undoStack.push(op); m_redoStack.clear(); } @@ -1860,16 +1866,16 @@ void FakeVimHandler::Private::recordOperation(const EditOperation &op) void FakeVimHandler::Private::recordMove(int position, int nestedCount) { EditOperation op; - op.m_position = position; - op.m_itemCount = nestedCount; + op.position = position; + op.itemCount = nestedCount; recordOperation(op); } void FakeVimHandler::Private::recordInsert(int position, const QString &data) { EditOperation op; - op.m_position = position; - op.m_to = data; + op.position = position; + op.to = data; recordOperation(op); } @@ -1884,8 +1890,8 @@ void FakeVimHandler::Private::recordRemove(int position, int length) void FakeVimHandler::Private::recordRemove(int position, const QString &data) { EditOperation op; - op.m_position = position; - op.m_from = data; + op.position = position; + op.from = data; recordOperation(op); } @@ -1894,6 +1900,7 @@ void FakeVimHandler::Private::enterInsertMode() EDITOR(setOverwriteMode(false)); m_mode = InsertMode; m_lastInsertion.clear(); + recordBeginGroup(); } void FakeVimHandler::Private::enterCommandMode() diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 1fed16416b6623225ed96181b44622e66bcf1413..a00e3878e8e795b825649b3c7e95ac03b14a4037 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -158,7 +158,7 @@ bool FakeVimPluginPrivate::initialize(const QStringList &arguments, QString *err m_handler = new FakeVimHandler; - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + m_core = Core::ICore::instance(); QTC_ASSERT(m_core, return false); Core::ActionManager *actionManager = m_core->actionManager(); @@ -177,7 +177,7 @@ bool FakeVimPluginPrivate::initialize(const QStringList &arguments, QString *err ActionContainer *advancedMenu = actionManager->actionContainer(Core::Constants::M_EDIT_ADVANCED); - advancedMenu->addAction(cmd); + advancedMenu->addAction(cmd, Core::Constants::G_EDIT_EDITOR); connect(m_installHandlerAction, SIGNAL(triggered()), this, SLOT(installHandler())); diff --git a/src/plugins/find/currentdocumentfind.cpp b/src/plugins/find/currentdocumentfind.cpp index b51504db7dfe803545f1eace2b54be5063a9ebdb..7c9532eb17f29a4ef42bd0de8685f074ca870689 100644 --- a/src/plugins/find/currentdocumentfind.cpp +++ b/src/plugins/find/currentdocumentfind.cpp @@ -45,8 +45,8 @@ using namespace Core; using namespace Find; using namespace Find::Internal; -CurrentDocumentFind::CurrentDocumentFind(ICore *core) - : m_core(core), m_currentFind(0) +CurrentDocumentFind::CurrentDocumentFind() + : m_currentFind(0) { connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(updateCurrentFindFilter(QWidget*,QWidget*))); diff --git a/src/plugins/find/currentdocumentfind.h b/src/plugins/find/currentdocumentfind.h index 2f41acbe7b023fe2af9af03d8858e85089ed6af6..c5674db66325f6277cff1a594fabf288e953071d 100644 --- a/src/plugins/find/currentdocumentfind.h +++ b/src/plugins/find/currentdocumentfind.h @@ -36,8 +36,6 @@ #include "ifindfilter.h" -#include <coreplugin/icore.h> - #include <QtCore/QPointer> #include <QtGui/QWidget> @@ -49,7 +47,7 @@ class CurrentDocumentFind : public QObject Q_OBJECT public: - CurrentDocumentFind(Core::ICore *core); + CurrentDocumentFind(); void resetIncrementalSearch(); void clearResults(); @@ -83,7 +81,6 @@ private slots: private: void removeFindSupportConnections(); - Core::ICore *m_core; QPointer<IFindSupport> m_currentFind; QPointer<QWidget> m_currentWidget; }; diff --git a/src/plugins/find/findplugin.cpp b/src/plugins/find/findplugin.cpp index b3c417debd303d27add21fc4a84be0730e1aa182..879acc7bda321b993582512d065db4b9a7b26214 100644 --- a/src/plugins/find/findplugin.cpp +++ b/src/plugins/find/findplugin.cpp @@ -42,10 +42,13 @@ #include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/command.h> #include <coreplugin/coreconstants.h> +#include <coreplugin/icore.h> + +#include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QSettings> Q_DECLARE_METATYPE(Find::IFindFilter*) @@ -58,8 +61,7 @@ using namespace Find; using namespace Find::Internal; FindPlugin::FindPlugin() - : m_core(0), - m_currentDocumentFind(0), + : m_currentDocumentFind(0), m_findToolBar(0), m_findDialog(0), m_findCompletionModel(new QStringListModel(this)), @@ -76,14 +78,13 @@ FindPlugin::~FindPlugin() bool FindPlugin::initialize(const QStringList &, QString *) { - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); setupMenu(); - m_currentDocumentFind = new CurrentDocumentFind(m_core); + m_currentDocumentFind = new CurrentDocumentFind; m_findToolBar = new FindToolBar(this, m_currentDocumentFind); m_findDialog = new FindToolWindow(this); - SearchResultWindow *searchResultWindow = new SearchResultWindow(m_core); + SearchResultWindow *searchResultWindow = new SearchResultWindow; addAutoReleasedObject(searchResultWindow); return true; } @@ -123,10 +124,9 @@ void FindPlugin::openFindFilter() m_findDialog->open(filter); } - void FindPlugin::setupMenu() { - Core::ActionManager *am = m_core->actionManager(); + Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *medit = am->actionContainer(Core::Constants::M_EDIT); Core::ActionContainer *mfind = am->createMenu(Constants::M_FIND); medit->addMenu(mfind, Core::Constants::G_EDIT_FIND); @@ -149,7 +149,7 @@ void FindPlugin::setupMenu() void FindPlugin::setupFilterMenuItems() { - Core::ActionManager *am = m_core->actionManager(); + Core::ActionManager *am = Core::ICore::instance()->actionManager(); QList<IFindFilter*> findInterfaces = ExtensionSystem::PluginManager::instance()->getObjects<IFindFilter>(); Core::Command *cmd; @@ -171,11 +171,6 @@ void FindPlugin::setupFilterMenuItems() m_findDialog->setFindFilters(findInterfaces); } -Core::ICore *FindPlugin::core() -{ - return m_core; -} - QTextDocument::FindFlags FindPlugin::findFlags() const { return m_findFlags; @@ -216,7 +211,7 @@ bool FindPlugin::hasFindFlag(QTextDocument::FindFlag flag) void FindPlugin::writeSettings() { - QSettings *settings = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->settings(); + QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("Find"); settings->setValue("Backward", QVariant((m_findFlags & QTextDocument::FindBackward) != 0)); settings->setValue("CaseSensitively", QVariant((m_findFlags & QTextDocument::FindCaseSensitively) != 0)); @@ -229,7 +224,7 @@ void FindPlugin::writeSettings() void FindPlugin::readSettings() { - QSettings *settings = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->settings(); + QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("Find"); bool block = blockSignals(true); setBackward(settings->value("Backward", false).toBool()); diff --git a/src/plugins/find/findplugin.h b/src/plugins/find/findplugin.h index caad6daa0cc3be4d52181a4a9f630a9a43c48208..28639476b950ef80afeebcc1f4256f71bf24a930 100644 --- a/src/plugins/find/findplugin.h +++ b/src/plugins/find/findplugin.h @@ -38,7 +38,6 @@ #include "ifindfilter.h" #include "findtoolbar.h" -#include <coreplugin/icore.h> #include <extensionsystem/iplugin.h> #include <QtCore/QHash> @@ -64,7 +63,6 @@ public: void extensionsInitialized(); void shutdown(); - Core::ICore *core(); QTextDocument::FindFlags findFlags() const; void updateFindCompletion(const QString &text); void updateReplaceCompletion(const QString &text); @@ -93,7 +91,6 @@ private: void readSettings(); //variables - Core::ICore *m_core; QHash<IFindFilter *, QAction *> m_filterActions; CurrentDocumentFind *m_currentDocumentFind; diff --git a/src/plugins/find/findtoolbar.cpp b/src/plugins/find/findtoolbar.cpp index 323fdbac58cbca395ba34409b204e22ae8d45c24..a8d9653160453488d20b987550c9ba27c241cd4a 100644 --- a/src/plugins/find/findtoolbar.cpp +++ b/src/plugins/find/findtoolbar.cpp @@ -37,20 +37,24 @@ #include <coreplugin/coreconstants.h> #include <coreplugin/findplaceholder.h> +#include <coreplugin/icore.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/command.h> +#include <extensionsystem/pluginmanager.h> + +#include <QtCore/QDebug> #include <QtCore/QSettings> -#include <QtGui/QPushButton> -#include <QtGui/QMenu> -#include <QtGui/QToolButton> -#include <QtGui/QLineEdit> -#include <QtGui/QKeyEvent> + #include <QtGui/QClipboard> -#include <QtGui/QPainter> #include <QtGui/QCompleter> -#include <QDebug> +#include <QtGui/QKeyEvent> +#include <QtGui/QLineEdit> +#include <QtGui/QMenu> +#include <QtGui/QPainter> +#include <QtGui/QPushButton> +#include <QtGui/QToolButton> Q_DECLARE_METATYPE(QStringList) Q_DECLARE_METATYPE(Find::IFindFilter*) @@ -138,7 +142,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen QList<int> globalcontext; globalcontext << Core::Constants::C_GLOBAL_ID; - Core::ActionManager *am = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->actionManager(); + Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *mfind = am->actionContainer(Constants::M_FIND); Core::Command *cmd; diff --git a/src/plugins/find/findtoolwindow.cpp b/src/plugins/find/findtoolwindow.cpp index f45c99b2aa313e963ff0d11d4b98d4a18bb0d42c..f9f23d0668f3094d6e8c893ac821542f120f1011 100644 --- a/src/plugins/find/findtoolwindow.cpp +++ b/src/plugins/find/findtoolwindow.cpp @@ -42,7 +42,7 @@ using namespace Find; using namespace Find::Internal; FindToolWindow::FindToolWindow(FindPlugin *plugin) - : QDialog(plugin->core()->mainWindow()), + : QDialog(Core::ICore::instance()->mainWindow()), m_plugin(plugin), m_findCompleter(new QCompleter(this)) { @@ -124,7 +124,7 @@ void FindToolWindow::search() void FindToolWindow::writeSettings() { - QSettings *settings = m_plugin->core()->settings(); + QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("Find"); foreach (IFindFilter *filter, m_filters) filter->writeSettings(settings); @@ -133,7 +133,7 @@ void FindToolWindow::writeSettings() void FindToolWindow::readSettings() { - QSettings *settings = m_plugin->core()->settings(); + QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("Find"); foreach (IFindFilter *filter, m_filters) filter->readSettings(settings); diff --git a/src/plugins/find/searchresultwindow.cpp b/src/plugins/find/searchresultwindow.cpp index 57cd669515b6a2a49f6ac8d9d5de03990d6f0192..a979e9b39c9f691223ba22ec485284433301f3ae 100644 --- a/src/plugins/find/searchresultwindow.cpp +++ b/src/plugins/find/searchresultwindow.cpp @@ -34,6 +34,8 @@ #include "searchresultwindow.h" #include "searchresulttreemodel.h" +#include <coreplugin/icore.h> + #include <QtCore/QFile> #include <QtCore/QTextStream> #include <QtCore/QSettings> @@ -46,10 +48,9 @@ using namespace Find::Internal; static const QString SETTINGSKEYSECTIONNAME("SearchResults"); static const QString SETTINGSKEYEXPANDRESULTS("ExpandResults"); -SearchResultWindow::SearchResultWindow(Core::ICore *core) : - m_core(core), - m_widget(new QStackedWidget()) +SearchResultWindow::SearchResultWindow() { + m_widget = new QStackedWidget; m_widget->setWindowTitle(name()); m_searchResultTreeView = new SearchResultTreeView(m_widget); @@ -173,8 +174,8 @@ void SearchResultWindow::handleExpandCollapseToolButton(bool checked) void SearchResultWindow::readSettings(void) { - if (m_core && m_core->settings()) { - QSettings *s = m_core->settings(); + QSettings *s = Core::ICore::instance()->settings(); + if (s) { s->beginGroup(SETTINGSKEYSECTIONNAME); m_expandCollapseToolButton->setChecked(s->value(SETTINGSKEYEXPANDRESULTS, m_initiallyExpand).toBool()); s->endGroup(); @@ -183,8 +184,8 @@ void SearchResultWindow::readSettings(void) void SearchResultWindow::writeSettings(void) { - if (m_core && m_core->settings()) { - QSettings *s = m_core->settings(); + QSettings *s = Core::ICore::instance()->settings(); + if (s) { s->beginGroup(SETTINGSKEYSECTIONNAME); s->setValue(SETTINGSKEYEXPANDRESULTS, m_expandCollapseToolButton->isChecked()); s->endGroup(); diff --git a/src/plugins/find/searchresultwindow.h b/src/plugins/find/searchresultwindow.h index c167727ea057781db090c7f10ec75f432e7ba82d..e7923b5cc8c5628764dd19a10e924913f6a05d72 100644 --- a/src/plugins/find/searchresultwindow.h +++ b/src/plugins/find/searchresultwindow.h @@ -38,7 +38,6 @@ #include "searchresulttreeview.h" #include <coreplugin/ioutputpane.h> -#include <coreplugin/icore.h> #include <QtCore/QThread> #include <QtCore/QStringList> @@ -65,7 +64,7 @@ class FIND_EXPORT SearchResultWindow : public Core::IOutputPane Q_OBJECT public: - SearchResultWindow(Core::ICore *core); + SearchResultWindow(); ~SearchResultWindow(); QWidget *outputWidget(QWidget *); @@ -97,7 +96,6 @@ private: Internal::SearchResultTreeView *m_searchResultTreeView; QListWidget *m_noMatchesFoundDisplay; - Core::ICore *m_core; QToolButton *m_expandCollapseToolButton; static const bool m_initiallyExpand = false; QStackedWidget *m_widget; diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 81820b8fa0fbb5097e207c9e7b11f07b8d8dcf25..fe2394c019ddcaec6753e93d7c0f9724fe4b5d0a 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -97,10 +97,10 @@ static QString formatCommand(const QString &binary, const QStringList &args) } // ---------------- GitClient -GitClient::GitClient(GitPlugin* plugin, Core::ICore *core) : - m_msgWait(tr("Waiting for data...")), +GitClient::GitClient(GitPlugin* plugin) + : m_msgWait(tr("Waiting for data...")), m_plugin(plugin), - m_core(core) + m_core(Core::ICore::instance()) { if (QSettings *s = m_core->settings()) m_settings.fromSettings(s); @@ -178,7 +178,7 @@ VCSBase::VCSBaseEditor QTC_ASSERT(rc, return 0); rc->setSource(source); if (setSourceCodec) - rc->setCodec(VCSBase::VCSBaseEditor::getCodec(m_core, source)); + rc->setCodec(VCSBase::VCSBaseEditor::getCodec(source)); } return rc; } diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index aa4ad97015ae3c2360fb5c460dd047a0bb9ae26c..c920ffc1b32f2e6626789553c520ac004faa8974 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -68,7 +68,7 @@ class GitClient : public QObject Q_OBJECT public: - explicit GitClient(GitPlugin *plugin, Core::ICore *core); + explicit GitClient(GitPlugin *plugin); ~GitClient(); bool managesDirectory(const QString &) const { return false; } diff --git a/src/plugins/git/gitcommand.cpp b/src/plugins/git/gitcommand.cpp index 703e42a8668520b083ac0c92f98bd176b22e08f6..fa62401b0119c1d22f789935af2b9a7ab2d3ec74 100644 --- a/src/plugins/git/gitcommand.cpp +++ b/src/plugins/git/gitcommand.cpp @@ -36,6 +36,7 @@ #include <coreplugin/icore.h> #include <coreplugin/progressmanager/progressmanager.h> +#include <extensionsystem/pluginmanager.h> #include <QtCore/QDebug> #include <QtCore/QProcess> @@ -83,8 +84,7 @@ void GitCommand::execute() QFuture<void> task = QtConcurrent::run(this, &GitCommand::run); const QString taskName = QLatin1String("Git ") + m_jobs.front().arguments.at(0); - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - core->progressManager()->addTask(task, taskName, + Core::ICore::instance()->progressManager()->addTask(task, taskName, QLatin1String("Git.action"), Core::ProgressManager::CloseOnSuccess); } diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index e71ccfea45e7b1cda9cfcf4b9b0141d83f14e18a..11823909585901a621faa645e81e33634af047b6 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -49,6 +49,7 @@ #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/editormanager/editormanager.h> +#include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> @@ -56,11 +57,11 @@ #include <vcsbase/vcsbaseeditor.h> #include <vcsbase/basevcssubmiteditorfactory.h> -#include <QtCore/qplugin.h> #include <QtCore/QDebug> #include <QtCore/QDir> #include <QtCore/QFileInfo> #include <QtCore/QTemporaryFile> +#include <QtCore/QtPlugin> #include <QtGui/QAction> #include <QtGui/QFileDialog> @@ -231,12 +232,11 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *error_message) Q_UNUSED(arguments); Q_UNUSED(error_message); - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - m_gitClient = new GitClient(this, m_core); + m_core = Core::ICore::instance(); + m_gitClient = new GitClient(this); // Create the globalcontext list to register actions accordingly QList<int> globalcontext; - globalcontext << m_core->uniqueIDManager()-> - uniqueIdentifier(Core::Constants::C_GLOBAL); + globalcontext << m_core->uniqueIDManager()->uniqueIdentifier(Core::Constants::C_GLOBAL); // Create the output Window m_outputWindow = new GitOutputWindow(); @@ -249,7 +249,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *error_message) static const char *describeSlot = SLOT(show(QString,QString)); const int editorCount = sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters); for (int i = 0; i < editorCount; i++) { - m_editorFactories.push_back(new GitEditorFactory(editorParameters + i, m_core, m_gitClient, describeSlot)); + m_editorFactories.push_back(new GitEditorFactory(editorParameters + i, m_gitClient, describeSlot)); addObject(m_editorFactories.back()); } @@ -621,7 +621,7 @@ void GitPlugin::startCommit() Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd) { - Core::IEditor *editor = m_core->editorManager()->openEditor(fileName, QLatin1String(Constants::GITSUBMITEDITOR_KIND)); + Core::IEditor *editor = m_core->editorManager()->openEditor(fileName, QLatin1String(Constants::GITSUBMITEDITOR_KIND)); if (Git::Constants::debug) qDebug() << Q_FUNC_INFO << fileName << editor; m_core->editorManager()->ensureEditorManagerVisible(); diff --git a/src/plugins/helloworld/helloworldplugin.cpp b/src/plugins/helloworld/helloworldplugin.cpp index 6dd0bc9c63f9feb9d65e007fa9789008f8dd0197..522984a9814c7de6b7379a22d17200eb2c9510dd 100644 --- a/src/plugins/helloworld/helloworldplugin.cpp +++ b/src/plugins/helloworld/helloworldplugin.cpp @@ -39,7 +39,6 @@ #include <coreplugin/icore.h> #include <coreplugin/modemanager.h> #include <coreplugin/uniqueidmanager.h> -#include <extensionsystem/pluginmanager.h> #include <QtCore/QDebug> #include <QtCore/QtPlugin> @@ -78,7 +77,7 @@ bool HelloWorldPlugin::initialize(const QStringList &arguments, QString *error_m Q_UNUSED(error_message) // Get the primary access point to the workbench. - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); // Create a unique context id for our own view, that will be used for the // menu entry later. diff --git a/src/plugins/helloworld/helloworldplugin.h b/src/plugins/helloworld/helloworldplugin.h index 8aa2a9aa127cef0aa00a6d571be54bba05da1fec..36c60165a326dd54993d7b624d08dca2384f2dcd 100644 --- a/src/plugins/helloworld/helloworldplugin.h +++ b/src/plugins/helloworld/helloworldplugin.h @@ -36,8 +36,6 @@ #include <extensionsystem/iplugin.h> -#include <QtCore/QObject> - namespace HelloWorld { namespace Internal { diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 74900b6acee27f50eef532f6f56d10060f3d183c..a22cc1f5105850a96bbde8088458938e069e67ee 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -123,9 +123,11 @@ HelpPlugin::~HelpPlugin() { } -bool HelpPlugin::initialize(const QStringList & /*arguments*/, QString *) +bool HelpPlugin::initialize(const QStringList &arguments, QString *error) { - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Q_UNUSED(arguments); + Q_UNUSED(error); + m_core = Core::ICore::instance(); QList<int> globalcontext; globalcontext << Core::Constants::C_GLOBAL_ID; QList<int> modecontext; diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 1b9c7e094d1082c3e9f8a94c80f585024fc7eca2..7d126c4bb945fcf2356c5c0aef063480b3b0d1e7 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -51,13 +51,14 @@ #include <coreplugin/messagemanager.h> #include <coreplugin/mimedatabase.h> #include <coreplugin/uniqueidmanager.h> +#include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> #include <utils/synchronousprocess.h> #include <vcsbase/basevcseditorfactory.h> #include <vcsbase/basevcssubmiteditorfactory.h> #include <vcsbase/vcsbaseeditor.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QDebug> #include <QtCore/QDir> #include <QtCore/QFileInfo> @@ -144,7 +145,6 @@ bool CoreListener::editorAboutToClose(Core::IEditor *editor) // PerforcePlugin //// -Core::ICore *PerforcePlugin::m_coreInstance = NULL; PerforcePlugin *PerforcePlugin::m_perforcePluginInstance = NULL; PerforcePlugin::PerforcePlugin() : @@ -182,17 +182,20 @@ static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = { Perforce::Constants::C_PERFORCESUBMITEDITOR }; -bool PerforcePlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) +bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMessage) { + Q_UNUSED(arguments); + Q_UNUSED(errorMessage); + typedef VCSBase::VCSEditorFactory<PerforceEditor> PerforceEditorFactory; typedef VCSBase::VCSSubmitEditorFactory<PerforceSubmitEditor> PerforceSubmitEditorFactory; - m_coreInstance = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - if (!m_coreInstance->mimeDatabase()->addMimeTypes(QLatin1String(":/trolltech.perforce/Perforce.mimetypes.xml"), errorMessage)) + Core::ICore *core = Core::ICore::instance(); + if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/trolltech.perforce/Perforce.mimetypes.xml"), errorMessage)) return false; m_perforcePluginInstance = this; - if (QSettings *settings = m_coreInstance->settings()) + if (QSettings *settings = core->settings()) m_settings.fromSettings(settings); m_perforceOutputWindow = new PerforceOutputWindow(this); @@ -208,24 +211,19 @@ bool PerforcePlugin::initialize(const QStringList & /*arguments*/, QString *erro static const char *describeSlot = SLOT(describe(QString,QString)); const int editorCount = sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters); for (int i = 0; i < editorCount; i++) { - m_editorFactories.push_back(new PerforceEditorFactory(editorParameters + i, m_coreInstance, this, describeSlot)); + m_editorFactories.push_back(new PerforceEditorFactory(editorParameters + i, this, describeSlot)); addObject(m_editorFactories.back()); } m_versionControl = new PerforceVersionControl(this); addObject(m_versionControl); -#ifdef USE_P4_API - m_workbenchClientUser = new WorkbenchClientUser(m_perforceOutputWindow, this); - m_enableP4APIActions = true; -#endif - m_coreListener = new CoreListener(this); addObject(m_coreListener); //register actions - Core::ActionManager *am = m_coreInstance->actionManager(); + Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS); @@ -243,8 +241,8 @@ bool PerforcePlugin::initialize(const QStringList & /*arguments*/, QString *erro globalcontext << Core::Constants::C_GLOBAL_ID; QList<int> perforcesubmitcontext; - perforcesubmitcontext << - m_coreInstance->uniqueIDManager()->uniqueIdentifier(Constants::C_PERFORCESUBMITEDITOR); + perforcesubmitcontext << Core::UniqueIDManager::instance()-> + uniqueIdentifier(Constants::C_PERFORCESUBMITEDITOR); Core::Command *command; QAction *tmpaction; @@ -382,10 +380,10 @@ bool PerforcePlugin::initialize(const QStringList & /*arguments*/, QString *erro m_redoAction = new QAction(tr("&Redo"), this); command = am->registerAction(m_redoAction, Core::Constants::REDO, perforcesubmitcontext); - connect(m_coreInstance, SIGNAL(contextChanged(Core::IContext *)), + connect(core, SIGNAL(contextChanged(Core::IContext *)), this, SLOT(updateActions())); - connect(m_coreInstance->fileManager(), SIGNAL(currentFileChanged(const QString &)), + connect(core->fileManager(), SIGNAL(currentFileChanged(const QString &)), this, SLOT(updateActions())); return true; @@ -419,10 +417,8 @@ void PerforcePlugin::deleteCurrentFile() void PerforcePlugin::revertCurrentFile() { - QTC_ASSERT(m_coreInstance, return); - const QString fileName = currentFileName(); - QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, fileName); + QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(fileName); QStringList args; args << QLatin1String("diff") << QLatin1String("-sa"); PerforceResponse result = runP4Cmd(args, QStringList(), CommandToWindow|StdErrToWindow|ErrorToWindow, codec); @@ -438,7 +434,7 @@ void PerforcePlugin::revertCurrentFile() return; } - Core::FileManager *fm = m_coreInstance->fileManager(); + Core::FileManager *fm = Core::ICore::instance()->fileManager(); QList<Core::IFile *> files = fm->managedFiles(fileName); foreach (Core::IFile *file, files) { fm->blockFileChange(file); @@ -471,7 +467,7 @@ void PerforcePlugin::diffAllOpened() void PerforcePlugin::printOpenedFileList() { - Core::IEditor *e = m_coreInstance->editorManager()->currentEditor(); + Core::IEditor *e = Core::EditorManager::instance()->currentEditor(); if (e) e->widget()->setFocus(); PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("opened"), QStringList(), CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow); @@ -487,8 +483,6 @@ void PerforcePlugin::resolve() void PerforcePlugin::submit() { - QTC_ASSERT(m_coreInstance, return); - if (!checkP4Command()) { showOutput(tr("No p4 executable specified!"), true); return; @@ -548,9 +542,9 @@ void PerforcePlugin::submit() Core::IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames) { - Core::IEditor *editor = - m_coreInstance->editorManager()->openEditor(fileName, Constants::PERFORCESUBMITEDITOR_KIND); - m_coreInstance->editorManager()->ensureEditorManagerVisible(); + Core::EditorManager *editorManager = Core::EditorManager::instance(); + Core::IEditor *editor = editorManager->openEditor(fileName, Constants::PERFORCESUBMITEDITOR_KIND); + editorManager->ensureEditorManagerVisible(); PerforceSubmitEditor *submitEditor = dynamic_cast<PerforceSubmitEditor*>(editor); QTC_ASSERT(submitEditor, return 0); submitEditor->restrictToProjectFiles(depotFileNames); @@ -562,7 +556,7 @@ Core::IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName, void PerforcePlugin::printPendingChanges() { qApp->setOverrideCursor(Qt::WaitCursor); - PendingChangesDialog dia(pendingChangesData(), m_coreInstance->mainWindow()); + PendingChangesDialog dia(pendingChangesData(), Core::ICore::instance()->mainWindow()); qApp->restoreOverrideCursor(); if (dia.exec() == QDialog::Accepted) { const int i = dia.changeNumber(); @@ -595,14 +589,15 @@ void PerforcePlugin::annotate() void PerforcePlugin::annotate(const QString &fileName) { - QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, fileName); + QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(fileName); QStringList args; args << QLatin1String("annotate") << QLatin1String("-cqi") << fileName; const PerforceResponse result = runP4Cmd(args, QStringList(), CommandToWindow|StdErrToWindow|ErrorToWindow, codec); if (!result.error) { const QFileInfo fi(fileName); - showOutputInEditor(tr("p4 annotate %1").arg(fi.fileName()), result.stdOut, VCSBase::AnnotateOutput, codec); + showOutputInEditor(tr("p4 annotate %1").arg(fi.fileName()), + result.stdOut, VCSBase::AnnotateOutput, codec); } } @@ -622,14 +617,15 @@ void PerforcePlugin::filelog() void PerforcePlugin::filelog(const QString &fileName) { - QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, fileName); + QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(fileName); QStringList args; args << QLatin1String("filelog") << QLatin1String("-li") << fileName; const PerforceResponse result = runP4Cmd(args, QStringList(), CommandToWindow|StdErrToWindow|ErrorToWindow, codec); if (!result.error) { const QFileInfo fi(fileName); - showOutputInEditor(tr("p4 filelog %1").arg(fi.fileName()), result.stdOut, VCSBase::LogOutput, codec); + showOutputInEditor(tr("p4 filelog %1").arg(fi.fileName()), + result.stdOut, VCSBase::LogOutput, codec); } } @@ -751,7 +747,6 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args, qDebug() << "PerforcePlugin::runP4Cmd" << args << extraArgs << debugCodec(outputCodec); PerforceResponse response; response.error = true; - QTC_ASSERT(m_coreInstance, return response); if (!checkP4Command()) { response.message = tr("No p4 executable specified!"); m_perforceOutputWindow->append(response.message, true); @@ -846,9 +841,9 @@ Core::IEditor * PerforcePlugin::showOutputInEditor(const QString& title, const Q if (Perforce::Constants::debug) qDebug() << "PerforcePlugin::showOutputInEditor" << title << kind << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); QString s = title; - Core::IEditor *ediface = m_coreInstance->editorManager()-> + Core::IEditor *editor = Core::EditorManager::instance()-> newFile(kind, &s, output.toLocal8Bit()); - PerforceEditor *e = qobject_cast<PerforceEditor*>(ediface->widget()); + PerforceEditor *e = qobject_cast<PerforceEditor*>(editor->widget()); if (!e) return 0; s.replace(QLatin1Char(' '), QLatin1Char('_')); @@ -862,7 +857,7 @@ QStringList PerforcePlugin::environment() const { QStringList newEnv = QProcess::systemEnvironment(); const QString name = "P4DIFF"; - for (int i=0; i<newEnv.count(); ++i) { + for (int i = 0; i < newEnv.count(); ++i) { if (newEnv.at(i).startsWith(name)) { newEnv.removeAt(i); return newEnv; @@ -881,7 +876,7 @@ void PerforcePlugin::p4Diff(const QStringList &files, QString diffname) Core::IEditor *editor = 0; bool displayInEditor = true; Core::IEditor *existingEditor = 0; - QTextCodec *codec = files.empty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditor::getCodec(m_coreInstance, files.front()); + QTextCodec *codec = files.empty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditor::getCodec(files.front()); if (Perforce::Constants::debug) qDebug() << Q_FUNC_INFO << files << debugCodec(codec); @@ -894,7 +889,7 @@ void PerforcePlugin::p4Diff(const QStringList &files, QString diffname) diffname = fi.fileName(); } - foreach (Core::IEditor *ed, m_coreInstance->editorManager()->openedEditors()) { + foreach (Core::IEditor *ed, Core::EditorManager::instance()->openedEditors()) { if (ed->property("originalFileName").toString() == fileName) { existingEditor = ed; displayInEditor = false; @@ -917,7 +912,7 @@ void PerforcePlugin::p4Diff(const QStringList &files, QString diffname) } else if (!displayInEditor && existingEditor) { if (existingEditor) { existingEditor->createNew(result.stdOut); - m_coreInstance->editorManager()->setCurrentEditor(existingEditor); + Core::EditorManager::instance()->setCurrentEditor(existingEditor); } } } @@ -925,7 +920,7 @@ void PerforcePlugin::p4Diff(const QStringList &files, QString diffname) void PerforcePlugin::describe(const QString & source, const QString &n) { - QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditor::getCodec(m_coreInstance, source); + QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditor::getCodec(source); QStringList args; args << QLatin1String("describe") << QLatin1String("-du") << n; const PerforceResponse result = runP4Cmd(args, QStringList(), CommandToWindow|StdErrToWindow|ErrorToWindow, codec); @@ -935,29 +930,32 @@ void PerforcePlugin::describe(const QString & source, const QString &n) void PerforcePlugin::submitCurrentLog() { - m_coreInstance->editorManager()->closeEditors(QList<Core::IEditor*>() - << m_coreInstance->editorManager()->currentEditor()); + Core::EditorManager *em = Core::EditorManager::instance(); + em->closeEditors(QList<Core::IEditor*>() << em->currentEditor()); } bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor) { if (!m_changeTmpFile || !editor) return true; + Core::ICore *core = Core::ICore::instance(); Core::IFile *fileIFace = editor->file(); if (!fileIFace) return true; QFileInfo editorFile(fileIFace->fileName()); QFileInfo changeFile(m_changeTmpFile->fileName()); if (editorFile.absoluteFilePath() == changeFile.absoluteFilePath()) { - const QMessageBox::StandardButton answer = QMessageBox::question(m_coreInstance->mainWindow(), tr("Closing p4 Editor"), tr("Do you want to submit this change list?"), - QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, QMessageBox::Yes); - if (answer == QMessageBox::Cancel) { + const QMessageBox::StandardButton answer = + QMessageBox::question(core->mainWindow(), + tr("Closing p4 Editor"), + tr("Do you want to submit this change list?"), + QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, QMessageBox::Yes); + if (answer == QMessageBox::Cancel) return false; - } - m_coreInstance->fileManager()->blockFileChange(fileIFace); + core->fileManager()->blockFileChange(fileIFace); fileIFace->save(); - m_coreInstance->fileManager()->unblockFileChange(fileIFace); + core->fileManager()->unblockFileChange(fileIFace); if (answer == QMessageBox::Yes) { QByteArray change = m_changeTmpFile->readAll(); m_changeTmpFile->close(); @@ -1006,15 +1004,14 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor) void PerforcePlugin::openFiles(const QStringList &files) { - foreach (QString s, files) { - m_coreInstance->editorManager()->openEditor(clientFilePath(s)); - } - m_coreInstance->editorManager()->ensureEditorManagerVisible(); + Core::EditorManager *em = Core::EditorManager::instance(); + foreach (const QString &s, files) + em->openEditor(clientFilePath(s)); + em->ensureEditorManagerVisible(); } QString PerforcePlugin::clientFilePath(const QString &serverFilePath) { - QTC_ASSERT(m_coreInstance, return QString()); if (!checkP4Command()) return QString(); @@ -1040,7 +1037,7 @@ QString PerforcePlugin::clientFilePath(const QString &serverFilePath) QString PerforcePlugin::currentFileName() { - QString fileName = m_coreInstance->fileManager()->currentFile(); + QString fileName = Core::ICore::instance()->fileManager()->currentFile(); // TODO: Use FileManager::fixPath const QFileInfo fileInfo(fileName); @@ -1068,67 +1065,9 @@ bool PerforcePlugin::checkP4Command() const return true; } -#ifdef USE_P4_API -void PerforcePlugin::runP4APICmd(const QString &cmd, const QStringList &args) -{ - m_enableP4APIActions = false; - updateActions(); - - ClientApi client; - if (!m_settings.defaultEnv) { - client.SetClient(m_settings.p4Client.toLatin1().constData()); - client.SetPort(m_settings.p4Port.toLatin1().constData()); - client.SetUser(m_settings.p4User.toLatin1().constData()); - } - - Error err; - m_coreInstance->messageManager()->displayStatusBarMessage(tr("Connecting to p4 server...")); - client.SetProtocol("api", "56"); - client.Init(&err); - if (err.Test()) { - StrBuf msg; - err.Fmt(&msg); - QMessageBox::critical(m_coreInstance->mainWindow(), tr("Perforce Plugin"), tr("Failed to connect to p4 server <b>%1</b>!").arg(msg.Text())); - client.Final(&err); - m_coreInstance->messageManager()->displayStatusBarMessage(tr("Connection to p4 server failed!"), 3000); - return; - } - m_coreInstance->messageManager()->displayStatusBarMessage(tr("Connection to p4 server established."), 3000); - - // ???? - //client.SetCwd("c:\\depot\\research\\qworkbench\\src"); - - int argc = args.count(); - char **argv = (char**)malloc(argc*sizeof(char*)); - int i = 0; - foreach (QString s, args) - argv[i++] = qstrdup(s.toLatin1().constData()); - - client.SetArgv( argc, argv ); - try { - client.Run(cmd.toLatin1().constData(), m_workbenchClientUser); - } catch (...) { - QMessageBox::critical(m_coreInstance->mainWindow(), tr("Perforce Plugin"), tr("Failed to run command <b>%1</b>!").arg(cmd)); - } - client.Final(&err); - i = 0; - while (i<argc) - free(argv[i++]); - free(argv); - - m_enableP4APIActions = true; - updateActions(); - - Core::IEditor *edt = m_coreInstance->editorManager()->currentEditor(); - if (edt && edt->widget()) - edt->widget()->setFocus(); -} -#endif - QString PerforcePlugin::pendingChangesData() { QString data; - Q_ASSERT(m_coreInstance); if (!checkP4Command()) return data; @@ -1168,22 +1107,18 @@ PerforcePlugin::~PerforcePlugin() m_settingsPage = 0; } -#ifdef USE_P4_API - if (m_workbenchClientUser) { - delete m_workbenchClientUser; - m_workbenchClientUser = 0; - } -#endif if (m_perforceOutputWindow) { removeObject(m_perforceOutputWindow); delete m_perforceOutputWindow; m_perforceOutputWindow = 0; } + if (m_submitEditorFactory) { removeObject(m_submitEditorFactory); delete m_submitEditorFactory; m_submitEditorFactory = 0; } + if (m_versionControl) { removeObject(m_versionControl); delete m_versionControl; @@ -1213,7 +1148,7 @@ void PerforcePlugin::setSettings(const PerforceSettings &s) { if (s != m_settings) { m_settings = s; - if (QSettings *settings = m_coreInstance->settings()) + if (QSettings *settings = Core::ICore::instance()->settings()) m_settings.toSettings(settings); } } @@ -1251,12 +1186,6 @@ QString PerforcePlugin::fileNameFromPerforceName(const QString& perforceName, return rc; } -Core::ICore *PerforcePlugin::coreInstance() -{ - QTC_ASSERT(m_coreInstance, return 0); - return m_coreInstance; -} - PerforcePlugin *PerforcePlugin::perforcePluginInstance() { QTC_ASSERT(m_perforcePluginInstance, return 0); diff --git a/src/plugins/perforce/perforceplugin.h b/src/plugins/perforce/perforceplugin.h index 8069154a25c3464b1d9f2e8c55fdc32148e74958..e5985a28ab5bcce0067f57652d42a05babba3545 100644 --- a/src/plugins/perforce/perforceplugin.h +++ b/src/plugins/perforce/perforceplugin.h @@ -42,12 +42,6 @@ #include <extensionsystem/iplugin.h> #include <projectexplorer/projectexplorer.h> -#ifdef USE_P4_API -#include "workbenchclientuser.h" -#else - -#endif - #include <QtCore/QObject> #include <QtCore/QProcess> #include <QtCore/QStringList> @@ -117,7 +111,6 @@ public: Core::IEditor *openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames); - static Core::ICore *coreInstance(); static PerforcePlugin *perforcePluginInstance(); PerforceSettings settings() const; @@ -230,7 +223,6 @@ private: static const char * const SEPARATOR2; static const char * const SEPARATOR3; - static Core::ICore *m_coreInstance; static PerforcePlugin *m_perforcePluginInstance; QString pendingChangesData(); diff --git a/src/plugins/perforce/workbenchclientuser.cpp b/src/plugins/perforce/workbenchclientuser.cpp index d8943ffd085758c76a3bbb4bcc93fc9bef751713..64dd3085eb5fa8efb6a0830e52a976a2cf81b5aa 100644 --- a/src/plugins/perforce/workbenchclientuser.cpp +++ b/src/plugins/perforce/workbenchclientuser.cpp @@ -95,7 +95,7 @@ QString PromptDialog::input() const WorkbenchClientUser::WorkbenchClientUser(PerforceOutputWindow *out, PerforcePlugin *plugin) : QObject(out), m_plugin(plugin), - m_coreIFace(PerforcePlugin::coreInstance()), + m_core(Core::ICore::instance()), m_currentEditorIface(0), m_userCancelled(false), m_mode(Submit), @@ -103,7 +103,7 @@ WorkbenchClientUser::WorkbenchClientUser(PerforceOutputWindow *out, PerforcePlug m_skipNextMsg(false), m_eventLoop(new QEventLoop(this)) { - connect(m_coreIFace, SIGNAL(coreAboutToClose()), + connect(m_core, SIGNAL(coreAboutToClose()), this, SLOT(cancelP4Command())); } @@ -147,13 +147,13 @@ void WorkbenchClientUser::displayErrorMsg(const QString &msg) const QString title = tr("Perforce Error"); switch (m_mode) { case Submit: { - QMessageBox msgBox(QMessageBox::Critical, title, msg, QMessageBox::Ok, m_coreIFace->mainWindow()); + QMessageBox msgBox(QMessageBox::Critical, title, msg, QMessageBox::Ok, m_core->mainWindow()); msgBox.setDetailedText(m_msg); msgBox.exec(); } break; default: - QMessageBox::critical(m_coreIFace->mainWindow(), title, msg); + QMessageBox::critical(m_core->mainWindow(), title, msg); break; } m_errMsg.clear(); @@ -182,7 +182,7 @@ bool WorkbenchClientUser::editorAboutToClose(Core::IEditor *editor) if (editor && editor == m_currentEditorIface) { if (m_mode == WorkbenchClientUser::Submit) { const QMessageBox::StandardButton answer = - QMessageBox::question(m_coreIFace->mainWindow(), + QMessageBox::question(m_core->mainWindow(), tr("Closing p4 Editor"), tr("Do you want to submit this change list?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, QMessageBox::Yes); @@ -190,9 +190,9 @@ bool WorkbenchClientUser::editorAboutToClose(Core::IEditor *editor) return false; if (answer == QMessageBox::No) m_userCancelled = true; - m_coreIFace->fileManager()->blockFileChange(m_currentEditorIface->file()); + m_core->fileManager()->blockFileChange(m_currentEditorIface->file()); m_currentEditorIface->file()->save(); - m_coreIFace->fileManager()->unblockFileChange(m_currentEditorIface->file()); + m_core->fileManager()->unblockFileChange(m_currentEditorIface->file()); } m_eventLoop->quit(); m_currentEditorIface = 0; @@ -228,7 +228,7 @@ void WorkbenchClientUser::Diff(FileSys *f1, FileSys *f2, int, char *, Error *err delete file2; QString title = QString("diff %1").arg(f1->Name()); - m_currentEditorIface = m_coreIFace->editorManager()->newFile("Perforce Editor", &title, tmp.readAll()); + m_currentEditorIface = m_core->editorManager()->newFile("Perforce Editor", &title, tmp.readAll()); if (!m_currentEditorIface) { err->Set(E_FAILED, "p4 data could not be opened!"); return; @@ -246,8 +246,8 @@ void WorkbenchClientUser::Edit(FileSys *f, Error *err) m_currentEditorIface = m_plugin->openPerforceSubmitEditor(fileName, QStringList()); } else { - m_currentEditorIface = m_coreIFace->editorManager()->openEditor(fileName); - m_coreIFace->editorManager()->ensureEditorManagerVisible(); + m_currentEditorIface = m_core->editorManager()->openEditor(fileName); + m_core->editorManager()->ensureEditorManagerVisible(); } if (!m_currentEditorIface) { err->Set(E_FAILED, "p4 data could not be opened!"); @@ -265,7 +265,7 @@ void WorkbenchClientUser::Prompt(const StrPtr &msg, StrBuf &answer, int , Error err->Set(E_FATAL, ""); return; } - PromptDialog dia(msg.Text(), m_msg, qobject_cast<QWidget*>(m_coreIFace)); + PromptDialog dia(msg.Text(), m_msg, qobject_cast<QWidget*>(m_core)); dia.exec(); answer = qstrdup(dia.input().toLatin1().constData()); if (m_mode == WorkbenchClientUser::Resolve) { @@ -282,5 +282,5 @@ void WorkbenchClientUser::Prompt(const StrPtr &msg, StrBuf &answer, int , Error void WorkbenchClientUser::ErrorPause(char *msg, Error *) { - QMessageBox::warning(m_coreIFace->mainWindow(), tr("Perforce Error"), QString::fromUtf8(msg)); + QMessageBox::warning(m_core->mainWindow(), tr("Perforce Error"), QString::fromUtf8(msg)); } diff --git a/src/plugins/perforce/workbenchclientuser.h b/src/plugins/perforce/workbenchclientuser.h index 200b68a9683b06bb6c350ff45aada2ab6d8e551a..8aef183e42d38473c676aaf353d6ae096d610fad 100644 --- a/src/plugins/perforce/workbenchclientuser.h +++ b/src/plugins/perforce/workbenchclientuser.h @@ -61,8 +61,7 @@ class PerforcePlugin; class PromptDialog : public QDialog { public: - PromptDialog(const QString &choice, const QString &text, - QWidget *parent = 0); + PromptDialog(const QString &choice, const QString &text, QWidget *parent = 0); QString input() const; private: @@ -96,7 +95,7 @@ private: void displayErrorMsg(const QString &msg); PerforcePlugin *m_plugin; - Core::ICore *m_coreIFace; + Core::ICore *m_core; Core::IEditor *m_currentEditorIface; bool m_userCancelled; Mode m_mode; diff --git a/src/plugins/projectexplorer/allprojectsfilter.cpp b/src/plugins/projectexplorer/allprojectsfilter.cpp index 07e34399b0bef30b2c9c9b3de3b40981887fdd78..cb1457f83663a38205419a25da1d745d22fd2165 100644 --- a/src/plugins/projectexplorer/allprojectsfilter.cpp +++ b/src/plugins/projectexplorer/allprojectsfilter.cpp @@ -43,8 +43,7 @@ using namespace QuickOpen; using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; -AllProjectsFilter::AllProjectsFilter(ProjectExplorerPlugin *pe, ICore *core) - : BaseFileFilter(core) +AllProjectsFilter::AllProjectsFilter(ProjectExplorerPlugin *pe) { m_projectExplorer = pe; connect(m_projectExplorer, SIGNAL(fileListChanged()), diff --git a/src/plugins/projectexplorer/allprojectsfilter.h b/src/plugins/projectexplorer/allprojectsfilter.h index 8de2de425e60bad3dbb102b141d845c6bcb97043..f94d51ea1bb7cf860af7d14f2a19e03a1e7edcbb 100644 --- a/src/plugins/projectexplorer/allprojectsfilter.h +++ b/src/plugins/projectexplorer/allprojectsfilter.h @@ -36,13 +36,10 @@ #include <quickopen/basefilefilter.h> -#include <QtCore/QString> -#include <QtCore/QList> -#include <QtCore/QByteArray> #include <QtCore/QFutureInterface> +#include <QtCore/QString> #include <QtGui/QWidget> - namespace ProjectExplorer { class ProjectExplorerPlugin; @@ -54,7 +51,7 @@ class AllProjectsFilter : public QuickOpen::BaseFileFilter Q_OBJECT public: - AllProjectsFilter(ProjectExplorerPlugin *pe, Core::ICore *core); + explicit AllProjectsFilter(ProjectExplorerPlugin *pe); QString trName() const { return tr("Files in any project"); } QString name() const { return "Files in any project"; } QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Low; } diff --git a/src/plugins/projectexplorer/allprojectsfind.cpp b/src/plugins/projectexplorer/allprojectsfind.cpp index 26998982614bbfaf40d29d6844eeab25e8a816e0..84af045f050779e4218f953e551d8bc0e1f33c32 100644 --- a/src/plugins/projectexplorer/allprojectsfind.cpp +++ b/src/plugins/projectexplorer/allprojectsfind.cpp @@ -47,8 +47,8 @@ using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; using namespace TextEditor; -AllProjectsFind::AllProjectsFind(ProjectExplorerPlugin *plugin, Core::ICore *core, SearchResultWindow *resultWindow) - : BaseFileFind(core, resultWindow), +AllProjectsFind::AllProjectsFind(ProjectExplorerPlugin *plugin, SearchResultWindow *resultWindow) + : BaseFileFind(resultWindow), m_plugin(plugin), m_configWidget(0) { diff --git a/src/plugins/projectexplorer/allprojectsfind.h b/src/plugins/projectexplorer/allprojectsfind.h index 48d1457b546a6a931f2ac6c51f17660255980a35..1b93842c691363e34fcdba5108787ca90d84ef88 100644 --- a/src/plugins/projectexplorer/allprojectsfind.h +++ b/src/plugins/projectexplorer/allprojectsfind.h @@ -34,15 +34,11 @@ #ifndef ALLPROJECTSFIND_H #define ALLPROJECTSFIND_H -#include <coreplugin/icore.h> #include <find/ifindfilter.h> #include <find/searchresultwindow.h> #include <texteditor/basefilefind.h> #include <QtCore/QPointer> -#include <QtGui/QLabel> -#include <QtGui/QComboBox> -#include <QtGui/QStringListModel> namespace ProjectExplorer { @@ -56,7 +52,7 @@ class AllProjectsFind : public TextEditor::BaseFileFind Q_OBJECT public: - AllProjectsFind(ProjectExplorerPlugin *plugin, Core::ICore *core, Find::SearchResultWindow *resultWindow); + AllProjectsFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow); QString name() const; diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index ff426805c2eedb072a40820fbb12e947f3aa6db3..a7e7286a30f6b18acfa823a3a9d98be333737107 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -178,8 +178,7 @@ void BuildManager::startBuildQueue() { if (!m_running) { // Progress Reporting - Core::ProgressManager *progressManager = - ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->progressManager(); + Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager(); m_progressFutureInterface = new QFutureInterface<void>; m_progressWatcher.setFuture(m_progressFutureInterface->future()); Core::FutureProgress *progress = progressManager->addTask(m_progressFutureInterface->future(), diff --git a/src/plugins/projectexplorer/currentprojectfilter.cpp b/src/plugins/projectexplorer/currentprojectfilter.cpp index 4b9e585cc130196e3aa9d4b56c3884364fd693a9..496aeb326c02e1c9ef2e97466f2f70ad82098017 100644 --- a/src/plugins/projectexplorer/currentprojectfilter.cpp +++ b/src/plugins/projectexplorer/currentprojectfilter.cpp @@ -36,20 +36,18 @@ #include "project.h" #include "session.h" -#include <QtCore/QVariant> -#include <QtCore/QTimer> +#include <QtCore/QtDebug> #include <QtCore/QThread> -#include <QtDebug> +#include <QtCore/QTimer> +#include <QtCore/QVariant> using namespace Core; using namespace QuickOpen; using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; -CurrentProjectFilter::CurrentProjectFilter(ProjectExplorerPlugin *pe, - ICore *core) - : BaseFileFilter(core), - m_project(0) +CurrentProjectFilter::CurrentProjectFilter(ProjectExplorerPlugin *pe) + : BaseFileFilter(), m_project(0) { m_projectExplorer = pe; @@ -73,12 +71,12 @@ void CurrentProjectFilter::currentProjectChanged(ProjectExplorer::Project *proje { if (project == m_project) return; - if (m_project) { + if (m_project) disconnect(m_project, SIGNAL(fileListChanged()), this, SLOT(refreshInternally())); - } - if (project) { + + if (project) connect(project, SIGNAL(fileListChanged()), this, SLOT(refreshInternally())); - } + m_project = project; refreshInternally(); } diff --git a/src/plugins/projectexplorer/currentprojectfilter.h b/src/plugins/projectexplorer/currentprojectfilter.h index 92ae4b6863538839b2f2687a1e7555d700f4c27e..25b2a12f57696990af4045223337de1ea169521c 100644 --- a/src/plugins/projectexplorer/currentprojectfilter.h +++ b/src/plugins/projectexplorer/currentprojectfilter.h @@ -54,7 +54,7 @@ class CurrentProjectFilter : public QuickOpen::BaseFileFilter Q_OBJECT public: - CurrentProjectFilter(ProjectExplorerPlugin *pe, Core::ICore *core); + CurrentProjectFilter(ProjectExplorerPlugin *pe); QString trName() const { return tr("Files in current project"); } QString name() const { return "Files in current project"; } QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Low; } diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp index cf1d81c3bc7e591050d1e8bd9bf2b73530f244b7..e453d0c6a49d5a03afcfe76fd383f8471757a8a8 100644 --- a/src/plugins/projectexplorer/currentprojectfind.cpp +++ b/src/plugins/projectexplorer/currentprojectfind.cpp @@ -47,8 +47,8 @@ using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; using namespace TextEditor; -CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin, Core::ICore *core, SearchResultWindow *resultWindow) - : BaseFileFind(core, resultWindow), +CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin, SearchResultWindow *resultWindow) + : BaseFileFind(resultWindow), m_plugin(plugin), m_configWidget(0) { diff --git a/src/plugins/projectexplorer/currentprojectfind.h b/src/plugins/projectexplorer/currentprojectfind.h index 5c08be0f2fc70d0a91982a27133446e5b41f231c..8690911277a2e3ad1073e1376b5fe501a6376235 100644 --- a/src/plugins/projectexplorer/currentprojectfind.h +++ b/src/plugins/projectexplorer/currentprojectfind.h @@ -34,7 +34,6 @@ #ifndef CURRENTPROJECTFIND_H #define CURRENTPROJECTFIND_H -#include <coreplugin/icore.h> #include <find/ifindfilter.h> #include <find/searchresultwindow.h> #include <texteditor/basefilefind.h> @@ -51,7 +50,7 @@ namespace Internal { class CurrentProjectFind : public TextEditor::BaseFileFind { public: - CurrentProjectFind(ProjectExplorerPlugin *plugin, Core::ICore *core, Find::SearchResultWindow *resultWindow); + CurrentProjectFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow); QString name() const; diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp index 029707155e5dffa7da2aee311eb28bb6befa6cb9..29b0fbe1cd1da1f8e85e4669c29a20f88656a914 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.cpp +++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp @@ -61,7 +61,7 @@ class FirstRowFilter : public QSortFilterProxyModel public: FirstRowFilter(QObject *parent = 0) : QSortFilterProxyModel(parent) {} protected: - bool filterAcceptsRow (int source_row, const QModelIndex & ) const { + bool filterAcceptsRow(int source_row, const QModelIndex &) const { return source_row != 0; } }; @@ -74,15 +74,14 @@ protected: Shows a file system folder */ -FolderNavigationWidget::FolderNavigationWidget(Core::ICore *core, QWidget *parent) - : QWidget(parent), - m_core(core), - m_explorer(ProjectExplorerPlugin::instance()), - m_view(new QListView(this)), - m_dirModel(new QDirModel(this)), - m_filter(new FirstRowFilter(this)), - m_title(new QLabel(this)), - m_autoSync(false) +FolderNavigationWidget::FolderNavigationWidget(QWidget *parent) + : QWidget(parent), + m_explorer(ProjectExplorerPlugin::instance()), + m_view(new QListView(this)), + m_dirModel(new QDirModel(this)), + m_filter(new FirstRowFilter(this)), + m_title(new QLabel(this)), + m_autoSync(false) { m_dirModel->setFilter(QDir::Dirs | QDir::Files | QDir::Drives | QDir::Readable | QDir::Writable | QDir::Executable | QDir::Hidden); @@ -124,14 +123,14 @@ void FolderNavigationWidget::setAutoSynchronization(bool sync) m_autoSync = sync; - Core::FileManager *fileManager = m_core->fileManager(); + Core::FileManager *fileManager = Core::ICore::instance()->fileManager(); if (m_autoSync) { - connect(fileManager, SIGNAL(currentFileChanged(const QString&)), - this, SLOT(setCurrentFile(const QString&))); + connect(fileManager, SIGNAL(currentFileChanged(QString)), + this, SLOT(setCurrentFile(QString))); setCurrentFile(fileManager->currentFile()); } else { - disconnect(fileManager, SIGNAL(currentFileChanged(const QString&)), - this, SLOT(setCurrentFile(const QString&))); + disconnect(fileManager, SIGNAL(currentFileChanged(QString)), + this, SLOT(setCurrentFile(QString))); } } @@ -171,8 +170,9 @@ void FolderNavigationWidget::openItem(const QModelIndex &index) setCurrentTitle(QDir(m_dirModel->filePath(srcIndex))); } else { const QString filePath = m_dirModel->filePath(srcIndex); - m_core->editorManager()->openEditor(filePath); - m_core->editorManager()->ensureEditorManagerVisible(); + Core::EditorManager *editorManager = Core::EditorManager::instance(); + editorManager->openEditor(filePath); + editorManager->ensureEditorManagerVisible(); } } } @@ -183,8 +183,7 @@ void FolderNavigationWidget::setCurrentTitle(const QDir &dir) m_title->setToolTip(dir.absolutePath()); } -FolderNavigationWidgetFactory::FolderNavigationWidgetFactory(Core::ICore *core) - : m_core(core) +FolderNavigationWidgetFactory::FolderNavigationWidgetFactory() { } @@ -205,7 +204,7 @@ QKeySequence FolderNavigationWidgetFactory::activationSequence() Core::NavigationView FolderNavigationWidgetFactory::createWidget() { Core::NavigationView n; - FolderNavigationWidget *ptw = new FolderNavigationWidget(m_core); + FolderNavigationWidget *ptw = new FolderNavigationWidget; n.widget = ptw; QToolButton *toggleSync = new QToolButton; toggleSync->setProperty("type", "dockbutton"); diff --git a/src/plugins/projectexplorer/foldernavigationwidget.h b/src/plugins/projectexplorer/foldernavigationwidget.h index c3eba4ce66282795859624d561f06c0c1ced37c6..d0f04f3d5a9cb78e10e2c4d5fd3f19e72330487d 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.h +++ b/src/plugins/projectexplorer/foldernavigationwidget.h @@ -36,15 +36,11 @@ #include <coreplugin/inavigationwidgetfactory.h> -#include <QtGui/QWidget> -#include <QtGui/QListView> #include <QtGui/QDirModel> #include <QtGui/QLabel> +#include <QtGui/QListView> #include <QtGui/QSortFilterProxyModel> - -namespace Core { -class ICore; -} +#include <QtGui/QWidget> namespace ProjectExplorer { @@ -54,10 +50,11 @@ class Node; namespace Internal { -class FolderNavigationWidget : public QWidget { +class FolderNavigationWidget : public QWidget +{ Q_OBJECT public: - FolderNavigationWidget(Core::ICore *core, QWidget *parent = 0); + FolderNavigationWidget(QWidget *parent = 0); bool autoSynchronization() const; void setAutoSynchronization(bool sync); @@ -74,7 +71,6 @@ private slots: private: void setCurrentTitle(const QDir &directory); - Core::ICore *m_core; ProjectExplorerPlugin *m_explorer; QListView *m_view; QDirModel *m_dirModel; @@ -86,14 +82,12 @@ private: class FolderNavigationWidgetFactory : public Core::INavigationWidgetFactory { public: - FolderNavigationWidgetFactory(Core::ICore *core); + FolderNavigationWidgetFactory(); virtual ~FolderNavigationWidgetFactory(); virtual QString displayName(); virtual QKeySequence activationSequence(); virtual Core::NavigationView createWidget(); -private: - Core::ICore *m_core; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/outputwindow.cpp b/src/plugins/projectexplorer/outputwindow.cpp index d34c3f2bb0e3645d0928731c72c6b1587d3e5916..6dc95b2bf053128f90ac76ec3bfde17978494779 100644 --- a/src/plugins/projectexplorer/outputwindow.cpp +++ b/src/plugins/projectexplorer/outputwindow.cpp @@ -55,7 +55,7 @@ using namespace ProjectExplorer::Internal; using namespace ProjectExplorer; -OutputPane::OutputPane(Core::ICore *core) +OutputPane::OutputPane() : m_mainWidget(new QWidget) { // m_insertLineButton = new QToolButton; @@ -78,7 +78,7 @@ OutputPane::OutputPane(Core::ICore *core) this, SLOT(reRunRunControl())); // Stop - Core::ActionManager *am = core->actionManager(); + Core::ActionManager *am = Core::ICore::instance()->actionManager(); QList<int> globalcontext; globalcontext.append(Core::Constants::C_GLOBAL_ID); @@ -107,8 +107,7 @@ OutputPane::OutputPane(Core::ICore *core) connect(m_tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); layout->addWidget(m_tabWidget); - connect(m_tabWidget, SIGNAL(currentChanged(int)), - this, SLOT(tabChanged(int))); + connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); m_mainWidget->setLayout(layout); } @@ -129,7 +128,7 @@ QWidget *OutputPane::outputWidget(QWidget *) return m_mainWidget; } -QList<QWidget*> OutputPane::toolBarWidgets(void) const +QList<QWidget*> OutputPane::toolBarWidgets() const { return QList<QWidget*>() << m_reRunButton << m_stopButton ; // << m_insertLineButton; diff --git a/src/plugins/projectexplorer/outputwindow.h b/src/plugins/projectexplorer/outputwindow.h index 674f25cd51d728f41fd45b216e3faa73ee7e6fa4..edc39ac2fb259ab81b3bbb4c1affb0f735e404a8 100644 --- a/src/plugins/projectexplorer/outputwindow.h +++ b/src/plugins/projectexplorer/outputwindow.h @@ -48,10 +48,6 @@ QT_BEGIN_NAMESPACE class QTabWidget; QT_END_NAMESPACE -namespace Core { -class ICore; -} - namespace ProjectExplorer { class RunControl; @@ -65,7 +61,7 @@ class OutputPane : public Core::IOutputPane Q_OBJECT public: - OutputPane(Core::ICore *core); + OutputPane(); ~OutputPane(); QWidget *outputWidget(QWidget *); diff --git a/src/plugins/projectexplorer/pluginfilefactory.cpp b/src/plugins/projectexplorer/pluginfilefactory.cpp index de7153c4015feb342d75f49f12f06a2c63e366e3..55b38f681bf3da05dee732c0d5f8d22235f50ce2 100644 --- a/src/plugins/projectexplorer/pluginfilefactory.cpp +++ b/src/plugins/projectexplorer/pluginfilefactory.cpp @@ -46,10 +46,9 @@ using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; -ProjectFileFactory::ProjectFileFactory(const Core::ICore* core, IProjectManager *manager) : - m_mimeTypes(manager->mimeType()), +ProjectFileFactory::ProjectFileFactory(IProjectManager *manager) + : m_mimeTypes(manager->mimeType()), m_kind(Constants::FILE_FACTORY_KIND), - m_core(core), m_manager(manager) { } @@ -70,7 +69,7 @@ Core::IFile *ProjectFileFactory::open(const QString &fileName) ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); if (!pe->openProject(fileName)) { - m_core->messageManager()->printToOutputPane(tr("Could not open the following project: '%1'").arg(fileName)); + Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not open the following project: '%1'").arg(fileName)); } else if (pe->session()) { SessionManager *session = pe->session(); if (session->projects().count() == 1) @@ -81,21 +80,21 @@ Core::IFile *ProjectFileFactory::open(const QString &fileName) return fIFace; } -QList<ProjectFileFactory*> ProjectFileFactory::createFactories(const Core::ICore* core, - QString *filterString) +QList<ProjectFileFactory *> ProjectFileFactory::createFactories(QString *filterString) { // Register factories for all project managers QList<Internal::ProjectFileFactory*> rc; - QList<IProjectManager*> projectManagers = core->pluginManager()->getObjects<IProjectManager>(); + QList<IProjectManager*> projectManagers = + ExtensionSystem::PluginManager::instance()->getObjects<IProjectManager>(); const QString filterSeparator = QLatin1String(";;"); filterString->clear(); foreach (IProjectManager *manager, projectManagers) { - rc.push_back(new ProjectFileFactory(core, manager)); + rc.push_back(new ProjectFileFactory(manager)); if (!filterString->isEmpty()) *filterString += filterSeparator; const QString mimeType = manager->mimeType(); - const QString pFilterString = core->mimeDatabase()->findByType(mimeType).filterString(); + const QString pFilterString = Core::ICore::instance()->mimeDatabase()->findByType(mimeType).filterString(); *filterString += pFilterString; } return rc; diff --git a/src/plugins/projectexplorer/pluginfilefactory.h b/src/plugins/projectexplorer/pluginfilefactory.h index 035eb50e665ea72f4143a99f9004b54ff9e58c55..e23be0e9f9f33350be692bd1dfaa78fd423f3dc4 100644 --- a/src/plugins/projectexplorer/pluginfilefactory.h +++ b/src/plugins/projectexplorer/pluginfilefactory.h @@ -35,16 +35,14 @@ #define PLUGINFILEFACTORY_H #include <coreplugin/ifilefactory.h> + #include <QtCore/QObject> #include <QtCore/QStringList> -namespace Core { - class ICore; -} - namespace ProjectExplorer { - class IProjectManager; - class ProjectExplorerPlugin; + +class IProjectManager; +class ProjectExplorerPlugin; namespace Internal { @@ -53,20 +51,20 @@ namespace Internal { class ProjectFileFactory : public Core::IFileFactory { Q_OBJECT - explicit ProjectFileFactory(const Core::ICore* core, ProjectExplorer::IProjectManager *manager); -public: + explicit ProjectFileFactory(ProjectExplorer::IProjectManager *manager); + +public: virtual QStringList mimeTypes() const; bool canOpen(const QString &fileName); QString kind() const; Core::IFile *open(const QString &fileName); - static QList<ProjectFileFactory*> createFactories(const Core::ICore* core, QString *filterString); + static QList<ProjectFileFactory*> createFactories(QString *filterString); private: const QStringList m_mimeTypes; const QString m_kind; - const Core::ICore* m_core; ProjectExplorer::IProjectManager *m_manager; }; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 20e4e15fc8a9ae6b98d3593a18caf3757558ebf6..69b642bc4259f013b2408a54e9dc1d6df627b0bb 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -78,25 +78,20 @@ #include <coreplugin/vcsmanager.h> #include <coreplugin/iversioncontrol.h> #include <coreplugin/vcsmanager.h> +#include <extensionsystem/pluginmanager.h> #include <utils/listutils.h> #include <utils/qtcassert.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QDateTime> #include <QtCore/QDebug> #include <QtCore/QSettings> #include <QtGui/QAction> #include <QtGui/QApplication> -#include <QtGui/QContextMenuEvent> #include <QtGui/QFileDialog> -#include <QtGui/QFileSystemModel> -#include <QtGui/QHeaderView> -#include <QtGui/QInputDialog> -#include <QtGui/QMainWindow> #include <QtGui/QMenu> #include <QtGui/QMessageBox> -#include <QtGui/QToolBar> Q_DECLARE_METATYPE(QSharedPointer<ProjectExplorer::RunConfiguration>); Q_DECLARE_METATYPE(Core::IEditorFactory *); @@ -152,18 +147,20 @@ ProjectExplorerPlugin *ProjectExplorerPlugin::instance() return m_instance; } -bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QString *) +bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error) { - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - m_core = pm->getObject<Core::ICore>(); - Core::ActionManager *am = m_core->actionManager(); + Q_UNUSED(arguments); + Q_UNUSED(error); + + Core::ICore *core = Core::ICore::instance(); + Core::ActionManager *am = core->actionManager(); addObject(this); - connect(m_core->fileManager(), SIGNAL(currentFileChanged(const QString&)), - this, SLOT(setCurrentFile(const QString&))); + connect(core->fileManager(), SIGNAL(currentFileChanged(QString)), + this, SLOT(setCurrentFile(QString))); - m_session = new SessionManager(m_core, this); + m_session = new SessionManager(this); connect(m_session, SIGNAL(projectAdded(ProjectExplorer::Project *)), this, SIGNAL(fileListChanged())); @@ -174,13 +171,13 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin connect(m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project *)), this, SLOT(startupProjectChanged())); - m_proWindow = new ProjectWindow(m_core); + m_proWindow = new ProjectWindow; QList<int> globalcontext; globalcontext.append(Core::Constants::C_GLOBAL_ID); QList<int> pecontext; - pecontext << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_PROJECTEXPLORER); + pecontext << core->uniqueIDManager()->uniqueIdentifier(Constants::C_PROJECTEXPLORER); Core::BaseMode *mode = new Core::BaseMode; mode->setName(tr("Projects")); @@ -202,15 +199,15 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin addAutoReleasedObject(new CoreListenerCheckingForRunningBuild(m_buildManager)); - m_outputPane = new OutputPane(m_core); + m_outputPane = new OutputPane; addAutoReleasedObject(m_outputPane); connect(m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)), m_outputPane, SLOT(projectRemoved())); - AllProjectsFilter *allProjectsFilter = new AllProjectsFilter(this, m_core); + AllProjectsFilter *allProjectsFilter = new AllProjectsFilter(this); addAutoReleasedObject(allProjectsFilter); - CurrentProjectFilter *currentProjectFilter = new CurrentProjectFilter(this, m_core); + CurrentProjectFilter *currentProjectFilter = new CurrentProjectFilter(this); addAutoReleasedObject(currentProjectFilter); addAutoReleasedObject(new BuildSettingsPanelFactory); @@ -221,18 +218,19 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin ProcessStepFactory *processStepFactory = new ProcessStepFactory; addAutoReleasedObject(processStepFactory); - AllProjectsFind *allProjectsFind = new AllProjectsFind(this, m_core, - m_core->pluginManager()->getObject<Find::SearchResultWindow>()); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + AllProjectsFind *allProjectsFind = new AllProjectsFind(this, + pm->getObject<Find::SearchResultWindow>()); addAutoReleasedObject(allProjectsFind); - CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this, m_core, - m_core->pluginManager()->getObject<Find::SearchResultWindow>()); + CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this, + pm->getObject<Find::SearchResultWindow>()); addAutoReleasedObject(currentProjectFind); addAutoReleasedObject(new ApplicationRunConfigurationRunner); addAutoReleasedObject(new CustomExecutableRunConfigurationFactory); - addAutoReleasedObject(new ProjectFileWizardExtension(m_core)); + addAutoReleasedObject(new ProjectFileWizardExtension); // context menus Core::ActionContainer *msessionContextMenu = @@ -258,7 +256,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin am->actionContainer(Core::Constants::MENU_BAR); // mode manager (for fancy actions) - Core::ModeManager *modeManager = m_core->modeManager(); + Core::ModeManager *modeManager = core->modeManager(); // build menu Core::ActionContainer *mbuild = @@ -588,13 +586,13 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin m_renameFileAction->setEnabled(false); m_renameFileAction->setVisible(false); - connect(m_core, SIGNAL(saveSettingsRequested()), + connect(core, SIGNAL(saveSettingsRequested()), this, SLOT(savePersistentSettings())); - addAutoReleasedObject(new ProjectTreeWidgetFactory(m_core)); - addAutoReleasedObject(new FolderNavigationWidgetFactory(m_core)); + addAutoReleasedObject(new ProjectTreeWidgetFactory); + addAutoReleasedObject(new FolderNavigationWidgetFactory); - if (QSettings *s = m_core->settings()) + if (QSettings *s = core->settings()) m_recentProjects = s->value("ProjectExplorer/RecentProjects/Files", QStringList()).toStringList(); for (QStringList::iterator it = m_recentProjects.begin(); it != m_recentProjects.end(); ) { if (QFileInfo(*it).isFile()) { @@ -630,7 +628,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin updateActions(); - connect(m_core, SIGNAL(coreOpened()), this, SLOT(restoreSession())); + connect(Core::ICore::instance(), SIGNAL(coreOpened()), this, SLOT(restoreSession())); return true; } @@ -650,7 +648,7 @@ template <class Factory, class Iterator> ProjectFileFactory * ProjectExplorerPlugin::findProjectFileFactory(const QString &filename) const { // Find factory - if (const Core::MimeType mt = m_core->mimeDatabase()->findByFile(QFileInfo(filename))) + if (const Core::MimeType mt = Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(filename))) if (ProjectFileFactory *pf = findFactory<ProjectFileFactory>(mt.type(), m_fileFactories.constBegin(), m_fileFactories.constEnd())) return pf; qWarning("Unable to find project file factory for '%s'", filename.toUtf8().constData()); @@ -708,9 +706,9 @@ void ProjectExplorerPlugin::unloadProject() bool success = false; if (readonlycount > 0) - success = m_core->fileManager()->saveModifiedFiles(filesToSave).isEmpty(); + success = Core::ICore::instance()->fileManager()->saveModifiedFiles(filesToSave).isEmpty(); else - success = m_core->fileManager()->saveModifiedFilesSilently(filesToSave).isEmpty(); + success = Core::ICore::instance()->fileManager()->saveModifiedFilesSilently(filesToSave).isEmpty(); if (!success) return; @@ -732,7 +730,7 @@ void ProjectExplorerPlugin::clearSession() void ProjectExplorerPlugin::extensionsInitialized() { - m_fileFactories = ProjectFileFactory::createFactories(m_core, &m_projectFilterString); + m_fileFactories = ProjectFileFactory::createFactories(&m_projectFilterString); foreach (ProjectFileFactory *pf, m_fileFactories) { m_profileMimeTypes += pf->mimeTypes(); addAutoReleasedObject(pf); @@ -758,7 +756,7 @@ void ProjectExplorerPlugin::newProject() defaultLocation = dir.absolutePath(); } - m_core->showNewItemDialog(tr("New Project", "Title of dialog"), + Core::ICore::instance()->showNewItemDialog(tr("New Project", "Title of dialog"), Core::BaseFileWizard::findWizardsOfKind(Core::IWizard::ProjectWizard), defaultLocation); updateActions(); @@ -808,7 +806,7 @@ void ProjectExplorerPlugin::savePersistentSettings() m_session->save(); } - QSettings *s = m_core->settings(); + QSettings *s = Core::ICore::instance()->settings(); if (s) { s->setValue("ProjectExplorer/StartupSession", m_session->file()->fileName()); s->setValue("ProjectExplorer/RecentProjects/Files", m_recentProjects); @@ -832,14 +830,14 @@ bool ProjectExplorerPlugin::openProjects(const QStringList &fileNames) if (debug) qDebug() << "ProjectExplorerPlugin - opening projects " << fileNames; - QList<IProjectManager*> projectManagers = - m_core->pluginManager()->getObjects<IProjectManager>(); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + QList<IProjectManager*> projectManagers = pm->getObjects<IProjectManager>(); //QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); // bool blocked = blockSignals(true); QList<Project*> openedPro; - foreach (QString fileName, fileNames) - if (const Core::MimeType mt = m_core->mimeDatabase()->findByFile(QFileInfo(fileName))) { + foreach (const QString &fileName, fileNames) { + if (const Core::MimeType mt = Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(fileName))) { foreach (IProjectManager *manager, projectManagers) if (manager->mimeType() == mt.type()) { if (Project *pro = manager->openProject(fileName)) @@ -848,6 +846,7 @@ bool ProjectExplorerPlugin::openProjects(const QStringList &fileNames) break; } } + } //blockSignals(blocked); if (openedPro.isEmpty()) { @@ -871,7 +870,7 @@ bool ProjectExplorerPlugin::openProjects(const QStringList &fileNames) updateActions(); - m_core->modeManager()->activateMode(Core::Constants::MODE_EDIT); + Core::ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT); QApplication::restoreOverrideCursor(); return true; @@ -987,7 +986,7 @@ void ProjectExplorerPlugin::restoreSession() } // update welcome page - Core::ModeManager *modeManager = m_core->modeManager(); + Core::ModeManager *modeManager = Core::ModeManager::instance(); connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*)), this, SLOT(currentModeChanged(Core::IMode*))); if (Core::Internal::WelcomeMode *welcomeMode = qobject_cast<Core::Internal::WelcomeMode*>(modeManager->mode(Core::Constants::MODE_WELCOME))) { updateWelcomePage(welcomeMode); @@ -995,7 +994,7 @@ void ProjectExplorerPlugin::restoreSession() connect(welcomeMode, SIGNAL(requestProject(QString)), this, SLOT(loadProject(QString))); } - m_core->openFiles(arguments); + Core::ICore::instance()->openFiles(arguments); updateActions(); } @@ -1122,6 +1121,8 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node else node = m_session->nodeForFile(filePath); + Core::ICore *core = Core::ICore::instance(); + bool projectChanged = false; if (m_currentProject != project) { int oldContext = -1; @@ -1136,11 +1137,11 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node newContext = project->projectManager()->projectContext(); newLanguageID = project->projectManager()->projectLanguage(); } - m_core->removeAdditionalContext(oldContext); - m_core->removeAdditionalContext(oldLanguageID); - m_core->addAdditionalContext(newContext); - m_core->addAdditionalContext(newLanguageID); - m_core->updateContext(); + core->removeAdditionalContext(oldContext); + core->removeAdditionalContext(oldLanguageID); + core->addAdditionalContext(newContext); + core->addAdditionalContext(newLanguageID); + core->updateContext(); m_currentProject = project; @@ -1158,16 +1159,16 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node qDebug() << "ProjectExplorer - currentProjectChanged(" << (project ? project->name() : "0") << ")"; // Enable the right VCS if (const Core::IFile *projectFile = project ? project->file() : static_cast<const Core::IFile *>(0)) { - m_core->vcsManager()->setVCSEnabled(QFileInfo(projectFile->fileName()).absolutePath()); + core->vcsManager()->setVCSEnabled(QFileInfo(projectFile->fileName()).absolutePath()); } else { - m_core->vcsManager()->setAllVCSEnabled(); + core->vcsManager()->setAllVCSEnabled(); } emit currentProjectChanged(project); updateActions(); } - m_core->fileManager()->setCurrentFile(filePath); + core->fileManager()->setCurrentFile(filePath); } void ProjectExplorerPlugin::updateActions() @@ -1228,7 +1229,7 @@ bool ProjectExplorerPlugin::saveModifiedFiles(const QList<Project *> & projects) if (debug) qDebug() << "ProjectExplorerPlugin::saveModifiedFiles"; - QList<Core::IFile *> modifiedFi = m_core->fileManager()->modifiedFiles(); + QList<Core::IFile *> modifiedFi = Core::ICore::instance()->fileManager()->modifiedFiles(); QMap<QString, Core::IFile *> modified; QStringList allFiles; @@ -1259,7 +1260,7 @@ bool ProjectExplorerPlugin::saveModifiedFiles(const QList<Project *> & projects) if (!filesToSave.isEmpty()) { bool cancelled; - m_core->fileManager()->saveModifiedFiles(filesToSave, &cancelled, + Core::ICore::instance()->fileManager()->saveModifiedFiles(filesToSave, &cancelled, tr("The following dependencies are modified, do you want to save them?")); if (cancelled) { return false; @@ -1433,7 +1434,8 @@ void ProjectExplorerPlugin::startupProjectChanged() // NBS TODO implement more than one runner IRunConfigurationRunner *ProjectExplorerPlugin::findRunner(QSharedPointer<RunConfiguration> config, const QString &mode) { - const QList<IRunConfigurationRunner *> runners = m_core->pluginManager()->getObjects<IRunConfigurationRunner>(); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + const QList<IRunConfigurationRunner *> runners = pm->getObjects<IRunConfigurationRunner>(); foreach (IRunConfigurationRunner *runner, runners) if (runner->canRun(config, mode)) return runner; @@ -1485,7 +1487,7 @@ void ProjectExplorerPlugin::updateRecentProjectMenu() qDebug() << "ProjectExplorerPlugin::updateRecentProjectMenu"; Core::ActionContainer *aci = - m_core->actionManager()->actionContainer(Constants::M_RECENTPROJECTS); + Core::ICore::instance()->actionManager()->actionContainer(Constants::M_RECENTPROJECTS); QMenu *menu = aci->menu(); menu->clear(); m_recentProjectsActions.clear(); @@ -1552,7 +1554,7 @@ void ProjectExplorerPlugin::addNewFile() if (!m_currentNode && m_currentNode->nodeType() == ProjectNodeType) return; const QString location = QFileInfo(m_currentNode->path()).dir().absolutePath(); - m_core->showNewItemDialog(tr("New File", "Title of dialog"), + Core::ICore::instance()->showNewItemDialog(tr("New File", "Title of dialog"), Core::BaseFileWizard::findWizardsOfKind(Core::IWizard::FileWizard) + Core::BaseFileWizard::findWizardsOfKind(Core::IWizard::ClassWizard), location); @@ -1563,14 +1565,15 @@ void ProjectExplorerPlugin::addExistingFiles() if (!m_currentNode && m_currentNode->nodeType() == ProjectNodeType) return; ProjectNode *projectNode = qobject_cast<ProjectNode*>(m_currentNode); + Core::ICore *core = Core::ICore::instance(); const QString dir = QFileInfo(m_currentNode->path()).dir().absolutePath(); - QStringList fileNames = QFileDialog::getOpenFileNames(m_core->mainWindow(), tr("Add Existing Files"), dir); + QStringList fileNames = QFileDialog::getOpenFileNames(core->mainWindow(), tr("Add Existing Files"), dir); if (fileNames.isEmpty()) return; QHash<FileType, QString> fileTypeToFiles; foreach (const QString &fileName, fileNames) { - FileType fileType = typeForFileName(m_core->mimeDatabase(), QFileInfo(fileName)); + FileType fileType = typeForFileName(core->mimeDatabase(), QFileInfo(fileName)); fileTypeToFiles.insertMulti(fileType, fileName); } @@ -1581,17 +1584,17 @@ void ProjectExplorerPlugin::addExistingFiles() if (!notAdded.isEmpty()) { QString message = tr("Could not add following files to project %1:\n").arg(projectNode->name()); QString files = notAdded.join("\n"); - QMessageBox::warning(m_core->mainWindow(), tr("Add files to project failed"), + QMessageBox::warning(core->mainWindow(), tr("Add files to project failed"), message + files); foreach (const QString &file, notAdded) fileNames.removeOne(file); } - if (Core::IVersionControl *vcManager = m_core->vcsManager()->findVersionControlForDirectory(dir)) + if (Core::IVersionControl *vcManager = core->vcsManager()->findVersionControlForDirectory(dir)) if (vcManager->supportsOperation(Core::IVersionControl::AddOperation)) { const QString files = fileNames.join(QString(QLatin1Char('\n'))); QMessageBox::StandardButton button = - QMessageBox::question(m_core->mainWindow(), tr("Add to Version Control"), + QMessageBox::question(core->mainWindow(), tr("Add to Version Control"), tr("Add files\n%1\nto version control (%2)?").arg(files, vcManager->name()), QMessageBox::Yes | QMessageBox::No); if (button == QMessageBox::Yes) { @@ -1604,7 +1607,7 @@ void ProjectExplorerPlugin::addExistingFiles() if (!notAddedToVc.isEmpty()) { const QString message = tr("Could not add following files to version control (%1)\n").arg(vcManager->name()); const QString filesNotAdded = notAddedToVc.join(QString(QLatin1Char('\n'))); - QMessageBox::warning(m_core->mainWindow(), tr("Add files to version control failed"), + QMessageBox::warning(core->mainWindow(), tr("Add files to version control failed"), message + filesNotAdded); } } @@ -1615,19 +1618,22 @@ void ProjectExplorerPlugin::openFile() { if (m_currentNode) return; - m_core->editorManager()->openEditor(m_currentNode->path()); - m_core->editorManager()->ensureEditorManagerVisible(); + Core::EditorManager *em = Core::EditorManager::instance(); + em->openEditor(m_currentNode->path()); + em->ensureEditorManagerVisible(); } void ProjectExplorerPlugin::removeFile() { if (!m_currentNode && m_currentNode->nodeType() == FileNodeType) return; + FileNode *fileNode = qobject_cast<FileNode*>(m_currentNode); + Core::ICore *core = Core::ICore::instance(); const QString filePath = m_currentNode->path(); const QString fileDir = QFileInfo(filePath).dir().absolutePath(); - RemoveFileDialog removeFileDialog(filePath, m_core->mainWindow()); + RemoveFileDialog removeFileDialog(filePath, core->mainWindow()); if (removeFileDialog.exec() == QDialog::Accepted) { const bool deleteFile = removeFileDialog.isDeleteFileChecked(); @@ -1637,13 +1643,13 @@ void ProjectExplorerPlugin::removeFile() Q_ASSERT(projectNode); if (!projectNode->removeFiles(fileNode->fileType(), QStringList(filePath))) { - QMessageBox::warning(m_core->mainWindow(), tr("Remove file failed"), + QMessageBox::warning(core->mainWindow(), tr("Remove file failed"), tr("Could not remove file %1 from project %2.").arg(filePath).arg(projectNode->name())); return; } // remove from version control - m_core->vcsManager()->showDeleteDialog(filePath); + core->vcsManager()->showDeleteDialog(filePath); // remove from file system if (deleteFile) { @@ -1652,7 +1658,7 @@ void ProjectExplorerPlugin::removeFile() if (file.exists()) { // could have been deleted by vc if (!file.remove()) - QMessageBox::warning(m_core->mainWindow(), tr("Delete file failed"), + QMessageBox::warning(core->mainWindow(), tr("Delete file failed"), tr("Could not delete file %1.").arg(filePath)); } } @@ -1756,11 +1762,12 @@ void ProjectExplorerPlugin::populateOpenWithMenu() bool anyMatches = false; const QString fileName = currentNode()->path(); - if (const Core::MimeType mt = m_core->mimeDatabase()->findByFile(QFileInfo(fileName))) { - const EditorFactoryList factories = m_core->editorManager()->editorFactories(mt, false); + Core::ICore *core = Core::ICore::instance(); + if (const Core::MimeType mt = core->mimeDatabase()->findByFile(QFileInfo(fileName))) { + const EditorFactoryList factories = core->editorManager()->editorFactories(mt, false); anyMatches = !factories.empty(); if (anyMatches) { - const QList<Core::IEditor *> editorsOpenForFile = m_core->editorManager()->editorsForFileName(fileName); + const QList<Core::IEditor *> editorsOpenForFile = core->editorManager()->editorsForFileName(fileName); // Add all suitable editors foreach (Core::IEditorFactory *editorFactory, factories) { // Add action to open with this very editor factory @@ -1795,8 +1802,9 @@ void ProjectExplorerPlugin::openWithMenuTriggered(QAction *action) qWarning() << "Editor Factory not attached to action, can't happen"<<editorFactory; return; } - m_core->editorManager()->openEditor(currentNode()->path(), editorFactory->kind()); - m_core->editorManager()->ensureEditorManagerVisible(); + Core::EditorManager *em = Core::EditorManager::instance(); + em->openEditor(currentNode()->path(), editorFactory->kind()); + em->ensureEditorManagerVisible(); } void ProjectExplorerPlugin::updateSessionMenu() diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 94e25159928c66cb77fd1a4a6086eeb6867410e5..d21adb8abda09a5404ccbd6866f32986737542c0 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -54,7 +54,6 @@ namespace Core { class IContext; -class ICore; class IMode; class IFileFactory; namespace Internal { @@ -239,7 +238,6 @@ private: QMenu *m_runConfigurationMenu; QActionGroup *m_runConfigurationActionGroup; - Core::ICore *m_core; Internal::ProjectWindow *m_proWindow; SessionManager *m_session; @@ -264,6 +262,7 @@ private: }; namespace Internal { + class CoreListenerCheckingForRunningBuild : public Core::ICoreListener { Q_OBJECT @@ -275,7 +274,8 @@ public: private: BuildManager *m_manager; }; -} + +} // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectfilewizardextension.cpp b/src/plugins/projectexplorer/projectfilewizardextension.cpp index 6b928db16b553ca39369ac295180aff76420b8bc..b897dd44ff91082fb7704fa870d1376bd7043398 100644 --- a/src/plugins/projectexplorer/projectfilewizardextension.cpp +++ b/src/plugins/projectexplorer/projectfilewizardextension.cpp @@ -87,16 +87,16 @@ void AllProjectNodesVisitor::visitProjectNode(ProjectNode *node) } // --------- ProjectWizardContext -struct ProjectWizardContext { +struct ProjectWizardContext +{ Core::IVersionControl *versionControl; ProjectNodeList projects; ProjectWizardPage *page; }; // ---- ProjectFileWizardExtension -ProjectFileWizardExtension::ProjectFileWizardExtension(Core::ICore *core) : - m_core(core), - m_context(0) +ProjectFileWizardExtension::ProjectFileWizardExtension() + : m_context(0) { } @@ -115,7 +115,7 @@ void ProjectFileWizardExtension::firstExtensionPageShown(const QList<Core::Gener fileNames.push_back(f.path()); const QString directory = QFileInfo(fileNames.front()).absolutePath(); - m_context->versionControl = m_core->vcsManager()->findVersionControlForDirectory(directory); + m_context->versionControl = Core::ICore::instance()->vcsManager()->findVersionControlForDirectory(directory); m_context->page->setFilesDisplay(fileNames); @@ -175,7 +175,7 @@ bool ProjectFileWizardExtension::process(const QList<Core::GeneratedFile> &files TypeFileMap typeFileMap; foreach (const Core::GeneratedFile &generatedFile, files) { const QString path = generatedFile.path(); - typeFileMap.insert(typeForFileName(m_core->mimeDatabase(), path), path); + typeFileMap.insert(typeForFileName(Core::ICore::instance()->mimeDatabase(), path), path); } foreach (FileType type, typeFileMap.uniqueKeys()) { const QStringList files = typeFileMap.values(type); diff --git a/src/plugins/projectexplorer/projectfilewizardextension.h b/src/plugins/projectexplorer/projectfilewizardextension.h index 3008b0772e69f80d04bdde553f55c0f7483278f1..e4930e9ff0945c13e27ee7103c5d8ab76a2e8931 100644 --- a/src/plugins/projectexplorer/projectfilewizardextension.h +++ b/src/plugins/projectexplorer/projectfilewizardextension.h @@ -36,10 +36,6 @@ #include <coreplugin/ifilewizardextension.h> -namespace Core { - class ICore; -} - namespace ProjectExplorer { namespace Internal { @@ -54,7 +50,7 @@ class ProjectFileWizardExtension : public Core::IFileWizardExtension { Q_OBJECT public: - explicit ProjectFileWizardExtension(Core::ICore *core); + explicit ProjectFileWizardExtension(); virtual ~ProjectFileWizardExtension(); virtual QList<QWizardPage *> extensionPages(const Core::IWizard *wizard); @@ -64,7 +60,6 @@ public slots: virtual void firstExtensionPageShown(const QList<Core::GeneratedFile> &); private: - Core::ICore *m_core; ProjectWizardContext *m_context; }; diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index 8c71ead433456dfedfff5f04f1cb706b81e2ad5b..3329f80788a7f31a44f6fd632ae9dc98651842c0 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -112,9 +112,8 @@ protected: Shows the projects in form of a tree. */ -ProjectTreeWidget::ProjectTreeWidget(Core::ICore *core, QWidget *parent) +ProjectTreeWidget::ProjectTreeWidget(QWidget *parent) : QWidget(parent), - m_core(core), m_explorer(ProjectExplorerPlugin::instance()), m_view(0), m_model(0), @@ -282,9 +281,8 @@ void ProjectTreeWidget::initView() m_model->fetchMore(sessionIndex); // expand top level projects - for (int i = 0; i < m_model->rowCount(sessionIndex); ++i) { + for (int i = 0; i < m_model->rowCount(sessionIndex); ++i) m_view->expand(m_model->index(i, 0, sessionIndex)); - } setCurrentItem(m_explorer->currentNode(), m_explorer->currentProject()); } @@ -293,8 +291,9 @@ void ProjectTreeWidget::openItem(const QModelIndex &mainIndex) { Node *node = m_model->nodeForIndex(mainIndex); if (node->nodeType() == FileNodeType) { - m_core->editorManager()->openEditor(node->path()); - m_core->editorManager()->ensureEditorManagerVisible(); + Core::EditorManager *editorManager = Core::EditorManager::instance(); + editorManager->openEditor(node->path()); + editorManager->ensureEditorManagerVisible(); } } @@ -321,8 +320,7 @@ bool ProjectTreeWidget::projectFilter() } -ProjectTreeWidgetFactory::ProjectTreeWidgetFactory(Core::ICore *core) - : m_core(core) +ProjectTreeWidgetFactory::ProjectTreeWidgetFactory() { } @@ -343,7 +341,7 @@ QKeySequence ProjectTreeWidgetFactory::activationSequence() Core::NavigationView ProjectTreeWidgetFactory::createWidget() { Core::NavigationView n; - ProjectTreeWidget *ptw = new ProjectTreeWidget(m_core); + ProjectTreeWidget *ptw = new ProjectTreeWidget; n.widget = ptw; QToolButton *filter = new QToolButton; @@ -364,16 +362,18 @@ void ProjectTreeWidgetFactory::saveSettings(int position, QWidget *widget) { ProjectTreeWidget *ptw = qobject_cast<ProjectTreeWidget *>(widget); Q_ASSERT(ptw); - m_core->settings()->setValue("ProjectTreeWidget."+QString::number(position)+".ProjectFilter", ptw->projectFilter()); - m_core->settings()->setValue("ProjectTreeWidget."+QString::number(position)+".GeneratedFilter", ptw->generatedFilesFilter()); - m_core->settings()->setValue("ProjectTreeWidget."+QString::number(position)+".SyncWithEditor", ptw->autoSynchronization()); + QSettings *settings = Core::ICore::instance()->settings(); + settings->setValue("ProjectTreeWidget."+QString::number(position)+".ProjectFilter", ptw->projectFilter()); + settings->setValue("ProjectTreeWidget."+QString::number(position)+".GeneratedFilter", ptw->generatedFilesFilter()); + settings->setValue("ProjectTreeWidget."+QString::number(position)+".SyncWithEditor", ptw->autoSynchronization()); } void ProjectTreeWidgetFactory::restoreSettings(int position, QWidget *widget) { ProjectTreeWidget *ptw = qobject_cast<ProjectTreeWidget *>(widget); Q_ASSERT(ptw); - ptw->setProjectFilter(m_core->settings()->value("ProjectTreeWidget."+QString::number(position)+".ProjectFilter", false).toBool()); - ptw->setGeneratedFilesFilter(m_core->settings()->value("ProjectTreeWidget."+QString::number(position)+".GeneratedFilter", true).toBool()); - ptw->setAutoSynchronization(m_core->settings()->value("ProjectTreeWidget."+QString::number(position)+".SyncWithEditor", true).toBool()); + QSettings *settings = Core::ICore::instance()->settings(); + ptw->setProjectFilter(settings->value("ProjectTreeWidget."+QString::number(position)+".ProjectFilter", false).toBool()); + ptw->setGeneratedFilesFilter(settings->value("ProjectTreeWidget."+QString::number(position)+".GeneratedFilter", true).toBool()); + ptw->setAutoSynchronization(settings->value("ProjectTreeWidget."+QString::number(position)+".SyncWithEditor", true).toBool()); } diff --git a/src/plugins/projectexplorer/projecttreewidget.h b/src/plugins/projectexplorer/projecttreewidget.h index 4d9224b46e95b1da574f3cdce80fd5403def5fec..dea4c7edb21048a0bcf38ce0baed0b366577f8f7 100644 --- a/src/plugins/projectexplorer/projecttreewidget.h +++ b/src/plugins/projectexplorer/projecttreewidget.h @@ -39,10 +39,6 @@ #include <QtGui/QWidget> #include <QtGui/QTreeView> -namespace Core { -class ICore; -} - namespace ProjectExplorer { class ProjectExplorerPlugin; @@ -53,10 +49,11 @@ namespace Internal { class FlatModel; -class ProjectTreeWidget : public QWidget { +class ProjectTreeWidget : public QWidget +{ Q_OBJECT public: - ProjectTreeWidget(Core::ICore *core, QWidget *parent = 0); + explicit ProjectTreeWidget(QWidget *parent = 0); bool autoSynchronization() const; void setAutoSynchronization(bool sync, bool syncNow = true); @@ -81,7 +78,6 @@ private slots: void initView(); private: - Core::ICore *m_core; ProjectExplorerPlugin *m_explorer; QTreeView *m_view; FlatModel *m_model; @@ -99,15 +95,13 @@ private: class ProjectTreeWidgetFactory : public Core::INavigationWidgetFactory { public: - ProjectTreeWidgetFactory(Core::ICore *core); + ProjectTreeWidgetFactory(); virtual ~ProjectTreeWidgetFactory(); virtual QString displayName(); virtual QKeySequence activationSequence(); virtual Core::NavigationView createWidget(); void restoreSettings(int position, QWidget *widget); void saveSettings(int position, QWidget *widget); -private: - Core::ICore *m_core; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index e6e2455cced2f147d28b60ca86dd988cfb6661d1..2a5ae1a42b650f17e0a769fc5950b12b36ebd1e2 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -43,6 +43,7 @@ #include <coreplugin/minisplitter.h> #include <coreplugin/fileiconprovider.h> #include <coreplugin/icore.h> +#include <extensionsystem/pluginmanager.h> #include <QtCore/QDebug> #include <QtGui/QApplication> @@ -60,15 +61,12 @@ namespace { bool debug = false; } -ProjectWindow::ProjectWindow(Core::ICore *core, - QWidget *parent) : - QWidget(parent), - m_core(core) +ProjectWindow::ProjectWindow(QWidget *parent) : QWidget(parent) { setWindowTitle(tr("Project Explorer")); setWindowIcon(QIcon(":/projectexplorer/images/projectexplorer.png")); - ExtensionSystem::PluginManager *pm = m_core->pluginManager(); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ProjectExplorerPlugin *projectExplorer = m_projectExplorer = pm->getObject<ProjectExplorerPlugin>(); m_session = projectExplorer->session(); diff --git a/src/plugins/projectexplorer/projectwindow.h b/src/plugins/projectexplorer/projectwindow.h index c9b387ceaa29e0c7d9cde7742c78b254e001624a..b7ea0b6005f41c3623caeb4e5b199aa7039fd164 100644 --- a/src/plugins/projectexplorer/projectwindow.h +++ b/src/plugins/projectexplorer/projectwindow.h @@ -43,10 +43,6 @@ class QTreeWidget; class QTreeWidgetItem; QT_END_NAMESPACE -namespace Core { -class ICore; -} - namespace ProjectExplorer { class Project; @@ -56,13 +52,12 @@ class SessionManager; namespace Internal { - class ProjectWindow : public QWidget { Q_OBJECT public: - ProjectWindow(Core::ICore *core, QWidget *parent = 0); + explicit ProjectWindow(QWidget *parent = 0); ~ProjectWindow(); private slots: @@ -75,7 +70,6 @@ private slots: void handleCurrentItemChanged(QTreeWidgetItem *); private: - Core::ICore *m_core; SessionManager *m_session; ProjectExplorerPlugin *m_projectExplorer; diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index f5b83d162cd2be7e07f2aacbd21dbf83a761fa5d..88f7b53e5599203c877ad8759c06f2b640bc2d94 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -70,13 +70,12 @@ namespace { namespace ProjectExplorer { namespace Internal { -class SessionFile - : public Core::IFile +class SessionFile : public Core::IFile { Q_OBJECT public: - SessionFile(Core::ICore *core); + SessionFile(); bool load(const QString &fileName); bool save(const QString &fileName = QString()); @@ -126,9 +125,9 @@ void SessionFile::sessionLoadingProgress() QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); } -SessionFile::SessionFile(Core::ICore *core) : - m_mimeType(QLatin1String(ProjectExplorer::Constants::SESSIONFILE_MIMETYPE)), - m_core(core), +SessionFile::SessionFile() + : m_mimeType(QLatin1String(ProjectExplorer::Constants::SESSIONFILE_MIMETYPE)), + m_core(Core::ICore::instance()), m_startupProject(0) { } @@ -369,10 +368,10 @@ void Internal::SessionNodeImpl::setFileName(const QString &fileName) /* --------------------------------- */ -SessionManager::SessionManager(Core::ICore *core, QObject *parent) - : QObject(parent), - m_core(core), - m_file(new SessionFile(core)), +SessionManager::SessionManager(QObject *parent) + : QObject(parent), + m_core(Core::ICore::instance()), + m_file(new SessionFile), m_sessionNode(new Internal::SessionNodeImpl(this)) { // Create qtcreator dir if it doesn't yet exist @@ -394,12 +393,11 @@ SessionManager::SessionManager(Core::ICore *core, QObject *parent) connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)), this, SLOT(saveActiveMode(Core::IMode*))); - connect(core->editorManager(), SIGNAL(editorCreated(Core::IEditor *, QString)), + connect(m_core->editorManager(), SIGNAL(editorCreated(Core::IEditor *, QString)), this, SLOT(setEditorCodec(Core::IEditor *, QString))); connect(ProjectExplorerPlugin::instance(), SIGNAL(currentProjectChanged(ProjectExplorer::Project *)), this, SLOT(updateWindowTitle())); - - } +} SessionManager::~SessionManager() { @@ -415,7 +413,6 @@ bool SessionManager::isDefaultVirgin() const && m_core->editorManager()->openedEditors().isEmpty(); } - bool SessionManager::isDefaultSession(const QString &session) const { return session == QLatin1String("default"); @@ -600,7 +597,7 @@ bool SessionManager::createImpl(const QString &fileName) if (success) { delete m_file; emit sessionUnloaded(); - m_file = new SessionFile(m_core); + m_file = new SessionFile; m_file->setFileName(fileName); setStartupProject(defaultStartupProject()); } @@ -634,10 +631,11 @@ bool SessionManager::loadImpl(const QString &fileName) if (success) { delete m_file; + m_file = 0; emit sessionUnloaded(); - m_file = new SessionFile(m_core); + m_file = new SessionFile; if (!m_file->load(fileName)) { - QMessageBox::warning(0, tr("Error while loading session"), \ + QMessageBox::warning(0, tr("Error while loading session"), tr("Could not load session %1").arg(fileName)); success = false; } @@ -880,7 +878,6 @@ void SessionManager::setEditorCodec(Core::IEditor *editor, const QString &fileNa textEditor->setTextCodec(project->editorConfiguration()->defaultTextCodec()); } - QList<Project *> SessionManager::requestCloseOfAllFiles(bool *cancelled) { *cancelled = false; diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index f8768ab468bb57087f4edcd09626ffaf5169b4f6..cb465471f7f9c616a46a7699ae13ceed3e692243 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -65,8 +65,7 @@ class SessionFile; // Must be in header as otherwise moc has issues // with ProjectExplorer::SessionNode on msvc2005 -class SessionNodeImpl - : public ProjectExplorer::SessionNode +class SessionNodeImpl : public ProjectExplorer::SessionNode { Q_OBJECT public: @@ -86,13 +85,12 @@ public: // public interface just wrap around functions which do the actual work // This could be improved. -class PROJECTEXPLORER_EXPORT SessionManager - : public QObject +class PROJECTEXPLORER_EXPORT SessionManager : public QObject { Q_OBJECT public: - SessionManager(Core::ICore *core, QObject *parent = 0); + explicit SessionManager(QObject *parent = 0); ~SessionManager(); // higher level session management diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 5421b9bbe63f7c1a3a61e89705a33c0f81931436..0091c82f2d490b57a335e04c625e759171abfba8 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -38,6 +38,7 @@ #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/coreconstants.h> #include <coreplugin/uniqueidmanager.h> +#include <extensionsystem/pluginmanager.h> #include <texteditor/itexteditor.h> #include <texteditor/basetexteditor.h> #include <projectexplorerconstants.h> @@ -250,7 +251,7 @@ void TaskModel::setFileNotFound(const QModelIndex &idx, bool b) TaskWindow::TaskWindow() { - m_coreIFace = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); m_model = new TaskModel; m_listview = new TaskView; @@ -265,10 +266,10 @@ TaskWindow::TaskWindow() m_listview->setContextMenuPolicy(Qt::ActionsContextMenu); m_taskWindowContext = new TaskWindowContext(m_listview); - m_coreIFace->addContextObject(m_taskWindowContext); + core->addContextObject(m_taskWindowContext); m_copyAction = new QAction(QIcon(Core::Constants::ICON_COPY), tr("&Copy"), this); - m_coreIFace->actionManager()-> + core->actionManager()-> registerAction(m_copyAction, Core::Constants::COPY, m_taskWindowContext->context()); m_listview->addAction(m_copyAction); @@ -288,7 +289,7 @@ TaskWindow::TaskWindow() TaskWindow::~TaskWindow() { - m_coreIFace->removeContextObject(m_taskWindowContext); + Core::ICore::instance()->removeContextObject(m_taskWindowContext); delete m_listview; delete m_model; } @@ -314,7 +315,6 @@ void TaskWindow::clearContents() void TaskWindow::visibilityChanged(bool /* b */) { - } void TaskWindow::addItem(ProjectExplorer::BuildParserInterface::PatternType type, @@ -578,8 +578,8 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, TaskWindowContext::TaskWindowContext(QWidget *widget) : m_taskList(widget) { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - m_context << core->uniqueIDManager()->uniqueIdentifier(Core::Constants::C_PROBLEM_PANE); + Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); + m_context << uidm->uniqueIdentifier(Core::Constants::C_PROBLEM_PANE); } QList<int> TaskWindowContext::context() const diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h index 71875f9e84fb7ace6514fb2a50bde22462d7bc6b..269f6e3ce6201c8bed8c565631b957bde756a7d9 100644 --- a/src/plugins/projectexplorer/taskwindow.h +++ b/src/plugins/projectexplorer/taskwindow.h @@ -89,7 +89,6 @@ private slots: private: int sizeHintForColumn(int column) const; - Core::ICore *m_coreIFace; int m_errorCount; int m_currentTask; diff --git a/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp b/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp index fcbff3f5dcc7628ca43e40bc4a2fd15790270ad8..ea622415a2012fad7634659ca0a6cd24e7d70d61 100644 --- a/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp +++ b/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp @@ -38,6 +38,7 @@ #include "qt4project.h" #include "qt4projectmanagerconstants.h" +#include <coreplugin/icore.h> #include <utils/qtcassert.h> using namespace Qt4ProjectManager; @@ -65,8 +66,7 @@ void GdbMacrosBuildStep::run(QFutureInterface<bool> & fi) QVariant v = value("clean"); if (v.isNull() || v.toBool() == false) { // Normal run - QString dumperPath = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>() - ->resourcePath() + "/gdbmacros/"; + QString dumperPath = Core::ICore::instance()->resourcePath() + "/gdbmacros/"; QStringList files; files << "gdbmacros.cpp" << "gdbmacros.pro"; diff --git a/src/plugins/qt4projectmanager/profileeditor.cpp b/src/plugins/qt4projectmanager/profileeditor.cpp index e173bff23160e49543b63b34d89371e94e06efaf..3cab2eaaca5c06ce4c9629a60bb76333e2b9973a 100644 --- a/src/plugins/qt4projectmanager/profileeditor.cpp +++ b/src/plugins/qt4projectmanager/profileeditor.cpp @@ -40,17 +40,16 @@ #include "proeditormodel.h" #include "procommandmanager.h" -#include <coreplugin/icore.h> #include <coreplugin/uniqueidmanager.h> #include <texteditor/fontsettings.h> #include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorconstants.h> #include <texteditor/texteditorsettings.h> +#include <QtCore/QDebug> #include <QtCore/QFileInfo> -#include <QtGui/QTextEdit> #include <QtGui/QHeaderView> -#include <QtCore/QDebug> +#include <QtGui/QTextEdit> using namespace ExtensionSystem; using namespace Core; @@ -59,28 +58,24 @@ using namespace Qt4ProjectManager::Internal; using namespace ProjectExplorer; -ProFileEditorEditable::ProFileEditorEditable(ProFileEditor *editor, Core::ICore *core) - :BaseTextEditorEditable(editor) +ProFileEditorEditable::ProFileEditorEditable(ProFileEditor *editor) + : BaseTextEditorEditable(editor) { - m_context << core->uniqueIDManager()-> - uniqueIdentifier(Qt4ProjectManager::Constants::C_PROFILEEDITOR); - m_context << core->uniqueIDManager()-> - uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); -// m_contexts << core->uniqueIDManager()-> -// uniqueIdentifier(Qt4ProjectManager::Constants::PROJECT_KIND); + Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); + m_context << uidm->uniqueIdentifier(Qt4ProjectManager::Constants::C_PROFILEEDITOR); + m_context << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); +// m_contexts << uidm->uniqueIdentifier(Qt4ProjectManager::Constants::PROJECT_KIND); } TextEditor::BaseTextEditorEditable *ProFileEditor::createEditableInterface() { - return new ProFileEditorEditable(this, m_core); + return new ProFileEditorEditable(this); } ProFileEditor::ProFileEditor(QWidget *parent, ProFileEditorFactory *factory, TextEditor::TextEditorActionHandler *ah) : BaseTextEditor(parent), m_factory(factory), m_ah(ah) { Qt4Manager *manager = factory->qt4ProjectManager(); - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - ProFileDocument *doc = new ProFileDocument(manager); doc->setMimeType(QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE)); setBaseTextDocument(doc); diff --git a/src/plugins/qt4projectmanager/profileeditor.h b/src/plugins/qt4projectmanager/profileeditor.h index e2c6c3be5c872ca5fe4b8f6a658462edb63010e4..256e9a9500801b5646724b1e01a09ff095214318 100644 --- a/src/plugins/qt4projectmanager/profileeditor.h +++ b/src/plugins/qt4projectmanager/profileeditor.h @@ -41,12 +41,6 @@ namespace TextEditor { class FontSettings; -class BaseEditorActionHandler; -} - -namespace Core { -class ICore; -class IFile; } namespace Qt4ProjectManager { @@ -66,7 +60,7 @@ class ProFileEditor; class ProFileEditorEditable : public TextEditor::BaseTextEditorEditable { public: - ProFileEditorEditable(ProFileEditor *, Core::ICore *core); + ProFileEditorEditable(ProFileEditor *); QList<int> context() const; bool duplicateSupported() const { return true; } @@ -98,7 +92,6 @@ public slots: virtual void setFontSettings(const TextEditor::FontSettings &); private: - Core::ICore *m_core; ProFileEditorFactory *m_factory; TextEditor::TextEditorActionHandler *m_ah; }; diff --git a/src/plugins/qt4projectmanager/profileeditorfactory.cpp b/src/plugins/qt4projectmanager/profileeditorfactory.cpp index dfe8c33232f29497cfdd1cb3d723ebe6385314df..21299bb2feae79771dc1dfa34a22eaecb97904b5 100644 --- a/src/plugins/qt4projectmanager/profileeditorfactory.cpp +++ b/src/plugins/qt4projectmanager/profileeditorfactory.cpp @@ -37,7 +37,6 @@ #include "qt4projectmanagerconstants.h" #include "profileeditor.h" -#include <coreplugin/icore.h> #include <coreplugin/fileiconprovider.h> #include <coreplugin/editormanager/editormanager.h> #include <texteditor/texteditoractionhandler.h> @@ -74,8 +73,7 @@ QString ProFileEditorFactory::kind() const Core::IFile *ProFileEditorFactory::open(const QString &fileName) { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - Core::IEditor *iface = core->editorManager()->openEditor(fileName, kind()); + Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, kind()); return iface ? iface->file() : 0; } diff --git a/src/plugins/qt4projectmanager/qt4buildconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4buildconfigwidget.cpp index 0a53b99b62d37dc632f86546650619c2c84fbd26..46d5b106f5cf41bfad75b01cd39b06dc8b39e218 100644 --- a/src/plugins/qt4projectmanager/qt4buildconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4buildconfigwidget.cpp @@ -36,11 +36,11 @@ #include "makestep.h" #include "qmakestep.h" #include "qt4project.h" +#include "qt4projectmanagerconstants.h" #include "qt4projectmanager.h" #include "ui_qt4buildconfigwidget.h" -#include <extensionsystem/pluginmanager.h> + #include <coreplugin/mainwindow.h> -#include "qt4projectmanagerconstants.h" #include <QtGui/QFileDialog> @@ -93,7 +93,7 @@ Qt4BuildConfigWidget::~Qt4BuildConfigWidget() void Qt4BuildConfigWidget::manageQtVersions() { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); core->showOptionsDialog(Constants::QT_CATEGORY, Constants::QTVERSION_PAGE); } diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index c7bf1e5803503c0e085fcb8ffacc02cf47adf403..d7a1783feb52b39c810aa8f10d2f5195210a72ec 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -50,6 +50,7 @@ #include <cpptools/cppmodelmanagerinterface.h> #include <cplusplus/CppDocument.h> +#include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> @@ -261,7 +262,7 @@ bool Qt4PriFileNode::changeIncludes(ProFile *includeFile, const QStringList &pro bool Qt4PriFileNode::priFileWritable(const QString &path) { const QString dir = QFileInfo(path).dir().path(); - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); Core::IVersionControl *versionControl = core->vcsManager()->findVersionControlForDirectory(dir); switch (Core::EditorManager::promptReadOnlyFile(path, versionControl, core->mainWindow(), false)) { case Core::EditorManager::RO_OpenVCS: @@ -290,7 +291,7 @@ bool Qt4PriFileNode::saveModifiedEditors(const QString &path) QList<Core::IFile*> allFileHandles; QList<Core::IFile*> modifiedFileHandles; - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); foreach (Core::IFile *file, core->fileManager()->managedFiles(path)) { allFileHandles << file; @@ -427,7 +428,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType, void Qt4PriFileNode::save(ProFile *includeFile) { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); Core::FileManager *fileManager = core->fileManager(); QList<Core::IFile *> allFileHandles = fileManager->managedFiles(includeFile->fileName()); Core::IFile *modifiedFileHandle = 0; @@ -838,13 +839,12 @@ void Qt4ProFileNode::updateUiFiles() ProFileReader *Qt4PriFileNode::createProFileReader() const { ProFileReader *reader = new ProFileReader(); - connect(reader, SIGNAL(errorFound(const QString &)), - m_project, SLOT(proFileParseError(const QString &))); + connect(reader, SIGNAL(errorFound(QString)), + m_project, SLOT(proFileParseError(QString))); QtVersion *version = m_project->qtVersion(m_project->activeBuildConfiguration()); - if (version->isValid()) { + if (version->isValid()) reader->setQtVersion(version); - } reader->setOutputDir(m_qt4ProFileNode->buildDir()); diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index cb5d99a642b5ceea1fd4c91f69d8f5aa35d669a0..a8fdc907cd0bb1a24a4fdb4fab2092a45f443310 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -48,21 +48,22 @@ #include "projectloadwizard.h" #include "gdbmacrosbuildstep.h" +#include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> #include <coreplugin/coreconstants.h> #include <cpptools/cppmodelmanagerinterface.h> +#include <extensionsystem/pluginmanager.h> #include <projectexplorer/nodesvisitor.h> #include <projectexplorer/project.h> #include <projectexplorer/customexecutablerunconfiguration.h> -#include <QtGui/QFileDialog> -#include <QtCore/QDir> #include <QtCore/QDebug> +#include <QtCore/QDir> +#include <QtGui/QFileDialog> using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; using namespace ProjectExplorer; -using Core::VariableManager; enum { debug = 0 }; @@ -380,9 +381,10 @@ void Qt4Project::updateCodeModel() qDebug()<<"Qt4Project::updateCodeModel()"; CppTools::CppModelManagerInterface *modelmanager = - m_manager->pluginManager()->getObject<CppTools::CppModelManagerInterface>(); + ExtensionSystem::PluginManager::instance() + ->getObject<CppTools::CppModelManagerInterface>(); - if (! modelmanager) + if (!modelmanager) return; QStringList allIncludePaths; @@ -643,7 +645,7 @@ void Qt4Project::newBuildConfiguration(const QString &buildConfiguration) void Qt4Project::proFileParseError(const QString &errorMessage) { - m_manager->core()->messageManager()->printToOutputPane(errorMessage); + Core::ICore::instance()->messageManager()->printToOutputPane(errorMessage); } Qt4ProFileNode *Qt4Project::rootProjectNode() const diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index c589d2eb8651f66b975a44f0e8a5bc2c462d979a..4356b0b536e80e69fe78b23ab667bb37b260ee63 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -42,6 +42,7 @@ #include "qmakestep.h" #include <extensionsystem/pluginmanager.h> +#include <coreplugin/icore.h> #include <coreplugin/basefilewizard.h> #include <coreplugin/messagemanager.h> #include <coreplugin/uniqueidmanager.h> @@ -53,13 +54,13 @@ #include <projectexplorer/projectexplorerconstants.h> #include <utils/listutils.h> -#include <QtCore/QVariant> -#include <QtCore/QFileInfo> -#include <QtCore/QDir> #include <QtCore/QCoreApplication> +#include <QtCore/QDir> +#include <QtCore/QFileInfo> #include <QtCore/QLinkedList> -#include <QtGui/QMenu> +#include <QtCore/QVariant> #include <QtGui/QFileDialog> +#include <QtGui/QMenu> #include <QtGui/QMessageBox> using namespace Qt4ProjectManager; @@ -81,16 +82,15 @@ static const char* qt4FileTypes[] = { "Qt4ResourceFiles" }; -Qt4Manager::Qt4Manager(Qt4ProjectManagerPlugin *plugin, Core::ICore *core) : - m_mimeType(QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE)), +Qt4Manager::Qt4Manager(Qt4ProjectManagerPlugin *plugin) + : m_mimeType(QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE)), m_plugin(plugin), - m_core(core), m_projectExplorer(0), m_contextProject(0), m_languageID(0) { - m_languageID = m_core->uniqueIDManager()-> - uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX); + m_languageID = Core::UniqueIDManager::instance()-> + uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX); } Qt4Manager::~Qt4Manager() @@ -115,7 +115,8 @@ void Qt4Manager::notifyChanged(const QString &name) void Qt4Manager::init() { - m_projectExplorer = m_core->pluginManager()->getObject<ProjectExplorer::ProjectExplorerPlugin>(); + m_projectExplorer = ExtensionSystem::PluginManager::instance() + ->getObject<ProjectExplorer::ProjectExplorerPlugin>(); } int Qt4Manager::projectContext() const @@ -142,7 +143,8 @@ ProjectExplorer::Project* Qt4Manager::openProject(const QString &fileName) QString errorMessage; - m_core->messageManager()->displayStatusBarMessage(tr("Loading project %1 ...").arg(fileName), 50000); + Core::MessageManager *messageManager = Core::ICore::instance()->messageManager(); + messageManager->displayStatusBarMessage(tr("Loading project %1 ...").arg(fileName), 50000); // TODO Make all file paths relative & remove this hack // We convert the path to an absolute one here because qt4project.cpp @@ -151,25 +153,25 @@ ProjectExplorer::Project* Qt4Manager::openProject(const QString &fileName) QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath(); if (canonicalFilePath.isEmpty()) { - m_core->messageManager()->printToOutputPane(tr("Failed opening project '%1': Project file does not exist").arg(canonicalFilePath)); - m_core->messageManager()->displayStatusBarMessage(tr("Failed opening project"), 5000); + messageManager->printToOutputPane(tr("Failed opening project '%1': Project file does not exist").arg(canonicalFilePath)); + messageManager->displayStatusBarMessage(tr("Failed opening project"), 5000); return 0; } foreach (ProjectExplorer::Project *pi, projectExplorer()->session()->projects()) { if (canonicalFilePath == pi->file()->fileName()) { - m_core->messageManager()->printToOutputPane(tr("Failed opening project '%1': Project already open").arg(canonicalFilePath)); - m_core->messageManager()->displayStatusBarMessage(tr("Failed opening project"), 5000); + messageManager->printToOutputPane(tr("Failed opening project '%1': Project already open").arg(canonicalFilePath)); + messageManager->displayStatusBarMessage(tr("Failed opening project"), 5000); return 0; } } - m_core->messageManager()->displayStatusBarMessage(tr("Opening %1 ...").arg(fileName)); + messageManager->displayStatusBarMessage(tr("Opening %1 ...").arg(fileName)); QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); Qt4Project *pro = new Qt4Project(this, canonicalFilePath); - m_core->messageManager()->displayStatusBarMessage(tr("Done opening project"), 5000); + messageManager->displayStatusBarMessage(tr("Done opening project"), 5000); return pro; } @@ -178,16 +180,6 @@ ProjectExplorer::ProjectExplorerPlugin *Qt4Manager::projectExplorer() const return m_projectExplorer; } -Core::ICore *Qt4Manager::core() const -{ - return m_core; -} - -ExtensionSystem::PluginManager *Qt4Manager::pluginManager() const -{ - return m_core->pluginManager(); -} - ProjectExplorer::Node *Qt4Manager::contextNode() const { return m_contextNode; diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.h b/src/plugins/qt4projectmanager/qt4projectmanager.h index 4bb4d6eaf188bed1ed8683a276c4ea4e367cecff..b6fc317362e7dbf20950f3df9b1de7036b1c727f 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.h +++ b/src/plugins/qt4projectmanager/qt4projectmanager.h @@ -44,10 +44,6 @@ namespace ExtensionSystem { class PluginManager; } -namespace Core { -class ICore; -} - namespace ProjectExplorer { class Project; class ProjectExplorerPlugin; @@ -64,13 +60,12 @@ class QtVersionManager; class Qt4Project; -class Qt4Manager - : public ProjectExplorer::IProjectManager +class Qt4Manager : public ProjectExplorer::IProjectManager { Q_OBJECT public: - Qt4Manager(Internal::Qt4ProjectManagerPlugin *plugin, Core::ICore *core); + Qt4Manager(Internal::Qt4ProjectManagerPlugin *plugin); ~Qt4Manager(); void init(); @@ -80,10 +75,8 @@ public: void notifyChanged(const QString &name); ProjectExplorer::ProjectExplorerPlugin *projectExplorer() const; - ExtensionSystem::PluginManager *pluginManager() const; - Core::ICore *core() const; - //ProjectExplorer::IProjectManager + // ProjectExplorer::IProjectManager int projectContext() const; int projectLanguage() const; @@ -111,7 +104,6 @@ private: const QString m_mimeType; Internal::Qt4ProjectManagerPlugin *m_plugin; - Core::ICore *m_core; ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; ProjectExplorer::Node *m_contextNode; diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp index a8dfb4cb89dd72581845689d114e8d78381f1179..0d90983aa88f389999da2c8a909283490364ec23 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp @@ -48,6 +48,8 @@ #include "profilereader.h" #include "gdbmacrosbuildstep.h" +#include <coreplugin/icore.h> +#include <extensionsystem/pluginmanager.h> #include <projectexplorer/buildmanager.h> #include <projectexplorer/project.h> #include <projectexplorer/projectexplorer.h> @@ -58,13 +60,12 @@ #include <coreplugin/actionmanager/actionmanager.h> #include <texteditor/texteditoractionhandler.h> -#include <QtCore/qplugin.h> +#include <QtCore/QDebug> +#include <QtCore/QtPlugin> #include <QtGui/QMenu> -#include <QDebug> #ifdef WITH_TESTS #include <QTest> -#include <extensionsystem/pluginmanager.h> #endif using namespace Qt4ProjectManager::Internal; @@ -95,33 +96,37 @@ static Core::Command *createSeparator(Core::ActionManager *am, return am->registerAction(tmpaction, name, context); } */ -bool Qt4ProjectManagerPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) + +bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *errorMessage) { - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - if (!m_core->mimeDatabase()->addMimeTypes(QLatin1String(":qt4projectmanager/Qt4ProjectManager.mimetypes.xml"), errorMessage)) + Q_UNUSED(arguments); + + Core::ICore *core = Core::ICore::instance(); + if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":qt4projectmanager/Qt4ProjectManager.mimetypes.xml"), errorMessage)) return false; - m_projectExplorer = m_core->pluginManager()->getObject<ProjectExplorer::ProjectExplorerPlugin>(); + m_projectExplorer = ExtensionSystem::PluginManager::instance() + ->getObject<ProjectExplorer::ProjectExplorerPlugin>(); - Core::ActionManager *am = m_core->actionManager(); + Core::ActionManager *am = core->actionManager(); //create and register objects - m_qt4ProjectManager = new Qt4Manager(this, m_core); + m_qt4ProjectManager = new Qt4Manager(this); addObject(m_qt4ProjectManager); TextEditor::TextEditorActionHandler *editorHandler - = new TextEditor::TextEditorActionHandler(m_core, Constants::C_PROFILEEDITOR); + = new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR); m_proFileEditorFactory = new ProFileEditorFactory(m_qt4ProjectManager, editorHandler); addObject(m_proFileEditorFactory); - GuiAppWizard *guiWizard = new GuiAppWizard(m_core); + GuiAppWizard *guiWizard = new GuiAppWizard; addAutoReleasedObject(guiWizard); - ConsoleAppWizard *consoleWizard = new ConsoleAppWizard(m_core); + ConsoleAppWizard *consoleWizard = new ConsoleAppWizard; addAutoReleasedObject(consoleWizard); - LibraryWizard *libWizard = new LibraryWizard(m_core); + LibraryWizard *libWizard = new LibraryWizard; addAutoReleasedObject(libWizard); addAutoReleasedObject(new QMakeBuildStepFactory); @@ -148,7 +153,7 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList & /*arguments*/, QStr am->actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT); //register actions - m_projectContext = m_core->uniqueIDManager()-> + m_projectContext = core->uniqueIDManager()-> uniqueIdentifier(Qt4ProjectManager::Constants::PROJECT_KIND); QList<int> context = QList<int>() << m_projectContext; Core::Command *command; diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h index 584a9bfca47472b6e44dcfca319eabe7fc64380d..374e8918345e49a1049e0c8418817e8ef0f156e8 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h +++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.h @@ -36,7 +36,6 @@ #include <projectexplorer/project.h> #include <projectexplorer/projectexplorer.h> -#include <coreplugin/icore.h> namespace Qt4ProjectManager { @@ -79,7 +78,6 @@ private slots: #endif private: - Core::ICore *m_core; ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; ProFileEditorFactory *m_proFileEditorFactory; Qt4Manager *m_qt4ProjectManager; diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp index 64961844996e1fab4f255dc3154917960634688e..3ff03bcc28a305115a3828fed94b71f780f7b475 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp @@ -181,8 +181,7 @@ void Qt4RunConfiguration::updateCachedValues() ProFileReader *reader = static_cast<Qt4Project *>(project())->createProFileReader(); if (!reader->readProFile(m_proFilePath)) { delete reader; - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - core->messageManager()->printToOutputPane(QString("Could not parse %1. The Qt4 run configuration %2 can not be started.").arg(m_proFilePath).arg(name())); + Core::ICore::instance()->messageManager()->printToOutputPane(QString("Could not parse %1. The Qt4 run configuration %2 can not be started.").arg(m_proFilePath).arg(name())); return; } @@ -232,7 +231,7 @@ QString Qt4RunConfiguration::resolveVariables(const QString &buildConfiguration, QString relSubDir = QFileInfo(project()->file()->fileName()).absoluteDir().relativeFilePath(m_srcDir); QString baseDir = QDir(project()->buildDirectory(buildConfiguration)).absoluteFilePath(relSubDir); - Core::VariableManager *vm = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->variableManager(); + Core::VariableManager *vm = Core::ICore::instance()->variableManager(); if (!vm) return QString(); QString dest; diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 2becf5465507bb1e79b2ae5fc74951c0d347df3c..6e67989158b6424f4da2f06c0bc1591016eb471e 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -37,7 +37,9 @@ #include "msvcenvironment.h" #include "cesdkhandler.h" +#include <coreplugin/icore.h> #include <coreplugin/coreconstants.h> +#include <extensionsystem/pluginmanager.h> #include <help/helpplugin.h> #include <utils/qtcassert.h> @@ -62,8 +64,7 @@ static const char *newQtVersionsKey = "NewQtVersions"; QtVersionManager::QtVersionManager() : m_emptyVersion(new QtVersion) { - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - QSettings *s = m_core->settings(); + QSettings *s = Core::ICore::instance()->settings(); m_defaultVersion = s->value(defaultQtVersionKey, 0).toInt(); m_idcount = 1; @@ -115,7 +116,8 @@ void QtVersionManager::addVersion(QtVersion *version) void QtVersionManager::updateDocumentation() { - Help::HelpManager *helpManager = m_core->pluginManager()->getObject<Help::HelpManager>(); + Help::HelpManager *helpManager + = ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>(); Q_ASSERT(helpManager); QStringList fileEndings = QStringList() << "/qch/qt.qch" << "/qch/qmake.qch" << "/qch/designer.qch"; QStringList files; @@ -195,7 +197,7 @@ void QtVersionManager::apply() void QtVersionManager::writeVersionsIntoSettings() { - QSettings *s = m_core->settings(); + QSettings *s = Core::ICore::instance()->settings(); s->setValue(defaultQtVersionKey, m_defaultVersion); s->beginWriteArray("QtVersions"); for (int i = 0; i < m_versions.size(); ++i) { @@ -234,7 +236,7 @@ void QtVersionManager::addNewVersionsFromInstaller() // NewQtVersions="qt 4.3.2=c:\\qt\\qt432;qt embedded=c:\\qtembedded;" // or NewQtVersions="qt 4.3.2=c:\\qt\\qt432=c:\\qtcreator\\mingw\\=prependToPath; // Duplicate entries are not added, the first new version is set as default. - QSettings *settings = m_core->settings(); + QSettings *settings = Core::ICore::instance()->settings(); if (!settings->contains(newQtVersionsKey)) return; diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index 872b44b2178ff8f3c6926fb3340592a5a819202b..f6ccd017b67e7edd9cd16548e06cfd967d3604d1 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -37,7 +37,6 @@ #include "ui_qtversionmanager.h" #include <coreplugin/dialogs/ioptionspage.h> -#include <coreplugin/icore.h> #include <projectexplorer/projectexplorer.h> #include <QtCore/QDebug> @@ -208,7 +207,6 @@ private: static int indexOfVersionInList(const QtVersion * const version, const QList<QtVersion *> &list); void updateUniqueIdToIndexMap(); - Core::ICore *m_core; QPointer<QtDirWidget> m_widget; QtVersion *m_emptyVersion; diff --git a/src/plugins/qt4projectmanager/wizards/consoleappwizard.cpp b/src/plugins/qt4projectmanager/wizards/consoleappwizard.cpp index 73884791fe829f8b4e9f36482e28aa269869a3d1..402ba7a2ffa3ba80efcb03d5f6d46b80867502ed 100644 --- a/src/plugins/qt4projectmanager/wizards/consoleappwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/consoleappwizard.cpp @@ -58,8 +58,8 @@ static const char *mainSourceFileC = "main"; namespace Qt4ProjectManager { namespace Internal { -ConsoleAppWizard::ConsoleAppWizard(Core::ICore *core) : - QtWizard(core, tr("Qt4 Console Application"), +ConsoleAppWizard::ConsoleAppWizard() + : QtWizard(tr("Qt4 Console Application"), tr("Creates a Qt4 console application."), QIcon(":/wizards/images/console.png")) { diff --git a/src/plugins/qt4projectmanager/wizards/consoleappwizard.h b/src/plugins/qt4projectmanager/wizards/consoleappwizard.h index 36fff218ddefd88be03bf18011f8b87b86ec02fe..be080c08507354388a9f2c41ac78b178519672f7 100644 --- a/src/plugins/qt4projectmanager/wizards/consoleappwizard.h +++ b/src/plugins/qt4projectmanager/wizards/consoleappwizard.h @@ -46,7 +46,7 @@ class ConsoleAppWizard : public QtWizard Q_OBJECT public: - explicit ConsoleAppWizard(Core::ICore *core); + ConsoleAppWizard(); protected: virtual QWizard *createWizardDialog(QWidget *parent, diff --git a/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp b/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp index 14df3821ccddfebb610926f50f4cc36298dc2618..d0a626aecce96b2f97a840d4fc34d34e151ea9e0 100644 --- a/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp @@ -70,12 +70,10 @@ static inline QStringList baseClasses() } namespace Qt4ProjectManager { - namespace Internal { -GuiAppWizard::GuiAppWizard(Core::ICore *core) : - QtWizard(core, - tr("Qt4 Gui Application"), +GuiAppWizard::GuiAppWizard() + : QtWizard(tr("Qt4 Gui Application"), tr("Creates a Qt4 Gui Application with one form."), QIcon(":/wizards/images/gui.png")) { diff --git a/src/plugins/qt4projectmanager/wizards/guiappwizard.h b/src/plugins/qt4projectmanager/wizards/guiappwizard.h index dd7d7e7d02d3cb5e8f6c22981cefb204f93b39be..d3ce961b2f2b415e25f3c59984d060777218c302 100644 --- a/src/plugins/qt4projectmanager/wizards/guiappwizard.h +++ b/src/plugins/qt4projectmanager/wizards/guiappwizard.h @@ -47,7 +47,7 @@ class GuiAppWizard : public QtWizard Q_OBJECT public: - explicit GuiAppWizard(Core::ICore *core); + GuiAppWizard(); protected: virtual QWizard *createWizardDialog(QWidget *parent, diff --git a/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp index 0bc379ecbeaf50e76741b4fa52175d8a67e84008..0c3c6513eb36a90e071bd1e69dec534e549439f7 100644 --- a/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp +++ b/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp @@ -91,7 +91,7 @@ void GuiAppWizardDialog::setBaseClasses(const QStringList &baseClasses) m_filesPage->setBaseClassName(baseClasses.front()); } -void GuiAppWizardDialog::setSuffixes(const QString &header, const QString &source, const QString &form) +void GuiAppWizardDialog::setSuffixes(const QString &header, const QString &source, const QString &form) { m_filesPage->setSuffixes(header, source, form); } diff --git a/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.h b/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.h index 080cf802c26c606561f97a1752c9e8164dccbb59..dbd2b69a421b3379bac229904617f71ba1a8be79 100644 --- a/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.h +++ b/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.h @@ -37,10 +37,12 @@ #include <QtGui/QWizard> namespace Core { - namespace Utils { - class ProjectIntroPage; - } -} +namespace Utils { + +class ProjectIntroPage; + +} // namespace Utils +} // namespace Core namespace Qt4ProjectManager { namespace Internal { @@ -50,7 +52,8 @@ class ModulesPage; class FilesPage; // Additional parameters required besides QtProjectParameters -struct GuiAppParameters { +struct GuiAppParameters +{ GuiAppParameters(); QString className; QString baseClassName; diff --git a/src/plugins/qt4projectmanager/wizards/librarywizard.cpp b/src/plugins/qt4projectmanager/wizards/librarywizard.cpp index e79cd1b6588f04b3eea9e7093a29401fcd59351f..788563f5cc3319edd46bdb3d084c38d05ecf7fc1 100644 --- a/src/plugins/qt4projectmanager/wizards/librarywizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/librarywizard.cpp @@ -50,8 +50,8 @@ namespace Qt4ProjectManager { namespace Internal { -LibraryWizard::LibraryWizard(Core::ICore *core) : - QtWizard(core, tr("C++ Library"), +LibraryWizard::LibraryWizard() + : QtWizard(tr("C++ Library"), tr("Creates a C++ Library."), QIcon(":/wizards/images/lib.png")) { @@ -69,8 +69,9 @@ QWizard *LibraryWizard::createWizardDialog(QWidget *parent, Core::GeneratedFiles LibraryWizard::generateFiles(const QWizard *w, - QString * /*errorMessage*/) const + QString *errorMessage) const { + Q_UNUSED(errorMessage); const LibraryWizardDialog *dialog = qobject_cast<const LibraryWizardDialog *>(w); const QtProjectParameters projectParams = dialog->parameters(); const QString projectPath = projectParams.projectPath(); diff --git a/src/plugins/qt4projectmanager/wizards/librarywizard.h b/src/plugins/qt4projectmanager/wizards/librarywizard.h index 203179d4c9114e72ad00698bf552def824c9d558..f5e6b2af845c377dd822a5771eade334b78fc62c 100644 --- a/src/plugins/qt4projectmanager/wizards/librarywizard.h +++ b/src/plugins/qt4projectmanager/wizards/librarywizard.h @@ -48,7 +48,7 @@ class LibraryWizard : public QtWizard Q_OBJECT public: - explicit LibraryWizard(Core::ICore *core); + LibraryWizard(); protected: virtual QWizard *createWizardDialog(QWidget *parent, diff --git a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp index 15f334cf2023008caf38b4d22a899fc940ec5ae2..a8fd467f80e40878b58148c7b18d11c7ddeb6f7b 100644 --- a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp @@ -35,6 +35,8 @@ #include "qt4project.h" #include "qt4projectmanagerconstants.h" +#include <coreplugin/icore.h> +#include <extensionsystem/pluginmanager.h> #include <projectexplorer/projectexplorer.h> #include <QtCore/QByteArray> @@ -61,9 +63,8 @@ static inline Core::BaseFileWizardParameters } // -------------------- QtWizard -QtWizard::QtWizard(Core::ICore *core, const QString &name, - const QString &description, const QIcon &icon) : - Core::BaseFileWizard(wizardParameters(name, description, icon), core), +QtWizard::QtWizard(const QString &name, const QString &description, const QIcon &icon) : + Core::BaseFileWizard(wizardParameters(name, description, icon)), m_projectExplorer(ExtensionSystem::PluginManager::instance()->getObject<ProjectExplorer::ProjectExplorerPlugin>()) { } @@ -101,7 +102,7 @@ bool QtWizard::postGenerateFiles(const Core::GeneratedFiles &l, QString *errorMe QString QtWizard::templateDir() const { - QString rc = core()->resourcePath(); + QString rc = Core::ICore::instance()->resourcePath(); rc += QLatin1String("/templates/qt4project"); return rc; } diff --git a/src/plugins/qt4projectmanager/wizards/qtwizard.h b/src/plugins/qt4projectmanager/wizards/qtwizard.h index 9858251a9dfd98f80383448d5518f58e7f527cf4..dd031ef7e013a97bda2f8c3bbd8ce8e64cc62e30 100644 --- a/src/plugins/qt4projectmanager/wizards/qtwizard.h +++ b/src/plugins/qt4projectmanager/wizards/qtwizard.h @@ -38,13 +38,8 @@ #include <coreplugin/basefilewizard.h> -QT_BEGIN_NAMESPACE -class QTextStream; -class QDir; -QT_END_NAMESPACE - namespace ProjectExplorer { - class ProjectExplorerPlugin; +class ProjectExplorerPlugin; } namespace Qt4ProjectManager { @@ -60,14 +55,11 @@ namespace Internal { class QtWizard : public Core::BaseFileWizard { - Q_DISABLE_COPY(QtWizard) Q_OBJECT - -public: + Q_DISABLE_COPY(QtWizard) protected: - explicit QtWizard(Core::ICore *core, const QString &name, - const QString &description, const QIcon &icon); + QtWizard(const QString &name, const QString &description, const QIcon &icon); QString templateDir() const; diff --git a/src/plugins/qtestlib/qtestlibplugin.cpp b/src/plugins/qtestlib/qtestlibplugin.cpp index 5b38e05b33afee294bbfe334759bcf521f07050f..3bb2d1df359366da08993e6aa88e84360448acfc 100644 --- a/src/plugins/qtestlib/qtestlibplugin.cpp +++ b/src/plugins/qtestlib/qtestlibplugin.cpp @@ -33,25 +33,26 @@ #include "qtestlibplugin.h" -#include <QtCore/qplugin.h> -#include <QIcon> -#include <QDebug> -#include <QKeySequence> -#include <QAction> -#include <QHeaderView> -#include <QDomDocument> -#include <QTemporaryFile> -#include <texteditor/TextEditorInterfaces> -#include <Qt4IProjectManagers> -#include <QFileInfo> -#include <QDir> -#include <QStandardItemModel> -#include <QTreeView> -#include <QTextEdit> -#include <QSplitter> -#include <QVBoxLayout> -#include <QComboBox> -#include <QLabel> +//#include <Qt4IProjectManagers> +//#include <texteditor/TextEditorInterfaces> + +#include <QtCore/QDebug> +#include <QtCore/QDir> +#include <QtCore/QFileInfo> +#include <QtCore/QTemporaryFile> +#include <QtCore/QtPlugin> +#include <QtGui/QAction> +#include <QtGui/QComboBox> +#include <QtGui/QHeaderView> +#include <QtGui/QIcon> +#include <QtGui/QKeySequence> +#include <QtGui/QLabel> +#include <QtGui/QSplitter> +#include <QtGui/QStandardItemModel> +#include <QtGui/QTextEdit> +#include <QtGui/QTreeView> +#include <QtGui/QVBoxLayout> +#include <QtXml/QDomDocument> using namespace QTestLib::Internal; @@ -128,10 +129,9 @@ QTestLibPlugin::~QTestLibPlugin() m_core->pluginManager()->removeObject(m_outputPane); } -bool QTestLibPlugin::init(ExtensionSystem::PluginManagerInterface *app, QString * /*error_message*/) +bool QTestLibPlugin::init(ExtensionSystem::PluginManagerInterface *app, QString *errorMessage) { - m_core = app->getObject<Core::ICore>(); - + Q_UNUSED(errorMessage); m_projectExplorer = app->getObject<ProjectExplorer::ProjectExplorerPlugin>(); connect(m_projectExplorer->qObject(), SIGNAL(aboutToExecuteProject(ProjectExplorer::Project *)), this, SLOT(projectRunHook(ProjectExplorer::Project *))); @@ -382,9 +382,8 @@ bool QTestOutputFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourc // ------- QTestOutputWidget -QTestOutputWidget::QTestOutputWidget(QStandardItemModel *model, Core::ICore *coreInterface, QWidget *parent): - QWidget(parent), - m_coreInterface(coreInterface), +QTestOutputWidget::QTestOutputWidget(QStandardItemModel *model, QWidget *parent) + : QWidget(parent), m_model(model), m_resultsView(new QTreeView(this)), m_filterCombo(new QComboBox(this)), diff --git a/src/plugins/qtestlib/qtestlibplugin.h b/src/plugins/qtestlib/qtestlibplugin.h index 2c804a16c3a3d80b2ce92225b976b5d5712a340f..c442a1ddec6b00235bd47fbed19990fa15a7ceb5 100644 --- a/src/plugins/qtestlib/qtestlibplugin.h +++ b/src/plugins/qtestlib/qtestlibplugin.h @@ -35,17 +35,19 @@ #define QTESTLIBPLUGIN_H #include <coreplugin/ioutputpane.h> -#include <projectexplorer/ProjectExplorerInterfaces> +//#include <projectexplorer/ProjectExplorerInterfaces> -#include <QPixmap> -#include <QStandardItem> -#include <QWidget> -#include <QSortFilterProxyModel> +#include <QtGui/QPixmap> +#include <QtGui/QStandardItem> +#include <QtGui/QWidget> +#include <QtGui/QSortFilterProxyModel> +QT_BEGIN_NAMESPACE class QStandardItemModel; class QTreeView; class QTextEdit; class QComboBox; +QT_END_NAMESPACE namespace QTestLib { namespace Internal { @@ -96,11 +98,10 @@ public: static bool indexHasIncidents(const QModelIndex &function, IncidentType type); }; -class QTestOutputPane : public QObject, - public Core::IOutputPane +class QTestOutputPane : public Core::IOutputPane { Q_OBJECT - Q_INTERFACES(Core::IOutputPane) + //Q_INTERFACES(Core::IOutputPane) public: QTestOutputPane(QTestLibPlugin *plugin); @@ -147,10 +148,9 @@ private: class QTestOutputWidget : public QWidget { Q_OBJECT + public: - QTestOutputWidget(QStandardItemModel *model, - Core::ICore *iCore, - QWidget *parent); + QTestOutputWidget(QStandardItemModel *model, QWidget *parent); void expand(); @@ -159,7 +159,6 @@ private Q_SLOTS: void gotoLocation(QModelIndex index); private: - Core::ICore *m_coreInterface; QStandardItemModel *m_model; QTreeView *m_resultsView; QComboBox *m_filterCombo; @@ -181,10 +180,6 @@ public: bool init(ExtensionSystem::PluginManagerInterface *app, QString *error_message); void extensionsInitialized(); - inline Core::ICore *coreInterface() const { - return m_core; - } - // IApplicationOutput virtual void clear(); virtual void appendOutput(const QString &out); @@ -195,7 +190,6 @@ private slots: private: ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; - Core::ICore *m_core; QString m_outputFile; QString m_projectDirectory; QTestOutputPane *m_outputPane; diff --git a/src/plugins/qtscripteditor/qtscripteditor.cpp b/src/plugins/qtscripteditor/qtscripteditor.cpp index 4062b69e5079a2a262ddb02ed2c8db86a76417d6..a7efcc0192c87e8924ae320290a3616f93f7d249 100644 --- a/src/plugins/qtscripteditor/qtscripteditor.cpp +++ b/src/plugins/qtscripteditor/qtscripteditor.cpp @@ -57,12 +57,10 @@ ScriptEditorEditable::ScriptEditorEditable(ScriptEditor *editor, const QList<int } ScriptEditor::ScriptEditor(const Context &context, - Core::ICore *core, TextEditor::TextEditorActionHandler *ah, QWidget *parent) : TextEditor::BaseTextEditor(parent), m_context(context), - m_core(core), m_ah(ah) { setParenthesesMatchingEnabled(true); @@ -84,7 +82,7 @@ Core::IEditor *ScriptEditorEditable::duplicate(QWidget *parent) ScriptEditor *ScriptEditor::duplicate(QWidget *parent) { - ScriptEditor *editor = new ScriptEditor(m_context, m_core, m_ah, parent); + ScriptEditor *editor = new ScriptEditor(m_context, m_ah, parent); editor->duplicateFrom(this); QtScriptEditorPlugin::initializeEditor(editor); return editor; @@ -157,7 +155,7 @@ void ScriptEditor::contextMenuEvent(QContextMenuEvent *e) { QMenu *menu = createStandardContextMenu(); - if (Core::ActionContainer *mcontext = m_core->actionManager()->actionContainer(QtScriptEditor::Constants::M_CONTEXT)) { + if (Core::ActionContainer *mcontext = Core::ICore::instance()->actionManager()->actionContainer(QtScriptEditor::Constants::M_CONTEXT)) { QMenu *contextMenu = mcontext->menu(); foreach (QAction *action, contextMenu->actions()) menu->addAction(action); diff --git a/src/plugins/qtscripteditor/qtscripteditor.h b/src/plugins/qtscripteditor/qtscripteditor.h index 1dda5a95e92677e97718a32346df491dab66aefa..d4f0ca94bb652dd95e7065cdd8fcec81cb7a3883 100644 --- a/src/plugins/qtscripteditor/qtscripteditor.h +++ b/src/plugins/qtscripteditor/qtscripteditor.h @@ -50,7 +50,7 @@ class ScriptEditor; class ScriptEditorEditable : public TextEditor::BaseTextEditorEditable { public: - ScriptEditorEditable(ScriptEditor *, const QList<int>&); + ScriptEditorEditable(ScriptEditor *, const QList<int> &); QList<int> context() const; bool duplicateSupported() const { return true; } @@ -71,9 +71,8 @@ public: typedef QList<int> Context; ScriptEditor(const Context &context, - Core::ICore *core, - TextEditor::TextEditorActionHandler *ah, - QWidget *parent = 0); + TextEditor::TextEditorActionHandler *ah, + QWidget *parent = 0); ~ScriptEditor(); ScriptEditor *duplicate(QWidget *parent); @@ -90,7 +89,6 @@ private: virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar); const Context m_context; - Core::ICore *m_core; TextEditor::TextEditorActionHandler *m_ah; }; diff --git a/src/plugins/qtscripteditor/qtscripteditoractionhandler.cpp b/src/plugins/qtscripteditor/qtscripteditoractionhandler.cpp index bb306f1a3f2d724c913d45961c44f731b484a051..18d57a6a7b2394156658cf4ace54d0e168d58e76 100644 --- a/src/plugins/qtscripteditor/qtscripteditoractionhandler.cpp +++ b/src/plugins/qtscripteditor/qtscripteditoractionhandler.cpp @@ -35,17 +35,18 @@ #include "qtscripteditorconstants.h" #include "qtscripteditor.h" +#include <coreplugin/icore.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/scriptmanager/scriptmanager.h> +#include <QtCore/QDebug> #include <QtGui/QAction> -#include <QtGui/QMessageBox> #include <QtGui/QMainWindow> -#include <QtCore/QDebug> +#include <QtGui/QMessageBox> -static QAction *actionFromId(Core::ICore *core, const QString &id) +static QAction *actionFromId(const QString &id) { - Core::Command *cmd = core->actionManager()->command(id); + Core::Command *cmd = Core::ICore::instance()->actionManager()->command(id); if (!cmd) return 0; return cmd->action(); @@ -54,9 +55,8 @@ static QAction *actionFromId(Core::ICore *core, const QString &id) namespace QtScriptEditor { namespace Internal { -QtScriptEditorActionHandler::QtScriptEditorActionHandler(Core::ICore *core) : - TextEditor::TextEditorActionHandler(core, - QLatin1String(QtScriptEditor::Constants::C_QTSCRIPTEDITOR), +QtScriptEditorActionHandler::QtScriptEditorActionHandler() + : TextEditor::TextEditorActionHandler(QLatin1String(QtScriptEditor::Constants::C_QTSCRIPTEDITOR), Format), m_runAction(0) { @@ -65,7 +65,7 @@ QtScriptEditorActionHandler::QtScriptEditorActionHandler(Core::ICore *core) : void QtScriptEditorActionHandler::createActions() { TextEditor::TextEditorActionHandler::createActions(); - m_runAction = actionFromId(core(), QLatin1String(QtScriptEditor::Constants::RUN)); + m_runAction = actionFromId(QLatin1String(QtScriptEditor::Constants::RUN)); connect(m_runAction, SIGNAL(triggered()), this, SLOT(run())); } @@ -88,7 +88,7 @@ void QtScriptEditorActionHandler::run() // run Stack errorStack; QString errorMessage; - if (core()->scriptManager()->runScript(script, &errorMessage, &errorStack)) + if (Core::ICore::instance()->scriptManager()->runScript(script, &errorMessage, &errorStack)) return; // try to find a suitable error line in the stack @@ -104,7 +104,7 @@ void QtScriptEditorActionHandler::run() } if (errorLineNumber) currentEditor()->gotoLine(errorLineNumber); - QMessageBox::critical(core()->mainWindow(), tr("Qt Script Error"), errorMessage); + QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("Qt Script Error"), errorMessage); } } // namespace Internal diff --git a/src/plugins/qtscripteditor/qtscripteditoractionhandler.h b/src/plugins/qtscripteditor/qtscripteditoractionhandler.h index d18ee2d25ff454fa6bb5960015bcbc6d1b0b1b63..c4940cfa160495f43be885fa7cc82832ef9e2626 100644 --- a/src/plugins/qtscripteditor/qtscripteditoractionhandler.h +++ b/src/plugins/qtscripteditor/qtscripteditoractionhandler.h @@ -44,7 +44,7 @@ class QtScriptEditorActionHandler : public TextEditor::TextEditorActionHandler Q_OBJECT public: - QtScriptEditorActionHandler(Core::ICore *core); + QtScriptEditorActionHandler(); private: virtual void createActions(); diff --git a/src/plugins/qtscripteditor/qtscripteditorfactory.cpp b/src/plugins/qtscripteditor/qtscripteditorfactory.cpp index 392b627363a74eca6b1df14aa89d35c3c1ab579a..1f776d8df0829285373c5c88a54a55560b405eae 100644 --- a/src/plugins/qtscripteditor/qtscripteditorfactory.cpp +++ b/src/plugins/qtscripteditor/qtscripteditorfactory.cpp @@ -40,20 +40,17 @@ #include <coreplugin/editormanager/editormanager.h> #include <QtCore/QFileInfo> -#include <QtCore/qdebug.h> +#include <QtCore/QDebug> using namespace QtScriptEditor::Internal; using namespace QtScriptEditor::Constants; -QtScriptEditorFactory::QtScriptEditorFactory(Core::ICore *core, - const Context &context, - QObject *parent) : - Core::IEditorFactory(parent), +QtScriptEditorFactory::QtScriptEditorFactory(const Context &context, QObject *parent) + : Core::IEditorFactory(parent), m_kind(QLatin1String(C_QTSCRIPTEDITOR)), m_mimeTypes(QLatin1String(QtScriptEditor::Constants::C_QTSCRIPTEDITOR_MIMETYPE)), m_context(context), - m_core(core), - m_actionHandler(new QtScriptEditorActionHandler(core)) + m_actionHandler(new QtScriptEditorActionHandler) { } @@ -69,7 +66,7 @@ QString QtScriptEditorFactory::kind() const Core::IFile *QtScriptEditorFactory::open(const QString &fileName) { - Core::IEditor *iface = m_core->editorManager()->openEditor(fileName, kind()); + Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, kind()); if (!iface) { qWarning() << "QtScriptEditorFactory::open: openEditor failed for " << fileName; return 0; @@ -79,7 +76,7 @@ Core::IFile *QtScriptEditorFactory::open(const QString &fileName) Core::IEditor *QtScriptEditorFactory::createEditor(QWidget *parent) { - ScriptEditor *rc = new ScriptEditor(m_context, m_core, m_actionHandler, parent); + ScriptEditor *rc = new ScriptEditor(m_context, m_actionHandler, parent); QtScriptEditorPlugin::initializeEditor(rc); return rc->editableInterface(); } diff --git a/src/plugins/qtscripteditor/qtscripteditorfactory.h b/src/plugins/qtscripteditor/qtscripteditorfactory.h index 08654aa035002c7764cae44bc3e5ea584e8e87d1..8048f30053dabbbe6d5d1ca695dd00ad071a5bd3 100644 --- a/src/plugins/qtscripteditor/qtscripteditorfactory.h +++ b/src/plugins/qtscripteditor/qtscripteditorfactory.h @@ -38,10 +38,6 @@ #include <QtCore/QStringList> -namespace Core { -class ICore; -} - namespace TextEditor { class TextEditorActionHandler; } @@ -58,13 +54,11 @@ class QtScriptEditorFactory : public Core::IEditorFactory public: typedef QList<int> Context; - QtScriptEditorFactory(Core::ICore *core, - const Context &context, - QObject *parent); + QtScriptEditorFactory(const Context &context, QObject *parent); ~QtScriptEditorFactory(); virtual QStringList mimeTypes() const; - //EditorFactory + // IEditorFactory QString kind() const; Core::IFile *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); @@ -74,7 +68,6 @@ private: const QStringList m_mimeTypes; const Context m_context; - Core::ICore *m_core; TextEditor::TextEditorActionHandler *m_actionHandler; }; diff --git a/src/plugins/qtscripteditor/qtscripteditorplugin.cpp b/src/plugins/qtscripteditor/qtscripteditorplugin.cpp index 1bf230155b644efbd6c0cceec9803839941073fd..c8c8e6dea389dac0e61d4418e93186cf555e329a 100644 --- a/src/plugins/qtscripteditor/qtscripteditorplugin.cpp +++ b/src/plugins/qtscripteditor/qtscripteditorplugin.cpp @@ -43,6 +43,7 @@ #include <coreplugin/mimedatabase.h> #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> +#include <extensionsystem/pluginmanager.h> #include <texteditor/fontsettings.h> #include <texteditor/storagesettings.h> #include <texteditor/texteditorconstants.h> @@ -50,7 +51,7 @@ #include <texteditor/textfilewizard.h> #include <utils/qtcassert.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QDebug> #include <QtGui/QAction> @@ -77,16 +78,16 @@ bool QtScriptEditorPlugin::initialize(const QStringList & /*arguments*/, QString { typedef SharedTools::QScriptHighlighter QScriptHighlighter; - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/qtscripteditor/QtScriptEditor.mimetypes.xml"), error_message)) return false; m_scriptcontext << core->uniqueIDManager()->uniqueIdentifier(QtScriptEditor::Constants::C_QTSCRIPTEDITOR); m_context = m_scriptcontext; m_context << core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); - registerActions(core); + registerActions(); - m_editor = new QtScriptEditorFactory(core, m_context, this); + m_editor = new QtScriptEditorFactory(m_context, this); addObject(m_editor); Core::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); @@ -97,7 +98,7 @@ bool QtScriptEditorPlugin::initialize(const QStringList & /*arguments*/, QString m_wizard = new TextEditor::TextFileWizard(QLatin1String(QtScriptEditor::Constants::C_QTSCRIPTEDITOR_MIMETYPE), QLatin1String(QtScriptEditor::Constants::C_QTSCRIPTEDITOR), QLatin1String("qtscript$"), - wizardParameters, core, this); + wizardParameters, this); addObject(m_wizard); error_message->clear(); @@ -129,9 +130,9 @@ void QtScriptEditorPlugin::initializeEditor(QtScriptEditor::Internal::ScriptEdit editor->setDisplaySettings(settings->displaySettings()); } -void QtScriptEditorPlugin::registerActions(Core::ICore *core) +void QtScriptEditorPlugin::registerActions() { - Core::ActionManager *am = core->actionManager(); + Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *mcontext = am->createMenu(QtScriptEditor::Constants::M_CONTEXT); QAction *action = new QAction(this); diff --git a/src/plugins/qtscripteditor/qtscripteditorplugin.h b/src/plugins/qtscripteditor/qtscripteditorplugin.h index 5bd1d5ba17e3158adf87c27ab1fdfa27d1fd54cf..a2a5981d18acd7446f0f26c91fec9a0db33733da 100644 --- a/src/plugins/qtscripteditor/qtscripteditorplugin.h +++ b/src/plugins/qtscripteditor/qtscripteditorplugin.h @@ -36,19 +36,13 @@ #include <extensionsystem/iplugin.h> -namespace Core { -class ICore; -} - namespace TextEditor { -class FontSettingsPage; class TextFileWizard; -} +} // namespace TextEditor namespace QtScriptEditor { namespace Internal { -class QtScriptWizard; class QtScriptEditorFactory; class ScriptEditor; @@ -60,14 +54,14 @@ public: QtScriptEditorPlugin(); virtual ~QtScriptEditorPlugin(); - //Plugin - bool initialize(const QStringList &arguments, QString *error_message = 0); + // IPlugin + bool initialize(const QStringList &arguments, QString *errorMessage = 0); void extensionsInitialized(); static void initializeEditor(ScriptEditor *editor); private: - void registerActions(Core::ICore *core); + void registerActions(); static QtScriptEditorPlugin *m_instance; diff --git a/src/plugins/quickopen/basefilefilter.cpp b/src/plugins/quickopen/basefilefilter.cpp index 65aea6d25527f4baf54ea11a88e644e300db571f..8bd10cd4a6bd84586f9cd63f1684b45a1ef42970 100644 --- a/src/plugins/quickopen/basefilefilter.cpp +++ b/src/plugins/quickopen/basefilefilter.cpp @@ -40,11 +40,8 @@ using namespace Core; using namespace QuickOpen; -BaseFileFilter::BaseFileFilter(ICore *core) - : m_core(core), - m_files(QStringList()), - m_fileNames(QStringList()), - m_forceNewSearchList(false) +BaseFileFilter::BaseFileFilter() + : m_forceNewSearchList(false) { } @@ -91,8 +88,9 @@ QList<FilterEntry> BaseFileFilter::matchesFor(const QString &origEntry) void BaseFileFilter::accept(QuickOpen::FilterEntry selection) const { - m_core->editorManager()->openEditor(selection.internalData.toString()); - m_core->editorManager()->ensureEditorManagerVisible(); + Core::EditorManager *em = Core::EditorManager::instance(); + em->openEditor(selection.internalData.toString()); + em->ensureEditorManagerVisible(); } void BaseFileFilter::generateFileNames() diff --git a/src/plugins/quickopen/basefilefilter.h b/src/plugins/quickopen/basefilefilter.h index ee9d302be5cdc454bdffd75840cd43df91bb39ab..711b84c0bae8c191384c51f26dbb8e251d2ee69f 100644 --- a/src/plugins/quickopen/basefilefilter.h +++ b/src/plugins/quickopen/basefilefilter.h @@ -37,12 +37,8 @@ #include "quickopen_global.h" #include "iquickopenfilter.h" -#include <coreplugin/icore.h> - #include <QtCore/QString> #include <QtCore/QList> -#include <QtCore/QByteArray> -#include <QtGui/QWidget> namespace QuickOpen { @@ -51,14 +47,13 @@ class QUICKOPEN_EXPORT BaseFileFilter : public QuickOpen::IQuickOpenFilter Q_OBJECT public: - BaseFileFilter(Core::ICore *core); + BaseFileFilter(); QList<QuickOpen::FilterEntry> matchesFor(const QString &entry); void accept(QuickOpen::FilterEntry selection) const; protected: void generateFileNames(); - Core::ICore *m_core; QStringList m_files; QStringList m_fileNames; QStringList m_previousResultPaths; diff --git a/src/plugins/quickopen/directoryfilter.cpp b/src/plugins/quickopen/directoryfilter.cpp index 84c60dfa8c746260f088365f5b3b055310c068da..8b70cbd51e9c26f6cbbdac666136e16dfe3d1764 100644 --- a/src/plugins/quickopen/directoryfilter.cpp +++ b/src/plugins/quickopen/directoryfilter.cpp @@ -35,20 +35,18 @@ #include <QtCore/QDir> #include <QtCore/QStack> -#include <QtGui/QDirModel> #include <QtGui/QCompleter> #include <QtGui/QFileDialog> #include <QtGui/QMessageBox> -using namespace Core; +#include <qtconcurrent/QtConcurrentTools> + using namespace QuickOpen; using namespace QuickOpen::Internal; -DirectoryFilter::DirectoryFilter(ICore *core) - : BaseFileFilter(core), - m_name(tr("Generic Directory Filter")), - m_directories(QStringList()), - m_filters(QStringList() << "*.h" << "*.cpp" << "*.ui" << "*.qrc") +DirectoryFilter::DirectoryFilter() + : m_name(tr("Generic Directory Filter")), + m_filters(QStringList() << "*.h" << "*.cpp" << "*.ui" << "*.qrc") { setIncludedByDefault(true); } diff --git a/src/plugins/quickopen/directoryfilter.h b/src/plugins/quickopen/directoryfilter.h index abe167d61d332f136dc711e434954d58d5df39a6..f156e01b45f29b7a4425defd3257620e97edf0cf 100644 --- a/src/plugins/quickopen/directoryfilter.h +++ b/src/plugins/quickopen/directoryfilter.h @@ -45,9 +45,6 @@ #include <QtGui/QWidget> #include <QtGui/QDialog> -#include <coreplugin/icore.h> -#include <qtconcurrent/QtConcurrentTools> - namespace QuickOpen { namespace Internal { @@ -56,7 +53,7 @@ class DirectoryFilter : public BaseFileFilter Q_OBJECT public: - DirectoryFilter(Core::ICore *core); + DirectoryFilter(); QString trName() const { return m_name; } QString name() const { return m_name; } QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; } diff --git a/src/plugins/quickopen/quickopenplugin.cpp b/src/plugins/quickopen/quickopenplugin.cpp index fe599b215a0dfdc9583e607cfc26c0c91f3b9cbc..0abebe3a88f7528c7d763a9c2f2f879d9463a7cf 100644 --- a/src/plugins/quickopen/quickopenplugin.cpp +++ b/src/plugins/quickopen/quickopenplugin.cpp @@ -40,7 +40,7 @@ #include "directoryfilter.h" #include "settingspage.h" -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QSettings> #include <QtCore/QFuture> #include <QtCore/QFutureWatcher> @@ -50,6 +50,7 @@ #include <coreplugin/uniqueidmanager.h> #include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/actionmanager/actionmanager.h> +#include <extensionsystem/pluginmanager.h> #include <qtconcurrent/QtConcurrentTools> using namespace QuickOpen; @@ -81,9 +82,8 @@ QuickOpenPlugin::~QuickOpenPlugin() bool QuickOpenPlugin::initialize(const QStringList &, QString *) { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - - m_settingsPage = new SettingsPage(core, this); + Core::ICore *core = Core::ICore::instance(); + m_settingsPage = new SettingsPage(this); addObject(m_settingsPage); m_quickOpenToolWindow = new QuickOpenToolWindow(this); @@ -136,7 +136,6 @@ void QuickOpenPlugin::startSettingsLoad() void QuickOpenPlugin::loadSettings() { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); QSettings settings; settings.beginGroup("QuickOpen"); m_refreshTimer.setInterval(settings.value("RefreshInterval", 60).toInt()*60000); @@ -150,7 +149,7 @@ void QuickOpenPlugin::loadSettings() settings.beginGroup("CustomFilters"); QList<IQuickOpenFilter *> customFilters; foreach (const QString &key, settings.childKeys()) { - IQuickOpenFilter *filter = new DirectoryFilter(core); + IQuickOpenFilter *filter = new DirectoryFilter; filter->restoreState(settings.value(key).toByteArray()); m_filters.append(filter); customFilters.append(filter); @@ -169,16 +168,15 @@ void QuickOpenPlugin::settingsLoaded() void QuickOpenPlugin::saveSettings() { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); if (core && core->settings()) { QSettings *s = core->settings(); s->beginGroup("QuickOpen"); - s->setValue("Interval", m_refreshTimer.interval()/60000); + s->setValue("Interval", m_refreshTimer.interval() / 60000); s->remove(""); foreach (IQuickOpenFilter *filter, m_filters) { - if (!m_customFilters.contains(filter)) { + if (!m_customFilters.contains(filter)) s->setValue(filter->name(), filter->saveState()); - } } s->beginGroup("CustomFilters"); int i = 0; @@ -244,7 +242,7 @@ void QuickOpenPlugin::refresh(QList<IQuickOpenFilter*> filters) if (filters.isEmpty()) filters = m_filters; QFuture<void> task = QtConcurrent::run(&IQuickOpenFilter::refresh, filters); - Core::FutureProgress *progress = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>() + Core::FutureProgress *progress = Core::ICore::instance() ->progressManager()->addTask(task, tr("Indexing"), Constants::TASK_INDEX, Core::ProgressManager::CloseOnSuccess); connect(progress, SIGNAL(finished()), this, SLOT(saveSettings())); } diff --git a/src/plugins/quickopen/quickopentoolwindow.cpp b/src/plugins/quickopen/quickopentoolwindow.cpp index 40cbeb7edcfde9f7958005af686a982f934a182b..d769313b58a1bbef5ce334571301c0129a4d925b 100644 --- a/src/plugins/quickopen/quickopentoolwindow.cpp +++ b/src/plugins/quickopen/quickopentoolwindow.cpp @@ -490,7 +490,6 @@ void QuickOpenToolWindow::showEvent(QShowEvent *event) void QuickOpenToolWindow::showConfigureDialog() { - ExtensionSystem::PluginManager::instance() - ->getObject<Core::ICore>()->showOptionsDialog(Constants::QUICKOPEN_CATEGORY, + Core::ICore::instance()->showOptionsDialog(Constants::QUICKOPEN_CATEGORY, Constants::FILTER_OPTIONS_PAGE); } diff --git a/src/plugins/quickopen/settingspage.cpp b/src/plugins/quickopen/settingspage.cpp index 174159163427a4b6f79b43dc9fc35f1f8f5616c0..2dd577aa27d2945a790584de12fc353a3e9f7b3b 100644 --- a/src/plugins/quickopen/settingspage.cpp +++ b/src/plugins/quickopen/settingspage.cpp @@ -45,8 +45,8 @@ Q_DECLARE_METATYPE(QuickOpen::IQuickOpenFilter*) using namespace QuickOpen; using namespace QuickOpen::Internal; -SettingsPage::SettingsPage(Core::ICore *core, QuickOpenPlugin *plugin) - : m_core(core), m_plugin(plugin), m_page(0) +SettingsPage::SettingsPage(QuickOpenPlugin *plugin) + : m_plugin(plugin), m_page(0) { } @@ -173,7 +173,7 @@ void SettingsPage::configureFilter(QListWidgetItem *item) void SettingsPage::addCustomFilter() { - IQuickOpenFilter *filter = new DirectoryFilter(m_core); + IQuickOpenFilter *filter = new DirectoryFilter; bool needsRefresh = false; if (filter->openConfigDialog(m_page, needsRefresh)) { m_filters.append(filter); diff --git a/src/plugins/quickopen/settingspage.h b/src/plugins/quickopen/settingspage.h index e169bca6a0b58d034b66c26f857e186e1e983435..ddd1d5e28880fc14a293da9ca6c51bbccb204222 100644 --- a/src/plugins/quickopen/settingspage.h +++ b/src/plugins/quickopen/settingspage.h @@ -60,7 +60,7 @@ class SettingsPage : public Core::IOptionsPage Q_OBJECT public: - SettingsPage(Core::ICore *core, QuickOpenPlugin *plugin); + explicit SettingsPage(QuickOpenPlugin *plugin); QString name() const { return tr(Constants::FILTER_OPTIONS_PAGE); } QString category() const { return Constants::QUICKOPEN_CATEGORY; } QString trCategory() const { return tr(Constants::QUICKOPEN_CATEGORY); } @@ -82,7 +82,6 @@ private: void requestRefresh(); Ui::SettingsWidget m_ui; - Core::ICore *m_core; QuickOpenPlugin *m_plugin; QPointer<QWidget> m_page; QList<IQuickOpenFilter *> m_filters; diff --git a/src/plugins/regexp/regexpplugin.cpp b/src/plugins/regexp/regexpplugin.cpp index 86a4ca0a7ca4b41a322fbf244cd859c9463a249e..af1bc8f242f91198e6bcdb264ccc63ecc6e3d024 100644 --- a/src/plugins/regexp/regexpplugin.cpp +++ b/src/plugins/regexp/regexpplugin.cpp @@ -32,14 +32,15 @@ ***************************************************************************/ #include "regexpplugin.h" -#include "settings.h" + #include "regexpwindow.h" +#include "settings.h" #include <coreplugin/baseview.h> #include <coreplugin/icore.h> #include <coreplugin/uniqueidmanager.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> using namespace RegExp::Internal; @@ -49,25 +50,24 @@ RegExpPlugin::RegExpPlugin() RegExpPlugin::~RegExpPlugin() { - if (m_regexpWindow) { - m_regexpWindow->settings().toQSettings(m_core->settings()); - } + if (m_regexpWindow) + m_regexpWindow->settings().toQSettings(Core::ICore::instance()->settings()); } void RegExpPlugin::extensionsInitialized() { } - -bool RegExpPlugin::initialize(const QStringList & /*arguments*/, QString *error_message) +bool RegExpPlugin::initialize(const QStringList &arguments, QString *errorMessage) { - Q_UNUSED(error_message) - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Q_UNUSED(arguments); + Q_UNUSED(errorMessage) + Core::ICore *core = Core::ICore::instance(); m_regexpWindow = new RegExpWindow; Settings settings; - settings.fromQSettings(m_core->settings()); + settings.fromQSettings(core->settings()); m_regexpWindow->setSettings(settings); - const int plugId = m_core->uniqueIDManager()->uniqueIdentifier(QLatin1String("RegExpPlugin")); + const int plugId = core->uniqueIDManager()->uniqueIdentifier(QLatin1String("RegExpPlugin")); addAutoReleasedObject(new Core::BaseView("TextEditor.RegExpWindow", m_regexpWindow, QList<int>() << plugId, diff --git a/src/plugins/regexp/regexpplugin.h b/src/plugins/regexp/regexpplugin.h index c944d37bc17fd739bd5fe53b253d386b37d22003..aa102953704082e350bf60d38b475bb72d8e7698 100644 --- a/src/plugins/regexp/regexpplugin.h +++ b/src/plugins/regexp/regexpplugin.h @@ -39,10 +39,6 @@ #include <QtCore/QObject> #include <QtCore/QPointer> -namespace Core { -class ICore; -} - namespace RegExp { namespace Internal { @@ -56,11 +52,10 @@ public: RegExpPlugin(); virtual ~RegExpPlugin(); - bool initialize(const QStringList &arguments, QString *error_message); + bool initialize(const QStringList &arguments, QString *errorMessage); void extensionsInitialized(); private: - Core::ICore *m_core; QPointer<RegExpWindow> m_regexpWindow; }; diff --git a/src/plugins/resourceeditor/resourceeditorfactory.cpp b/src/plugins/resourceeditor/resourceeditorfactory.cpp index 4a623c77f4aaedd0add95dd41b0ebfc6da376672..dcdd691c9fc8afc209ce030cdb28b611ac2f717a 100644 --- a/src/plugins/resourceeditor/resourceeditorfactory.cpp +++ b/src/plugins/resourceeditor/resourceeditorfactory.cpp @@ -36,7 +36,6 @@ #include "resourceeditorplugin.h" #include "resourceeditorconstants.h" -#include <coreplugin/icore.h> #include <coreplugin/uniqueidmanager.h> #include <coreplugin/fileiconprovider.h> #include <coreplugin/editormanager/editormanager.h> @@ -47,14 +46,13 @@ using namespace ResourceEditor::Internal; using namespace ResourceEditor::Constants; -ResourceEditorFactory::ResourceEditorFactory(Core::ICore *core, ResourceEditorPlugin *plugin) : +ResourceEditorFactory::ResourceEditorFactory(ResourceEditorPlugin *plugin) : Core::IEditorFactory(plugin), m_mimeTypes(QStringList(QLatin1String("application/vnd.nokia.xml.qt.resource"))), m_kind(QLatin1String(C_RESOURCEEDITOR)), - m_core(core), m_plugin(plugin) { - m_context += m_core->uniqueIDManager() + m_context += Core::UniqueIDManager::instance() ->uniqueIdentifier(QLatin1String(ResourceEditor::Constants::C_RESOURCEEDITOR)); Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); iconProvider->registerIconForSuffix(QIcon(":/resourceeditor/images/qt_qrc.png"), @@ -68,7 +66,7 @@ QString ResourceEditorFactory::kind() const Core::IFile *ResourceEditorFactory::open(const QString &fileName) { - Core::IEditor *iface = m_core->editorManager()->openEditor(fileName, kind()); + Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, kind()); if (!iface) { qWarning() << "ResourceEditorFactory::open: openEditor failed for " << fileName; return 0; @@ -78,7 +76,7 @@ Core::IFile *ResourceEditorFactory::open(const QString &fileName) Core::IEditor *ResourceEditorFactory::createEditor(QWidget *parent) { - return new ResourceEditorW(m_context, m_core, m_plugin, parent); + return new ResourceEditorW(m_context, m_plugin, parent); } QStringList ResourceEditorFactory::mimeTypes() const diff --git a/src/plugins/resourceeditor/resourceeditorfactory.h b/src/plugins/resourceeditor/resourceeditorfactory.h index 4097fdecaccf83a3e0e6d9fd598ce541cf2be731..0c4ab63c909ce31b1cd5f6901d2835ceae208067 100644 --- a/src/plugins/resourceeditor/resourceeditorfactory.h +++ b/src/plugins/resourceeditor/resourceeditorfactory.h @@ -38,10 +38,6 @@ #include <QtCore/QStringList> -namespace Core { -class ICore; -} // namespace Core - namespace ResourceEditor { namespace Internal { @@ -54,11 +50,11 @@ class ResourceEditorFactory : public Core::IEditorFactory public: typedef QList<int> Context; - ResourceEditorFactory(Core::ICore *core, ResourceEditorPlugin *plugin); + explicit ResourceEditorFactory(ResourceEditorPlugin *plugin); virtual QStringList mimeTypes() const; - //EditorFactory + // IEditorFactory QString kind() const; Core::IFile *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); @@ -68,7 +64,6 @@ private: const QString m_kind; Context m_context; - Core::ICore *m_core; ResourceEditorPlugin *m_plugin; }; diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp index 851cf8634c15845ffeb14a065315344e612638e6..117ccedfbd7f85cdb10631c975f98cec64b1b472 100644 --- a/src/plugins/resourceeditor/resourceeditorplugin.cpp +++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp @@ -44,10 +44,11 @@ #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/editormanager/editormanager.h> +#include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtGui/QAction> using namespace ResourceEditor::Internal; @@ -55,9 +56,8 @@ using namespace ResourceEditor::Internal; ResourceEditorPlugin::ResourceEditorPlugin() : m_wizard(0), m_editor(0), - m_core(NULL), - m_redoAction(NULL), - m_undoAction(NULL) + m_redoAction(0), + m_undoAction(0) { } @@ -67,13 +67,14 @@ ResourceEditorPlugin::~ResourceEditorPlugin() removeObject(m_wizard); } -bool ResourceEditorPlugin::initialize(const QStringList & /*arguments*/, QString *error_message) +bool ResourceEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage) { - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - if (!m_core->mimeDatabase()->addMimeTypes(QLatin1String(":/resourceeditor/ResourceEditor.mimetypes.xml"), error_message)) + Q_UNUSED(arguments); + Core::ICore *core = Core::ICore::instance(); + if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/resourceeditor/ResourceEditor.mimetypes.xml"), errorMessage)) return false; - m_editor = new ResourceEditorFactory(m_core, this); + m_editor = new ResourceEditorFactory(this); addObject(m_editor); Core::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); @@ -82,16 +83,16 @@ bool ResourceEditorPlugin::initialize(const QStringList & /*arguments*/, QString wizardParameters.setCategory(QLatin1String("Qt")); wizardParameters.setTrCategory(tr("Qt")); - m_wizard = new ResourceWizard(wizardParameters, m_core, this); + m_wizard = new ResourceWizard(wizardParameters, this); addObject(m_wizard); - error_message->clear(); + errorMessage->clear(); // Register undo and redo - Core::ActionManager * const actionManager = m_core->actionManager(); - int const pluginId = m_core->uniqueIDManager()->uniqueIdentifier( + Core::ActionManager * const actionManager = core->actionManager(); + int const pluginId = core->uniqueIDManager()->uniqueIdentifier( Constants::C_RESOURCEEDITOR); - QList<int> const idList = QList<int>() << pluginId; + const QList<int> idList = QList<int>() << pluginId; m_undoAction = new QAction(tr("&Undo"), this); m_redoAction = new QAction(tr("&Redo"), this); actionManager->registerAction(m_undoAction, Core::Constants::UNDO, idList); @@ -128,7 +129,7 @@ void ResourceEditorPlugin::onUndoStackChanged(ResourceEditorW const *editor, ResourceEditorW * ResourceEditorPlugin::currentEditor() const { ResourceEditorW * const focusEditor = qobject_cast<ResourceEditorW *>( - m_core->editorManager()->currentEditor()); + Core::EditorManager::instance()->currentEditor()); QTC_ASSERT(focusEditor, return 0); return focusEditor; } diff --git a/src/plugins/resourceeditor/resourceeditorplugin.h b/src/plugins/resourceeditor/resourceeditorplugin.h index fd9576ea00de1db41e644d64f240b6ce5bfdfb6d..d8c4c3daf1a68570fe3f4df476a9d7ce4bf858c0 100644 --- a/src/plugins/resourceeditor/resourceeditorplugin.h +++ b/src/plugins/resourceeditor/resourceeditorplugin.h @@ -36,11 +36,9 @@ #include <extensionsystem/iplugin.h> -QT_FORWARD_DECLARE_CLASS(QAction); - -namespace Core { - class ICore; -} +QT_BEGIN_NAMESPACE +class QAction; +QT_END_NAMESPACE namespace ResourceEditor { namespace Internal { @@ -57,8 +55,8 @@ public: ResourceEditorPlugin(); virtual ~ResourceEditorPlugin(); - //Plugin - bool initialize(const QStringList &arguments, QString *error_message = 0); + // IPlugin + bool initialize(const QStringList &arguments, QString *errorMessage = 0); void extensionsInitialized(); private slots: @@ -74,7 +72,6 @@ private: private: ResourceWizard *m_wizard; ResourceEditorFactory *m_editor; - Core::ICore *m_core; QAction *m_redoAction; QAction *m_undoAction; }; diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp index db4ed08980501f7de66dbe1ede76de9e6aa3462a..c8e0bbf51072ddad9ddc86028840b47aeb128c4e 100644 --- a/src/plugins/resourceeditor/resourceeditorw.cpp +++ b/src/plugins/resourceeditor/resourceeditorw.cpp @@ -70,11 +70,9 @@ QString ResourceEditorFile::mimeType() const ResourceEditorW::ResourceEditorW(const QList<int> &context, - Core::ICore *core, ResourceEditorPlugin *plugin, QWidget *parent) : m_context(context), - m_core(core), m_resourceEditor(new SharedTools::QrcEditor(parent)), m_resourceFile(new ResourceEditorFile(this)), m_plugin(plugin) @@ -207,7 +205,7 @@ void ResourceEditorFile::modified(Core::IFile::ReloadBehavior *behavior) break; } - switch (Core::Utils::reloadPrompt(fileName, m_parent->m_core->mainWindow())) { + switch (Core::Utils::reloadPrompt(fileName, Core::ICore::instance()->mainWindow())) { case Core::Utils::ReloadCurrent: m_parent->open(fileName); break; diff --git a/src/plugins/resourceeditor/resourceeditorw.h b/src/plugins/resourceeditor/resourceeditorw.h index 4070e155cd6e936ca96f52a1e5f710482c2bbdea..cc26250458aed18e5b36ab938a8f09c391e5f54c 100644 --- a/src/plugins/resourceeditor/resourceeditorw.h +++ b/src/plugins/resourceeditor/resourceeditorw.h @@ -40,11 +40,6 @@ #include <QtGui/QWidget> #include <QtCore/QPointer> - -namespace Core { - class ICore; -} - namespace SharedTools { class QrcEditor; } @@ -92,7 +87,6 @@ public: typedef QList<int> Context; ResourceEditorW(const Context &context, - Core::ICore *core, ResourceEditorPlugin *plugin, QWidget *parent = 0); ~ResourceEditorW(); @@ -126,7 +120,6 @@ private: QString m_displayName; QString m_suggestedName; const Context m_context; - Core::ICore *m_core; QPointer<SharedTools::QrcEditor> m_resourceEditor; ResourceEditorFile *m_resourceFile; ResourceEditorPlugin *m_plugin; diff --git a/src/plugins/resourceeditor/resourcewizard.cpp b/src/plugins/resourceeditor/resourcewizard.cpp index b2e76ed154a9cce9f15dd6ad2396cae548bedcb8..e4657fb0a95d721352ede88976eb83322b59ed2b 100644 --- a/src/plugins/resourceeditor/resourcewizard.cpp +++ b/src/plugins/resourceeditor/resourcewizard.cpp @@ -38,16 +38,17 @@ using namespace ResourceEditor; using namespace ResourceEditor::Internal; -ResourceWizard::ResourceWizard(const BaseFileWizardParameters ¶meters, Core::ICore *core, QObject *parent) : - Core::StandardFileWizard(parameters, core, parent) +ResourceWizard::ResourceWizard(const BaseFileWizardParameters ¶meters, QObject *parent) + : Core::StandardFileWizard(parameters, parent) { } Core::GeneratedFiles ResourceWizard::generateFilesFromPath(const QString &path, const QString &name, - QString * /*errorMessage*/) const + QString *errorMessage) const { + Q_UNUSED(errorMessage); const QString suffix = preferredSuffix(QLatin1String(Constants::C_RESOURCE_MIMETYPE)); const QString fileName = Core::BaseFileWizard::buildFileName(path, name, suffix); Core::GeneratedFile file(fileName); diff --git a/src/plugins/resourceeditor/resourcewizard.h b/src/plugins/resourceeditor/resourcewizard.h index e435755b2fc9b2cff629cbcd08f2850146cba0cb..829c6eae9a9bab909cf179a68da897454439dd31 100644 --- a/src/plugins/resourceeditor/resourcewizard.h +++ b/src/plugins/resourceeditor/resourcewizard.h @@ -45,7 +45,7 @@ class ResourceWizard : public Core::StandardFileWizard public: typedef Core::BaseFileWizardParameters BaseFileWizardParameters; - explicit ResourceWizard(const BaseFileWizardParameters ¶meters, Core::ICore *core, QObject *parent); + explicit ResourceWizard(const BaseFileWizardParameters ¶meters, QObject *parent); protected: virtual Core::GeneratedFiles diff --git a/src/plugins/snippets/snippetsplugin.cpp b/src/plugins/snippets/snippetsplugin.cpp index c014a6432a1a5e4f27f467ddac2ad953fcf4eb30..32dd4bc04e2655b54b3dfef63769ae7e03aa60c8 100644 --- a/src/plugins/snippets/snippetsplugin.cpp +++ b/src/plugins/snippets/snippetsplugin.cpp @@ -36,13 +36,12 @@ #include "snippetsplugin.h" #include "snippetspec.h" -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> #include <QtCore/QDebug> #include <QtGui/QShortcut> #include <QtGui/QApplication> #include <extensionsystem/pluginmanager.h> -#include <coreplugin/icore.h> #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanagerinterface.h> #include <coreplugin/editormanager/editormanager.h> @@ -69,19 +68,20 @@ void SnippetsPlugin::extensionsInitialized() { } -bool SnippetsPlugin::initialize(const QStringList & /*arguments*/, QString *) +bool SnippetsPlugin::initialize(const QStringList &arguments, QString *) { - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - Core::ActionManager *am = m_core->actionManager(); + Q_UNUSED(arguments); + Core::ICore *core = Core::ICore::instance(); + Core::ActionManager *am = core->actionManager(); QList<int> context; - context << m_core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); + context << core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); m_snippetWnd = new SnippetsWindow(); addAutoReleasedObject(new Core::BaseView("Snippets.SnippetsTree", m_snippetWnd, - QList<int>() << m_core->uniqueIDManager()->uniqueIdentifier(QLatin1String("Snippets Window")) - << m_core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR), + QList<int>() << core->uniqueIDManager()->uniqueIdentifier(QLatin1String("Snippets Window")) + << core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR), Qt::RightDockWidgetArea)); m_snippetsCompletion = new SnippetsCompletion(this); addObject(m_snippetsCompletion); @@ -107,11 +107,12 @@ QString SnippetsPlugin::simplifySnippetName(SnippetSpec *snippet) const void SnippetsPlugin::snippetActivated() { + Core::ICore *core = Core::ICore::instance(); SnippetSpec *snippet = m_shortcuts.value(sender()); - if (snippet && m_core->editorManager()->currentEditor()) { + if (snippet && core->editorManager()->currentEditor()) { TextEditor::ITextEditable *te = qobject_cast<TextEditor::ITextEditable *>( - m_core->editorManager()->currentEditor()); + core->editorManager()->currentEditor()); m_snippetWnd->insertSnippet(te, snippet); } } diff --git a/src/plugins/snippets/snippetsplugin.h b/src/plugins/snippets/snippetsplugin.h index 3647244d659ea820c80e395390a6be55bf4b8d85..dba0804a63282c96e530a14a89d8dc8b890d57e0 100644 --- a/src/plugins/snippets/snippetsplugin.h +++ b/src/plugins/snippets/snippetsplugin.h @@ -40,11 +40,6 @@ #include <extensionsystem/iplugin.h> -namespace Core { -class ICore; -struct Application; -} - namespace Snippets { namespace Internal { @@ -62,9 +57,8 @@ public: static SnippetsPlugin *instance() { return m_instance; } static SnippetsWindow *snippetsWindow() { return m_instance->m_snippetWnd; } - static Core::ICore *core() { return m_instance->m_core; } - bool initialize(const QStringList &arguments, QString *error_message); + bool initialize(const QStringList &arguments, QString *errorMessage); void extensionsInitialized(); private slots: @@ -74,7 +68,6 @@ private: static SnippetsPlugin *m_instance; QString simplifySnippetName(SnippetSpec *snippet) const; - Core::ICore *m_core; SnippetsCompletion *m_snippetsCompletion; SnippetsWindow *m_snippetWnd; diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 811e46514152af55dc9dd47b309e37326ef1da0e..7f6ea476eb29d12fd27ae5f74102fa476757c97b 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -55,20 +55,21 @@ #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/editormanager/editormanager.h> +#include <extensionsystem/pluginmanager.h> #include <projectexplorer/projectexplorer.h> #include <utils/qtcassert.h> -#include <QtCore/qplugin.h> #include <QtCore/QDebug> -#include <QtCore/QTextCodec> +#include <QtCore/QDir> #include <QtCore/QFileInfo> #include <QtCore/QTemporaryFile> -#include <QtCore/QDir> +#include <QtCore/QTextCodec> +#include <QtCore/QtPlugin> #include <QtGui/QAction> +#include <QtGui/QFileDialog> +#include <QtGui/QMainWindow> #include <QtGui/QMenu> #include <QtGui/QMessageBox> -#include <QtGui/QMainWindow> -#include <QtGui/QFileDialog> using namespace Subversion::Internal; @@ -131,9 +132,9 @@ static inline QString debugCodec(const QTextCodec *c) return c ? QString::fromAscii(c->name()) : QString::fromAscii("Null codec"); } -inline Core::IEditor* locateEditor(const Core::ICore *core, const char *property, const QString &entry) +Core::IEditor* locateEditor(const char *property, const QString &entry) { - foreach (Core::IEditor *ed, core->editorManager()->openedEditors()) + foreach (Core::IEditor *ed, Core::EditorManager::instance()->openedEditors()) if (ed->property(property).toString() == entry) return ed; return 0; @@ -163,7 +164,6 @@ StatusList parseStatusOutput(const QString &output) } // ------------- SubversionPlugin -Core::ICore *SubversionPlugin::m_coreInstance = 0; SubversionPlugin *SubversionPlugin::m_subversionPluginInstance = 0; SubversionPlugin::SubversionPlugin() : @@ -248,8 +248,10 @@ static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = { Subversion::Constants::SUBVERSIONCOMMITEDITOR }; -bool SubversionPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) +bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMessage) { + Q_UNUSED(arguments); + typedef VCSBase::VCSSubmitEditorFactory<SubversionSubmitEditor> SubversionSubmitEditorFactory; typedef VCSBase::VCSEditorFactory<SubversionEditor> SubversionEditorFactory; using namespace Constants; @@ -258,15 +260,15 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments*/, QString *er using namespace ExtensionSystem; m_subversionPluginInstance = this; - m_coreInstance = PluginManager::instance()->getObject<Core::ICore>(); + Core::ICore *core = Core::ICore::instance(); - if (!m_coreInstance->mimeDatabase()->addMimeTypes(QLatin1String(":/trolltech.subversion/Subversion.mimetypes.xml"), errorMessage)) + if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/trolltech.subversion/Subversion.mimetypes.xml"), errorMessage)) return false; m_versionControl = new SubversionControl(this); addObject(m_versionControl); - if (QSettings *settings = m_coreInstance->settings()) + if (QSettings *settings = core->settings()) m_settings.fromSettings(settings); m_coreListener = new CoreListener(this); @@ -281,7 +283,8 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments*/, QString *er static const char *describeSlot = SLOT(describe(QString,QString)); const int editorCount = sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters); for (int i = 0; i < editorCount; i++) { - m_editorFactories.push_back(new SubversionEditorFactory(editorParameters + i, m_coreInstance, this, describeSlot)); + m_editorFactories.push_back( + new SubversionEditorFactory(editorParameters + i, this, describeSlot)); addObject(m_editorFactories.back()); } @@ -289,7 +292,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments*/, QString *er addObject(m_subversionOutputWindow); //register actions - Core::ActionManager *ami = m_coreInstance->actionManager(); + Core::ActionManager *ami = core->actionManager(); Core::ActionContainer *toolsContainer = ami->actionContainer(M_TOOLS); Core::ActionContainer *subversionMenu = @@ -302,7 +305,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments*/, QString *er } QList<int> globalcontext; - globalcontext << m_coreInstance->uniqueIDManager()->uniqueIdentifier(C_GLOBAL); + globalcontext << core->uniqueIDManager()->uniqueIdentifier(C_GLOBAL); Core::Command *command; m_addAction = new QAction(tr("Add"), this); @@ -404,7 +407,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments*/, QString *er // Actions of the submit editor QList<int> svncommitcontext; - svncommitcontext << m_coreInstance->uniqueIDManager()->uniqueIdentifier(Constants::SUBVERSIONCOMMITEDITOR); + svncommitcontext << Core::UniqueIDManager::instance()->uniqueIdentifier(Constants::SUBVERSIONCOMMITEDITOR); m_submitCurrentLogAction = new QAction(VCSBase::VCSBaseSubmitEditor::submitIcon(), tr("Commit"), this); command = ami->registerAction(m_submitCurrentLogAction, Constants::SUBMIT_CURRENT, svncommitcontext); @@ -419,7 +422,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments*/, QString *er m_submitRedoAction = new QAction(tr("&Redo"), this); command = ami->registerAction(m_submitRedoAction, Core::Constants::REDO, svncommitcontext); - connect(m_coreInstance, SIGNAL(contextChanged(Core::IContext *)), this, SLOT(updateActions())); + connect(Core::ICore::instance(), SIGNAL(contextChanged(Core::IContext *)), this, SLOT(updateActions())); return true; } @@ -457,7 +460,7 @@ bool SubversionPlugin::editorAboutToClose(Core::IEditor *iEditor) // Prompt user. const QMessageBox::StandardButton answer = QMessageBox::question( - m_coreInstance->mainWindow(), tr("Closing Subversion Editor"), + Core::ICore::instance()->mainWindow(), tr("Closing Subversion Editor"), tr("Do you want to commit the change?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, QMessageBox::Yes); switch (answer) { @@ -473,9 +476,9 @@ bool SubversionPlugin::editorAboutToClose(Core::IEditor *iEditor) const QStringList fileList = editor->checkedFiles(); if (!fileList.empty()) { // get message & commit - m_coreInstance->fileManager()->blockFileChange(fileIFace); + Core::ICore::instance()->fileManager()->blockFileChange(fileIFace); fileIFace->save(); - m_coreInstance->fileManager()->unblockFileChange(fileIFace); + Core::ICore::instance()->fileManager()->unblockFileChange(fileIFace); commit(m_changeTmpFile->fileName(), fileList); } cleanChangeTmpFile(); @@ -492,7 +495,7 @@ void SubversionPlugin::svnDiff(const QStringList &files, QString diffname) if (Subversion::Constants::debug) qDebug() << Q_FUNC_INFO << files << diffname; const QString source = files.empty() ? QString() : files.front(); - QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditor::getCodec(m_coreInstance, source); + QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditor::getCodec(source); if (files.count() == 1 && diffname.isEmpty()) diffname = QFileInfo(files.front()).fileName(); @@ -508,9 +511,9 @@ void SubversionPlugin::svnDiff(const QStringList &files, QString diffname) // the common usage pattern of continuously changing and diffing a file if (files.count() == 1) { // Show in the same editor if diff has been executed before - if (Core::IEditor *editor = locateEditor(m_coreInstance, "originalFileName", files.front())) { + if (Core::IEditor *editor = locateEditor("originalFileName", files.front())) { editor->createNew(response.stdOut); - m_coreInstance->editorManager()->setCurrentEditor(editor); + Core::EditorManager::instance()->setCurrentEditor(editor); return; } } @@ -522,7 +525,7 @@ void SubversionPlugin::svnDiff(const QStringList &files, QString diffname) SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QString &fileName) { - Core::IEditor *editor = m_coreInstance->editorManager()->openEditor(fileName, QLatin1String(Constants::SUBVERSIONCOMMITEDITOR_KIND)); + Core::IEditor *editor = Core::EditorManager::instance()->openEditor(fileName, QLatin1String(Constants::SUBVERSIONCOMMITEDITOR_KIND)); SubversionSubmitEditor *submitEditor = qobject_cast<SubversionSubmitEditor*>(editor); QTC_ASSERT(submitEditor, /**/); submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction); @@ -593,7 +596,7 @@ void SubversionPlugin::revertCurrentFile() QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) return; - Core::FileManager *fm = m_coreInstance->fileManager(); + Core::FileManager *fm = Core::ICore::instance()->fileManager(); QList<Core::IFile *> files = fm->managedFiles(file); foreach (Core::IFile *file, files) fm->blockFileChange(file); @@ -759,7 +762,7 @@ void SubversionPlugin::filelogCurrentFile() void SubversionPlugin::filelog(const QString &file) { - QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, file); + QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(file); // no need for temp file QStringList args(QLatin1String("log")); args.append(QDir::toNativeSeparators(file)); @@ -771,9 +774,9 @@ void SubversionPlugin::filelog(const QString &file) // Re-use an existing view if possible to support // the common usage pattern of continuously changing and diffing a file - if (Core::IEditor *editor = locateEditor(m_coreInstance, "logFileName", file)) { + if (Core::IEditor *editor = locateEditor("logFileName", file)) { editor->createNew(response.stdOut); - m_coreInstance->editorManager()->setCurrentEditor(editor); + Core::EditorManager::instance()->setCurrentEditor(editor); } else { const QString title = tr("svn log %1").arg(QFileInfo(file).fileName()); Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::LogOutput, file, codec); @@ -801,7 +804,7 @@ void SubversionPlugin::annotateCurrentFile() void SubversionPlugin::annotate(const QString &file) { - QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, file); + QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(file); QStringList args(QLatin1String("annotate")); args.push_back(QLatin1String("-v")); @@ -814,9 +817,9 @@ void SubversionPlugin::annotate(const QString &file) // Re-use an existing view if possible to support // the common usage pattern of continuously changing and diffing a file - if (Core::IEditor *editor = locateEditor(m_coreInstance, "annotateFileName", file)) { + if (Core::IEditor *editor = locateEditor("annotateFileName", file)) { editor->createNew(response.stdOut); - m_coreInstance->editorManager()->setCurrentEditor(editor); + Core::EditorManager::instance()->setCurrentEditor(editor); } else { const QString title = tr("svn annotate %1").arg(QFileInfo(file).fileName()); Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::AnnotateOutput, file, codec); @@ -860,7 +863,7 @@ void SubversionPlugin::describe(const QString &source, const QString &changeNr) args.push_back(diffArg); args.push_back(topLevel); - QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, source); + QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(source); const SubversionResponse response = runSvn(args, subversionShortTimeOut, false, codec); if (response.error) return; @@ -868,9 +871,9 @@ void SubversionPlugin::describe(const QString &source, const QString &changeNr) // Re-use an existing view if possible to support // the common usage pattern of continuously changing and diffing a file const QString id = diffArg + source; - if (Core::IEditor *editor = locateEditor(m_coreInstance, "describeChange", id)) { + if (Core::IEditor *editor = locateEditor("describeChange", id)) { editor->createNew(response.stdOut); - m_coreInstance->editorManager()->setCurrentEditor(editor); + Core::EditorManager::instance()->setCurrentEditor(editor); } else { const QString title = tr("svn describe %1#%2").arg(QFileInfo(source).fileName(), changeNr); Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::DiffOutput, source, codec); @@ -880,13 +883,13 @@ void SubversionPlugin::describe(const QString &source, const QString &changeNr) void SubversionPlugin::submitCurrentLog() { - m_coreInstance->editorManager()->closeEditors(QList<Core::IEditor*>() - << m_coreInstance->editorManager()->currentEditor()); + Core::EditorManager::instance()->closeEditors(QList<Core::IEditor*>() + << Core::EditorManager::instance()->currentEditor()); } QString SubversionPlugin::currentFileName() const { - const QString fileName = m_coreInstance->fileManager()->currentFile(); + const QString fileName = Core::ICore::instance()->fileManager()->currentFile(); if (!fileName.isEmpty()) { const QFileInfo fi(fileName); if (fi.exists()) @@ -987,8 +990,8 @@ Core::IEditor * SubversionPlugin::showOutputInEditor(const QString& title, const if (Subversion::Constants::debug) qDebug() << "SubversionPlugin::showOutputInEditor" << title << kind << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); QString s = title; - Core::IEditor *ediface = m_coreInstance->editorManager()->newFile(kind, &s, output.toLocal8Bit()); - SubversionEditor *e = qobject_cast<SubversionEditor*>(ediface->widget()); + Core::IEditor *editor = Core::EditorManager::instance()->newFile(kind, &s, output.toLocal8Bit()); + SubversionEditor *e = qobject_cast<SubversionEditor*>(editor->widget()); if (!e) return 0; s.replace(QLatin1Char(' '), QLatin1Char('_')); @@ -1009,17 +1012,11 @@ void SubversionPlugin::setSettings(const SubversionSettings &s) { if (s != m_settings) { m_settings = s; - if (QSettings *settings = m_coreInstance->settings()) + if (QSettings *settings = Core::ICore::instance()->settings()) m_settings.toSettings(settings); } } -Core::ICore *SubversionPlugin::coreInstance() -{ - QTC_ASSERT(m_coreInstance, return 0); - return m_coreInstance; -} - SubversionPlugin *SubversionPlugin::subversionPluginInstance() { QTC_ASSERT(m_subversionPluginInstance, return m_subversionPluginInstance); diff --git a/src/plugins/subversion/subversionplugin.h b/src/plugins/subversion/subversionplugin.h index 729bbc909fde61010f7ff7b137c927fddbcaa565..f589468e40f555ce6f2881a3186aa85ce5bd37ab 100644 --- a/src/plugins/subversion/subversionplugin.h +++ b/src/plugins/subversion/subversionplugin.h @@ -54,7 +54,6 @@ class QTextCodec; QT_END_NAMESPACE namespace Core { - class ICore; class IEditorFactory; class IVersionControl; } @@ -105,7 +104,6 @@ public: bool managesDirectory(const QString &directory) const; QString findTopLevelForDirectory(const QString &directory) const; - static Core::ICore *coreInstance(); static SubversionPlugin *subversionPluginInstance(); private slots: @@ -190,7 +188,6 @@ private: static const char * const STATUS; static const char * const UPDATE; - static Core::ICore *m_coreInstance; static SubversionPlugin *m_subversionPluginInstance; friend class SubversionOutputWindow; diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index 61fc6eadc175cc73affbc380af0277bdc7518c88..36295979d1dc7b60d782f4551a3e9e67926ea208 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -33,6 +33,7 @@ #include "basefilefind.h" +#include <coreplugin/icore.h> #include <coreplugin/stylehelper.h> #include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/editormanager/editormanager.h> @@ -40,7 +41,7 @@ #include <texteditor/itexteditor.h> #include <texteditor/basetexteditor.h> -#include <QtDebug> +#include <QtCore/QDebug> #include <QtCore/QDirIterator> #include <QtGui/QPushButton> #include <QtGui/QFileDialog> @@ -49,9 +50,8 @@ using namespace Core::Utils; using namespace Find; using namespace TextEditor; -BaseFileFind::BaseFileFind(Core::ICore *core, SearchResultWindow *resultWindow) - : m_core(core), - m_resultWindow(resultWindow), +BaseFileFind::BaseFileFind(SearchResultWindow *resultWindow) + : m_resultWindow(resultWindow), m_isSearching(false), m_resultLabel(0), m_filterCombo(0), @@ -95,7 +95,8 @@ void BaseFileFind::findAll(const QString &txt, QTextDocument::FindFlags findFlag m_watcher.setFuture(Core::Utils::findInFilesRegExp(txt, files(), findFlags)); else m_watcher.setFuture(Core::Utils::findInFiles(txt, files(), findFlags)); - Core::FutureProgress *progress = m_core->progressManager()->addTask(m_watcher.future(), + Core::FutureProgress *progress = + Core::ICore::instance()->progressManager()->addTask(m_watcher.future(), "Search", Constants::TASK_SEARCH); progress->setWidget(createProgressWidget()); diff --git a/src/plugins/texteditor/basefilefind.h b/src/plugins/texteditor/basefilefind.h index 2aacf2d9650ee172d0ed0e83edbe31c30d9baff2..706964cf50ab7367617b9643e004a26e5ee4ef9f 100644 --- a/src/plugins/texteditor/basefilefind.h +++ b/src/plugins/texteditor/basefilefind.h @@ -36,7 +36,6 @@ #include "texteditor_global.h" -#include <coreplugin/icore.h> #include <find/ifindfilter.h> #include <find/searchresultwindow.h> #include <utils/filesearch.h> @@ -55,7 +54,7 @@ class TEXTEDITOR_EXPORT BaseFileFind : public Find::IFindFilter Q_OBJECT public: - BaseFileFind(Core::ICore *core, Find::SearchResultWindow *resultWindow); + explicit BaseFileFind(Find::SearchResultWindow *resultWindow); bool isEnabled() const; void findAll(const QString &txt, QTextDocument::FindFlags findFlags); @@ -79,7 +78,6 @@ private slots: private: QWidget *createProgressWidget(); - Core::ICore *m_core; Find::SearchResultWindow *m_resultWindow; QFutureWatcher<Core::Utils::FileSearchResult> m_watcher; bool m_isSearching; diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h index 83f42dcee7be51ce24f617821e71cb19693e1b97..72d81d33c859eaa9bfb97f33e8635f6bebb4ed50 100644 --- a/src/plugins/texteditor/basetextdocument.h +++ b/src/plugins/texteditor/basetextdocument.h @@ -46,11 +46,8 @@ class QSyntaxHighlighter; QT_END_NAMESPACE -namespace Core { class ICore; } - namespace TextEditor { - class DocumentMarker : public ITextMarkable { Q_OBJECT @@ -69,9 +66,7 @@ private: }; - -class TEXTEDITOR_EXPORT BaseTextDocument - : public Core::IFile +class TEXTEDITOR_EXPORT BaseTextDocument : public Core::IFile { Q_OBJECT @@ -133,7 +128,6 @@ private: QString m_mimeType; StorageSettings m_storageSettings; TabSettings m_tabSettings; - Core::ICore *m_core; QTextDocument *m_document; DocumentMarker *m_documentMarker; QSyntaxHighlighter *m_highlighter; diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index f3d1ab07566d3cf9d63d3052a2a39e54f5cabe82..0e058ff752e1635b472cae29a82070d4abeaa7e9 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -43,10 +43,10 @@ #include "codecselector.h" #ifndef TEXTEDITOR_STANDALONE -#include <coreplugin/icore.h> #include <coreplugin/manhattanstyle.h> #include <coreplugin/coreconstants.h> #include <coreplugin/editormanager/editormanager.h> +#include <extensionsystem/pluginmanager.h> #include <find/basetextfind.h> #include <texteditor/fontsettings.h> #include <utils/reloadpromptutils.h> @@ -87,7 +87,7 @@ using namespace TextEditor::Internal; namespace TextEditor { - namespace Internal { +namespace Internal { class TextEditExtraArea : public QWidget { BaseTextEditor *textEdit; @@ -123,16 +123,15 @@ protected: } }; - } -} +} // namespace Internal +} // namespace TextEditor ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName, int line, int column, const QString &editorKind) { - Core::EditorManager *editorManager = - ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->editorManager(); + Core::EditorManager *editorManager = Core::EditorManager::instance(); editorManager->addCurrentPositionToNavigationHistory(true); Core::IEditor *editor = editorManager->openEditor(fileName, editorKind, true); TextEditor::ITextEditor *texteditor = qobject_cast<TextEditor::ITextEditor *>(editor); @@ -562,7 +561,7 @@ bool BaseTextEditor::open(const QString &fileName) return false; } -Core::IFile * BaseTextEditor::file() +Core::IFile *BaseTextEditor::file() { return d->m_document; } diff --git a/src/plugins/texteditor/basetextmark.cpp b/src/plugins/texteditor/basetextmark.cpp index 4e4adf28bdcfc091ed9d9e2c8e131782451ef300..b6ec76b7ddc84707d05a462d10e1e633c004b46b 100644 --- a/src/plugins/texteditor/basetextmark.cpp +++ b/src/plugins/texteditor/basetextmark.cpp @@ -35,7 +35,6 @@ #include <coreplugin/editormanager/editormanager.h> #include <extensionsystem/pluginmanager.h> -#include <coreplugin/icore.h> #include <QtCore/QTimer> @@ -57,7 +56,7 @@ BaseTextMark::BaseTextMark(const QString &filename, int line) void BaseTextMark::init() { m_init = true; - Core::EditorManager *em = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->editorManager(); + Core::EditorManager *em = Core::EditorManager::instance(); connect(em, SIGNAL(editorOpened(Core::IEditor *)), this, SLOT(editorOpened(Core::IEditor *))); foreach (Core::IEditor *editor, em->openedEditors()) @@ -117,7 +116,7 @@ void BaseTextMark::updateMarker() void BaseTextMark::moveMark(const QString & /* filename */, int /* line */) { - Core::EditorManager *em = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->editorManager(); + Core::EditorManager *em = Core::EditorManager::instance(); if (!m_init) { connect(em, SIGNAL(editorOpened(Core::IEditor *)), this, SLOT(editorOpened(Core::IEditor *))); m_init = true; diff --git a/src/plugins/texteditor/completionsupport.cpp b/src/plugins/texteditor/completionsupport.cpp index 5c863e3afe231a08be5b2ea60bed06ed014e5d3e..ddac8de09d179f99f2ab2c25df364786765568a2 100644 --- a/src/plugins/texteditor/completionsupport.cpp +++ b/src/plugins/texteditor/completionsupport.cpp @@ -36,11 +36,12 @@ #include "icompletioncollector.h" #include <coreplugin/icore.h> +#include <extensionsystem/pluginmanager.h> #include <texteditor/itexteditable.h> #include <utils/qtcassert.h> -#include <QString> -#include <QList> +#include <QtCore/QString> +#include <QtCore/QList> #include <algorithm> @@ -48,23 +49,23 @@ using namespace TextEditor; using namespace TextEditor::Internal; -CompletionSupport *CompletionSupport::instance(Core::ICore *core) +CompletionSupport *CompletionSupport::instance() { static CompletionSupport *m_instance = 0; - if (!m_instance) { - m_instance = new CompletionSupport(core); - } + if (!m_instance) + m_instance = new CompletionSupport; return m_instance; } -CompletionSupport::CompletionSupport(Core::ICore *core) - : QObject(core), +CompletionSupport::CompletionSupport() + : QObject(Core::ICore::instance()), m_completionList(0), m_startPosition(0), m_checkCompletionTrigger(false), m_editor(0) { - m_completionCollector = core->pluginManager()->getObject<ICompletionCollector>(); + m_completionCollector = ExtensionSystem::PluginManager::instance() + ->getObject<ICompletionCollector>(); } void CompletionSupport::performCompletion(const CompletionItem &item) diff --git a/src/plugins/texteditor/completionsupport.h b/src/plugins/texteditor/completionsupport.h index 9704f80f2a229c9ce9a9fb07f4b44e56ce1ba4cd..a2300010200929b3efad6db0b7d0ee3883ab3bf8 100644 --- a/src/plugins/texteditor/completionsupport.h +++ b/src/plugins/texteditor/completionsupport.h @@ -38,8 +38,6 @@ #include <QtCore/QObject> -namespace Core { class ICore; } - namespace TextEditor { struct CompletionItem; @@ -58,9 +56,9 @@ class TEXTEDITOR_EXPORT CompletionSupport : public QObject Q_OBJECT public: - CompletionSupport(Core::ICore *core); + CompletionSupport(); - static CompletionSupport *instance(Core::ICore *core); + static CompletionSupport *instance(); public slots: void autoComplete(ITextEditable *editor, bool forced); diff --git a/src/plugins/texteditor/findinfiles.cpp b/src/plugins/texteditor/findinfiles.cpp index c8c1020563e1212b19bc6c9f82fc097317d66da5..b474fdd5eac1b7f15d783f5a7298e0e52037b754 100644 --- a/src/plugins/texteditor/findinfiles.cpp +++ b/src/plugins/texteditor/findinfiles.cpp @@ -42,8 +42,8 @@ using namespace Find; using namespace TextEditor::Internal; -FindInFiles::FindInFiles(Core::ICore *core, SearchResultWindow *resultWindow) - : BaseFileFind(core, resultWindow), +FindInFiles::FindInFiles(SearchResultWindow *resultWindow) + : BaseFileFind(resultWindow), m_configWidget(0), m_directory(0) { diff --git a/src/plugins/texteditor/findinfiles.h b/src/plugins/texteditor/findinfiles.h index e38c838f87dc5264bf600261e1b3150f4ed3fa33..e894f7eece76841aeed2baed3725074f8bbcc4fb 100644 --- a/src/plugins/texteditor/findinfiles.h +++ b/src/plugins/texteditor/findinfiles.h @@ -36,7 +36,6 @@ #include "basefilefind.h" -#include <coreplugin/icore.h> #include <find/ifindfilter.h> #include <find/searchresultwindow.h> @@ -54,12 +53,10 @@ class FindInFiles : public BaseFileFind Q_OBJECT public: - FindInFiles(Core::ICore *core, Find::SearchResultWindow *resultWindow); + explicit FindInFiles(Find::SearchResultWindow *resultWindow); QString name() const; - QKeySequence defaultShortcut() const; - void findAll(const QString &txt, QTextDocument::FindFlags findFlags); QWidget *createConfigWidget(); void writeSettings(QSettings *settings); diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index 1eaccaba6e26689b16f82eb4c9a0f9a946a6b525..5d493cef404c5a828a8e89ce4607ee85e78fca7f 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -36,20 +36,21 @@ #include "texteditorconstants.h" #include "ui_fontsettingspage.h" +#include <coreplugin/icore.h> #include <utils/settingsutils.h> #include <QtCore/QSettings> #include <QtCore/QTimer> -#include <QtGui/QListWidget> -#include <QtGui/QToolButton> -#include <QtGui/QPalette> #include <QtGui/QCheckBox> #include <QtGui/QColorDialog> -#include <QtGui/QTextEdit> -#include <QtGui/QTextCharFormat> #include <QtGui/QComboBox> #include <QtGui/QFontDatabase> +#include <QtGui/QListWidget> #include <QtGui/QPalette> +#include <QtGui/QPalette> +#include <QtGui/QTextCharFormat> +#include <QtGui/QTextEdit> +#include <QtGui/QToolButton> static inline QString colorButtonStyleSheet(const QColor &bgColor) { @@ -70,10 +71,9 @@ public: FontSettingsPagePrivate(const TextEditor::FormatDescriptions &fd, const QString &name, const QString &category, - const QString &trCategory, - Core::ICore *core); + const QString &trCategory); - Core::ICore *m_core; +public: const QString m_name; const QString m_settingsGroup; const QString m_category; @@ -89,9 +89,7 @@ public: FontSettingsPagePrivate::FontSettingsPagePrivate(const TextEditor::FormatDescriptions &fd, const QString &name, const QString &category, - const QString &trCategory, - Core::ICore *core) : - m_core(core), + const QString &trCategory) : m_name(name), m_settingsGroup(Core::Utils::settingsKey(category)), m_category(category), @@ -102,9 +100,8 @@ FontSettingsPagePrivate::FontSettingsPagePrivate(const TextEditor::FormatDescrip m_curItem(-1) { bool settingsFound = false; - if (m_core) - if (const QSettings *settings = m_core->settings()) - settingsFound = m_value.fromSettings(m_settingsGroup, m_descriptions, settings); + if (const QSettings *settings = Core::ICore::instance()->settings()) + settingsFound = m_value.fromSettings(m_settingsGroup, m_descriptions, settings); if (!settingsFound) { // Apply defaults foreach (const FormatDescription &f, m_descriptions) { const QString name = f.name(); @@ -200,10 +197,9 @@ QColor FormatDescription::background() const FontSettingsPage::FontSettingsPage(const FormatDescriptions &fd, const QString &category, const QString &trCategory, - Core::ICore *core, QObject *parent) : Core::IOptionsPage(parent), - d_ptr(new FontSettingsPagePrivate(fd, tr("Font & Colors"), category, trCategory, core)) + d_ptr(new FontSettingsPagePrivate(fd, tr("Font & Colors"), category, trCategory)) { } @@ -232,7 +228,6 @@ QWidget *FontSettingsPage::createPage(QWidget *parent) QWidget *w = new QWidget(parent); d_ptr->ui.setupUi(w); - d_ptr->ui.itemListWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); foreach (const FormatDescription &d, d_ptr->m_descriptions) @@ -447,9 +442,8 @@ void FontSettingsPage::apply() if (d_ptr->m_value != d_ptr->m_lastValue) { d_ptr->m_lastValue = d_ptr->m_value; - if (d_ptr->m_core) - if (QSettings *settings = d_ptr->m_core->settings()) - d_ptr->m_value.toSettings(d_ptr->m_settingsGroup, d_ptr->m_descriptions, settings); + if (QSettings *settings = Core::ICore::instance()->settings()) + d_ptr->m_value.toSettings(d_ptr->m_settingsGroup, d_ptr->m_descriptions, settings); QTimer::singleShot(0, this, SLOT(delayedChange())); } diff --git a/src/plugins/texteditor/fontsettingspage.h b/src/plugins/texteditor/fontsettingspage.h index 6a518f518d361757d2eff3502c042bcba7f382b3..bc674de3c2028bb50badbfefb0948d333472cea3 100644 --- a/src/plugins/texteditor/fontsettingspage.h +++ b/src/plugins/texteditor/fontsettingspage.h @@ -38,7 +38,6 @@ #include "fontsettings.h" -#include <coreplugin/icore.h> #include <coreplugin/dialogs/ioptionspage.h> #include <QtGui/QColor> @@ -89,7 +88,6 @@ public: FontSettingsPage(const FormatDescriptions &fd, const QString &category, const QString &trCategory, - Core::ICore *core, QObject *parent = 0); ~FontSettingsPage(); diff --git a/src/plugins/texteditor/generalsettingspage.cpp b/src/plugins/texteditor/generalsettingspage.cpp index d20763b0cab82ff5f2a0b6c9983a5b592dcab548..7be7bca1f4b3fc5e3c272a3509f419dbb55aeeea 100644 --- a/src/plugins/texteditor/generalsettingspage.cpp +++ b/src/plugins/texteditor/generalsettingspage.cpp @@ -37,16 +37,17 @@ #include "tabsettings.h" #include "ui_generalsettingspage.h" +#include <coreplugin/icore.h> + #include <QtCore/QSettings> #include <QtCore/QDebug> using namespace TextEditor; -struct GeneralSettingsPage::GeneralSettingsPagePrivate { - GeneralSettingsPagePrivate(Core::ICore *core, - const GeneralSettingsPageParameters &p); +struct GeneralSettingsPage::GeneralSettingsPagePrivate +{ + explicit GeneralSettingsPagePrivate(const GeneralSettingsPageParameters &p); - Core::ICore *m_core; const GeneralSettingsPageParameters m_parameters; Ui::generalSettingsPage m_page; TabSettings m_tabSettings; @@ -54,24 +55,21 @@ struct GeneralSettingsPage::GeneralSettingsPagePrivate { DisplaySettings m_displaySettings; }; -GeneralSettingsPage::GeneralSettingsPagePrivate::GeneralSettingsPagePrivate(Core::ICore *core, - const GeneralSettingsPageParameters &p) : - m_core(core), - m_parameters(p) +GeneralSettingsPage::GeneralSettingsPagePrivate::GeneralSettingsPagePrivate + (const GeneralSettingsPageParameters &p) + : m_parameters(p) { - if (m_core) - if (const QSettings *s = m_core->settings()) { - m_tabSettings.fromSettings(m_parameters.settingsPrefix, s); - m_storageSettings.fromSettings(m_parameters.settingsPrefix, s); - m_displaySettings.fromSettings(m_parameters.settingsPrefix, s); - } + if (const QSettings *s = Core::ICore::instance()->settings()) { + m_tabSettings.fromSettings(m_parameters.settingsPrefix, s); + m_storageSettings.fromSettings(m_parameters.settingsPrefix, s); + m_displaySettings.fromSettings(m_parameters.settingsPrefix, s); + } } -GeneralSettingsPage::GeneralSettingsPage(Core::ICore *core, - const GeneralSettingsPageParameters &p, - QObject *parent) : - Core::IOptionsPage(parent), - m_d(new GeneralSettingsPagePrivate(core, p)) +GeneralSettingsPage::GeneralSettingsPage(const GeneralSettingsPageParameters &p, + QObject *parent) + : Core::IOptionsPage(parent), + m_d(new GeneralSettingsPagePrivate(p)) { } @@ -99,9 +97,7 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent) { QWidget *w = new QWidget(parent); m_d->m_page.setupUi(w); - settingsToUI(); - return w; } @@ -112,30 +108,28 @@ void GeneralSettingsPage::apply() DisplaySettings newDisplaySettings; settingsFromUI(newTabSettings, newStorageSettings, newDisplaySettings); + Core::ICore *core = Core::ICore::instance(); if (newTabSettings != m_d->m_tabSettings) { m_d->m_tabSettings = newTabSettings; - if (m_d->m_core) - if (QSettings *s = m_d->m_core->settings()) - m_d->m_tabSettings.toSettings(m_d->m_parameters.settingsPrefix, s); + if (QSettings *s = core->settings()) + m_d->m_tabSettings.toSettings(m_d->m_parameters.settingsPrefix, s); emit tabSettingsChanged(newTabSettings); } if (newStorageSettings != m_d->m_storageSettings) { m_d->m_storageSettings = newStorageSettings; - if (m_d->m_core) - if (QSettings *s = m_d->m_core->settings()) - m_d->m_storageSettings.toSettings(m_d->m_parameters.settingsPrefix, s); + if (QSettings *s = core->settings()) + m_d->m_storageSettings.toSettings(m_d->m_parameters.settingsPrefix, s); emit storageSettingsChanged(newStorageSettings); } if (newDisplaySettings != m_d->m_displaySettings) { m_d->m_displaySettings = newDisplaySettings; - if (m_d->m_core) - if (QSettings *s = m_d->m_core->settings()) - m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s); + if (QSettings *s = core->settings()) + m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s); emit displaySettingsChanged(newDisplaySettings); } @@ -207,9 +201,9 @@ void GeneralSettingsPage::setDisplaySettings(const DisplaySettings &newDisplaySe { if (newDisplaySettings != m_d->m_displaySettings) { m_d->m_displaySettings = newDisplaySettings; - if (m_d->m_core) - if (QSettings *s = m_d->m_core->settings()) - m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s); + Core::ICore *core = Core::ICore::instance(); + if (QSettings *s = core->settings()) + m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s); emit displaySettingsChanged(newDisplaySettings); } diff --git a/src/plugins/texteditor/generalsettingspage.h b/src/plugins/texteditor/generalsettingspage.h index eea75e2ccc8a72ada08b7881ccd666656c45aa91..5eb9c0811c23b9f761e2b3a8e1f37c11486646e1 100644 --- a/src/plugins/texteditor/generalsettingspage.h +++ b/src/plugins/texteditor/generalsettingspage.h @@ -36,7 +36,6 @@ #include "texteditor_global.h" -#include <coreplugin/icore.h> #include <coreplugin/dialogs/ioptionspage.h> #include <QtCore/QObject> @@ -47,26 +46,23 @@ struct TabSettings; struct StorageSettings; struct DisplaySettings; -struct TEXTEDITOR_EXPORT GeneralSettingsPageParameters { +struct TEXTEDITOR_EXPORT GeneralSettingsPageParameters +{ QString name; QString category; QString trCategory; QString settingsPrefix; }; -class Ui_generalSettingsPage; - class TEXTEDITOR_EXPORT GeneralSettingsPage : public Core::IOptionsPage { Q_OBJECT public: - GeneralSettingsPage(Core::ICore *core, - const GeneralSettingsPageParameters &p, - QObject *parent); + GeneralSettingsPage(const GeneralSettingsPageParameters &p, QObject *parent); virtual ~GeneralSettingsPage(); - //IOptionsPage + // IOptionsPage QString name() const; QString category() const; QString trCategory() const; diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp index b9370bca9cf46089f343d9deb5948816fb772245..f4fbe12aa8c4f470025cac96a6b9098e7009fe45 100644 --- a/src/plugins/texteditor/plaintexteditor.cpp +++ b/src/plugins/texteditor/plaintexteditor.cpp @@ -36,26 +36,22 @@ #include "texteditorplugin.h" #include <coreplugin/coreconstants.h> -#include <coreplugin/icore.h> #include <coreplugin/uniqueidmanager.h> using namespace TextEditor; using namespace TextEditor::Internal; PlainTextEditorEditable::PlainTextEditorEditable(PlainTextEditor *editor) - :BaseTextEditorEditable(editor) + : BaseTextEditorEditable(editor) { - Core::ICore *core = TextEditorPlugin::core(); - m_context << core->uniqueIDManager()-> - uniqueIdentifier(Core::Constants::K_DEFAULT_TEXT_EDITOR); - m_context << core->uniqueIDManager()-> - uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); + Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); + m_context << uidm->uniqueIdentifier(Core::Constants::K_DEFAULT_TEXT_EDITOR); + m_context << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); } -PlainTextEditor::PlainTextEditor(QWidget *parent) : - BaseTextEditor(parent) +PlainTextEditor::PlainTextEditor(QWidget *parent) + : BaseTextEditor(parent) { - setRevisionsVisible(true); setMarksVisible(true); setRequestMarkEnabled(false); @@ -69,7 +65,6 @@ QList<int> PlainTextEditorEditable::context() const return m_context; } - Core::IEditor *PlainTextEditorEditable::duplicate(QWidget *parent) { PlainTextEditor *newEditor = new PlainTextEditor(parent); @@ -103,8 +98,10 @@ const char *PlainTextEditorEditable::kind() const // to do in 2 steps (indenting/wrapping)} // -void PlainTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar /* typedChar */) +void PlainTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar) { + Q_UNUSED(typedChar); + // At beginning: Leave as is. if (block == doc->begin()) return; diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index 92a3a79ea4f8d697cddac7d0c9ec401ca25cc788..8fc40ac703f936fa42fbfe43ebcb38bdda370620 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -43,13 +43,13 @@ using namespace TextEditor; using namespace TextEditor::Internal; -PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent) : - Core::IEditorFactory(parent), +PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent) + : Core::IEditorFactory(parent), m_kind(Core::Constants::K_DEFAULT_TEXT_EDITOR) { - m_actionHandler = new TextEditorActionHandler(TextEditorPlugin::core(), - QLatin1String(TextEditor::Constants::C_TEXTEDITOR), - TextEditorActionHandler::Format); + m_actionHandler = new TextEditorActionHandler( + QLatin1String(TextEditor::Constants::C_TEXTEDITOR), + TextEditorActionHandler::Format); m_mimeTypes << QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT) << QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_XML); } @@ -66,14 +66,13 @@ QString PlainTextEditorFactory::kind() const Core::IFile *PlainTextEditorFactory::open(const QString &fileName) { - Core::ICore *core = TextEditorPlugin::core(); - Core::IEditor *iface = core->editorManager()->openEditor(fileName, kind()); + Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, kind()); return iface ? iface->file() : 0; } Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent) { - PlainTextEditor *rc = new PlainTextEditor(parent); + PlainTextEditor *rc = new PlainTextEditor(parent); TextEditorPlugin::instance()->initializeEditor(rc); return rc->editableInterface(); } diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 44b6f33b17d41bdf3df2c20ff78a974c9dcf5017..5ff46ef1353f94174ff13db0d390ba93fe070004 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -38,6 +38,7 @@ #include "linenumberfilter.h" #include <quickopen/quickopenmanager.h> +#include <coreplugin/icore.h> #include <coreplugin/coreconstants.h> #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> @@ -52,31 +53,45 @@ using namespace TextEditor; using namespace TextEditor::Internal; -TextEditorActionHandler::TextEditorActionHandler(Core::ICore *core, - const QString &context, - uint optionalActions) : - QObject(core), +TextEditorActionHandler::TextEditorActionHandler(const QString &context, + uint optionalActions) + : QObject(Core::ICore::instance()), m_optionalActions(optionalActions), m_currentEditor(0), - m_core(core), m_initialized(false) { - m_undoAction = m_redoAction = m_copyAction = m_cutAction = m_pasteAction - = m_selectAllAction = m_gotoAction = m_printAction = m_formatAction - = m_visualizeWhitespaceAction = m_cleanWhitespaceAction = m_textWrappingAction - = m_unCommentSelectionAction = m_unCollapseAllAction - = m_collapseAction = m_expandAction - = m_deleteLineAction = m_selectEncodingAction - = m_increaseFontSizeAction = m_decreaseFontSizeAction - = m_gotoBlockStartAction = m_gotoBlockStartWithSelectionAction - = m_gotoBlockEndAction = m_gotoBlockEndWithSelectionAction - = m_selectBlockUpAction = m_selectBlockDownAction - = m_moveLineUpAction = m_moveLineDownAction - = 0; - - m_contextId << m_core->uniqueIDManager()->uniqueIdentifier(context); - - connect(m_core, SIGNAL(contextAboutToChange(Core::IContext *)), + m_undoAction = 0; + m_redoAction = 0; + m_copyAction = 0; + m_cutAction = 0; + m_pasteAction = 0; + m_selectAllAction = 0; + m_gotoAction = 0; + m_printAction = 0; + m_formatAction = 0; + m_visualizeWhitespaceAction = 0; + m_cleanWhitespaceAction = 0; + m_textWrappingAction = 0; + m_unCommentSelectionAction = 0; + m_unCollapseAllAction = 0; + m_collapseAction = 0; + m_expandAction = 0; + m_deleteLineAction = 0; + m_selectEncodingAction = 0; + m_increaseFontSizeAction = 0; + m_decreaseFontSizeAction = 0; + m_gotoBlockStartAction = 0; + m_gotoBlockStartWithSelectionAction = 0; + m_gotoBlockEndAction = 0; + m_gotoBlockEndWithSelectionAction = 0; + m_selectBlockUpAction = 0; + m_selectBlockDownAction = 0; + m_moveLineUpAction = 0; + m_moveLineDownAction = 0; + + m_contextId << Core::UniqueIDManager::instance()->uniqueIdentifier(context); + + connect(Core::ICore::instance(), SIGNAL(contextAboutToChange(Core::IContext *)), this, SLOT(updateCurrentEditor(Core::IContext *))); } @@ -111,7 +126,7 @@ void TextEditorActionHandler::createActions() m_gotoAction = registerNewAction(QLatin1String(Core::Constants::GOTO), this, SLOT(gotoAction())); m_printAction = registerNewAction(QLatin1String(Core::Constants::PRINT), this, SLOT(printAction())); - Core::ActionManager *am = m_core->actionManager(); + Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *medit = am->actionContainer(Core::Constants::M_EDIT); Core::ActionContainer *advancedMenu = am->actionContainer(Core::Constants::M_EDIT_ADVANCED); @@ -125,35 +140,34 @@ void TextEditorActionHandler::createActions() m_formatAction = new QAction(tr("Auto-&indent Selection"), this); command = am->registerAction(m_formatAction, TextEditor::Constants::AUTO_INDENT_SELECTION, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+I"))); - advancedMenu->addAction(command); + advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_formatAction, SIGNAL(triggered(bool)), this, SLOT(formatAction())); m_visualizeWhitespaceAction = new QAction(tr("&Visualize Whitespace"), this); m_visualizeWhitespaceAction->setCheckable(true); command = am->registerAction(m_visualizeWhitespaceAction, - TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId); + TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId); #ifndef Q_OS_MAC command->setDefaultKeySequence(QKeySequence(tr("Ctrl+E, Ctrl+V"))); #endif - advancedMenu->addAction(command); + advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_visualizeWhitespaceAction, SIGNAL(triggered(bool)), this, SLOT(setVisualizeWhitespace(bool))); m_cleanWhitespaceAction = new QAction(tr("Clean Whitespace"), this); command = am->registerAction(m_cleanWhitespaceAction, TextEditor::Constants::CLEAN_WHITESPACE, m_contextId); - advancedMenu->addAction(command); + advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_cleanWhitespaceAction, SIGNAL(triggered()), this, SLOT(cleanWhitespace())); m_textWrappingAction = new QAction(tr("Enable Text &Wrapping"), this); m_textWrappingAction->setCheckable(true); - command = am->registerAction(m_textWrappingAction, - TextEditor::Constants::TEXT_WRAPPING, m_contextId); + command = am->registerAction(m_textWrappingAction, TextEditor::Constants::TEXT_WRAPPING, m_contextId); #ifndef Q_OS_MAC command->setDefaultKeySequence(QKeySequence(tr("Ctrl+E, Ctrl+W"))); #endif - advancedMenu->addAction(command); + advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_textWrappingAction, SIGNAL(triggered(bool)), this, SLOT(setTextWrapping(bool))); @@ -161,7 +175,7 @@ void TextEditorActionHandler::createActions() command = am->registerAction(m_unCommentSelectionAction, Constants::UN_COMMENT_SELECTION, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+/"))); connect(m_unCommentSelectionAction, SIGNAL(triggered()), this, SLOT(unCommentSelection())); - advancedMenu->addAction(command); + advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); m_deleteLineAction = new QAction(tr("Delete &Line"), this); command = am->registerAction(m_deleteLineAction, Constants::DELETE_LINE, m_contextId); @@ -172,28 +186,30 @@ void TextEditorActionHandler::createActions() command = am->registerAction(m_collapseAction, Constants::COLLAPSE, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+<"))); connect(m_collapseAction, SIGNAL(triggered()), this, SLOT(collapse())); + advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING); m_expandAction = new QAction(tr("Expand"), this); command = am->registerAction(m_expandAction, Constants::EXPAND, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+>"))); connect(m_expandAction, SIGNAL(triggered()), this, SLOT(expand())); + advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING); m_unCollapseAllAction = new QAction(tr("(Un)&Collapse All"), this); command = am->registerAction(m_unCollapseAllAction, Constants::UN_COLLAPSE_ALL, m_contextId); connect(m_unCollapseAllAction, SIGNAL(triggered()), this, SLOT(unCollapseAll())); - advancedMenu->addAction(command); + advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING); m_increaseFontSizeAction = new QAction(tr("Increase Font Size"), this); command = am->registerAction(m_increaseFontSizeAction, Constants::INCREASE_FONT_SIZE, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl++"))); connect(m_increaseFontSizeAction, SIGNAL(triggered()), this, SLOT(increaseFontSize())); - advancedMenu->addAction(command); + advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT); m_decreaseFontSizeAction = new QAction(tr("Decrease Font Size"), this); command = am->registerAction(m_decreaseFontSizeAction, Constants::DECREASE_FONT_SIZE, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+-"))); connect(m_decreaseFontSizeAction, SIGNAL(triggered()), this, SLOT(decreaseFontSize())); - advancedMenu->addAction(command); + advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT); m_gotoBlockStartAction = new QAction(tr("Goto Block Start"), this); command = am->registerAction(m_gotoBlockStartAction, Constants::GOTO_BLOCK_START, m_contextId); @@ -247,7 +263,7 @@ QAction *TextEditorActionHandler::registerNewAction(const QString &id, const QSt return 0; QAction *result = new QAction(title, this); - m_core->actionManager()->registerAction(result, id, m_contextId); + Core::ICore::instance()->actionManager()->registerAction(result, id, m_contextId); return result; } @@ -348,7 +364,7 @@ void TextEditorActionHandler::gotoAction() void TextEditorActionHandler::printAction() { if (m_currentEditor) - m_currentEditor->print(m_core->printer()); + m_currentEditor->print(Core::ICore::instance()->printer()); } void TextEditorActionHandler::setVisualizeWhitespace(bool checked) @@ -444,9 +460,3 @@ const QPointer<BaseTextEditor> &TextEditorActionHandler::currentEditor() const { return m_currentEditor; } - -Core::ICore *TextEditorActionHandler::core() const -{ - return m_core; -} - diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index ea30cad741337c1bf5bb74c6d3577b4a1d2494f1..172617e9a27e7b7fc55869b9a0f87262a05e62f4 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -38,11 +38,10 @@ #include "basetexteditor.h" #include "coreplugin/icontext.h" -#include "coreplugin/icore.h" +#include <QtCore/QList> #include <QtCore/QObject> #include <QtCore/QPointer> -#include <QtCore/QList> namespace TextEditor { @@ -62,9 +61,7 @@ public: UnCollapseAll = 4 }; - TextEditorActionHandler(Core::ICore *core, - const QString &context, - uint optionalActions = None); + TextEditorActionHandler(const QString &context, uint optionalActions = None); void setupActions(BaseTextEditor *editor); void initializeActions(); @@ -80,7 +77,6 @@ protected: QAction *registerNewAction(const QString &id, const QString &title = QString()); QAction *registerNewAction(const QString &id, QObject *receiver, const char *slot, const QString &title = QString()); - Core::ICore *core() const; enum UpdateMode { NoEditor , ReadOnlyMode, WriteMode }; UpdateMode updateMode() const; @@ -152,7 +148,6 @@ private: uint m_optionalActions; QPointer<BaseTextEditor> m_currentEditor; - Core::ICore *m_core; QList<int> m_contextId; bool m_initialized; }; diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index d76bd7167082e15f07ee6941592c0752920f7093..1e6a47e47d4a56d7e1ff0b6117659813d3135e14 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -43,27 +43,28 @@ #include "plaintexteditor.h" #include "storagesettings.h" +#include <coreplugin/icore.h> #include <coreplugin/coreconstants.h> #include <coreplugin/mimedatabase.h> #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/command.h> #include <coreplugin/editormanager/editormanager.h> +#include <extensionsystem/pluginmanager.h> #include <texteditor/texteditoractionhandler.h> #include <utils/qtcassert.h> -#include <QtCore/qplugin.h> -#include <QtGui/QShortcut> +#include <QtCore/QtPlugin> #include <QtGui/QMainWindow> +#include <QtGui/QShortcut> using namespace TextEditor; using namespace TextEditor::Internal; TextEditorPlugin *TextEditorPlugin::m_instance = 0; -TextEditorPlugin::TextEditorPlugin() : - m_core(0), - m_settings(0), +TextEditorPlugin::TextEditorPlugin() + : m_settings(0), m_wizard(0), m_editorFactory(0), m_lineNumberFilter(0) @@ -82,17 +83,12 @@ TextEditorPlugin *TextEditorPlugin::instance() return m_instance; } -Core::ICore *TextEditorPlugin::core() -{ - return m_instance->m_core; -} - -//ExtensionSystem::PluginInterface -bool TextEditorPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) +// ExtensionSystem::PluginInterface +bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage) { - m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Q_UNUSED(arguments); - if (!m_core->mimeDatabase()->addMimeTypes(QLatin1String(":/texteditor/TextEditor.mimetypes.xml"), errorMessage)) + if (!Core::ICore::instance()->mimeDatabase()->addMimeTypes(QLatin1String(":/texteditor/TextEditor.mimetypes.xml"), errorMessage)) return false; Core::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); @@ -103,7 +99,7 @@ bool TextEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er m_wizard = new TextFileWizard(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT), QLatin1String(Core::Constants::K_DEFAULT_TEXT_EDITOR), QLatin1String("text$"), - wizardParameters, m_core); + wizardParameters); // Add text file wizard addAutoReleasedObject(m_wizard); @@ -115,15 +111,16 @@ bool TextEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er addAutoReleasedObject(m_editorFactory); // Goto line functionality for quick open - m_lineNumberFilter = new LineNumberFilter(m_core->editorManager()); + Core::ICore *core = Core::ICore::instance(); + m_lineNumberFilter = new LineNumberFilter(core->editorManager()); addAutoReleasedObject(m_lineNumberFilter); - int contextId = m_core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); + int contextId = core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); QList<int> context = QList<int>() << contextId; - Core::ActionManager *am = m_core->actionManager(); + Core::ActionManager *am = core->actionManager(); // Add shortcut for invoking automatic completion - QShortcut *completionShortcut = new QShortcut(m_core->mainWindow()); + QShortcut *completionShortcut = new QShortcut(core->mainWindow()); completionShortcut->setWhatsThis(tr("Triggers a completion in this scope")); // Make sure the shortcut still works when the completion widget is active completionShortcut->setContext(Qt::ApplicationShortcut); @@ -135,7 +132,8 @@ bool TextEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er #endif connect(completionShortcut, SIGNAL(activated()), this, SLOT(invokeCompletion())); - addAutoReleasedObject(new FindInFiles(m_core, m_core->pluginManager()->getObject<Find::SearchResultWindow>())); + addAutoReleasedObject(new FindInFiles( + ExtensionSystem::PluginManager::instance()->getObject<Find::SearchResultWindow>())); return true; } @@ -169,10 +167,7 @@ void TextEditorPlugin::initializeEditor(TextEditor::PlainTextEditor *editor) void TextEditorPlugin::invokeCompletion() { - if (!m_core) - return; - - Core::IEditor *iface = m_core->editorManager()->currentEditor(); + Core::IEditor *iface = Core::EditorManager::instance()->currentEditor(); ITextEditor *editor = qobject_cast<ITextEditor *>(iface); if (editor) editor->triggerCompletions(); diff --git a/src/plugins/texteditor/texteditorplugin.h b/src/plugins/texteditor/texteditorplugin.h index 65c7c3e48e83fb28197af9c289de0bf74e991fb6..1f0029a71aa09600e65f1fbb273074d433ed6198 100644 --- a/src/plugins/texteditor/texteditorplugin.h +++ b/src/plugins/texteditor/texteditorplugin.h @@ -36,22 +36,13 @@ #include <extensionsystem/iplugin.h> -QT_BEGIN_NAMESPACE -class QAction; -QT_END_NAMESPACE - -namespace Core { -class ICore; -class IEditor; -} - namespace TextEditor { class FontSettings; class FontSettingsPage; +class PlainTextEditor; class TextEditorSettings; class TextFileWizard; -class PlainTextEditor; namespace Internal { @@ -67,10 +58,9 @@ public: virtual ~TextEditorPlugin(); static TextEditorPlugin *instance(); - static Core::ICore *core(); // ExtensionSystem::PluginInterface - bool initialize(const QStringList &arguments, QString *); + bool initialize(const QStringList &arguments, QString *errorMessage); void extensionsInitialized(); void initializeEditor(PlainTextEditor *editor); @@ -82,7 +72,6 @@ private slots: private: static TextEditorPlugin *m_instance; - Core::ICore *m_core; TextEditorSettings *m_settings; TextFileWizard *m_wizard; PlainTextEditorFactory *m_editorFactory; diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index 2637b5da545c9c24d5dd5e3c11393760c547264a..ea61d57172527e1bcb346cdd5276b17630b3bbd5 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -41,9 +41,10 @@ #include "texteditorconstants.h" #include "texteditorplugin.h" +#include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> -#include <QApplication> +#include <QtGui/QApplication> using namespace TextEditor; using namespace TextEditor::Constants; @@ -93,8 +94,7 @@ TextEditorSettings::TextEditorSettings(Internal::TextEditorPlugin *plugin, m_fontSettingsPage = new FontSettingsPage(formatDescriptions, QLatin1String("TextEditor"), - tr("Text Editor"), - plugin->core()); + tr("Text Editor")); pm->addObject(m_fontSettingsPage); // Add the GUI used to configure the tab, storage and display settings @@ -103,7 +103,7 @@ TextEditorSettings::TextEditorSettings(Internal::TextEditorPlugin *plugin, generalSettingsPageParameters.category = QLatin1String("TextEditor"); generalSettingsPageParameters.trCategory = tr("Text Editor"); generalSettingsPageParameters.settingsPrefix = QLatin1String("text"); - m_generalSettingsPage = new GeneralSettingsPage(plugin->core(), generalSettingsPageParameters, this); + m_generalSettingsPage = new GeneralSettingsPage(generalSettingsPageParameters, this); pm->addObject(m_generalSettingsPage); connect(m_fontSettingsPage, SIGNAL(changed(TextEditor::FontSettings)), diff --git a/src/plugins/texteditor/textfilewizard.cpp b/src/plugins/texteditor/textfilewizard.cpp index e755233735df41d296a58fb50b4a3afa553f402e..05a3b843a4d454d448d1d7b63af0e1cc73aa0322 100644 --- a/src/plugins/texteditor/textfilewizard.cpp +++ b/src/plugins/texteditor/textfilewizard.cpp @@ -41,9 +41,8 @@ TextFileWizard::TextFileWizard(const QString &mimeType, const QString &editorKind, const QString &suggestedFileName, const BaseFileWizardParameters ¶meters, - Core::ICore *core, QObject *parent) : - Core::StandardFileWizard(parameters, core, parent), + Core::StandardFileWizard(parameters, parent), m_mimeType(mimeType), m_editorKind(editorKind), m_suggestedFileName(suggestedFileName) diff --git a/src/plugins/texteditor/textfilewizard.h b/src/plugins/texteditor/textfilewizard.h index 2cf2a01b39505af4e0ee6b13d585ea0dfd6d17e1..1ccc50166f5521d506c1d68c249ef48ce4d585ba 100644 --- a/src/plugins/texteditor/textfilewizard.h +++ b/src/plugins/texteditor/textfilewizard.h @@ -50,7 +50,6 @@ public: const QString &editorKind, const QString &suggestedFileName, const BaseFileWizardParameters ¶meters, - Core::ICore *core, QObject *parent = 0); protected: diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index 392b9c269642b4f62e33e95356927491cf420a4d..d7f85a9449d2ce4389bd597ba5562a06f676b22a 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -35,7 +35,6 @@ #include "vcsbaseplugin.h" #include "vcsbaseeditor.h" -#include <coreplugin/icore.h> #include <coreplugin/editormanager/editormanager.h> #include <texteditor/fontsettings.h> #include <texteditor/texteditoractionhandler.h> @@ -43,28 +42,26 @@ namespace VCSBase { -struct BaseVCSEditorFactoryPrivate { - BaseVCSEditorFactoryPrivate(const VCSBaseEditorParameters *t, Core::ICore *core); +struct BaseVCSEditorFactoryPrivate +{ + BaseVCSEditorFactoryPrivate(const VCSBaseEditorParameters *t); const VCSBaseEditorParameters *m_type; const QString m_kind; const QStringList m_mimeTypes; - Core::ICore *m_core; TextEditor::TextEditorActionHandler *m_editorHandler; }; -BaseVCSEditorFactoryPrivate::BaseVCSEditorFactoryPrivate(const VCSBaseEditorParameters *t, Core::ICore *core) : +BaseVCSEditorFactoryPrivate::BaseVCSEditorFactoryPrivate(const VCSBaseEditorParameters *t) : m_type(t), m_kind(QLatin1String(t->kind)), m_mimeTypes(QStringList(QLatin1String(t->mimeType))), - m_core(core), - m_editorHandler(new TextEditor::TextEditorActionHandler(core, t->kind)) + m_editorHandler(new TextEditor::TextEditorActionHandler(t->kind)) { } -BaseVCSEditorFactory::BaseVCSEditorFactory(const VCSBaseEditorParameters *t, - Core::ICore *core) : - m_d(new BaseVCSEditorFactoryPrivate(t, core)) +BaseVCSEditorFactory::BaseVCSEditorFactory(const VCSBaseEditorParameters *t) + : m_d(new BaseVCSEditorFactoryPrivate(t)) { } @@ -85,7 +82,7 @@ QString BaseVCSEditorFactory::kind() const Core::IFile *BaseVCSEditorFactory::open(const QString &fileName) { - Core::IEditor *iface = m_d->m_core->editorManager()->openEditor(fileName, kind()); + Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, kind()); return iface ? iface->file() : 0; } diff --git a/src/plugins/vcsbase/basevcseditorfactory.h b/src/plugins/vcsbase/basevcseditorfactory.h index bc10a21180dd4712fa3d92eb5950c3d79cadde7f..ca6e926937ad03bd02f8ab4157201c6331eb3a47 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.h +++ b/src/plugins/vcsbase/basevcseditorfactory.h @@ -41,14 +41,6 @@ #include <QtCore/QStringList> -namespace TextEditor { - class TextEditorActionHandler; -} - -namespace Core { - class ICore; -} - namespace VCSBase { struct BaseVCSEditorFactoryPrivate; @@ -59,8 +51,7 @@ class VCSBASE_EXPORT BaseVCSEditorFactory : public Core::IEditorFactory { Q_OBJECT public: - explicit BaseVCSEditorFactory(const VCSBaseEditorParameters *type, - Core::ICore *core); + explicit BaseVCSEditorFactory(const VCSBaseEditorParameters *type); virtual ~BaseVCSEditorFactory(); virtual QStringList mimeTypes() const; @@ -85,7 +76,6 @@ class VCSEditorFactory : public BaseVCSEditorFactory { public: explicit VCSEditorFactory(const VCSBaseEditorParameters *type, - Core::ICore *core, QObject *describeReceiver = 0, const char *describeSlot = 0); @@ -98,10 +88,9 @@ private: template <class Editor> VCSEditorFactory<Editor>::VCSEditorFactory(const VCSBaseEditorParameters *type, - Core::ICore *core, QObject *describeReceiver, const char *describeSlot) : - BaseVCSEditorFactory(type, core), + BaseVCSEditorFactory(type), m_describeReceiver(describeReceiver), m_describeSlot(describeSlot) { diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp index b662abbf409f00655da680edaac5b15a22322c15..616f27794a392e3fd858e8708da12b63d588c6b9 100644 --- a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp +++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp @@ -34,7 +34,6 @@ #include "basevcssubmiteditorfactory.h" #include "vcsbasesubmiteditor.h" -#include <coreplugin/icore.h> #include <coreplugin/editormanager/editormanager.h> namespace VCSBase { @@ -82,8 +81,7 @@ QStringList BaseVCSSubmitEditorFactory::mimeTypes() const Core::IFile *BaseVCSSubmitEditorFactory::open(const QString &fileName) { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); - if (Core::IEditor *iface = core->editorManager()->openEditor(fileName, kind())) + if (Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, kind())) return iface->file(); return 0; } diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 6951d39eea58b0776d35883a23e472101ac84e11..5a4e02dd81eaf4fc6eed60fbf2e634659ed0515e 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -37,29 +37,28 @@ #include "vcsbasetextdocument.h" #include "vcsbaseconstants.h" -#include <coreplugin/icore.h> -#include <coreplugin/uniqueidmanager.h> #include <coreplugin/editormanager/editormanager.h> -#include <texteditor/fontsettings.h> -#include <texteditor/texteditorconstants.h> - +#include <coreplugin/uniqueidmanager.h> +#include <extensionsystem/pluginmanager.h> +#include <projectexplorer/editorconfiguration.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/session.h> -#include <projectexplorer/editorconfiguration.h> +#include <texteditor/fontsettings.h> +#include <texteditor/texteditorconstants.h> +#include <QtCore/QDebug> #include <QtCore/QFileInfo> -#include <QtCore/QTextStream> -#include <QtCore/QSet> +#include <QtCore/QProcess> #include <QtCore/QRegExp> -#include <QtCore/QDebug> +#include <QtCore/QSet> #include <QtCore/QTextCodec> +#include <QtCore/QTextStream> +#include <QtGui/QAction> #include <QtGui/QKeyEvent> #include <QtGui/QLayout> -#include <QtGui/QTextEdit> #include <QtGui/QMenu> -#include <QtGui/QAction> #include <QtGui/QTextCursor> -#include <QtCore/QProcess> +#include <QtGui/QTextEdit> namespace VCSBase { @@ -68,8 +67,7 @@ class VCSBaseEditorEditable : public TextEditor::BaseTextEditorEditable { public: VCSBaseEditorEditable(VCSBaseEditor *, - const VCSBaseEditorParameters *type, - Core::ICore *); + const VCSBaseEditorParameters *type); QList<int> context() const; bool duplicateSupported() const { return false; } @@ -83,14 +81,12 @@ private: }; VCSBaseEditorEditable::VCSBaseEditorEditable(VCSBaseEditor *editor, - const VCSBaseEditorParameters *type, - Core::ICore *core) : - BaseTextEditorEditable(editor), - m_kind(type->kind) + const VCSBaseEditorParameters *type) + : BaseTextEditorEditable(editor), m_kind(type->kind) { - m_context << core->uniqueIDManager()->uniqueIdentifier(QLatin1String(type->context)) - << core->uniqueIDManager()->uniqueIdentifier(QLatin1String(TextEditor::Constants::C_TEXTEDITOR)); - + Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); + m_context << uidm->uniqueIdentifier(QLatin1String(type->context)) + << uidm->uniqueIdentifier(QLatin1String(TextEditor::Constants::C_TEXTEDITOR)); } QList<int> VCSBaseEditorEditable::context() const @@ -100,46 +96,39 @@ QList<int> VCSBaseEditorEditable::context() const // ----------- VCSBaseEditorPrivate -struct VCSBaseEditorPrivate { +struct VCSBaseEditorPrivate +{ VCSBaseEditorPrivate(const VCSBaseEditorParameters *type, QObject *parent); const VCSBaseEditorParameters *m_parameters; QAction *m_describeAction; QString m_currentChange; - Core::ICore *m_core; QString m_source; }; -VCSBaseEditorPrivate::VCSBaseEditorPrivate(const VCSBaseEditorParameters *type, QObject *parent) : - m_parameters(type), - m_describeAction(new QAction(parent)), - m_core(ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()) +VCSBaseEditorPrivate::VCSBaseEditorPrivate(const VCSBaseEditorParameters *type, QObject *parent) + : m_parameters(type), m_describeAction(new QAction(parent)) { } // ------------ VCSBaseEditor -VCSBaseEditor::VCSBaseEditor(const VCSBaseEditorParameters *type, - QWidget *parent) : - BaseTextEditor(parent), - m_d(new VCSBaseEditorPrivate(type, this)) +VCSBaseEditor::VCSBaseEditor(const VCSBaseEditorParameters *type, QWidget *parent) + : BaseTextEditor(parent), + d(new VCSBaseEditorPrivate(type, this)) { if (VCSBase::Constants::Internal::debug) qDebug() << "VCSBaseEditor::VCSBaseEditor" << type->type << type->kind; setReadOnly(true); - - connect(m_d->m_describeAction, SIGNAL(triggered()), this, SLOT(describe())); - + connect(d->m_describeAction, SIGNAL(triggered()), this, SLOT(describe())); viewport()->setMouseTracking(true); - setBaseTextDocument(new Internal::VCSBaseTextDocument); - - setMimeType(QLatin1String(m_d->m_parameters->mimeType)); + setMimeType(QLatin1String(d->m_parameters->mimeType)); } void VCSBaseEditor::init() { - switch (m_d->m_parameters->type) { + switch (d->m_parameters->type) { case RegularCommandOutput: case LogOutput: case AnnotateOutput: @@ -154,17 +143,17 @@ void VCSBaseEditor::init() VCSBaseEditor::~VCSBaseEditor() { - delete m_d; + delete d; } QString VCSBaseEditor::source() const { - return m_d->m_source; + return d->m_source; } void VCSBaseEditor::setSource(const QString &source) { - m_d->m_source = source; + d->m_source = source; } QTextCodec *VCSBaseEditor::codec() const @@ -183,7 +172,7 @@ void VCSBaseEditor::setCodec(QTextCodec *c) EditorContentType VCSBaseEditor::contentType() const { - return m_d->m_parameters->type; + return d->m_parameters->type; } bool VCSBaseEditor::isModified() const @@ -193,19 +182,19 @@ bool VCSBaseEditor::isModified() const TextEditor::BaseTextEditorEditable *VCSBaseEditor::createEditableInterface() { - return new VCSBaseEditorEditable(this, m_d->m_parameters, m_d->m_core); + return new VCSBaseEditorEditable(this, d->m_parameters); } void VCSBaseEditor::contextMenuEvent(QContextMenuEvent *e) { QMenu *menu = createStandardContextMenu(); // 'click on change-interaction' - if (m_d->m_parameters->type == LogOutput || m_d->m_parameters->type == AnnotateOutput) { - m_d->m_currentChange = changeUnderCursor(cursorForPosition(e->pos())); - if (!m_d->m_currentChange.isEmpty()) { - m_d->m_describeAction->setText(tr("Describe change %1").arg(m_d->m_currentChange)); + if (d->m_parameters->type == LogOutput || d->m_parameters->type == AnnotateOutput) { + d->m_currentChange = changeUnderCursor(cursorForPosition(e->pos())); + if (!d->m_currentChange.isEmpty()) { + d->m_describeAction->setText(tr("Describe change %1").arg(d->m_currentChange)); menu->addSeparator(); - menu->addAction(m_d->m_describeAction); + menu->addAction(d->m_describeAction); } } menu->exec(e->globalPos()); @@ -217,7 +206,7 @@ void VCSBaseEditor::mouseMoveEvent(QMouseEvent *e) bool overrideCursor = false; Qt::CursorShape cursorShape; - if (m_d->m_parameters->type == LogOutput || m_d->m_parameters->type == AnnotateOutput) { + if (d->m_parameters->type == LogOutput || d->m_parameters->type == AnnotateOutput) { // Link emulation behaviour for 'click on change-interaction' QTextCursor cursor = cursorForPosition(e->pos()); QString change = changeUnderCursor(cursor); @@ -245,11 +234,11 @@ void VCSBaseEditor::mouseMoveEvent(QMouseEvent *e) void VCSBaseEditor::mouseReleaseEvent(QMouseEvent *e) { - if (m_d->m_parameters->type == LogOutput || m_d->m_parameters->type == AnnotateOutput) { + if (d->m_parameters->type == LogOutput || d->m_parameters->type == AnnotateOutput) { if (e->button() == Qt::LeftButton &&!(e->modifiers() & Qt::ShiftModifier)) { QTextCursor cursor = cursorForPosition(e->pos()); - m_d->m_currentChange = changeUnderCursor(cursor); - if (!m_d->m_currentChange.isEmpty()) { + d->m_currentChange = changeUnderCursor(cursor); + if (!d->m_currentChange.isEmpty()) { describe(); e->accept(); return; @@ -261,7 +250,7 @@ void VCSBaseEditor::mouseReleaseEvent(QMouseEvent *e) void VCSBaseEditor::mouseDoubleClickEvent(QMouseEvent *e) { - if (m_d->m_parameters->type == DiffOutput) { + if (d->m_parameters->type == DiffOutput) { if (e->button() == Qt::LeftButton &&!(e->modifiers() & Qt::ShiftModifier)) { QTextCursor cursor = cursorForPosition(e->pos()); jumpToChangeFromDiff(cursor); @@ -282,16 +271,16 @@ void VCSBaseEditor::keyPressEvent(QKeyEvent *e) void VCSBaseEditor::describe() { if (VCSBase::Constants::Internal::debug) - qDebug() << "VCSBaseEditor::describe" << m_d->m_currentChange; - if (!m_d->m_currentChange.isEmpty()) - emit describeRequested(m_d->m_source, m_d->m_currentChange); + qDebug() << "VCSBaseEditor::describe" << d->m_currentChange; + if (!d->m_currentChange.isEmpty()) + emit describeRequested(d->m_source, d->m_currentChange); } void VCSBaseEditor::slotActivateAnnotation() { // The annotation highlighting depends on contents (change number // set with assigned colors) - if (m_d->m_parameters->type != AnnotateOutput) + if (d->m_parameters->type != AnnotateOutput) return; const QSet<QString> changes = annotationChanges(); @@ -372,9 +361,10 @@ void VCSBaseEditor::jumpToChangeFromDiff(QTextCursor cursor) if (!exists) return; - Core::IEditor *ediface = m_d->m_core->editorManager()->openEditor(fileName); - m_d->m_core->editorManager()->ensureEditorManagerVisible(); - if (TextEditor::ITextEditor *editor = qobject_cast<TextEditor::ITextEditor *>(ediface)) + Core::EditorManager *em = Core::EditorManager::instance(); + Core::IEditor *ed = em->openEditor(fileName); + em->ensureEditorManagerVisible(); + if (TextEditor::ITextEditor *editor = qobject_cast<TextEditor::ITextEditor *>(ed)) editor->gotoLine(chunkStart + lineCount); } @@ -386,7 +376,7 @@ void VCSBaseEditor::setPlainTextData(const QByteArray &data) void VCSBaseEditor::setFontSettings(const TextEditor::FontSettings &fs) { TextEditor::BaseTextEditor::setFontSettings(fs); - if (m_d->m_parameters->type == DiffOutput) { + if (d->m_parameters->type == DiffOutput) { if (DiffHighlighter *highlighter = qobject_cast<DiffHighlighter*>(baseTextDocument()->syntaxHighlighter())) { static QVector<QString> categories; if (categories.isEmpty()) { @@ -413,11 +403,11 @@ const VCSBaseEditorParameters *VCSBaseEditor::findType(const VCSBaseEditorParame } // Find the codec used for a file querying the editor. -static QTextCodec *findFileCodec(const Core::ICore *core, const QString &source) +static QTextCodec *findFileCodec(const QString &source) { typedef QList<Core::IEditor *> EditorList; - const EditorList editors = core->editorManager()->editorsForFileName(source); + const EditorList editors = Core::EditorManager::instance()->editorsForFileName(source); if (!editors.empty()) { const EditorList::const_iterator ecend = editors.constEnd(); for (EditorList::const_iterator it = editors.constBegin(); it != ecend; ++it) @@ -456,13 +446,13 @@ static QTextCodec *findProjectCodec(const QString &dir) return 0; } -QTextCodec *VCSBaseEditor::getCodec(const Core::ICore *core, const QString &source) +QTextCodec *VCSBaseEditor::getCodec(const QString &source) { if (!source.isEmpty()) { // Check file const QFileInfo sourceFi(source); if (sourceFi.isFile()) - if (QTextCodec *fc = findFileCodec(core, source)) + if (QTextCodec *fc = findFileCodec(source)) return fc; // Find by project via directory if (QTextCodec *pc = findProjectCodec(sourceFi.isFile() ? sourceFi.absolutePath() : source)) diff --git a/src/plugins/vcsbase/vcsbaseeditor.h b/src/plugins/vcsbase/vcsbaseeditor.h index 42c31c6c37dfb18b6fd0c6fb9789fb0bec2d3e09..5c516f00ffb56bd696298a4056227341d384f85d 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.h +++ b/src/plugins/vcsbase/vcsbaseeditor.h @@ -46,10 +46,6 @@ class QTextCodec; class QTextCursor; QT_END_NAMESPACE -namespace Core { -class ICore; -} - namespace VCSBase { struct VCSBaseEditorPrivate; @@ -121,7 +117,7 @@ public: // the editor manager and the project managers (defaults to system codec). // The codec should be set on editors displaying diff or annotation // output. - static QTextCodec *getCodec(const Core::ICore *core, const QString &source); + static QTextCodec *getCodec(const QString &source); // Utility to return the editor from the IEditor returned by the editor // manager which is a BaseTextEditable. @@ -166,7 +162,7 @@ private: void jumpToChangeFromDiff(QTextCursor cursor); - VCSBaseEditorPrivate *m_d; + VCSBaseEditorPrivate *d; }; } // namespace VCSBase diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index 7cbd8a9233ed6f2ad6a929d6065f63b18e41b242..06cefbb71dde5cf31700d377600fe311d2d579b5 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -34,13 +34,12 @@ #include "vcsbaseplugin.h" #include "diffhighlighter.h" -#include <extensionsystem/pluginmanager.h> #include <coreplugin/icore.h> #include <coreplugin/coreconstants.h> #include <coreplugin/uniqueidmanager.h> #include <coreplugin/mimedatabase.h> -#include <QtCore/qplugin.h> +#include <QtCore/QtPlugin> namespace VCSBase { namespace Internal { @@ -57,10 +56,12 @@ VCSBasePlugin::~VCSBasePlugin() m_instance = 0; } -bool VCSBasePlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) +bool VCSBasePlugin::initialize(const QStringList &arguments, QString *errorMessage) { - Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>(); + Q_UNUSED(arguments); + Q_UNUSED(errorMessage); + Core::ICore *core = Core::ICore::instance(); if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/vcsbase/VCSBase.mimetypes.xml"), errorMessage)) return false; diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index a47a66ab064be7d2983f0c0dd97c3fd44e2317ae..16636aaedb276483657ffcbfe58ab07b746f7093 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -35,36 +35,35 @@ #include "submiteditorfile.h" #include <coreplugin/ifile.h> -#include <coreplugin/icore.h> #include <coreplugin/uniqueidmanager.h> #include <coreplugin/actionmanager/actionmanager.h> - +#include <extensionsystem/pluginmanager.h> #include <utils/submiteditorwidget.h> #include <find/basetextfind.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/session.h> -#include <QtGui/QToolBar> -#include <QtGui/QStyle> -#include <QtCore/QPointer> -#include <QtCore/QFileInfo> -#include <QtCore/QFile> +#include <QtCore/QDebug> #include <QtCore/QDir> +#include <QtCore/QFile> +#include <QtCore/QFileInfo> +#include <QtCore/QPointer> #include <QtCore/QTextStream> -#include <QtCore/QDebug> +#include <QtGui/QStyle> +#include <QtGui/QToolBar> enum { debug = 0 }; enum { wantToolBar = 0 }; namespace VCSBase { -struct VCSBaseSubmitEditorPrivate { +struct VCSBaseSubmitEditorPrivate +{ VCSBaseSubmitEditorPrivate(const VCSBaseSubmitEditorParameters *parameters, Core::Utils::SubmitEditorWidget *editorWidget, QObject *q); - Core::ICore *m_core; Core::Utils::SubmitEditorWidget *m_widget; QToolBar *m_toolWidget; const VCSBaseSubmitEditorParameters *m_parameters; @@ -79,13 +78,12 @@ struct VCSBaseSubmitEditorPrivate { VCSBaseSubmitEditorPrivate::VCSBaseSubmitEditorPrivate(const VCSBaseSubmitEditorParameters *parameters, Core::Utils::SubmitEditorWidget *editorWidget, QObject *q) : - m_core(ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()), m_widget(editorWidget), m_toolWidget(0), m_parameters(parameters), m_file(new VCSBase::Internal::SubmitEditorFile(QLatin1String(m_parameters->mimeType), q)) { - m_contexts << m_core->uniqueIDManager()->uniqueIdentifier(m_parameters->context); + m_contexts << Core::UniqueIDManager::instance()->uniqueIdentifier(m_parameters->context); } VCSBaseSubmitEditor::VCSBaseSubmitEditor(const VCSBaseSubmitEditorParameters *parameters,