forked from qt-creator/qt-creator
ProjectExplorer: Use new setup pattern for ProjectTreeWidgetFactory
Change-Id: Id046dca1358547e21a2920eac62f5a694c7f6905 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -697,7 +697,6 @@ public:
|
|||||||
SshSettingsPage m_sshSettingsPage;
|
SshSettingsPage m_sshSettingsPage;
|
||||||
CustomParsersSettingsPage m_customParsersSettingsPage;
|
CustomParsersSettingsPage m_customParsersSettingsPage;
|
||||||
|
|
||||||
ProjectTreeWidgetFactory m_projectTreeFactory;
|
|
||||||
DefaultDeployConfigurationFactory m_defaultDeployConfigFactory;
|
DefaultDeployConfigurationFactory m_defaultDeployConfigFactory;
|
||||||
|
|
||||||
IDocumentFactory m_documentFactory;
|
IDocumentFactory m_documentFactory;
|
||||||
@@ -816,6 +815,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
setupMsvcToolchain();
|
setupMsvcToolchain();
|
||||||
setupClangClToolchain();
|
setupClangClToolchain();
|
||||||
|
|
||||||
|
setupProjectTreeWidgetFactory();
|
||||||
|
|
||||||
dd = new ProjectExplorerPluginPrivate;
|
dd = new ProjectExplorerPluginPrivate;
|
||||||
|
|
||||||
dd->extendFolderNavigationWidgetFactory();
|
dd->extendFolderNavigationWidgetFactory();
|
||||||
|
@@ -14,11 +14,12 @@
|
|||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/command.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <coreplugin/idocument.h>
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/find/itemviewfind.h>
|
#include <coreplugin/find/itemviewfind.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/idocument.h>
|
||||||
|
#include <coreplugin/inavigationwidgetfactory.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/navigationtreeview.h>
|
#include <utils/navigationtreeview.h>
|
||||||
@@ -46,9 +47,9 @@ using namespace Utils;
|
|||||||
|
|
||||||
QList<ProjectTreeWidget *> ProjectTreeWidget::m_projectTreeWidgets;
|
QList<ProjectTreeWidget *> ProjectTreeWidget::m_projectTreeWidgets;
|
||||||
|
|
||||||
namespace {
|
namespace ProjectExplorer::Internal {
|
||||||
|
|
||||||
class ProjectTreeItemDelegate : public QStyledItemDelegate
|
class ProjectTreeItemDelegate final : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProjectTreeItemDelegate(QTreeView *view) : QStyledItemDelegate(view),
|
ProjectTreeItemDelegate(QTreeView *view) : QStyledItemDelegate(view),
|
||||||
@@ -65,12 +66,12 @@ public:
|
|||||||
this, &ProjectTreeItemDelegate::deleteAllIndicators);
|
this, &ProjectTreeItemDelegate::deleteAllIndicators);
|
||||||
}
|
}
|
||||||
|
|
||||||
~ProjectTreeItemDelegate() override
|
~ProjectTreeItemDelegate() final
|
||||||
{
|
{
|
||||||
deleteAllIndicators();
|
deleteAllIndicators();
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const final
|
||||||
{
|
{
|
||||||
const bool useUnavailableMarker = index.data(Project::UseUnavailableMarkerRole).toBool();
|
const bool useUnavailableMarker = index.data(Project::UseUnavailableMarkerRole).toBool();
|
||||||
if (useUnavailableMarker) {
|
if (useUnavailableMarker) {
|
||||||
@@ -128,7 +129,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
}
|
|
||||||
|
|
||||||
class ProjectTreeView : public NavigationTreeView
|
class ProjectTreeView : public NavigationTreeView
|
||||||
{
|
{
|
||||||
@@ -159,7 +159,7 @@ public:
|
|||||||
m_cachedSize = -1;
|
m_cachedSize = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setModel(QAbstractItemModel *newModel) override
|
void setModel(QAbstractItemModel *newModel) final
|
||||||
{
|
{
|
||||||
// Note: Don't connect to column signals, as we have only one column
|
// Note: Don't connect to column signals, as we have only one column
|
||||||
if (model()) {
|
if (model()) {
|
||||||
@@ -194,7 +194,7 @@ public:
|
|||||||
NavigationTreeView::setModel(newModel);
|
NavigationTreeView::setModel(newModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sizeHintForColumn(int column) const override
|
int sizeHintForColumn(int column) const final
|
||||||
{
|
{
|
||||||
if (m_cachedSize < 0)
|
if (m_cachedSize < 0)
|
||||||
m_cachedSize = NavigationTreeView::sizeHintForColumn(column);
|
m_cachedSize = NavigationTreeView::sizeHintForColumn(column);
|
||||||
@@ -211,7 +211,7 @@ private:
|
|||||||
|
|
||||||
Shows the projects in form of a tree.
|
Shows the projects in form of a tree.
|
||||||
*/
|
*/
|
||||||
ProjectTreeWidget::ProjectTreeWidget(QWidget *parent) : QWidget(parent)
|
ProjectTreeWidget::ProjectTreeWidget()
|
||||||
{
|
{
|
||||||
// We keep one instance per tree as this also manages the
|
// We keep one instance per tree as this also manages the
|
||||||
// simple/non-simple etc state which is per tree.
|
// simple/non-simple etc state which is per tree.
|
||||||
@@ -614,8 +614,10 @@ bool ProjectTreeWidget::projectFilter()
|
|||||||
return m_model->projectFilterEnabled();
|
return m_model->projectFilterEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ProjectTreeWidgetFactory final : public INavigationWidgetFactory
|
||||||
ProjectTreeWidgetFactory::ProjectTreeWidgetFactory()
|
{
|
||||||
|
public:
|
||||||
|
ProjectTreeWidgetFactory()
|
||||||
{
|
{
|
||||||
setDisplayName(Tr::tr("Projects"));
|
setDisplayName(Tr::tr("Projects"));
|
||||||
setPriority(100);
|
setPriority(100);
|
||||||
@@ -623,12 +625,16 @@ ProjectTreeWidgetFactory::ProjectTreeWidgetFactory()
|
|||||||
setActivationSequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+X") : Tr::tr("Alt+X")));
|
setActivationSequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+X") : Tr::tr("Alt+X")));
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationView ProjectTreeWidgetFactory::createWidget()
|
Core::NavigationView createWidget() final
|
||||||
{
|
{
|
||||||
auto ptw = new ProjectTreeWidget;
|
auto ptw = new ProjectTreeWidget;
|
||||||
return {ptw, ptw->createToolButtons()};
|
return {ptw, ptw->createToolButtons()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void restoreSettings(Utils::QtcSettings *settings, int position, QWidget *widget) final;
|
||||||
|
void saveSettings(Utils::QtcSettings *settings, int position, QWidget *widget) final;
|
||||||
|
};
|
||||||
|
|
||||||
const bool kProjectFilterDefault = false;
|
const bool kProjectFilterDefault = false;
|
||||||
const bool kHideGeneratedFilesDefault = true;
|
const bool kHideGeneratedFilesDefault = true;
|
||||||
const bool kHideDisabledFilesDefault = false;
|
const bool kHideDisabledFilesDefault = false;
|
||||||
@@ -683,3 +689,10 @@ void ProjectTreeWidgetFactory::restoreSettings(QtcSettings *settings, int positi
|
|||||||
settings->value(baseKey + kHideSourceGroupsKey, kHideSourceGroupsDefault).toBool());
|
settings->value(baseKey + kHideSourceGroupsKey, kHideSourceGroupsDefault).toBool());
|
||||||
ptw->setAutoSynchronization(settings->value(baseKey + kSyncKey, kSyncDefault).toBool());
|
ptw->setAutoSynchronization(settings->value(baseKey + kSyncKey, kSyncDefault).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setupProjectTreeWidgetFactory()
|
||||||
|
{
|
||||||
|
static ProjectTreeWidgetFactory theProjectTreeWidgetFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // ProjectExplorer::Internal
|
||||||
|
@@ -3,14 +3,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <coreplugin/inavigationwidgetfactory.h>
|
|
||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QTreeView)
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QToolButton;
|
||||||
|
class QTreeView;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
@@ -20,12 +21,12 @@ namespace Internal {
|
|||||||
|
|
||||||
class FlatModel;
|
class FlatModel;
|
||||||
|
|
||||||
class ProjectTreeWidget : public QWidget
|
class ProjectTreeWidget final : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ProjectTreeWidget(QWidget *parent = nullptr);
|
ProjectTreeWidget();
|
||||||
~ProjectTreeWidget() override;
|
~ProjectTreeWidget() final;
|
||||||
|
|
||||||
bool autoSynchronization() const;
|
bool autoSynchronization() const;
|
||||||
void setAutoSynchronization(bool sync);
|
void setAutoSynchronization(bool sync);
|
||||||
@@ -85,16 +86,7 @@ private:
|
|||||||
friend class ProjectTreeWidgetFactory;
|
friend class ProjectTreeWidgetFactory;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProjectTreeWidgetFactory : public Core::INavigationWidgetFactory
|
void setupProjectTreeWidgetFactory();
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
ProjectTreeWidgetFactory();
|
|
||||||
|
|
||||||
Core::NavigationView createWidget() override;
|
|
||||||
void restoreSettings(Utils::QtcSettings *settings, int position, QWidget *widget) override;
|
|
||||||
void saveSettings(Utils::QtcSettings *settings, int position, QWidget *widget) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
Reference in New Issue
Block a user