diff --git a/src/plugins/classview/classviewmanager.cpp b/src/plugins/classview/classviewmanager.cpp index 1e0cf89f719..15eb5668038 100644 --- a/src/plugins/classview/classviewmanager.cpp +++ b/src/plugins/classview/classviewmanager.cpp @@ -19,8 +19,7 @@ using namespace Core; using namespace ProjectExplorer; using namespace Utils; -namespace ClassView { -namespace Internal { +namespace ClassView::Internal { ///////////////////////////////// ManagerPrivate ////////////////////////////////// @@ -347,9 +346,9 @@ void Manager::onWidgetVisibilityIsChanged(bool visibility) \a column (0-based). */ -void Manager::gotoLocation(const QString &fileName, int line, int column) +void Manager::gotoLocation(const FilePath &filePath, int line, int column) { - EditorManager::openEditorAt({FilePath::fromString(fileName), line, column}); + EditorManager::openEditorAt({filePath, line, column}); } /*! @@ -372,11 +371,11 @@ void Manager::gotoLocations(const QList &list) auto textEditor = qobject_cast(EditorManager::currentEditor()); if (textEditor) { // check if current cursor position is a known location of the symbol - const QString fileName = textEditor->document()->filePath().toString(); + const FilePath filePath = textEditor->document()->filePath(); int line; int column; textEditor->convertPosition(textEditor->position(), &line, &column); - const SymbolLocation current(fileName, line, column); + const SymbolLocation current(filePath, line, column); if (auto it = locations.constFind(current), end = locations.constEnd(); it != end) { // we already are at the symbol, cycle to next location ++it; @@ -388,7 +387,7 @@ void Manager::gotoLocations(const QList &list) } const SymbolLocation &location = *locationIt; // line is 1-based, column is 0-based - gotoLocation(location.fileName(), location.line(), location.column() - 1); + gotoLocation(location.filePath(), location.line(), location.column() - 1); } /*! @@ -402,5 +401,4 @@ void Manager::setFlatMode(bool flat) }, Qt::QueuedConnection); } -} // namespace Internal -} // namespace ClassView +} // ClassView::Internal diff --git a/src/plugins/classview/classviewmanager.h b/src/plugins/classview/classviewmanager.h index fe821224c1b..972915af19c 100644 --- a/src/plugins/classview/classviewmanager.h +++ b/src/plugins/classview/classviewmanager.h @@ -7,8 +7,9 @@ #include #include -namespace ClassView { -namespace Internal { +namespace Utils { class FilePath; } + +namespace ClassView::Internal { class ManagerPrivate; @@ -24,7 +25,7 @@ public: void fetchMore(QStandardItem *item, bool skipRoot = false); bool hasChildren(QStandardItem *item) const; - void gotoLocation(const QString &fileName, int line = 0, int column = 0); + void gotoLocation(const Utils::FilePath &filePath, int line = 0, int column = 0); void gotoLocations(const QList &locations); void setFlatMode(bool flat); void onWidgetVisibilityIsChanged(bool visibility); @@ -41,5 +42,4 @@ private: ManagerPrivate *d; }; -} // namespace Internal -} // namespace ClassView +} // ClassView::Internal diff --git a/src/plugins/classview/classviewparsertreeitem.cpp b/src/plugins/classview/classviewparsertreeitem.cpp index 51fbcef32e2..ea712b04a00 100644 --- a/src/plugins/classview/classviewparsertreeitem.cpp +++ b/src/plugins/classview/classviewparsertreeitem.cpp @@ -101,7 +101,7 @@ void ParserTreeItemPrivate::mergeSymbol(const CPlusPlus::Symbol *symbol) childItem = ParserTreeItem::ConstPtr(new ParserTreeItem()); // locations have 1-based column in Symbol, use the same here. - SymbolLocation location(QString::fromUtf8(symbol->fileName() , symbol->fileNameLength()), + SymbolLocation location(symbol->filePath(), symbol->line(), symbol->column()); childItem->d->m_symbolLocations.insert(location); diff --git a/src/plugins/classview/classviewsymbollocation.cpp b/src/plugins/classview/classviewsymbollocation.cpp index 8a5ad86781c..86766c0cce5 100644 --- a/src/plugins/classview/classviewsymbollocation.cpp +++ b/src/plugins/classview/classviewsymbollocation.cpp @@ -5,8 +5,7 @@ #include -namespace ClassView { -namespace Internal { +namespace ClassView::Internal { /*! \class SymbolLocation @@ -23,7 +22,7 @@ SymbolLocation::SymbolLocation() : { } -SymbolLocation::SymbolLocation(const QString &file, int lineNumber, int columnNumber) +SymbolLocation::SymbolLocation(const Utils::FilePath &file, int lineNumber, int columnNumber) : m_fileName(file) , m_line(lineNumber) , m_column(qMax(columnNumber, 0)) @@ -31,5 +30,4 @@ SymbolLocation::SymbolLocation(const QString &file, int lineNumber, int columnNu { } -} // namespace Internal -} // namespace ClassView +} // ClassView::Internal diff --git a/src/plugins/classview/classviewsymbollocation.h b/src/plugins/classview/classviewsymbollocation.h index faaadf0abb3..49b43ef8699 100644 --- a/src/plugins/classview/classviewsymbollocation.h +++ b/src/plugins/classview/classviewsymbollocation.h @@ -3,11 +3,11 @@ #pragma once -#include -#include +#include -namespace ClassView { -namespace Internal { +#include + +namespace ClassView::Internal { class SymbolLocation { @@ -16,20 +16,21 @@ public: SymbolLocation(); //! Constructor - explicit SymbolLocation(const QString &file, int lineNumber = 0, int columnNumber = 0); + explicit SymbolLocation(const Utils::FilePath &file, int lineNumber = 0, int columnNumber = 0); - inline const QString &fileName() const { return m_fileName; } - inline int line() const { return m_line; } - inline int column() const { return m_column; } - inline size_t hash() const { return m_hash; } - inline bool operator==(const SymbolLocation &other) const + const Utils::FilePath &filePath() const { return m_fileName; } + int line() const { return m_line; } + int column() const { return m_column; } + size_t hash() const { return m_hash; } + + bool operator==(const SymbolLocation &other) const { return hash() == other.hash() && line() == other.line() && column() == other.column() - && fileName() == other.fileName(); + && filePath() == other.filePath(); } private: - const QString m_fileName; + const Utils::FilePath m_fileName; const int m_line; const int m_column; const size_t m_hash; // precalculated hash value - to speed up qHash @@ -41,7 +42,6 @@ inline size_t qHash(const ClassView::Internal::SymbolLocation &location) return location.hash(); } -} // namespace Internal -} // namespace ClassView +} // ClassView::Internal Q_DECLARE_METATYPE(ClassView::Internal::SymbolLocation) diff --git a/src/plugins/classview/classviewtreeitemmodel.cpp b/src/plugins/classview/classviewtreeitemmodel.cpp index a3c50d392c7..23879a11b2c 100644 --- a/src/plugins/classview/classviewtreeitemmodel.cpp +++ b/src/plugins/classview/classviewtreeitemmodel.cpp @@ -162,7 +162,7 @@ QMimeData *TreeItemModel::mimeData(const QModelIndexList &indexes) const if (locations.isEmpty()) continue; const SymbolLocation loc = *locations.constBegin(); - mimeData->addFile(Utils::FilePath::fromString(loc.fileName()), loc.line(), loc.column()); + mimeData->addFile(loc.filePath(), loc.line(), loc.column()); } if (mimeData->files().isEmpty()) { delete mimeData;