Commit b23b4588 authored by Denis Mingulov's avatar Denis Mingulov Committed by hjk

Navigation Widget: add 'Priority' support

Merge-request: 176
Reviewed-by: default avatarhjk <qtc-committer@nokia.com>
parent 0c9d85a9
......@@ -778,6 +778,11 @@ QString BookmarkViewFactory::displayName() const
return BookmarkView::tr("Bookmarks");
}
int BookmarkViewFactory::priority() const
{
return 300;
}
QString BookmarkViewFactory::id() const
{
return QLatin1String("Bookmarks");
......
......@@ -173,6 +173,7 @@ class BookmarkViewFactory : public Core::INavigationWidgetFactory
public:
BookmarkViewFactory(BookmarkManager *bm);
QString displayName() const;
int priority() const;
QString id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
......
......@@ -36,6 +36,9 @@ namespace Constants {
//! Navi Widget Factory id
const char * const CLASSVIEWNAVIGATION_ID = "Class View";
//! Navi Widget Factory priority
const int CLASSVIEWNAVIGATION_PRIORITY = 500;
//! Settings' group
const char * const CLASSVIEW_SETTINGS_GROUP = "ClassView";
......
......@@ -87,6 +87,11 @@ QString NavigationWidgetFactory::displayName() const
return tr("Class View");
}
int NavigationWidgetFactory::priority() const
{
return Constants::CLASSVIEWNAVIGATION_PRIORITY;
}
QString NavigationWidgetFactory::id() const
{
return QLatin1String(Constants::CLASSVIEWNAVIGATION_ID);
......
......@@ -62,6 +62,9 @@ public:
//! \implements Core::INavigationWidgetFactory::displayName
QString displayName() const;
//! \implements Core::INavigationWidgetFactory::priority
int priority() const;
//! \implements Core::INavigationWidgetFactory::id
QString id() const;
......
......@@ -247,6 +247,11 @@ QString OpenEditorsViewFactory::displayName() const
return OpenEditorsWidget::tr("Open Documents");
}
int OpenEditorsViewFactory::priority() const
{
return 200;
}
QString OpenEditorsViewFactory::id() const
{
return QLatin1String("Open Documents");
......
......@@ -85,6 +85,7 @@ public:
OpenEditorsViewFactory();
~OpenEditorsViewFactory();
QString displayName() const;
int priority() const;
QString id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
......
......@@ -56,6 +56,7 @@ public:
virtual ~INavigationWidgetFactory();
virtual QString displayName() const = 0;
virtual int priority() const = 0;
virtual QString id() const = 0;
virtual QKeySequence activationSequence() const;
// This design is not optimal, think about it again once we need to extend it
......
......@@ -143,6 +143,7 @@ NavigationWidget::NavigationWidget(QAction *toggleSideBarAction) :
m_width(0),
m_toggleSideBarAction(toggleSideBarAction)
{
m_factoryModel->setSortRole(FactoryPriorityRole);
setOrientation(Qt::Vertical);
insertSubItem(0, -1); // we don't have any entry to show yet
m_instance = this;
......@@ -180,8 +181,10 @@ void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> fact
QStandardItem *newRow = new QStandardItem(factory->displayName());
newRow->setData(qVariantFromValue(factory), FactoryObjectRole);
newRow->setData(factory->id(), FactoryIdRole);
newRow->setData(factory->priority(), FactoryPriorityRole);
m_factoryModel->appendRow(newRow);
}
m_factoryModel->sort(0);
}
int NavigationWidget::storedWidth()
......@@ -403,8 +406,7 @@ int NavigationWidget::factoryIndex(const QString &id)
NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int position, int factoryIndex)
: m_parentWidget(parentWidget),
m_position(position),
m_currentIndex(-1)
m_position(position)
{
m_navigationComboBox = new NavComboBox(this);
m_navigationComboBox->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
......@@ -412,6 +414,7 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int pos
m_navigationComboBox->setMinimumContentsLength(0);
m_navigationComboBox->setModel(parentWidget->factoryModel());
m_navigationWidget = 0;
m_navigationWidgetFactory = 0;
m_toolBar = new Utils::StyledBar(this);
QHBoxLayout *toolBarLayout = new QHBoxLayout;
......@@ -453,27 +456,24 @@ NavigationSubWidget::~NavigationSubWidget()
void NavigationSubWidget::comboBoxIndexChanged(int factoryIndex)
{
if (m_currentIndex == factoryIndex)
return;
saveSettings();
m_currentIndex = factoryIndex;
// Remove toolbutton
foreach (QWidget *w, m_additionalToolBarWidgets)
delete w;
m_additionalToolBarWidgets.clear();
// Remove old Widget
delete m_navigationWidget;
m_navigationWidget = 0;
m_navigationWidgetFactory = 0;
if (factoryIndex == -1)
return;
// Get new stuff
INavigationWidgetFactory *factory
= m_navigationComboBox->itemData(factoryIndex,
NavigationWidget::FactoryObjectRole).value<INavigationWidgetFactory *>();
NavigationView n = factory->createWidget();
m_navigationWidgetFactory = m_navigationComboBox->itemData(factoryIndex,
NavigationWidget::FactoryObjectRole).value<INavigationWidgetFactory *>();
NavigationView n = m_navigationWidgetFactory->createWidget();
m_navigationWidget = n.widget;
layout()->addWidget(m_navigationWidget);
......@@ -495,10 +495,7 @@ void NavigationSubWidget::setFocusWidget()
INavigationWidgetFactory *NavigationSubWidget::factory()
{
if (m_currentIndex == -1)
return 0;
return m_navigationComboBox->itemData(m_currentIndex,
NavigationWidget::FactoryObjectRole).value<INavigationWidgetFactory *>();
return m_navigationWidgetFactory;
}
......@@ -527,7 +524,7 @@ Core::Command *NavigationSubWidget::command(const QString &title) const
int NavigationSubWidget::factoryIndex() const
{
return m_currentIndex;
return m_navigationComboBox->currentIndex();
}
void NavigationSubWidget::setFactoryIndex(int i)
......
......@@ -77,7 +77,8 @@ class CORE_EXPORT NavigationWidget : public MiniSplitter
public:
enum FactoryModelRoles {
FactoryObjectRole = Qt::UserRole,
FactoryIdRole
FactoryIdRole,
FactoryPriorityRole
};
......@@ -168,10 +169,10 @@ private:
NavigationWidget *m_parentWidget;
QComboBox *m_navigationComboBox;
QWidget *m_navigationWidget;
INavigationWidgetFactory *m_navigationWidgetFactory;
Utils::StyledBar *m_toolBar;
QList<QToolButton *> m_additionalToolBarWidgets;
int m_position;
int m_currentIndex;
};
class NavComboBox : public QComboBox
......
......@@ -48,6 +48,7 @@ const char * const FIND_REFERENCES = "CppEditor.FindReferences";
const char * const JUMP_TO_DEFINITION = "CppEditor.JumpToDefinition";
const char * const UPDATE_CODEMODEL = "CppEditor.UpdateCodeModel";
const int TYPE_HIERARCHY_PRIORITY = 700;
const char * const TYPE_HIERARCHY_ID = "CppEditor.TypeHierarchy";
const char * const OPEN_TYPE_HIERARCHY = "CppEditor.OpenTypeHierarchy";
......
......@@ -262,6 +262,11 @@ QString CppTypeHierarchyFactory::displayName() const
return tr("Type Hierarchy");
}
int CppTypeHierarchyFactory::priority() const
{
return Constants::TYPE_HIERARCHY_PRIORITY;
}
QString CppTypeHierarchyFactory::id() const
{
return QLatin1String(Constants::TYPE_HIERARCHY_ID);
......
......@@ -133,6 +133,7 @@ public:
virtual ~CppTypeHierarchyFactory();
virtual QString displayName() const;
virtual int priority() const;
virtual QString id() const;
virtual QKeySequence activationSequence() const;
virtual Core::NavigationView createWidget();
......
......@@ -466,6 +466,11 @@ QString FolderNavigationWidgetFactory::displayName() const
return tr("File System");
}
int FolderNavigationWidgetFactory::priority() const
{
return 400;
}
QString FolderNavigationWidgetFactory::id() const
{
return QLatin1String("File System");
......
......@@ -102,6 +102,7 @@ public:
~FolderNavigationWidgetFactory();
QString displayName() const;
int priority() const;
QString id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
......
......@@ -340,6 +340,11 @@ QString ProjectTreeWidgetFactory::displayName() const
return tr("Projects");
}
int ProjectTreeWidgetFactory::priority() const
{
return 100;
}
QString ProjectTreeWidgetFactory::id() const
{
return QLatin1String("Projects");
......
......@@ -100,6 +100,7 @@ public:
ProjectTreeWidgetFactory();
~ProjectTreeWidgetFactory();
QString displayName() const;
int priority() const;
QString id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
......
......@@ -164,6 +164,11 @@ QString OutlineFactory::displayName() const
return tr("Outline");
}
int OutlineFactory::priority() const
{
return 600;
}
QString OutlineFactory::id() const
{
return QLatin1String("Outline");
......
......@@ -58,6 +58,7 @@ public:
// from INavigationWidgetFactory
virtual QString displayName() const;
virtual int priority() const;
virtual QString id() const;
virtual QKeySequence activationSequence() const;
virtual Core::NavigationView createWidget();
......
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