Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / coreplugin / uavgadgetmanager / uavgadgetmanager.h
blob5389fbcae5edcaf38a7010ab968c9cbaa8675ef3
1 /**
2 ******************************************************************************
4 * @file uavgadgetmanager.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup CorePlugin Core Plugin
10 * @{
11 * @brief The Core GCS plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef UAVGADGETMANAGER_H
30 #define UAVGADGETMANAGER_H
32 #include "../core_global.h"
34 #include <coreplugin/icorelistener.h>
35 #include <coreplugin/imode.h>
37 #include <QWidget>
38 #include <QList>
39 #include <QIcon>
41 QT_BEGIN_NAMESPACE
42 class QModelIndex;
43 class QSettings;
44 QT_END_NAMESPACE
46 namespace Core {
47 class IContext;
48 class ICore;
49 class IUAVGadget;
51 namespace Internal {
52 class UAVGadgetView;
53 class SplitterOrView;
54 } // namespace Internal
56 class CORE_EXPORT UAVGadgetManager : public IMode {
57 Q_OBJECT
59 public:
61 explicit UAVGadgetManager(ICore *core, QString name, QIcon icon, int priority, QString uniqueName, QWidget *parent);
62 virtual ~UAVGadgetManager();
64 // IMode
65 QString name() const
67 return m_name;
69 QIcon icon() const
71 return m_icon;
73 int priority() const
75 return m_priority;
77 void setPriority(int priority)
79 m_priority = priority;
81 const char *uniqueModeName() const
83 return m_uniqueModeName;
85 QList<int> context() const;
87 void init();
88 QWidget *widget()
90 return m_widget;
93 void ensureUAVGadgetManagerVisible();
95 IUAVGadget *currentGadget() const;
97 void saveState(QSettings &) const;
98 bool restoreState(QSettings &);
100 void readSettings(QSettings &settings);
101 void saveSettings(QSettings &settings) const;
103 bool toolbarsShown()
105 return m_showToolbars;
108 signals:
109 void currentGadgetChanged(IUAVGadget *gadget);
110 void showUavGadgetMenus(bool show, bool hasSplitter);
111 void updateSplitMenus(bool hasSplitter);
113 private slots:
114 void handleContextChange(Core::IContext *context);
115 void updateUavGadgetMenus();
116 void modeChanged(Core::IMode *mode);
119 public slots:
120 void split(Qt::Orientation orientation);
121 void split();
122 void splitSideBySide();
123 void removeCurrentSplit();
124 void removeAllSplits();
125 void gotoOtherSplit();
126 void showToolbars(bool show);
128 private:
129 void setCurrentGadget(IUAVGadget *gadget);
130 void addGadgetToContext(IUAVGadget *gadget);
131 void removeGadget(IUAVGadget *gadget);
132 void closeView(Core::Internal::UAVGadgetView *view);
133 void emptyView(Core::Internal::UAVGadgetView *view);
134 Core::Internal::SplitterOrView *currentSplitterOrView() const;
136 bool m_showToolbars;
137 Core::Internal::SplitterOrView *m_splitterOrView;
138 Core::IUAVGadget *m_currentGadget;
139 Core::ICore *m_core;
141 QString m_name;
142 QIcon m_icon;
143 int m_priority;
144 QString m_uniqueName;
145 QByteArray m_uniqueNameBA;
146 const char *m_uniqueModeName;
147 QWidget *m_widget;
149 friend class Core::Internal::SplitterOrView;
150 friend class Core::Internal::UAVGadgetView;
152 } // namespace Core
154 #endif // UAVGADGETMANAGER_H