diff options
40 files changed, 411 insertions, 515 deletions
diff --git a/share/qtcreator/themes/dark.creatortheme b/share/qtcreator/themes/dark.creatortheme index bcd4fb213e..006daa501c 100644 --- a/share/qtcreator/themes/dark.creatortheme +++ b/share/qtcreator/themes/dark.creatortheme @@ -116,10 +116,10 @@ SplitterColor=ff313131 TextColorDisabled=textDisabled TextColorError=ffff4040 TextColorHighlight=ffff0000 +TextColorHighlightBackground=555500 TextColorLink=textColorLink TextColorLinkVisited=textColorLinkVisited TextColorNormal=text -TodoItemTextColor=ff000000 ToggleButtonBackgroundColor=shadowBackground ToolBarBackgroundColor=shadowBackground TreeViewArrowColorNormal=hoverBackground diff --git a/share/qtcreator/themes/default.creatortheme b/share/qtcreator/themes/default.creatortheme index 13362cc799..4be1514bb2 100644 --- a/share/qtcreator/themes/default.creatortheme +++ b/share/qtcreator/themes/default.creatortheme @@ -108,10 +108,10 @@ SplitterColor=ff151515 TextColorDisabled=ff000000 TextColorError=ffff0000 TextColorHighlight=ffa0a0a4 +TextColorHighlightBackground=ffef0b TextColorLink=ff0057ae TextColorLinkVisited=ff644a9b TextColorNormal=ff000000 -TodoItemTextColor=ff000000 ToggleButtonBackgroundColor=ffff0000 ToolBarBackgroundColor=ffff0000 TreeViewArrowColorNormal=ffff0000 diff --git a/share/qtcreator/themes/flat-dark.creatortheme b/share/qtcreator/themes/flat-dark.creatortheme index 1a6fe22dc5..24c3f57319 100644 --- a/share/qtcreator/themes/flat-dark.creatortheme +++ b/share/qtcreator/themes/flat-dark.creatortheme @@ -121,10 +121,10 @@ SplitterColor=splitter TextColorDisabled=textDisabled TextColorError=ffff4040 TextColorHighlight=ffff0000 +TextColorHighlightBackground=8a7f2c TextColorLink=textColorLink TextColorLinkVisited=textColorLinkVisited TextColorNormal=text -TodoItemTextColor=ff000000 ToggleButtonBackgroundColor=shadowBackground ToolBarBackgroundColor=shadowBackground TreeViewArrowColorNormal=hoverBackground diff --git a/share/qtcreator/themes/flat-light.creatortheme b/share/qtcreator/themes/flat-light.creatortheme index 2e2a951355..4460fd72d1 100644 --- a/share/qtcreator/themes/flat-light.creatortheme +++ b/share/qtcreator/themes/flat-light.creatortheme @@ -119,10 +119,10 @@ SplitterColor=splitter TextColorDisabled=textDisabled TextColorError=ffff4040 TextColorHighlight=ffff0000 +TextColorHighlightBackground=ffef0b TextColorLink=ff007af4 TextColorLinkVisited=ffa57aff TextColorNormal=text -TodoItemTextColor=ff000000 ToggleButtonBackgroundColor=shadowBackground ToolBarBackgroundColor=shadowBackground TreeViewArrowColorNormal=hoverBackground diff --git a/share/qtcreator/themes/flat.creatortheme b/share/qtcreator/themes/flat.creatortheme index e79402de93..e98999056a 100644 --- a/share/qtcreator/themes/flat.creatortheme +++ b/share/qtcreator/themes/flat.creatortheme @@ -117,10 +117,10 @@ SplitterColor=splitter TextColorDisabled=textDisabled TextColorError=ffff4040 TextColorHighlight=ffff0000 +TextColorHighlightBackground=ffef0b TextColorLink=ff007af4 TextColorLinkVisited=ffa57aff TextColorNormal=text -TodoItemTextColor=ff000000 ToggleButtonBackgroundColor=shadowBackground ToolBarBackgroundColor=shadowBackground TreeViewArrowColorNormal=hoverBackground diff --git a/src/libs/utils/theme/theme.h b/src/libs/utils/theme/theme.h index d4caa4902f..ea69e2fae7 100644 --- a/src/libs/utils/theme/theme.h +++ b/src/libs/utils/theme/theme.h @@ -116,10 +116,10 @@ public: TextColorDisabled, TextColorError, TextColorHighlight, + TextColorHighlightBackground, TextColorLink, TextColorLinkVisited, TextColorNormal, - TodoItemTextColor, ToggleButtonBackgroundColor, ToolBarBackgroundColor, TreeViewArrowColorNormal, diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp index 11b7696bae..124ec906b1 100644 --- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp @@ -65,10 +65,12 @@ void CMakeLocatorFilter::prepareSearch(const QString &entry) if (!cmakeProject) continue; foreach (const QString &title, cmakeProject->buildTargetTitles()) { - if (title.contains(entry)) { - Core::LocatorFilterEntry entry(this, title, cmakeProject->projectFilePath().toString()); - entry.extraInfo = FileUtils::shortNativePath(cmakeProject->projectFilePath()); - m_result.append(entry); + const int index = title.indexOf(entry); + if (index >= 0) { + Core::LocatorFilterEntry filterEntry(this, title, cmakeProject->projectFilePath().toString()); + filterEntry.extraInfo = FileUtils::shortNativePath(cmakeProject->projectFilePath()); + filterEntry.highlightInfo = {index, entry.length()}; + m_result.append(filterEntry); } } } diff --git a/src/plugins/coreplugin/locator/basefilefilter.cpp b/src/plugins/coreplugin/locator/basefilefilter.cpp index 7562a76d76..df624793dd 100644 --- a/src/plugins/coreplugin/locator/basefilefilter.cpp +++ b/src/plugins/coreplugin/locator/basefilefilter.cpp @@ -98,18 +98,18 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<LocatorFil { QList<LocatorFilterEntry> betterEntries; QList<LocatorFilterEntry> goodEntries; - const QString trimmed = trimWildcards(QDir::fromNativeSeparators(origEntry)); - const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(trimmed); - QStringMatcher matcher(fp.filePath, Qt::CaseInsensitive); - const QChar asterisk = QLatin1Char('*'); - QRegExp regexp(asterisk + fp.filePath+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard); + const QString entry = QDir::fromNativeSeparators(origEntry); + const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(entry); + const Qt::CaseSensitivity cs = caseSensitivity(fp.filePath); + QStringMatcher matcher(fp.filePath, cs); + QRegExp regexp(fp.filePath, cs, QRegExp::Wildcard); if (!regexp.isValid()) { d->m_current.clear(); // free memory return betterEntries; } const QChar pathSeparator(QLatin1Char('/')); const bool hasPathSeparator = fp.filePath.contains(pathSeparator); - const bool hasWildcard = fp.filePath.contains(asterisk) || fp.filePath.contains(QLatin1Char('?')); + const bool hasWildcard = containsWildcard(fp.filePath); const bool containsPreviousEntry = !d->m_current.previousEntry.isEmpty() && fp.filePath.contains(d->m_current.previousEntry); const bool pathSeparatorAdded = !d->m_current.previousEntry.contains(pathSeparator) @@ -124,7 +124,6 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<LocatorFil d->m_current.previousResultPaths.clear(); d->m_current.previousResultNames.clear(); d->m_current.previousEntry = fp.filePath; - const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(fp.filePath); d->m_current.iterator->toFront(); bool canceled = false; while (d->m_current.iterator->hasNext()) { @@ -137,16 +136,32 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<LocatorFil QString path = d->m_current.iterator->filePath(); QString name = d->m_current.iterator->fileName(); QString matchText = hasPathSeparator ? path : name; - if ((hasWildcard && regexp.exactMatch(matchText)) - || (!hasWildcard && matcher.indexIn(matchText) != -1)) { + int index = hasWildcard ? regexp.indexIn(matchText) : matcher.indexIn(matchText); + + if (index >= 0) { QFileInfo fi(path); - LocatorFilterEntry entry(this, fi.fileName(), QString(path + fp.postfix)); - entry.extraInfo = FileUtils::shortNativePath(FileName(fi)); - entry.fileName = path; - if (matchText.startsWith(fp.filePath, caseSensitivityForPrefix)) - betterEntries.append(entry); + LocatorFilterEntry filterEntry(this, fi.fileName(), QString(path + fp.postfix)); + filterEntry.fileName = path; + filterEntry.extraInfo = FileUtils::shortNativePath(FileName(fi)); + + LocatorFilterEntry::HighlightInfo::DataType hDataType = LocatorFilterEntry::HighlightInfo::DisplayName; + int length = hasWildcard ? regexp.matchedLength() : fp.filePath.length(); + const bool betterMatch = index == 0; + if (hasPathSeparator) { + const int indexCandidate = index + filterEntry.extraInfo.length() - path.length(); + const int cutOff = indexCandidate < 0 ? -indexCandidate : 0; + index = qMax(indexCandidate, 0); + length = qMax(length - cutOff, 1); + hDataType = LocatorFilterEntry::HighlightInfo::ExtraInfo; + } + + if (index >= 0) + filterEntry.highlightInfo = LocatorFilterEntry::HighlightInfo(index, length, hDataType); + + if (betterMatch) + betterEntries.append(filterEntry); else - goodEntries.append(entry); + goodEntries.append(filterEntry); d->m_current.previousResultPaths.append(path); d->m_current.previousResultNames.append(name); } diff --git a/src/plugins/coreplugin/locator/commandlocator.cpp b/src/plugins/coreplugin/locator/commandlocator.cpp index 37d1fe2739..14e57ad017 100644 --- a/src/plugins/coreplugin/locator/commandlocator.cpp +++ b/src/plugins/coreplugin/locator/commandlocator.cpp @@ -67,20 +67,27 @@ QList<LocatorFilterEntry> CommandLocator::matchesFor(QFutureInterface<LocatorFil // Get active, enabled actions matching text, store in list. // Reference via index in extraInfo. const QChar ampersand = QLatin1Char('&'); - const Qt::CaseSensitivity caseSensitivity_ = caseSensitivity(entry); + const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(entry); const int count = d->commands.size(); for (int i = 0; i < count; i++) { if (future.isCanceled()) break; - if (d->commands.at(i)->isActive()) { - if (QAction *action = d->commands.at(i)->action()) - if (action->isEnabled()) { - QString text = action->text(); - text.remove(ampersand); - if (text.startsWith(entry, caseSensitivity_)) - betterEntries.append(LocatorFilterEntry(this, text, QVariant(i))); - else if (text.contains(entry, caseSensitivity_)) - goodEntries.append(LocatorFilterEntry(this, text, QVariant(i))); + if (!d->commands.at(i)->isActive()) + continue; + + QAction *action = d->commands.at(i)->action(); + if (action && action->isEnabled()) { + QString text = action->text(); + text.remove(ampersand); + const int index = text.indexOf(entry, 0, entryCaseSensitivity); + if (index >= 0) { + LocatorFilterEntry filterEntry(this, text, QVariant(i)); + filterEntry.highlightInfo = {index, entry.length()}; + + if (index == 0) + betterEntries.append(filterEntry); + else + goodEntries.append(filterEntry); } } } diff --git a/src/plugins/coreplugin/locator/executefilter.cpp b/src/plugins/coreplugin/locator/executefilter.cpp index ce0636fe6b..d46550a569 100644 --- a/src/plugins/coreplugin/locator/executefilter.cpp +++ b/src/plugins/coreplugin/locator/executefilter.cpp @@ -60,16 +60,20 @@ QList<LocatorFilterEntry> ExecuteFilter::matchesFor(QFutureInterface<LocatorFilt if (!entry.isEmpty()) // avoid empty entry value.append(LocatorFilterEntry(this, entry, QVariant())); QList<LocatorFilterEntry> others; - const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry); - foreach (const QString &i, m_commandHistory) { + const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(entry); + foreach (const QString &cmd, m_commandHistory) { if (future.isCanceled()) break; - if (i == entry) // avoid repeated entry + if (cmd == entry) // avoid repeated entry continue; - if (i.startsWith(entry, caseSensitivityForPrefix)) - value.append(LocatorFilterEntry(this, i, QVariant())); - else - others.append(LocatorFilterEntry(this, i, QVariant())); + LocatorFilterEntry filterEntry(this, cmd, QVariant()); + const int index = cmd.indexOf(entry, 0, entryCaseSensitivity); + if (index >= 0) { + filterEntry.highlightInfo = {index, entry.length()}; + value.append(filterEntry); + } else { + others.append(filterEntry); + } } value.append(others); return value; diff --git a/src/plugins/coreplugin/locator/externaltoolsfilter.cpp b/src/plugins/coreplugin/locator/externaltoolsfilter.cpp index 69dfe6c670..7307473168 100644 --- a/src/plugins/coreplugin/locator/externaltoolsfilter.cpp +++ b/src/plugins/coreplugin/locator/externaltoolsfilter.cpp @@ -64,17 +64,23 @@ void ExternalToolsFilter::refresh(QFutureInterface<void> &) void ExternalToolsFilter::prepareSearch(const QString &entry) { m_results.clear(); - - Qt::CaseSensitivity useCaseSensitivity = caseSensitivity(entry); + const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(entry); const QMap<QString, ExternalTool *> externalToolsById = ExternalToolManager::toolsById(); auto end = externalToolsById.cend(); for (auto it = externalToolsById.cbegin(); it != end; ++it) { ExternalTool *tool = *it; - if (tool->description().contains(entry, useCaseSensitivity) || - tool->displayName().contains(entry, useCaseSensitivity)) { + int index = tool->displayName().indexOf(entry, 0, entryCaseSensitivity); + LocatorFilterEntry::HighlightInfo::DataType hDataType = LocatorFilterEntry::HighlightInfo::DisplayName; + if (index < 0) { + index = tool->description().indexOf(entry, 0, entryCaseSensitivity); + hDataType = LocatorFilterEntry::HighlightInfo::ExtraInfo; + } + + if (index >= 0) { LocatorFilterEntry filterEntry(this, tool->displayName(), QVariant::fromValue(tool)); filterEntry.extraInfo = tool->description(); + filterEntry.highlightInfo = LocatorFilterEntry::HighlightInfo(index, entry.length(), hDataType); m_results.append(filterEntry); } } diff --git a/src/plugins/coreplugin/locator/filesystemfilter.cpp b/src/plugins/coreplugin/locator/filesystemfilter.cpp index fcfb0415b2..14014cda2e 100644 --- a/src/plugins/coreplugin/locator/filesystemfilter.cpp +++ b/src/plugins/coreplugin/locator/filesystemfilter.cpp @@ -41,11 +41,16 @@ namespace { QList<LocatorFilterEntry> *categorize(const QString &entry, const QString &candidate, Qt::CaseSensitivity caseSensitivity, - QList<LocatorFilterEntry> *betterEntries, QList<LocatorFilterEntry> *goodEntries) + QList<LocatorFilterEntry> *betterEntries, QList<LocatorFilterEntry> *goodEntries, + int *index) { - if (entry.isEmpty() || candidate.startsWith(entry, caseSensitivity)) + const int position = candidate.indexOf(entry, 0, caseSensitivity); + if (index) + *index = position; + + if (entry.isEmpty() || position == 0) return betterEntries; - else if (candidate.contains(entry, caseSensitivity)) + else if (position >= 0) return goodEntries; return 0; } @@ -99,11 +104,15 @@ QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorF foreach (const QString &dir, dirs) { if (future.isCanceled()) break; - if (QList<LocatorFilterEntry> *category = categorize(entryFileName, dir, caseSensitivity_, &betterEntries, - &goodEntries)) { + int index = -1; + if (QList<LocatorFilterEntry> *category = categorize(entryFileName, dir, caseSensitivity_, + &betterEntries, &goodEntries, &index)) { const QString fullPath = dirInfo.filePath(dir); LocatorFilterEntry filterEntry(this, dir, QVariant()); filterEntry.fileName = fullPath; + if (index >= 0) + filterEntry.highlightInfo = {index, entryFileName.length()}; + category->append(filterEntry); } } @@ -113,11 +122,15 @@ QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorF foreach (const QString &file, files) { if (future.isCanceled()) break; - if (QList<LocatorFilterEntry> *category = categorize(fileName, file, caseSensitivity_, &betterEntries, - &goodEntries)) { + int index = -1; + if (QList<LocatorFilterEntry> *category = categorize(fileName, file, caseSensitivity_, + &betterEntries, &goodEntries, &index)) { const QString fullPath = dirInfo.filePath(file); LocatorFilterEntry filterEntry(this, file, QString(fullPath + fp.postfix)); filterEntry.fileName = fullPath; + if (index >= 0) + filterEntry.highlightInfo = {index, fileName.length()}; + category->append(filterEntry); } } diff --git a/src/plugins/coreplugin/locator/ilocatorfilter.cpp b/src/plugins/coreplugin/locator/ilocatorfilter.cpp index aabc2d43ba..ea1ca929bf 100644 --- a/src/plugins/coreplugin/locator/ilocatorfilter.cpp +++ b/src/plugins/coreplugin/locator/ilocatorfilter.cpp @@ -118,27 +118,16 @@ bool ILocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) return false; } -QString ILocatorFilter::trimWildcards(const QString &str) -{ - if (str.isEmpty()) - return str; - int first = 0, last = str.size() - 1; - const QChar asterisk = QLatin1Char('*'); - const QChar question = QLatin1Char('?'); - while (first < str.size() && (str.at(first) == asterisk || str.at(first) == question)) - ++first; - while (last >= 0 && (str.at(last) == asterisk || str.at(last) == question)) - --last; - if (first > last) - return QString(); - return str.mid(first, last - first + 1); -} - Qt::CaseSensitivity ILocatorFilter::caseSensitivity(const QString &str) { return str == str.toLower() ? Qt::CaseInsensitive : Qt::CaseSensitive; } +bool ILocatorFilter::containsWildcard(const QString &str) +{ + return str.contains(QLatin1Char('*')) || str.contains(QLatin1Char('?')); +} + QString ILocatorFilter::msgConfigureDialogTitle() { return tr("Filter Configuration"); diff --git a/src/plugins/coreplugin/locator/ilocatorfilter.h b/src/plugins/coreplugin/locator/ilocatorfilter.h index c50bdf2217..bb2fa00001 100644 --- a/src/plugins/coreplugin/locator/ilocatorfilter.h +++ b/src/plugins/coreplugin/locator/ilocatorfilter.h @@ -37,6 +37,23 @@ class ILocatorFilter; struct LocatorFilterEntry { + struct HighlightInfo { + enum DataType { + DisplayName, + ExtraInfo + }; + + HighlightInfo(int startIndex, int length, DataType type = DataType::DisplayName) + : startIndex(startIndex) + , length(length) + , dataType(type) + {} + + int startIndex; + int length; + DataType dataType; + }; + LocatorFilterEntry() = default; LocatorFilterEntry(ILocatorFilter *fromFilter, const QString &name, const QVariant &data, @@ -67,6 +84,14 @@ struct LocatorFilterEntry QString fileName; /* internal */ bool fileIconResolved = false; + /* highlighting support */ + HighlightInfo highlightInfo{0, 0}; + + static bool compareLexigraphically(const Core::LocatorFilterEntry &lhs, + const Core::LocatorFilterEntry &rhs) + { + return lhs.displayName < rhs.displayName; + } }; class CORE_EXPORT ILocatorFilter : public QObject @@ -134,8 +159,8 @@ public: /* Returns whether the filter should be enabled and used in menus. */ bool isEnabled() const; - static QString trimWildcards(const QString &str); static Qt::CaseSensitivity caseSensitivity(const QString &str); + static bool containsWildcard(const QString &str); static QString msgConfigureDialogTitle(); static QString msgPrefixLabel(); diff --git a/src/plugins/coreplugin/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp index 8169cff3c0..e85bdf30df 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.cpp +++ b/src/plugins/coreplugin/locator/locatorwidget.cpp @@ -33,6 +33,8 @@ #include <coreplugin/modemanager.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/fileiconprovider.h> +#include <coreplugin/find/searchresulttreeitemdelegate.h> +#include <coreplugin/find/searchresulttreeitemroles.h> #include <coreplugin/icontext.h> #include <coreplugin/mainwindow.h> #include <utils/algorithm.h> @@ -69,8 +71,16 @@ namespace Internal { class LocatorModel : public QAbstractListModel { public: + + enum Columns { + DisplayNameColumn, + ExtraInfoColumn, + ColumnCount + }; + LocatorModel(QObject *parent = 0) : QAbstractListModel(parent) + , mBackgroundColor(Utils::creatorTheme()->color(Utils::Theme::TextColorHighlightBackground).name()) {} void clear(); @@ -83,6 +93,7 @@ public: private: mutable QList<LocatorFilterEntry> mEntries; bool hasExtraInfo = false; + QColor mBackgroundColor; }; class CompletionList : public QTreeView @@ -144,7 +155,7 @@ int LocatorModel::columnCount(const QModelIndex &parent) const { if (parent.isValid()) return 0; - return hasExtraInfo ? 2 : 1; + return hasExtraInfo ? ColumnCount : 1; } QVariant LocatorModel::data(const QModelIndex &index, int role) const @@ -154,9 +165,9 @@ QVariant LocatorModel::data(const QModelIndex &index, int role) const switch (role) { case Qt::DisplayRole: - if (index.column() == 0) + if (index.column() == DisplayNameColumn) return mEntries.at(index.row()).displayName; - else if (index.column() == 1) + else if (index.column() == ExtraInfoColumn) return mEntries.at(index.row()).extraInfo; break; case Qt::ToolTipRole: @@ -167,7 +178,8 @@ QVariant LocatorModel::data(const QModelIndex &index, int role) const + QLatin1String("\n\n") + mEntries.at(index.row()).extraInfo); break; case Qt::DecorationRole: - if (index.column() == 0) { + case ItemDataRoles::ResultIconRole: + if (index.column() == DisplayNameColumn) { LocatorFilterEntry &entry = mEntries[index.row()]; if (!entry.fileIconResolved && !entry.fileName.isEmpty() && entry.displayIcon.isNull()) { entry.fileIconResolved = true; @@ -177,11 +189,25 @@ QVariant LocatorModel::data(const QModelIndex &index, int role) const } break; case Qt::ForegroundRole: - if (index.column() == 1) + if (index.column() == ExtraInfoColumn) return QColor(Qt::darkGray); break; - case Qt::UserRole: + case ItemDataRoles::ResultItemRole: return qVariantFromValue(mEntries.at(index.row())); + case ItemDataRoles::ResultBeginColumnNumberRole: + case ItemDataRoles::SearchTermLengthRole: { + LocatorFilterEntry &entry = mEntries[index.row()]; + const int highlightColumn = entry.highlightInfo.dataType == LocatorFilterEntry::HighlightInfo::DisplayName + ? DisplayNameColumn + : ExtraInfoColumn; + if (highlightColumn == index.column()) { + const bool startIndexRole = role == ItemDataRoles::ResultBeginColumnNumberRole; + return startIndexRole ? entry.highlightInfo.startIndex : entry.highlightInfo.length; + } + break; + } + case ItemDataRoles::ResultHighlightBackgroundColor: + return mBackgroundColor; } return QVariant(); @@ -202,6 +228,7 @@ void LocatorModel::addEntries(const QList<LocatorFilterEntry> &entries) CompletionList::CompletionList(QWidget *parent) : QTreeView(parent) { + setItemDelegate(new SearchResultTreeItemDelegate(0, this)); setRootIsDecorated(false); setUniformRowHeights(true); header()->hide(); @@ -611,9 +638,10 @@ void LocatorWidget::acceptCurrentEntry() const QModelIndex index = m_completionList->currentIndex(); if (!index.isValid()) return; - const LocatorFilterEntry entry = m_locatorModel->data(index, Qt::UserRole).value<LocatorFilterEntry>(); + const LocatorFilterEntry entry = m_locatorModel->data(index, ItemDataRoles::ResultItemRole).value<LocatorFilterEntry>(); m_completionList->hide(); m_fileLineEdit->clearFocus(); + Q_ASSERT(entry.filter != nullptr); entry.filter->accept(entry); } diff --git a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp index 73c3c2dc40..d6bfcab4ef 100644 --- a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp +++ b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp @@ -55,19 +55,16 @@ OpenDocumentsFilter::OpenDocumentsFilter() this, &OpenDocumentsFilter::refreshInternally); } -QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, const QString &entry) +QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, + const QString &entry) { QList<LocatorFilterEntry> goodEntries; QList<LocatorFilterEntry> betterEntries; const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(entry); - const QChar asterisk = QLatin1Char('*'); - QString pattern = QString(asterisk); - pattern += fp.filePath; - pattern += asterisk; - QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp regexp(fp.filePath, caseSensitivity(fp.filePath), QRegExp::Wildcard); if (!regexp.isValid()) return goodEntries; - const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(fp.filePath); + foreach (const Entry &editorEntry, editors()) { if (future.isCanceled()) break; @@ -75,13 +72,16 @@ QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locat if (fileName.isEmpty()) continue; QString displayName = editorEntry.displayName; - if (regexp.exactMatch(displayName)) { - LocatorFilterEntry fiEntry(this, displayName, QString(fileName + fp.postfix)); - fiEntry.extraInfo = FileUtils::shortNativePath(FileName::fromString(fileName)); - fiEntry.fileName = fileName; - QList<LocatorFilterEntry> &category = displayName.startsWith(fp.filePath, caseSensitivityForPrefix) - ? betterEntries : goodEntries; - category.append(fiEntry); + const int index = regexp.indexIn(displayName); + if (index >= 0) { + LocatorFilterEntry filterEntry(this, displayName, QString(fileName + fp.postfix)); + filterEntry.extraInfo = FileUtils::shortNativePath(FileName::fromString(fileName)); + filterEntry.fileName = fileName; + filterEntry.highlightInfo = {index, regexp.matchedLength()}; + if (index == 0) + betterEntries.append(filterEntry); + else + goodEntries.append(filterEntry); } } betterEntries.append(goodEntries); diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp index 964720e7a9..537dcc6da8 100644 --- a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp +++ b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp @@ -62,18 +62,16 @@ CppCurrentDocumentFilter::CppCurrentDocumentFilter(CppTools::CppModelManager *ma } QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor( - QFutureInterface<Core::LocatorFilterEntry> &future, const QString & origEntry) + QFutureInterface<Core::LocatorFilterEntry> &future, const QString & entry) { - QString entry = trimWildcards(origEntry); QList<Core::LocatorFilterEntry> goodEntries; QList<Core::LocatorFilterEntry> betterEntries; - QStringMatcher matcher(entry, Qt::CaseInsensitive); - const QChar asterisk = QLatin1Char('*'); - QRegExp regexp(asterisk + entry + asterisk, Qt::CaseInsensitive, QRegExp::Wildcard); + const Qt::CaseSensitivity cs = caseSensitivity(entry); + QStringMatcher matcher(entry, cs); + QRegExp regexp(entry, cs, QRegExp::Wildcard); if (!regexp.isValid()) return goodEntries; - bool hasWildcard = (entry.contains(asterisk) || entry.contains(QLatin1Char('?'))); - const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry); + bool hasWildcard = containsWildcard(entry); foreach (IndexItem::Ptr info, itemsOfCurrentDocument()) { if (future.isCanceled()) @@ -85,20 +83,30 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor( else if (info->type() == IndexItem::Function) matchString += info->symbolType(); - if ((hasWildcard && regexp.exactMatch(matchString)) - || (!hasWildcard && matcher.indexIn(matchString) != -1)) - { + int index = hasWildcard ? regexp.indexIn(matchString) : matcher.indexIn(matchString); + if (index >= 0) { + const bool betterMatch = index == 0; QVariant id = qVariantFromValue(info); QString name = matchString; QString extraInfo = info->symbolScope(); if (info->type() == IndexItem::Function) { - if (info->unqualifiedNameAndScope(matchString, &name, &extraInfo)) + if (info->unqualifiedNameAndScope(matchString, &name, &extraInfo)) { name += info->symbolType(); + index = hasWildcard ? regexp.indexIn(name) : matcher.indexIn(name); + } } + Core::LocatorFilterEntry filterEntry(this, name, id, info->icon()); filterEntry.extraInfo = extraInfo; - - if (matchString.startsWith(entry, caseSensitivityForPrefix)) + if (index < 0) { + index = hasWildcard ? regexp.indexIn(extraInfo) : matcher.indexIn(extraInfo); + filterEntry.highlightInfo.dataType = Core::LocatorFilterEntry::HighlightInfo::ExtraInfo; + } + if (index >= 0) { + filterEntry.highlightInfo.startIndex = index; + filterEntry.highlightInfo.length = hasWildcard ? regexp.matchedLength() : entry.length(); + } + if (betterMatch) betterEntries.append(filterEntry); else goodEntries.append(filterEntry); diff --git a/src/plugins/cpptools/cpplocatorfilter.cpp b/src/plugins/cpptools/cpplocatorfilter.cpp index e18a1a4c57..084c4d5479 100644 --- a/src/plugins/cpptools/cpplocatorfilter.cpp +++ b/src/plugins/cpptools/cpplocatorfilter.cpp @@ -27,6 +27,7 @@ #include "cppmodelmanager.h" #include <coreplugin/editormanager/editormanager.h> +#include <utils/algorithm.h> #include <QRegExp> #include <QStringMatcher> @@ -66,26 +67,18 @@ void CppLocatorFilter::refresh(QFutureInterface<void> &future) Q_UNUSED(future) } -static bool compareLexigraphically(const Core::LocatorFilterEntry &a, - const Core::LocatorFilterEntry &b) -{ - return a.displayName < b.displayName; -} - QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor( - QFutureInterface<Core::LocatorFilterEntry> &future, const QString &origEntry) + QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry) { - QString entry = trimWildcards(origEntry); QList<Core::LocatorFilterEntry> goodEntries; QList<Core::LocatorFilterEntry> betterEntries; - const QChar asterisk = QLatin1Char('*'); - QStringMatcher matcher(entry, Qt::CaseInsensitive); - QRegExp regexp(asterisk + entry+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard); + const Qt::CaseSensitivity cs = caseSensitivity(entry); + QStringMatcher matcher(entry, cs); + QRegExp regexp(entry, cs, QRegExp::Wildcard); if (!regexp.isValid()) return goodEntries; - bool hasWildcard = (entry.contains(asterisk) || entry.contains(QLatin1Char('?'))); + bool hasWildcard = containsWildcard(entry); bool hasColonColon = entry.contains(QLatin1String("::")); - const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry); const IndexItem::ItemType wanted = matchTypes(); m_data->filterAllFiles([&](const IndexItem::Ptr &info) -> IndexItem::VisitorResult { @@ -93,10 +86,20 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor( return IndexItem::Break; if (info->type() & wanted) { const QString matchString = hasColonColon ? info->scopedSymbolName() : info->symbolName(); - if ((hasWildcard && regexp.exactMatch(matchString)) || - (!hasWildcard && matcher.indexIn(matchString) != -1)) { - const Core::LocatorFilterEntry filterEntry = filterEntryFromIndexItem(info); - if (matchString.startsWith(entry, caseSensitivityForPrefix)) + int index = hasWildcard ? regexp.indexIn(matchString) : matcher.indexIn(matchString); + if (index >= 0) { + const bool betterMatch = index == 0; + Core::LocatorFilterEntry filterEntry = filterEntryFromIndexItem(info); + + if (matchString != filterEntry.displayName) { + index = hasWildcard ? regexp.indexIn(filterEntry.displayName) + : matcher.indexIn(filterEntry.displayName); + } + + if (index >= 0) + filterEntry.highlightInfo = {index, (hasWildcard ? regexp.matchedLength() : entry.length())}; + + if (betterMatch) betterEntries.append(filterEntry); else goodEntries.append(filterEntry); @@ -110,9 +113,9 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor( }); if (goodEntries.size() < 1000) - std::stable_sort(goodEntries.begin(), goodEntries.end(), compareLexigraphically); + Utils::sort(goodEntries, Core::LocatorFilterEntry::compareLexigraphically); if (betterEntries.size() < 1000) - std::stable_sort(betterEntries.begin(), betterEntries.end(), compareLexigraphically); + Utils::sort(betterEntries, Core::LocatorFilterEntry::compareLexigraphically); betterEntries += goodEntries; return betterEntries; diff --git a/src/plugins/debugger/console/consoleitemdelegate.cpp b/src/plugins/debugger/console/consoleitemdelegate.cpp index c2e2f1627d..4fdb01b036 100644 --- a/src/plugins/debugger/console/consoleitemdelegate.cpp +++ b/src/plugins/debugger/console/consoleitemdelegate.cpp @@ -29,6 +29,7 @@ #include <coreplugin/coreconstants.h> #include <utils/utilsicons.h> +#include <utils/theme/theme.h> #include <QPainter> #include <QTreeView> @@ -36,23 +37,6 @@ #include <QTextLayout> #include <QUrl> -const char CONSOLE_LOG_BACKGROUND_COLOR[] = "#E8EEF2"; -const char CONSOLE_WARNING_BACKGROUND_COLOR[] = "#F6F4EB"; -const char CONSOLE_ERROR_BACKGROUND_COLOR[] = "#F6EBE7"; -const char CONSOLE_EDITOR_BACKGROUND_COLOR[] = "#F7F7F7"; - -const char CONSOLE_LOG_BACKGROUND_SELECTED_COLOR[] = "#CDDEEA"; -const char CONSOLE_WARNING_BACKGROUND_SELECTED_COLOR[] = "#F3EED1"; -const char CONSOLE_ERROR_BACKGROUND_SELECTED_COLOR[] = "#F5D4CB"; -const char CONSOLE_EDITOR_BACKGROUND_SELECTED_COLOR[] = "#DEDEDE"; - -const char CONSOLE_LOG_TEXT_COLOR[] = "#333333"; -const char CONSOLE_WARNING_TEXT_COLOR[] = "#666666"; -const char CONSOLE_ERROR_TEXT_COLOR[] = "#1D5B93"; -const char CONSOLE_EDITOR_TEXT_COLOR[] = "#000000"; - -const char CONSOLE_BORDER_COLOR[] = "#C9C9C9"; - const int ELLIPSIS_GRADIENT_WIDTH = 16; namespace Debugger { @@ -72,7 +56,8 @@ ConsoleItemDelegate::ConsoleItemDelegate(ConsoleItemModel *model, QObject *paren m_errorIcon(Utils::Icons::CRITICAL.icon()), m_expandIcon(Utils::Icons::EXPAND.icon()), m_collapseIcon(Utils::Icons::COLLAPSE.icon()), - m_prompt(QLatin1String(":/qmljstools/images/prompt.png")), + m_prompt(Utils::Icon({{QLatin1String(":/utils/images/next.png"), + Utils::Theme::TextColorNormal}}, Utils::Icon::Tint).icon()), m_cachedHeight(0) { } @@ -86,39 +71,15 @@ QColor ConsoleItemDelegate::drawBackground(QPainter *painter, const QRect &rect, const QModelIndex &index, bool selected) const { + const Utils::Theme *theme = Utils::creatorTheme(); painter->save(); - ConsoleItem::ItemType itemType = (ConsoleItem::ItemType)index.data( - ConsoleItem::TypeRole).toInt(); - QColor backgroundColor; - switch (itemType) { - case ConsoleItem::DebugType: - backgroundColor = selected ? QColor(CONSOLE_LOG_BACKGROUND_SELECTED_COLOR) : - QColor(CONSOLE_LOG_BACKGROUND_COLOR); - break; - case ConsoleItem::WarningType: - backgroundColor = selected ? QColor(CONSOLE_WARNING_BACKGROUND_SELECTED_COLOR) : - QColor(CONSOLE_WARNING_BACKGROUND_COLOR); - break; - case ConsoleItem::ErrorType: - backgroundColor = selected ? QColor(CONSOLE_ERROR_BACKGROUND_SELECTED_COLOR) : - QColor(CONSOLE_ERROR_BACKGROUND_COLOR); - break; - case ConsoleItem::InputType: - default: - backgroundColor = selected ? QColor(CONSOLE_EDITOR_BACKGROUND_SELECTED_COLOR) : - QColor(CONSOLE_EDITOR_BACKGROUND_COLOR); - break; - } + QColor backgroundColor = theme->color(selected + ? Utils::Theme::BackgroundColorSelected + : Utils::Theme::BackgroundColorNormal); if (!(index.flags() & Qt::ItemIsEditable)) painter->setBrush(backgroundColor); painter->setPen(Qt::NoPen); painter->drawRect(rect); - - // Separator lines - painter->setPen(QColor(CONSOLE_BORDER_COLOR)); - if (!(index.flags() & Qt::ItemIsEditable)) - painter->drawLine(0, rect.bottom(), rect.right(), - rect.bottom()); painter->restore(); return backgroundColor; } @@ -126,6 +87,7 @@ QColor ConsoleItemDelegate::drawBackground(QPainter *painter, const QRect &rect, void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { + const Utils::Theme *theme = Utils::creatorTheme(); QStyleOptionViewItem opt = option; initStyleOption(&opt, index); painter->save(); @@ -137,23 +99,23 @@ void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o ConsoleItem::TypeRole).toInt(); switch (type) { case ConsoleItem::DebugType: - textColor = QColor(CONSOLE_LOG_TEXT_COLOR); + textColor = theme->color(Utils::Theme::OutputPanes_NormalMessageTextColor); taskIcon = m_logIcon; break; case ConsoleItem::WarningType: - textColor = QColor(CONSOLE_WARNING_TEXT_COLOR); + textColor = theme->color(Utils::Theme::OutputPanes_WarningMessageTextColor); taskIcon = m_warningIcon; break; case ConsoleItem::ErrorType: - textColor = QColor(CONSOLE_ERROR_TEXT_COLOR); + textColor = theme->color(Utils::Theme::OutputPanes_ErrorMessageTextColor); taskIcon = m_errorIcon; break; case ConsoleItem::InputType: - textColor = QColor(CONSOLE_EDITOR_TEXT_COLOR); + textColor = theme->color(Utils::Theme::TextColorNormal); taskIcon = m_prompt; break; default: - textColor = QColor(CONSOLE_EDITOR_TEXT_COLOR); + textColor = theme->color(Utils::Theme::TextColorNormal); break; } @@ -307,18 +269,11 @@ QWidget *ConsoleItemDelegate::createEditor(QWidget *parent, { ConsoleEdit *editor = new ConsoleEdit(index, parent); - // Fiddle the prompt into the margin so that we don't have to put it into the text. - // Apparently you can have both background-image and background-color, which conveniently - // prevents the painted text from shining through. + // Make the background transparent so that the prompt shines through editor->setStyleSheet(QLatin1String("QTextEdit {" "margin-left: 24px;" "margin-top: 4px;" - "color: black;" - "background-color: white;" - "background-image: url(:/qmljstools/images/prompt.png);" - "background-position: baseline left;" - "background-origin: margin;" - "background-repeat: none;" + "background-color: transparent;" "}")); connect(editor, &ConsoleEdit::editingFinished, this, [this, editor] { auto delegate = const_cast<ConsoleItemDelegate*>(this); diff --git a/src/plugins/debugger/console/consoleview.cpp b/src/plugins/debugger/console/consoleview.cpp index db80e9cee6..b3586ce6e5 100644 --- a/src/plugins/debugger/console/consoleview.cpp +++ b/src/plugins/debugger/console/consoleview.cpp @@ -97,9 +97,7 @@ ConsoleView::ConsoleView(ConsoleItemModel *model, QWidget *parent) : "QTreeView::branch:open:has-children:!has-siblings," "QTreeView::branch:open:has-children:has-siblings {" "border-image: none;" - "image: none; }" - "QTreeView {" - "background-color: white; }")); + "image: none; }")); QString baseName = QApplication::style()->objectName(); if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost() diff --git a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp index 1e2f38ea62..461232e4c8 100644 --- a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp +++ b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp @@ -30,11 +30,14 @@ #include "genericprojectconstants.h" #include <coreplugin/icore.h> + #include <projectexplorer/buildinfo.h> #include <projectexplorer/buildsteplist.h> #include <projectexplorer/kitinformation.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/target.h> #include <projectexplorer/toolchain.h> + #include <utils/mimetypes/mimedatabase.h> #include <utils/pathchooser.h> #include <utils/qtcassert.h> diff --git a/src/plugins/genericprojectmanager/genericmakestep.cpp b/src/plugins/genericprojectmanager/genericmakestep.cpp index 4046106eee..8569a994ef 100644 --- a/src/plugins/genericprojectmanager/genericmakestep.cpp +++ b/src/plugins/genericprojectmanager/genericmakestep.cpp @@ -29,15 +29,17 @@ #include "ui_genericmakestep.h" #include "genericbuildconfiguration.h" -#include <extensionsystem/pluginmanager.h> #include <projectexplorer/buildsteplist.h> #include <projectexplorer/gnumakeparser.h> #include <projectexplorer/kitinformation.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/target.h> #include <projectexplorer/toolchain.h> + #include <qtsupport/qtkitinformation.h> #include <qtsupport/qtparser.h> + #include <utils/stringutils.h> #include <utils/qtcassert.h> #include <utils/qtcprocess.h> diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index c8b14a125d..be174cae0d 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -32,11 +32,13 @@ #include <coreplugin/documentmanager.h> #include <coreplugin/icontext.h> #include <coreplugin/icore.h> +#include <coreplugin/idocument.h> + #include <cpptools/cpptoolsconstants.h> #include <cpptools/cppmodelmanager.h> #include <cpptools/projectinfo.h> #include <cpptools/cppprojectupdater.h> -#include <extensionsystem/pluginmanager.h> + #include <projectexplorer/abi.h> #include <projectexplorer/buildsteplist.h> #include <projectexplorer/customexecutablerunconfiguration.h> @@ -44,13 +46,20 @@ #include <projectexplorer/kitinformation.h> #include <projectexplorer/kitmanager.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/projectnodes.h> +#include <projectexplorer/target.h> + #include <qtsupport/baseqtversion.h> #include <qtsupport/qtkitinformation.h> + #include <utils/algorithm.h> #include <utils/fileutils.h> #include <utils/qtcassert.h> #include <QDir> +#include <QHash> +#include <QSet> +#include <QStringList> using namespace Core; using namespace ProjectExplorer; @@ -61,6 +70,89 @@ namespace Internal { //////////////////////////////////////////////////////////////////////////////////// // +// GenericProjectFile +// +//////////////////////////////////////////////////////////////////////////////////// + +class GenericProjectFile : public Core::IDocument +{ +public: + GenericProjectFile(GenericProject *parent, const FileName &fileName, + GenericProject::RefreshOptions options) : + m_project(parent), + m_options(options) + { + setId("Generic.ProjectFile"); + setMimeType(Constants::GENERICMIMETYPE); + setFilePath(fileName); + } + + ReloadBehavior reloadBehavior(ChangeTrigger, ChangeType) const final + { + return BehaviorSilent; + } + + bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override + { + Q_UNUSED(errorString); + Q_UNUSED(flag); + if (type == TypePermissions) + return true; + m_project->refresh(m_options); + return true; + } + +private: + GenericProject *m_project = nullptr; + GenericProject::RefreshOptions m_options; +}; + + +//////////////////////////////////////////////////////////////////////////////////// +// +// GenericProjectNode +// +//////////////////////////////////////////////////////////////////////////////////// + +class GenericProjectNode : public ProjectNode +{ +public: + explicit GenericProjectNode(GenericProject *project) : + ProjectNode(project->projectDirectory()), + m_project(project) + { + setDisplayName(project->projectFilePath().toFileInfo().completeBaseName()); + } + + bool showInSimpleTree() const override { return true; } + + QList<ProjectExplorer::ProjectAction> supportedActions(Node *) const override + { + return {AddNewFile, AddExistingFile, AddExistingDirectory, RemoveFile, Rename}; + } + + bool addFiles(const QStringList &filePaths, QStringList * = 0) override + { + return m_project->addFiles(filePaths); + } + + bool removeFiles(const QStringList &filePaths, QStringList * = 0) override + { + return m_project->removeFiles(filePaths); + } + + bool renameFile(const QString &filePath, const QString &newFilePath) override + { + return m_project->renameFile(filePath, newFilePath); + } + +private: + GenericProject *m_project = nullptr; +}; + + +//////////////////////////////////////////////////////////////////////////////////// +// // GenericProject // //////////////////////////////////////////////////////////////////////////////////// @@ -97,21 +189,6 @@ GenericProject::~GenericProject() delete m_cppCodeModelUpdater; } -QString GenericProject::filesFileName() const -{ - return m_filesFileName; -} - -QString GenericProject::includesFileName() const -{ - return m_includesFileName; -} - -QString GenericProject::configFileName() const -{ - return m_configFileName; -} - static QStringList readLines(const QString &absoluteFileName) { QStringList lines; @@ -134,7 +211,7 @@ static QStringList readLines(const QString &absoluteFileName) bool GenericProject::saveRawFileList(const QStringList &rawFileList) { - bool result = saveRawList(rawFileList, filesFileName()); + bool result = saveRawList(rawFileList, m_filesFileName); refresh(GenericProject::Files); return result; } @@ -168,7 +245,7 @@ bool GenericProject::addFiles(const QStringList &filePaths) for (const QString &filePath : filePaths) insertSorted(&newList, baseDir.relativeFilePath(filePath)); - const QSet<QString> includes = projectIncludePaths().toSet(); + const QSet<QString> includes = m_projectIncludePaths.toSet(); QSet<QString> toAdd; for (const QString &filePath : filePaths) { @@ -186,8 +263,8 @@ bool GenericProject::addFiles(const QStringList &filePaths) m_rawProjectIncludePaths.append(relative); } - bool result = saveRawList(newList, filesFileName()); - result &= saveRawList(m_rawProjectIncludePaths, includesFileName()); + bool result = saveRawList(newList, m_filesFileName); + result &= saveRawList(m_rawProjectIncludePaths, m_includesFileName); refresh(GenericProject::Everything); return result; @@ -238,12 +315,12 @@ void GenericProject::parseProject(RefreshOptions options) { if (options & Files) { m_rawListEntries.clear(); - m_rawFileList = readLines(filesFileName()); + m_rawFileList = readLines(m_filesFileName); m_files = processEntries(m_rawFileList, &m_rawListEntries); } if (options & Configuration) { - m_rawProjectIncludePaths = readLines(includesFileName()); + m_rawProjectIncludePaths = readLines(m_includesFileName); m_projectIncludePaths = processEntries(m_rawProjectIncludePaths); // TODO: Possibly load some configuration from the project file @@ -261,7 +338,7 @@ void GenericProject::refresh(RefreshOptions options) if (options & Files) { auto newRoot = new GenericProjectNode(this); - for (const QString &f : files()) { + for (const QString &f : m_files) { FileType fileType = FileType::Source; // ### FIXME if (f.endsWith(".qrc")) fileType = FileType::Resource; @@ -362,9 +439,9 @@ void GenericProject::refreshCppCodeModel() rpp.setDisplayName(displayName()); rpp.setProjectFileLocation(projectFilePath().toString()); rpp.setQtVersion(activeQtVersion); - rpp.setIncludePaths(projectIncludePaths()); - rpp.setConfigFileName(configFileName()); - rpp.setFiles(files()); + rpp.setIncludePaths(m_projectIncludePaths); + rpp.setConfigFileName(m_configFileName); + rpp.setFiles(m_files); const CppTools::ProjectUpdateInfo projectInfoUpdate(this, cToolChain, cxxToolChain, k, {rpp}); m_cppCodeModelUpdater->update(projectInfoUpdate); @@ -392,11 +469,6 @@ void GenericProject::activeBuildConfigurationWasChanged() refresh(Everything); } -QStringList GenericProject::projectIncludePaths() const -{ - return m_projectIncludePaths; -} - QStringList GenericProject::files() const { return m_files; @@ -455,38 +527,5 @@ Project::RestoreResult GenericProject::fromMap(const QVariantMap &map, QString * return RestoreResult::Ok; } -//////////////////////////////////////////////////////////////////////////////////// -// -// GenericProjectFile -// -//////////////////////////////////////////////////////////////////////////////////// - -GenericProjectFile::GenericProjectFile(GenericProject *parent, const Utils::FileName &fileName, - GenericProject::RefreshOptions options) : - m_project(parent), - m_options(options) -{ - setId("Generic.ProjectFile"); - setMimeType(Constants::GENERICMIMETYPE); - setFilePath(fileName); -} - -IDocument::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const -{ - Q_UNUSED(state); - Q_UNUSED(type); - return BehaviorSilent; -} - -bool GenericProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type) -{ - Q_UNUSED(errorString); - Q_UNUSED(flag); - if (type == TypePermissions) - return true; - m_project->refresh(m_options); - return true; -} - } // namespace Internal } // namespace GenericProjectManager diff --git a/src/plugins/genericprojectmanager/genericproject.h b/src/plugins/genericprojectmanager/genericproject.h index c63614ed6f..3b14c0b11d 100644 --- a/src/plugins/genericprojectmanager/genericproject.h +++ b/src/plugins/genericprojectmanager/genericproject.h @@ -25,16 +25,7 @@ #pragma once -#include "genericprojectnodes.h" - #include <projectexplorer/project.h> -#include <projectexplorer/projectnodes.h> -#include <projectexplorer/target.h> -#include <projectexplorer/toolchain.h> -#include <projectexplorer/buildconfiguration.h> -#include <coreplugin/idocument.h> - -#include <QFuture> namespace CppTools { class CppProjectUpdater; } @@ -51,10 +42,6 @@ public: explicit GenericProject(const Utils::FileName &filename); ~GenericProject() override; - QString filesFileName() const; - QString includesFileName() const; - QString configFileName() const; - QString displayName() const override; QStringList files(FilesMode fileMode) const override; @@ -74,7 +61,6 @@ public: void refresh(RefreshOptions options); - QStringList projectIncludePaths() const; QStringList files() const; protected: @@ -108,19 +94,5 @@ private: ProjectExplorer::Target *m_activeTarget = nullptr; }; -class GenericProjectFile : public Core::IDocument -{ -public: - GenericProjectFile(GenericProject *parent, const Utils::FileName &fileName, - GenericProject::RefreshOptions options); - - ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override; - bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; - -private: - GenericProject *m_project; - GenericProject::RefreshOptions m_options; -}; - } // namespace Internal } // namespace GenericProjectManager diff --git a/src/plugins/genericprojectmanager/genericprojectmanager.pro b/src/plugins/genericprojectmanager/genericprojectmanager.pro index b4a8cf0631..ba64569783 100644 --- a/src/plugins/genericprojectmanager/genericprojectmanager.pro +++ b/src/plugins/genericprojectmanager/genericprojectmanager.pro @@ -3,20 +3,20 @@ include(../../qtcreatorplugin.pri) HEADERS = genericproject.h \ genericprojectplugin.h \ genericprojectconstants.h \ - genericprojectnodes.h \ genericprojectwizard.h \ genericprojectfileseditor.h \ genericmakestep.h \ genericbuildconfiguration.h \ filesselectionwizardpage.h + SOURCES = genericproject.cpp \ genericprojectplugin.cpp \ - genericprojectnodes.cpp \ genericprojectwizard.cpp \ genericprojectfileseditor.cpp \ genericmakestep.cpp \ genericbuildconfiguration.cpp \ filesselectionwizardpage.cpp + FORMS += genericmakestep.ui equals(TEST, 1) { diff --git a/src/plugins/genericprojectmanager/genericprojectmanager.qbs b/src/plugins/genericprojectmanager/genericprojectmanager.qbs index 74fc022ec2..be30ddffad 100644 --- a/src/plugins/genericprojectmanager/genericprojectmanager.qbs +++ b/src/plugins/genericprojectmanager/genericprojectmanager.qbs @@ -30,8 +30,6 @@ QtcPlugin { "genericprojectconstants.h", "genericprojectfileseditor.cpp", "genericprojectfileseditor.h", - "genericprojectnodes.cpp", - "genericprojectnodes.h", "genericprojectplugin.cpp", "genericprojectplugin.h", "genericprojectwizard.cpp", diff --git a/src/plugins/genericprojectmanager/genericprojectnodes.cpp b/src/plugins/genericprojectmanager/genericprojectnodes.cpp deleted file mode 100644 index bdd7b71cdf..0000000000 --- a/src/plugins/genericprojectmanager/genericprojectnodes.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "genericprojectnodes.h" -#include "genericproject.h" - -#include <coreplugin/idocument.h> -#include <projectexplorer/projectexplorer.h> - -#include <utils/algorithm.h> -#include <utils/fileutils.h> - -#include <QFileInfo> - -using namespace ProjectExplorer; - -namespace GenericProjectManager { -namespace Internal { - -GenericProjectNode::GenericProjectNode(GenericProject *project) : - ProjectNode(project->projectDirectory()), - m_project(project) -{ - setDisplayName(project->projectFilePath().toFileInfo().completeBaseName()); -} - -QHash<QString, QStringList> sortFilesIntoPaths(const QString &base, const QSet<QString> &files) -{ - QHash<QString, QStringList> filesInPath; - const QDir baseDir(base); - - foreach (const QString &absoluteFileName, files) { - QFileInfo fileInfo(absoluteFileName); - Utils::FileName absoluteFilePath = Utils::FileName::fromString(fileInfo.path()); - QString relativeFilePath; - - if (absoluteFilePath.isChildOf(baseDir)) { - relativeFilePath = absoluteFilePath.relativeChildPath(Utils::FileName::fromString(base)).toString(); - } else { - // `file' is not part of the project. - relativeFilePath = baseDir.relativeFilePath(absoluteFilePath.toString()); - if (relativeFilePath.endsWith('/')) - relativeFilePath.chop(1); - } - - if (relativeFilePath == ".") - relativeFilePath.clear(); - - filesInPath[relativeFilePath].append(absoluteFileName); - } - return filesInPath; -} - -bool GenericProjectNode::showInSimpleTree() const -{ - return true; -} - -QList<ProjectAction> GenericProjectNode::supportedActions(Node *node) const -{ - Q_UNUSED(node); - return { - AddNewFile, - AddExistingFile, - AddExistingDirectory, - RemoveFile, - Rename - }; -} - -bool GenericProjectNode::addFiles(const QStringList &filePaths, QStringList *notAdded) -{ - Q_UNUSED(notAdded) - - return m_project->addFiles(filePaths); -} - -bool GenericProjectNode::removeFiles(const QStringList &filePaths, QStringList *notRemoved) -{ - Q_UNUSED(notRemoved) - - return m_project->removeFiles(filePaths); -} - -bool GenericProjectNode::renameFile(const QString &filePath, const QString &newFilePath) -{ - return m_project->renameFile(filePath, newFilePath); -} - -} // namespace Internal -} // namespace GenericProjectManager diff --git a/src/plugins/genericprojectmanager/genericprojectnodes.h b/src/plugins/genericprojectmanager/genericprojectnodes.h deleted file mode 100644 index 3c51d75fa4..0000000000 --- a/src/plugins/genericprojectmanager/genericprojectnodes.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <projectexplorer/projectnodes.h> - -#include <QStringList> -#include <QHash> -#include <QSet> - -namespace Core { class IDocument; } - -namespace GenericProjectManager { -namespace Internal { - -class GenericProject; - -class GenericProjectNode : public ProjectExplorer::ProjectNode -{ -public: - explicit GenericProjectNode(GenericProject *project); - - bool showInSimpleTree() const override; - - QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const override; - - bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0) override; - bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0) override; - bool renameFile(const QString &filePath, const QString &newFilePath) override; - -private: - GenericProject *const m_project; -}; - -} // namespace Internal -} // namespace GenericProjectManager diff --git a/src/plugins/help/helpindexfilter.cpp b/src/plugins/help/helpindexfilter.cpp index 8f12c34fb4..61bf3d76b3 100644 --- a/src/plugins/help/helpindexfilter.cpp +++ b/src/plugins/help/helpindexfilter.cpp @@ -127,8 +127,12 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi keywords << unsortedKeywords; m_keywordCache = allresults; m_searchTermCache = entry; - foreach (const QString &keyword, keywords) - entries.append(LocatorFilterEntry(this, keyword, QVariant(), m_icon)); + foreach (const QString &keyword, keywords) { + const int index = keyword.indexOf(entry, 0, cs); + LocatorFilterEntry filterEntry(this, keyword, QVariant(), m_icon); + filterEntry.highlightInfo = {index, entry.length()}; + entries.append(filterEntry); + } return entries; } diff --git a/src/plugins/help/remotehelpfilter.cpp b/src/plugins/help/remotehelpfilter.cpp index 43e32bd847..a88e6e2d2f 100644 --- a/src/plugins/help/remotehelpfilter.cpp +++ b/src/plugins/help/remotehelpfilter.cpp @@ -129,15 +129,16 @@ RemoteHelpFilter::~RemoteHelpFilter() { } -QList<Core::LocatorFilterEntry> RemoteHelpFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &pattern) +QList<Core::LocatorFilterEntry> RemoteHelpFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry) { QList<Core::LocatorFilterEntry> entries; foreach (const QString &url, remoteUrls()) { if (future.isCanceled()) break; - - entries.append(Core::LocatorFilterEntry(this, url.arg(pattern), QVariant(), - m_icon)); + const QString name = url.arg(entry); + Core::LocatorFilterEntry filterEntry(this, name, QVariant(), m_icon); + filterEntry.highlightInfo = {name.lastIndexOf(entry), entry.length()}; + entries.append(filterEntry); } return entries; } diff --git a/src/plugins/macros/macrolocatorfilter.cpp b/src/plugins/macros/macrolocatorfilter.cpp index 7f210f4178..a631eafd54 100644 --- a/src/plugins/macros/macrolocatorfilter.cpp +++ b/src/plugins/macros/macrolocatorfilter.cpp @@ -54,26 +54,32 @@ QList<Core::LocatorFilterEntry> MacroLocatorFilter::matchesFor(QFutureInterface< QList<Core::LocatorFilterEntry> goodEntries; QList<Core::LocatorFilterEntry> betterEntries; - const Qt::CaseSensitivity caseSensitivity_ = caseSensitivity(entry); + const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(entry); const QMap<QString, Macro*> ¯os = MacroManager::macros(); QMapIterator<QString, Macro*> it(macros); while (it.hasNext()) { it.next(); - QString name = it.key(); - - QList<Core::LocatorFilterEntry> *category = 0; - if (name.startsWith(entry, caseSensitivity_)) - category = &betterEntries; - else if (name.contains(entry, caseSensitivity_)) - category = &goodEntries; - - if (category) { - QVariant id; - Core::LocatorFilterEntry entry(this, it.key(), id, m_icon); - entry.extraInfo = it.value()->description(); - category->append(entry); + const QString displayName = it.key(); + const QString description = it.value()->description(); + + int index = displayName.indexOf(entry, 0, entryCaseSensitivity); + Core::LocatorFilterEntry::HighlightInfo::DataType hDataType = Core::LocatorFilterEntry::HighlightInfo::DisplayName; + if (index < 0) { + index = description.indexOf(entry, 0, entryCaseSensitivity); + hDataType = Core::LocatorFilterEntry::HighlightInfo::ExtraInfo; + } + + if (index >= 0) { + Core::LocatorFilterEntry filterEntry(this, displayName, QVariant(), m_icon); + filterEntry.extraInfo = description; + filterEntry.highlightInfo = Core::LocatorFilterEntry::HighlightInfo(index, entry.length(), hDataType); + + if (index == 0) + betterEntries.append(filterEntry); + else + goodEntries.append(filterEntry); } } betterEntries.append(goodEntries); diff --git a/src/plugins/qmljstools/images/prompt.png b/src/plugins/qmljstools/images/prompt.png Binary files differdeleted file mode 100644 index a333a87198..0000000000 --- a/src/plugins/qmljstools/images/prompt.png +++ /dev/null diff --git a/src/plugins/qmljstools/qmljsfunctionfilter.cpp b/src/plugins/qmljstools/qmljsfunctionfilter.cpp index d7c5979fd7..036ba1a314 100644 --- a/src/plugins/qmljstools/qmljsfunctionfilter.cpp +++ b/src/plugins/qmljstools/qmljsfunctionfilter.cpp @@ -53,24 +53,18 @@ void FunctionFilter::refresh(QFutureInterface<void> &) { } -static bool compareLexigraphically(const Core::LocatorFilterEntry &a, - const Core::LocatorFilterEntry &b) +QList<Core::LocatorFilterEntry> FunctionFilter::matchesFor( + QFutureInterface<Core::LocatorFilterEntry> &future, + const QString &entry) { - return a.displayName < b.displayName; -} - -QList<Core::LocatorFilterEntry> FunctionFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &origEntry) -{ - QString entry = trimWildcards(origEntry); QList<Core::LocatorFilterEntry> goodEntries; QList<Core::LocatorFilterEntry> betterEntries; - const QChar asterisk = QLatin1Char('*'); - QStringMatcher matcher(entry, Qt::CaseInsensitive); - QRegExp regexp(asterisk + entry+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard); + const Qt::CaseSensitivity cs = caseSensitivity(entry); + QStringMatcher matcher(entry, cs); + QRegExp regexp(entry, cs, QRegExp::Wildcard); if (!regexp.isValid()) return goodEntries; - bool hasWildcard = (entry.contains(asterisk) || entry.contains(QLatin1Char('?'))); - const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry); + bool hasWildcard = containsWildcard(entry); QHashIterator<QString, QList<LocatorData::Entry> > it(m_data->entries()); while (it.hasNext()) { @@ -83,14 +77,17 @@ QList<Core::LocatorFilterEntry> FunctionFilter::matchesFor(QFutureInterface<Core foreach (const LocatorData::Entry &info, items) { if (info.type != LocatorData::Function) continue; - if ((hasWildcard && regexp.exactMatch(info.symbolName)) - || (!hasWildcard && matcher.indexIn(info.symbolName) != -1)) { + const int index = hasWildcard ? regexp.indexIn(info.symbolName) + : matcher.indexIn(info.symbolName); + if (index >= 0) { QVariant id = qVariantFromValue(info); Core::LocatorFilterEntry filterEntry(this, info.displayName, id/*, info.icon*/); filterEntry.extraInfo = info.extraInfo; + const int length = hasWildcard ? regexp.matchedLength() : entry.length(); + filterEntry.highlightInfo = {index, length}; - if (info.symbolName.startsWith(entry, caseSensitivityForPrefix)) + if (index == 0) betterEntries.append(filterEntry); else goodEntries.append(filterEntry); @@ -99,9 +96,9 @@ QList<Core::LocatorFilterEntry> FunctionFilter::matchesFor(QFutureInterface<Core } if (goodEntries.size() < 1000) - Utils::sort(goodEntries, compareLexigraphically); + Utils::sort(goodEntries, Core::LocatorFilterEntry::compareLexigraphically); if (betterEntries.size() < 1000) - Utils::sort(betterEntries, compareLexigraphically); + Utils::sort(betterEntries, Core::LocatorFilterEntry::compareLexigraphically); betterEntries += goodEntries; return betterEntries; diff --git a/src/plugins/qmljstools/qmljstools.qrc b/src/plugins/qmljstools/qmljstools.qrc index 3c9877514d..d663b7c095 100644 --- a/src/plugins/qmljstools/qmljstools.qrc +++ b/src/plugins/qmljstools/qmljstools.qrc @@ -1,6 +1,5 @@ <RCC> <qresource prefix="/qmljstools"> <file>images/category_qml.png</file> - <file>images/prompt.png</file> </qresource> </RCC> diff --git a/src/plugins/todo/constants.h b/src/plugins/todo/constants.h index d597bc5c6f..13e141b7bc 100644 --- a/src/plugins/todo/constants.h +++ b/src/plugins/todo/constants.h @@ -31,13 +31,6 @@ namespace Todo { namespace Constants { -// Default todo item background colors -const char COLOR_TODO_BG[] = "#ccffcc"; -const char COLOR_WARNING_BG[] = "#ffffcc"; -const char COLOR_FIXME_BG[] = "#ffcccc"; -const char COLOR_BUG_BG[] = "#ffcccc"; -const char COLOR_NOTE_BG[] = "#e0ebff"; - // Dummy, needs to be changed const char ICON_TODO[] = ":/todoplugin/images/todo.png"; diff --git a/src/plugins/todo/keyword.cpp b/src/plugins/todo/keyword.cpp index 00f9232323..7516d5bed1 100644 --- a/src/plugins/todo/keyword.cpp +++ b/src/plugins/todo/keyword.cpp @@ -25,11 +25,12 @@ ****************************************************************************/ #include "keyword.h" +#include <utils/theme/theme.h> namespace Todo { namespace Internal { -Keyword::Keyword() : color(Qt::white) +Keyword::Keyword() : color(Utils::creatorTheme()->color(Utils::Theme::TextColorNormal)) { } diff --git a/src/plugins/todo/optionsdialog.cpp b/src/plugins/todo/optionsdialog.cpp index 5ab683ac1b..c6bd7c89f5 100644 --- a/src/plugins/todo/optionsdialog.cpp +++ b/src/plugins/todo/optionsdialog.cpp @@ -75,7 +75,7 @@ void OptionsDialog::addToKeywordsList(const Keyword &keyword) QListWidgetItem *item = new QListWidgetItem( icon(keyword.iconType), keyword.name); item->setData(Qt::UserRole, static_cast<int>(keyword.iconType)); - item->setBackgroundColor(keyword.color); + item->setTextColor(keyword.color); ui->keywordsList->addItem(item); } @@ -116,7 +116,7 @@ void OptionsDialog::editKeyword(QListWidgetItem *item) Keyword keyword; keyword.name = item->text(); keyword.iconType = static_cast<IconType>(item->data(Qt::UserRole).toInt()); - keyword.color = item->backgroundColor(); + keyword.color = item->textColor(); QSet<QString> keywordNamesButThis = keywordNames(); keywordNamesButThis.remove(keyword.name); @@ -127,7 +127,7 @@ void OptionsDialog::editKeyword(QListWidgetItem *item) item->setIcon(icon(keyword.iconType)); item->setText(keyword.name); item->setData(Qt::UserRole, static_cast<int>(keyword.iconType)); - item->setBackgroundColor(keyword.color); + item->setTextColor(keyword.color); } } @@ -179,7 +179,7 @@ Settings OptionsDialog::settingsFromUi() Keyword keyword; keyword.name = item->text(); keyword.iconType = static_cast<IconType>(item->data(Qt::UserRole).toInt()); - keyword.color = item->backgroundColor(); + keyword.color = item->textColor(); settings.keywords << keyword; } diff --git a/src/plugins/todo/settings.cpp b/src/plugins/todo/settings.cpp index b61d106812..88c754e21e 100644 --- a/src/plugins/todo/settings.cpp +++ b/src/plugins/todo/settings.cpp @@ -28,6 +28,7 @@ #include "constants.h" #include <coreplugin/coreconstants.h> +#include <utils/theme/theme.h> #include <QSettings> @@ -110,6 +111,7 @@ void Settings::load(QSettings *settings) void Settings::setDefault() { scanningScope = ScanningScopeCurrentFile; + Utils::Theme *theme = Utils::creatorTheme(); keywords.clear(); @@ -117,27 +119,27 @@ void Settings::setDefault() keyword.name = QLatin1String("TODO"); keyword.iconType = IconType::Todo; - keyword.color = QColor(QLatin1String(Constants::COLOR_TODO_BG)); + keyword.color = theme->color(Utils::Theme::OutputPanes_NormalMessageTextColor); keywords.append(keyword); keyword.name = QLatin1String("NOTE"); keyword.iconType = IconType::Info; - keyword.color = QColor(QLatin1String(Constants::COLOR_NOTE_BG)); + keyword.color = theme->color(Utils::Theme::OutputPanes_NormalMessageTextColor); keywords.append(keyword); keyword.name = QLatin1String("FIXME"); keyword.iconType = IconType::Error; - keyword.color = QColor(QLatin1String(Constants::COLOR_FIXME_BG)); + keyword.color = theme->color(Utils::Theme::OutputPanes_ErrorMessageTextColor); keywords.append(keyword); keyword.name = QLatin1String("BUG"); keyword.iconType = IconType::Bug; - keyword.color = QColor(QLatin1String(Constants::COLOR_BUG_BG)); + keyword.color = theme->color(Utils::Theme::OutputPanes_ErrorMessageTextColor); keywords.append(keyword); keyword.name = QLatin1String("WARNING"); keyword.iconType = IconType::Warning; - keyword.color = QColor(QLatin1String(Constants::COLOR_WARNING_BG)); + keyword.color = theme->color(Utils::Theme::OutputPanes_WarningMessageTextColor); keywords.append(keyword); keywordsEdited = false; diff --git a/src/plugins/todo/todoitemsmodel.cpp b/src/plugins/todo/todoitemsmodel.cpp index ebcfde810c..64919bf35e 100644 --- a/src/plugins/todo/todoitemsmodel.cpp +++ b/src/plugins/todo/todoitemsmodel.cpp @@ -80,10 +80,8 @@ QVariant TodoItemsModel::data(const QModelIndex &index, int role) const TodoItem item = m_todoItemsList->at(index.row()); - if (role == Qt::BackgroundColorRole) - return item.color; if (role == Qt::TextColorRole) - return creatorTheme()->color(Theme::TodoItemTextColor); + return item.color; switch (index.column()) { diff --git a/src/plugins/todo/todooutputpane.cpp b/src/plugins/todo/todooutputpane.cpp index fab4a65839..99d8779abf 100644 --- a/src/plugins/todo/todooutputpane.cpp +++ b/src/plugins/todo/todooutputpane.cpp @@ -178,7 +178,7 @@ void TodoOutputPane::todoTreeViewClicked(const QModelIndex &index) item.text = index.sibling(row, Constants::OUTPUT_COLUMN_TEXT).data().toString(); item.file = Utils::FileName::fromUserInput(index.sibling(row, Constants::OUTPUT_COLUMN_FILE).data().toString()); item.line = index.sibling(row, Constants::OUTPUT_COLUMN_LINE).data().toInt(); - item.color = index.data(Qt::BackgroundColorRole).value<QColor>(); + item.color = index.data(Qt::TextColorRole).value<QColor>(); item.iconType = static_cast<IconType>(index.sibling(row, Constants::OUTPUT_COLUMN_TEXT) .data(Qt::UserRole).toInt()); |