Status messages as table view in the GUI, not only text.

Some minor GUI tweaks.
This commit is contained in:
Klaus Basan
2014-02-05 21:25:42 +00:00
committed by Mathew Sutcliffe
parent 576952b690
commit e88bfde3db
5 changed files with 92 additions and 19 deletions

View File

@@ -28,6 +28,7 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
// misc // misc
m_contextNetworkAvailable(false), m_contextVoiceAvailable(false), m_dBusConnection("dummy"), m_coreRuntime(nullptr), m_contextNetworkAvailable(false), m_contextVoiceAvailable(false), m_dBusConnection("dummy"), m_coreRuntime(nullptr),
// table view models // table view models
m_statusMessageList(nullptr),
m_atcListOnline(nullptr), m_atcListBooked(nullptr), m_trafficServerList(nullptr), m_aircraftsInRange(nullptr), m_atcListOnline(nullptr), m_atcListBooked(nullptr), m_trafficServerList(nullptr), m_aircraftsInRange(nullptr),
m_allUsers(nullptr), m_usersVoiceCom1(nullptr), m_usersVoiceCom2(nullptr), m_allUsers(nullptr), m_usersVoiceCom1(nullptr), m_usersVoiceCom2(nullptr),
// contexts // contexts
@@ -36,7 +37,7 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), m_timerUpdateUsers(nullptr), m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), m_timerUpdateUsers(nullptr),
m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr), m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr),
// context menus // context menus
m_contextMenuAudio(nullptr) m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr)
{ {
if (windowMode == GuiModes::WindowFrameless) if (windowMode == GuiModes::WindowFrameless)
{ {
@@ -242,9 +243,10 @@ bool MainWindow::isContextVoiceAvailableCheck()
void MainWindow::displayStatusMessage(const CStatusMessage &message) void MainWindow::displayStatusMessage(const CStatusMessage &message)
{ {
this->ui->sb_MainStatusBar->showMessage(message.getMessage(), 3000); this->ui->sb_MainStatusBar->showMessage(message.getMessage(), 3000);
this->ui->te_StatusMessages->insertPlainText(message.toQString(true).append("\n")); this->m_statusMessageList->insert(message);
this->ui->tv_StatusMessages->resizeColumnsToContents();
this->ui->tv_StatusMessages->resizeRowsToContents();
if (message.getSeverity() == CStatusMessage::SeverityError) this->displayOverlayInfo(message); if (message.getSeverity() == CStatusMessage::SeverityError) this->displayOverlayInfo(message);
} }
/* /*

View File

@@ -21,10 +21,11 @@
#include "blackgui/serverlistmodel.h" #include "blackgui/serverlistmodel.h"
#include "blackgui/aircraftlistmodel.h" #include "blackgui/aircraftlistmodel.h"
#include "blackgui/userlistmodel.h" #include "blackgui/userlistmodel.h"
#include "blackmisc/statusmessage.h" #include "blackgui/statusmessagelistmodel.h"
#include "blackmisc/nwtextmessage.h" #include "blackmisc/nwtextmessage.h"
#include <QMainWindow> #include <QMainWindow>
#include <QTextEdit> #include <QTextEdit>
#include <QTableView>
#include <QItemSelection> #include <QItemSelection>
#include <QTimer> #include <QTimer>
@@ -105,7 +106,8 @@ private:
QDBusConnection m_dBusConnection; QDBusConnection m_dBusConnection;
QScopedPointer<BlackCore::CCoreRuntime> m_coreRuntime; /*!< runtime, if working with local core */ QScopedPointer<BlackCore::CCoreRuntime> m_coreRuntime; /*!< runtime, if working with local core */
// the table view models // the table view models
// normal pointers, asl these will be deleted by parent // normal pointers, as these will be deleted by parent
BlackGui::CStatusMessageListModel *m_statusMessageList;
BlackGui::CAtcListModel *m_atcListOnline; BlackGui::CAtcListModel *m_atcListOnline;
BlackGui::CAtcListModel *m_atcListBooked; BlackGui::CAtcListModel *m_atcListBooked;
BlackGui::CServerListModel *m_trafficServerList; BlackGui::CServerListModel *m_trafficServerList;
@@ -113,6 +115,7 @@ private:
BlackGui::CUserListModel *m_allUsers; BlackGui::CUserListModel *m_allUsers;
BlackGui::CUserListModel *m_usersVoiceCom1; BlackGui::CUserListModel *m_usersVoiceCom1;
BlackGui::CUserListModel *m_usersVoiceCom2; BlackGui::CUserListModel *m_usersVoiceCom2;
// contexts // contexts
BlackCore::IContextApplication *m_contextApplication; /*!< overall application state */ BlackCore::IContextApplication *m_contextApplication; /*!< overall application state */
BlackCore::IContextNetwork *m_contextNetwork; BlackCore::IContextNetwork *m_contextNetwork;
@@ -121,7 +124,7 @@ private:
BlackMisc::Aviation::CAircraft m_ownAircraft; /*!< own aircraft's state */ BlackMisc::Aviation::CAircraft m_ownAircraft; /*!< own aircraft's state */
QTimer *m_timerUpdateAtcStationsOnline; /*!< timer for update of stations */ QTimer *m_timerUpdateAtcStationsOnline; /*!< timer for update of stations */
QTimer *m_timerUpdateAircraftsInRange; /*!< timer for update of aircrafts */ QTimer *m_timerUpdateAircraftsInRange; /*!< timer for update of aircrafts */
QTimer *m_timerUpdateUsers; /*!< timer dor update of users */ QTimer *m_timerUpdateUsers; /*!< timer for update of users */
QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */ QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */
QTimer *m_timerContextWatchdog; /*!< core available? */ QTimer *m_timerContextWatchdog; /*!< core available? */
QPixmap m_resPixmapConnectionConnected; QPixmap m_resPixmapConnectionConnected;
@@ -131,7 +134,8 @@ private:
QPixmap m_resPixmapVoiceLow; QPixmap m_resPixmapVoiceLow;
QPixmap m_resPixmapVoiceMuted; QPixmap m_resPixmapVoiceMuted;
QPoint m_dragPosition; /*!< position, if moving is handled with frameless window */ QPoint m_dragPosition; /*!< position, if moving is handled with frameless window */
QMenu *m_contextMenuAudio; /*! Audio context menu */ QMenu *m_contextMenuAudio; /*! audio context menu */
QMenu *m_contextMenuStatusMessageList; /*! context menu for status message list */
QString m_transponderResetValue; /*! Temp. storage of XPdr mode to reset, req. until timer allows singleShoot with Lambdas */ QString m_transponderResetValue; /*! Temp. storage of XPdr mode to reset, req. until timer allows singleShoot with Lambdas */
/*! /*!
@@ -475,6 +479,9 @@ private slots:
*/ */
void audioIconContextMenu(const QPoint &position); void audioIconContextMenu(const QPoint &position);
//! \brief Context menu for message list
void messageListContextMenu(const QPoint &position);
/*! /*!
* \brief Test SELCAL (code valid? play tone) * \brief Test SELCAL (code valid? play tone)
*/ */

View File

@@ -565,7 +565,17 @@ QSizeGrip {
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QTableView" name="tv_StatusMessages"/> <widget class="QTableView" name="tv_StatusMessages">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@@ -574,8 +584,8 @@ QSizeGrip {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>90</width> <width>326</width>
<height>55</height> <height>267</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@@ -598,7 +608,7 @@ QSizeGrip {
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QPlainTextEdit" name="te_StatusMessages"> <widget class="QPlainTextEdit" name="te_StatusPageConsole">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@@ -1980,9 +1990,15 @@ QSizeGrip {
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="le_SettingsAircraftCallsign"> <widget class="QLineEdit" name="le_SettingsAircraftCallsign">
<property name="inputMethodHints">
<set>Qt::ImhLatinOnly|Qt::ImhUppercaseOnly</set>
</property>
<property name="text"> <property name="text">
<string>BLACK</string> <string>BLACK</string>
</property> </property>
<property name="maxLength">
<number>20</number>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
@@ -1993,7 +2009,11 @@ QSizeGrip {
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="le_SettingsIcaoTypeDesignator"/> <widget class="QLineEdit" name="le_SettingsIcaoTypeDesignator">
<property name="inputMethodHints">
<set>Qt::ImhUppercaseOnly</set>
</property>
</widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="lbl_SettingsIcaoAirline"> <widget class="QLabel" name="lbl_SettingsIcaoAirline">
@@ -2061,7 +2081,7 @@ QSizeGrip {
</widget> </widget>
<widget class="QWidget" name="tb_SettingsAudio"> <widget class="QWidget" name="tb_SettingsAudio">
<attribute name="title"> <attribute name="title">
<string>Voice</string> <string>Audio</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_14"> <layout class="QVBoxLayout" name="verticalLayout_14">
<property name="leftMargin"> <property name="leftMargin">

View File

@@ -47,6 +47,9 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
} }
// init models, the delete allows to re-init // init models, the delete allows to re-init
if (this->m_statusMessageList != nullptr) this->m_statusMessageList->deleteLater();
this->m_statusMessageList = new CStatusMessageListModel(this);
if (this->m_atcListBooked != nullptr) this->m_atcListBooked->deleteLater(); if (this->m_atcListBooked != nullptr) this->m_atcListBooked->deleteLater();
this->m_atcListBooked = new CAtcListModel(this); this->m_atcListBooked = new CAtcListModel(this);
@@ -72,6 +75,11 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
// enable first, otherwise order in the model will be reset // enable first, otherwise order in the model will be reset
this->ui->tv_SettingsTnServers->setModel(this->m_trafficServerList); this->ui->tv_SettingsTnServers->setModel(this->m_trafficServerList);
this->ui->tv_StatusMessages->setSortingEnabled(true);
this->ui->tv_StatusMessages->setModel(this->m_statusMessageList);
this->m_statusMessageList->setSortColumnByPropertyIndex(BlackMisc::CStatusMessage::IndexTimestamp);
if (this->m_statusMessageList->hasValidSortColumn())
this->ui->tv_StatusMessages->horizontalHeader()->setSortIndicator(this->m_statusMessageList->getSortColumn(), this->m_statusMessageList->getSortOrder());
this->ui->tv_AtcStationsOnline->setSortingEnabled(true); this->ui->tv_AtcStationsOnline->setSortingEnabled(true);
this->ui->tv_AtcStationsOnline->setModel(this->m_atcListOnline); this->ui->tv_AtcStationsOnline->setModel(this->m_atcListOnline);

View File

@@ -54,21 +54,24 @@ void MainWindow::menuClicked()
void MainWindow::initContextMenus() void MainWindow::initContextMenus()
{ {
this->ui->lbl_VoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu); this->ui->lbl_VoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this->ui->lbl_VoiceStatus, SIGNAL(customContextMenuRequested(const QPoint &)), connect(this->ui->lbl_VoiceStatus, &QLabel::customContextMenuRequested, this, &MainWindow::audioIconContextMenu);
this, SLOT(audioIconContextMenu(const QPoint &))); this->ui->tv_StatusMessages->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this->ui->tv_StatusMessages, &QTableView::customContextMenuRequested, this, &MainWindow::messageListContextMenu);
} }
/* /*
* Reload settings * Audio context menu
*/ */
void MainWindow::audioIconContextMenu(const QPoint &position) void MainWindow::audioIconContextMenu(const QPoint &position)
{ {
// for most widgets // position for most widgets
QPoint globalPosition = this->ui->lbl_VoiceStatus->mapToGlobal(position); QPoint globalPosition = this->ui->lbl_VoiceStatus->mapToGlobal(position);
if (!this->m_contextMenuAudio) if (!this->m_contextMenuAudio)
{ {
this->m_contextMenuAudio = new QMenu(this); this->m_contextMenuAudio = new QMenu(this);
this->m_contextMenuAudio->addAction("Toogle mute");
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
if (QSysInfo::WindowsVersion && QSysInfo::WV_NT_based) if (QSysInfo::WindowsVersion && QSysInfo::WV_NT_based)
{ {
@@ -82,7 +85,40 @@ void MainWindow::audioIconContextMenu(const QPoint &position)
{ {
// http://forum.technical-assistance.co.uk/sndvol32exe-command-line-parameters-vt1348.html // http://forum.technical-assistance.co.uk/sndvol32exe-command-line-parameters-vt1348.html
const QList<QAction *> actions = this->m_contextMenuAudio->actions(); const QList<QAction *> actions = this->m_contextMenuAudio->actions();
QStringList parameterlist; if (selectedItem == actions.at(0)) this->ui->pb_SoundMute->click();
if (selectedItem == actions.at(0)) QProcess::startDetached("SndVol.exe", parameterlist); else if (actions.size() > 1 && selectedItem == actions.at(1))
{
QStringList parameterlist;
QProcess::startDetached("SndVol.exe", parameterlist);
}
}
}
/*
* Message list context menu
*/
void MainWindow::messageListContextMenu(const QPoint &position)
{
// position for most widgets
QPoint globalPosition = this->ui->tv_StatusMessages->mapToGlobal(position);
if (!this->m_contextMenuStatusMessageList)
{
this->m_contextMenuStatusMessageList = new QMenu(this);
this->m_contextMenuStatusMessageList->addAction("Clear");
}
QAction *selectedItem = this->m_contextMenuStatusMessageList->exec(globalPosition);
if (selectedItem)
{
// http://forum.technical-assistance.co.uk/sndvol32exe-command-line-parameters-vt1348.html
const QList<QAction *> actions = this->m_contextMenuStatusMessageList->actions();
if (selectedItem == actions.at(0))
{
this->m_statusMessageList->clear();
this->ui->tv_StatusMessages->resizeColumnsToContents();
this->ui->tv_StatusMessages->horizontalHeader()->setStretchLastSection(true);
}
} }
} }