mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
refs #227, view/model for client class
* model * view * and GUI component which now encapsulates the user table view
This commit is contained in:
49
src/blackgui/clientlistmodel.cpp
Normal file
49
src/blackgui/clientlistmodel.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "clientlistmodel.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <QMetaProperty>
|
||||
#include <QBrush>
|
||||
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CClientListModel::CClientListModel(QObject *parent) :
|
||||
CListModelBase<BlackMisc::Network::CClient, BlackMisc::Network::CClientList>("ViewClientList", parent)
|
||||
{
|
||||
this->m_columns.addColumn(CColumn("", CClient::IndexCallsignIcon));
|
||||
this->m_columns.addColumn(CColumn("callsign", CClient::IndexCallsign));
|
||||
this->m_columns.addColumn(CColumn("realname", CClient::IndexRealName));
|
||||
this->m_columns.addColumn(CColumn("capabilities", CClient::IndexCapabilitiesString));
|
||||
this->m_columns.addColumn(CColumn("model", CClient::IndexQueriedModelString));
|
||||
this->m_columns.addColumn(CColumn("host", CClient::IndexHost));
|
||||
|
||||
// force strings for translation in resource files
|
||||
// force strings for translation in resource files
|
||||
(void)QT_TRANSLATE_NOOP("ViewClientList", "callsign");
|
||||
(void)QT_TRANSLATE_NOOP("ViewClientList", "realname");
|
||||
(void)QT_TRANSLATE_NOOP("ViewClientList", "userid");
|
||||
(void)QT_TRANSLATE_NOOP("ViewClientList", "model");
|
||||
(void)QT_TRANSLATE_NOOP("ViewClientList", "host");
|
||||
}
|
||||
|
||||
/*
|
||||
* Display icons
|
||||
*/
|
||||
QVariant CClientListModel::data(const QModelIndex &modelIndex, int role) const
|
||||
{
|
||||
// shortcut, fast check
|
||||
if (role != Qt::DecorationRole) return CListModelBase::data(modelIndex, role);
|
||||
if (this->columnToPropertyIndex(modelIndex.column()) == CClient::IndexCallsignIcon)
|
||||
{
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
CClient u = this->at(modelIndex);
|
||||
return u.toIcon();
|
||||
}
|
||||
}
|
||||
return CListModelBase::data(modelIndex, role);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user