Newer
Older
lm
committed
#ifndef QGCTOOLWIDGET_H
#define QGCTOOLWIDGET_H
#include <QWidget>
#include <QAction>
lm
committed
#include <QVBoxLayout>
lm
committed
#include "UAS.h"
namespace Ui
{
class QGCToolWidget;
lm
committed
}
class QGCToolWidget : public QWidget
{
Q_OBJECT
public:
John Tapsell
committed
explicit QGCToolWidget(const QString& objectName, const QString& title, QWidget *parent = 0, QSettings* settings = 0);
lm
committed
~QGCToolWidget();
/** @brief Factory method to instantiate all tool widgets */
static QList<QGCToolWidget*> createWidgetsFromSettings(QWidget* parent, QString settingsFile=QString());
/** @Give the tool widget a reference to its action in the main menu */
void setMainMenuAction(QAction* action);
/** @brief All instances of this class */
static QMap<QString, QGCToolWidget*>* instances();
int isVisible(int view) const { return viewVisible.value(view, false); }
Qt::DockWidgetArea getDockWidgetArea(int view) { return dockWidgetArea.value(view, Qt::BottomDockWidgetArea); }
void setParent(QWidget *parent);
John Tapsell
committed
/** @brief Store all widgets of this type to QSettings */
static void storeWidgetsToSettings(QSettings &settingsFile);
lm
committed
public slots:
void addUAS(UASInterface* uas);
/** @brief Delete this widget */
void deleteWidget();
/** @brief Export this widget to a file */
void exportWidget();
/** @brief Import settings for this widget from a file */
/** @brief Store all widgets of this type to QSettings */
John Tapsell
committed
void storeWidgetsToSettings() { QSettings settings; QGCToolWidget::storeWidgetsToSettings(settings); }
public:
Michael Carpenter
committed
void loadSettings(QVariantMap& settings);
/** @brief Load this widget from a QSettings object */
void loadSettings(QSettings& settings);
/** @brief Load this widget from a settings file */
bool loadSettings(const QString& settings, bool singleinstance=false);
/** @brief Store the view id and dock widget area */
void setViewVisibilityAndDockWidgetArea(int view, bool visible, Qt::DockWidgetArea area);
Michael Carpenter
committed
void setSettings(QVariantMap& settings);
QList<QString> getParamList();
void setParameterValue(int uas, int component, QString parameterName, const QVariant value);
bool fromMetaData() const { return isFromMetaData; }
Michael Carpenter
committed
void showLabel(QString name,int num);
John Tapsell
committed
John Tapsell
committed
void titleChanged(const QString &title);
lm
committed
protected:
Michael Carpenter
committed
bool isFromMetaData;
Michael Carpenter
committed
QMap<QString,QGCToolWidgetItem*> paramToItemMap;
Michael Carpenter
committed
QList<QGCToolWidgetItem*> toolItemList;
Michael Carpenter
committed
QList<QString> paramList;
QVariantMap settingsMap;
lm
committed
QAction* addParamAction;
lm
committed
QAction* setTitleAction;
QAction* exportAction;
QAction* importAction;
lm
committed
QVBoxLayout* toolLayout;
UAS* mav;
QAction* mainMenuAction; ///< Main menu action
QMap<int, Qt::DockWidgetArea> dockWidgetArea; ///< Dock widget area desired by this widget
QMap<int, bool> viewVisible; ///< Visibility in one view
QString widgetTitle;
lm
committed
void contextMenuEvent(QContextMenuEvent* event);
void createActions();
/** @brief Add an existing tool widget */
void addToolWidget(QGCToolWidgetItem* widget);
/** @brief Add an existing tool widget and set it to edit mode */
void addToolWidgetAndEdit(QGCToolWidgetItem* widget);
lm
committed
void hideEvent(QHideEvent* event);
Michael Carpenter
committed
public slots:
void setTitle(const QString &title);
Michael Carpenter
committed
void addParam(int uas,int component,QString paramname,QVariant value);
lm
committed
protected slots:
void addParam();
lm
committed
void setTitle();
void widgetRemoved();
Michael Carpenter
committed
lm
committed
private:
John Tapsell
committed
/** Do not use this from outside the class to set the object name,
* because we cannot track changes to the object name, and the
* QObject::setObjectName() function is not virtual. Instead only
* pass in the object name to the constructor, or use the , then
* never change it again. */
void setObjectName(const QString &name) { QWidget::setObjectName(name); }
John Tapsell
committed
/** Helper for storeWidgetsToSettings() */
void storeSettings(QSettings& settings);