Commit c6cd2cc0 authored by Michael Carpenter's avatar Michael Carpenter

Added save/load settings to UASQuickView, and commented header file

parent 93b786aa
......@@ -75,21 +75,8 @@ UASQuickView::UASQuickView(QWidget *parent) : QWidget(parent)
ui.verticalLayout->addWidget(item);
uasPropertyToLabelMap["distToWaypoint"] = item;
}*/
QSettings settings;
int size = settings.beginReadArray("UAS_QUICK_VIEW_ITEMS");
for (int i=0;i<size;i++)
{
settings.setArrayIndex(i);
QString nameval = settings.value("name").toString();
QString typeval = settings.value("type").toString();
if (typeval == "text" && !uasPropertyToLabelMap.contains(nameval))
{
valueEnabled(nameval);
}
//QString name = settings.value("name").toString();
//QString var = settings.value("variable").toString();
}
loadSettings();
//If we don't have any predefined settings, set some defaults.
if (uasPropertyValueMap.size() == 0)
{
......@@ -127,17 +114,8 @@ void UASQuickView::actionTriggered()
}
quickViewSelectDialog->show();
}
void UASQuickView::valueEnabled(QString value)
void UASQuickView::saveSettings()
{
UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle(value);
ui.verticalLayout->addWidget(item);
uasPropertyToLabelMap[value] = item;
uasEnabledPropertyList.append(value);
if (!uasPropertyValueMap.contains(value))
{
uasPropertyValueMap[value] = 0;
}
QSettings settings;
settings.beginWriteArray("UAS_QUICK_VIEW_ITEMS");
int count = 0;
......@@ -146,12 +124,40 @@ void UASQuickView::valueEnabled(QString value)
settings.setArrayIndex(count++);
settings.setValue("name",i.key());
settings.setValue("type","text");
//QString name = settings.value("name").toString();
//QString var = settings.value("variable").toString();
}
settings.endArray();
settings.sync();
}
void UASQuickView::loadSettings()
{
QSettings settings;
int size = settings.beginReadArray("UAS_QUICK_VIEW_ITEMS");
for (int i=0;i<size;i++)
{
settings.setArrayIndex(i);
QString nameval = settings.value("name").toString();
QString typeval = settings.value("type").toString();
if (typeval == "text" && !uasPropertyToLabelMap.contains(nameval))
{
valueEnabled(nameval);
}
}
}
void UASQuickView::valueEnabled(QString value)
{
UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle(value);
ui.verticalLayout->addWidget(item);
uasPropertyToLabelMap[value] = item;
uasEnabledPropertyList.append(value);
if (!uasPropertyValueMap.contains(value))
{
uasPropertyValueMap[value] = 0;
}
saveSettings();
}
void UASQuickView::valueDisabled(QString value)
{
......@@ -163,19 +169,7 @@ void UASQuickView::valueDisabled(QString value)
ui.verticalLayout->removeWidget(item);
item->deleteLater();
uasEnabledPropertyList.removeOne(value);
QSettings settings;
settings.beginWriteArray("UAS_QUICK_VIEW_ITEMS");
int count = 0;
for (QMap<QString,UASQuickViewItem*>::const_iterator i = uasPropertyToLabelMap.constBegin();i!=uasPropertyToLabelMap.constEnd();i++)
{
settings.setArrayIndex(count++);
settings.setValue("name",i.key());
settings.setValue("type","text");
//QString name = settings.value("name").toString();
//QString var = settings.value("variable").toString();
}
settings.endArray();
settings.sync();
saveSettings();
}
}
......
......@@ -18,11 +18,27 @@ public:
void addSource(MAVLinkDecoder *decoder);
private:
UASInterface *uas;
/** List of enabled properties */
QList<QString> uasEnabledPropertyList;
/** Maps from the property name to the current value */
QMap<QString,double> uasPropertyValueMap;
/** Maps from property name to the display item */
QMap<QString,UASQuickViewItem*> uasPropertyToLabelMap;
/** Timer for updating the UI */
QTimer *updateTimer;
/** Selection dialog for selectin/deselecting gauge items */
UASQuickViewItemSelect *quickViewSelectDialog;
/** Saves gauge layout to settings file */
void saveSettings();
/** Loads gauge layout from settings file */
void loadSettings();
protected:
Ui::Form ui;
signals:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment