mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
GCS/core+gadgets: Second attempt at cleanup of uav gadget interface.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@400 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
3656caccbb
commit
35f4fc06a0
@ -58,7 +58,8 @@ SOURCES += mainwindow.cpp \
|
||||
iconnection.cpp \
|
||||
iuavgadgetconfiguration.cpp \
|
||||
uavgadgetinstancemanager.cpp \
|
||||
uavgadgetoptionspagedecorator.cpp
|
||||
uavgadgetoptionspagedecorator.cpp \
|
||||
uavgadgetdecorator.cpp
|
||||
HEADERS += mainwindow.h \
|
||||
tabpositionindicator.h \
|
||||
fancyactionbar.h \
|
||||
@ -113,7 +114,8 @@ HEADERS += mainwindow.h \
|
||||
iconnection.h \
|
||||
iuavgadgetconfiguration.h \
|
||||
uavgadgetinstancemanager.h \
|
||||
uavgadgetoptionspagedecorator.h
|
||||
uavgadgetoptionspagedecorator.h \
|
||||
uavgadgetdecorator.h
|
||||
FORMS += dialogs/settingsdialog.ui \
|
||||
dialogs/shortcutsettings.ui \
|
||||
generalsettings.ui \
|
||||
|
@ -26,95 +26,3 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "iuavgadget.h"
|
||||
#include "iuavgadgetconfiguration.h"
|
||||
|
||||
using namespace Core;
|
||||
|
||||
IUAVGadget::IUAVGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, QObject *parent) :
|
||||
IContext(parent),
|
||||
m_toolbar(new QComboBox),
|
||||
m_classId(classId),
|
||||
m_activeConfiguration(0),
|
||||
m_configurations(configurations)
|
||||
{
|
||||
m_toolbar->setMinimumContentsLength(15);
|
||||
foreach (IUAVGadgetConfiguration *config, *m_configurations)
|
||||
m_toolbar->addItem(config->name());
|
||||
connect(m_toolbar, SIGNAL(activated(int)), this, SLOT(loadConfiguration(int)));
|
||||
if (m_configurations->count() > 0)
|
||||
loadConfiguration(0);
|
||||
updateToolbar();
|
||||
}
|
||||
|
||||
void IUAVGadget::loadConfiguration(int index) {
|
||||
IUAVGadgetConfiguration* config = m_configurations->at(index);
|
||||
m_activeConfiguration = config;
|
||||
loadConfiguration(config);
|
||||
}
|
||||
|
||||
void IUAVGadget::setActiveConfiguration(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
m_activeConfiguration = config;
|
||||
int index = m_toolbar->findText(config->name());
|
||||
m_toolbar->setCurrentIndex(index);
|
||||
|
||||
}
|
||||
|
||||
void IUAVGadget::configurationChanged(IUAVGadgetConfiguration* config)
|
||||
{
|
||||
if (config == m_activeConfiguration)
|
||||
loadConfiguration(config);
|
||||
}
|
||||
|
||||
void IUAVGadget::configurationAdded(IUAVGadgetConfiguration* config)
|
||||
{
|
||||
m_configurations->append(config);
|
||||
m_toolbar->addItem(config->name());
|
||||
updateToolbar();
|
||||
}
|
||||
|
||||
void IUAVGadget::configurationToBeDeleted(IUAVGadgetConfiguration* config)
|
||||
{
|
||||
int index = m_configurations->indexOf(config);
|
||||
if (index >= 0) {
|
||||
m_toolbar->removeItem(index);
|
||||
m_configurations->removeAt(index);
|
||||
}
|
||||
updateToolbar();
|
||||
}
|
||||
|
||||
void IUAVGadget::configurationNameChanged(QString oldName, QString newName)
|
||||
{
|
||||
for (int i = 0; i < m_toolbar->count(); ++i) {
|
||||
if (m_toolbar->itemText(i) == oldName)
|
||||
m_toolbar->setItemText(i, newName);
|
||||
}
|
||||
}
|
||||
|
||||
void IUAVGadget::updateToolbar()
|
||||
{
|
||||
m_toolbar->setEnabled(m_toolbar->count() > 1);
|
||||
}
|
||||
|
||||
QByteArray IUAVGadget::saveState()
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
if (m_activeConfiguration)
|
||||
stream << m_activeConfiguration->name().toLatin1();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void IUAVGadget::restoreState(QByteArray state)
|
||||
{
|
||||
QDataStream stream(state);
|
||||
QByteArray configName;
|
||||
stream >> configName;
|
||||
foreach (IUAVGadgetConfiguration *config, *m_configurations) {
|
||||
if (config->name() == configName) {
|
||||
m_activeConfiguration = config;
|
||||
loadConfiguration(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,34 +46,32 @@ class CORE_EXPORT IUAVGadget : public IContext
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
IUAVGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, QObject *parent = 0);
|
||||
IUAVGadget(QString classId, QObject *parent = 0) :
|
||||
IContext(parent),
|
||||
m_classId(classId) { }
|
||||
|
||||
virtual ~IUAVGadget() {}
|
||||
|
||||
virtual QList<int> context() const = 0;
|
||||
QList<int> context() const { return m_context; }
|
||||
void setContext(QList<int> context) { m_context = context; }
|
||||
virtual QWidget *widget() = 0;
|
||||
virtual QComboBox *toolBar() { return 0; }
|
||||
virtual QString contextHelpId() const { return QString(); }
|
||||
QString classId() const { return m_classId; }
|
||||
|
||||
virtual void loadConfiguration(IUAVGadgetConfiguration* /*config*/) { }
|
||||
IUAVGadgetConfiguration *activeConfiguration() { return m_activeConfiguration; }
|
||||
void setActiveConfiguration(IUAVGadgetConfiguration *config);
|
||||
QComboBox *toolBar() { return m_toolbar; }
|
||||
virtual QByteArray saveState();
|
||||
virtual void restoreState(QByteArray state);
|
||||
virtual IUAVGadgetConfiguration *activeConfiguration() { return 0; }
|
||||
virtual void loadConfiguration(IUAVGadgetConfiguration*) { }
|
||||
virtual QByteArray saveState() { return QByteArray(); }
|
||||
virtual void restoreState(QByteArray) { }
|
||||
public slots:
|
||||
void configurationChanged(IUAVGadgetConfiguration* config);
|
||||
void configurationAdded(IUAVGadgetConfiguration* config);
|
||||
void configurationToBeDeleted(IUAVGadgetConfiguration* config);
|
||||
void configurationNameChanged(QString oldName, QString newName);
|
||||
virtual void configurationChanged(IUAVGadgetConfiguration* ) { }
|
||||
virtual void configurationAdded(IUAVGadgetConfiguration*) { }
|
||||
virtual void configurationToBeDeleted(IUAVGadgetConfiguration*) { }
|
||||
virtual void configurationNameChanged(QString, QString) { }
|
||||
private slots:
|
||||
void loadConfiguration(int index);
|
||||
protected:
|
||||
QComboBox *m_toolbar;
|
||||
private:
|
||||
void updateToolbar();
|
||||
QString m_classId;
|
||||
IUAVGadgetConfiguration *m_activeConfiguration;
|
||||
QList<IUAVGadgetConfiguration*> *m_configurations;
|
||||
QList<int> m_context;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
@ -52,10 +52,10 @@ public:
|
||||
m_name(name) {}
|
||||
virtual ~IUAVGadgetFactory() {}
|
||||
|
||||
virtual IUAVGadget *createGadget(QList<IUAVGadgetConfiguration*> *configurations, QWidget *parent) = 0;
|
||||
virtual IUAVGadget *createGadget(QWidget *parent) = 0;
|
||||
virtual IUAVGadgetConfiguration *createConfiguration(bool /*locked*/,
|
||||
const QString /*configName*/,
|
||||
const QByteArray &/*state*/) { return 0; }
|
||||
const QString /*configName*/,
|
||||
const QByteArray &/*state*/) { return 0; }
|
||||
virtual IOptionsPage *createOptionsPage(IUAVGadgetConfiguration */*config*/) { return 0; }
|
||||
QString classId() const { return m_classId; }
|
||||
QString name() const { return m_name; }
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "iuavgadgetconfiguration.h"
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
@ -70,6 +71,8 @@ void UAVGadgetDecorator::configurationChanged(IUAVGadgetConfiguration* config)
|
||||
|
||||
void UAVGadgetDecorator::configurationAdded(IUAVGadgetConfiguration* config)
|
||||
{
|
||||
if (config->classId() != classId())
|
||||
return;
|
||||
m_configurations->append(config);
|
||||
m_toolbar->addItem(config->name());
|
||||
updateToolbar();
|
||||
@ -77,6 +80,8 @@ void UAVGadgetDecorator::configurationAdded(IUAVGadgetConfiguration* config)
|
||||
|
||||
void UAVGadgetDecorator::configurationToBeDeleted(IUAVGadgetConfiguration* config)
|
||||
{
|
||||
if (config->classId() != classId())
|
||||
return;
|
||||
int index = m_configurations->indexOf(config);
|
||||
if (index >= 0) {
|
||||
m_toolbar->removeItem(index);
|
||||
@ -85,8 +90,10 @@ void UAVGadgetDecorator::configurationToBeDeleted(IUAVGadgetConfiguration* confi
|
||||
updateToolbar();
|
||||
}
|
||||
|
||||
void UAVGadgetDecorator::configurationNameChanged(QString oldName, QString newName)
|
||||
void UAVGadgetDecorator::configurationNameChanged(IUAVGadgetConfiguration* config, QString oldName, QString newName)
|
||||
{
|
||||
if (config->classId() != classId())
|
||||
return;
|
||||
for (int i = 0; i < m_toolbar->count(); ++i) {
|
||||
if (m_toolbar->itemText(i) == oldName)
|
||||
m_toolbar->setItemText(i, newName);
|
||||
|
@ -49,7 +49,7 @@ public slots:
|
||||
void configurationChanged(IUAVGadgetConfiguration* config);
|
||||
void configurationAdded(IUAVGadgetConfiguration* config);
|
||||
void configurationToBeDeleted(IUAVGadgetConfiguration* config);
|
||||
void configurationNameChanged(QString oldName, QString newName);
|
||||
void configurationNameChanged(IUAVGadgetConfiguration* config, QString oldName, QString newName);
|
||||
private slots:
|
||||
void loadConfiguration(int index);
|
||||
private:
|
||||
|
@ -27,8 +27,10 @@
|
||||
|
||||
#include "uavgadgetinstancemanager.h"
|
||||
#include "iuavgadget.h"
|
||||
#include "uavgadgetdecorator.h"
|
||||
#include "iuavgadgetfactory.h"
|
||||
#include "iuavgadgetconfiguration.h"
|
||||
#include "uavgadgetoptionspagedecorator.h"
|
||||
#include "coreplugin/dialogs/ioptionspage.h"
|
||||
#include "coreplugin/dialogs/settingsdialog.h"
|
||||
#include "icore.h"
|
||||
@ -122,7 +124,8 @@ void UAVGadgetInstanceManager::createOptionsPages()
|
||||
foreach (IUAVGadgetConfiguration *config, m_configurations)
|
||||
{
|
||||
IUAVGadgetFactory *f = factory(config->classId());
|
||||
IOptionsPage *page = f->createOptionsPage(config);
|
||||
IOptionsPage *p = f->createOptionsPage(config);
|
||||
IOptionsPage *page = new UAVGadgetOptionsPageDecorator(p, config);
|
||||
m_optionsPages.append(page);
|
||||
m_pm->addObject(page);
|
||||
}
|
||||
@ -134,17 +137,25 @@ IUAVGadget *UAVGadgetInstanceManager::createGadget(QString classId, QWidget *par
|
||||
IUAVGadgetFactory *f = factory(classId);
|
||||
if (f) {
|
||||
QList<IUAVGadgetConfiguration*> *configs = configurations(classId);
|
||||
IUAVGadget *gadget = f->createGadget(configs, parent);
|
||||
IUAVGadget *g = f->createGadget(0);
|
||||
IUAVGadget *gadget = new UAVGadgetDecorator(g, configs);
|
||||
m_gadgetInstances.append(gadget);
|
||||
connect(this, SIGNAL(configurationAdded(IUAVGadgetConfiguration*)), gadget, SLOT(configurationAdded(IUAVGadgetConfiguration*)));
|
||||
connect(this, SIGNAL(configurationChanged(IUAVGadgetConfiguration*)), gadget, SLOT(configurationChanged(IUAVGadgetConfiguration*)));
|
||||
connect(this, SIGNAL(configurationNameChanged(QString,QString)), gadget, SLOT(configurationNameChanged(QString,QString)));
|
||||
connect(this, SIGNAL(configurationNameChanged(IUAVGadgetConfiguration*, QString,QString)), gadget, SLOT(configurationNameChanged(IUAVGadgetConfiguration*, QString,QString)));
|
||||
connect(this, SIGNAL(configurationToBeDeleted(IUAVGadgetConfiguration*)), gadget, SLOT(configurationToBeDeleted(IUAVGadgetConfiguration*)));
|
||||
return gadget;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UAVGadgetInstanceManager::removeGadget(IUAVGadget *gadget)
|
||||
{
|
||||
if (m_gadgetInstances.contains(gadget)) {
|
||||
m_gadgetInstances.removeOne(gadget);
|
||||
}
|
||||
}
|
||||
|
||||
bool UAVGadgetInstanceManager::canDeleteConfiguration(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
// to be able to delete a configuration, no instance must be using it
|
||||
@ -183,7 +194,8 @@ void UAVGadgetInstanceManager::cloneConfiguration(IUAVGadgetConfiguration *conf
|
||||
|
||||
IUAVGadgetConfiguration *config = configToClone->clone(name);
|
||||
IUAVGadgetFactory *f = factory(config->classId());
|
||||
IOptionsPage *page = f->createOptionsPage(config);
|
||||
IOptionsPage *p = f->createOptionsPage(config);
|
||||
IOptionsPage *page = new UAVGadgetOptionsPageDecorator(p, config);
|
||||
m_provisionalConfigs.append(config);
|
||||
m_provisionalOptionsPages.append(page);
|
||||
m_settingsDialog->insertPage(page);
|
||||
@ -229,7 +241,7 @@ void UAVGadgetInstanceManager::applyChanges(IUAVGadgetConfiguration *config)
|
||||
return;
|
||||
}
|
||||
if (config->provisionalName() != config->name()) {
|
||||
emit configurationNameChanged(config->name(), config->provisionalName());
|
||||
emit configurationNameChanged(config, config->name(), config->provisionalName());
|
||||
config->setName(config->provisionalName());
|
||||
}
|
||||
if (m_configurations.contains(config)) {
|
||||
@ -251,17 +263,17 @@ void UAVGadgetInstanceManager::configurationNameEdited(QString text, bool hasTex
|
||||
bool disable = false;
|
||||
foreach (IUAVGadgetConfiguration *c, m_configurations) {
|
||||
foreach (IUAVGadgetConfiguration *d, m_configurations) {
|
||||
if (c != d && c->provisionalName() == d->provisionalName())
|
||||
if (c != d && c->classId() == d->classId() && c->provisionalName() == d->provisionalName())
|
||||
disable = true;
|
||||
}
|
||||
foreach (IUAVGadgetConfiguration *d, m_provisionalConfigs) {
|
||||
if (c != d && c->provisionalName() == d->provisionalName())
|
||||
if (c != d && c->classId() == d->classId() && c->provisionalName() == d->provisionalName())
|
||||
disable = true;
|
||||
}
|
||||
}
|
||||
foreach (IUAVGadgetConfiguration *c, m_provisionalConfigs) {
|
||||
foreach (IUAVGadgetConfiguration *d, m_provisionalConfigs) {
|
||||
if (c != d && c->provisionalName() == d->provisionalName())
|
||||
if (c != d && c->classId() == d->classId() && c->provisionalName() == d->provisionalName())
|
||||
disable = true;
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
void readConfigurations();
|
||||
void writeConfigurations();
|
||||
IUAVGadget *createGadget(QString classId, QWidget *parent);
|
||||
void removeGadget(IUAVGadget *gadget);
|
||||
bool canDeleteConfiguration(IUAVGadgetConfiguration *config);
|
||||
void deleteConfiguration(IUAVGadgetConfiguration *config);
|
||||
void cloneConfiguration(IUAVGadgetConfiguration *config);
|
||||
@ -70,7 +71,7 @@ signals:
|
||||
void configurationChanged(IUAVGadgetConfiguration* config);
|
||||
void configurationAdded(IUAVGadgetConfiguration* config);
|
||||
void configurationToBeDeleted(IUAVGadgetConfiguration* config);
|
||||
void configurationNameChanged(QString oldName, QString newName);
|
||||
void configurationNameChanged(IUAVGadgetConfiguration* config, QString oldName, QString newName);
|
||||
|
||||
public slots:
|
||||
void settingsDialogShown(Core::Internal::SettingsDialog* settingsDialog);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "uavgadgetmanager.h"
|
||||
#include "uavgadgetview.h"
|
||||
#include "uavgadgetmode.h"
|
||||
#include "uavgadgetinstancemanager.h"
|
||||
#include "iuavgadgetfactory.h"
|
||||
#include "iuavgadget.h"
|
||||
#include "icore.h"
|
||||
@ -300,11 +301,9 @@ void UAVGadgetManager::handleContextChange(Core::IContext *context)
|
||||
// if (debugUAVGadgetManager)
|
||||
// qDebug() << Q_FUNC_INFO << context;
|
||||
IUAVGadget *uavGadget = context ? qobject_cast<IUAVGadget*>(context) : 0;
|
||||
if (uavGadget) {
|
||||
if (uavGadget)
|
||||
setCurrentGadget(uavGadget);
|
||||
} else {
|
||||
updateActions();
|
||||
}
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void UAVGadgetManager::setCurrentGadget(IUAVGadget *uavGadget)
|
||||
@ -368,6 +367,10 @@ void UAVGadgetManager::closeView(Core::Internal::UAVGadgetView *view)
|
||||
if (splitterOrView == m_d->m_splitterOrView)
|
||||
return;
|
||||
|
||||
IUAVGadget *gadget = view->gadget();
|
||||
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
|
||||
im->removeGadget(gadget);
|
||||
|
||||
emptyView(view);
|
||||
|
||||
SplitterOrView *splitter = m_d->m_splitterOrView->findSplitter(splitterOrView);
|
||||
@ -382,23 +385,22 @@ void UAVGadgetManager::closeView(Core::Internal::UAVGadgetView *view)
|
||||
Q_ASSERT(newCurrent);
|
||||
if (newCurrent)
|
||||
setCurrentGadget(newCurrent->gadget());
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void UAVGadgetManager::addGadgetToContext(IUAVGadget *uavGadget)
|
||||
void UAVGadgetManager::addGadgetToContext(IUAVGadget *gadget)
|
||||
{
|
||||
if (!uavGadget)
|
||||
if (!gadget)
|
||||
return;
|
||||
m_d->m_core->addContextObject(uavGadget);
|
||||
m_d->m_core->addContextObject(gadget);
|
||||
|
||||
// emit uavGadgetOpened(uavGadget);
|
||||
}
|
||||
|
||||
void UAVGadgetManager::removeGadget(IUAVGadget *uavGadget)
|
||||
void UAVGadgetManager::removeGadget(IUAVGadget *gadget)
|
||||
{
|
||||
if (!uavGadget)
|
||||
if (!gadget)
|
||||
return;
|
||||
m_d->m_core->removeContextObject(qobject_cast<IContext*>(uavGadget));
|
||||
m_d->m_core->removeContextObject(qobject_cast<IContext*>(gadget));
|
||||
}
|
||||
|
||||
void UAVGadgetManager::ensureUAVGadgetManagerVisible()
|
||||
@ -409,6 +411,8 @@ void UAVGadgetManager::ensureUAVGadgetManagerVisible()
|
||||
|
||||
void UAVGadgetManager::updateActions()
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
return;
|
||||
if (!m_d->m_splitterOrView) // this is only for startup
|
||||
return;
|
||||
// Splitting is only possible when the toolbars are shown
|
||||
@ -436,6 +440,9 @@ QByteArray UAVGadgetManager::saveState() const
|
||||
bool UAVGadgetManager::restoreState(const QByteArray &state)
|
||||
{
|
||||
removeAllSplits();
|
||||
|
||||
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
|
||||
im->removeGadget(m_d->m_splitterOrView->view()->gadget());
|
||||
emptyView(m_d->m_splitterOrView->view());
|
||||
QDataStream stream(state);
|
||||
|
||||
@ -454,7 +461,6 @@ bool UAVGadgetManager::restoreState(const QByteArray &state)
|
||||
m_d->m_splitterOrView->restoreState(splitterstates);
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -505,7 +511,6 @@ void UAVGadgetManager::split(Qt::Orientation orientation)
|
||||
SplitterOrView *sor = m_d->m_splitterOrView->findView(uavGadget);
|
||||
SplitterOrView *next = m_d->m_splitterOrView->findNextView(sor);
|
||||
setCurrentGadget(next->gadget());
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void UAVGadgetManager::split()
|
||||
@ -527,7 +532,6 @@ void UAVGadgetManager::removeCurrentSplit()
|
||||
if (viewToClose == m_d->m_splitterOrView)
|
||||
return;
|
||||
closeView(viewToClose->view());
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void UAVGadgetManager::removeAllSplits()
|
||||
@ -538,6 +542,13 @@ void UAVGadgetManager::removeAllSplits()
|
||||
if (!m_d->m_splitterOrView->isSplitter())
|
||||
return;
|
||||
IUAVGadget *uavGadget = m_d->m_currentGadget;
|
||||
QList<IUAVGadget*> gadgets = m_d->m_splitterOrView->gadgets();
|
||||
gadgets.removeOne(uavGadget);
|
||||
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
|
||||
foreach (IUAVGadget *g, gadgets) {
|
||||
im->removeGadget(g);
|
||||
}
|
||||
|
||||
m_d->m_currentGadget = 0; // trigger update below
|
||||
m_d->m_splitterOrView->unsplitAll();
|
||||
m_d->m_splitterOrView->view()->setGadget(uavGadget);
|
||||
|
@ -217,11 +217,12 @@ void UAVGadgetView::listSelectionActivated(int index)
|
||||
{
|
||||
if (index < 0) // this could happen when called from SplitterOrView::restoreState()
|
||||
index = m_defaultIndex;
|
||||
UAVGadgetInstanceManager *fm = ICore::instance()->uavGadgetInstanceManager();
|
||||
QString classId = m_uavGadgetList->itemData(index).toString();
|
||||
if (m_uavGadget && (m_uavGadget->classId() == classId))
|
||||
return;
|
||||
IUAVGadget *gadget = fm->createGadget(classId, this);
|
||||
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
|
||||
im->removeGadget(m_uavGadget);
|
||||
IUAVGadget *gadget = im->createGadget(classId, this);
|
||||
setGadget(gadget);
|
||||
m_uavGadgetManager->setCurrentGadget(gadget);
|
||||
}
|
||||
@ -460,6 +461,22 @@ UAVGadgetView *SplitterOrView::takeView()
|
||||
return oldView;
|
||||
}
|
||||
|
||||
QList<IUAVGadget*> SplitterOrView::gadgets()
|
||||
{
|
||||
QList<IUAVGadget*> g;
|
||||
if (hasGadget())
|
||||
g.append(gadget());
|
||||
if (m_splitter) {
|
||||
for (int i = 0; i < m_splitter->count(); ++i) {
|
||||
if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) {
|
||||
QList<IUAVGadget*> result = splitterOrView->gadgets();
|
||||
g.append(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
void SplitterOrView::split(Qt::Orientation orientation)
|
||||
{
|
||||
Q_ASSERT(m_view && (m_splitter == 0));
|
||||
@ -579,11 +596,8 @@ void SplitterOrView::restoreState(const QByteArray &state)
|
||||
QString classId;
|
||||
QByteArray uavGadgetState;
|
||||
stream >> classId >> uavGadgetState;
|
||||
m_view = new UAVGadgetView(m_uavGadgetManager, 0);
|
||||
int index = m_view->indexOfClassId(classId);
|
||||
m_view->listSelectionActivated(index);
|
||||
m_layout->addWidget(m_view);
|
||||
m_layout->setCurrentWidget(m_view);
|
||||
gadget()->restoreState(uavGadgetState);
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,7 @@ public:
|
||||
inline bool hasGadget() const { return m_view && (m_view->gadget() != 0); }
|
||||
inline UAVGadgetView *view() const { return m_view; }
|
||||
inline QSplitter *splitter() const { return m_splitter; }
|
||||
QList<Core::IUAVGadget*> gadgets();
|
||||
QSplitter *takeSplitter();
|
||||
UAVGadgetView *takeView();
|
||||
|
||||
|
@ -27,8 +27,8 @@
|
||||
#include "emptygadget.h"
|
||||
#include "emptygadgetwidget.h"
|
||||
|
||||
EmptyGadget::EmptyGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, EmptyGadgetWidget *widget) :
|
||||
IUAVGadget(classId, configurations, widget),
|
||||
EmptyGadget::EmptyGadget(QString classId, EmptyGadgetWidget *widget, QWidget *parent) :
|
||||
IUAVGadget(classId, parent),
|
||||
m_widget(widget)
|
||||
{
|
||||
}
|
||||
|
@ -30,9 +30,11 @@
|
||||
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
namespace Core {
|
||||
class IUAVGadget;
|
||||
class QWidget;
|
||||
class QString;
|
||||
}
|
||||
//class QWidget;
|
||||
//class QString;
|
||||
class EmptyGadgetWidget;
|
||||
|
||||
using namespace Core;
|
||||
@ -41,7 +43,7 @@ class EmptyGadget : public Core::IUAVGadget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EmptyGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, EmptyGadgetWidget *widget = 0);
|
||||
EmptyGadget(QString classId, EmptyGadgetWidget *widget, QWidget *parent = 0);
|
||||
~EmptyGadget();
|
||||
|
||||
QList<int> context() const { return m_context; }
|
||||
|
@ -41,7 +41,7 @@ EmptyGadgetFactory::~EmptyGadgetFactory()
|
||||
|
||||
}
|
||||
|
||||
Core::IUAVGadget* EmptyGadgetFactory::createGadget(QList<IUAVGadgetConfiguration*> *configurations, QWidget *parent) {
|
||||
EmptyGadgetWidget* gadgetWidget = new EmptyGadgetWidget(parent);
|
||||
return new EmptyGadget(QString("EmptyGadget"), configurations, gadgetWidget);
|
||||
IUAVGadget* EmptyGadgetFactory::createGadget(QWidget *parent) {
|
||||
EmptyGadgetWidget* gadgetWidget = new EmptyGadgetWidget(parent);
|
||||
return new EmptyGadget(QString("EmptyGadget"), gadgetWidget, parent);
|
||||
}
|
||||
|
@ -30,18 +30,21 @@
|
||||
|
||||
#include <coreplugin/iuavgadgetfactory.h>
|
||||
|
||||
using namespace Core;
|
||||
namespace Core {
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetFactory;
|
||||
}
|
||||
|
||||
class EmptyGadgetFactory : public Core::IUAVGadgetFactory
|
||||
using namespace Core;
|
||||
|
||||
class EmptyGadgetFactory : public IUAVGadgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EmptyGadgetFactory(QObject *parent = 0);
|
||||
~EmptyGadgetFactory();
|
||||
|
||||
Core::IUAVGadget *createGadget(QList<IUAVGadgetConfiguration*> *configurations, QWidget *parent);
|
||||
IUAVGadget *createGadget(QWidget *parent);
|
||||
};
|
||||
|
||||
#endif // EMPTYGADGETFACTORY_H_
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include "mapgadgetwidget.h"
|
||||
#include "mapgadgetconfiguration.h"
|
||||
|
||||
MapGadget::MapGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, MapGadgetWidget *widget) :
|
||||
IUAVGadget(classId, configurations, widget),
|
||||
MapGadget::MapGadget(QString classId, MapGadgetWidget *widget, QWidget *parent) :
|
||||
IUAVGadget(classId, parent),
|
||||
m_widget(widget)
|
||||
{
|
||||
}
|
||||
@ -41,8 +41,6 @@ MapGadget::~MapGadget()
|
||||
|
||||
void MapGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||
{
|
||||
setActiveConfiguration(config);
|
||||
|
||||
MapGadgetConfiguration *m = qobject_cast<MapGadgetConfiguration*>(config);
|
||||
m_widget->setZoom(m->zoom());
|
||||
m_widget->setPosition(QPointF(m->longitude(), m->latitude()));
|
||||
|
@ -43,17 +43,14 @@ class MapGadget : public Core::IUAVGadget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MapGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, MapGadgetWidget *widget = 0);
|
||||
MapGadget(QString classId, MapGadgetWidget *widget, QWidget *parent = 0);
|
||||
~MapGadget();
|
||||
|
||||
QList<int> context() const { return m_context; }
|
||||
QWidget *widget() { return m_widget; }
|
||||
QString contextHelpId() const { return QString(); }
|
||||
void loadConfiguration(IUAVGadgetConfiguration* config);
|
||||
|
||||
private:
|
||||
MapGadgetWidget *m_widget;
|
||||
QList<int> m_context;
|
||||
MapGadgetWidget *m_widget;
|
||||
};
|
||||
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "mapgadget.h"
|
||||
#include "mapgadgetconfiguration.h"
|
||||
#include "mapgadgetoptionspage.h"
|
||||
#include <coreplugin/uavgadgetoptionspagedecorator.h>
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
MapGadgetFactory::MapGadgetFactory(QObject *parent) :
|
||||
@ -41,10 +40,10 @@ MapGadgetFactory::~MapGadgetFactory()
|
||||
{
|
||||
}
|
||||
|
||||
Core::IUAVGadget* MapGadgetFactory::createGadget(QList<IUAVGadgetConfiguration*> *configurations, QWidget *parent)
|
||||
Core::IUAVGadget* MapGadgetFactory::createGadget(QWidget *parent)
|
||||
{
|
||||
MapGadgetWidget* gadgetWidget = new MapGadgetWidget(parent);
|
||||
return new MapGadget(QString("MapGadget"), configurations, gadgetWidget);
|
||||
MapGadgetWidget* gadgetWidget = new MapGadgetWidget(parent);
|
||||
return new MapGadget(QString("MapGadget"), gadgetWidget, parent);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *MapGadgetFactory::createConfiguration(bool locked,
|
||||
@ -56,7 +55,6 @@ IUAVGadgetConfiguration *MapGadgetFactory::createConfiguration(bool locked,
|
||||
|
||||
IOptionsPage *MapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
MapGadgetOptionsPage *page = new MapGadgetOptionsPage(config);
|
||||
return new UAVGadgetOptionsPageDecorator(page, config);
|
||||
return new MapGadgetOptionsPage(config);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
MapGadgetFactory(QObject *parent = 0);
|
||||
~MapGadgetFactory();
|
||||
|
||||
Core::IUAVGadget *createGadget(QList<IUAVGadgetConfiguration*> *configurations, QWidget *parent);
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(bool locked,
|
||||
const QString configName,
|
||||
const QByteArray &state);
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include "scopegadget.h"
|
||||
#include "scopegadgetwidget.h"
|
||||
|
||||
ScopeGadget::ScopeGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, ScopeGadgetWidget *widget) :
|
||||
IUAVGadget(classId, configurations, widget),
|
||||
ScopeGadget::ScopeGadget(QString classId, ScopeGadgetWidget *widget, QWidget *parent) :
|
||||
IUAVGadget(classId, parent),
|
||||
m_widget(widget)
|
||||
{
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class ScopeGadget : public Core::IUAVGadget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ScopeGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, ScopeGadgetWidget *widget = 0);
|
||||
ScopeGadget(QString classId, ScopeGadgetWidget *widget, QWidget *parent = 0);
|
||||
~ScopeGadget();
|
||||
|
||||
QList<int> context() const { return m_context; }
|
||||
|
@ -21,7 +21,7 @@ ScopeGadgetFactory::~ScopeGadgetFactory()
|
||||
|
||||
}
|
||||
|
||||
Core::IUAVGadget* ScopeGadgetFactory::createGadget(QList<IUAVGadgetConfiguration*> *configurations, QWidget *parent) {
|
||||
ScopeGadgetWidget* gadgetWidget = new ScopeGadgetWidget(parent);
|
||||
return new ScopeGadget(QString("ScopeGadget"), configurations, gadgetWidget);
|
||||
Core::IUAVGadget* ScopeGadgetFactory::createGadget(QWidget *parent) {
|
||||
ScopeGadgetWidget* gadgetWidget = new ScopeGadgetWidget(parent);
|
||||
return new ScopeGadget(QString("ScopeGadget"), gadgetWidget, parent);
|
||||
}
|
||||
|
@ -10,18 +10,21 @@
|
||||
|
||||
#include <coreplugin/iuavgadgetfactory.h>
|
||||
|
||||
using namespace Core;
|
||||
namespace Core {
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetFactory;
|
||||
}
|
||||
|
||||
class ScopeGadgetFactory : public Core::IUAVGadgetFactory
|
||||
using namespace Core;
|
||||
|
||||
class ScopeGadgetFactory : public IUAVGadgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ScopeGadgetFactory(QObject *parent = 0);
|
||||
~ScopeGadgetFactory();
|
||||
|
||||
Core::IUAVGadget *createGadget(QList<IUAVGadgetConfiguration*> *configurations, QWidget *parent);
|
||||
IUAVGadget *createGadget(QWidget *parent);
|
||||
};
|
||||
|
||||
#endif // SCOPEGADGETFACTORY_H_
|
||||
|
Loading…
Reference in New Issue
Block a user