mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
OP-1538 Changed the way splitter state is changed.
Fixed some formatting colors.
This commit is contained in:
parent
80fb6565b3
commit
3dd9503454
@ -33,7 +33,7 @@ UAVObjectBrowser::UAVObjectBrowser(QString classId, UAVObjectBrowserWidget *widg
|
||||
m_config(NULL)
|
||||
{
|
||||
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>&)));
|
||||
connect(m_widget, SIGNAL(splitterChanged(QByteArray)), this, SLOT(splitterChanged(QByteArray)));
|
||||
}
|
||||
|
||||
UAVObjectBrowser::~UAVObjectBrowser()
|
||||
@ -51,7 +51,7 @@ void UAVObjectBrowser::loadConfiguration(IUAVGadgetConfiguration *config)
|
||||
m_widget->setRecentlyUpdatedTimeout(m->recentlyUpdatedTimeout());
|
||||
m_widget->setOnlyHilightChangedValues(m->onlyHighlightChangedValues());
|
||||
m_widget->setViewOptions(m->categorizedView(), m->scientificView(), m->showMetaData(), m->showDescription());
|
||||
m_widget->setSplitterSizes(m->splitterSizes());
|
||||
m_widget->setSplitterState(m->splitterState());
|
||||
}
|
||||
|
||||
void UAVObjectBrowser::viewOptionsChangedSlot(bool categorized, bool scientific, bool metadata, bool description)
|
||||
@ -64,9 +64,9 @@ void UAVObjectBrowser::viewOptionsChangedSlot(bool categorized, bool scientific,
|
||||
}
|
||||
}
|
||||
|
||||
void UAVObjectBrowser::splitterChanged(QList<QVariant> &splitterSizes)
|
||||
void UAVObjectBrowser::splitterChanged(QByteArray state)
|
||||
{
|
||||
if (m_config) {
|
||||
m_config->setSplitterSizes(splitterSizes);
|
||||
m_config->setSplitterState(state);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void viewOptionsChangedSlot(bool categorized, bool scientific, bool metadata, bool description);
|
||||
void splitterChanged(QList<QVariant> &splitterSizes);
|
||||
void splitterChanged(QByteArray state);
|
||||
|
||||
private:
|
||||
UAVObjectBrowserWidget *m_widget;
|
||||
|
@ -260,7 +260,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
|
@ -40,22 +40,15 @@ UAVObjectBrowserConfiguration::UAVObjectBrowserConfiguration(QString classId, QS
|
||||
{
|
||||
// if a saved configuration exists load it
|
||||
if (qSettings != 0) {
|
||||
QColor recent = qSettings->value("recentlyUpdatedColor").value<QColor>();
|
||||
QColor manual = qSettings->value("manuallyChangedColor").value<QColor>();
|
||||
int timeout = qSettings->value("recentlyUpdatedTimeout").toInt();
|
||||
bool hilight = qSettings->value("onlyHilightChangedValues").toBool();
|
||||
|
||||
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);
|
||||
m_splitterState = qSettings->value("splitterState").toByteArray();
|
||||
m_recentlyUpdatedColor = qSettings->value("recentlyUpdatedColor").value<QColor>();
|
||||
m_manuallyChangedColor = qSettings->value("manuallyChangedColor").value<QColor>();
|
||||
m_recentlyUpdatedTimeout = qSettings->value("recentlyUpdatedTimeout").toInt();
|
||||
m_onlyHilightChangedValues = qSettings->value("onlyHilightChangedValues").toBool();
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +62,7 @@ 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_splitterState = m_splitterState;
|
||||
m->m_showMetaData = m_showMetaData;
|
||||
m->m_showDescription = m_showDescription;
|
||||
return m;
|
||||
@ -89,5 +82,5 @@ void UAVObjectBrowserConfiguration::saveConfig(QSettings *qSettings) const
|
||||
qSettings->setValue("ScientificView", m_useScientificView);
|
||||
qSettings->setValue("showMetaData", m_showMetaData);
|
||||
qSettings->setValue("showDescription", m_showDescription);
|
||||
qSettings->setValue("splitterSizes", m_splitterSizes);
|
||||
qSettings->setValue("splitterState", m_splitterState);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class UAVObjectBrowserConfiguration : public IUAVGadgetConfiguration {
|
||||
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)
|
||||
Q_PROPERTY(QByteArray m_splitterState READ splitterState WRITE setSplitterState)
|
||||
public:
|
||||
explicit UAVObjectBrowserConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
|
||||
|
||||
@ -82,9 +82,9 @@ public:
|
||||
return m_showDescription;
|
||||
}
|
||||
|
||||
QList<QVariant> splitterSizes() const
|
||||
QByteArray splitterState() const
|
||||
{
|
||||
return m_splitterSizes;
|
||||
return m_splitterState;
|
||||
}
|
||||
|
||||
signals:
|
||||
@ -123,9 +123,9 @@ public slots:
|
||||
m_showDescription = value;
|
||||
}
|
||||
|
||||
void setSplitterSizes(QList<QVariant> arg)
|
||||
void setSplitterState(QByteArray arg)
|
||||
{
|
||||
m_splitterSizes = arg;
|
||||
m_splitterState = arg;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -137,7 +137,7 @@ private:
|
||||
bool m_useScientificView;
|
||||
bool m_showMetaData;
|
||||
bool m_showDescription;
|
||||
QList<QVariant> m_splitterSizes;
|
||||
QByteArray m_splitterState;
|
||||
};
|
||||
|
||||
#endif // UAVOBJECTBROWSERCONFIGURATION_H
|
||||
|
@ -54,6 +54,7 @@ UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent
|
||||
m_browser->treeView->setItemDelegate(m_delegate);
|
||||
m_browser->treeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
|
||||
m_browser->treeView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||
m_browser->splitter->setChildrenCollapsible(false);
|
||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||
showDescription(m_viewoptions->cbDescription->isChecked());
|
||||
connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
|
||||
@ -89,13 +90,9 @@ void UAVObjectBrowserWidget::setViewOptions(bool categorized, bool scientific, b
|
||||
m_viewoptions->cbDescription->setChecked(description);
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::setSplitterSizes(QList<QVariant> sizes)
|
||||
void UAVObjectBrowserWidget::setSplitterState(QByteArray state)
|
||||
{
|
||||
QList<int> sizs;
|
||||
foreach (QVariant size, sizes) {
|
||||
sizs << size.toInt();
|
||||
}
|
||||
m_browser->splitter->setSizes(sizs);
|
||||
m_browser->splitter->restoreState(state);
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::showMetaData(bool show)
|
||||
@ -270,19 +267,14 @@ void UAVObjectBrowserWidget::viewOptionsChangedSlot()
|
||||
|
||||
void UAVObjectBrowserWidget::splitterMoved()
|
||||
{
|
||||
QList<QVariant> sizs;
|
||||
foreach (int size, m_browser->splitter->sizes()) {
|
||||
sizs << QVariant(size);
|
||||
}
|
||||
|
||||
emit splitterChanged(sizs);
|
||||
emit splitterChanged(m_browser->splitter->saveState());
|
||||
}
|
||||
|
||||
QString UAVObjectBrowserWidget::createObjectDescription(UAVObject *object)
|
||||
{
|
||||
QString description;
|
||||
description.append("<html><head></head><body style=\" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;\">");
|
||||
description.append("<table border='0' width='99%' cellpadding='5' cellspacing='0'><tbody><tr bgcolor='#ffcc00'>");
|
||||
description.append("<table border='0' width='99%' cellpadding='5' cellspacing='0'><tbody><tr bgcolor='#498ae8'>");
|
||||
description.append("<td nowrap='nowrap'><b>").append(tr("Name:")).append(" </b>").append(object->getName());
|
||||
description.append("<br><b>").append(tr("Type:")).append(" </b>")
|
||||
.append(object->isSettingsObject() ? tr("Settings") : object->isMetaDataObject() ? tr("Metadata") : tr("Data"));
|
||||
@ -296,25 +288,28 @@ QString UAVObjectBrowserWidget::createObjectDescription(UAVObject *object)
|
||||
int fields = 0;
|
||||
foreach (UAVObjectField *field, object->getFields()) {
|
||||
fields++;
|
||||
description.append("</tr><tr><td nowrap='nowrap' ").append(fields & 1 ? "bgcolor='#ffcc99'>" : "bgcolor='#ff9900'>");
|
||||
QString bgColor = fields & 1 ? "bgcolor='#ffcc99'>" : "bgcolor='#ff9900'>";
|
||||
description.append("</tr><tr><td nowrap='nowrap' ").append(bgColor);
|
||||
description.append("<b>").append(tr("Name:")).append(" </b>").append(field->getName())
|
||||
.append("</td><td").append(fields & 1 ? " bgcolor='#ffcc99'>" : " bgcolor='#ff9900'>");
|
||||
.append("</td><td").append(bgColor);
|
||||
description.append("<b>").append(tr("Size:")).append(" </b>").append(tr("%1 bytes").arg(field->getNumBytes()))
|
||||
.append("</td>");
|
||||
|
||||
description.append("<td").append(fields & 1 ? " bgcolor='#ffcc99'>" : " bgcolor='#ff9900'>");
|
||||
description.append("<td").append(bgColor);
|
||||
description.append(tr("<b>Type:")).append(" </b>").append(field->getTypeAsString());
|
||||
int elements = field->getNumElements();
|
||||
if (elements > 1) {
|
||||
description.append("[").append(QString("%1").arg(field->getNumElements())).append("]");
|
||||
}
|
||||
|
||||
description.append("</td><td").append(fields & 1 ? " bgcolor='#ffcc99'>" : " bgcolor='#ff9900'>");
|
||||
description.append("<b>").append(tr("Unit:")).append(" </b>").append(field->getUnits());
|
||||
description.append("</td><td").append(bgColor);
|
||||
if (field->getUnits() != "") {
|
||||
description.append("<b>").append(tr("Unit:")).append(" </b>").append(field->getUnits());
|
||||
}
|
||||
|
||||
description.append("</td></tr>");
|
||||
if (field->getDescription() != "") {
|
||||
description.append("<tr><td").append(fields & 1 ? " bgcolor='#ffcc99'>" : " bgcolor='#ff9900'>");
|
||||
description.append("<tr><td").append(bgColor);
|
||||
description.append("<b>").append(tr("Description:")).append(" </b>").append(field->getDescription());
|
||||
description.append("</td></tr>");
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
m_onlyHilightChangedValues = hilight; m_model->setOnlyHilightChangedValues(hilight);
|
||||
}
|
||||
void setViewOptions(bool categorized, bool scientific, bool metadata, bool description);
|
||||
void setSplitterSizes(QList<QVariant> sizes);
|
||||
void setSplitterState(QByteArray state);
|
||||
public slots:
|
||||
void showMetaData(bool show);
|
||||
void showDescription(bool show);
|
||||
@ -81,7 +81,7 @@ private slots:
|
||||
QString createObjectDescription(UAVObject* object);
|
||||
signals:
|
||||
void viewOptionsChanged(bool categorized, bool scientific, bool metadata, bool description);
|
||||
void splitterChanged(QList<QVariant> &sizes);
|
||||
void splitterChanged(QByteArray state);
|
||||
private:
|
||||
QPushButton *m_requestUpdate;
|
||||
QPushButton *m_sendUpdate;
|
||||
|
@ -587,7 +587,6 @@ QString UAVObjectParser::processObjectFields(QDomNode & childNode, ObjectInfo *i
|
||||
}
|
||||
// Add field to object
|
||||
info->fields.append(field);
|
||||
qDebug() << "field added" << info->name << ", description" << field->description;
|
||||
// Done
|
||||
return QString();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user