mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 09:45:44 +08:00
refs #195, view classes for
* ATC station * keyboard key * server * status message * users * aircrafts
This commit is contained in:
18
src/blackgui/aircraftview.cpp
Normal file
18
src/blackgui/aircraftview.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "aircraftview.h"
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
CAircraftView::CAircraftView(QWidget *parent) : CViewBase(parent)
|
||||||
|
{
|
||||||
|
this->m_model = new CAircraftListModel(this);
|
||||||
|
this->setModel(this->m_model); // via QTableView
|
||||||
|
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAircraft::IndexDistance);
|
||||||
|
if (this->m_model->hasValidSortColumn())
|
||||||
|
this->horizontalHeader()->setSortIndicator(
|
||||||
|
this->m_model->getSortColumn(),
|
||||||
|
this->m_model->getSortOrder());
|
||||||
|
}
|
||||||
|
}
|
||||||
21
src/blackgui/aircraftview.h
Normal file
21
src/blackgui/aircraftview.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef BLACKGUI_AIRCRAFTVIEW_H
|
||||||
|
#define BLACKGUI_AIRCRAFTVIEW_H
|
||||||
|
|
||||||
|
#include "viewbase.h"
|
||||||
|
#include "aircraftlistmodel.h"
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Aircrafts view
|
||||||
|
*/
|
||||||
|
class CAircraftView : public CViewBase<CAircraftListModel>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
explicit CAircraftView(QWidget *parent = nullptr);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // guard
|
||||||
24
src/blackgui/atcstationview.cpp
Normal file
24
src/blackgui/atcstationview.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include "atcstationview.h"
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
CAtcStationView::CAtcStationView(QWidget *parent) : CViewBase(parent)
|
||||||
|
{
|
||||||
|
this->m_model = new CAtcStationListModel(CAtcStationListModel::StationsOnline, this);
|
||||||
|
this->setModel(this->m_model); // via QTableView
|
||||||
|
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAtcStation::IndexDistance);
|
||||||
|
if (this->m_model->hasValidSortColumn())
|
||||||
|
this->horizontalHeader()->setSortIndicator(
|
||||||
|
this->m_model->getSortColumn(),
|
||||||
|
this->m_model->getSortOrder());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAtcStationView::setStationMode(CAtcStationListModel::AtcStationMode stationMode)
|
||||||
|
{
|
||||||
|
Q_ASSERT(this->m_model);
|
||||||
|
this->m_model->setStationMode(stationMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/blackgui/atcstationview.h
Normal file
24
src/blackgui/atcstationview.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef BLACKGUI_ATCSTATIONVIEW_H
|
||||||
|
#define BLACKGUI_ATCSTATIONVIEW_H
|
||||||
|
|
||||||
|
#include "viewbase.h"
|
||||||
|
#include "atcstationlistmodel.h"
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* \brief ATC stations view
|
||||||
|
*/
|
||||||
|
class CAtcStationView : public CViewBase<CAtcStationListModel>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
explicit CAtcStationView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! Set station mode
|
||||||
|
void setStationMode(CAtcStationListModel::AtcStationMode stationMode);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // guard
|
||||||
19
src/blackgui/keyboardkeyview.cpp
Normal file
19
src/blackgui/keyboardkeyview.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "keyboardkeyview.h"
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
CKeyboardKeyView::CKeyboardKeyView(QWidget *parent) : CViewBase(parent)
|
||||||
|
{
|
||||||
|
this->m_model = new CKeyboardKeyListModel(this);
|
||||||
|
this->setModel(this->m_model); // via QTableView
|
||||||
|
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Hardware::CKeyboardKey::IndexFunctionAsString);
|
||||||
|
if (this->m_model->hasValidSortColumn())
|
||||||
|
this->horizontalHeader()->setSortIndicator(
|
||||||
|
this->m_model->getSortColumn(),
|
||||||
|
this->m_model->getSortOrder());
|
||||||
|
this->setItemDelegate(new BlackGui::CKeyboardKeyItemDelegate(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
21
src/blackgui/keyboardkeyview.h
Normal file
21
src/blackgui/keyboardkeyview.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef BLACKGUI_KEYBOARDKEYVIEW_H
|
||||||
|
#define BLACKGUI_KEYBOARDKEYVIEW_H
|
||||||
|
|
||||||
|
#include "viewbase.h"
|
||||||
|
#include "keyboardkeylistmodel.h"
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Keyboard key view
|
||||||
|
*/
|
||||||
|
class CKeyboardKeyView : public CViewBase<CKeyboardKeyListModel>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
explicit CKeyboardKeyView(QWidget *parent = nullptr);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // guard
|
||||||
24
src/blackgui/serverview.cpp
Normal file
24
src/blackgui/serverview.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include "serverview.h"
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
CServerView::CServerView(QWidget *parent) : CViewBase(parent)
|
||||||
|
{
|
||||||
|
this->m_model = new CServerListModel(this);
|
||||||
|
this->setModel(this->m_model); // via QTableView
|
||||||
|
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Network::CServer::IndexName);
|
||||||
|
if (this->m_model->hasValidSortColumn())
|
||||||
|
this->horizontalHeader()->setSortIndicator(
|
||||||
|
this->m_model->getSortColumn(),
|
||||||
|
this->m_model->getSortOrder());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CServerView::setSelectedServer(const Network::CServer &selectedServer)
|
||||||
|
{
|
||||||
|
Q_ASSERT(this->m_model);
|
||||||
|
this->m_model->setSelectedServer(selectedServer);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/blackgui/serverview.h
Normal file
24
src/blackgui/serverview.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef BLACKGUI_SERVERVIEW_H
|
||||||
|
#define BLACKGUI_SERVERVIEW_H
|
||||||
|
|
||||||
|
#include "viewbase.h"
|
||||||
|
#include "serverlistmodel.h"
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Network servers
|
||||||
|
*/
|
||||||
|
class CServerView : public CViewBase<CServerListModel>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
explicit CServerView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! \copydoc CServerListModel::setSelectedServer
|
||||||
|
void setSelectedServer(const BlackMisc::Network::CServer &selectedServer);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // guard
|
||||||
49
src/blackgui/statusmessageview.cpp
Normal file
49
src/blackgui/statusmessageview.cpp
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#include "statusmessageview.h"
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
CStatusMessageView::CStatusMessageView(QWidget *parent) : CViewBase(parent), m_contextMenu(nullptr)
|
||||||
|
{
|
||||||
|
this->m_model = new CStatusMessageListModel(this);
|
||||||
|
this->setModel(this->m_model); // QTableView
|
||||||
|
this->m_model->setSortColumnByPropertyIndex(BlackMisc::CStatusMessage::IndexTimestamp);
|
||||||
|
if (this->m_model->hasValidSortColumn())
|
||||||
|
{
|
||||||
|
this->horizontalHeader()->setSortIndicator(
|
||||||
|
this->m_model->getSortColumn(),
|
||||||
|
this->m_model->getSortOrder());
|
||||||
|
}
|
||||||
|
|
||||||
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
this->m_contextMenu = new QMenu(this);
|
||||||
|
this->m_contextMenu->addAction("Clear");
|
||||||
|
connect(this, &QTableView::customContextMenuRequested, this, &CStatusMessageView::contextMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Message list context menu
|
||||||
|
*/
|
||||||
|
void CStatusMessageView::contextMenu(const QPoint &position)
|
||||||
|
{
|
||||||
|
// position for most widgets
|
||||||
|
QPoint globalPosition = this->mapToGlobal(position);
|
||||||
|
QAction *selectedItem = this->m_contextMenu->exec(globalPosition);
|
||||||
|
if (selectedItem)
|
||||||
|
{
|
||||||
|
// http://forum.technical-assistance.co.uk/sndvol32exe-command-line-parameters-vt1348.html
|
||||||
|
const QList<QAction *> actions = this->m_contextMenu->actions();
|
||||||
|
if (selectedItem == actions.at(0))
|
||||||
|
{
|
||||||
|
this->clear();
|
||||||
|
this->resizeColumnsToContents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/blackgui/statusmessageview.h
Normal file
28
src/blackgui/statusmessageview.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef BLACKGUI_STATUSMESSAGEVIEW_H
|
||||||
|
#define BLACKGUI_STATUSMESSAGEVIEW_H
|
||||||
|
|
||||||
|
#include "viewbase.h"
|
||||||
|
#include "statusmessagelistmodel.h"
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Status message view
|
||||||
|
*/
|
||||||
|
class CStatusMessageView : public CViewBase<CStatusMessageListModel>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
explicit CStatusMessageView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMenu *m_contextMenu;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
//! Context menu for message list
|
||||||
|
void contextMenu(const QPoint &position);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // guard
|
||||||
25
src/blackgui/userview.cpp
Normal file
25
src/blackgui/userview.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include "userview.h"
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
CUserView::CUserView(QWidget *parent) : CViewBase(parent)
|
||||||
|
{
|
||||||
|
this->m_model = new CUserListModel(CUserListModel::UserDetailed, this);
|
||||||
|
this->setModel(this->m_model); // via QTableView
|
||||||
|
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName);
|
||||||
|
if (this->m_model->hasValidSortColumn())
|
||||||
|
this->horizontalHeader()->setSortIndicator(
|
||||||
|
this->m_model->getSortColumn(),
|
||||||
|
this->m_model->getSortOrder());
|
||||||
|
this->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CUserView::setUserMode(CUserListModel::UserMode userMode)
|
||||||
|
{
|
||||||
|
Q_ASSERT(this->m_model);
|
||||||
|
this->m_model->setUserMode(userMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/blackgui/userview.h
Normal file
24
src/blackgui/userview.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef BLACKGUI_USERVIEW_H
|
||||||
|
#define BLACKGUI_USERVIEW_H
|
||||||
|
|
||||||
|
#include "viewbase.h"
|
||||||
|
#include "userlistmodel.h"
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* \brief User view
|
||||||
|
*/
|
||||||
|
class CUserView : public CViewBase<CUserListModel>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
explicit CUserView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! Set station mode
|
||||||
|
void setUserMode(CUserListModel::UserMode userMode);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user