Made the first nodes in the list of vendors expanded in EditDeviceDialog, closes #42
This commit is contained in:
parent
ecd652e572
commit
12e5442f7e
4 changed files with 20 additions and 0 deletions
|
@ -110,6 +110,7 @@ foreach( DeviceSetting *s, deviceSettings ) {
|
||||||
settingsLayout->addWidget( s );
|
settingsLayout->addWidget( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expandNodes(deviceView);
|
||||||
QModelIndex index = model->index( device );
|
QModelIndex index = model->index( device );
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
deviceView->expand( index.parent() );
|
deviceView->expand( index.parent() );
|
||||||
|
@ -189,3 +190,13 @@ void EditDeviceDialog::cancelClicked() {
|
||||||
#endif
|
#endif
|
||||||
this->reject();
|
this->reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditDeviceDialog::expandNodes(QTreeView *deviceView) {
|
||||||
|
for( int i = 0; i < model->rowCount(QModelIndex()); ++i ) {
|
||||||
|
QModelIndex index = model->index(i, 0, QModelIndex());
|
||||||
|
VendorDeviceTreeItem *item = model->item(index);
|
||||||
|
if (item && item->isExpanded()) {
|
||||||
|
deviceView->expand(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QStackedLayout;
|
class QStackedLayout;
|
||||||
class QItemSelectionModel;
|
class QItemSelectionModel;
|
||||||
|
class QTreeView;
|
||||||
|
|
||||||
class EditDeviceDialog : public QDialog
|
class EditDeviceDialog : public QDialog
|
||||||
{
|
{
|
||||||
|
@ -26,6 +27,7 @@ private slots:
|
||||||
void cancelClicked();
|
void cancelClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void expandNodes(QTreeView *deviceView);
|
||||||
VendorDeviceModel *model;
|
VendorDeviceModel *model;
|
||||||
Device *device;
|
Device *device;
|
||||||
QStackedLayout *settingsLayout;
|
QStackedLayout *settingsLayout;
|
||||||
|
|
|
@ -74,6 +74,10 @@ bool VendorDeviceTreeItem::isDevice() const {
|
||||||
return model.length() > 0;
|
return model.length() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VendorDeviceTreeItem::isExpanded() const {
|
||||||
|
return expanded;
|
||||||
|
}
|
||||||
|
|
||||||
QString VendorDeviceTreeItem::deviceModel() const {
|
QString VendorDeviceTreeItem::deviceModel() const {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
@ -142,6 +146,7 @@ bool VendorDeviceTreeItem::parseXml( const QString &filename ) {
|
||||||
void VendorDeviceTreeItem::parseType( QXmlStreamReader *reader ) {
|
void VendorDeviceTreeItem::parseType( QXmlStreamReader *reader ) {
|
||||||
VendorDeviceTreeItem *item = new VendorDeviceTreeItem(this);
|
VendorDeviceTreeItem *item = new VendorDeviceTreeItem(this);
|
||||||
item->deviceName = reader->attributes().value("name").toString();
|
item->deviceName = reader->attributes().value("name").toString();
|
||||||
|
item->expanded = (reader->attributes().value("expanded").toString() == "true" ? true : false);
|
||||||
appendChild(item);
|
appendChild(item);
|
||||||
|
|
||||||
reader->readNext();
|
reader->readNext();
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
QPixmap image() const;
|
QPixmap image() const;
|
||||||
int widget() const;
|
int widget() const;
|
||||||
bool isDevice() const;
|
bool isDevice() const;
|
||||||
|
bool isExpanded() const;
|
||||||
QString deviceModel() const;
|
QString deviceModel() const;
|
||||||
const QString &deviceProtocol() const;
|
const QString &deviceProtocol() const;
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ private:
|
||||||
QList<VendorDeviceTreeItem *> childItems;
|
QList<VendorDeviceTreeItem *> childItems;
|
||||||
|
|
||||||
int settingsWidget;
|
int settingsWidget;
|
||||||
|
bool expanded;
|
||||||
QString deviceName, protocol, model;
|
QString deviceName, protocol, model;
|
||||||
QString img;
|
QString img;
|
||||||
VendorDeviceTreeItem *parentItem;
|
VendorDeviceTreeItem *parentItem;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue