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;
|
||||
CustomParsersSettingsPage m_customParsersSettingsPage;
|
||||
|
||||
ProjectTreeWidgetFactory m_projectTreeFactory;
|
||||
DefaultDeployConfigurationFactory m_defaultDeployConfigFactory;
|
||||
|
||||
IDocumentFactory m_documentFactory;
|
||||
@@ -816,6 +815,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
setupMsvcToolchain();
|
||||
setupClangClToolchain();
|
||||
|
||||
setupProjectTreeWidgetFactory();
|
||||
|
||||
dd = new ProjectExplorerPluginPrivate;
|
||||
|
||||
dd->extendFolderNavigationWidgetFactory();
|
||||
|
@@ -14,11 +14,12 @@
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/inavigationwidgetfactory.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/navigationtreeview.h>
|
||||
@@ -46,9 +47,9 @@ using namespace Utils;
|
||||
|
||||
QList<ProjectTreeWidget *> ProjectTreeWidget::m_projectTreeWidgets;
|
||||
|
||||
namespace {
|
||||
namespace ProjectExplorer::Internal {
|
||||
|
||||
class ProjectTreeItemDelegate : public QStyledItemDelegate
|
||||
class ProjectTreeItemDelegate final : public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
ProjectTreeItemDelegate(QTreeView *view) : QStyledItemDelegate(view),
|
||||
@@ -65,12 +66,12 @@ public:
|
||||
this, &ProjectTreeItemDelegate::deleteAllIndicators);
|
||||
}
|
||||
|
||||
~ProjectTreeItemDelegate() override
|
||||
~ProjectTreeItemDelegate() final
|
||||
{
|
||||
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();
|
||||
if (useUnavailableMarker) {
|
||||
@@ -128,7 +129,6 @@ private:
|
||||
};
|
||||
|
||||
bool debug = false;
|
||||
}
|
||||
|
||||
class ProjectTreeView : public NavigationTreeView
|
||||
{
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
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
|
||||
if (model()) {
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
NavigationTreeView::setModel(newModel);
|
||||
}
|
||||
|
||||
int sizeHintForColumn(int column) const override
|
||||
int sizeHintForColumn(int column) const final
|
||||
{
|
||||
if (m_cachedSize < 0)
|
||||
m_cachedSize = NavigationTreeView::sizeHintForColumn(column);
|
||||
@@ -211,7 +211,7 @@ private:
|
||||
|
||||
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
|
||||
// simple/non-simple etc state which is per tree.
|
||||
@@ -614,8 +614,10 @@ bool ProjectTreeWidget::projectFilter()
|
||||
return m_model->projectFilterEnabled();
|
||||
}
|
||||
|
||||
|
||||
ProjectTreeWidgetFactory::ProjectTreeWidgetFactory()
|
||||
class ProjectTreeWidgetFactory final : public INavigationWidgetFactory
|
||||
{
|
||||
public:
|
||||
ProjectTreeWidgetFactory()
|
||||
{
|
||||
setDisplayName(Tr::tr("Projects"));
|
||||
setPriority(100);
|
||||
@@ -623,12 +625,16 @@ ProjectTreeWidgetFactory::ProjectTreeWidgetFactory()
|
||||
setActivationSequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+X") : Tr::tr("Alt+X")));
|
||||
}
|
||||
|
||||
NavigationView ProjectTreeWidgetFactory::createWidget()
|
||||
Core::NavigationView createWidget() final
|
||||
{
|
||||
auto ptw = new ProjectTreeWidget;
|
||||
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 kHideGeneratedFilesDefault = true;
|
||||
const bool kHideDisabledFilesDefault = false;
|
||||
@@ -683,3 +689,10 @@ void ProjectTreeWidgetFactory::restoreSettings(QtcSettings *settings, int positi
|
||||
settings->value(baseKey + kHideSourceGroupsKey, kHideSourceGroupsDefault).toBool());
|
||||
ptw->setAutoSynchronization(settings->value(baseKey + kSyncKey, kSyncDefault).toBool());
|
||||
}
|
||||
|
||||
void setupProjectTreeWidgetFactory()
|
||||
{
|
||||
static ProjectTreeWidgetFactory theProjectTreeWidgetFactory;
|
||||
}
|
||||
|
||||
} // ProjectExplorer::Internal
|
||||
|
@@ -3,14 +3,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/inavigationwidgetfactory.h>
|
||||
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QModelIndex>
|
||||
#include <QWidget>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QTreeView)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QToolButton;
|
||||
class QTreeView;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
@@ -20,12 +21,12 @@ namespace Internal {
|
||||
|
||||
class FlatModel;
|
||||
|
||||
class ProjectTreeWidget : public QWidget
|
||||
class ProjectTreeWidget final : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ProjectTreeWidget(QWidget *parent = nullptr);
|
||||
~ProjectTreeWidget() override;
|
||||
ProjectTreeWidget();
|
||||
~ProjectTreeWidget() final;
|
||||
|
||||
bool autoSynchronization() const;
|
||||
void setAutoSynchronization(bool sync);
|
||||
@@ -85,16 +86,7 @@ private:
|
||||
friend class ProjectTreeWidgetFactory;
|
||||
};
|
||||
|
||||
class ProjectTreeWidgetFactory : public Core::INavigationWidgetFactory
|
||||
{
|
||||
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;
|
||||
};
|
||||
void setupProjectTreeWidgetFactory();
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ProjectExplorer
|
||||
|
Reference in New Issue
Block a user