swift
Loading...
Searching...
No Matches
userview.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <QtGlobal>
7
9
10using namespace swift::misc;
11using namespace swift::misc::network;
12using namespace swift::gui::models;
13using namespace swift::gui::menus;
14
15namespace swift::gui::views
16{
18 {
19 this->standardInit(new CUserListModel(CUserListModel::UserDetailed, this));
20 }
21
23 {
24 Q_ASSERT(m_model);
25 m_model->setUserMode(userMode);
26 }
27
29 {
30 if (this->hasSelection())
31 {
32 const CUser user(this->selectedObject());
33 if (user.hasCallsign())
34 {
35 menuActions.addMenuCom();
36 menuActions.addAction(CIcons::appTextMessages16(), "Show text messages", CMenuAction::pathClientCom(),
37 { this, &CUserView::requestTextMessage });
38 }
39 }
40 }
41
42 void CUserView::requestTextMessage()
43 {
44 const CUser user(this->selectedObject());
45 if (!user.hasCallsign())
46 {
47 return;
48 }
49 emit this->requestTextMessageWidget(user.getCallsign());
50 }
51} // namespace swift::gui::views
static const QString & pathClientCom()
Client COM related.
Definition menuaction.h:209
Bunch of CMenuAction objects.
Definition menuaction.h:384
CMenuAction addMenuCom()
Add COM model menu.
CMenuAction addAction(const CMenuAction &menuAction)
Add menu action.
void setUserMode(models::CUserListModel::UserMode userMode)
Set user mode.
Definition userview.cpp:22
void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign)
Request a text message.
void customMenu(menus::CMenuActions &menuActions)
Method creating the menu.
Definition userview.cpp:28
CUserView(QWidget *parent=nullptr)
Constructor.
Definition userview.cpp:17
CViewBase(QWidget *parent, ModelClass *model=nullptr)
Definition viewbase.cpp:31
bool hasSelection() const
Selection (selected rows).
static const QPixmap & appTextMessages16()
Application text messages.
Value object encapsulating information of a user.
Definition user.h:28
bool hasCallsign() const
Has associated callsign?
Definition user.h:89
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.
QObject * parent() const const