Device Emulation (contd.): Use two different TableViews for DeviceGroupList and DeviceList

This commit is contained in:
Srivats P 2016-03-11 21:05:07 +05:30
parent 0503c8acaf
commit 7c87e2130a
2 changed files with 78 additions and 28 deletions

View File

@ -55,6 +55,8 @@ PortsWindow::PortsWindow(PortGroupList *pgl, QWidget *parent)
tvStreamList->verticalHeader()->minimumSectionSize());
deviceGroupList->verticalHeader()->setDefaultSectionSize(
deviceGroupList->verticalHeader()->minimumSectionSize());
deviceList->verticalHeader()->setDefaultSectionSize(
deviceList->verticalHeader()->minimumSectionSize());
// Populate PortList Context Menu Actions
tvPortList->addAction(actionNew_Port_Group);
@ -97,6 +99,7 @@ PortsWindow::PortsWindow(PortGroupList *pgl, QWidget *parent)
tvStreamList->setModel(plm->getStreamModel());
deviceGroupList->setModel(plm->getDeviceGroupModel());
deviceList->setModel(plm->getDeviceModel());
// XXX: It would be ideal if we only needed to do the below to
// get the proxy model to do its magic. However, the QModelIndex
@ -158,8 +161,11 @@ PortsWindow::PortsWindow(PortGroupList *pgl, QWidget *parent)
SLOT(updateDeviceViewActions()));
// FIXME: hardcoding
deviceGroupList->resizeColumnToContents(1);
deviceGroupList->resizeColumnToContents(2);
deviceGroupList->resizeColumnToContents(1); // Vlan Count
deviceGroupList->resizeColumnToContents(2); // Device Count
// FIXME: hardcoding
deviceList->resizeColumnToContents(1); // Vlan Id(s)
// Initially we don't have any ports/streams/devices
// - so send signal triggers
@ -896,11 +902,7 @@ _exit:
void PortsWindow::on_deviceInfo_toggled(bool checked)
{
refresh->setVisible(checked);
if (checked)
deviceGroupList->setModel(plm->getDeviceModel());
else
deviceGroupList->setModel(plm->getDeviceGroupModel());
devicesWidget->setCurrentIndex(checked ? 1 : 0);
}
void PortsWindow::on_actionNewDeviceGroup_triggered()

View File

@ -219,28 +219,76 @@
</layout>
</item>
<item>
<widget class="QTableView" name="deviceGroupList" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy" >
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="lineWidth" >
<number>1</number>
</property>
<property name="selectionMode" >
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior" >
<enum>QAbstractItemView::SelectRows</enum>
<widget class="QStackedWidget" name="devicesWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="deviceConfigPage" >
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<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="QTableView" name="deviceGroupList" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy" >
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="lineWidth" >
<number>1</number>
</property>
<property name="selectionMode" >
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior" >
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="deviceInfoPage" >
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<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="QTableView" name="deviceList" />
</item>
</layout>
</widget>
</widget>
</item>
</layout>