2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-16 15:00:29 +02:00
|
|
|
#include <coreplugin/minisplitter.h>
|
2011-11-09 12:07:41 +01:00
|
|
|
#include <coreplugin/id.h>
|
2009-07-16 15:00:29 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QHash>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QSettings;
|
2010-09-16 12:26:28 +02:00
|
|
|
class QAbstractItemModel;
|
2010-07-15 12:24:03 +02:00
|
|
|
class QStandardItemModel;
|
2008-12-02 12:01:29 +01:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2009-10-05 11:06:05 +02:00
|
|
|
namespace Core {
|
2008-12-02 12:01:29 +01:00
|
|
|
class INavigationWidgetFactory;
|
2009-01-14 13:17:53 +01:00
|
|
|
class Command;
|
2008-12-02 12:01:29 +01:00
|
|
|
class NavigationWidget;
|
2010-09-16 12:26:28 +02:00
|
|
|
struct NavigationWidgetPrivate;
|
2014-02-11 21:55:42 +02:00
|
|
|
namespace Internal { class NavigationSubWidget; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-09-17 18:31:56 +03:00
|
|
|
enum class Side {
|
|
|
|
|
Left,
|
|
|
|
|
Right
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
class CORE_EXPORT NavigationWidgetPlaceHolder : public QWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2011-09-16 15:00:41 +02:00
|
|
|
friend class Core::NavigationWidget;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2016-09-17 18:31:56 +03:00
|
|
|
explicit NavigationWidgetPlaceHolder(Id mode, Side side, QWidget *parent = 0);
|
2010-09-16 12:26:28 +02:00
|
|
|
virtual ~NavigationWidgetPlaceHolder();
|
2016-09-17 18:31:56 +03:00
|
|
|
static NavigationWidgetPlaceHolder *current(Side side);
|
|
|
|
|
static void setCurrent(Side side, NavigationWidgetPlaceHolder *navWidget);
|
2008-12-02 12:01:29 +01:00
|
|
|
void applyStoredSize(int width);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2016-03-25 20:00:19 +01:00
|
|
|
void currentModeAboutToChange(Id mode);
|
2014-11-16 10:52:41 +02:00
|
|
|
|
2016-03-25 20:00:19 +01:00
|
|
|
Id m_mode;
|
2016-09-17 18:31:56 +03:00
|
|
|
Side m_side;
|
|
|
|
|
static NavigationWidgetPlaceHolder *s_currentLeft;
|
|
|
|
|
static NavigationWidgetPlaceHolder *s_currentRight;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2010-08-13 10:10:43 +02:00
|
|
|
class CORE_EXPORT NavigationWidget : public MiniSplitter
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2011-09-16 15:00:41 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2010-07-15 12:24:03 +02:00
|
|
|
enum FactoryModelRoles {
|
|
|
|
|
FactoryObjectRole = Qt::UserRole,
|
2010-09-09 14:35:26 +02:00
|
|
|
FactoryIdRole,
|
|
|
|
|
FactoryPriorityRole
|
2010-07-15 12:24:03 +02:00
|
|
|
};
|
|
|
|
|
|
2016-09-17 18:31:56 +03:00
|
|
|
explicit NavigationWidget(QAction *toggleSideBarAction, Side side);
|
2010-09-16 12:26:28 +02:00
|
|
|
virtual ~NavigationWidget();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-11-13 13:34:47 +01:00
|
|
|
void setFactories(const QList<INavigationWidgetFactory*> &factories);
|
2010-07-15 12:24:03 +02:00
|
|
|
|
2016-09-17 18:31:56 +03:00
|
|
|
QString settingsGroup() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
void saveSettings(QSettings *settings);
|
2008-12-11 14:35:14 +01:00
|
|
|
void restoreSettings(QSettings *settings);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-09-17 18:31:56 +03:00
|
|
|
QWidget *activateSubWidget(Id factoryId, int preferredPosition);
|
2010-08-11 14:59:04 +02:00
|
|
|
void closeSubWidgets();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
bool isShown() const;
|
|
|
|
|
void setShown(bool b);
|
|
|
|
|
|
|
|
|
|
bool isSuppressed() const;
|
|
|
|
|
void setSuppressed(bool b);
|
|
|
|
|
|
2016-09-17 18:31:56 +03:00
|
|
|
static NavigationWidget *instance(Side side);
|
|
|
|
|
static QWidget *activateSubWidget(Id factoryId, Side fallbackSide);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
int storedWidth();
|
|
|
|
|
|
|
|
|
|
// Called from the place holders
|
|
|
|
|
void placeHolderChanged(NavigationWidgetPlaceHolder *holder);
|
|
|
|
|
|
2014-11-16 10:52:41 +02:00
|
|
|
QHash<Id, Command *> commandMap() const;
|
2010-07-15 12:24:03 +02:00
|
|
|
QAbstractItemModel *factoryModel() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void resizeEvent(QResizeEvent *);
|
2010-07-15 12:24:03 +02:00
|
|
|
|
2016-02-02 09:10:54 +02:00
|
|
|
private:
|
2014-12-04 13:07:01 +01:00
|
|
|
void splitSubWidget(int factoryIndex);
|
2009-08-20 17:27:33 +02:00
|
|
|
void closeSubWidget();
|
2009-12-08 18:29:44 +01:00
|
|
|
void updateToggleText();
|
2016-09-17 18:31:56 +03:00
|
|
|
Internal::NavigationSubWidget *insertSubItem(int position, int factoryIndex);
|
2014-07-01 11:08:26 +02:00
|
|
|
int factoryIndex(Id id);
|
2016-09-17 18:31:56 +03:00
|
|
|
QString settingsKey(const QString &key) const;
|
|
|
|
|
void onSubWidgetFactoryIndexChanged(int factoryIndex);
|
2010-07-15 12:24:03 +02:00
|
|
|
|
2011-09-16 15:00:41 +02:00
|
|
|
NavigationWidgetPrivate *d;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Core
|