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 );
|
||||
}
|
||||
|
||||
expandNodes(deviceView);
|
||||
QModelIndex index = model->index( device );
|
||||
if (index.isValid()) {
|
||||
deviceView->expand( index.parent() );
|
||||
|
@ -189,3 +190,13 @@ void EditDeviceDialog::cancelClicked() {
|
|||
#endif
|
||||
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 QStackedLayout;
|
||||
class QItemSelectionModel;
|
||||
class QTreeView;
|
||||
|
||||
class EditDeviceDialog : public QDialog
|
||||
{
|
||||
|
@ -26,6 +27,7 @@ private slots:
|
|||
void cancelClicked();
|
||||
|
||||
private:
|
||||
void expandNodes(QTreeView *deviceView);
|
||||
VendorDeviceModel *model;
|
||||
Device *device;
|
||||
QStackedLayout *settingsLayout;
|
||||
|
|
|
@ -74,6 +74,10 @@ bool VendorDeviceTreeItem::isDevice() const {
|
|||
return model.length() > 0;
|
||||
}
|
||||
|
||||
bool VendorDeviceTreeItem::isExpanded() const {
|
||||
return expanded;
|
||||
}
|
||||
|
||||
QString VendorDeviceTreeItem::deviceModel() const {
|
||||
return model;
|
||||
}
|
||||
|
@ -142,6 +146,7 @@ bool VendorDeviceTreeItem::parseXml( const QString &filename ) {
|
|||
void VendorDeviceTreeItem::parseType( QXmlStreamReader *reader ) {
|
||||
VendorDeviceTreeItem *item = new VendorDeviceTreeItem(this);
|
||||
item->deviceName = reader->attributes().value("name").toString();
|
||||
item->expanded = (reader->attributes().value("expanded").toString() == "true" ? true : false);
|
||||
appendChild(item);
|
||||
|
||||
reader->readNext();
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
QPixmap image() const;
|
||||
int widget() const;
|
||||
bool isDevice() const;
|
||||
bool isExpanded() const;
|
||||
QString deviceModel() const;
|
||||
const QString &deviceProtocol() const;
|
||||
|
||||
|
@ -40,6 +41,7 @@ private:
|
|||
QList<VendorDeviceTreeItem *> childItems;
|
||||
|
||||
int settingsWidget;
|
||||
bool expanded;
|
||||
QString deviceName, protocol, model;
|
||||
QString img;
|
||||
VendorDeviceTreeItem *parentItem;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue