Commit a355013e authored by hjk's avatar hjk

Core: Use some data members in NavigationWidgetFactory

Adjust user code, remove unused bits.

Change-Id: I351deb27679c9251518a4d1bf7f78a12bacae2fb
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 142f48e3
......@@ -832,34 +832,15 @@ void BookmarkManager::handleBookmarkTooltipRequest(ITextEditor *textEditor, cons
BookmarkViewFactory::BookmarkViewFactory(BookmarkManager *bm)
: m_manager(bm)
{
setDisplayName(BookmarkView::tr("Bookmarks"));
setPriority(300);
setId("Bookmarks");
setActivationSequence(QKeySequence(Core::UseMacShortcuts ? tr("Alt+Meta+M") : tr("Alt+M")));
}
QString BookmarkViewFactory::displayName() const
NavigationView BookmarkViewFactory::createWidget()
{
return BookmarkView::tr("Bookmarks");
}
int BookmarkViewFactory::priority() const
{
return 300;
}
Id BookmarkViewFactory::id() const
{
return "Bookmarks";
}
QKeySequence BookmarkViewFactory::activationSequence() const
{
return QKeySequence(Core::UseMacShortcuts ? tr("Alt+Meta+M") : tr("Alt+M"));
}
Core::NavigationView BookmarkViewFactory::createWidget()
{
BookmarkView *bookmarkView = new BookmarkView(m_manager);
Core::NavigationView view;
view.widget = bookmarkView;
return view;
return NavigationView(new BookmarkView(m_manager));
}
} // namespace Internal
......
......@@ -170,10 +170,6 @@ public:
BookmarkViewFactory(BookmarkManager *bm);
private:
QString displayName() const;
int priority() const;
Core::Id id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
BookmarkManager *m_manager;
......
......@@ -224,10 +224,6 @@ void Manager::initialize()
{
// use Qt::QueuedConnection everywhere
// widget factory signals
connect(NavigationWidgetFactory::instance(), SIGNAL(widgetIsCreated()),
SLOT(onWidgetIsCreated()), Qt::QueuedConnection);
// internal manager state is changed
connect(this, SIGNAL(stateChanged(bool)), SLOT(onStateChanged(bool)), Qt::QueuedConnection);
......@@ -318,17 +314,6 @@ void Manager::setState(bool state)
emit stateChanged(d->state);
}
/*!
Reacts to the widget factory creating a widget.
\sa setState, state
*/
void Manager::onWidgetIsCreated()
{
// do nothing - continue to sleep
}
/*!
Reacts to the \a visibility of one navigation pane widget being changed
(there might be a lot of them).
......
......@@ -87,7 +87,6 @@ public slots:
void setFlatMode(bool flat);
protected slots:
void onWidgetIsCreated();
void onWidgetVisibilityIsChanged(bool visibility);
void onStateChanged(bool state);
void onProjectListChanged();
......
......@@ -41,8 +41,6 @@
namespace ClassView {
namespace Internal {
static NavigationWidgetFactory *factoryInstance;
///////////////////////////////// NavigationWidgetFactory //////////////////////////////////
/*!
......@@ -52,49 +50,13 @@ static NavigationWidgetFactory *factoryInstance;
Supports the \c setState public slot for adding the widget factory to or
removing it from \c ExtensionSystem::PluginManager.
Also supports the \c widgetIsCreated and \c stateChanged signals.
*/
/*!
\fn void NavigationWidgetFactory::widgetIsCreated()
Informs that the widget factory created a widget.
*/
NavigationWidgetFactory::NavigationWidgetFactory()
{
factoryInstance = this;
}
NavigationWidgetFactory::~NavigationWidgetFactory()
{
factoryInstance = 0;
}
NavigationWidgetFactory *NavigationWidgetFactory::instance()
{
return factoryInstance;
}
QString NavigationWidgetFactory::displayName() const
{
return tr("Class View");
}
int NavigationWidgetFactory::priority() const
{
return 500;
}
Core::Id NavigationWidgetFactory::id() const
{
return "Class View";
}
QKeySequence NavigationWidgetFactory::activationSequence() const
{
return QKeySequence();
setDisplayName(tr("Class View"));
setPriority(500);
setId("Class View");
}
Core::NavigationView NavigationWidgetFactory::createWidget()
......@@ -103,7 +65,6 @@ Core::NavigationView NavigationWidgetFactory::createWidget()
NavigationWidget *widget = new NavigationWidget();
navigationView.widget = widget;
navigationView.dockToolBarWidgets = widget->createToolButtons();
emit widgetIsCreated();
return navigationView;
}
......
......@@ -40,28 +40,8 @@ class NavigationWidgetFactory : public Core::INavigationWidgetFactory
Q_OBJECT
public:
//! Constructor
NavigationWidgetFactory();
//! Destructor
~NavigationWidgetFactory();
//! Access to static instance
static NavigationWidgetFactory *instance();
// Core::INavigationWidgetFactory
//! \implements Core::INavigationWidgetFactory::displayName
QString displayName() const;
//! \implements Core::INavigationWidgetFactory::priority
int priority() const;
//! \implements Core::INavigationWidgetFactory::id
Core::Id id() const;
//! \implements Core::INavigationWidgetFactory::activationSequence
QKeySequence activationSequence() const;
//! \implements Core::INavigationWidgetFactory::createWidget
Core::NavigationView createWidget();
......@@ -70,9 +50,6 @@ public:
//! \implements Core::INavigationWidgetFactory::restoreSettings
void restoreSettings(int position, QWidget *widget);
signals:
void widgetIsCreated();
};
} // namespace Internal
......
......@@ -51,11 +51,8 @@ bool Plugin::initialize(const QStringList &arguments, QString *errorMessage)
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
// create a navigation widget factory
(void) new NavigationWidgetFactory;
// add to ExtensionSystem
addAutoReleasedObject(NavigationWidgetFactory::instance());
addAutoReleasedObject(new NavigationWidgetFactory);
// create manager
(void) new Manager(this);
......
......@@ -216,42 +216,19 @@ void OpenEditorsWidget::contextMenuRequested(QPoint pos)
// OpenEditorsViewFactory
///
NavigationView OpenEditorsViewFactory::createWidget()
{
NavigationView n;
n.widget = new OpenEditorsWidget();
return n;
}
QString OpenEditorsViewFactory::displayName() const
{
return OpenEditorsWidget::tr("Open Documents");
}
int OpenEditorsViewFactory::priority() const
{
return 200;
}
Id OpenEditorsViewFactory::id() const
{
return "Open Documents";
}
QKeySequence OpenEditorsViewFactory::activationSequence() const
{
return QKeySequence(Core::UseMacShortcuts ? tr("Meta+O") : tr("Alt+O"));
}
OpenEditorsViewFactory::OpenEditorsViewFactory()
{
setId("Open Documents");
setDisplayName(OpenEditorsWidget::tr("Open Documents"));
setActivationSequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+O") : tr("Alt+O")));
setPriority(200);
}
OpenEditorsViewFactory::~OpenEditorsViewFactory()
NavigationView OpenEditorsViewFactory::createWidget()
{
return NavigationView(new OpenEditorsWidget());
}
ProxyModel::ProxyModel(QObject *parent) : QAbstractProxyModel(parent)
{
}
......
......@@ -109,13 +109,10 @@ private:
class OpenEditorsViewFactory : public Core::INavigationWidgetFactory
{
Q_OBJECT
public:
OpenEditorsViewFactory();
~OpenEditorsViewFactory();
QString displayName() const;
int priority() const;
Id id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
};
......
......@@ -89,12 +89,60 @@
using namespace Core;
/*!
Creates a \l{Core::NavigationViewFactory}.
*/
INavigationWidgetFactory::INavigationWidgetFactory()
: m_priority(0)
{
}
/*!
Sets the display name for the factory.
\sa displayName()
*/
void INavigationWidgetFactory::setDisplayName(const QString &displayName)
{
m_displayName = displayName;
}
/*!
Sets the priority for the factory.
\sa priority()
*/
void INavigationWidgetFactory::setPriority(int priority)
{
m_priority = priority;
}
/*!
Sets the id for the factory.
\sa id()
*/
void INavigationWidgetFactory::setId(Id id)
{
m_id = id;
}
/*!
Sets the keyboard activation sequence for the factory.
\sa activationSequence()
*/
void INavigationWidgetFactory::setActivationSequence(const QKeySequence &keys)
{
m_activationSequence = keys;
}
/*!
Returns the keyboard shortcut to activate an instance of a navigation widget.
*/
QKeySequence INavigationWidgetFactory::activationSequence() const
{
return QKeySequence();
return m_activationSequence;
}
/*!
......
......@@ -34,10 +34,10 @@
#include <QObject>
#include <QList>
#include <QKeySequence>
QT_BEGIN_NAMESPACE
class QToolButton;
class QKeySequence;
class QWidget;
QT_END_NAMESPACE
......@@ -45,6 +45,8 @@ namespace Core {
struct NavigationView
{
NavigationView(QWidget *w = 0) : widget(w) {}
QWidget *widget;
QList<QToolButton *> dockToolBarWidgets;
};
......@@ -54,12 +56,18 @@ class CORE_EXPORT INavigationWidgetFactory : public QObject
Q_OBJECT
public:
INavigationWidgetFactory() {}
INavigationWidgetFactory();
void setDisplayName(const QString &displayName);
void setPriority(int priority);
void setId(Id id);
void setActivationSequence(const QKeySequence &keys);
QString displayName() const { return m_displayName ; }
int priority() const { return m_priority; }
Id id() const { return m_id; }
QKeySequence activationSequence() const;
virtual QString displayName() const = 0;
virtual int priority() const = 0;
virtual Id id() const = 0;
virtual QKeySequence activationSequence() const;
// This design is not optimal, think about it again once we need to extend it
// It could be implemented as returning an object which has both the widget
// and the docktoolbar widgets
......@@ -68,6 +76,12 @@ public:
virtual void saveSettings(int position, QWidget *widget);
virtual void restoreSettings(int position, QWidget *widget);
private:
QString m_displayName;
int m_priority;
Id m_id;
QKeySequence m_activationSequence;
};
} // namespace Core
......
......@@ -46,11 +46,9 @@ const char M_REFACTORING_MENU_INSERTION_POINT[] = "CppEditor.RefactorGroup";
const char UPDATE_CODEMODEL[] = "CppEditor.UpdateCodeModel";
const char INSPECT_CPP_CODEMODEL[] = "CppEditor.InspectCppCodeModel";
const int TYPE_HIERARCHY_PRIORITY = 700;
const char TYPE_HIERARCHY_ID[] = "CppEditor.TypeHierarchy";
const char OPEN_TYPE_HIERARCHY[] = "CppEditor.OpenTypeHierarchy";
const int INCLUDE_HIERARCHY_PRIORITY = 800;
const char INCLUDE_HIERARCHY_ID[] = "CppEditor.IncludeHierarchy";
const char OPEN_INCLUDE_HIERARCHY[] = "CppEditor.OpenIncludeHierarchy";
......
......@@ -207,30 +207,9 @@ CppIncludeHierarchyStackedWidget::~CppIncludeHierarchyStackedWidget()
// CppIncludeHierarchyFactory
CppIncludeHierarchyFactory::CppIncludeHierarchyFactory()
{
}
CppIncludeHierarchyFactory::~CppIncludeHierarchyFactory()
{
}
QString CppIncludeHierarchyFactory::displayName() const
{
return tr("Include Hierarchy");
}
int CppIncludeHierarchyFactory::priority() const
{
return Constants::INCLUDE_HIERARCHY_PRIORITY;
}
Core::Id CppIncludeHierarchyFactory::id() const
{
return Core::Id(Constants::INCLUDE_HIERARCHY_ID);
}
QKeySequence CppIncludeHierarchyFactory::activationSequence() const
{
return QKeySequence();
setDisplayName(tr("Include Hierarchy"));
setPriority(800);
setId(Constants::INCLUDE_HIERARCHY_ID);
}
Core::NavigationView CppIncludeHierarchyFactory::createWidget()
......
......@@ -106,12 +106,7 @@ class CppIncludeHierarchyFactory : public Core::INavigationWidgetFactory
Q_OBJECT
public:
CppIncludeHierarchyFactory();
virtual ~CppIncludeHierarchyFactory();
QString displayName() const;
int priority() const;
Core::Id id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
};
......
......@@ -256,38 +256,17 @@ CppTypeHierarchyStackedWidget::~CppTypeHierarchyStackedWidget()
// CppTypeHierarchyFactory
CppTypeHierarchyFactory::CppTypeHierarchyFactory()
{}
CppTypeHierarchyFactory::~CppTypeHierarchyFactory()
{}
QString CppTypeHierarchyFactory::displayName() const
{
return tr("Type Hierarchy");
}
int CppTypeHierarchyFactory::priority() const
{
return Constants::TYPE_HIERARCHY_PRIORITY;
}
Core::Id CppTypeHierarchyFactory::id() const
{
return Core::Id(Constants::TYPE_HIERARCHY_ID);
}
QKeySequence CppTypeHierarchyFactory::activationSequence() const
{
return QKeySequence();
setDisplayName(tr("Type Hierarchy"));
setPriority(700);
setId(Constants::TYPE_HIERARCHY_ID);
}
Core::NavigationView CppTypeHierarchyFactory::createWidget()
{
CppTypeHierarchyStackedWidget *w = new CppTypeHierarchyStackedWidget;
static_cast<CppTypeHierarchyWidget *>(w->currentWidget())->perform();
Core::NavigationView navigationView;
navigationView.widget = w;
return navigationView;
return Core::NavigationView(w);
}
} // namespace Internal
......
......@@ -109,12 +109,7 @@ class CppTypeHierarchyFactory : public Core::INavigationWidgetFactory
Q_OBJECT
public:
CppTypeHierarchyFactory();
virtual ~CppTypeHierarchyFactory();
virtual QString displayName() const;
virtual int priority() const;
virtual Core::Id id() const;
virtual QKeySequence activationSequence() const;
virtual Core::NavigationView createWidget();
};
......
......@@ -415,30 +415,10 @@ void FolderNavigationWidget::ensureCurrentIndex()
// --------------------FolderNavigationWidgetFactory
FolderNavigationWidgetFactory::FolderNavigationWidgetFactory()
{
}
FolderNavigationWidgetFactory::~FolderNavigationWidgetFactory()
{
}
QString FolderNavigationWidgetFactory::displayName() const
{
return tr("File System");
}
int FolderNavigationWidgetFactory::priority() const
{
return 400;
}
Core::Id FolderNavigationWidgetFactory::id() const
{
return "File System";
}
QKeySequence FolderNavigationWidgetFactory::activationSequence() const
{
return QKeySequence(Core::UseMacShortcuts ? tr("Meta+Y") : tr("Alt+Y"));
setDisplayName(tr("File System"));
setPriority(400);
setId("File System");
setActivationSequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Y") : tr("Alt+Y")));
}
Core::NavigationView FolderNavigationWidgetFactory::createWidget()
......
......@@ -99,12 +99,7 @@ class FolderNavigationWidgetFactory : public Core::INavigationWidgetFactory
Q_OBJECT
public:
FolderNavigationWidgetFactory();
~FolderNavigationWidgetFactory();
QString displayName() const;
int priority() const;
Core::Id id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
void saveSettings(int position, QWidget *widget);
void restoreSettings(int position, QWidget *widget);
......
......@@ -406,30 +406,10 @@ bool ProjectTreeWidget::projectFilter()
ProjectTreeWidgetFactory::ProjectTreeWidgetFactory()
{
}
ProjectTreeWidgetFactory::~ProjectTreeWidgetFactory()
{
}
QString ProjectTreeWidgetFactory::displayName() const
{
return tr("Projects");
}
int ProjectTreeWidgetFactory::priority() const
{
return 100;
}
Id ProjectTreeWidgetFactory::id() const
{
return "Projects";
}
QKeySequence ProjectTreeWidgetFactory::activationSequence() const
{
return QKeySequence(UseMacShortcuts ? tr("Meta+X") : tr("Alt+X"));
setDisplayName(tr("Projects"));
setPriority(100);
setId("Projects");
setActivationSequence(QKeySequence(UseMacShortcuts ? tr("Meta+X") : tr("Alt+X")));
}
NavigationView ProjectTreeWidgetFactory::createWidget()
......
......@@ -107,11 +107,7 @@ class ProjectTreeWidgetFactory : public Core::INavigationWidgetFactory
Q_OBJECT
public:
ProjectTreeWidgetFactory();
~ProjectTreeWidgetFactory();
QString displayName() const;
int priority() const;
Core::Id id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
void restoreSettings(int position, QWidget *widget);
void saveSettings(int position, QWidget *widget);
......
......@@ -175,6 +175,13 @@ void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor)
}
}
OutlineFactory::OutlineFactory()
{
setDisplayName(tr("Outline"));
setId("Outline");
setPriority(600);
}
QList<IOutlineWidgetFactory*> OutlineFactory::widgetFactories() const
{
return m_factories;
......@@ -185,26 +192,6 @@ void OutlineFactory::setWidgetFactories(QList<IOutlineWidgetFactory*> factories)
m_factories = factories;
}
QString OutlineFactory::displayName() const
{
return tr("Outline");
}
int OutlineFactory::priority() const
{
return 600;
}
Core::Id OutlineFactory::id() const
{
return "Outline";
}
QKeySequence OutlineFactory::activationSequence() const
{
return QKeySequence();
}
Core::NavigationView OutlineFactory::createWidget()
{
Core::NavigationView n;
......
......@@ -78,16 +78,12 @@ class OutlineFactory : public Core::INavigationWidgetFactory
{
Q_OBJECT
public:
OutlineFactory() {}
OutlineFactory();
QList<IOutlineWidgetFactory*> widgetFactories() const;
void setWidgetFactories(QList<IOutlineWidgetFactory*> factories);
// from INavigationWidgetFactory
virtual QString displayName() const;
virtual int priority() const;
virtual Core::Id id() const;
virtual QKeySequence activationSequence() const;
virtual Core::NavigationView createWidget();
virtual void saveSettings(int position, QWidget *widget);
virtual void restoreSettings(int position, QWidget *widget);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment