2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "navigationwidget.h"
|
2010-09-16 12:26:28 +02:00
|
|
|
#include "navigationsubwidget.h"
|
2009-01-23 13:03:36 +01:00
|
|
|
#include "icore.h"
|
2010-06-25 12:56:16 +02:00
|
|
|
#include "icontext.h"
|
2009-01-23 13:03:36 +01:00
|
|
|
#include "coreconstants.h"
|
|
|
|
|
#include "inavigationwidgetfactory.h"
|
|
|
|
|
#include "modemanager.h"
|
|
|
|
|
#include "actionmanager/actionmanager.h"
|
2010-03-18 10:59:06 +01:00
|
|
|
#include "actionmanager/command.h"
|
2010-09-10 14:13:19 +02:00
|
|
|
#include "uniqueidmanager.h"
|
2009-01-23 13:03:36 +01:00
|
|
|
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
2009-10-01 16:38:08 +02:00
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtCore/QSettings>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
#include <QtGui/QHBoxLayout>
|
|
|
|
|
#include <QtGui/QResizeEvent>
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <QtGui/QToolButton>
|
2009-10-01 16:38:08 +02:00
|
|
|
#include <QtGui/QShortcut>
|
2010-07-15 12:24:03 +02:00
|
|
|
#include <QtGui/QStandardItemModel>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Core::INavigationWidgetFactory *)
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
namespace Core {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
NavigationWidgetPlaceHolder *NavigationWidgetPlaceHolder::m_current = 0;
|
|
|
|
|
|
|
|
|
|
NavigationWidgetPlaceHolder* NavigationWidgetPlaceHolder::current()
|
|
|
|
|
{
|
|
|
|
|
return m_current;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NavigationWidgetPlaceHolder::NavigationWidgetPlaceHolder(Core::IMode *mode, QWidget *parent)
|
|
|
|
|
:QWidget(parent), m_mode(mode)
|
|
|
|
|
{
|
|
|
|
|
setLayout(new QVBoxLayout);
|
|
|
|
|
layout()->setMargin(0);
|
|
|
|
|
connect(Core::ModeManager::instance(), SIGNAL(currentModeAboutToChange(Core::IMode *)),
|
|
|
|
|
this, SLOT(currentModeAboutToChange(Core::IMode *)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NavigationWidgetPlaceHolder::~NavigationWidgetPlaceHolder()
|
|
|
|
|
{
|
|
|
|
|
if (m_current == this) {
|
|
|
|
|
NavigationWidget::instance()->setParent(0);
|
|
|
|
|
NavigationWidget::instance()->hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NavigationWidgetPlaceHolder::applyStoredSize(int width)
|
|
|
|
|
{
|
|
|
|
|
if (width) {
|
|
|
|
|
QSplitter *splitter = qobject_cast<QSplitter *>(parentWidget());
|
|
|
|
|
if (splitter) {
|
|
|
|
|
// A splitter we need to resize the splitter sizes
|
|
|
|
|
QList<int> sizes = splitter->sizes();
|
|
|
|
|
int index = splitter->indexOf(this);
|
|
|
|
|
int diff = width - sizes.at(index);
|
2008-12-09 11:07:24 +01:00
|
|
|
int adjust = sizes.count() > 1 ? (diff / (sizes.count() - 1)) : 0;
|
|
|
|
|
for (int i = 0; i < sizes.count(); ++i) {
|
2008-12-02 12:01:29 +01:00
|
|
|
if (i != index)
|
|
|
|
|
sizes[i] += adjust;
|
|
|
|
|
}
|
|
|
|
|
sizes[index]= width;
|
|
|
|
|
splitter->setSizes(sizes);
|
|
|
|
|
} else {
|
|
|
|
|
QSize s = size();
|
|
|
|
|
s.setWidth(width);
|
|
|
|
|
resize(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This function does work even though the order in which
|
|
|
|
|
// the placeHolder get the signal is undefined.
|
|
|
|
|
// It does ensure that after all PlaceHolders got the signal
|
|
|
|
|
// m_current points to the current PlaceHolder, or zero if there
|
|
|
|
|
// is no PlaceHolder in this mode
|
|
|
|
|
// And that the parent of the NavigationWidget gets the correct parent
|
|
|
|
|
void NavigationWidgetPlaceHolder::currentModeAboutToChange(Core::IMode *mode)
|
|
|
|
|
{
|
|
|
|
|
NavigationWidget *navigationWidget = NavigationWidget::instance();
|
|
|
|
|
|
|
|
|
|
if (m_current == this) {
|
|
|
|
|
m_current = 0;
|
|
|
|
|
navigationWidget->setParent(0);
|
|
|
|
|
navigationWidget->hide();
|
|
|
|
|
navigationWidget->placeHolderChanged(m_current);
|
|
|
|
|
}
|
|
|
|
|
if (m_mode == mode) {
|
|
|
|
|
m_current = this;
|
|
|
|
|
|
|
|
|
|
int width = navigationWidget->storedWidth();
|
|
|
|
|
|
|
|
|
|
layout()->addWidget(navigationWidget);
|
|
|
|
|
navigationWidget->show();
|
|
|
|
|
|
|
|
|
|
applyStoredSize(width);
|
|
|
|
|
setVisible(navigationWidget->isShown());
|
|
|
|
|
navigationWidget->placeHolderChanged(m_current);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
struct NavigationWidgetPrivate {
|
|
|
|
|
explicit NavigationWidgetPrivate(QAction *toggleSideBarAction);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
QList<Internal::NavigationSubWidget *> m_subWidgets;
|
|
|
|
|
QHash<QShortcut *, QString> m_shortcutMap;
|
|
|
|
|
QHash<QString, Core::Command*> m_commandMap;
|
|
|
|
|
QStandardItemModel *m_factoryModel;
|
|
|
|
|
|
|
|
|
|
bool m_shown;
|
|
|
|
|
bool m_suppressed;
|
|
|
|
|
int m_width;
|
|
|
|
|
static NavigationWidget* m_instance;
|
|
|
|
|
QAction *m_toggleSideBarAction;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
NavigationWidgetPrivate::NavigationWidgetPrivate(QAction *toggleSideBarAction) :
|
2010-07-15 12:24:03 +02:00
|
|
|
m_factoryModel(new QStandardItemModel),
|
|
|
|
|
m_shown(true),
|
|
|
|
|
m_suppressed(false),
|
|
|
|
|
m_width(0),
|
|
|
|
|
m_toggleSideBarAction(toggleSideBarAction)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NavigationWidget *NavigationWidgetPrivate::m_instance = 0;
|
|
|
|
|
|
|
|
|
|
NavigationWidget::NavigationWidget(QAction *toggleSideBarAction) :
|
|
|
|
|
d(new NavigationWidgetPrivate(toggleSideBarAction))
|
|
|
|
|
{
|
|
|
|
|
d->m_factoryModel->setSortRole(FactoryPriorityRole);
|
2008-12-02 12:01:29 +01:00
|
|
|
setOrientation(Qt::Vertical);
|
2010-07-15 12:24:03 +02:00
|
|
|
insertSubItem(0, -1); // we don't have any entry to show yet
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_instance = this;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NavigationWidget::~NavigationWidget()
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
NavigationWidgetPrivate::m_instance = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NavigationWidget *NavigationWidget::instance()
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
return NavigationWidgetPrivate::m_instance;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 12:24:03 +02:00
|
|
|
void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> factories)
|
|
|
|
|
{
|
|
|
|
|
ICore *core = ICore::instance();
|
|
|
|
|
ActionManager *am = core->actionManager();
|
|
|
|
|
Context navicontext(Core::Constants::C_NAVIGATION_PANE);
|
|
|
|
|
|
|
|
|
|
foreach (INavigationWidgetFactory *factory, factories) {
|
|
|
|
|
const QString id = factory->id();
|
|
|
|
|
|
|
|
|
|
QShortcut *shortcut = new QShortcut(this);
|
|
|
|
|
shortcut->setWhatsThis(tr("Activate %1 Pane").arg(factory->displayName()));
|
|
|
|
|
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSubWidget()));
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_shortcutMap.insert(shortcut, id);
|
2010-07-15 12:24:03 +02:00
|
|
|
|
2010-09-10 14:13:19 +02:00
|
|
|
Command *cmd = am->registerShortcut(shortcut,
|
|
|
|
|
Id(QLatin1String("QtCreator.Sidebar.") + id), navicontext);
|
2010-07-15 12:24:03 +02:00
|
|
|
cmd->setDefaultKeySequence(factory->activationSequence());
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_commandMap.insert(id, cmd);
|
2010-07-15 12:24:03 +02:00
|
|
|
|
|
|
|
|
QStandardItem *newRow = new QStandardItem(factory->displayName());
|
|
|
|
|
newRow->setData(qVariantFromValue(factory), FactoryObjectRole);
|
|
|
|
|
newRow->setData(factory->id(), FactoryIdRole);
|
2010-09-09 14:35:26 +02:00
|
|
|
newRow->setData(factory->priority(), FactoryPriorityRole);
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_factoryModel->appendRow(newRow);
|
2010-07-15 12:24:03 +02:00
|
|
|
}
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_factoryModel->sort(0);
|
2010-07-15 12:24:03 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
int NavigationWidget::storedWidth()
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
return d->m_width;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 12:24:03 +02:00
|
|
|
QAbstractItemModel *NavigationWidget::factoryModel() const
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
return d->m_factoryModel;
|
2010-07-15 12:24:03 +02:00
|
|
|
}
|
|
|
|
|
|
2009-12-08 18:29:44 +01:00
|
|
|
void NavigationWidget::updateToggleText()
|
|
|
|
|
{
|
|
|
|
|
if (isShown())
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_toggleSideBarAction->setText(tr("Hide Sidebar"));
|
2009-12-08 18:29:44 +01:00
|
|
|
else
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_toggleSideBarAction->setText(tr("Show Sidebar"));
|
2009-12-08 18:29:44 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void NavigationWidget::placeHolderChanged(NavigationWidgetPlaceHolder *holder)
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_toggleSideBarAction->setEnabled(holder);
|
|
|
|
|
d->m_toggleSideBarAction->setChecked(holder && isShown());
|
2009-12-08 18:29:44 +01:00
|
|
|
updateToggleText();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NavigationWidget::resizeEvent(QResizeEvent *re)
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
if (d->m_width && re->size().width())
|
|
|
|
|
d->m_width = re->size().width();
|
2008-12-02 12:01:29 +01:00
|
|
|
MiniSplitter::resizeEvent(re);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position,int index)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
for (int pos = position + 1; pos < d->m_subWidgets.size(); ++pos) {
|
|
|
|
|
d->m_subWidgets.at(pos)->setPosition(pos + 1);
|
2010-07-15 12:24:03 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
Internal::NavigationSubWidget *nsw = new Internal::NavigationSubWidget(this, position, index);
|
2009-08-20 17:27:33 +02:00
|
|
|
connect(nsw, SIGNAL(splitMe()), this, SLOT(splitSubWidget()));
|
|
|
|
|
connect(nsw, SIGNAL(closeMe()), this, SLOT(closeSubWidget()));
|
2008-12-02 12:01:29 +01:00
|
|
|
insertWidget(position, nsw);
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_subWidgets.insert(position, nsw);
|
2010-07-15 12:24:03 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
return nsw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NavigationWidget::activateSubWidget()
|
|
|
|
|
{
|
|
|
|
|
QShortcut *original = qobject_cast<QShortcut *>(sender());
|
2010-09-16 12:26:28 +02:00
|
|
|
QString id = d->m_shortcutMap[original];
|
2010-08-13 10:10:43 +02:00
|
|
|
activateSubWidget(id);
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-08-13 10:10:43 +02:00
|
|
|
void NavigationWidget::activateSubWidget(const QString &factoryId)
|
|
|
|
|
{
|
|
|
|
|
setShown(true);
|
2010-09-16 12:26:28 +02:00
|
|
|
foreach (Internal::NavigationSubWidget *subWidget, d->m_subWidgets) {
|
2010-08-13 10:10:43 +02:00
|
|
|
if (subWidget->factory()->id() == factoryId) {
|
2008-12-02 12:01:29 +01:00
|
|
|
subWidget->setFocusWidget();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-07-15 12:24:03 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-08-13 10:10:43 +02:00
|
|
|
int index = factoryIndex(factoryId);
|
2010-07-15 12:24:03 +02:00
|
|
|
if (index >= 0) {
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_subWidgets.first()->setFactoryIndex(index);
|
|
|
|
|
d->m_subWidgets.first()->setFocusWidget();
|
2010-07-15 12:24:03 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-08-20 17:27:33 +02:00
|
|
|
void NavigationWidget::splitSubWidget()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
Internal::NavigationSubWidget *original = qobject_cast<Internal::NavigationSubWidget *>(sender());
|
2008-12-02 12:01:29 +01:00
|
|
|
int pos = indexOf(original) + 1;
|
2010-07-15 12:24:03 +02:00
|
|
|
insertSubItem(pos, original->factoryIndex());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-08-20 17:27:33 +02:00
|
|
|
void NavigationWidget::closeSubWidget()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
if (d->m_subWidgets.count() != 1) {
|
|
|
|
|
Internal::NavigationSubWidget *subWidget = qobject_cast<Internal::NavigationSubWidget *>(sender());
|
2010-07-15 12:24:03 +02:00
|
|
|
subWidget->saveSettings();
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_subWidgets.removeOne(subWidget);
|
2008-12-02 12:01:29 +01:00
|
|
|
subWidget->hide();
|
|
|
|
|
subWidget->deleteLater();
|
|
|
|
|
} else {
|
|
|
|
|
setShown(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NavigationWidget::saveSettings(QSettings *settings)
|
|
|
|
|
{
|
2010-07-15 12:24:03 +02:00
|
|
|
QStringList viewIds;
|
2010-09-16 12:26:28 +02:00
|
|
|
for (int i=0; i<d->m_subWidgets.count(); ++i) {
|
|
|
|
|
d->m_subWidgets.at(i)->saveSettings();
|
|
|
|
|
viewIds.append(d->m_subWidgets.at(i)->factory()->id());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2010-07-15 12:24:03 +02:00
|
|
|
settings->setValue("Navigation/Views", viewIds);
|
2008-12-02 12:01:29 +01:00
|
|
|
settings->setValue("Navigation/Visible", isShown());
|
|
|
|
|
settings->setValue("Navigation/VerticalPosition", saveState());
|
2010-09-16 12:26:28 +02:00
|
|
|
settings->setValue("Navigation/Width", d->m_width);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-11 14:35:14 +01:00
|
|
|
void NavigationWidget::restoreSettings(QSettings *settings)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-03-26 15:54:05 +01:00
|
|
|
int version = settings->value("Navigation/Version", 1).toInt();
|
2010-07-15 12:24:03 +02:00
|
|
|
QStringList viewIds = settings->value("Navigation/Views").toStringList();
|
2009-03-26 15:54:05 +01:00
|
|
|
|
|
|
|
|
bool restoreSplitterState = true;
|
|
|
|
|
if (version == 1) {
|
2010-07-15 12:24:03 +02:00
|
|
|
if (viewIds.isEmpty())
|
|
|
|
|
viewIds += "Projects";
|
|
|
|
|
if (!viewIds.contains("Open Documents")) {
|
|
|
|
|
viewIds += "Open Documents";
|
2009-03-26 15:54:05 +01:00
|
|
|
restoreSplitterState = false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-03-26 15:54:05 +01:00
|
|
|
settings->setValue("Navigation/Version", 2);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-15 12:24:03 +02:00
|
|
|
for (int i=0; i<viewIds.count(); ++i) {
|
|
|
|
|
const QString &view = viewIds.at(i);
|
|
|
|
|
int index = factoryIndex(view);
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
if (i >= d->m_subWidgets.size()) {
|
2010-07-15 12:24:03 +02:00
|
|
|
insertSubItem(i, index);
|
|
|
|
|
} else {
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_subWidgets.at(i)->setFactoryIndex(index);
|
2010-07-15 12:24:03 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (settings->contains("Navigation/Visible")) {
|
|
|
|
|
setShown(settings->value("Navigation/Visible").toBool());
|
|
|
|
|
} else {
|
|
|
|
|
setShown(true);
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-26 15:54:05 +01:00
|
|
|
if (restoreSplitterState && settings->contains("Navigation/VerticalPosition")) {
|
2008-12-02 12:01:29 +01:00
|
|
|
restoreState(settings->value("Navigation/VerticalPosition").toByteArray());
|
2009-03-26 15:54:05 +01:00
|
|
|
} else {
|
|
|
|
|
QList<int> sizes;
|
|
|
|
|
sizes += 256;
|
2010-07-15 12:24:03 +02:00
|
|
|
for (int i = viewIds.size()-1; i > 0; --i)
|
2009-03-26 15:54:05 +01:00
|
|
|
sizes.prepend(512);
|
|
|
|
|
setSizes(sizes);
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
if (settings->contains("Navigation/Width")) {
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_width = settings->value("Navigation/Width").toInt();
|
|
|
|
|
if (!d->m_width)
|
|
|
|
|
d->m_width = 240;
|
2008-12-02 12:01:29 +01:00
|
|
|
} else {
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_width = 240; //pixel
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
// Apply
|
|
|
|
|
if (NavigationWidgetPlaceHolder::m_current) {
|
2010-09-16 12:26:28 +02:00
|
|
|
NavigationWidgetPlaceHolder::m_current->applyStoredSize(d->m_width);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-11 14:59:04 +02:00
|
|
|
void NavigationWidget::closeSubWidgets()
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
foreach (Internal::NavigationSubWidget *subWidget, d->m_subWidgets) {
|
2010-08-11 14:59:04 +02:00
|
|
|
subWidget->saveSettings();
|
|
|
|
|
delete subWidget;
|
|
|
|
|
}
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_subWidgets.clear();
|
2010-08-11 14:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void NavigationWidget::setShown(bool b)
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
if (d->m_shown == b)
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_shown = b;
|
2009-01-06 17:03:08 +01:00
|
|
|
if (NavigationWidgetPlaceHolder::m_current) {
|
2010-09-16 12:26:28 +02:00
|
|
|
NavigationWidgetPlaceHolder::m_current->setVisible(d->m_shown && !d->m_suppressed);
|
|
|
|
|
d->m_toggleSideBarAction->setChecked(d->m_shown);
|
2009-01-06 17:03:08 +01:00
|
|
|
} else {
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_toggleSideBarAction->setChecked(false);
|
2009-01-06 17:03:08 +01:00
|
|
|
}
|
2009-12-08 18:29:44 +01:00
|
|
|
updateToggleText();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NavigationWidget::isShown() const
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
return d->m_shown;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NavigationWidget::isSuppressed() const
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
return d->m_suppressed;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NavigationWidget::setSuppressed(bool b)
|
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
if (d->m_suppressed == b)
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_suppressed = b;
|
2008-12-02 12:01:29 +01:00
|
|
|
if (NavigationWidgetPlaceHolder::m_current)
|
2010-09-16 12:26:28 +02:00
|
|
|
NavigationWidgetPlaceHolder::m_current->setVisible(d->m_shown && !d->m_suppressed);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 12:24:03 +02:00
|
|
|
int NavigationWidget::factoryIndex(const QString &id)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
for (int row = 0; row < d->m_factoryModel->rowCount(); ++row) {
|
|
|
|
|
if (d->m_factoryModel->data(d->m_factoryModel->index(row, 0), FactoryIdRole).toString() == id) {
|
2010-07-15 12:24:03 +02:00
|
|
|
return row;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
QHash<QString, Core::Command*> NavigationWidget::commandMap() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
return d->m_commandMap;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
} // namespace Core
|
2008-12-11 14:35:14 +01:00
|
|
|
|