Skip to content

Commit d7bfbf5

Browse files
committed
Added icons into ProjectView for client and server
1 parent 2571f6a commit d7bfbf5

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/client/gui/project/client_projectmodel.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323
#include "client_projectmodel.h"
2424

25+
#include <QIcon>
26+
2527
#include <project/client_project.h>
2628
#include <project/client_port.h>
2729
#include <project/client_device.h>
@@ -75,12 +77,21 @@ QModelIndex mbClientProjectModel::index(int row, int column, const QModelIndex &
7577

7678
QVariant mbClientProjectModel::data(const QModelIndex &index, int role) const
7779
{
78-
if ((role == Qt::DisplayRole) || (role == Qt::EditRole))
80+
switch (role)
7981
{
82+
case Qt::DisplayRole:
83+
case Qt::EditRole:
8084
if (mbClientPort *p = port(index))
8185
return portName(p);
8286
if (mbClientDevice *d = device(index))
8387
return deviceName(d);
88+
break;
89+
case Qt::DecorationRole:
90+
if (mbClientPort *p = port(index))
91+
return QIcon(":/core/icons/port.png");
92+
if (mbClientDevice *d = device(index))
93+
return QIcon(":/core/icons/device.png");
94+
break;
8495
}
8596
return QVariant();
8697
}

src/server/gui/project/server_projectmodel.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323
#include "server_projectmodel.h"
2424

25+
#include <QIcon>
26+
2527
#include <project/server_project.h>
2628
#include <project/server_port.h>
2729
#include <project/server_deviceref.h>
@@ -76,12 +78,21 @@ QModelIndex mbServerProjectModel::index(int row, int column, const QModelIndex &
7678

7779
QVariant mbServerProjectModel::data(const QModelIndex &index, int role) const
7880
{
79-
if ((role == Qt::DisplayRole) || (role == Qt::EditRole))
81+
switch (role)
8082
{
83+
case Qt::DisplayRole:
84+
case Qt::EditRole:
8185
if (mbServerPort *p = port(index))
8286
return portName(p);
8387
if (mbServerDeviceRef *d = deviceRef(index))
8488
return deviceName(d);
89+
break;
90+
case Qt::DecorationRole:
91+
if (mbServerPort *p = port(index))
92+
return QIcon(":/core/icons/port.png");
93+
if (mbServerDeviceRef *d = deviceRef(index))
94+
return QIcon(":/core/icons/device.png");
95+
break;
8596
}
8697
return QVariant();
8798
}

0 commit comments

Comments
 (0)