diff options
author | hjk <hjk@qt.io> | 2024-01-17 18:33:43 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2024-01-26 10:45:14 +0000 |
commit | 17463757cebd4b20e357b4b8f24ec45ddc537458 (patch) | |
tree | 15cf3a380db3f5ced25698d134ba03670f024174 /src/plugins/resourceeditor | |
parent | dbee11f5b4e8a751e33a961233447b2c383b282b (diff) |
ResourceEditor: Remove some indirection
Change-Id: I930e7e35401e6c6d8b3e1245e6a7c663f131d345
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/plugins/resourceeditor')
-rw-r--r-- | src/plugins/resourceeditor/resourceeditor.cpp | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/src/plugins/resourceeditor/resourceeditor.cpp b/src/plugins/resourceeditor/resourceeditor.cpp index a15d6af31c..54ea676713 100644 --- a/src/plugins/resourceeditor/resourceeditor.cpp +++ b/src/plugins/resourceeditor/resourceeditor.cpp @@ -96,11 +96,11 @@ public: ResourceEditorImpl(); ~ResourceEditorImpl() final; - static ResourceEditorImpl *currentEditor() + static QrcEditor *currentQrcEditor() { auto const focusEditor = qobject_cast<ResourceEditorImpl *>(EditorManager::currentEditor()); QTC_ASSERT(focusEditor, return nullptr); - return focusEditor; + return focusEditor->m_resourceEditor; } IDocument *document() const final { return m_resourceDocument; } @@ -130,11 +130,6 @@ private: QAction *m_copyFileNameAction; QAction *m_orderList; -public: - void onRefresh(); - void onUndo(); - void onRedo(); - friend class ResourceEditorDocument; }; @@ -150,7 +145,7 @@ ResourceEditorImpl::ResourceEditorImpl() CommandButton *refreshButton = new CommandButton(Constants::REFRESH, m_toolBar); refreshButton->setIcon(QIcon(QLatin1String(":/texteditor/images/finddocuments.png"))); - connect(refreshButton, &QAbstractButton::clicked, this, &ResourceEditorImpl::onRefresh); + connect(refreshButton, &QAbstractButton::clicked, m_resourceEditor, &QrcEditor::refresh); m_toolBar->addWidget(refreshButton); m_resourceEditor->setResourceDragEnabled(true); @@ -294,8 +289,6 @@ void ResourceEditorImpl::restoreState(const QByteArray &state) m_resourceEditor->restoreState(splitterState); } - - bool ResourceEditorDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type) { Q_UNUSED(type) @@ -319,7 +312,7 @@ void ResourceEditorDocument::dirtyChanged(bool dirty) void ResourceEditorImpl::onUndoStackChanged(bool canUndo, bool canRedo) { - if (currentEditor() == this) { + if (currentQrcEditor() == m_resourceEditor) { s_undoAction->setEnabled(canUndo); s_redoAction->setEnabled(canRedo); } @@ -343,11 +336,6 @@ void ResourceEditorImpl::openFile(const QString &fileName) EditorManager::openEditor(FilePath::fromString(fileName)); } -void ResourceEditorImpl::onRefresh() -{ - m_resourceEditor->refresh(); -} - void ResourceEditorImpl::renameCurrentFile() { m_resourceEditor->editCurrentItem(); @@ -363,16 +351,6 @@ void ResourceEditorImpl::orderList() m_resourceDocument->model()->orderList(); } -void ResourceEditorImpl::onUndo() -{ - m_resourceEditor->onUndo(); -} - -void ResourceEditorImpl::onRedo() -{ - m_resourceEditor->onRedo(); -} - class ResourceEditorFactory final : public IEditorFactory { public: @@ -401,7 +379,7 @@ void setupResourceEditor(QObject *guard) .bindContextAction(&s_undoAction) .setContext(context) .addOnTriggered(guard, [] { - if (ResourceEditorImpl *editor = ResourceEditorImpl::currentEditor()) + if (QrcEditor *editor = ResourceEditorImpl::currentQrcEditor()) editor->onUndo(); }); @@ -410,7 +388,7 @@ void setupResourceEditor(QObject *guard) .setText(Tr::tr("&Redo")) .setContext(context) .addOnTriggered(guard, [] { - if (ResourceEditorImpl *editor = ResourceEditorImpl::currentEditor()) + if (QrcEditor *editor = ResourceEditorImpl::currentQrcEditor()) editor->onRedo(); }); @@ -419,8 +397,8 @@ void setupResourceEditor(QObject *guard) .bindContextAction(&s_refreshAction) .setContext(context) .addOnTriggered(guard, [] { - if (ResourceEditorImpl *editor = ResourceEditorImpl::currentEditor()) - editor->onRefresh(); + if (QrcEditor *editor = ResourceEditorImpl::currentQrcEditor()) + editor->refresh(); }); } |