diff --git a/dist/changes-3.2.0 b/dist/changes-3.2.0 index 3a67b9aab71..4f78fe3a9a3 100644 --- a/dist/changes-3.2.0 +++ b/dist/changes-3.2.0 @@ -5,21 +5,54 @@ list of changes, see the Git log for the Qt Creator sources that you can check out from the public Git repository. For example: git clone git://gitorious.org/qt-creator/qt-creator.git -git log --cherry-pick --pretty=oneline origin/3.1..origin/master +git log --cherry-pick --pretty=oneline origin/3.1..origin/3.2 General * Added "Get Help Online" context menu item to issues pane that searches for the issue description online in Google * Added action to file system locator filter ('f') for creating and opening a new file * Added search capability to general messages and most navigation panes + * Added display of current variable values in variable chooser dialog + * Added variable %{Env:...} for accessing environment variables + (where variables can be used) * Enabled resizing of the locator field * Improved look and feel on HiDPI by adding more hi-resolution icons + * Made New dialog non-modal (QTCREATORBUG-6102) * Made keyboard and mouse activation of navigation panes and other trees more consistent - * Added display of current variable values in variable chooser dialog * Removed unhelpful Generic Highlighter loading progress bar + * Fixed case-sensitivity of file system locator filter (QTCREATORBUG-10843) Editing + * Made Ctrl+Up and Ctrl+Down shortcuts configurable (QTCREATORBUG-4994) + * Made editor popup (Ctrl+Tab) adapt its size to contents (QTCREATORBUG-10618) + * Improved block editing (QTCREATORBUG-7773) * Fixed support for mixed languages in the generic highlighter + * Fixed title when printing (QTCREATORBUG-12161) + * Fixed that line number background color setting was ignored + (QTCREATORBUG-12170) + * Fixed that tooltips were shown when hovering over empty area + (QTCREATORBUG-9437) + * Fixed that tooltips were shown after triggering shortcut with + Alt key (QTCREATORBUG-12382) + * Fixed scroll behavior when editing same file in multiple splits + (QTCREATORBUG-11486) + * Fixed Open With when file is open in multiple splits + * Fixed that search highlights were removed when switching editors + (QTCREATORBUG-9949) + +Help + * Added page up and page down shortcuts to topic chooser + * Added button for regenerating documentation index to Search pane + (QTCREATORBUG-11484) + * Changed documentation of examples to open in an external window + * Fixed that opening help in external window was not possible without + disabling help mode + * Fixed issue with F1 in help viewer showing 'No document' instead of opening + Help mode + * Fixed that context help was not showing latest Qt 5 documentation + (QTCREATORBUG-10331) + * Fixed reverted check state of Show Sidebar menu item + * Fixed selection behavior in documentation settings (QTCREATORBUG-12135) Managing and Building Projects @@ -27,11 +60,18 @@ QMake Projects * Added context menu item for copying resource path from entries in QRC files in project tree (QTCREATORBUG-11776) * Added deployment support to plain C and C++ application wizards + * Added support for restricting automatic creation of run configurations + (QTCREATORBUG-10953) + * Added Show in Explorer context menu item for qrc nodes and their subnodes + in project tree (QTCREATORBUG-12374) + * Improved dropdown menu for selecting the project file when using wizard + to add files (QTCREATORBUG-12002) * Removed warning about build directory below source directory for kits with Qt 5.2 and later where this is supported (QTCREATORBUG-10024) * Fixed that adding files to .pri file was missing $$PWD Qbs Projects + * Added support for adding and removing files from projects * Fixed that run configurations were created for products that are not runnable (QTCREATORBUG-12152) * Fixed that run configurations were created for disabled products (QBS-560) @@ -79,22 +119,48 @@ Debugging * Fixed debugging applications that are run in a terminal on Linux (QTCREATORBUG-3509) QML Profiler + * Improved performance (QTCREATORBUG-12341) + * Fixed drawing issues (QTBUG-38222) + * Fixed that clicking visible event was sometimes moving timeline + (QTCREATORBUG-11945) Analyzer * Added support for Run in Terminal (QTCREATORBUG-7311) + * Fixed passing of multiple arguments to application C++ Support + * Added support for C99 designated initializers (QTCREATORBUG-1902) * Fixed finding usages of members of typedef'ed anonymous structs (QTCREATORBUG-11859, QTCREATORBUG-11860) * Fixed indentation of concatenated strings * Fixed pointer typedef resolving (QTCREATORBUG-10021) * Fixed scroll wheel behavior in editor's symbols dropdown + * Fixed encoding issues (QTCREATORBUG-7356) + * Fixed that some wizards were ignoring configured file extensions + (QTCREATORBUG-12309) + * Fixed parsing of trailing type-specifier + * Fixed parsing of expressions like vector{1} + * Fixed generating getters and setters for variables with + 'm' and 'm_' prefixes QML Support + * Fixed handling of properties that start with underscore (QTCREATORBUG-12214) Qt Quick Designer + * Changed puppet helper executable to be compiled on demand + * Added support for reloading states editor + * Improved gradient editor + * Fixed minimum and maximum sizes for Window component (QTCREATORBUG-12209) + * Fixed wrong password mode property on text fields + * Fixed that it was not possible to anchor to all possible targets + (QTCREATORBUG-12077) + * Fixed possible values for preferred highlight properties + (QTCREATORBUG-12216) + * Fixed setting empty text on Label and Text items (QTCREATORBUG-12119) + * Fixed property sections for TextEdit (QTCREATORBUG-12452) Diff Viewer + * Reworked unified diff mode Version Control Systems * Git @@ -122,6 +188,7 @@ Windows * Fixed detection of MSVC tool chains (QTCREATORBUG-10998) OS X + * Removed support for OS X 10.6 * Fixed activation of items with Enter in Bookmarks pane Android @@ -131,13 +198,68 @@ Remote Linux * Added custom remote executable run configuration type (QTCREATORBUG-12168) * Fixed issue with environment variables that contain spaces -BareMetal: +QNX + * Added option to deploy Qt libraries to device options + +BareMetal * Added openocd pipelining support * Added variable support for device specific GDB commands -Valgrind: - * Fixed passing of multiple arguments to application - - Credits for these changes go to: +Adam Strzelecki +Alessandro Portale +André Pönitz +Andrew Knight +Anton Kalmykov +Benjamin Zeller +Campbell Barton +Christian Kamm +Christian Kandeler +Christian Stenger +Daniel Teske +David Kaspar +David Schulz +Eike Ziller +El Mehdi Fekari +Erik Verbruggen +Evgenly Stepanov +Fawzi Mohamed +Frantisek Vacek +Friedemann Kleint +Hugues Delorme +Jaroslaw Kobus +Jerome Pasion +Jörg Bornemann +Kai Köhne +Karsten Heimrich +Knut Petter Svendsen +Leena Miettinen +Lorenz Haas +Lukas Holecek +Marco Bubke +Mitch Curtis +Niels Weber +Nikita Baryshnikov +Nikolai Kosjar +Oliver Wolff +Orgad Shaneh +Oswald Buddenhagen +Przemyslaw Gorszkowski +Rainer Keller +Robert Löhning +Sergey Shambir +Stephen Kelly +Sveinung Kvilhaugsvik +Thiago Macieira +Thomas Epting +Thomas Hartmann +Tim Jenssen +Tim Sander +Tobias Hunger +Tobias Nätterlund +Tom Deblauwe +Ulf Hermann +Vicken Simonian +Wang Hoi +Wiebe Cazemier diff --git a/qtcreator.pri b/qtcreator.pri index 1c893c11cea..5ba38a7f9f8 100644 --- a/qtcreator.pri +++ b/qtcreator.pri @@ -1,8 +1,8 @@ !isEmpty(QTCREATOR_PRI_INCLUDED):error("qtcreator.pri already included") QTCREATOR_PRI_INCLUDED = 1 -QTCREATOR_VERSION = 3.1.82 -QTCREATOR_COMPAT_VERSION = 3.1.82 +QTCREATOR_VERSION = 3.1.83 +QTCREATOR_COMPAT_VERSION = 3.1.83 BINARY_ARTIFACTS_BRANCH = master # enable c++11 diff --git a/qtcreator.qbs b/qtcreator.qbs index 512c5671540..34be1f66c3b 100644 --- a/qtcreator.qbs +++ b/qtcreator.qbs @@ -4,11 +4,11 @@ Project { property bool withAutotests: qbs.buildVariant === "debug" property string ide_version_major: '3' property string ide_version_minor: '1' - property string ide_version_release: '82' + property string ide_version_release: '83' property string qtcreator_version: ide_version_major + '.' + ide_version_minor + '.' + ide_version_release property string ide_compat_version_major: '3' property string ide_compat_version_minor: '1' - property string ide_compat_version_release: '82' + property string ide_compat_version_release: '83' property string qtcreator_compat_version: ide_compat_version_major + '.' + ide_compat_version_minor + '.' + ide_compat_version_release property path ide_source_tree: path property string ide_app_path: qbs.targetOS.contains("osx") ? "" : "bin" diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index 9b9c4308b95..c610acb3713 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -600,9 +600,11 @@ class DumperBase: else: val = str(value.GetValue()) if self.isLldb else str(value) if index == -1: - self.put('name="%s",' % val) + key = 'key="%s",' % val else: - self.put('key="[%d] %s",' % (index, val)) + key = 'key="[%d] %s",' % (index, val) + self.put('key="%s",' % self.hexencode(key)) + self.put('keyencoded="%s",' % Hex2EncodedLatin1) def putPair(self, pair, index = -1): if self.pairData.useKeyAndValue: @@ -1500,20 +1502,15 @@ class DumperBase: self.put('iname="%s",' % iname) self.put('name="%s",' % exp) self.put('wname="%s",' % escapedExp) - if len(exp) == 0: # The case - self.putValue(" ") - self.putNoType() + try: + value = self.parseAndEvaluate(exp) + self.putItem(value) + except RuntimeError: + self.currentType.value = " " + self.currentValue.value = "" + self.currentChildNumChild = -1 + self.currentNumChild = 0 self.putNumChild(0) - else: - try: - value = self.parseAndEvaluate(exp) - self.putItem(value) - except RuntimeError: - self.currentType.value = " " - self.currentValue.value = "" - self.currentChildNumChild = -1 - self.currentNumChild = 0 - self.putNumChild(0) # Some "Enums" diff --git a/share/qtcreator/debugger/qttypes.py b/share/qtcreator/debugger/qttypes.py index b950db94171..b110e50cfb8 100644 --- a/share/qtcreator/debugger/qttypes.py +++ b/share/qtcreator/debugger/qttypes.py @@ -638,6 +638,9 @@ def qdump__QHash(d, value): d.putItem(it) +def qform__QHashNode(): + return mapForms() + def qdump__QHashNode(d, value): key = value["key"] if not key: @@ -645,12 +648,17 @@ def qdump__QHashNode(d, value): # for Qt4 optimized int keytype key = value[1]["key"] val = value["value"] - d.putEmptyValue() - d.putNumChild(2) - if d.isExpanded(): - with Children(d): - d.putSubItem("key", key) - d.putSubItem("value", val) + if d.isMapCompact(key.type, val.type): + d.putMapName(key) + d.putItem(val) + d.putType(value.type) + else: + d.putEmptyValue() + d.putNumChild(2) + if d.isExpanded(): + with Children(d): + d.putSubItem("key", key) + d.putSubItem("value", val) def qHashIteratorHelper(d, value): diff --git a/src/app/app.pro b/src/app/app.pro index b7430651e74..249960f125d 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -2,6 +2,7 @@ include(../../qtcreator.pri) include(../shared/qtsingleapplication/qtsingleapplication.pri) TEMPLATE = app +CONFIG += qtc_runnable TARGET = $$IDE_APP_TARGET DESTDIR = $$IDE_APP_PATH diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index aae1b25ff10..c90fdb005d7 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -1158,11 +1158,13 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac } } else { SubstitutionMap map; - for (unsigned i = 0; - i < argumentCountOfSpecialization && i < argumentCountOfInitialization; - ++i) { - map.bind(templateSpecialization->templateParameterAt(i)->name(), - templId->templateArgumentAt(i)); + for (unsigned i = 0; i < argumentCountOfSpecialization; ++i) { + const Name *name = templateSpecialization->templateParameterAt(i)->name(); + FullySpecifiedType ty = (i < argumentCountOfInitialization) ? + templId->templateArgumentAt(i): + templateSpecialization->templateParameterAt(i)->type(); + + map.bind(name, ty); } SubstitutionEnvironment env; env.enter(&map); diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp index f3e0eb5fe53..efa966ba3c6 100644 --- a/src/libs/qmljs/qmljsdocument.cpp +++ b/src/libs/qmljs/qmljsdocument.cpp @@ -564,7 +564,7 @@ void Snapshot::insertLibraryInfo(const QString &path, const LibraryInfo &info) if (vNr.indexIn(myPath.last()) == 0) { myPath.last() = vNr.cap(1); } - for (int iPath = myPath.size(); iPath != 0; ) { + for (int iPath = myPath.size(); iPath != 1; ) { --iPath; if (safeName.indexIn(myPath.at(iPath)) != 0) break; @@ -595,7 +595,7 @@ void Snapshot::insertLibraryInfo(const QString &path, const LibraryInfo &info) minorVersion = LanguageUtils::ComponentVersion::NoVersion; } - for (int iPath = splitPath.size(); iPath != 0; ) { + for (int iPath = splitPath.size(); iPath != 1; ) { --iPath; if (safeName.indexIn(splitPath.at(iPath)) != 0) break; diff --git a/src/libs/utils/fancylineedit.cpp b/src/libs/utils/fancylineedit.cpp index 7dfb82bda7c..51415c903b5 100644 --- a/src/libs/utils/fancylineedit.cpp +++ b/src/libs/utils/fancylineedit.cpp @@ -299,8 +299,20 @@ bool FancyLineEdit::hasAutoHideButton(Side side) const void FancyLineEdit::setHistoryCompleter(const QString &historyKey) { QTC_ASSERT(!d->m_historyCompleter, return); - d->m_historyCompleter = new HistoryCompleter(this, historyKey, this); + d->m_historyCompleter = new HistoryCompleter(historyKey, this); QLineEdit::setCompleter(d->m_historyCompleter); + + // Hitting in the popup first causes editingFinished() + // being emitted and more updates finally calling setText() (again). + // To make sure we report the "final" content delay the addEntry() + // "a bit". + connect(this, SIGNAL(editingFinished()), + this, SLOT(onEditingFinished()), Qt::QueuedConnection); +} + +void FancyLineEdit::onEditingFinished() +{ + d->m_historyCompleter->addEntry(text()); } void FancyLineEdit::setSpecialCompleter(QCompleter *completer) diff --git a/src/libs/utils/fancylineedit.h b/src/libs/utils/fancylineedit.h index 2b533c2575e..27be6898319 100644 --- a/src/libs/utils/fancylineedit.h +++ b/src/libs/utils/fancylineedit.h @@ -162,6 +162,7 @@ signals: private slots: void iconClicked(); void onTextChanged(const QString &); + void onEditingFinished(); protected: void resizeEvent(QResizeEvent *e); diff --git a/src/libs/utils/historycompleter.cpp b/src/libs/utils/historycompleter.cpp index 687a2b5b07e..f51855b2a73 100644 --- a/src/libs/utils/historycompleter.cpp +++ b/src/libs/utils/historycompleter.cpp @@ -47,19 +47,18 @@ static QSettings *theSettings = 0; class HistoryCompleterPrivate : public QAbstractListModel { public: - HistoryCompleterPrivate() : maxLines(30), lineEdit(0) {} + HistoryCompleterPrivate() : maxLines(30) {} int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); void clearHistory(); - void saveEntry(const QString &str); + void addEntry(const QString &str); QStringList list; QString historyKey; int maxLines; - FancyLineEdit *lineEdit; }; class HistoryLineDelegate : public QItemDelegate @@ -146,38 +145,33 @@ void HistoryCompleterPrivate::clearHistory() endResetModel(); } -void HistoryCompleterPrivate::saveEntry(const QString &str) +void HistoryCompleterPrivate::addEntry(const QString &str) { - QTC_ASSERT(theSettings, return); - const QString &entry = str.trimmed(); + const QString entry = str.trimmed(); + if (entry.isEmpty()) + return; int removeIndex = list.indexOf(entry); + beginResetModel(); if (removeIndex != -1) - removeRow(removeIndex); - beginInsertRows (QModelIndex(), list.count(), list.count()); + list.removeAt(removeIndex); list.prepend(entry); - list = list.mid(0, maxLines); - endInsertRows(); + list = list.mid(0, maxLines - 1); + endResetModel(); theSettings->setValue(historyKey, list); } -HistoryCompleter::HistoryCompleter(FancyLineEdit *lineEdit, const QString &historyKey, QObject *parent) +HistoryCompleter::HistoryCompleter(const QString &historyKey, QObject *parent) : QCompleter(parent), d(new HistoryCompleterPrivate) { - QTC_ASSERT(lineEdit, return); QTC_ASSERT(!historyKey.isEmpty(), return); QTC_ASSERT(theSettings, return); d->historyKey = QLatin1String("CompleterHistory/") + historyKey; d->list = theSettings->value(d->historyKey).toStringList(); - d->lineEdit = lineEdit; - if (d->list.count() && lineEdit->text().isEmpty()) - lineEdit->setText(d->list.at(0)); setModel(d); setPopup(new HistoryLineView(d)); - - connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(saveHistory())); } bool HistoryCompleter::removeHistoryItem(int index) @@ -210,9 +204,9 @@ void HistoryCompleter::clearHistory() d->clearHistory(); } -void HistoryCompleter::saveHistory() +void HistoryCompleter::addEntry(const QString &str) { - d->saveEntry(d->lineEdit->text()); + d->addEntry(str); } void HistoryCompleter::setSettings(QSettings *settings) diff --git a/src/libs/utils/historycompleter.h b/src/libs/utils/historycompleter.h index 41cb01cb3f6..cb55806eb10 100644 --- a/src/libs/utils/historycompleter.h +++ b/src/libs/utils/historycompleter.h @@ -40,7 +40,6 @@ QT_END_NAMESPACE namespace Utils { -class FancyLineEdit; namespace Internal { class HistoryCompleterPrivate; } class QTCREATOR_UTILS_EXPORT HistoryCompleter : public QCompleter @@ -49,7 +48,7 @@ class QTCREATOR_UTILS_EXPORT HistoryCompleter : public QCompleter public: static void setSettings(QSettings *settings); - HistoryCompleter(FancyLineEdit *lineEdit, const QString &historyKey, QObject *parent = 0); + HistoryCompleter(const QString &historyKey, QObject *parent = 0); bool removeHistoryItem(int index); private: @@ -60,7 +59,7 @@ private: public Q_SLOTS: void clearHistory(); - void saveHistory(); + void addEntry(const QString &str); private: Internal::HistoryCompleterPrivate *d; diff --git a/src/plugins/bookmarks/bookmark.cpp b/src/plugins/bookmarks/bookmark.cpp index 7c444a6e549..666b146d733 100644 --- a/src/plugins/bookmarks/bookmark.cpp +++ b/src/plugins/bookmarks/bookmark.cpp @@ -31,18 +31,15 @@ #include "bookmarkmanager.h" #include +#include #include using namespace Bookmarks::Internal; Bookmark::Bookmark(const QString& fileName, int lineNumber, BookmarkManager *manager) : BaseTextMark(fileName, lineNumber), - m_manager(manager), - m_fileName(fileName) + m_manager(manager) { - QFileInfo fi(fileName); - m_onlyFile = fi.fileName(); - m_path = fi.path(); setPriority(TextEditor::ITextMark::NormalPriority); setIcon(m_manager->bookmarkIcon()); } @@ -70,12 +67,8 @@ void Bookmark::updateBlock(const QTextBlock &block) void Bookmark::updateFileName(const QString &fileName) { - m_fileName = fileName; - QFileInfo fi(fileName); - m_onlyFile = fi.fileName(); - m_path = fi.path(); - m_manager->updateBookmark(this); BaseTextMark::updateFileName(fileName); + m_manager->updateBookmark(this); } void Bookmark::setNote(const QString ¬e) @@ -98,18 +91,3 @@ QString Bookmark::note() const { return m_note; } - -QString Bookmark::filePath() const -{ - return m_fileName; -} - -QString Bookmark::fileName() const -{ - return m_onlyFile; -} - -QString Bookmark::path() const -{ - return m_path; -} diff --git a/src/plugins/bookmarks/bookmark.h b/src/plugins/bookmarks/bookmark.h index 0fd48441428..89e5ea0d54d 100644 --- a/src/plugins/bookmarks/bookmark.h +++ b/src/plugins/bookmarks/bookmark.h @@ -33,8 +33,6 @@ #include #include -#include - namespace Bookmarks { namespace Internal { @@ -52,17 +50,11 @@ public: void updateNote(const QString ¬e); void removedFromEditor(); - QString filePath() const; - QString fileName() const; - QString path() const; QString lineText() const; QString note() const; private: BookmarkManager *m_manager; - QString m_fileName; - QString m_onlyFile; - QString m_path; QString m_lineText; QString m_note; }; diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index 670b59426c9..a51c11ee258 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -353,8 +353,7 @@ QItemSelectionModel *BookmarkManager::selectionModel() const bool BookmarkManager::hasBookmarkInPosition(const QString &fileName, int lineNumber) { - QFileInfo fi(fileName); - return findBookmark(fi.path(), fi.fileName(), lineNumber); + return findBookmark(fileName, lineNumber); } QModelIndex BookmarkManager::index(int row, int column, const QModelIndex &parent) const @@ -390,19 +389,19 @@ QVariant BookmarkManager::data(const QModelIndex &index, int role) const if (!index.isValid() || index.column() !=0 || index.row() < 0 || index.row() >= m_bookmarksList.count()) return QVariant(); + Bookmark *bookMark = m_bookmarksList.at(index.row()); if (role == BookmarkManager::Filename) - return m_bookmarksList.at(index.row())->fileName(); + return QFileInfo(bookMark->fileName()).fileName(); if (role == BookmarkManager::LineNumber) - return m_bookmarksList.at(index.row())->lineNumber(); + return bookMark->lineNumber(); if (role == BookmarkManager::Directory) - return m_bookmarksList.at(index.row())->path(); + return QFileInfo(bookMark->fileName()).path(); if (role == BookmarkManager::LineText) - return m_bookmarksList.at(index.row())->lineText(); + return bookMark->lineText(); if (role == BookmarkManager::Note) - return m_bookmarksList.at(index.row())->note(); + return bookMark->note(); if (role == Qt::ToolTipRole) - return QDir::toNativeSeparators(m_bookmarksList.at(index.row())->filePath()); - + return QDir::toNativeSeparators(bookMark->fileName()); return QVariant(); } @@ -417,18 +416,17 @@ void BookmarkManager::toggleBookmark() void BookmarkManager::toggleBookmark(const QString &fileName, int lineNumber) { - const QFileInfo fi(fileName); const int editorLine = lineNumber; // Remove any existing bookmark on this line - if (Bookmark *mark = findBookmark(fi.path(), fi.fileName(), lineNumber)) { + if (Bookmark *mark = findBookmark(fileName, lineNumber)) { // TODO check if the bookmark is really on the same markable Interface removeBookmark(mark); return; } // Add a new bookmark if no bookmark existed on this line - Bookmark *bookmark = new Bookmark(fi.filePath(), editorLine, this); + Bookmark *bookmark = new Bookmark(fileName, editorLine, this); bookmark->init(); addBookmark(bookmark); } @@ -471,7 +469,7 @@ void BookmarkManager::removeBookmark(Bookmark *bookmark) int idx = m_bookmarksList.indexOf(bookmark); beginRemoveRows(QModelIndex(), idx, idx); - const QFileInfo fi(bookmark->filePath() ); + const QFileInfo fi(bookmark->fileName()); FileNameBookmarksMap *files = m_bookmarksMap.value(fi.path()); FileNameBookmarksMap::iterator i = files->begin(); @@ -508,7 +506,7 @@ Bookmark *BookmarkManager::bookmarkForIndex(const QModelIndex &index) const bool BookmarkManager::gotoBookmark(Bookmark *bookmark) { - if (IEditor *editor = EditorManager::openEditorAt(bookmark->filePath(), bookmark->lineNumber())) + if (IEditor *editor = EditorManager::openEditorAt(bookmark->fileName(), bookmark->lineNumber())) return editor->currentLine() == bookmark->lineNumber(); return false; } @@ -677,8 +675,7 @@ void BookmarkManager::moveDown() void BookmarkManager::editNote(const QString &fileName, int lineNumber) { - QFileInfo fi(fileName); - Bookmark *b = findBookmark(fi.path(), fi.fileName(), lineNumber); + Bookmark *b = findBookmark(fileName, lineNumber); QModelIndex current = selectionModel()->currentIndex(); selectionModel()->setCurrentIndex(current.sibling(m_bookmarksList.indexOf(b), 0), QItemSelectionModel::Select | QItemSelectionModel::Clear); @@ -703,10 +700,12 @@ void BookmarkManager::editNote() } /* Returns the bookmark at the given file and line number, or 0 if no such bookmark exists. */ -Bookmark *BookmarkManager::findBookmark(const QString &path, const QString &fileName, int lineNumber) +Bookmark *BookmarkManager::findBookmark(const QString &filePath, int lineNumber) { + QFileInfo fi(filePath); + QString path = fi.path(); if (m_bookmarksMap.contains(path)) { - foreach (Bookmark *bookmark, m_bookmarksMap.value(path)->values(fileName)) { + foreach (Bookmark *bookmark, m_bookmarksMap.value(path)->values(fi.fileName())) { if (bookmark->lineNumber() == lineNumber) return bookmark; } @@ -721,7 +720,7 @@ Bookmark *BookmarkManager::findBookmark(const QString &path, const QString &file void BookmarkManager::addBookmark(Bookmark *bookmark, bool userset) { beginInsertRows(QModelIndex(), m_bookmarksList.size(), m_bookmarksList.size()); - const QFileInfo fi(bookmark->filePath()); + const QFileInfo fi(bookmark->fileName()); const QString &path = fi.path(); if (!m_bookmarksMap.contains(path)) @@ -752,9 +751,7 @@ void BookmarkManager::addBookmark(const QString &s) const QString &filePath = s.mid(index1+1, index2-index1-1); const QString ¬e = s.mid(index3 + 1); const int lineNumber = s.mid(index2 + 1, index3 - index2 - 1).toInt(); - const QFileInfo fi(filePath); - - if (!filePath.isEmpty() && !findBookmark(fi.path(), fi.fileName(), lineNumber)) { + if (!filePath.isEmpty() && !findBookmark(filePath, lineNumber)) { Bookmark *b = new Bookmark(filePath, lineNumber, this); b->setNote(note); b->init(); @@ -771,8 +768,7 @@ QString BookmarkManager::bookmarkToString(const Bookmark *b) const QLatin1Char colon(':'); // Using \t as delimiter because any another symbol can be a part of note. const QLatin1Char noteDelimiter('\t'); - // Empty string was the name of the bookmark, which now is always "" - return QLatin1String("") + colon + b->filePath() + + return colon + b->fileName() + colon + QString::number(b->lineNumber()) + noteDelimiter + b->note(); } @@ -821,8 +817,7 @@ void BookmarkManager::handleBookmarkTooltipRequest(ITextEditor *textEditor, cons int line) { if (textEditor->document()) { - const QFileInfo fi(textEditor->document()->filePath()); - Bookmark *mark = findBookmark(fi.path(), fi.fileName(), line); + Bookmark *mark = findBookmark(textEditor->document()->filePath(), line); operateTooltip(textEditor, pos, mark); } } diff --git a/src/plugins/bookmarks/bookmarkmanager.h b/src/plugins/bookmarks/bookmarkmanager.h index 5ff51ff5e89..a1a2d4a038b 100644 --- a/src/plugins/bookmarks/bookmarkmanager.h +++ b/src/plugins/bookmarks/bookmarkmanager.h @@ -118,7 +118,7 @@ private slots: private: void documentPrevNext(bool next); - Bookmark *findBookmark(const QString &path, const QString &fileName, int lineNumber); + Bookmark *findBookmark(const QString &filePath, int lineNumber); void addBookmark(Bookmark *bookmark, bool userset = true); void addBookmark(const QString &s); static QString bookmarkToString(const Bookmark *b); diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index a55968da4a9..e50a2a01b2d 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -2281,6 +2281,20 @@ void CppToolsPlugin::test_completion_data() << QLatin1String("Derived") << QLatin1String("foo") << QLatin1String("Foo")); + + QTest::newRow("default_arguments_for_class_templates_and_template_base_class_QTCREATORBUG-12606") << _( + "struct Foo { int foo; };\n" + "template \n" + "struct Base { T t; };\n" + "template \n" + "struct Derived : Base {};\n" + "void fun() {\n" + " Derived<> derived;\n" + " @\n" + "}\n" + ) << _("derived.t.") << (QStringList() + << QLatin1String("foo") + << QLatin1String("Foo")); } void CppToolsPlugin::test_completion_member_access_operator() diff --git a/src/plugins/cpptools/cpptoolseditorsupport.cpp b/src/plugins/cpptools/cpptoolseditorsupport.cpp index eb496f9e3d0..56f31d9218e 100644 --- a/src/plugins/cpptools/cpptoolseditorsupport.cpp +++ b/src/plugins/cpptools/cpptoolseditorsupport.cpp @@ -526,7 +526,8 @@ SemanticInfo CppEditorSupport::recalculateSemanticInfoNow(const SemanticInfo::So const QSharedPointer snapshotUpdater = snapshotUpdater_internal(); QTC_ASSERT(snapshotUpdater, return newSemanticInfo); newSemanticInfo.snapshot = snapshotUpdater->snapshot(); - QTC_ASSERT(newSemanticInfo.snapshot.contains(source.fileName), return newSemanticInfo); + if (!newSemanticInfo.snapshot.contains(source.fileName)) + return newSemanticInfo; // SnapshotUpdater::update() not yet started. Document::Ptr doc = newSemanticInfo.snapshot.preprocessedDocument(source.code, source.fileName); if (processor) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 6c8717ca8de..8c45d960f26 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -684,8 +684,6 @@ static QString quoteUnprintable(const QString &str) static QString translate(const QString &str) { if (str.startsWith(QLatin1Char('<'))) { - if (str == QLatin1String("")) - return WatchHandler::tr(""); if (str == QLatin1String("")) return WatchHandler::tr(""); if (str == QLatin1String("")) @@ -1063,9 +1061,7 @@ static QString expression(const WatchItem *item) QString WatchModel::displayName(const WatchItem *item) const { QString result; - if (item->parent == m_watchRoot && item->name.isEmpty()) - result = tr(""); - else if (item->parent == m_returnRoot) + if (item->parent == m_returnRoot) result = tr("returned value"); else if (item->name == QLatin1String("*")) result = QLatin1Char('*') + item->parent->name; diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index d89513b5288..b519c253223 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -554,8 +554,7 @@ void WatchTreeView::mouseDoubleClickEvent(QMouseEvent *ev) { const QModelIndex idx = indexAt(ev->pos()); if (!idx.isValid()) { - // The "" case. - watchExpression(QString()); + inputNewExpression(); return; } BaseTreeView::mouseDoubleClickEvent(ev); @@ -921,12 +920,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev) if (!act) { ; } else if (act == &actInsertNewWatchItem) { - bool ok; - QString newExp = QInputDialog::getText(this, tr("Enter Expression for Evaluator"), - tr("Expression:"), QLineEdit::Normal, - QString(), &ok); - if (ok && !newExp.isEmpty()) - watchExpression(newExp); + inputNewExpression(); } else if (act == &actOpenMemoryEditAtObjectAddress) { addVariableMemoryView(currentEngine(), false, mi0, false, ev->globalPos(), this); } else if (act == &actOpenMemoryEditAtPointerAddress) { @@ -1090,5 +1084,15 @@ void WatchTreeView::setModelData model()->setData(index, value, role); } +void WatchTreeView::inputNewExpression() +{ + bool ok; + QString exp = QInputDialog::getText(this, tr("Enter Expression for Evaluator"), + tr("Expression:"), QLineEdit::Normal, + QString(), &ok); + if (ok && !exp.isEmpty()) + watchExpression(exp, exp); +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index 2e322dcb090..caeb68bef45 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -89,6 +89,7 @@ private: bool event(QEvent *ev); void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); + void inputNewExpression(); void editItem(const QModelIndex &idx); void resetHelper(const QModelIndex &idx); diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index 7fd196af44a..ac002491e35 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -74,6 +74,7 @@ #include "qmldesignerplugin.h" #include "puppetcreator.h" +#include #include #include @@ -175,8 +176,7 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV } } else { - QMessageBox::warning(Core::ICore::dialogParent(), - tr("Cannot Start QML Puppet Executable"), + QmlDesignerWarning::show(tr("Cannot Start QML Puppet Executable"), tr("The executable of the QML Puppet process cannot be started or is hanging.")); QmlDesignerPlugin::instance()->switchToTextModeDeferred(); diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index e1087710a33..5c4ee57de7f 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -730,40 +730,68 @@ void TextToModelMerger::setupImports(const Document::Ptr &doc, differenceHandler.importAbsentInQMl(import); } -void TextToModelMerger::setupPossibleImports(const QmlJS::Snapshot &snapshot, const QmlJS::ViewerContext &viewContext) +static bool isLatestImportVersion(const ImportKey &importKey, const QHash &filteredPossibleImportKeys) { - QList possibleImports; + return !filteredPossibleImportKeys.contains(importKey.path()) + || filteredPossibleImportKeys.value(importKey.path()).majorVersion < importKey.majorVersion + || (filteredPossibleImportKeys.value(importKey.path()).majorVersion == importKey.majorVersion + && filteredPossibleImportKeys.value(importKey.path()).minorVersion < importKey.minorVersion); +} - QSet possibleImportKeys = snapshot.importDependencies()->libraryImports(viewContext); +static bool isBlacklistImport(const ImportKey &importKey) +{ + QString importPathFirst = importKey.splitPath.first(); + QString importPathLast = importKey.splitPath.last(); + return importPathFirst == QStringLiteral("") + || importPathFirst == QStringLiteral("QML") + || importPathFirst == QStringLiteral("QtQml") + || (importPathFirst == QStringLiteral("QtQuick") && importPathLast == QStringLiteral("PrivateWidgets")) + || importPathLast == QStringLiteral("Private") + || (importKey.splitPath.count() == 1 && importPathFirst == QStringLiteral("QtQuick")); // Don't show Quick X.X imports +} +static QHash filterPossibleImportKeys(const QSet &possibleImportKeys) +{ QHash filteredPossibleImportKeys; foreach (const ImportKey &importKey, possibleImportKeys) { - if (!filteredPossibleImportKeys.contains(importKey.path()) - || filteredPossibleImportKeys.value(importKey.path()).majorVersion < importKey.majorVersion - || (filteredPossibleImportKeys.value(importKey.path()).majorVersion == importKey.majorVersion - && filteredPossibleImportKeys.value(importKey.path()).minorVersion < importKey.minorVersion)) - filteredPossibleImportKeys.insert(importKey.path(), importKey); + if (isLatestImportVersion(importKey, filteredPossibleImportKeys) && !isBlacklistImport(importKey)) + filteredPossibleImportKeys.insert(importKey.path(), importKey); } - filteredPossibleImportKeys.remove(QStringLiteral("")); - filteredPossibleImportKeys.remove(QStringLiteral("QML")); - filteredPossibleImportKeys.remove(QStringLiteral("QtQml")); - filteredPossibleImportKeys.remove(QStringLiteral("QtQuick/PrivateWidgets")); + return filteredPossibleImportKeys; +} - QList allImports = m_scopeChain->context()->imports(m_document.data())->all(); - - foreach (const QmlJS::Import &import, allImports) { +static void removeUsedImports(QHash &filteredPossibleImportKeys, const QList &usedImports) +{ + foreach (const QmlJS::Import &import, usedImports) filteredPossibleImportKeys.remove(import.info.path()); - } +} + +static QList generatePossibleImports(const QHash &filteredPossibleImportKeys) +{ + QList possibleImports; foreach (const ImportKey &importKey, filteredPossibleImportKeys) { QString libraryName = importKey.splitPath.join(QLatin1Char('.')); - QString version = QString(QStringLiteral("%1.%2") - .arg((importKey.majorVersion == LanguageUtils::ComponentVersion::NoVersion) ? 1 : importKey.majorVersion) - .arg((importKey.minorVersion == LanguageUtils::ComponentVersion::NoVersion) ? 0 : importKey.minorVersion)); - possibleImports.append(Import::createLibraryImport(libraryName, version)); + int majorVersion = importKey.majorVersion; + if (majorVersion >= 0) { + int minorVersion = (importKey.minorVersion == LanguageUtils::ComponentVersion::NoVersion) ? 0 : importKey.minorVersion; + QString version = QStringLiteral("%1.%2").arg(majorVersion).arg(minorVersion); + possibleImports.append(QmlDesigner::Import::createLibraryImport(libraryName, version)); + } } + return possibleImports; +} + +void TextToModelMerger::setupPossibleImports(const QmlJS::Snapshot &snapshot, const QmlJS::ViewerContext &viewContext) +{ + QHash filteredPossibleImportKeys = filterPossibleImportKeys(snapshot.importDependencies()->libraryImports(viewContext)); + + removeUsedImports(filteredPossibleImportKeys, m_scopeChain->context()->imports(m_document.data())->all()); + + QList possibleImports = generatePossibleImports(filteredPossibleImportKeys); + if ( m_rewriterView->isAttached()) m_rewriterView->model()->setPossibleImports(possibleImports); } @@ -783,11 +811,6 @@ void TextToModelMerger::setupUsedImports() } } } - // even if not explicitly used we probably want to keep QtQuick imports - usedImports.append(Import::createLibraryImport("QtQuick", "1.0")); - usedImports.append(Import::createLibraryImport("QtQuick", "1.1")); - usedImports.append(Import::createLibraryImport("QtQuick", "2.0")); - usedImports.append(Import::createLibraryImport("QtQuick", "2.1")); if (m_rewriterView->isAttached()) m_rewriterView->model()->setUsedImports(usedImports); diff --git a/src/plugins/tasklist/stopmonitoringhandler.cpp b/src/plugins/tasklist/stopmonitoringhandler.cpp index 0b5cd6b8dc3..a4a09c8a3e2 100644 --- a/src/plugins/tasklist/stopmonitoringhandler.cpp +++ b/src/plugins/tasklist/stopmonitoringhandler.cpp @@ -54,7 +54,7 @@ void StopMonitoringHandler::handle(const ProjectExplorer::Task &task) { QTC_ASSERT(canHandle(task), return); Q_UNUSED(task); - TaskList::TaskListPlugin::stopMonitoring(); + TaskListPlugin::stopMonitoring(); } QAction *StopMonitoringHandler::createAction(QObject *parent) const diff --git a/src/plugins/tasklist/taskfile.cpp b/src/plugins/tasklist/taskfile.cpp index fa695c5e2ab..8b105e81fcf 100644 --- a/src/plugins/tasklist/taskfile.cpp +++ b/src/plugins/tasklist/taskfile.cpp @@ -97,7 +97,7 @@ bool TaskFile::reload(QString *errorString, ReloadFlag flag, ChangeType type) bool TaskFile::open(QString *errorString, const QString &fileName) { setFilePath(fileName); - return TaskList::TaskListPlugin::loadFile(errorString, m_baseDir, fileName); + return TaskListPlugin::loadFile(errorString, m_baseDir, fileName); } QString TaskFile::baseDir() const diff --git a/src/plugins/tasklist/taskfilefactory.cpp b/src/plugins/tasklist/taskfilefactory.cpp deleted file mode 100644 index f8aea9f0346..00000000000 --- a/src/plugins/tasklist/taskfilefactory.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "taskfilefactory.h" - -#include "taskfile.h" - -#include -#include -#include -#include - -#include - -using namespace TaskList::Internal; - -// -------------------------------------------------------------------------- -// TaskFileFactory -// -------------------------------------------------------------------------- - -TaskFileFactory::TaskFileFactory(QObject * parent) : - Core::IDocumentFactory(parent) -{ - setId("ProjectExplorer.TaskFileFactory"); - setDisplayName(tr("Task file reader")); - addMimeType(QLatin1String("text/x-tasklist")); - setOpener([this](const QString &fileName) -> Core::IDocument * { - ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject(); - return this->open(project ? project->projectDirectory().toString() : QString(), fileName); - }); -} - -Core::IDocument *TaskFileFactory::open(const QString &base, const QString &fileName) -{ - foreach (TaskFile *doc, m_openFiles) { - if (doc->filePath() == fileName) - return doc; - } - - TaskFile *file = new TaskFile(this); - file->setBaseDir(base); - - QString errorString; - if (!file->open(&errorString, fileName)) { - QMessageBox::critical(Core::ICore::mainWindow(), tr("File Error"), errorString); - delete file; - return 0; - } - - m_openFiles.append(file); - - // Register with filemanager: - Core::DocumentManager::addDocument(file); - - return file; -} - -void TaskFileFactory::closeAllFiles() -{ - foreach (TaskFile *document, m_openFiles) - document->deleteLater(); - m_openFiles.clear(); -} diff --git a/src/plugins/tasklist/taskfilefactory.h b/src/plugins/tasklist/taskfilefactory.h deleted file mode 100644 index 894f49f5fa9..00000000000 --- a/src/plugins/tasklist/taskfilefactory.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef TASKFILEFACTORY_H -#define TASKFILEFACTORY_H - -#include -#include - -namespace ProjectExplorer { class Project; } - -namespace TaskList { -namespace Internal { - -class TaskFile; - -class TaskFileFactory : public Core::IDocumentFactory -{ - Q_OBJECT - -public: - TaskFileFactory(QObject *parent = 0); - - Core::IDocument *open(const QString &base, const QString &fileName); - - void closeAllFiles(); - -private: - QList m_openFiles; -}; - -} // namespace Internal -} // namespace TaskList - -#endif // TASKFILEFACTORY_H diff --git a/src/plugins/tasklist/tasklist.pro b/src/plugins/tasklist/tasklist.pro index 29696e98820..e842884f664 100644 --- a/src/plugins/tasklist/tasklist.pro +++ b/src/plugins/tasklist/tasklist.pro @@ -4,11 +4,9 @@ HEADERS += tasklistplugin.h \ tasklistconstants.h \ stopmonitoringhandler.h \ taskfile.h \ - taskfilefactory.h \ SOURCES += tasklistplugin.cpp \ stopmonitoringhandler.cpp \ taskfile.cpp \ - taskfilefactory.cpp \ RESOURCES += tasklist.qrc diff --git a/src/plugins/tasklist/tasklist.qbs b/src/plugins/tasklist/tasklist.qbs index b00c1e7505a..8b89df02d03 100644 --- a/src/plugins/tasklist/tasklist.qbs +++ b/src/plugins/tasklist/tasklist.qbs @@ -16,8 +16,6 @@ QtcPlugin { "stopmonitoringhandler.h", "taskfile.cpp", "taskfile.h", - "taskfilefactory.cpp", - "taskfilefactory.h", "tasklist.qrc", "tasklistconstants.h", "tasklistplugin.cpp", diff --git a/src/plugins/tasklist/tasklistplugin.cpp b/src/plugins/tasklist/tasklistplugin.cpp index 8f8c81e7ad1..d8c28177f84 100644 --- a/src/plugins/tasklist/tasklistplugin.cpp +++ b/src/plugins/tasklist/tasklistplugin.cpp @@ -31,10 +31,11 @@ #include "stopmonitoringhandler.h" #include "taskfile.h" -#include "taskfilefactory.h" #include "tasklistconstants.h" #include +#include +#include #include #include #include @@ -43,16 +44,20 @@ #include #include +#include #include #include +using namespace Core; using namespace ProjectExplorer; -using namespace TaskList::Internal; static const char SESSION_FILE_KEY[] = "TaskList.File"; static const char SESSION_BASE_KEY[] = "TaskList.BaseDir"; namespace TaskList { +namespace Internal { + +static TaskListPlugin *m_instance; static Task::TaskType typeFrom(const QString &typeName) { @@ -160,7 +165,35 @@ static bool parseTaskFile(QString *errorString, const QString &base, const QStri // TaskListPlugin // -------------------------------------------------------------------------- -static TaskFileFactory *m_fileFactory = 0; +Core::IDocument *TaskListPlugin::openTasks(const QString &base, const QString &fileName) +{ + foreach (TaskFile *doc, m_openFiles) { + if (doc->filePath() == fileName) + return doc; + } + + TaskFile *file = new TaskFile(this); + file->setBaseDir(base); + + QString errorString; + if (!file->open(&errorString, fileName)) { + QMessageBox::critical(Core::ICore::mainWindow(), tr("File Error"), errorString); + delete file; + return 0; + } + + m_openFiles.append(file); + + // Register with filemanager: + Core::DocumentManager::addDocument(file); + + return file; +} + +TaskListPlugin::TaskListPlugin() +{ + m_instance = this; +} bool TaskListPlugin::initialize(const QStringList &arguments, QString *errorMessage) { @@ -172,7 +205,15 @@ bool TaskListPlugin::initialize(const QStringList &arguments, QString *errorMess if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":tasklist/TaskList.mimetypes.xml"), errorMessage)) return false; - m_fileFactory = new TaskFileFactory(this); + m_fileFactory = new IDocumentFactory; + m_fileFactory->setId("ProjectExplorer.TaskFileFactory"); + m_fileFactory->setDisplayName(tr("Task file reader")); + m_fileFactory->addMimeType(QLatin1String("text/x-tasklist")); + m_fileFactory->setOpener([this](const QString &fileName) -> IDocument * { + ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject(); + return this->openTasks(project ? project->projectDirectory().toString() : QString(), fileName); + }); + addAutoReleasedObject(m_fileFactory); addAutoReleasedObject(new StopMonitoringHandler); @@ -202,7 +243,9 @@ void TaskListPlugin::stopMonitoring() SessionManager::setValue(QLatin1String(SESSION_BASE_KEY), QString()); SessionManager::setValue(QLatin1String(SESSION_FILE_KEY), QString()); - m_fileFactory->closeAllFiles(); + foreach (TaskFile *document, m_instance->m_openFiles) + document->deleteLater(); + m_instance->m_openFiles.clear(); } void TaskListPlugin::clearTasks() @@ -215,9 +258,10 @@ void TaskListPlugin::loadDataFromSession() const QString fileName = SessionManager::value(QLatin1String(SESSION_FILE_KEY)).toString(); if (fileName.isEmpty()) return; - m_fileFactory->open(SessionManager::value(QLatin1String(SESSION_BASE_KEY)).toString(), fileName); + openTasks(SessionManager::value(QLatin1String(SESSION_BASE_KEY)).toString(), fileName); } +} // namespace Internal } // namespace TaskList -Q_EXPORT_PLUGIN(TaskList::TaskListPlugin) +Q_EXPORT_PLUGIN(TaskList::Internal::TaskListPlugin) diff --git a/src/plugins/tasklist/tasklistplugin.h b/src/plugins/tasklist/tasklistplugin.h index c2f62141138..f8d0e9c5551 100644 --- a/src/plugins/tasklist/tasklistplugin.h +++ b/src/plugins/tasklist/tasklistplugin.h @@ -30,11 +30,13 @@ #ifndef TASKLISTPLUGIN_H #define TASKLISTPLUGIN_H +#include #include -namespace ProjectExplorer { class Project; } - namespace TaskList { +namespace Internal { + +class TaskFile; class TaskListPlugin : public ExtensionSystem::IPlugin { @@ -42,6 +44,8 @@ class TaskListPlugin : public ExtensionSystem::IPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "TaskList.json") public: + TaskListPlugin(); + bool initialize(const QStringList &arguments, QString *errorMessage); void extensionsInitialized() {} @@ -50,10 +54,17 @@ public: static void stopMonitoring(); static void clearTasks(); + Core::IDocument *openTasks(const QString &base, const QString &fileName); + public slots: void loadDataFromSession(); + +private: + Core::IDocumentFactory *m_fileFactory; + QList m_openFiles; }; +} // namespace Internal } // namespace TaskList #endif // TASKLISTPLUGIN_H diff --git a/src/tools/sdktool/adddebuggeroperation.cpp b/src/tools/sdktool/adddebuggeroperation.cpp index 13f38ab1574..254a73f905d 100644 --- a/src/tools/sdktool/adddebuggeroperation.cpp +++ b/src/tools/sdktool/adddebuggeroperation.cpp @@ -139,7 +139,7 @@ bool AddDebuggerOperation::setArguments(const QStringList &args) int AddDebuggerOperation::execute() const { - QVariantMap map = load(QLatin1String("debuggers")); + QVariantMap map = load(QLatin1String("Debuggers")); if (map.isEmpty()) map = initializeDebuggers(); @@ -149,7 +149,7 @@ int AddDebuggerOperation::execute() const if (result.isEmpty() || map == result) return 2; - return save(result, QLatin1String("debuggers")) ? 0 : 3; + return save(result, QLatin1String("Debuggers")) ? 0 : 3; } #ifdef WITH_TESTS diff --git a/src/tools/sdktool/adddeviceoperation.cpp b/src/tools/sdktool/adddeviceoperation.cpp index ee3b1c70879..ddd0191e3c6 100644 --- a/src/tools/sdktool/adddeviceoperation.cpp +++ b/src/tools/sdktool/adddeviceoperation.cpp @@ -45,6 +45,8 @@ const char DEVICE_LIST_ID[] = "DeviceList"; const char DEVICE_ID_ID[] = "InternalId"; +static const char INTERNAL_DSEKTOP_DEVICE_ID[] = "Desktop Device"; + AddDeviceOperation::AddDeviceOperation() { } @@ -255,7 +257,7 @@ bool AddDeviceOperation::setArguments(const QStringList &args) int AddDeviceOperation::execute() const { - QVariantMap map = load(QLatin1String("devices")); + QVariantMap map = load(QLatin1String("Devices")); if (map.isEmpty()) map = initializeDevices(); @@ -267,7 +269,7 @@ int AddDeviceOperation::execute() const if (result.isEmpty() || map == result) return 2; - return save(result, QLatin1String("devices")) ? 0 : 3; + return save(result, QLatin1String("Devices")) ? 0 : 3; } #ifdef WITH_TESTS @@ -371,12 +373,14 @@ QVariantMap AddDeviceOperation::initializeDevices() bool AddDeviceOperation::exists(const QString &id) { - QVariantMap map = load(QLatin1String("device")); + QVariantMap map = load(QLatin1String("Devices")); return exists(map, id); } bool AddDeviceOperation::exists(const QVariantMap &map, const QString &id) { + if (id == QLatin1String(INTERNAL_DSEKTOP_DEVICE_ID)) + return true; QVariantMap dmMap = map.value(QLatin1String(DEVICEMANAGER_ID)).toMap(); QVariantList devList = dmMap.value(QLatin1String(DEVICE_LIST_ID)).toList(); foreach (const QVariant &dev, devList) { diff --git a/src/tools/sdktool/addkitoperation.cpp b/src/tools/sdktool/addkitoperation.cpp index 6f18d1730a0..110be9951bf 100644 --- a/src/tools/sdktool/addkitoperation.cpp +++ b/src/tools/sdktool/addkitoperation.cpp @@ -242,7 +242,7 @@ bool AddKitOperation::setArguments(const QStringList &args) int AddKitOperation::execute() const { - QVariantMap map = load(QLatin1String("profiles")); + QVariantMap map = load(QLatin1String("Profiles")); if (map.isEmpty()) map = initializeKits(); @@ -253,7 +253,7 @@ int AddKitOperation::execute() const if (result.isEmpty() || map == result) return 2; - return save(result, QLatin1String("profiles")) ? 0 : 3; + return save(result, QLatin1String("Profiles")) ? 0 : 3; } #ifdef WITH_TESTS @@ -510,9 +510,9 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, const QString &sysRoot, const QString &tc, const QString &qt, const QString &mkspec, const KeyValuePairList &extra) { - QVariantMap tcMap = load(QLatin1String("toolchains")); - QVariantMap qtMap = load(QLatin1String("qtversions")); - QVariantMap devMap = load(QLatin1String("devices")); + QVariantMap tcMap = load(QLatin1String("ToolChains")); + QVariantMap qtMap = load(QLatin1String("QtVersions")); + QVariantMap devMap = load(QLatin1String("Devices")); return addKit(map, tcMap, qtMap, devMap, id, displayName, icon, debuggerId, debuggerType, debugger, deviceType, device, sysRoot, tc, qt, mkspec, extra); diff --git a/src/tools/sdktool/addqtoperation.cpp b/src/tools/sdktool/addqtoperation.cpp index 316e3ec89ae..6ae46b860dd 100644 --- a/src/tools/sdktool/addqtoperation.cpp +++ b/src/tools/sdktool/addqtoperation.cpp @@ -155,7 +155,7 @@ bool AddQtOperation::setArguments(const QStringList &args) int AddQtOperation::execute() const { - QVariantMap map = load(QLatin1String("qtversions")); + QVariantMap map = load(QLatin1String("QtVersions")); if (map.isEmpty()) map = initializeQtVersions(); @@ -164,7 +164,7 @@ int AddQtOperation::execute() const if (result.isEmpty() || result == map) return 2; - return save(result, QLatin1String("qtversions")) ? 0 : 3; + return save(result, QLatin1String("QtVersions")) ? 0 : 3; } #ifdef WITH_TESTS @@ -315,7 +315,7 @@ QVariantMap AddQtOperation::initializeQtVersions() bool AddQtOperation::exists(const QString &id) { - QVariantMap map = load(QLatin1String("qtversion")); + QVariantMap map = load(QLatin1String("QtVersions")); return exists(map, id); } diff --git a/src/tools/sdktool/addtoolchainoperation.cpp b/src/tools/sdktool/addtoolchainoperation.cpp index 77d9cd45cba..7053fe4d59e 100644 --- a/src/tools/sdktool/addtoolchainoperation.cpp +++ b/src/tools/sdktool/addtoolchainoperation.cpp @@ -145,7 +145,7 @@ bool AddToolChainOperation::setArguments(const QStringList &args) int AddToolChainOperation::execute() const { - QVariantMap map = load(QLatin1String("toolchains")); + QVariantMap map = load(QLatin1String("ToolChains")); if (map.isEmpty()) map = initializeToolChains(); @@ -153,7 +153,7 @@ int AddToolChainOperation::execute() const if (result.isEmpty() || map == result) return 2; - return save(result, QLatin1String("toolchains")) ? 0 : 3; + return save(result, QLatin1String("ToolChains")) ? 0 : 3; } #ifdef WITH_TESTS @@ -291,6 +291,6 @@ bool AddToolChainOperation::exists(const QVariantMap &map, const QString &id) bool AddToolChainOperation::exists(const QString &id) { - QVariantMap map = Operation::load(QLatin1String("toolchains")); + QVariantMap map = Operation::load(QLatin1String("ToolChains")); return exists(map, id); } diff --git a/src/tools/sdktool/operation.cpp b/src/tools/sdktool/operation.cpp index 5c068bbddd4..ccd67d2cf8d 100644 --- a/src/tools/sdktool/operation.cpp +++ b/src/tools/sdktool/operation.cpp @@ -128,8 +128,8 @@ bool Operation::save(const QVariantMap &map, const QString &file) const return false; } - - Utils::PersistentSettingsWriter writer(path, QLatin1String("unknown")); + Utils::PersistentSettingsWriter writer(path, QLatin1String("QtCreator") + + file[0].toUpper() + file.mid(1)); return writer.save(map, 0) && QFile::setPermissions(path.toString(), QFile::ReadOwner | QFile::WriteOwner diff --git a/src/tools/sdktool/rmdebuggeroperation.cpp b/src/tools/sdktool/rmdebuggeroperation.cpp index e4b1e73ca2e..87ad5c299f2 100644 --- a/src/tools/sdktool/rmdebuggeroperation.cpp +++ b/src/tools/sdktool/rmdebuggeroperation.cpp @@ -82,7 +82,7 @@ bool RmDebuggerOperation::setArguments(const QStringList &args) int RmDebuggerOperation::execute() const { - QVariantMap map = load(QLatin1String("debuggers")); + QVariantMap map = load(QLatin1String("Debuggers")); if (map.isEmpty()) map = AddDebuggerOperation::initializeDebuggers(); @@ -91,7 +91,7 @@ int RmDebuggerOperation::execute() const if (result == map) return 2; - return save(result, QLatin1String("debuggers")) ? 0 : 3; + return save(result, QLatin1String("Debuggers")) ? 0 : 3; } #ifdef WITH_TESTS diff --git a/src/tools/sdktool/rmdeviceoperation.cpp b/src/tools/sdktool/rmdeviceoperation.cpp index 9b6ad2fe691..c409884f079 100644 --- a/src/tools/sdktool/rmdeviceoperation.cpp +++ b/src/tools/sdktool/rmdeviceoperation.cpp @@ -68,7 +68,7 @@ bool RmDeviceOperation::setArguments(const QStringList &args) int RmDeviceOperation::execute() const { - QVariantMap map = load(QLatin1String("devices")); + QVariantMap map = load(QLatin1String("Devices")); if (map.isEmpty()) map = AddDeviceOperation::initializeDevices(); @@ -77,7 +77,7 @@ int RmDeviceOperation::execute() const if (result == map) return 2; - return save(result, QLatin1String("devices")) ? 0 : 3; + return save(result, QLatin1String("Devices")) ? 0 : 3; } #ifdef WITH_TESTS diff --git a/src/tools/sdktool/rmkitoperation.cpp b/src/tools/sdktool/rmkitoperation.cpp index 72216a9669d..52439397394 100644 --- a/src/tools/sdktool/rmkitoperation.cpp +++ b/src/tools/sdktool/rmkitoperation.cpp @@ -86,7 +86,7 @@ bool RmKitOperation::setArguments(const QStringList &args) int RmKitOperation::execute() const { - QVariantMap map = load(QLatin1String("profiles")); + QVariantMap map = load(QLatin1String("Profiles")); if (map.isEmpty()) map = AddKitOperation::initializeKits(); @@ -95,7 +95,7 @@ int RmKitOperation::execute() const if (result == map) return 2; - return save(result, QLatin1String("profiles")) ? 0 : 3; + return save(result, QLatin1String("Profiles")) ? 0 : 3; } #ifdef WITH_TESTS diff --git a/src/tools/sdktool/rmqtoperation.cpp b/src/tools/sdktool/rmqtoperation.cpp index 20f74ccc474..5a0e3c5c83c 100644 --- a/src/tools/sdktool/rmqtoperation.cpp +++ b/src/tools/sdktool/rmqtoperation.cpp @@ -84,7 +84,7 @@ bool RmQtOperation::setArguments(const QStringList &args) int RmQtOperation::execute() const { - QVariantMap map = load(QLatin1String("qtversion")); + QVariantMap map = load(QLatin1String("QtVersions")); if (map.isEmpty()) return 0; @@ -92,7 +92,7 @@ int RmQtOperation::execute() const if (result == map) return 2; - return save(result, QLatin1String("qtversion")) ? 0 : 3; + return save(result, QLatin1String("QtVersions")) ? 0 : 3; } #ifdef WITH_TESTS diff --git a/src/tools/sdktool/rmtoolchainoperation.cpp b/src/tools/sdktool/rmtoolchainoperation.cpp index be71a283c3f..0a1bad4b1a0 100644 --- a/src/tools/sdktool/rmtoolchainoperation.cpp +++ b/src/tools/sdktool/rmtoolchainoperation.cpp @@ -85,7 +85,7 @@ bool RmToolChainOperation::setArguments(const QStringList &args) int RmToolChainOperation::execute() const { - QVariantMap map = load(QLatin1String("toolchains")); + QVariantMap map = load(QLatin1String("ToolChains")); if (map.isEmpty()) return 0; @@ -93,7 +93,7 @@ int RmToolChainOperation::execute() const if (result == map) return 2; - return save(result, QLatin1String("toolchains")) ? 0 : 3; + return save(result, QLatin1String("ToolChains")) ? 0 : 3; } #ifdef WITH_TESTS diff --git a/src/tools/sdktool/settings.cpp b/src/tools/sdktool/settings.cpp index fab28a88d86..c9b7ddb8200 100644 --- a/src/tools/sdktool/settings.cpp +++ b/src/tools/sdktool/settings.cpp @@ -61,18 +61,20 @@ Settings::Settings() : Utils::FileName Settings::getPath(const QString &file) { Utils::FileName result = sdkPath; - if (file == QLatin1String("profiles") || file == QLatin1String("kits")) + const QString lowerFile = file.toLower(); + const QStringList identical = QStringList() + << QLatin1String("profiles") + << QLatin1String("qtversion") + << QLatin1String("toolchains") + << QLatin1String("devices") + << QLatin1String("android") + << QLatin1String("debuggers"); + if (lowerFile == QLatin1String("kits")) result.appendPath(QLatin1String("profiles")); - else if (file == QLatin1String("qtversions") || file == QLatin1String("qtversion")) + else if (lowerFile == QLatin1String("qtversions")) result.appendPath(QLatin1String("qtversion")); - else if (file == QLatin1String("toolchains") || file == QLatin1String("toolChains")) - result.appendPath(QLatin1String("toolchains")); - else if (file == QLatin1String("devices")) - result.appendPath(QLatin1String("devices")); - else if (file == QLatin1String("android")) - result.appendPath(QLatin1String("android")); - else if (file == QLatin1String("debuggers")) - result.appendPath(QLatin1String("debuggers")); + else if (identical.contains(lowerFile)) + result.appendPath(lowerFile); else return Utils::FileName(); result.appendString(QLatin1String(".xml"));