diff --git a/src/blackgui/aircraftview.cpp b/src/blackgui/aircraftview.cpp deleted file mode 100644 index 3eecd56f7..000000000 --- a/src/blackgui/aircraftview.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "aircraftview.h" -#include - -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()); - } -} diff --git a/src/blackgui/aircraftview.h b/src/blackgui/aircraftview.h deleted file mode 100644 index 70b6ccc63..000000000 --- a/src/blackgui/aircraftview.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef BLACKGUI_AIRCRAFTVIEW_H -#define BLACKGUI_AIRCRAFTVIEW_H - -#include "viewbase.h" -#include "aircraftlistmodel.h" - -namespace BlackGui -{ - /*! - * Aircrafts view - */ - class CAircraftView : public CViewBase - { - - public: - - //! Constructor - explicit CAircraftView(QWidget *parent = nullptr); - }; -} -#endif // guard diff --git a/src/blackgui/airportview.cpp b/src/blackgui/airportview.cpp deleted file mode 100644 index 24b547171..000000000 --- a/src/blackgui/airportview.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "airportview.h" -#include - -using namespace BlackMisc; - -namespace BlackGui -{ - CAirportView::CAirportView(QWidget *parent) : CViewBase(parent) - { - this->m_model = new CAirportListModel(this); - this->setModel(this->m_model); // via QTableView - this->m_model->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAirport::IndexDistance); - if (this->m_model->hasValidSortColumn()) - this->horizontalHeader()->setSortIndicator( - this->m_model->getSortColumn(), - this->m_model->getSortOrder()); - } -} diff --git a/src/blackgui/airportview.h b/src/blackgui/airportview.h deleted file mode 100644 index 5029ad6cb..000000000 --- a/src/blackgui/airportview.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef BLACKGUI_AIRPORTVIEW_H -#define BLACKGUI_AIRPORTVIEW_H - -#include "viewbase.h" -#include "airportlistmodel.h" - -namespace BlackGui -{ - /*! - * Airports view - */ - class CAirportView : public CViewBase - { - - public: - - //! Constructor - explicit CAirportView(QWidget *parent = nullptr); - }; -} -#endif // guard diff --git a/src/blackgui/atcstationview.cpp b/src/blackgui/atcstationview.cpp deleted file mode 100644 index 745ccd3be..000000000 --- a/src/blackgui/atcstationview.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "atcstationview.h" -#include - -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); - } - - void CAtcStationView::changedAtcStationConnectionStatus(const Aviation::CAtcStation &station, bool added) - { - this->m_model->changedAtcStationConnectionStatus(station, added); - this->resizeColumnsToContents(); - this->resizeRowsToContents(); - } -} diff --git a/src/blackgui/atcstationview.h b/src/blackgui/atcstationview.h deleted file mode 100644 index ec0de08d0..000000000 --- a/src/blackgui/atcstationview.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef BLACKGUI_ATCSTATIONVIEW_H -#define BLACKGUI_ATCSTATIONVIEW_H - -#include "viewbase.h" -#include "atcstationlistmodel.h" - -namespace BlackGui -{ - /*! - * \brief ATC stations view - */ - class CAtcStationView : public CViewBase - { - - public: - - //! Constructor - explicit CAtcStationView(QWidget *parent = nullptr); - - //! Set station mode - void setStationMode(CAtcStationListModel::AtcStationMode stationMode); - - public slots: - //! \copydoc CAtcStationListModel::changedAtcStationConnectionStatus - void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added); - - }; -} -#endif // guard diff --git a/src/blackgui/clientview.cpp b/src/blackgui/clientview.cpp deleted file mode 100644 index 29c71f6fb..000000000 --- a/src/blackgui/clientview.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "clientview.h" -#include - -using namespace BlackMisc; - -namespace BlackGui -{ - CClientView::CClientView(QWidget *parent) : CViewBase(parent) - { - this->m_model = new CClientListModel(this); - this->setModel(this->m_model); // via QTableView - this->m_model->setSortColumnByPropertyIndex(BlackMisc::Network::CClient::IndexRealName); - if (this->m_model->hasValidSortColumn()) - this->horizontalHeader()->setSortIndicator( - this->m_model->getSortColumn(), - this->m_model->getSortOrder()); - this->horizontalHeader()->setStretchLastSection(true); - } -} diff --git a/src/blackgui/clientview.h b/src/blackgui/clientview.h deleted file mode 100644 index 895a576e2..000000000 --- a/src/blackgui/clientview.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef BLACKGUI_CLIENTVIEW_H -#define BLACKGUI_CLIENTVIEW_H - -#include "viewbase.h" -#include "clientlistmodel.h" - -namespace BlackGui -{ - /*! - * \brief Client view - */ - class CClientView : public CViewBase - { - - public: - - //! Constructor - explicit CClientView(QWidget *parent = nullptr); - }; -} -#endif // guard diff --git a/src/blackgui/keyboardkeyview.cpp b/src/blackgui/keyboardkeyview.cpp deleted file mode 100644 index d047b4acf..000000000 --- a/src/blackgui/keyboardkeyview.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "keyboardkeyview.h" -#include - -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)); - } -} diff --git a/src/blackgui/keyboardkeyview.h b/src/blackgui/keyboardkeyview.h deleted file mode 100644 index 4b6213dcb..000000000 --- a/src/blackgui/keyboardkeyview.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef BLACKGUI_KEYBOARDKEYVIEW_H -#define BLACKGUI_KEYBOARDKEYVIEW_H - -#include "viewbase.h" -#include "keyboardkeylistmodel.h" - -namespace BlackGui -{ - /*! - * \brief Keyboard key view - */ - class CKeyboardKeyView : public CViewBase - { - - public: - - //! Constructor - explicit CKeyboardKeyView(QWidget *parent = nullptr); - }; -} -#endif // guard diff --git a/src/blackgui/serverview.cpp b/src/blackgui/serverview.cpp deleted file mode 100644 index 1b5bbeed8..000000000 --- a/src/blackgui/serverview.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "serverview.h" -#include - -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); - } -} diff --git a/src/blackgui/serverview.h b/src/blackgui/serverview.h deleted file mode 100644 index 879247099..000000000 --- a/src/blackgui/serverview.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef BLACKGUI_SERVERVIEW_H -#define BLACKGUI_SERVERVIEW_H - -#include "viewbase.h" -#include "serverlistmodel.h" - -namespace BlackGui -{ - /*! - * \brief Network servers - */ - class CServerView : public CViewBase - { - - public: - - //! Constructor - explicit CServerView(QWidget *parent = nullptr); - - //! \copydoc CServerListModel::setSelectedServer - void setSelectedServer(const BlackMisc::Network::CServer &selectedServer); - }; -} -#endif // guard diff --git a/src/blackgui/statusmessageview.cpp b/src/blackgui/statusmessageview.cpp deleted file mode 100644 index c396ab3fa..000000000 --- a/src/blackgui/statusmessageview.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "statusmessageview.h" -#include -#include - -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 actions = this->m_contextMenu->actions(); - if (selectedItem == actions.at(0)) - { - this->clear(); - this->resizeColumnsToContents(); - } - } - } -} diff --git a/src/blackgui/statusmessageview.h b/src/blackgui/statusmessageview.h deleted file mode 100644 index 64330bd6c..000000000 --- a/src/blackgui/statusmessageview.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef BLACKGUI_STATUSMESSAGEVIEW_H -#define BLACKGUI_STATUSMESSAGEVIEW_H - -#include "viewbase.h" -#include "statusmessagelistmodel.h" - -namespace BlackGui -{ - /*! - * \brief Status message view - */ - class CStatusMessageView : public CViewBase - { - - 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 diff --git a/src/blackgui/userview.cpp b/src/blackgui/userview.cpp deleted file mode 100644 index 49b52375c..000000000 --- a/src/blackgui/userview.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "userview.h" -#include - -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); - } -} diff --git a/src/blackgui/userview.h b/src/blackgui/userview.h deleted file mode 100644 index d040cf9d6..000000000 --- a/src/blackgui/userview.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef BLACKGUI_USERVIEW_H -#define BLACKGUI_USERVIEW_H - -#include "viewbase.h" -#include "userlistmodel.h" - -namespace BlackGui -{ - /*! - * \brief User view - */ - class CUserView : public CViewBase - { - - public: - - //! Constructor - explicit CUserView(QWidget *parent = nullptr); - - //! Set station mode - void setUserMode(CUserListModel::UserMode userMode); - }; -} -#endif // guard diff --git a/src/blackgui/viewbase.h b/src/blackgui/viewbase.h deleted file mode 100644 index 35a974f52..000000000 --- a/src/blackgui/viewbase.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef BLACKGUI_VIEWBASE_H -#define BLACKGUI_VIEWBASE_H - -#include - -namespace BlackGui -{ - /*! - * \brief List model - */ - template class CViewBase : public QTableView - { - - protected: - - //! Constructor - CViewBase(QWidget *parent, ModelClass *model = nullptr) : QTableView(parent), m_model(model) - { - this->setSortingEnabled(true); - this->horizontalHeader()->setStretchLastSection(true); - } - - //! Destructor - virtual ~CViewBase() {} - - ModelClass *m_model; //!< corresponding model - - public: - - //! Model - ModelClass *derivedModel() { return this->m_model; } - - //! Model - const ModelClass *derivedModel() const { return this->m_model; } - - //! Clear - void clear() { Q_ASSERT(this->m_model); this->m_model->clear(); } - - //! Update - template int update(const ContainerType &container, bool resize = true) - { - Q_ASSERT(this->m_model); - int c = this->m_model->update(container); - if (!resize) return c; - this->resizeColumnsToContents(); - this->resizeRowsToContents(); - return c; - } - - //! Insert - template void insert(const ObjectType &value, bool resize = true) - { - Q_ASSERT(this->m_model); - this->m_model->insert(value); - if (!resize) return; - this->resizeColumnsToContents(); - this->resizeRowsToContents(); - } - - //! Value object at - template const ObjectType &at(const QModelIndex &index) const - { - Q_ASSERT(this->m_model); - return this->m_model->at(index); - } - - //! Row count - int rowCount() const - { - Q_ASSERT(this->m_model); - return this->m_model->rowCount(); - } - - //! Any data? - bool isEmpty() const - { - Q_ASSERT(this->m_model); - return this->m_model->rowCount() < 1; - } - }; -} -#endif // guard diff --git a/src/blackgui/views/aircraftview.cpp b/src/blackgui/views/aircraftview.cpp new file mode 100644 index 000000000..56be7b103 --- /dev/null +++ b/src/blackgui/views/aircraftview.cpp @@ -0,0 +1,31 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "aircraftview.h" +#include + +using namespace BlackMisc; +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Views + { + 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()); + } + } +} diff --git a/src/blackgui/views/aircraftview.h b/src/blackgui/views/aircraftview.h new file mode 100644 index 000000000..a2ebdefcb --- /dev/null +++ b/src/blackgui/views/aircraftview.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_AIRCRAFTVIEW_H +#define BLACKGUI_AIRCRAFTVIEW_H + +#include "viewbase.h" +#include "../models/aircraftlistmodel.h" + +namespace BlackGui +{ + namespace Views + { + //! Aircrafts view + class CAircraftView : public CViewBase + { + + public: + + //! Constructor + explicit CAircraftView(QWidget *parent = nullptr); + }; + } +} +#endif // guard diff --git a/src/blackgui/views/airportview.cpp b/src/blackgui/views/airportview.cpp new file mode 100644 index 000000000..1b8acdc8d --- /dev/null +++ b/src/blackgui/views/airportview.cpp @@ -0,0 +1,33 @@ +/* Copyright (C) 2013 + * Swift Project Community / Contributors + * + * This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "airportview.h" +#include + +using namespace BlackMisc; +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Views + { + CAirportView::CAirportView(QWidget *parent) : CViewBase(parent) + { + this->m_model = new CAirportListModel(this); + this->setModel(this->m_model); // via QTableView + this->m_model->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAirport::IndexDistance); + if (this->m_model->hasValidSortColumn()) + { + this->horizontalHeader()->setSortIndicator( + this->m_model->getSortColumn(), + this->m_model->getSortOrder()); + } + } + } +} diff --git a/src/blackgui/views/airportview.h b/src/blackgui/views/airportview.h new file mode 100644 index 000000000..6465551a3 --- /dev/null +++ b/src/blackgui/views/airportview.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#ifndef BLACKGUI_AIRPORTVIEW_H +#define BLACKGUI_AIRPORTVIEW_H + +//! \file + +#include "viewbase.h" +#include "../models/airportlistmodel.h" + +namespace BlackGui +{ + namespace Views + { + //! Airports view + class CAirportView : public CViewBase + { + + public: + + //! Constructor + explicit CAirportView(QWidget *parent = nullptr); + }; + } +} +#endif // guard diff --git a/src/blackgui/views/atcstationview.cpp b/src/blackgui/views/atcstationview.cpp new file mode 100644 index 000000000..87b902556 --- /dev/null +++ b/src/blackgui/views/atcstationview.cpp @@ -0,0 +1,44 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "atcstationview.h" +#include + +using namespace BlackMisc; +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Views + { + 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); + } + + void CAtcStationView::changedAtcStationConnectionStatus(const Aviation::CAtcStation &station, bool added) + { + this->m_model->changedAtcStationConnectionStatus(station, added); + this->resizeColumnsToContents(); + this->resizeRowsToContents(); + } + } +} diff --git a/src/blackgui/views/atcstationview.h b/src/blackgui/views/atcstationview.h new file mode 100644 index 000000000..5d12ccef0 --- /dev/null +++ b/src/blackgui/views/atcstationview.h @@ -0,0 +1,41 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#ifndef BLACKGUI_ATCSTATIONVIEW_H +#define BLACKGUI_ATCSTATIONVIEW_H + +//! \file + +#include "viewbase.h" +#include "../models/atcstationlistmodel.h" + +namespace BlackGui +{ + namespace Views + { + //! ATC stations view + class CAtcStationView : public CViewBase + { + + public: + + //! Constructor + explicit CAtcStationView(QWidget *parent = nullptr); + + //! Set station mode + void setStationMode(Models::CAtcStationListModel::AtcStationMode stationMode); + + public slots: + //! \copydoc CAtcStationListModel::changedAtcStationConnectionStatus + void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added); + + }; + } +} +#endif // guard diff --git a/src/blackgui/views/clientview.cpp b/src/blackgui/views/clientview.cpp new file mode 100644 index 000000000..b9df5cf11 --- /dev/null +++ b/src/blackgui/views/clientview.cpp @@ -0,0 +1,32 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "clientview.h" +#include + +using namespace BlackMisc; +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Views + { + CClientView::CClientView(QWidget *parent) : CViewBase(parent) + { + this->m_model = new CClientListModel(this); + this->setModel(this->m_model); // via QTableView + this->m_model->setSortColumnByPropertyIndex(BlackMisc::Network::CClient::IndexRealName); + if (this->m_model->hasValidSortColumn()) + this->horizontalHeader()->setSortIndicator( + this->m_model->getSortColumn(), + this->m_model->getSortOrder()); + this->horizontalHeader()->setStretchLastSection(true); + } + } +} diff --git a/src/blackgui/views/clientview.h b/src/blackgui/views/clientview.h new file mode 100644 index 000000000..bc46de577 --- /dev/null +++ b/src/blackgui/views/clientview.h @@ -0,0 +1,31 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#ifndef BLACKGUI_CLIENTVIEW_H +#define BLACKGUI_CLIENTVIEW_H + +//! \file + +#include "viewbase.h" +#include "../models/clientlistmodel.h" + +namespace BlackGui +{ + namespace Views + { + //! Client view + class CClientView : public CViewBase + { + public: + //! Constructor + explicit CClientView(QWidget *parent = nullptr); + }; + } +} +#endif // guard diff --git a/src/blackgui/views/keyboardkeyview.cpp b/src/blackgui/views/keyboardkeyview.cpp new file mode 100644 index 000000000..e88c38b63 --- /dev/null +++ b/src/blackgui/views/keyboardkeyview.cpp @@ -0,0 +1,32 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "keyboardkeyview.h" +#include + +using namespace BlackMisc; +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Views + { + 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 CKeyboardKeyItemDelegate(this)); + } + } +} diff --git a/src/blackgui/views/keyboardkeyview.h b/src/blackgui/views/keyboardkeyview.h new file mode 100644 index 000000000..ac61472de --- /dev/null +++ b/src/blackgui/views/keyboardkeyview.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#ifndef BLACKGUI_KEYBOARDKEYVIEW_H +#define BLACKGUI_KEYBOARDKEYVIEW_H + +//! \file + +#include "viewbase.h" +#include "../models/keyboardkeylistmodel.h" + +namespace BlackGui +{ + namespace Views + { + //! Keyboard key view + class CKeyboardKeyView : public CViewBase + { + + public: + + //! Constructor + explicit CKeyboardKeyView(QWidget *parent = nullptr); + }; + } +} +#endif // guard diff --git a/src/blackgui/views/serverview.cpp b/src/blackgui/views/serverview.cpp new file mode 100644 index 000000000..5f16e9f07 --- /dev/null +++ b/src/blackgui/views/serverview.cpp @@ -0,0 +1,37 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "serverview.h" +#include + +using namespace BlackMisc; +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Views + { + 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); + } + } +} diff --git a/src/blackgui/views/serverview.h b/src/blackgui/views/serverview.h new file mode 100644 index 000000000..fbc51b01b --- /dev/null +++ b/src/blackgui/views/serverview.h @@ -0,0 +1,36 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#ifndef BLACKGUI_SERVERVIEW_H +#define BLACKGUI_SERVERVIEW_H + +//! \file + +#include "viewbase.h" +#include "../models/serverlistmodel.h" + +namespace BlackGui +{ + namespace Views + { + //! Network servers + class CServerView : public CViewBase + { + + public: + + //! Constructor + explicit CServerView(QWidget *parent = nullptr); + + //! \copydoc CServerListModel::setSelectedServer + void setSelectedServer(const BlackMisc::Network::CServer &selectedServer); + }; + } +} +#endif // guard diff --git a/src/blackgui/views/statusmessageview.cpp b/src/blackgui/views/statusmessageview.cpp new file mode 100644 index 000000000..10b45ebe0 --- /dev/null +++ b/src/blackgui/views/statusmessageview.cpp @@ -0,0 +1,62 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "statusmessageview.h" +#include +#include + +using namespace BlackMisc; +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Views + { + /* + * 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 actions = this->m_contextMenu->actions(); + if (selectedItem == actions.at(0)) + { + this->clear(); + this->resizeColumnsToContents(); + } + } + } + } +} diff --git a/src/blackgui/views/statusmessageview.h b/src/blackgui/views/statusmessageview.h new file mode 100644 index 000000000..b5b0ed761 --- /dev/null +++ b/src/blackgui/views/statusmessageview.h @@ -0,0 +1,40 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#ifndef BLACKGUI_STATUSMESSAGEVIEW_H +#define BLACKGUI_STATUSMESSAGEVIEW_H + +//! \file + +#include "viewbase.h" +#include "../models/statusmessagelistmodel.h" + +namespace BlackGui +{ + namespace Views + { + //! Status message view + class CStatusMessageView : public CViewBase + { + + 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 diff --git a/src/blackgui/views/userview.cpp b/src/blackgui/views/userview.cpp new file mode 100644 index 000000000..5243761db --- /dev/null +++ b/src/blackgui/views/userview.cpp @@ -0,0 +1,38 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "userview.h" +#include + +using namespace BlackMisc; +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Views + { + 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); + } + } +} diff --git a/src/blackgui/views/userview.h b/src/blackgui/views/userview.h new file mode 100644 index 000000000..dc0702051 --- /dev/null +++ b/src/blackgui/views/userview.h @@ -0,0 +1,36 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_USERVIEW_H +#define BLACKGUI_USERVIEW_H + +#include "viewbase.h" +#include "../models/userlistmodel.h" + +namespace BlackGui +{ + namespace Views + { + //! User view + class CUserView : public CViewBase + { + + public: + + //! Constructor + explicit CUserView(QWidget *parent = nullptr); + + //! Set station mode + void setUserMode(Models::CUserListModel::UserMode userMode); + }; + } +} +#endif // guard diff --git a/src/blackgui/views/viewbase.h b/src/blackgui/views/viewbase.h new file mode 100644 index 000000000..62202739b --- /dev/null +++ b/src/blackgui/views/viewbase.h @@ -0,0 +1,94 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#ifndef BLACKGUI_VIEWBASE_H +#define BLACKGUI_VIEWBASE_H + +//! \file + +#include + +namespace BlackGui +{ + namespace Views + { + //! List model + template class CViewBase : public QTableView + { + + protected: + + //! Constructor + CViewBase(QWidget *parent, ModelClass *model = nullptr) : QTableView(parent), m_model(model) + { + this->setSortingEnabled(true); + this->horizontalHeader()->setStretchLastSection(true); + } + + //! Destructor + virtual ~CViewBase() {} + + ModelClass *m_model; //!< corresponding model + + public: + + //! Model + ModelClass *derivedModel() { return this->m_model; } + + //! Model + const ModelClass *derivedModel() const { return this->m_model; } + + //! Clear + void clear() { Q_ASSERT(this->m_model); this->m_model->clear(); } + + //! Update + template int update(const ContainerType &container, bool resize = true) + { + Q_ASSERT(this->m_model); + int c = this->m_model->update(container); + if (!resize) return c; + this->resizeColumnsToContents(); + this->resizeRowsToContents(); + return c; + } + + //! Insert + template void insert(const ObjectType &value, bool resize = true) + { + Q_ASSERT(this->m_model); + this->m_model->insert(value); + if (!resize) return; + this->resizeColumnsToContents(); + this->resizeRowsToContents(); + } + + //! Value object at + template const ObjectType &at(const QModelIndex &index) const + { + Q_ASSERT(this->m_model); + return this->m_model->at(index); + } + + //! Row count + int rowCount() const + { + Q_ASSERT(this->m_model); + return this->m_model->rowCount(); + } + + //! Any data? + bool isEmpty() const + { + Q_ASSERT(this->m_model); + return this->m_model->rowCount() < 1; + } + }; + } +} +#endif // guard