diff options
author | David Schulz <david.schulz@qt.io> | 2022-08-15 09:42:49 +0200 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2022-08-16 07:53:41 +0000 |
commit | b39c7cd782c7e99b11ffd4977e7660be1f992d08 (patch) | |
tree | 9b010e95f07d1bdf5236f159c3249b3797031641 /src/plugins/cppeditor/cppoverviewmodel.cpp | |
parent | 8703bcd777f8d1c7e903162f03254f81630ca428 (diff) | |
download | qt-creator-b39c7cd782c7e99b11ffd4977e7660be1f992d08.tar.gz |
CppEditor: remove unneeded indirection for the outline model
Change-Id: I01e9fb0dae30d6df22c0f5d7255ab247c48749fc
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppoverviewmodel.cpp')
-rw-r--r-- | src/plugins/cppeditor/cppoverviewmodel.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/plugins/cppeditor/cppoverviewmodel.cpp b/src/plugins/cppeditor/cppoverviewmodel.cpp index de7a8df2f4..9e032ce922 100644 --- a/src/plugins/cppeditor/cppoverviewmodel.cpp +++ b/src/plugins/cppeditor/cppoverviewmodel.cpp @@ -126,10 +126,10 @@ public: case Qt::DecorationRole: return Icons::iconForSymbol(symbol); - case AbstractOverviewModel::FileNameRole: + case OverviewModel::FileNameRole: return QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()); - case AbstractOverviewModel::LineNumberRole: + case OverviewModel::LineNumberRole: return symbol->line(); default: @@ -168,6 +168,40 @@ Symbol *OverviewModel::symbolFromIndex(const QModelIndex &index) const return item ? item->symbol : nullptr; } +Qt::ItemFlags OverviewModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return Qt::NoItemFlags; + + return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; +} + +Qt::DropActions OverviewModel::supportedDragActions() const +{ + return Qt::MoveAction; +} + +QStringList OverviewModel::mimeTypes() const +{ + return Utils::DropSupport::mimeTypesForFilePaths(); +} + +QMimeData *OverviewModel::mimeData(const QModelIndexList &indexes) const +{ + auto mimeData = new Utils::DropMimeData; + for (const QModelIndex &index : indexes) { + const QVariant fileName = data(index, FileNameRole); + if (!fileName.canConvert<QString>()) + continue; + const QVariant lineNumber = data(index, LineNumberRole); + if (!lineNumber.canConvert<unsigned>()) + continue; + mimeData->addFile(Utils::FilePath::fromVariant(fileName), + static_cast<int>(lineNumber.value<unsigned>())); + } + return mimeData; +} + void OverviewModel::rebuild(Document::Ptr doc) { beginResetModel(); |