mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
OP-642 Added a checkbox in the UAVOBrowser widget to select if the objects should be shown in a categorized manner or not.
It is now possible to switch between categorized and 'classic' view.
This commit is contained in:
parent
32abd2e32f
commit
069b5dda44
@ -202,6 +202,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="categorizeCheckbox">
|
||||
<property name="toolTip">
|
||||
<string>Select to sort objects in to categories.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Categorize Objects</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
|
@ -54,6 +54,7 @@ UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent
|
||||
showMetaData(m_browser->metaCheckBox->isChecked());
|
||||
connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex,QModelIndex)));
|
||||
connect(m_browser->metaCheckBox, SIGNAL(toggled(bool)), this, SLOT(showMetaData(bool)));
|
||||
connect(m_browser->categorizeCheckbox, SIGNAL(toggled(bool)), this, SLOT(categorize(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,16 +70,6 @@ UAVObjectBrowserWidget::~UAVObjectBrowserWidget()
|
||||
|
||||
void UAVObjectBrowserWidget::showMetaData(bool show)
|
||||
{
|
||||
/*
|
||||
int topRowCount = m_model->rowCount(QModelIndex());
|
||||
for (int i = 0; i < topRowCount; ++i) {
|
||||
QModelIndex index = m_model->index(i, 0, QModelIndex());
|
||||
int subRowCount = m_model->rowCount(index);
|
||||
for (int j = 0; j < subRowCount; ++j) {
|
||||
m_browser->treeView->setRowHidden(0, index.child(j,0), !show);
|
||||
}
|
||||
}
|
||||
*/
|
||||
QList<QModelIndex> metaIndexes = m_model->getMetaDataIndexes();
|
||||
foreach(QModelIndex index , metaIndexes)
|
||||
{
|
||||
@ -86,6 +77,20 @@ void UAVObjectBrowserWidget::showMetaData(bool show)
|
||||
}
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::categorize(bool categorize)
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pm);
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objManager);
|
||||
|
||||
UAVObjectTreeModel* tmpModel = m_model;
|
||||
m_model = new UAVObjectTreeModel(0, categorize);
|
||||
m_browser->treeView->setModel(m_model);
|
||||
|
||||
delete tmpModel;
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::sendUpdate()
|
||||
{
|
||||
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void showMetaData(bool show);
|
||||
void categorize(bool categorize);
|
||||
|
||||
private slots:
|
||||
void sendUpdate();
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <QtCore/QSignalMapper>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent) :
|
||||
UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent, bool categorize) :
|
||||
QAbstractItemModel(parent),
|
||||
m_recentlyUpdatedTimeout(500), // ms
|
||||
m_recentlyUpdatedColor(QColor(255, 230, 230)),
|
||||
@ -53,7 +53,7 @@ UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent) :
|
||||
connect(objManager, SIGNAL(newInstance(UAVObject*)), this, SLOT(newObject(UAVObject*)));
|
||||
|
||||
TreeItem::setHighlightTime(m_recentlyUpdatedTimeout);
|
||||
setupModelData(objManager);
|
||||
setupModelData(objManager, categorize);
|
||||
}
|
||||
|
||||
UAVObjectTreeModel::~UAVObjectTreeModel()
|
||||
@ -62,7 +62,7 @@ UAVObjectTreeModel::~UAVObjectTreeModel()
|
||||
delete m_rootItem;
|
||||
}
|
||||
|
||||
void UAVObjectTreeModel::setupModelData(UAVObjectManager *objManager)
|
||||
void UAVObjectTreeModel::setupModelData(UAVObjectManager *objManager, bool categorize)
|
||||
{
|
||||
// root
|
||||
QList<QVariant> rootData;
|
||||
@ -82,7 +82,7 @@ void UAVObjectTreeModel::setupModelData(UAVObjectManager *objManager)
|
||||
QList< QList<UAVDataObject*> > objList = objManager->getDataObjects();
|
||||
foreach (QList<UAVDataObject*> list, objList) {
|
||||
foreach (UAVDataObject* obj, list) {
|
||||
addDataObject(obj);
|
||||
addDataObject(obj, categorize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,13 +95,13 @@ void UAVObjectTreeModel::newObject(UAVObject *obj)
|
||||
}
|
||||
}
|
||||
|
||||
void UAVObjectTreeModel::addDataObject(UAVDataObject *obj)
|
||||
void UAVObjectTreeModel::addDataObject(UAVDataObject *obj, bool categorize)
|
||||
{
|
||||
TopTreeItem *root = obj->isSettings() ? m_settingsTree : m_nonSettingsTree;
|
||||
|
||||
TreeItem* parent = root;
|
||||
|
||||
if(obj->getCategory() != 0 && !obj->getCategory().isEmpty()) {
|
||||
if(categorize && obj->getCategory() != 0 && !obj->getCategory().isEmpty()) {
|
||||
QStringList categoryPath = obj->getCategory().split('/');
|
||||
parent = createCategoryItems(categoryPath, root);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class UAVObjectTreeModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UAVObjectTreeModel(QObject *parent = 0);
|
||||
explicit UAVObjectTreeModel(QObject *parent = 0, bool categorize=true);
|
||||
~UAVObjectTreeModel();
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
@ -83,18 +83,17 @@ private slots:
|
||||
void updateHighlight(TreeItem*);
|
||||
|
||||
private:
|
||||
void setupModelData(UAVObjectManager *objManager, bool categorize = true);
|
||||
QModelIndex index(TreeItem *item);
|
||||
void addDataObject(UAVDataObject *obj);
|
||||
void addDataObject(UAVDataObject *obj, bool categorize = true);
|
||||
MetaObjectTreeItem *addMetaObject(UAVMetaObject *obj, TreeItem *parent);
|
||||
void addArrayField(UAVObjectField *field, TreeItem *parent);
|
||||
|
||||
void addSingleField(int index, UAVObjectField *field, TreeItem *parent);
|
||||
void addInstance(UAVObject *obj, TreeItem *parent);
|
||||
|
||||
TreeItem *createCategoryItems(QStringList categoryPath, TreeItem *root);
|
||||
|
||||
QString updateMode(quint8 updateMode);
|
||||
void setupModelData(UAVObjectManager *objManager);
|
||||
ObjectTreeItem *findObjectTreeItem(UAVObject *obj);
|
||||
DataObjectTreeItem *findDataObjectTreeItem(UAVDataObject *obj);
|
||||
MetaObjectTreeItem *findMetaObjectTreeItem(UAVMetaObject *obj);
|
||||
|
Loading…
x
Reference in New Issue
Block a user