sign: Open StreamStats as a Tabbed widget

PortStats and StreamStats Windows are presented as a tabbed widget.
Multiple StreamStats windows are titled to include an id to hint at the
sequence in which they were opened
This commit is contained in:
Srivats P 2016-11-27 12:39:37 +05:30
parent 4f8ee757b3
commit 3d7a459b5f
4 changed files with 24 additions and 4 deletions

View File

@ -234,14 +234,18 @@ void PortStatsWindow::on_tbGetStreamStats_clicked()
model->portListFromIndex(selectedColumns(), portList); model->portListFromIndex(selectedColumns(), portList);
if (portList.size()) { if (portList.size()) {
QDockWidget *dock = new QDockWidget(tr("Stream Statistics"), QDockWidget *dock = new QDockWidget(mainWindow);
mainWindow);
streamStatsModel = new StreamStatsModel(dock); streamStatsModel = new StreamStatsModel(dock);
dock->setWidget(new StreamStatsWindow(streamStatsModel, dock)); dock->setWidget(new StreamStatsWindow(streamStatsModel, dock));
dock->setWindowTitle(dock->widget()->windowTitle());
dock->setObjectName("streamStatsDock"); dock->setObjectName("streamStatsDock");
dock->setFloating(true);
dock->setAttribute(Qt::WA_DeleteOnClose); dock->setAttribute(Qt::WA_DeleteOnClose);
QDockWidget *statsDock = mainWindow->findChild<QDockWidget*>(
"statsDock");
mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dock); mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dock);
mainWindow->tabifyDockWidget(statsDock, dock);
dock->show();
dock->raise();
} }
// Get stream stats for selected ports, portgroup by portgroup // Get stream stats for selected ports, portgroup by portgroup

View File

@ -22,14 +22,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QHeaderView> #include <QHeaderView>
static int id;
static int count;
StreamStatsWindow::StreamStatsWindow(QAbstractItemModel *model, QWidget *parent) StreamStatsWindow::StreamStatsWindow(QAbstractItemModel *model, QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
if (id)
setWindowTitle(windowTitle() + QString("(%1)").arg(id));
id++;
count++;
streamStats->setModel(model); streamStats->setModel(model);
streamStats->verticalHeader()->setHighlightSections(false); streamStats->verticalHeader()->setHighlightSections(false);
streamStats->verticalHeader()->setDefaultSectionSize( streamStats->verticalHeader()->setDefaultSectionSize(
streamStats->verticalHeader()->minimumSectionSize()); streamStats->verticalHeader()->minimumSectionSize());
} }
StreamStatsWindow::~StreamStatsWindow()
{
count--;
if (count == 0)
id = 0;
}

View File

@ -29,6 +29,7 @@ class StreamStatsWindow: public QWidget, private Ui::StreamStatsWindow
Q_OBJECT Q_OBJECT
public: public:
StreamStatsWindow(QAbstractItemModel *model, QWidget *parent = 0); StreamStatsWindow(QAbstractItemModel *model, QWidget *parent = 0);
~StreamStatsWindow();
}; };
#endif #endif

View File

@ -10,7 +10,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
<string>Form</string> <string>Stream Statistics</string>
</property> </property>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<item> <item>