forked from qt-creator/qt-creator
Todo: Use free function to setup TodoOutputPane
Change-Id: Ifed2db897d80d1d95fd1cf2a67cf8531b9153bdc Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -10,16 +10,19 @@
|
||||
#include "todotr.h"
|
||||
|
||||
#include <aggregation/aggregate.h>
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QHeaderView>
|
||||
#include <QToolButton>
|
||||
#include <QButtonGroup>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <todoitemsprovider.h>
|
||||
|
||||
namespace Todo {
|
||||
namespace Internal {
|
||||
namespace Todo::Internal {
|
||||
|
||||
TodoOutputPane::TodoOutputPane(TodoItemsModel *todoItemsModel, QObject *parent) :
|
||||
IOutputPane(parent),
|
||||
@@ -31,7 +34,9 @@ TodoOutputPane::TodoOutputPane(TodoItemsModel *todoItemsModel, QObject *parent)
|
||||
|
||||
createTreeView();
|
||||
createScopeButtons();
|
||||
setScanningScope(ScanningScopeCurrentFile); // default
|
||||
|
||||
setScanningScope(todoSettings().scanningScope);
|
||||
|
||||
connect(m_todoTreeView->model(), &TodoItemsModel::layoutChanged,
|
||||
this, &TodoOutputPane::navigateStateUpdate);
|
||||
connect(m_todoTreeView->model(), &TodoItemsModel::layoutChanged,
|
||||
@@ -125,17 +130,32 @@ void TodoOutputPane::setScanningScope(ScanningScope scanningScope)
|
||||
Q_ASSERT_X(false, "Updating scanning scope buttons", "Unknown scanning scope enum value");
|
||||
}
|
||||
|
||||
void TodoOutputPane::todoItemClicked(const TodoItem &item)
|
||||
{
|
||||
if (item.file.exists())
|
||||
Core::EditorManager::openEditorAt(Utils::Link(item.file, item.line));
|
||||
}
|
||||
|
||||
void TodoOutputPane::scopeButtonClicked(QAbstractButton *button)
|
||||
{
|
||||
if (button == m_currentFileButton)
|
||||
emit scanningScopeChanged(ScanningScopeCurrentFile);
|
||||
scanningScopeChanged(ScanningScopeCurrentFile);
|
||||
else if (button == m_subProjectButton)
|
||||
emit scanningScopeChanged(ScanningScopeSubProject);
|
||||
scanningScopeChanged(ScanningScopeSubProject);
|
||||
else if (button == m_wholeProjectButton)
|
||||
emit scanningScopeChanged(ScanningScopeProject);
|
||||
scanningScopeChanged(ScanningScopeProject);
|
||||
emit setBadgeNumber(m_todoTreeView->model()->rowCount());
|
||||
}
|
||||
|
||||
void TodoOutputPane::scanningScopeChanged(ScanningScope scanningScope)
|
||||
{
|
||||
todoSettings().scanningScope = scanningScope;
|
||||
todoSettings().save(Core::ICore::settings());
|
||||
|
||||
todoItemsProvider().settingsChanged();
|
||||
setScanningScope(todoSettings().scanningScope);
|
||||
}
|
||||
|
||||
void TodoOutputPane::todoTreeViewClicked(const QModelIndex &index)
|
||||
{
|
||||
// Create a to-do item and notify that it was clicked on
|
||||
@@ -295,5 +315,16 @@ QModelIndex TodoOutputPane::previousModelIndex()
|
||||
return indexToBeSelected;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Todo
|
||||
static TodoOutputPane *s_instance = nullptr;
|
||||
|
||||
TodoOutputPane &todoOutputPane()
|
||||
{
|
||||
return *s_instance;
|
||||
}
|
||||
|
||||
void setupTodoOutputPane(QObject *guard)
|
||||
{
|
||||
s_instance = new TodoOutputPane(todoItemsProvider().todoItemsModel(), guard);
|
||||
}
|
||||
|
||||
} // Todo::Internal
|
||||
|
@@ -16,8 +16,7 @@ class QAbstractButton;
|
||||
class QSortFilterProxyModel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Todo {
|
||||
namespace Internal {
|
||||
namespace Todo::Internal {
|
||||
|
||||
class TodoItem;
|
||||
class TodoItemsModel;
|
||||
@@ -47,11 +46,9 @@ public:
|
||||
|
||||
void setScanningScope(ScanningScope scanningScope);
|
||||
|
||||
signals:
|
||||
private:
|
||||
void todoItemClicked(const TodoItem &item);
|
||||
void scanningScopeChanged(ScanningScope scanningScope);
|
||||
|
||||
private:
|
||||
void scopeButtonClicked(QAbstractButton *button);
|
||||
void todoTreeViewClicked(const QModelIndex &index);
|
||||
void updateTodoCount();
|
||||
@@ -81,5 +78,8 @@ private:
|
||||
QToolButtonList m_filterButtons;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Todo
|
||||
TodoOutputPane &todoOutputPane();
|
||||
|
||||
void setupTodoOutputPane(QObject *guard);
|
||||
|
||||
} // Todo::Internal
|
||||
|
@@ -8,13 +8,9 @@
|
||||
#include "todotr.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <utils/link.h>
|
||||
|
||||
namespace Todo::Internal {
|
||||
|
||||
class TodoPluginPrivate : public QObject
|
||||
@@ -23,11 +19,6 @@ public:
|
||||
TodoPluginPrivate();
|
||||
|
||||
void settingsChanged();
|
||||
void scanningScopeChanged(ScanningScope scanningScope);
|
||||
void todoItemClicked(const TodoItem &item);
|
||||
void createTodoOutputPane();
|
||||
|
||||
TodoOutputPane *m_todoOutputPane = nullptr;
|
||||
};
|
||||
|
||||
TodoPluginPrivate::TodoPluginPrivate()
|
||||
@@ -35,7 +26,7 @@ TodoPluginPrivate::TodoPluginPrivate()
|
||||
todoSettings().load(Core::ICore::settings());
|
||||
|
||||
setupTodoItemsProvider(this);
|
||||
createTodoOutputPane();
|
||||
setupTodoOutputPane(this);
|
||||
|
||||
setupTodoSettingsPage([this] { settingsChanged(); });
|
||||
|
||||
@@ -50,29 +41,7 @@ void TodoPluginPrivate::settingsChanged()
|
||||
todoSettings().save(Core::ICore::settings());
|
||||
|
||||
todoItemsProvider().settingsChanged();
|
||||
m_todoOutputPane->setScanningScope(todoSettings().scanningScope);
|
||||
}
|
||||
|
||||
void TodoPluginPrivate::scanningScopeChanged(ScanningScope scanningScope)
|
||||
{
|
||||
todoSettings().scanningScope = scanningScope;
|
||||
settingsChanged();
|
||||
}
|
||||
|
||||
void TodoPluginPrivate::todoItemClicked(const TodoItem &item)
|
||||
{
|
||||
if (item.file.exists())
|
||||
Core::EditorManager::openEditorAt(Utils::Link(item.file, item.line));
|
||||
}
|
||||
|
||||
void TodoPluginPrivate::createTodoOutputPane()
|
||||
{
|
||||
m_todoOutputPane = new TodoOutputPane(todoItemsProvider().todoItemsModel(), this);
|
||||
m_todoOutputPane->setScanningScope(todoSettings().scanningScope);
|
||||
connect(m_todoOutputPane, &TodoOutputPane::scanningScopeChanged,
|
||||
this, &TodoPluginPrivate::scanningScopeChanged);
|
||||
connect(m_todoOutputPane, &TodoOutputPane::todoItemClicked,
|
||||
this, &TodoPluginPrivate::todoItemClicked);
|
||||
todoOutputPane().setScanningScope(todoSettings().scanningScope);
|
||||
}
|
||||
|
||||
class TodoPlugin final : public ExtensionSystem::IPlugin
|
||||
|
Reference in New Issue
Block a user