2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef NAVIGATIONWIDGET_H
|
|
|
|
|
#define NAVIGATIONWIDGET_H
|
|
|
|
|
|
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;
|
|
|
|
|
class IMode;
|
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
|
|
|
|
|
|
|
|
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:
|
2014-11-16 10:52:41 +02:00
|
|
|
explicit NavigationWidgetPlaceHolder(IMode *mode, QWidget *parent = 0);
|
2010-09-16 12:26:28 +02:00
|
|
|
virtual ~NavigationWidgetPlaceHolder();
|
2008-12-02 12:01:29 +01:00
|
|
|
static NavigationWidgetPlaceHolder* current();
|
|
|
|
|
void applyStoredSize(int width);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2014-11-16 10:52:41 +02:00
|
|
|
void currentModeAboutToChange(IMode *);
|
|
|
|
|
|
|
|
|
|
IMode *m_mode;
|
2008-12-02 12:01:29 +01:00
|
|
|
static NavigationWidgetPlaceHolder* m_current;
|
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
explicit NavigationWidget(QAction *toggleSideBarAction);
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
void activateSubWidget(Id factoryId);
|
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);
|
|
|
|
|
|
|
|
|
|
static NavigationWidget* instance();
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private slots:
|
|
|
|
|
void activateSubWidget();
|
2014-12-04 13:07:01 +01:00
|
|
|
void splitSubWidget(int factoryIndex);
|
2009-08-20 17:27:33 +02:00
|
|
|
void closeSubWidget();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
private:
|
2009-12-08 18:29:44 +01:00
|
|
|
void updateToggleText();
|
2010-08-13 10:10:43 +02:00
|
|
|
Internal::NavigationSubWidget *insertSubItem(int position, int index);
|
2014-07-01 11:08:26 +02:00
|
|
|
int factoryIndex(Id id);
|
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
|
|
|
|
|
|
|
|
|
|
#endif // NAVIGATIONWIDGET_H
|