mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-15 07:29:15 +01:00
OP-1538 Added saving of splitter sizes.
This commit is contained in:
parent
ef15064b26
commit
01e9f9565a
@ -32,7 +32,8 @@ UAVObjectBrowser::UAVObjectBrowser(QString classId, UAVObjectBrowserWidget *widg
|
||||
m_widget(widget),
|
||||
m_config(NULL)
|
||||
{
|
||||
connect(m_widget, SIGNAL(viewOptionsChanged(bool, bool, bool)), this, SLOT(viewOptionsChangedSlot(bool, bool, bool)));
|
||||
connect(m_widget, SIGNAL(viewOptionsChanged(bool, bool, bool, bool)), this, SLOT(viewOptionsChangedSlot(bool, bool, bool, bool)));
|
||||
connect(m_widget, SIGNAL(splitterChanged(QList<QVariant>&)), this, SLOT(splitterChanged(QList<QVariant>&)));
|
||||
}
|
||||
|
||||
UAVObjectBrowser::~UAVObjectBrowser()
|
||||
@ -49,14 +50,23 @@ void UAVObjectBrowser::loadConfiguration(IUAVGadgetConfiguration *config)
|
||||
m_widget->setManuallyChangedColor(m->manuallyChangedColor());
|
||||
m_widget->setRecentlyUpdatedTimeout(m->recentlyUpdatedTimeout());
|
||||
m_widget->setOnlyHilightChangedValues(m->onlyHighlightChangedValues());
|
||||
m_widget->setViewOptions(m->categorizedView(), m->scientificView(), m->showMetaData());
|
||||
m_widget->setViewOptions(m->categorizedView(), m->scientificView(), m->showMetaData(), m->showDescription());
|
||||
m_widget->setSplitterSizes(m->splitterSizes());
|
||||
}
|
||||
|
||||
void UAVObjectBrowser::viewOptionsChangedSlot(bool categorized, bool scientific, bool metadata)
|
||||
void UAVObjectBrowser::viewOptionsChangedSlot(bool categorized, bool scientific, bool metadata, bool description)
|
||||
{
|
||||
if (m_config) {
|
||||
m_config->setCategorizedView(categorized);
|
||||
m_config->setScientificView(scientific);
|
||||
m_config->setShowMetaData(metadata);
|
||||
m_config->setShowDescription(description);
|
||||
}
|
||||
}
|
||||
|
||||
void UAVObjectBrowser::splitterChanged(QList<QVariant> &splitterSizes)
|
||||
{
|
||||
if (m_config) {
|
||||
m_config->setSplitterSizes(splitterSizes);
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,11 @@ public:
|
||||
return m_widget;
|
||||
}
|
||||
void loadConfiguration(IUAVGadgetConfiguration *config);
|
||||
|
||||
private slots:
|
||||
void viewOptionsChangedSlot(bool categorized, bool scientific, bool metadata);
|
||||
void viewOptionsChangedSlot(bool categorized, bool scientific, bool metadata, bool description);
|
||||
void splitterChanged(QList<QVariant> &splitterSizes);
|
||||
|
||||
private:
|
||||
UAVObjectBrowserWidget *m_widget;
|
||||
UAVObjectBrowserConfiguration *m_config;
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>786</width>
|
||||
<height>300</height>
|
||||
<height>462</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -220,7 +220,63 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QTreeView" name="treeView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="descriptionText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>This space shows a description of the selected UAVObject.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -35,7 +35,8 @@ UAVObjectBrowserConfiguration::UAVObjectBrowserConfiguration(QString classId, QS
|
||||
m_recentlyUpdatedTimeout(500),
|
||||
m_useCategorizedView(false),
|
||||
m_useScientificView(false),
|
||||
m_showMetaData(false)
|
||||
m_showMetaData(false),
|
||||
m_showDescription(false)
|
||||
{
|
||||
// if a saved configuration exists load it
|
||||
if (qSettings != 0) {
|
||||
@ -47,10 +48,14 @@ UAVObjectBrowserConfiguration::UAVObjectBrowserConfiguration(QString classId, QS
|
||||
m_useCategorizedView = qSettings->value("CategorizedView").toBool();
|
||||
m_useScientificView = qSettings->value("ScientificView").toBool();
|
||||
m_showMetaData = qSettings->value("showMetaData").toBool();
|
||||
m_showDescription = qSettings->value("showDescription").toBool();
|
||||
m_splitterSizes = qSettings->value("splitterSizes").toList();
|
||||
m_recentlyUpdatedColor = recent;
|
||||
m_manuallyChangedColor = manual;
|
||||
m_recentlyUpdatedTimeout = timeout;
|
||||
m_onlyHilightChangedValues = hilight;
|
||||
} else {
|
||||
m_splitterSizes << QVariant(300) << QVariant(300);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +69,9 @@ IUAVGadgetConfiguration *UAVObjectBrowserConfiguration::clone()
|
||||
m->m_onlyHilightChangedValues = m_onlyHilightChangedValues;
|
||||
m->m_useCategorizedView = m_useCategorizedView;
|
||||
m->m_useScientificView = m_useScientificView;
|
||||
m->m_splitterSizes = m_splitterSizes;
|
||||
m->m_showMetaData = m_showMetaData;
|
||||
m->m_showDescription = m_showDescription;
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -81,4 +88,6 @@ void UAVObjectBrowserConfiguration::saveConfig(QSettings *qSettings) const
|
||||
qSettings->setValue("CategorizedView", m_useCategorizedView);
|
||||
qSettings->setValue("ScientificView", m_useScientificView);
|
||||
qSettings->setValue("showMetaData", m_showMetaData);
|
||||
qSettings->setValue("showDescription", m_showDescription);
|
||||
qSettings->setValue("splitterSizes", m_splitterSizes);
|
||||
}
|
||||
|
@ -40,7 +40,9 @@ class UAVObjectBrowserConfiguration : public IUAVGadgetConfiguration {
|
||||
Q_PROPERTY(bool m_onlyHilightChangedValues READ onlyHighlightChangedValues WRITE setOnlyHighlightChangedValues)
|
||||
Q_PROPERTY(bool m_useCategorizedView READ categorizedView WRITE setCategorizedView)
|
||||
Q_PROPERTY(bool m_useScientificView READ scientificView WRITE setScientificView)
|
||||
Q_PROPERTY(bool m_showDescription READ showDescription WRITE setShowDescription)
|
||||
Q_PROPERTY(bool m_showMetaData READ showMetaData WRITE setShowMetaData)
|
||||
Q_PROPERTY(QList<QVariant> m_splitterSizes READ splitterSizes WRITE setSplitterSizes)
|
||||
public:
|
||||
explicit UAVObjectBrowserConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
|
||||
|
||||
@ -75,6 +77,15 @@ public:
|
||||
{
|
||||
return m_showMetaData;
|
||||
}
|
||||
bool showDescription() const
|
||||
{
|
||||
return m_showDescription;
|
||||
}
|
||||
|
||||
QList<QVariant> splitterSizes() const
|
||||
{
|
||||
return m_splitterSizes;
|
||||
}
|
||||
|
||||
signals:
|
||||
|
||||
@ -107,6 +118,15 @@ public slots:
|
||||
{
|
||||
m_showMetaData = value;
|
||||
}
|
||||
void setShowDescription(bool value)
|
||||
{
|
||||
m_showDescription = value;
|
||||
}
|
||||
|
||||
void setSplitterSizes(QList<QVariant> arg)
|
||||
{
|
||||
m_splitterSizes = arg;
|
||||
}
|
||||
|
||||
private:
|
||||
QColor m_recentlyUpdatedColor;
|
||||
@ -116,6 +136,8 @@ private:
|
||||
bool m_useCategorizedView;
|
||||
bool m_useScientificView;
|
||||
bool m_showMetaData;
|
||||
bool m_showDescription;
|
||||
QList<QVariant> m_splitterSizes;
|
||||
};
|
||||
|
||||
#endif // UAVOBJECTBROWSERCONFIGURATION_H
|
||||
|
@ -50,15 +50,17 @@ UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent
|
||||
m_model = new UAVObjectTreeModel();
|
||||
m_browser->treeView->setModel(m_model);
|
||||
m_browser->treeView->setColumnWidth(0, 300);
|
||||
// m_browser->treeView->expandAll();
|
||||
BrowserItemDelegate *m_delegate = new BrowserItemDelegate();
|
||||
m_browser->treeView->setItemDelegate(m_delegate);
|
||||
m_browser->treeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
|
||||
m_browser->treeView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||
connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
|
||||
showDescription(m_viewoptions->cbDescription->isChecked());
|
||||
connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
|
||||
this, SLOT(currentChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
|
||||
connect(m_viewoptions->cbMetaData, SIGNAL(toggled(bool)), this, SLOT(showMetaData(bool)));
|
||||
connect(m_viewoptions->cbCategorized, SIGNAL(toggled(bool)), this, SLOT(categorize(bool)));
|
||||
connect(m_viewoptions->cbDescription, SIGNAL(toggled(bool)), this, SLOT(showDescription(bool)));
|
||||
connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveObject()));
|
||||
connect(m_browser->readSDButton, SIGNAL(clicked()), this, SLOT(loadObject()));
|
||||
connect(m_browser->eraseSDButton, SIGNAL(clicked()), this, SLOT(eraseObject()));
|
||||
@ -69,6 +71,8 @@ UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent
|
||||
connect(m_viewoptions->cbScientific, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot()));
|
||||
connect(m_viewoptions->cbMetaData, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot()));
|
||||
connect(m_viewoptions->cbCategorized, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot()));
|
||||
connect(m_viewoptions->cbDescription, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot()));
|
||||
connect(m_browser->splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(splitterMoved()));
|
||||
enableSendRequest(false);
|
||||
}
|
||||
|
||||
@ -77,11 +81,21 @@ UAVObjectBrowserWidget::~UAVObjectBrowserWidget()
|
||||
delete m_browser;
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::setViewOptions(bool categorized, bool scientific, bool metadata)
|
||||
void UAVObjectBrowserWidget::setViewOptions(bool categorized, bool scientific, bool metadata, bool description)
|
||||
{
|
||||
m_viewoptions->cbCategorized->setChecked(categorized);
|
||||
m_viewoptions->cbMetaData->setChecked(metadata);
|
||||
m_viewoptions->cbScientific->setChecked(scientific);
|
||||
m_viewoptions->cbDescription->setChecked(description);
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::setSplitterSizes(QList<QVariant> sizes)
|
||||
{
|
||||
QList<int> sizs;
|
||||
foreach (QVariant size, sizes) {
|
||||
sizs << size.toInt();
|
||||
}
|
||||
m_browser->splitter->setSizes(sizs);
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::showMetaData(bool show)
|
||||
@ -92,6 +106,11 @@ void UAVObjectBrowserWidget::showMetaData(bool show)
|
||||
}
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::showDescription(bool show)
|
||||
{
|
||||
m_browser->descriptionText->setVisible(show);
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::categorize(bool categorize)
|
||||
{
|
||||
UAVObjectTreeModel *tmpModel = m_model;
|
||||
@ -228,6 +247,7 @@ void UAVObjectBrowserWidget::currentChanged(const QModelIndex ¤t, const QM
|
||||
enable = false;
|
||||
}
|
||||
enableSendRequest(enable);
|
||||
updateDescription();
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::viewSlot()
|
||||
@ -244,7 +264,23 @@ void UAVObjectBrowserWidget::viewSlot()
|
||||
|
||||
void UAVObjectBrowserWidget::viewOptionsChangedSlot()
|
||||
{
|
||||
emit viewOptionsChanged(m_viewoptions->cbCategorized->isChecked(), m_viewoptions->cbScientific->isChecked(), m_viewoptions->cbMetaData->isChecked());
|
||||
emit viewOptionsChanged(m_viewoptions->cbCategorized->isChecked(), m_viewoptions->cbScientific->isChecked(),
|
||||
m_viewoptions->cbMetaData->isChecked(), m_viewoptions->cbDescription->isChecked());
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::splitterMoved()
|
||||
{
|
||||
QList<QVariant> sizs;
|
||||
foreach (int size, m_browser->splitter->sizes()) {
|
||||
sizs << QVariant(size);
|
||||
}
|
||||
|
||||
emit splitterChanged(sizs);
|
||||
}
|
||||
|
||||
QString UAVObjectBrowserWidget::createObjectDescription(UAVObject *object)
|
||||
{
|
||||
return object->getDescription();
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::enableSendRequest(bool enable)
|
||||
@ -255,3 +291,16 @@ void UAVObjectBrowserWidget::enableSendRequest(bool enable)
|
||||
m_browser->readSDButton->setEnabled(enable);
|
||||
m_browser->eraseSDButton->setEnabled(enable);
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::updateDescription()
|
||||
{
|
||||
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
|
||||
if (objItem) {
|
||||
UAVObject *obj = objItem->object();
|
||||
if (obj) {
|
||||
m_browser->descriptionText->setText(createObjectDescription(obj));
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_browser->descriptionText->setText("");
|
||||
}
|
||||
|
@ -60,9 +60,11 @@ public:
|
||||
{
|
||||
m_onlyHilightChangedValues = hilight; m_model->setOnlyHilightChangedValues(hilight);
|
||||
}
|
||||
void setViewOptions(bool categorized, bool scientific, bool metadata);
|
||||
void setViewOptions(bool categorized, bool scientific, bool metadata, bool description);
|
||||
void setSplitterSizes(QList<QVariant> sizes);
|
||||
public slots:
|
||||
void showMetaData(bool show);
|
||||
void showDescription(bool show);
|
||||
void categorize(bool categorize);
|
||||
void useScientificNotation(bool scientific);
|
||||
|
||||
@ -75,8 +77,11 @@ private slots:
|
||||
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void viewSlot();
|
||||
void viewOptionsChangedSlot();
|
||||
void splitterMoved();
|
||||
QString createObjectDescription(UAVObject* object);
|
||||
signals:
|
||||
void viewOptionsChanged(bool categorized, bool scientific, bool metadata);
|
||||
void viewOptionsChanged(bool categorized, bool scientific, bool metadata, bool description);
|
||||
void splitterChanged(QList<QVariant> &sizes);
|
||||
private:
|
||||
QPushButton *m_requestUpdate;
|
||||
QPushButton *m_sendUpdate;
|
||||
@ -92,6 +97,7 @@ private:
|
||||
|
||||
void updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj);
|
||||
void enableSendRequest(bool enable);
|
||||
void updateDescription();
|
||||
ObjectTreeItem *findCurrentObjectTreeItem();
|
||||
};
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>169</width>
|
||||
<height>96</height>
|
||||
<width>172</width>
|
||||
<height>124</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -35,6 +35,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbDescription">
|
||||
<property name="text">
|
||||
<string>Show description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user