refs #195, extended model classes

* mode for users (detailed, complete)
* mode for ATC station (booked, online)
* clear method for columns
This commit is contained in:
Klaus Basan
2014-04-20 18:30:20 +02:00
parent 247e045288
commit 60f1b285ec
5 changed files with 102 additions and 34 deletions

View File

@@ -10,15 +10,10 @@ namespace BlackGui
/*
* Constructor
*/
CUserListModel::CUserListModel(QObject *parent) :
CListModelBase<BlackMisc::Network::CUser, BlackMisc::Network::CUserList>("ViewUserList", parent)
CUserListModel::CUserListModel(UserMode userMode, QObject *parent) :
CListModelBase<BlackMisc::Network::CUser, BlackMisc::Network::CUserList>("ViewUserList", parent), m_userMode(NotSet)
{
this->m_columns.addColumn(CColumn("", CUser::IndexCallsignIcon));
this->m_columns.addColumn(CColumn("realname", CUser::IndexRealName));
this->m_columns.addColumn(CColumn("callsign", CUser::IndexCallsign));
this->m_columns.addColumn(CColumn("userid", CUser::IndexId));
// this->m_columns.addColumn(CUser::IndexEmail, "email");
this->setUserMode(userMode);
// force strings for translation in resource files
(void)QT_TRANSLATE_NOOP("ViewUserList", "callsign");
(void)QT_TRANSLATE_NOOP("ViewUserList", "realname");
@@ -26,6 +21,32 @@ namespace BlackGui
(void)QT_TRANSLATE_NOOP("ViewUserList", "email");
}
/*
* Mode
*/
void CUserListModel::setUserMode(CUserListModel::UserMode userMode)
{
if (this->m_userMode == userMode) return;
this->m_userMode = userMode;
this->m_columns.clear();
switch (userMode)
{
case UserDetailed:
this->m_columns.addColumn(CColumn("", CUser::IndexCallsignIcon));
this->m_columns.addColumn(CColumn("realname", CUser::IndexRealName));
this->m_columns.addColumn(CColumn("callsign", CUser::IndexCallsign));
this->m_columns.addColumn(CColumn("userid", CUser::IndexId));
// this->m_columns.addColumn(CUser::IndexEmail, "email");
break;
case UserShort:
this->m_columns.addColumn(CColumn("", CUser::IndexCallsignIcon));
this->m_columns.addColumn(CColumn("realname", CUser::IndexRealName));
this->m_columns.addColumn(CColumn("callsign", CUser::IndexCallsign));
break;
}
}
/*
* Display icons
*/