From 4ceb7367f9e775e94698b9de1d98e0ce82e003b2 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 22 Jan 2014 03:06:40 +0100 Subject: [PATCH] GUI, added table view for user lists: * All users * Voice room COM1/2 users Remark: Not yet updated, just preparation of views --- samples/blackgui/mainwindow.cpp | 21 ++++-- samples/blackgui/mainwindow.h | 37 ++++++----- samples/blackgui/mainwindow.ui | 98 +++++++++++++++++++++++++++- samples/blackgui/mainwindow_init.cpp | 45 ++++++++++++- 4 files changed, 173 insertions(+), 28 deletions(-) diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index e9ed5cfa0..cfa7462dd 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -22,14 +22,19 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) : QMainWindow(parent, windowMode == GuiModes::WindowFrameless ? (Qt::Window | Qt::FramelessWindowHint) : Qt::Tool), ui(new Ui::MainWindow), m_infoWindow(nullptr), - m_init(false), m_windowMode(windowMode), m_coreMode(GuiModes::CoreExternal), - m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextVoiceAvailable(false), - m_dBusConnection("dummy"), m_coreRuntime(nullptr), - m_atcListOnline(nullptr), m_atcListBooked(nullptr), - m_trafficServerList(nullptr), m_aircraftsInRange(nullptr), + m_init(false), m_windowMode(windowMode), + // core + m_coreMode(GuiModes::CoreExternal), m_coreAvailable(false), + // misc + m_contextNetworkAvailable(false), m_contextVoiceAvailable(false), m_dBusConnection("dummy"), m_coreRuntime(nullptr), + // table view models + m_atcListOnline(nullptr), m_atcListBooked(nullptr), m_trafficServerList(nullptr), m_aircraftsInRange(nullptr), + m_allUsers(nullptr), m_usersVoiceCom1(nullptr), m_usersVoiceCom2(nullptr), + // contexts m_contextApplication(nullptr), m_contextNetwork(nullptr), m_contextVoice(nullptr), m_contextSettings(nullptr), - m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), - m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr), + // timers + m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr), + // context menus m_contextMenuAudio(nullptr) { if (windowMode == GuiModes::WindowFrameless) @@ -150,6 +155,8 @@ void MainWindow::setMainPage(bool start) this->ui->sw_MainMiddle->setCurrentIndex(MainPageAircrafts); else if (sender == this->ui->pb_MainCockpit) this->ui->sw_MainMiddle->setCurrentIndex(MainPageCockpit); + else if (sender == this->ui->pb_MainUsers) + this->ui->sw_MainMiddle->setCurrentIndex(MainPageUsers); else if (sender == this->ui->pb_MainTextMessages) this->ui->sw_MainMiddle->setCurrentIndex(MainPageTextMessages); else if (sender == this->ui->pb_MainFlightplan) diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h index 7adb28acf..42bc24d43 100644 --- a/samples/blackgui/mainwindow.h +++ b/samples/blackgui/mainwindow.h @@ -20,6 +20,7 @@ #include "blackgui/atcstationlistmodel.h" #include "blackgui/serverlistmodel.h" #include "blackgui/aircraftlistmodel.h" +#include "blackgui/userlistmodel.h" #include "blackmisc/statusmessage.h" #include "blackmisc/nwtextmessage.h" #include @@ -84,10 +85,11 @@ protected: MainPageStatus = 0, MainPageAtc = 1, MainPageAircrafts = 2, - MainPageCockpit = 3, - MainPageTextMessages = 4, - MainPageFlightplan = 5, - MainPageSettings = 6 + MainPageUsers = 3, + MainPageCockpit = 4, + MainPageTextMessages = 5, + MainPageFlightplan = 6, + MainPageSettings = 7 }; private: @@ -101,10 +103,16 @@ private: bool m_contextVoiceAvailable; QDBusConnection m_dBusConnection; QScopedPointer m_coreRuntime; /*!< runtime, if working with local core */ + // the table view models + // normal pointers, asl these will be deleted by parent BlackGui::CAtcListModel *m_atcListOnline; BlackGui::CAtcListModel *m_atcListBooked; BlackGui::CServerListModel *m_trafficServerList; BlackGui::CAircraftListModel *m_aircraftsInRange; + BlackGui::CUserListModel *m_allUsers; + BlackGui::CUserListModel *m_usersVoiceCom1; + BlackGui::CUserListModel *m_usersVoiceCom2; + // contexts BlackCore::IContextApplication *m_contextApplication; /*!< overall application state */ BlackCore::IContextNetwork *m_contextNetwork; BlackCore::IContextVoice *m_contextVoice; @@ -177,21 +185,19 @@ private: bool isCockpitUpdatePending() const; /*! - * \brief Round the com frequency display - * \param com1 - * \param com2 + * \brief Round the COM frequency display */ void roundComFrequencyDisplays(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2); /*! * \brief Add new text message tab - * \param tabName + * \param tabName name of the new tab, usually the channel name * \return */ QWidget *addNewTextMessageTab(const QString &tabName); /*! - * \brief Find text message tab by name + * \brief Find text message tab by its name * \param name * \return */ @@ -213,7 +219,6 @@ private: /*! * \brief Audio device lists - * \return */ void setAudioDeviceLists(); @@ -224,8 +229,8 @@ private: /*! * \brief Position of own plane for testing - * \param wgsLatitude - * \param wgsLongitude + * \param wgsLatitude WGS latitude + * \param wgsLongitude WGS longitude * \param altitude */ void setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const BlackMisc::Aviation::CAltitude &altitude); @@ -236,21 +241,21 @@ private: void displayOverlayInfo(const QString &message = ""); /*! - * \brief Overlay info by status message + * \brief Overlay info displaying status message * \param message */ void displayOverlayInfo(const BlackMisc::CStatusMessage &message); /*! * \brief Is given main page selected? - * \param mainPage + * \param mainPage index to be checked * \return */ bool isMainPageSelected(MainPageIndex mainPage) const; /*! - * \brief For this text message's receiver, is the current tab selected - * \param textMessage + * \brief For this text message's receipient, is the current tab selected? + * \param textMessage to be checked * \return */ bool isCorrespondingTextMessageTabSelected(BlackMisc::Network::CTextMessage textMessage) const; diff --git a/samples/blackgui/mainwindow.ui b/samples/blackgui/mainwindow.ui index 4d35fbe31..b46087b44 100644 --- a/samples/blackgui/mainwindow.ui +++ b/samples/blackgui/mainwindow.ui @@ -388,7 +388,7 @@ QSizeGrip { QFrame::NoFrame - 3 + 0 @@ -821,6 +821,19 @@ QSizeGrip { + + + + 0 + + + 0 + + + + + + @@ -2320,7 +2333,7 @@ QSizeGrip { - + Users @@ -2457,6 +2470,87 @@ QSizeGrip { + + cb_StatusWithDBus + le_StatusNetworkContext + le_StatusVoiceContext + te_StatusMessages + le_CommandLineInput + tw_AtcStations + tv_AtcStationsOnline + te_AtcStationsOnlineInfo + le_AtcStationsOnlineMetar + pb_AtcStationsLoadMetar + pb_AtcStationsAtisReload + tv_AtcStationsBooked + pb_ReloadAtcStationsBooked + tv_AircraftsInRange + pb_CockpitToggleCom1 + ds_CockpitCom1Active + ds_CockpitCom1Standby + di_CockpitCom1Volume + pb_CockpitToggleCom2 + ds_CockpitCom2Active + ds_CockpitCom2Standby + di_CockpitCom2Volume + pb_CockpitSelcalTest + cb_CockpitSelcal1 + cb_CockpitSelcal2 + ds_CockpitTransponder + cb_CockpitTransponderMode + le_CockpitVoiceRoomCom1 + cb_CockpitVoiceRoom1Override + le_CockpitVoiceRoomCom2 + cb_CockpitVoiceRoom2Override + tv_CockpitVoiceRoom1 + tv_CockpitVoiceRoom2 + tw_TextMessages + te_TextMessagesAll + te_TextMessagesUnicom + te_TextMessagesCOM1 + te_TextMessagesCOM2 + tb_Settings + tv_SettingsTnServers + le_SettingsTnCsName + le_SettingsTnCsDescription + le_SettingsTnCsAddress + le_SettingsTnCsPort + le_SettingsTnCsRealName + le_SettingsTnCsNetworkId + le_SettingsTnCsPassword + pb_SettingsTnSaveServer + pb_SettingsTnRemoveServer + pb_SettingsTnCurrentServer + le_SettingsAircraftCallsign + le_SettingsIcaoTypeDesignator + le_SettingsIcaoAirline + le_SettingsIcaoType + lbl_SettingsStealthMode + lbl_SettingsObserver + cb_VoiceInputDevice + cb_VoiceOutputDevice + pb_VoiceStartMicTest + pb_VoiceStartSquelchTest + hs_SettingsGuiOpacity + hs_SettingsGuiAircraftRefreshTime + hs_SettingsGuiAtcRefreshTime + pb_MainConnect + pb_MainStatus + pb_MainWeather + pb_MainFlightplan + pb_MainAtc + pb_MainAircrafts + pb_MainUsers + pb_CockpitIdent + pb_MainCockpit + pb_MainTextMessages + pb_Mappings + pb_MainSettings + pb_MainKeypadOpacity100 + pb_MainKeypadOpacity050 + pb_SoundMute + pb_SoundMaxVolume + diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index c906fe1d8..819fd3f68 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -58,28 +58,65 @@ void MainWindow::init(GuiModes::CoreMode coreMode) if (this->m_aircraftsInRange != nullptr) this->m_aircraftsInRange->deleteLater(); this->m_aircraftsInRange = new CAircraftListModel(this); + if (this->m_allUsers != nullptr) this->m_allUsers->deleteLater(); + this->m_allUsers = new CUserListModel(this); + + if (this->m_usersVoiceCom1 != nullptr) this->m_usersVoiceCom1->deleteLater(); + this->m_usersVoiceCom1 = new CUserListModel(this); + + if (this->m_usersVoiceCom2 != nullptr) this->m_usersVoiceCom2->deleteLater(); + this->m_usersVoiceCom2 = new CUserListModel(this); + // set sort order and models // enable first, otherwise order in the model will be reset + this->ui->tv_SettingsTnServers->setModel(this->m_trafficServerList); + + this->ui->tv_AtcStationsOnline->setSortingEnabled(true); this->ui->tv_AtcStationsOnline->setModel(this->m_atcListOnline); + this->m_atcListBooked->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAtcStation::IndexDistance); if (this->m_atcListOnline->hasValidSortColumn()) this->ui->tv_AtcStationsOnline->horizontalHeader()->setSortIndicator(this->m_atcListOnline->getSortColumn(), this->m_atcListOnline->getSortOrder()); - this->m_atcListBooked->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAtcStation::IndexBookedFrom); this->ui->tv_AtcStationsBooked->setSortingEnabled(true); this->ui->tv_AtcStationsBooked->setModel(this->m_atcListBooked); + this->m_atcListBooked->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAtcStation::IndexBookedFrom); if (this->m_atcListBooked->hasValidSortColumn()) this->ui->tv_AtcStationsBooked->horizontalHeader()->setSortIndicator(this->m_atcListBooked->getSortColumn(), this->m_atcListBooked->getSortOrder()); this->ui->tv_AircraftsInRange->setSortingEnabled(true); this->ui->tv_AircraftsInRange->setModel(this->m_aircraftsInRange); + this->m_atcListBooked->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAircraft::IndexDistance); if (this->m_aircraftsInRange->hasValidSortColumn()) this->ui->tv_AircraftsInRange->horizontalHeader()->setSortIndicator(this->m_aircraftsInRange->getSortColumn(), this->m_aircraftsInRange->getSortOrder()); - - this->ui->tv_SettingsTnServers->setModel(this->m_trafficServerList); this->ui->tv_AircraftsInRange->resizeColumnsToContents(); this->ui->tv_AircraftsInRange->resizeRowsToContents(); + this->ui->tv_AllUsers->setSortingEnabled(true); + this->ui->tv_AllUsers->setModel(this->m_allUsers); + this->m_allUsers->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName); + if (this->m_allUsers->hasValidSortColumn()) + this->ui->tv_AllUsers->horizontalHeader()->setSortIndicator(this->m_allUsers->getSortColumn(), this->m_allUsers->getSortOrder()); + this->ui->tv_AllUsers->resizeColumnsToContents(); + this->ui->tv_AllUsers->resizeRowsToContents(); + + this->ui->tv_CockpitVoiceRoom1->setSortingEnabled(true); + this->ui->tv_CockpitVoiceRoom1->setModel(this->m_usersVoiceCom1); + this->m_usersVoiceCom1->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName); + if (this->m_usersVoiceCom1->hasValidSortColumn()) + this->ui->tv_CockpitVoiceRoom1->horizontalHeader()->setSortIndicator(this->m_usersVoiceCom1->getSortColumn(), this->m_usersVoiceCom1->getSortOrder()); + this->ui->tv_CockpitVoiceRoom1->resizeColumnsToContents(); + this->ui->tv_CockpitVoiceRoom1->resizeRowsToContents(); + + this->ui->tv_CockpitVoiceRoom2->setSortingEnabled(true); + this->ui->tv_CockpitVoiceRoom2->setModel(this->m_usersVoiceCom2); + this->m_usersVoiceCom2->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName); + if (this->m_usersVoiceCom1->hasValidSortColumn()) + this->ui->tv_CockpitVoiceRoom2->horizontalHeader()->setSortIndicator(this->m_usersVoiceCom2->getSortColumn(), this->m_usersVoiceCom2->getSortOrder()); + this->ui->tv_CockpitVoiceRoom2->resizeColumnsToContents(); + this->ui->tv_CockpitVoiceRoom2->resizeRowsToContents(); + + // timer if (this->m_timerUpdateAircraftsInRange == nullptr) this->m_timerUpdateAircraftsInRange = new QTimer(this); if (this->m_timerUpdateAtcStationsOnline == nullptr) this->m_timerUpdateAtcStationsOnline = new QTimer(this); if (this->m_timerContextWatchdog == nullptr) this->m_timerContextWatchdog = new QTimer(this); @@ -181,6 +218,8 @@ void MainWindow::initGuiSignals() Q_ASSERT(connected); connected = this->connect(this->ui->pb_MainStatus, SIGNAL(released()), this, SLOT(setMainPage())); Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainUsers, SIGNAL(released()), this, SLOT(setMainPage())); + Q_ASSERT(connected); connected = this->connect(this->ui->pb_MainTextMessages, SIGNAL(released()), this, SLOT(setMainPage())); Q_ASSERT(connected); connected = this->connect(this->ui->pb_MainWeather, SIGNAL(released()), this, SLOT(setMainPage()));