diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp index 0d6575db5b7..199b783f45d 100644 --- a/bin/gdbmacros/gdbmacros.cpp +++ b/bin/gdbmacros/gdbmacros.cpp @@ -1674,7 +1674,10 @@ static void qDumpQObjectSignal(QDumper &d) d.beginHash(); P(d, "name", "[" << i << "] slot"); P(d, "type", ""); - P(d, "value", conn.receiver->metaObject()->method(conn.method).signature()); + if (conn.receiver) + P(d, "value", conn.receiver->metaObject()->method(conn.method).signature()); + else + P(d, "value", ""); P(d, "numchild", "0"); d.endHash(); d.beginHash(); @@ -1861,17 +1864,25 @@ static void qDumpQSet(QDumper &d) n = 100; d << ",children=["; int i = 0; - for (int bucket = 0; bucket != hd->numBuckets; ++bucket) { + for (int bucket = 0; bucket != hd->numBuckets && i <= 10000; ++bucket) { for (node = hd->buckets[bucket]; node->next; node = node->next) { d.beginHash(); P(d, "name", "[" << i << "]"); P(d, "type", d.innertype); - P(d, "exp", "(('QHashNode<" << d.innertype - << ",QHashDummyValue>'*)" + P(d, "exp", "(('"NS"QHashNode<" << d.innertype + << ","NS"QHashDummyValue>'*)" << static_cast(node) << ")->key" ); d.endHash(); ++i; + if (i > 10000) { + d.beginHash(); + P(d, "name", "Warning:"); + P(d, "value", ""); + P(d, "type", ""); + d.endHash(); + break; + } } } d << "]"; diff --git a/doc/qtcreator.qch b/doc/qtcreator.qch index 00473f3458d..c728e43245e 100644 Binary files a/doc/qtcreator.qch and b/doc/qtcreator.qch differ diff --git a/doc/qtcreator.qdoc b/doc/qtcreator.qdoc index 4521b7e2fa4..8ac302ce481 100644 --- a/doc/qtcreator.qdoc +++ b/doc/qtcreator.qdoc @@ -23,6 +23,8 @@ \o \inlineimage qtcreator.png \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. \o \bold{Qt4 Project Generating Wizard}: This wizard allows the user to generate a project for a console application, a GUI application, or a C++ library. @@ -48,7 +50,7 @@ \o \l{Creating a Project in Qt Creator} \o \l{Build Settings} \o \l{Writing a Simple Program with Qt Creator} - \o \l{Quick Navigation} + \o \l{Navigating Quickly Around Your Code} \o \l{Debugging with Qt Creator} \o \l{Tips and Tricks} \o \l{Glossary} @@ -64,86 +66,85 @@ \title A Quick Tour Around Qt Creator - The labeled screenshot below shows some of the components of Qt Creator, - in \gui Edit mode. + The labeled screenshot below shows some of the components of Qt Creator, in + \gui Edit mode. \image qtcreator-breakdown.png - \seection1 The Mode Selectors + \section1 The Mode Selectors - When working in Qt Creator, you can be in one of five modes: \bold Project, - \bold Edit, \bold Debug, \bold Help, and \bold Output. + When working in Qt Creator, you can be in one of six modes: \bold Welcome, + \bold Edit, \bold Debug, \bold Projects, \bold Help, and \bold Output. - Mode selectors allow you to quickly switch between tasks: Editing, - browsing the Qt manual, setting up the build environment, etc. You can + Mode selectors allow you to quickly switch between tasks: Editing, browsing + the Qt Creator manual, setting up the build environment, etc. You can activate a mode by either clicking on its mode selector, or using the \l{keyboard-shortcuts}{corresponding shortcut}. Certain actions also trigger a mode change, e.g., \gui{Debug}/\gui{Start Debugging} will switch to the \gui Debug mode. - \list \o \gui{Welcome Mode} - Displays a welcome screen allowing you to quickly - load recent sessions or individual projects. This is the first mode - displayed if Qt Creator is run without command line switches. + load recent sessions or individual projects. This is the mode you will see + if Qt Creator is run without command line switches. - \o \gui{Edit Mode} - You can edit both project and source files here. An - optional sidebar on the left provides different views to navigate between - files. + \o \gui{Edit Mode} - Lets you edit both project and source files. A sidebar + on the left provides different views to navigate between files. \o \gui{Debug Mode} - Provides various ways to inspect the state of the program while debugging. See \l{qtcreator-debugging}{Debugging With Qt - Creator} for a hands-on description of the mode. + Creator} for a hands-on description of how to use this mode. - \o \gui{Build & Run Mode} - Lets you configure how projects can be built - and executed. Under the list of projects, there are tabs to configure the - build and run settings. + \o \gui{Projects Mode} - Lets you configure how projects can be built and + executed. Under the list of projects, there are tabs to configure the + build, run, and editor settings. \o \gui{Help Mode} - Shows any documentation registered by Qt Assistant, such as the Qt library and Qt Creator documentation. - \o \gui{Output Mode} - Lets you examine various logs in detail, for example - the task list, the compiler and application output. Some of these logs can - also be viewed in the output panes. + \o \gui{Output Mode} - Lets you examine various data in detail, for example + build issues as well as compile and application output. This information + is also available in the output panes. \endlist \section1 The Output Panes - The task pane in Qt Creator can display one out of four different panes: - Task List, Search Results, Application Output, and Compile Output. These - panes are available in all modes. + The task pane in Qt Creator can display one of four different panes: + \gui{Build Issues}, \gui{Search Results}, \gui{Application Output}, and + \gui{Compile}. These panes are available in all modes. - \section2 Task List + \section2 Build Issues - The Task List provides a list of important tasks such as error messages - that need to be fixed. It filters out irrelevant output from the compiler - and collects them in the form of tasks. + The {Build Issues} pane provides a list of issues, e.g., error messages or + warnings that need to be fixed. It filters out irrelevant output from the + compiler and collects them in an organized way. - \image qtcreator-task-list.png + \image qtcreator-build-issues.png \section2 Search Results - The Search Results pane displays the results for global searches such as - searching within a current document, files on disk, or all projects. - In the screenshot below, we searched for all occurrences of \c{textfinder} - within the "/TextFinder" folder. + The \gui{Search Results} pane displays the results for global searches such + as searching within a current document, files on disk, or all projects. In + the screenshot below, we searched for all occurrences of \c{textfinder} + within the \c{"/TextFinder"} folder. \image qtcreator-search-pane.png \section2 Application Output - This pane displays the status of the program when it is executed, as - well as debug output, for example, output from qDebug(). + The \gui{Application Output} pane displays the status of the program when + it is executed and debug output, e.g., output from qDebug(). \image qtcreator-application-output.png - \section2 Compile Output + \section2 Compile - The Compile Output provides all the output from the compiler. In other - words, it is a more verbose version of the Task List. + The \gui{Compile} pane provides all the output from the compiler. In other + words, it is a more verbose version of information displayed in the + \gui{Build Issues} \image qtcreator-compile-pane.png @@ -521,7 +522,7 @@ \page creator-navigation.html \nextpage creator-debugging.html - \title Quick Navigation + \title Navigating Quickly Around Your Code With Qt Creator, navigating to different locations in your project or on your disk, such as files, classes and methods, is trivial using the input @@ -613,7 +614,7 @@ \page creator-debugging.html \nextpage creator-tips.html - \title Debugging With Qt Creator + \title Debugging with Qt Creator \table \row @@ -677,9 +678,9 @@ \list \o At a particular line you want the program to stop -- click on the - left margin or press \key F9 (\key F8 for Mac Os X). - \o At the name of a function that you want the program to stop -- enter - the function's name in \gui{Set Breakpoint at Function...} under the + left margin or press \key F9 (\key F8 for Mac OS X). + \o At a function that you want the program to stop -- enter the + function's name in \gui{Set Breakpoint at Function...} under the \gui Debug menu. \endlist @@ -744,7 +745,7 @@ When the program being debugged is stopped, Qt Creator displays the nested function calls leading to the current position as a \e call stack trace. - This stack trace is built up from \e call stack frames, each representing a + This stack trace is built up from \e{call stack frames}, each representing a particular function. For each function, Qt Creator will try to retrieve the file name and line number of the corresponding source files. This data is shown in the \gui Stack view. @@ -765,11 +766,10 @@ \section2 Threads - The \gui Thread view displays the state of the program being debugged one - thread at a time. If a multi-threaded program is stopped, the \gui Thread - view or the combobox named \gui Thread in the debugger's status bar can - be used to switch from one thread to another. The \gui Stack view will - adjust itself accordingly. + If a multi-threaded program is stopped, the \gui Thread view or the + combobox named \gui Thread in the debugger's status bar can be used to + switch from one thread to another. The \gui Stack view will adjust itself + accordingly. \section2 Locals and Watchers @@ -851,8 +851,7 @@ function, the latter the current state of the CPU registers. Both views are mainly useful in connection with the low-level \gui{Step single instruction} and \gui{Step over single instruction} - commands - + commands. \section1 A Walkthrough for the Debugger Frontend @@ -947,27 +946,27 @@ \bold{Running Qt Creator from the Command Line} - You can start Qt Creator from a command prompt with an existing session or - \c{.pro} file by giving the name as argument on the command line. + You can start Qt Creator from a command prompt with the name of an existing + session or \c{.pro} file by giving the name as argument on the command + line. - \bold{Sidebar} + \bold{Show and Hide the Sidebar} - You can hide/unhide the sidebar in the edit and debug mode - by clicking on the corresponding icon on the left bottom. - Keyboard shortcut is \key{Alt+0}. + You can show and hide the the sidebar in \gui Edit and \gui Debug mode by + clicking on the corresponding icon, or by pressing \key{Alt+0}. - \bold{Display signals and slots} + \bold{Display Signals and Slots} - If you have an instance of a class derived from QObject and - want to find all other objects connected to one of its - slots by Qt's signals-and-slots mechanism, enable - \gui{Debug} and \gui{Use Custom Display for Qt Objects}. - In the \gui{Locals and Watchers View}, expand the object's - entry and open the wanted slot in the "slots" subitem. The - objects connect to this slot are exposed as children of - this slot. The same works with signals. + If you have an instance of a class that is derived from QObject, and you + you would like to find all other objects connected to one of your object's + slots using Qt's signals and slots mechanism -- you can enable + \gui{Use Custom Display for Qt Objects} feature under the \gui Debug menu. - \bold{Low level display} + In the \gui{Locals and Watchers} view, expand the object's entry and open + the slot in the \e slots subitem. The objects connected to this slot are + exposed as children of the slot. This method works with signals too. + + \bold{Display Low Level Data} If the special debugging of Qt objects fails due to data corruption within the debugged objects, you can switch the @@ -983,33 +982,38 @@ \title Glossary - \bold{System Qt} + \table + \header + \o Term + \o Meaning - \target glossary-system-qt - The version of Qt installed on your system. - This is the one whose \c qmake command is found in the \c PATH. + \row + \o System Qt \target glossary-system-qt + \o The version of Qt installed on your system. This is the Qt + version for the \c qmake command found in your \c PATH. - \bold{Default Qt} + \row + \o Default Qt \target glossary-default-qt + \o The version of Qt configured in \gui{Tools -> Options -> Qt 4 + -> Default Qt Version}. This is the Qt version used by your + new projects. It defaults to System Qt. - \target glossary-default-qt - The version of Qt configured in \gui{Tools - -> Options -> Qt 4 -> Default Qt Version}. This is the version - used by new projects. It defaults to the System Qt. + \row + \o Project Qt \target glossary-project-qt + \o The version of Qt configured in \gui{Build&Run -> Build + Settings -> Build Configurations}. This is the Qt version that + is actually used by a particular project. It defaults to + Default Qt. - \bold{Project Qt} - - \target glossary-project-qt - The version of Qt configured in \gui{Build&Run - -> Build Settings -> Build Configurations}. This is the version - actually used by the project. It defaults to the Default Qt. - - \bold{Shadow Build} - - \target glossary-shadow-build - Shadow building means building the project not in the source directory, - but in a seperate \bold{build directory}. This has the benefit of keeping - the source directory clean. It is also considered "best practice" if - you need many build configurations for a single set of sources. + \row + \o Shadow Build \target glossary-shadow-build + \o Shadow building means building a project in a separate + directory, the \e{build directory}. The build directory is + different from the source directory. One of the benefits of + shadow building is that it keeps your source directory clean. + Shadow building is the best practice if you need many build + configurations for a single set of source. + \endtable */ diff --git a/installer/qinstaller.cpp b/installer/qinstaller.cpp index b0b4cbff77e..9ccaa53850c 100644 --- a/installer/qinstaller.cpp +++ b/installer/qinstaller.cpp @@ -239,7 +239,7 @@ static void appendFileData(QIODevice *out, const QString &fileName) static void appendFileData(QIODevice *out, QIODevice *in) { - Q_ASSERT(!in->isSequential()); + QTC_ASSERT(!in->isSequential(), return); qint64 size = in->size(); QByteArray &b = theBuffer(size); rawRead(in, b.data(), size); diff --git a/shared/cpaster/cgi.cpp b/shared/cpaster/cgi.cpp index 2e94dc96b02..6e8ecd1404c 100644 --- a/shared/cpaster/cgi.cpp +++ b/shared/cpaster/cgi.cpp @@ -45,7 +45,7 @@ QString CGI::encodeURL(const QString &rawText) enc.reserve(utf.length()); // Make sure we at least have space for a normal US-ASCII URL QByteArray::const_iterator it = utf.constBegin(); - while(it != utf.constEnd()) { + while (it != utf.constEnd()) { char ch = *it; if (('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z') @@ -54,7 +54,7 @@ QString CGI::encodeURL(const QString &rawText) else if (ch == ' ') enc.append('+'); else { - switch(ch) { + switch (ch) { case '-': case '_': case '(': case ')': case '.': case '!': @@ -80,15 +80,15 @@ QString CGI::decodeURL(const QString &urlText) { QByteArray dec; QString::const_iterator it = urlText.constBegin(); - while(it != urlText.constEnd()) { + while (it != urlText.constEnd()) { ushort ch = (*it).unicode(); - switch(ch) { + switch (ch) { case '%': { char c1 = char(0x00ff & (*(++it)).unicode()); char c2 = char(0x00ff & (*(++it)).unicode()); ushort v = 0; - if('A' <= c1 && c1 <= 'Z') + if ('A' <= c1 && c1 <= 'Z') v = c1 - 'A' + 10; else if ('a' <= c1 && c1 <= 'z') v = c1 - 'a' + 10; @@ -97,7 +97,7 @@ QString CGI::decodeURL(const QString &urlText) else continue; // Malformed URL! v <<= 4; // c1 was MSB half - if('A' <= c2 && c2 <= 'Z') + if ('A' <= c2 && c2 <= 'Z') v |= c2 - 'A' + 10; else if ('a' <= c2 && c2 <= 'z') v |= c2 - 'a' + 10; @@ -123,7 +123,7 @@ QString CGI::decodeURL(const QString &urlText) // ------------------------------------------------------------------------------------------------- inline const char *unicodeToHTML(ushort unicode_char) { - switch(unicode_char) { + switch (unicode_char) { // Latin ------------------------------- case 0x0022: return "quot"; // (34 ) quotation mark = APL quote case 0x0026: return "amp"; // (38 ) ampersand diff --git a/shared/cpaster/splitter.cpp b/shared/cpaster/splitter.cpp index 08ec626f625..22ccf1d9901 100644 --- a/shared/cpaster/splitter.cpp +++ b/shared/cpaster/splitter.cpp @@ -66,10 +66,8 @@ FileDataList splitDiffToFiles(const QByteArray &data) // The algorithm works like this: // On the first match we only get the filename of the first patch part // On the second match (if any) we get the diff content, and the name of the next file patch - // - - while(-1 != (splitIndex = splitExpr.indexIn(strData,splitIndex))) { + while (-1 != (splitIndex = splitExpr.indexIn(strData,splitIndex))) { if (!filename.isEmpty()) { QString content = strData.mid(previousSplit, splitIndex - previousSplit); ret.append(FileData(filename, content.toLatin1())); diff --git a/shared/cpaster/view.cpp b/shared/cpaster/view.cpp index ca5bd270eb2..6c37defe36b 100644 --- a/shared/cpaster/view.cpp +++ b/shared/cpaster/view.cpp @@ -125,7 +125,7 @@ QString View::getComment() QByteArray View::getContent() { QByteArray newContent; - for(int i = 0; i < m_ui.uiPatchList->count(); ++i) { + for (int i = 0; i < m_ui.uiPatchList->count(); ++i) { QListWidgetItem *item = m_ui.uiPatchList->item(i); if (item->checkState() != Qt::Unchecked) newContent += m_parts.at(i).content; @@ -159,7 +159,7 @@ int View::show(const QString &user, const QString &description, const QString &c QByteArray content; m_parts = parts; m_ui.uiPatchList->clear(); - foreach(const FileData part, parts) { + foreach (const FileData part, parts) { QListWidgetItem *itm = new QListWidgetItem(part.filename, m_ui.uiPatchList); itm->setCheckState(Qt::Checked); itm->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); diff --git a/shared/cplusplus/Control.cpp b/shared/cplusplus/Control.cpp index c994dbab9a2..a486dfdb940 100644 --- a/shared/cplusplus/Control.cpp +++ b/shared/cplusplus/Control.cpp @@ -511,6 +511,12 @@ Identifier *Control::findOrInsertIdentifier(const char *chars) return findOrInsertIdentifier(chars, length); } +Control::IdentifierIterator Control::firstIdentifier() const +{ return d->identifiers.begin(); } + +Control::IdentifierIterator Control::lastIdentifier() const +{ return d->identifiers.end(); } + StringLiteral *Control::findOrInsertStringLiteral(const char *chars, unsigned size) { return d->stringLiterals.findOrInsertLiteral(chars, size); } diff --git a/shared/cplusplus/Control.h b/shared/cplusplus/Control.h index fa7b4faa502..bd4b204843f 100644 --- a/shared/cplusplus/Control.h +++ b/shared/cplusplus/Control.h @@ -151,6 +151,11 @@ public: Identifier *findOrInsertIdentifier(const char *chars, unsigned size); Identifier *findOrInsertIdentifier(const char *chars); + typedef const Identifier *const *IdentifierIterator; + + IdentifierIterator firstIdentifier() const; + IdentifierIterator lastIdentifier() const; + StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size); StringLiteral *findOrInsertStringLiteral(const char *chars); diff --git a/shared/designerintegrationv2/formresizer.cpp b/shared/designerintegrationv2/formresizer.cpp index 3b44599d7ef..156b8e718ac 100644 --- a/shared/designerintegrationv2/formresizer.cpp +++ b/shared/designerintegrationv2/formresizer.cpp @@ -30,19 +30,22 @@ ** version 1.2, included in the file GPL_EXCEPTION.txt in this package. ** ***************************************************************************/ + #include "formresizer.h" #include "sizehandlerect.h" #include "widgethostconstants.h" +#include + #include + #include #include #include #include #include -#include -enum { debugFormResizer=0 }; +enum { debugFormResizer = 0 }; using namespace SharedTools::Internal; @@ -140,7 +143,7 @@ void FormResizer::setFormWindow(QDesignerFormWindowInterface *fw) if (debugFormResizer) qDebug() << "FormResizer::setFormWindow " << fw; QVBoxLayout *layout = qobject_cast(m_frame->layout()); - Q_ASSERT(layout); + QTC_ASSERT(layout, return); if (layout->count()) delete layout->takeAt(0); m_formWindow = fw; diff --git a/shared/help/bookmarkmanager.h b/shared/help/bookmarkmanager.h index a8afa867e65..c40d8672db0 100644 --- a/shared/help/bookmarkmanager.h +++ b/shared/help/bookmarkmanager.h @@ -95,8 +95,10 @@ private: QSortFilterProxyModel *proxyModel; }; -class TreeView : public QTreeView { +class TreeView : public QTreeView +{ Q_OBJECT + public: TreeView(QWidget* parent = 0) : QTreeView(parent) {} void subclassKeyPressEvent(QKeyEvent* event) @@ -159,18 +161,18 @@ class BookmarkManager : public QObject Q_OBJECT public: - BookmarkManager(QHelpEngineCore* helpEngine); + BookmarkManager(QHelpEngineCore *helpEngine); ~BookmarkManager(); - BookmarkModel* treeBookmarkModel(); - BookmarkModel* listBookmarkModel(); + BookmarkModel *treeBookmarkModel(); + BookmarkModel *listBookmarkModel(); void saveBookmarks(); QStringList bookmarkFolders() const; - QModelIndex addNewFolder(const QModelIndex& index); + QModelIndex addNewFolder(const QModelIndex &index); void removeBookmarkItem(QTreeView *treeView, const QModelIndex& index); - void showBookmarkDialog(QWidget* parent, const QString &name, const QString &url); - void addNewBookmark(const QModelIndex& index, const QString &name, const QString &url); + void showBookmarkDialog(QWidget *parent, const QString &name, const QString &url); + void addNewBookmark(const QModelIndex &index, const QString &name, const QString &url); void setupBookmarkModels(); private slots: diff --git a/shared/help/helpviewer.cpp b/shared/help/helpviewer.cpp index d542e4996f5..9b80e99cd84 100644 --- a/shared/help/helpviewer.cpp +++ b/shared/help/helpviewer.cpp @@ -409,7 +409,7 @@ QVariant HelpViewer::loadResource(int type, const QUrl &name) void HelpViewer::openLinkInNewTab() { - if(lastAnchor.isEmpty()) + if (lastAnchor.isEmpty()) return; parentWidget->setSourceInNewTab(QUrl(lastAnchor)); diff --git a/shared/indenter/constants.cpp b/shared/indenter/constants.cpp index 2339ceb6938..120ebdccb22 100644 --- a/shared/indenter/constants.cpp +++ b/shared/indenter/constants.cpp @@ -33,6 +33,8 @@ #include "indenter.h" +#include + using namespace SharedTools::IndenterInternal; // --- Constants @@ -55,12 +57,12 @@ Constants::Constants() : "|(?:public|protected|private|signals|Q_SIGNALS|default)(?:\\s+slots|\\s+Q_SLOTS)?\\s*" ")?:.*")) { - m_literal.setMinimal( true ); - m_inlineCComment.setMinimal( true ); - Q_ASSERT(m_literal.isValid()); - Q_ASSERT(m_label.isValid()); - Q_ASSERT(m_inlineCComment.isValid()); - Q_ASSERT(m_braceX.isValid()); - Q_ASSERT(m_iflikeKeyword.isValid()); - Q_ASSERT(m_caseLabel.isValid()); + m_literal.setMinimal(true); + m_inlineCComment.setMinimal(true); + QTC_ASSERT(m_literal.isValid(), return); + QTC_ASSERT(m_label.isValid(), return); + QTC_ASSERT(m_inlineCComment.isValid(), return); + QTC_ASSERT(m_braceX.isValid(), return); + QTC_ASSERT(m_iflikeKeyword.isValid(), return); + QTC_ASSERT(m_caseLabel.isValid(), return); } diff --git a/shared/indenter/test/main.cpp b/shared/indenter/test/main.cpp index 701f66987c0..e9c9396197a 100644 --- a/shared/indenter/test/main.cpp +++ b/shared/indenter/test/main.cpp @@ -174,7 +174,7 @@ int main(int argc, char **argv) return 1; } - foreach(QString fileName, fileNames) + foreach (const QString &fileName, fileNames) if (const int rc = format(fileName)) return rc; diff --git a/shared/proparser/procommandmanager.cpp b/shared/proparser/procommandmanager.cpp index a6b61f4a3fb..99fc3025637 100644 --- a/shared/proparser/procommandmanager.cpp +++ b/shared/proparser/procommandmanager.cpp @@ -33,6 +33,8 @@ #include "procommandmanager.h" +#include + using namespace Qt4ProjectManager::Internal; ProCommandGroup::ProCommandGroup(const QString &name) @@ -76,7 +78,7 @@ ProCommandManager::~ProCommandManager() void ProCommandManager::beginGroup(const QString &name) { - Q_ASSERT(!m_group); + QTC_ASSERT(!m_group, return); if (m_pos != m_groups.count()) { int removecount = m_groups.count() - m_pos; @@ -95,7 +97,7 @@ bool ProCommandManager::hasGroup() const void ProCommandManager::endGroup() { - Q_ASSERT(m_group); + QTC_ASSERT(m_group, return); m_groups.append(m_group); m_pos = m_groups.count(); @@ -106,7 +108,7 @@ void ProCommandManager::endGroup() bool ProCommandManager::command(ProCommand *cmd) { - Q_ASSERT(m_group); + QTC_ASSERT(m_group, return false); if (cmd->redo()) { m_group->appendCommand(cmd); diff --git a/shared/proparser/proeditor.cpp b/shared/proparser/proeditor.cpp index 02287b06ab1..93adb12493e 100644 --- a/shared/proparser/proeditor.cpp +++ b/shared/proparser/proeditor.cpp @@ -139,7 +139,7 @@ bool ProEditor::eventFilter(QObject *, QEvent *event) if (event->type() == QEvent::ShortcutOverride) { QKeyEvent *k = static_cast(event); if (k->modifiers() == Qt::ControlModifier) { - switch(k->key()) { + switch (k->key()) { case Qt::Key_X: cut(); return true; case Qt::Key_C: @@ -168,11 +168,8 @@ void ProEditor::updatePasteAction() bool pasteEnabled = false; const QMimeData *data = QApplication::clipboard()->mimeData(); - if (data) { - if (data->hasFormat(QLatin1String("application/x-problock"))) { - pasteEnabled = true; - } - } + if (data && data->hasFormat(QLatin1String("application/x-problock"))) + pasteEnabled = true; m_pasteAction->setEnabled(pasteEnabled); } diff --git a/shared/proparser/proeditormodel.cpp b/shared/proparser/proeditormodel.cpp index d0f28f68688..a929c7ab88d 100644 --- a/shared/proparser/proeditormodel.cpp +++ b/shared/proparser/proeditormodel.cpp @@ -732,13 +732,10 @@ bool ProEditorModel::insertItem(ProItem *item, int row, const QModelIndex &paren void ProEditorModel::markProFileModified(QModelIndex index) { - while(index.isValid()) - { - if( proItem(index)->kind() == ProItem::BlockKind) - { + while (index.isValid()) { + if (proItem(index)->kind() == ProItem::BlockKind) { ProBlock * block = proBlock(index); - if(block->blockKind() == ProBlock::ProFileKind) - { + if (block->blockKind() == ProBlock::ProFileKind) { ProFile * file = static_cast(block); file->setModified(true); return; @@ -791,9 +788,9 @@ QString ProEditorModel::expressionToString(ProBlock *block, bool display) const { QString result; QList items = block->items(); - for(int i=0; ikind()) { + switch (item->kind()) { case ProItem::FunctionKind: { ProFunction *v = static_cast(item); result += v->text(); @@ -808,14 +805,16 @@ QString ProEditorModel::expressionToString(ProBlock *block, bool display) const } else { result += v->text(); } - break; } + break; + } case ProItem::OperatorKind: { ProOperator *v = static_cast(item); if (v->operatorKind() == ProOperator::NotOperator) result += QLatin1Char('!'); else result += QLatin1Char('|'); - break; } + break; + } case ProItem::ValueKind: case ProItem::BlockKind: break; // ### unhandled @@ -847,7 +846,7 @@ QList ProEditorModel::stringToExpression(const QString &exp) const bool c = false; QString tmpstr; - for (int i=0; i + #include #include #include @@ -332,7 +334,7 @@ void ProFileEvaluator::Private::insertOperator(const char op) updateItem(); ProOperator::OperatorKind opkind; - switch(op) { + switch (op) { case '!': opkind = ProOperator::NotOperator; break; @@ -532,21 +534,21 @@ bool ProFileEvaluator::Private::visitEndProFile(ProFile * pro) evaluateFile(mkspecDirectory + "/features/default_post.prf", &ok); QStringList processed; - while(1) { + while (1) { bool finished = true; QStringList configs = values("CONFIG"); - for(int i = configs.size()-1; i >= 0; --i) { + for (int i = configs.size()-1; i >= 0; --i) { const QString config = configs[i].toLower(); - if(!processed.contains(config)) { + if (!processed.contains(config)) { processed.append(config); evaluateFile(mkspecDirectory + "/features/" + config + ".prf", &ok); - if(ok) { + if (ok) { finished = false; break; } } } - if(finished) + if (finished) break; } } @@ -683,7 +685,7 @@ bool ProFileEvaluator::Private::visitProFunction(ProFunction *func) QString text = func->text(); int lparen = text.indexOf(QLatin1Char('(')); int rparen = text.lastIndexOf(QLatin1Char(')')); - Q_ASSERT(lparen < rparen); + QTC_ASSERT(lparen < rparen, return false); QString arguments = text.mid(lparen + 1, rparen - lparen - 1); QString funcName = text.left(lparen); diff --git a/shared/proparser/proparserutils.h b/shared/proparser/proparserutils.h index 8c5cb3aaabc..82941e31c1b 100644 --- a/shared/proparser/proparserutils.h +++ b/shared/proparser/proparserutils.h @@ -173,41 +173,41 @@ static QStringList split_arg_list(QString params) const QChar *params_data = params.data(); const int params_len = params.length(); int last = 0; - while(last < params_len && ((params_data+last)->unicode() == SPACE + while (last < params_len && ((params_data+last)->unicode() == SPACE /*|| (params_data+last)->unicode() == TAB*/)) ++last; - for(int x = last, parens = 0; x <= params_len; x++) { + for (int x = last, parens = 0; x <= params_len; x++) { unicode = (params_data+x)->unicode(); - if(x == params_len) { - while(x && (params_data+(x-1))->unicode() == SPACE) + if (x == params_len) { + while (x && (params_data+(x-1))->unicode() == SPACE) --x; QString mid(params_data+last, x-last); - if(quote) { - if(mid[0] == quote && mid[(int)mid.length()-1] == quote) + if (quote) { + if (mid[0] == quote && mid[(int)mid.length()-1] == quote) mid = mid.mid(1, mid.length()-2); quote = 0; } args << mid; break; } - if(unicode == LPAREN) { + if (unicode == LPAREN) { --parens; - } else if(unicode == RPAREN) { + } else if (unicode == RPAREN) { ++parens; - } else if(quote && unicode == quote) { + } else if (quote && unicode == quote) { quote = 0; - } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) { + } else if (!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) { quote = unicode; - } else if(!parens && !quote && unicode == COMMA) { + } else if (!parens && !quote && unicode == COMMA) { QString mid = params.mid(last, x - last).trimmed(); args << mid; last = x+1; - while(last < params_len && ((params_data+last)->unicode() == SPACE + while (last < params_len && ((params_data+last)->unicode() == SPACE /*|| (params_data+last)->unicode() == TAB*/)) ++last; } } - for(int i = 0; i < args.count(); i++) + for (int i = 0; i < args.count(); i++) unquote(&args[i]); return args; } @@ -227,22 +227,22 @@ static QStringList split_value_list(const QString &vals, bool do_semicolon=false const QChar *vals_data = vals.data(); const int vals_len = vals.length(); - for(int x = 0, parens = 0; x < vals_len; x++) { + for (int x = 0, parens = 0; x < vals_len; x++) { QChar c = vals_data[x]; if (x != vals_len-1 && c == BACKSLASH && vals_data[x+1].unicode() == '\'' || vals_data[x+1] == DOUBLEQUOTE) { build += vals_data[x++]; // get that 'escape' } else if (!quote.isEmpty() && c == quote.top()) { quote.pop(); - } else if(c == SINGLEQUOTE || c == DOUBLEQUOTE) { + } else if (c == SINGLEQUOTE || c == DOUBLEQUOTE) { quote.push(c); - } else if(c == RPAREN) { + } else if (c == RPAREN) { --parens; - } else if(c == LPAREN) { + } else if (c == LPAREN) { ++parens; } - if(!parens && quote.isEmpty() && ((do_semicolon && c == SEMICOLON) || + if (!parens && quote.isEmpty() && ((do_semicolon && c == SEMICOLON) || vals_data[x] == Option::field_sep)) { ret << build; build.clear(); @@ -250,7 +250,7 @@ static QStringList split_value_list(const QString &vals, bool do_semicolon=false build += vals_data[x]; } } - if(!build.isEmpty()) + if (!build.isEmpty()) ret << build; return ret; } @@ -262,7 +262,7 @@ static QStringList qmake_mkspec_paths() QByteArray qmakepath = qgetenv("QMAKEPATH"); if (!qmakepath.isEmpty()) { const QStringList lst = splitPathList(QString::fromLocal8Bit(qmakepath)); - for(QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it) + for (QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it) ret << ((*it) + concat); } ret << QLibraryInfo::location(QLibraryInfo::DataPath) + concat; diff --git a/shared/proparser/prowriter.cpp b/shared/proparser/prowriter.cpp index 0f215fd79c4..98787294ce4 100644 --- a/shared/proparser/prowriter.cpp +++ b/shared/proparser/prowriter.cpp @@ -137,7 +137,7 @@ void ProWriter::writeBlock(ProBlock *block, const QString &indent) if (block->blockKind() & ProBlock::VariableKind) { ProVariable *v = static_cast(block); m_out << v->variable(); - switch(v->variableOperator()) { + switch (v->variableOperator()) { case ProVariable::AddOperator: m_out << QLatin1String(" += "); break; case ProVariable::RemoveOperator: @@ -165,12 +165,12 @@ void ProWriter::writeBlock(ProBlock *block, const QString &indent) } QList items = block->items(); - for (int i=0; iitems()) { + foreach (ProItem *child, block->items()) { QDomNode childNode = createItemNode(doc, child); if (!childNode.isNull()) tag.appendChild(childNode); diff --git a/shared/proparser/valueeditor.cpp b/shared/proparser/valueeditor.cpp index 2208b0492e9..638d7994a92 100644 --- a/shared/proparser/valueeditor.cpp +++ b/shared/proparser/valueeditor.cpp @@ -131,7 +131,7 @@ void ValueEditor::initialize() connect(m_itemListWidget, SIGNAL(itemChanged(QListWidgetItem *)), this, SLOT(updateItemChanges(QListWidgetItem *))); - foreach(ProVariableInfo *varinfo, m_infomanager->variables()) { + foreach (ProVariableInfo *varinfo, m_infomanager->variables()) { m_varComboBox->addItem(varinfo->name(), varinfo->id()); } diff --git a/shared/qrceditor/resourcefile.cpp b/shared/qrceditor/resourcefile.cpp index daf1946e53e..f394f43f41e 100644 --- a/shared/qrceditor/resourcefile.cpp +++ b/shared/qrceditor/resourcefile.cpp @@ -33,13 +33,16 @@ #include "resourcefile_p.h" -#include -#include -#include +#include + #include -#include -#include #include +#include +#include +#include +#include +#include + #include #include @@ -109,14 +112,14 @@ bool ResourceFile::load() const QString language = relt.attribute(QLatin1String("lang")); const int idx = indexOfPrefix(prefix); - Prefix * p = NULL; + Prefix * p = 0; if (idx == -1) { p = new Prefix(prefix, language); m_prefix_list.append(p); } else { p = m_prefix_list[idx]; } - Q_ASSERT(p != NULL); + QTC_ASSERT(p, return false); QDomElement felt = relt.firstChildElement(QLatin1String("file")); for (; !felt.isNull(); felt = felt.nextSiblingElement(QLatin1String("file"))) { @@ -151,7 +154,7 @@ bool ResourceFile::save() const QStringList name_list = prefixList(); - foreach (QString name, name_list) { + foreach (const QString &name, name_list) { FileList file_list; QString lang; foreach (Prefix *pref, m_prefix_list) { @@ -164,7 +167,7 @@ bool ResourceFile::save() QDomElement relt = doc.createElement(QLatin1String("qresource")); root.appendChild(relt); relt.setAttribute(QLatin1String("prefix"), name); - if(!lang.isEmpty()) + if (!lang.isEmpty()) relt.setAttribute(QLatin1String("lang"), lang); foreach (const File *f, file_list) { @@ -247,9 +250,9 @@ bool ResourceFile::isEmpty() const QStringList ResourceFile::fileList(int pref_idx) const { - Q_ASSERT((pref_idx >= 0) && (pref_idx < m_prefix_list.count())); - const FileList &abs_file_list = m_prefix_list.at(pref_idx)->file_list; QStringList result; + QTC_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count(), return result); + const FileList &abs_file_list = m_prefix_list.at(pref_idx)->file_list; foreach (const File *abs_file, abs_file_list) result.append(relativePath(abs_file->name)); return result; @@ -258,9 +261,9 @@ QStringList ResourceFile::fileList(int pref_idx) const void ResourceFile::addFile(int prefix_idx, const QString &file, int file_idx) { Prefix * const p = m_prefix_list[prefix_idx]; - Q_ASSERT(p != NULL); + QTC_ASSERT(p, return); FileList &files = p->file_list; - Q_ASSERT((file_idx >= -1) && (file_idx <= files.size())); + QTC_ASSERT(file_idx >= -1 && file_idx <= files.size(), return); if (file_idx == -1) file_idx = files.size(); files.insert(file_idx, new File(p, absolutePath(file))); @@ -272,7 +275,7 @@ void ResourceFile::addPrefix(const QString &prefix, int prefix_idx) if (indexOfPrefix(fixed_prefix) != -1) return; - Q_ASSERT((prefix_idx >= -1) && (prefix_idx <= m_prefix_list.size())); + QTC_ASSERT(prefix_idx >= -1 && prefix_idx <= m_prefix_list.size(), return); if (prefix_idx == -1) prefix_idx = m_prefix_list.size(); m_prefix_list.insert(prefix_idx, new Prefix(fixed_prefix)); @@ -280,7 +283,7 @@ void ResourceFile::addPrefix(const QString &prefix, int prefix_idx) void ResourceFile::removePrefix(int prefix_idx) { - Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count())); + QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return); Prefix * const p = m_prefix_list.at(prefix_idx); delete p; m_prefix_list.removeAt(prefix_idx); @@ -288,39 +291,39 @@ void ResourceFile::removePrefix(int prefix_idx) void ResourceFile::removeFile(int prefix_idx, int file_idx) { - Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count())); + QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return); FileList &fileList = m_prefix_list[prefix_idx]->file_list; - Q_ASSERT((file_idx >= 0) && (file_idx < fileList.count())); + QTC_ASSERT(file_idx >= 0 && file_idx < fileList.count(), return); delete fileList.at(file_idx); fileList.removeAt(file_idx); } void ResourceFile::replacePrefix(int prefix_idx, const QString &prefix) { - Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count())); + QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return); m_prefix_list[prefix_idx]->name = fixPrefix(prefix); } void ResourceFile::replaceLang(int prefix_idx, const QString &lang) { - Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count())); + QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return); m_prefix_list[prefix_idx]->lang = lang; } void ResourceFile::replaceAlias(int prefix_idx, int file_idx, const QString &alias) { - Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count())); + QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return); FileList &fileList = m_prefix_list.at(prefix_idx)->file_list; - Q_ASSERT((file_idx >= 0) && (file_idx < fileList.count())); + QTC_ASSERT(file_idx >= 0 && file_idx < fileList.count(), return); fileList[file_idx]->alias = alias; } void ResourceFile::replaceFile(int pref_idx, int file_idx, const QString &file) { - Q_ASSERT((pref_idx >= 0) && (pref_idx < m_prefix_list.count())); + QTC_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count(), return); FileList &fileList = m_prefix_list.at(pref_idx)->file_list; - Q_ASSERT((file_idx >= 0) && (file_idx < fileList.count())); + QTC_ASSERT(file_idx >= 0 && file_idx < fileList.count(), return); fileList[file_idx]->name = file; } @@ -336,7 +339,7 @@ int ResourceFile::indexOfPrefix(const QString &prefix) const int ResourceFile::indexOfFile(int pref_idx, const QString &file) const { - Q_ASSERT((pref_idx >= 0) && (pref_idx < m_prefix_list.count())); + QTC_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count(), return -1); Prefix * const p = m_prefix_list.at(pref_idx); File equalFile(p, absolutePath(file)); return p->file_list.indexOf(&equalFile); @@ -370,16 +373,16 @@ bool ResourceFile::contains(const QString &prefix, const QString &file) const return false; if (file.isEmpty()) return true; - Q_ASSERT((pref_idx >= 0) && (pref_idx < m_prefix_list.count())); + QTC_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count(), return false); Prefix * const p = m_prefix_list.at(pref_idx); - Q_ASSERT(p != NULL); + QTC_ASSERT(p, return false); File equalFile(p, absolutePath(file)); return p->file_list.contains(&equalFile); } bool ResourceFile::contains(int pref_idx, const QString &file) const { - Q_ASSERT((pref_idx >= 0) && (pref_idx < m_prefix_list.count())); + QTC_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count(), return false); Prefix * const p = m_prefix_list.at(pref_idx); File equalFile(p, absolutePath(file)); return p->file_list.contains(&equalFile); @@ -409,49 +412,49 @@ int ResourceFile::prefixCount() const QString ResourceFile::prefix(int idx) const { - Q_ASSERT((idx >= 0) && (idx < m_prefix_list.count())); + QTC_ASSERT((idx >= 0) && (idx < m_prefix_list.count()), return QString()); return m_prefix_list.at(idx)->name; } QString ResourceFile::lang(int idx) const { - Q_ASSERT((idx >= 0) && (idx < m_prefix_list.count())); + QTC_ASSERT(idx >= 0 && idx < m_prefix_list.count(), return QString()); return m_prefix_list.at(idx)->lang; } int ResourceFile::fileCount(int prefix_idx) const { - Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count())); + QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return 0); return m_prefix_list.at(prefix_idx)->file_list.size(); } QString ResourceFile::file(int prefix_idx, int file_idx) const { - Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count())); + QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return QString()); FileList &fileList = m_prefix_list.at(prefix_idx)->file_list; - Q_ASSERT((file_idx >= 0) && (file_idx < fileList.count())); + QTC_ASSERT(file_idx >= 0 && file_idx < fileList.count(), return QString()); return fileList.at(file_idx)->name; } QString ResourceFile::alias(int prefix_idx, int file_idx) const { - Q_ASSERT((prefix_idx >= 0) && (prefix_idx < m_prefix_list.count())); + QTC_ASSERT(prefix_idx >= 0 && prefix_idx < m_prefix_list.count(), return QString()); FileList &fileList = m_prefix_list.at(prefix_idx)->file_list; - Q_ASSERT((file_idx >= 0) && (file_idx < fileList.count())); + QTC_ASSERT(file_idx >= 0 && file_idx < fileList.count(), return QString()); return fileList.at(file_idx)->alias; } void * ResourceFile::prefixPointer(int prefixIndex) const { - Q_ASSERT((prefixIndex >= 0) && (prefixIndex < m_prefix_list.count())); + QTC_ASSERT(prefixIndex >= 0 && prefixIndex < m_prefix_list.count(), return 0); return m_prefix_list.at(prefixIndex); } void * ResourceFile::filePointer(int prefixIndex, int fileIndex) const { - Q_ASSERT((prefixIndex >= 0) && (prefixIndex < m_prefix_list.count())); + QTC_ASSERT(prefixIndex >= 0 && prefixIndex < m_prefix_list.count(), return 0); FileList &fileList = m_prefix_list.at(prefixIndex)->file_list; - Q_ASSERT((fileIndex >= 0) && (fileIndex < fileList.count())); + QTC_ASSERT(fileIndex >= 0 && fileIndex < fileList.count(), return 0); return fileList.at(fileIndex); } @@ -497,28 +500,28 @@ QModelIndex ResourceModel::index(int row, int column, const QModelIndex &parent) if (column != 0) return QModelIndex(); - void * internalPointer = NULL; + void * internalPointer = 0; if (parent.isValid()) { void * const pip = parent.internalPointer(); - if (pip == NULL) + if (pip == 0) return QModelIndex(); // File node Node * const node = reinterpret_cast(pip); Prefix * const prefix = node->prefix(); - Q_ASSERT(prefix != NULL); - if ((row < 0) || (row >= prefix->file_list.count())) + QTC_ASSERT(prefix, return QModelIndex()); + if (row < 0 || row >= prefix->file_list.count()) return QModelIndex(); const int prefixIndex = m_resource_file.prefixPointerIndex(prefix); const int fileIndex = row; internalPointer = m_resource_file.filePointer(prefixIndex, fileIndex); } else { // Prefix node - if ((row < 0) || (row >= m_resource_file.prefixCount())) + if (row < 0 || row >= m_resource_file.prefixCount()) return QModelIndex(); internalPointer = m_resource_file.prefixPointer(row); } - Q_ASSERT(internalPointer != NULL); + QTC_ASSERT(internalPointer, return QModelIndex()); return createIndex(row, 0, internalPointer); } @@ -528,16 +531,16 @@ QModelIndex ResourceModel::parent(const QModelIndex &index) const return QModelIndex(); void * const internalPointer = index.internalPointer(); - if (internalPointer == NULL) + if (internalPointer == 0) return QModelIndex(); Node * const node = reinterpret_cast(internalPointer); Prefix * const prefix = node->prefix(); - Q_ASSERT(prefix != NULL); + QTC_ASSERT(prefix, return QModelIndex()); bool const isFileNode = (prefix != node); if (isFileNode) { const int row = m_resource_file.prefixPointerIndex(prefix); - Q_ASSERT(row >= 0); + QTC_ASSERT(row >= 0, return QModelIndex()); return createIndex(row, 0, prefix); } else { return QModelIndex(); @@ -550,7 +553,7 @@ int ResourceModel::rowCount(const QModelIndex &parent) const void * const internalPointer = parent.internalPointer(); Node * const node = reinterpret_cast(internalPointer); Prefix * const prefix = node->prefix(); - Q_ASSERT(prefix != NULL); + QTC_ASSERT(prefix, return 0); bool const isFileNode = (prefix != node); if (isFileNode) { @@ -609,7 +612,7 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const Node * const node = reinterpret_cast(internalPointer); Prefix const * const prefix = node->prefix(); File const * const file = node->file(); - Q_ASSERT(prefix != NULL); + QTC_ASSERT(prefix, return QVariant()); bool const isFileNode = (prefix != node); QVariant result; @@ -622,14 +625,14 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const // Prefix node stringRes = prefix->name; const QString &lang = prefix->lang; - if(!lang.isEmpty()) + if (!lang.isEmpty()) appendParenthesized(lang, stringRes); } else { // File node - Q_ASSERT(file != NULL); + QTC_ASSERT(file, return result); stringRes = QFileInfo(file->name).fileName(); const QString alias = file->alias; - if(!alias.isEmpty()) + if (!alias.isEmpty()) appendParenthesized(alias, stringRes); } result = stringRes; @@ -638,7 +641,7 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const case Qt::DecorationRole: if (isFileNode) { // File node - Q_ASSERT(file != NULL); + QTC_ASSERT(file, return result); const QString path = m_resource_file.absolutePath(file->name); if (iconFileExtension(path)) { const QIcon icon(path); @@ -650,11 +653,11 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const case Qt::ToolTipRole: if (isFileNode) { // File node - Q_ASSERT(file != NULL); + QTC_ASSERT(file, return result); QString conv_file = m_resource_file.relativePath(file->name); QString stringRes = conv_file.replace(QDir::separator(), QLatin1Char('/')); const QString &alias_file = file->alias; - if(!alias_file.isEmpty()) + if (!alias_file.isEmpty()) appendParenthesized(alias_file, stringRes); result = stringRes; @@ -679,12 +682,12 @@ void ResourceModel::getItem(const QModelIndex &index, QString &prefix, QString & void * const internalPointer = index.internalPointer(); Node * const node = reinterpret_cast(internalPointer); Prefix * const p = node->prefix(); - Q_ASSERT(p != NULL); + QTC_ASSERT(p, return); bool const isFileNode = (p != node); if (isFileNode) { - File * const f = node->file(); - Q_ASSERT(f != NULL); + File *const f = node->file(); + QTC_ASSERT(f, return); if (!f->alias.isEmpty()) file = f->alias; else @@ -696,7 +699,7 @@ void ResourceModel::getItem(const QModelIndex &index, QString &prefix, QString & QString ResourceModel::lang(const QModelIndex &index) const { - if(!index.isValid()) + if (!index.isValid()) return QString(); return m_resource_file.lang(index.row()); @@ -704,14 +707,14 @@ QString ResourceModel::lang(const QModelIndex &index) const QString ResourceModel::alias(const QModelIndex &index) const { - if(!index.isValid() || !index.parent().isValid()) + if (!index.isValid() || !index.parent().isValid()) return QString(); return m_resource_file.alias(index.parent().row(), index.row()); } QString ResourceModel::file(const QModelIndex &index) const { - if(!index.isValid() || !index.parent().isValid()) + if (!index.isValid() || !index.parent().isValid()) return QString(); return m_resource_file.file(index.parent().row(), index.row()); } @@ -852,7 +855,7 @@ void ResourceModel::changePrefix(const QModelIndex &model_idx, const QString &pr if (m_resource_file.prefix(prefix_idx) == ResourceFile::fixPrefix(prefix)) return; - if(m_resource_file.contains(prefix)) + if (m_resource_file.contains(prefix)) return; m_resource_file.replacePrefix(prefix_idx, prefix); @@ -880,7 +883,7 @@ void ResourceModel::changeAlias(const QModelIndex &index, const QString &alias) if (!index.parent().isValid()) return; - if(m_resource_file.alias(index.parent().row(), index.row()) == alias) + if (m_resource_file.alias(index.parent().row(), index.row()) == alias) return; m_resource_file.replaceAlias(index.parent().row(), index.row(), alias); emit dataChanged(index, index); diff --git a/shared/qrceditor/resourcefile_p.h b/shared/qrceditor/resourcefile_p.h index 3276c2dec1e..6643be39aba 100644 --- a/shared/qrceditor/resourcefile_p.h +++ b/shared/qrceditor/resourcefile_p.h @@ -36,10 +36,12 @@ #include "namespace_global.h" +#include + +#include +#include #include #include -#include -#include #include "shared_global_p.h" @@ -66,11 +68,11 @@ class Node protected: Node(File *file, Prefix *prefix) : m_file(file), m_prefix(prefix) { - Q_ASSERT(m_prefix != NULL); + QTC_ASSERT(m_prefix, return); } public: - File * file() { return m_file; } - Prefix * prefix() { Q_ASSERT(m_prefix != NULL); return m_prefix; } + File *file() { return m_file; } + Prefix *prefix() { return m_prefix; } private: File *m_file; Prefix *m_prefix; diff --git a/shared/qrceditor/resourceview.cpp b/shared/qrceditor/resourceview.cpp index 27a0a5a4254..d0d3a9d11c5 100644 --- a/shared/qrceditor/resourceview.cpp +++ b/shared/qrceditor/resourceview.cpp @@ -32,16 +32,20 @@ ***************************************************************************/ #include "resourceview.h" + #include "undocommands_p.h" -#include -#include +#include + +#include + #include -#include #include -#include #include -#include +#include +#include +#include +#include #include namespace SharedTools { @@ -308,14 +312,14 @@ void ResourceView::findSamePlacePostDeletionModelIndex(int &row, QModelIndex &pa EntryBackup * ResourceView::removeEntry(const QModelIndex &index) { - Q_ASSERT(m_qrcModel != NULL); + QTC_ASSERT(m_qrcModel, return 0); return m_qrcModel->removeEntry(index); } void ResourceView::addFiles(int prefixIndex, const QStringList &fileNames, int cursorFile, int &firstFile, int &lastFile) { - Q_ASSERT(m_qrcModel != NULL); + QTC_ASSERT(m_qrcModel, return); m_qrcModel->addFiles(prefixIndex, fileNames, cursorFile, firstFile, lastFile); // Expand prefix node @@ -327,11 +331,11 @@ void ResourceView::addFiles(int prefixIndex, const QStringList &fileNames, int c void ResourceView::removeFiles(int prefixIndex, int firstFileIndex, int lastFileIndex) { - Q_ASSERT((prefixIndex >= 0) && (prefixIndex < m_qrcModel->rowCount(QModelIndex()))); + QTC_ASSERT(prefixIndex >= 0 && prefixIndex < m_qrcModel->rowCount(QModelIndex()), return); const QModelIndex prefixModelIndex = m_qrcModel->index(prefixIndex, 0, QModelIndex()); - Q_ASSERT(prefixModelIndex != QModelIndex()); - Q_ASSERT((firstFileIndex >= 0) && (firstFileIndex < m_qrcModel->rowCount(prefixModelIndex))); - Q_ASSERT((lastFileIndex >= 0) && (lastFileIndex < m_qrcModel->rowCount(prefixModelIndex))); + QTC_ASSERT(prefixModelIndex != QModelIndex(), return); + QTC_ASSERT(firstFileIndex >= 0 && firstFileIndex < m_qrcModel->rowCount(prefixModelIndex), return); + QTC_ASSERT(lastFileIndex >= 0 && lastFileIndex < m_qrcModel->rowCount(prefixModelIndex), return); for (int i = lastFileIndex; i >= firstFileIndex; i--) { const QModelIndex index = m_qrcModel->index(i, 0, prefixModelIndex); @@ -476,7 +480,7 @@ bool ResourceView::load(QString fileName) const QFileInfo fi(fileName); m_qrcModel->setFileName(fi.absoluteFilePath()); - if(!fi.exists()) + if (!fi.exists()) return false; const bool result = m_qrcModel->reload(); @@ -501,9 +505,8 @@ void ResourceView::changePrefix(const QModelIndex &index) QString const prefixAfter = QInputDialog::getText(this, tr("Change Prefix"), tr("Input Prefix:"), QLineEdit::Normal, prefixBefore, &ok); - if (ok) { + if (ok) addUndoCommand(preindex, PrefixProperty, prefixBefore, prefixAfter); - } } void ResourceView::changeLang(const QModelIndex &index) @@ -522,7 +525,7 @@ void ResourceView::changeLang(const QModelIndex &index) void ResourceView::changeAlias(const QModelIndex &index) { - if(!index.parent().isValid()) + if (!index.parent().isValid()) return; bool ok = false; @@ -531,9 +534,8 @@ void ResourceView::changeAlias(const QModelIndex &index) QString const aliasAfter = QInputDialog::getText(this, tr("Change File Alias"), tr("Alias:"), QLineEdit::Normal, aliasBefore, &ok); - if (ok) { + if (ok) addUndoCommand(index, AliasProperty, aliasBefore, aliasAfter); - } } QString ResourceView::currentAlias() const @@ -570,7 +572,7 @@ QString ResourceView::getCurrentValue(NodeProperty property) const case AliasProperty: return currentAlias(); case PrefixProperty: return currentPrefix(); case LanguageProperty: return currentLanguage(); - default: Q_ASSERT(false); return QString(); // Kill warning + default: QTC_ASSERT(false, /**/); return QString(); // Kill warning } } @@ -581,19 +583,20 @@ void ResourceView::changeValue(const QModelIndex &nodeIndex, NodeProperty proper case AliasProperty: m_qrcModel->changeAlias(nodeIndex, value); return; case PrefixProperty: m_qrcModel->changePrefix(nodeIndex, value); return; case LanguageProperty: m_qrcModel->changeLang(nodeIndex, value); return; - default: Q_ASSERT(false); + default: QTC_ASSERT(false, /**/); } } -void ResourceView::advanceMergeId() { +void ResourceView::advanceMergeId() +{ m_mergeId++; - if (m_mergeId < 0) { + if (m_mergeId < 0) m_mergeId = 0; - } } void ResourceView::addUndoCommand(const QModelIndex &nodeIndex, NodeProperty property, - const QString &before, const QString &after) { + const QString &before, const QString &after) +{ QUndoCommand * const command = new ModifyPropertyCommand(this, nodeIndex, property, m_mergeId, before, after); m_history->push(command); diff --git a/shared/qrceditor/undocommands.cpp b/shared/qrceditor/undocommands.cpp index 6b549326d58..246b69c0d71 100644 --- a/shared/qrceditor/undocommands.cpp +++ b/shared/qrceditor/undocommands.cpp @@ -92,7 +92,7 @@ bool ModifyPropertyCommand::mergeWith(const QUndoCommand * command) { const ModifyPropertyCommand * const brother = dynamic_cast(command); - if (command == NULL || m_property != brother->m_property) + if (command == 0 || m_property != brother->m_property) return false; // Choose older command (this) and forgot the other @@ -101,7 +101,7 @@ bool ModifyPropertyCommand::mergeWith(const QUndoCommand * command) void ModifyPropertyCommand::undo() { - Q_ASSERT(m_view != NULL); + QTC_ASSERT(m_view, return); // Save current text in m_after for redo() m_after = m_view->getCurrentValue(m_property); @@ -117,12 +117,12 @@ void ModifyPropertyCommand::redo() return; // Bring back text before undo - Q_ASSERT(m_view != NULL); + QTC_ASSERT(m_view, return); m_view->changeValue(makeIndex(), m_property, m_after); } RemoveEntryCommand::RemoveEntryCommand(ResourceView *view, const QModelIndex &index) - : ModelIndexViewCommand(view), m_entry(NULL), m_isExpanded(true) + : ModelIndexViewCommand(view), m_entry(0), m_isExpanded(true) { storeIndex(index); } @@ -142,9 +142,9 @@ void RemoveEntryCommand::redo() void RemoveEntryCommand::undo() { - if (m_entry != NULL) { + if (m_entry == 0) { m_entry->restore(); - Q_ASSERT(m_view != NULL); + QTC_ASSERT(m_view != 0, return); const QModelIndex index = makeIndex(); m_view->setExpanded(index, m_isExpanded); m_view->setCurrentIndex(index); @@ -155,7 +155,7 @@ void RemoveEntryCommand::undo() void RemoveEntryCommand::freeEntry() { delete m_entry; - m_entry = NULL; + m_entry = 0; } AddFilesCommand::AddFilesCommand(ResourceView *view, int prefixIndex, int cursorFileIndex, diff --git a/shared/qtsingleapplication/qtlocalpeer.cpp b/shared/qtsingleapplication/qtlocalpeer.cpp index f488e72134b..1e324106ad0 100644 --- a/shared/qtsingleapplication/qtlocalpeer.cpp +++ b/shared/qtsingleapplication/qtlocalpeer.cpp @@ -50,9 +50,9 @@ static PProcessIdToSessionId pProcessIdToSessionId = 0; namespace SharedTools { -const char* QtLocalPeer::ack = "ack"; +const char *QtLocalPeer::ack = "ack"; -QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) +QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId) : QObject(parent), id(appId) { if (id.isEmpty()) @@ -86,8 +86,6 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) lockFile.open(QIODevice::ReadWrite); } - - bool QtLocalPeer::isClient() { if (lockFile.isLocked()) @@ -105,7 +103,6 @@ bool QtLocalPeer::isClient() return false; } - bool QtLocalPeer::sendMessage(const QString &message, int timeout) { if (!isClient()) @@ -113,7 +110,7 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout) QLocalSocket socket; bool connOk = false; - for(int i = 0; i < 2; i++) { + for (int i = 0; i < 2; i++) { // Try twice, in case the other instance is just starting up socket.connectToServer(socketName); connOk = socket.waitForConnected(timeout/2); @@ -139,7 +136,6 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout) return res; } - void QtLocalPeer::receiveConnection() { QLocalSocket* socket = server->nextPendingConnection(); diff --git a/shared/scriptwrapper/wrap_helpers.h b/shared/scriptwrapper/wrap_helpers.h index 21ed625c161..02db144a3e5 100644 --- a/shared/scriptwrapper/wrap_helpers.h +++ b/shared/scriptwrapper/wrap_helpers.h @@ -34,6 +34,8 @@ #ifndef WRAP_HELPERS_H #define WRAP_HELPERS_H +#include + #include #include #include @@ -87,7 +89,7 @@ template Wrapped * (Wrapper::*wrappedAccessor) () const) { Wrapped *wrapped = wrappedFromScriptValue(context->thisObject(), wrappedAccessor); - Q_ASSERT(wrapped); + QTC_ASSERT(wrapped, return 0); return wrapped; } @@ -314,7 +316,7 @@ static void scriptValueToQObject(const QScriptValue &sv, SomeQObject * &p) { QObject *qObject = sv.toQObject(); p = qobject_cast(qObject); - Q_ASSERT(p); + QTC_ASSERT(p, return); } // Register a QObject-derived class which has Q_DECLARE_METATYPE(Ptr*) diff --git a/src/app/main.cpp b/src/app/main.cpp index 68dfa3e3b23..ad61ab0c750 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -212,9 +212,9 @@ int main(int argc, char **argv) pluginManager.setPluginPaths(pluginPaths); const QStringList arguments = app.arguments(); - QMap foundAppOptions; + QMap foundAppOptions; if (arguments.size() > 1) { - QMap appOptions; + QMap appOptions; appOptions.insert(QLatin1String(HELP_OPTION1), false); appOptions.insert(QLatin1String(HELP_OPTION2), false); appOptions.insert(QLatin1String(HELP_OPTION3), false); diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 3a280416d9b..3e619548a23 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -32,6 +32,9 @@ ***************************************************************************/ #include "CppDocument.h" + +#include + #include #include #include @@ -138,24 +141,14 @@ void Document::addIncludeFile(const QString &fileName) _includedFiles.append(fileName); } -QByteArray Document::definedMacros() const +void Document::appendMacro(const Macro ¯o) { - return _definedMacros; + _definedMacros.append(macro); } -void Document::appendMacro(const QByteArray ¯oName, const QByteArray &text) +void Document::addMacroUse(const Macro ¯o, unsigned offset, unsigned length) { - int index = macroName.indexOf('('); - if (index == -1) - _macroNames.insert(macroName); - else - _macroNames.insert(macroName.left(index)); - _definedMacros += text; -} - -void Document::addMacroUse(unsigned offset, unsigned length) -{ - _macroUses.append(Block(offset, offset + length)); + _macroUses.append(MacroUse(macro, offset, offset + length)); } TranslationUnit *Document::translationUnit() const @@ -251,11 +244,6 @@ void Document::stopSkippingBlocks(unsigned stop) _skippedBlocks.back() = Block(start, stop); } -QSet Document::macroNames() const -{ - return _macroNames; -} - bool Document::parse(ParseMode mode) { TranslationUnit::ParseMode m = TranslationUnit::ParseTranlationUnit; @@ -285,7 +273,7 @@ bool Document::parse(ParseMode mode) void Document::check() { - Q_ASSERT(! _globalNamespace); + QTC_ASSERT(!_globalNamespace, return); Semantic semantic(_control); diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h index e952913a07b..aaca36c18ee 100644 --- a/src/libs/cplusplus/CppDocument.h +++ b/src/libs/cplusplus/CppDocument.h @@ -36,6 +36,8 @@ #include +#include "pp-macro.h" + #include #include #include @@ -45,6 +47,8 @@ namespace CPlusPlus { +class Macro; + class CPLUSPLUS_EXPORT Document { Document(const Document &other); @@ -63,12 +67,8 @@ public: QStringList includedFiles() const; void addIncludeFile(const QString &fileName); - QByteArray definedMacros() const; - QSet macroNames() const; - - void appendMacro(const QByteArray ¯oName, const QByteArray &text); - - void addMacroUse(unsigned offset, unsigned length); + void appendMacro(const Macro ¯o); + void addMacroUse(const Macro ¯o, unsigned offset, unsigned length); Control *control() const; TranslationUnit *translationUnit() const; @@ -81,6 +81,9 @@ public: Scope *globalSymbols() const; // ### deprecate? Namespace *globalNamespace() const; + QList definedMacros() const + { return _definedMacros; } + Symbol *findSymbolAt(unsigned line, unsigned column) const; void setSource(const QByteArray &source); @@ -173,12 +176,30 @@ public: inline unsigned end() const { return _end; } + + bool contains(unsigned pos) const + { return pos >= _begin && pos < _end; } + }; + + class MacroUse: public Block { + Macro _macro; + + public: + inline MacroUse(const Macro ¯o, + unsigned begin = 0, + unsigned end = 0) + : Block(begin, end), + _macro(macro) + { } + + const Macro ¯o() const + { return _macro; } }; QList skippedBlocks() const { return _skippedBlocks; } - QList macroUses() const + QList macroUses() const { return _macroUses; } private: @@ -191,10 +212,9 @@ private: TranslationUnit *_translationUnit; Namespace *_globalNamespace; QList _diagnosticMessages; - QByteArray _definedMacros; - QSet _macroNames; + QList _definedMacros; QList _skippedBlocks; - QList _macroUses; + QList _macroUses; }; } // end of namespace CPlusPlus diff --git a/src/libs/cplusplus/Icons.cpp b/src/libs/cplusplus/Icons.cpp index 94b6469ea46..3b7ee24da3c 100644 --- a/src/libs/cplusplus/Icons.cpp +++ b/src/libs/cplusplus/Icons.cpp @@ -61,11 +61,11 @@ Icons::Icons() { } -QIcon Icons::iconForSymbol(Symbol *symbol) const +QIcon Icons::iconForSymbol(const Symbol *symbol) const { if (symbol->isFunction() || (symbol->isDeclaration() && symbol->type()->isFunction())) { - Function *function = symbol->asFunction(); + const Function *function = symbol->asFunction(); if (!function) function = symbol->type()->asFunction(); diff --git a/src/libs/cplusplus/Icons.h b/src/libs/cplusplus/Icons.h index c49bcde12d1..6d4e0bb25d6 100644 --- a/src/libs/cplusplus/Icons.h +++ b/src/libs/cplusplus/Icons.h @@ -47,7 +47,7 @@ class CPLUSPLUS_EXPORT Icons public: Icons(); - QIcon iconForSymbol(Symbol *symbol) const; + QIcon iconForSymbol(const Symbol *symbol) const; QIcon keywordIcon() const; QIcon macroIcon() const; diff --git a/src/libs/cplusplus/OverviewModel.cpp b/src/libs/cplusplus/OverviewModel.cpp index 38456d8fa7d..7f38cb8ba1a 100644 --- a/src/libs/cplusplus/OverviewModel.cpp +++ b/src/libs/cplusplus/OverviewModel.cpp @@ -34,6 +34,8 @@ #include "OverviewModel.h" #include "Overview.h" +#include + #include #include #include @@ -74,20 +76,20 @@ Symbol *OverviewModel::globalSymbolAt(unsigned index) const QModelIndex OverviewModel::index(int row, int column, const QModelIndex &parent) const { - if (! hasDocument()) { - return QModelIndex(); - } else if (! parent.isValid()) { - Symbol *symbol = globalSymbolAt(row); + if (!parent.isValid()) { + if (row == 0) // account for no symbol item + return createIndex(row, column); + Symbol *symbol = globalSymbolAt(row-1); // account for no symbol item return createIndex(row, column, symbol); } else { Symbol *parentSymbol = static_cast(parent.internalPointer()); - Q_ASSERT(parentSymbol != 0); + QTC_ASSERT(parentSymbol, return QModelIndex()); ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol(); - Q_ASSERT(scopedSymbol != 0); + QTC_ASSERT(scopedSymbol, return QModelIndex()); Scope *scope = scopedSymbol->members(); - Q_ASSERT(scope != 0); + QTC_ASSERT(scope, return QModelIndex()); return createIndex(row, 0, scope->symbolAt(row)); } @@ -96,12 +98,20 @@ QModelIndex OverviewModel::index(int row, int column, const QModelIndex &parent) QModelIndex OverviewModel::parent(const QModelIndex &child) const { Symbol *symbol = static_cast(child.internalPointer()); - Q_ASSERT(symbol != 0); + if (!symbol) // account for no symbol item + return QModelIndex(); if (Scope *scope = symbol->scope()) { Symbol *parentSymbol = scope->owner(); - if (parentSymbol && parentSymbol->scope()) - return createIndex(parentSymbol->index(), 0, parentSymbol); + if (parentSymbol && parentSymbol->scope()) { + QModelIndex index; + if (parentSymbol->scope() && parentSymbol->scope()->owner() + && parentSymbol->scope()->owner()->scope()) // the parent doesn't have a parent + index = createIndex(parentSymbol->index(), 0, parentSymbol); + else //+1 to account for no symbol item + index = createIndex(parentSymbol->index() + 1, 0, parentSymbol); + return index; + } } return QModelIndex(); @@ -110,22 +120,27 @@ QModelIndex OverviewModel::parent(const QModelIndex &child) const int OverviewModel::rowCount(const QModelIndex &parent) const { if (hasDocument()) { - if (! parent.isValid()) { - return globalSymbolCount(); + if (!parent.isValid()) { + return globalSymbolCount()+1; // account for no symbol item } else { + if (!parent.parent().isValid() && parent.row() == 0) // account for no symbol item + return 0; Symbol *parentSymbol = static_cast(parent.internalPointer()); - Q_ASSERT(parentSymbol != 0); + QTC_ASSERT(parentSymbol, return 0); if (ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol()) { - if (! scopedSymbol->isFunction()) { + if (!scopedSymbol->isFunction()) { Scope *parentScope = scopedSymbol->members(); - Q_ASSERT(parentScope != 0); + QTC_ASSERT(parentScope, return 0); return parentScope->symbolCount(); } } + return 0; } } + if (!parent.isValid()) + return 1; // account for no symbol item return 0; } @@ -136,6 +151,19 @@ int OverviewModel::columnCount(const QModelIndex &) const QVariant OverviewModel::data(const QModelIndex &index, int role) const { + // account for no symbol item + if (!index.parent().isValid() && index.row() == 0) { + switch (role) { + case Qt::DisplayRole: + if (rowCount() > 1) + return tr("