mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
Misc. imorvements as discussed in RW/KB worksho
* preparation for a context menu to send text messages from ATC/aircraft view * preparation for context menu for fast pos. updates * reverse ICAO lookup at login screen * display fast updates / parts in GUI * moved max- aircraft into settings * made serverselection own component
This commit is contained in:
@@ -21,5 +21,6 @@ namespace BlackGui
|
||||
{
|
||||
this->standardInit(new CAircraftListModel(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Aircrafts view
|
||||
//! \deprecated use simulated aircraft instead
|
||||
class CAircraftView : public CViewBase<Models::CAircraftListModel, BlackMisc::Aviation::CAircraftList, BlackMisc::Aviation::CAircraft>
|
||||
{
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace BlackGui
|
||||
{
|
||||
menu.addAction(CIcons::appCockpit16(), "Tune in COM1", this, SLOT(ps_tuneInAtcCom1()));
|
||||
menu.addAction(CIcons::appCockpit16(), "Tune in COM2", this, SLOT(ps_tuneInAtcCom2()));
|
||||
menu.addAction(CIcons::appTextMessages16(), "Text message", this, SLOT(ps_requestTextMessage()));
|
||||
menu.addSeparator();
|
||||
}
|
||||
CViewBase::customMenu(menu);
|
||||
@@ -60,16 +61,23 @@ namespace BlackGui
|
||||
|
||||
void CAtcStationView::ps_tuneInAtcCom1()
|
||||
{
|
||||
CAtcStationList l = this->selectedObjects();
|
||||
if (l.isEmpty()) { return; }
|
||||
emit this->requestComFrequency(l.front().getFrequency(), CComSystem::Com1);
|
||||
CAtcStation s(this->selectedObject());
|
||||
if (s.getCallsign().isEmpty()) { return; }
|
||||
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com1);
|
||||
}
|
||||
|
||||
void CAtcStationView::ps_tuneInAtcCom2()
|
||||
{
|
||||
CAtcStationList l = this->selectedObjects();
|
||||
if (l.isEmpty()) { return; }
|
||||
emit this->requestComFrequency(l.front().getFrequency(), CComSystem::Com2);
|
||||
CAtcStation s(this->selectedObject());
|
||||
if (s.getCallsign().isEmpty()) { return; }
|
||||
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com2);
|
||||
}
|
||||
|
||||
void CAtcStationView::ps_requestTextMessage()
|
||||
{
|
||||
CAtcStation s(this->selectedObject());
|
||||
if (s.getCallsign().isEmpty()) { return; }
|
||||
emit this->requestTextMessage(s.getCallsign());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -40,6 +40,9 @@ namespace BlackGui
|
||||
//! Request COM frequency
|
||||
void requestComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit unit);
|
||||
|
||||
//! Request a text message to
|
||||
void requestTextMessage(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
public slots:
|
||||
//! \copydoc CAtcStationListModel::changedAtcStationConnectionStatus
|
||||
void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
|
||||
@@ -53,6 +56,7 @@ namespace BlackGui
|
||||
void ps_testRequest3kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(3000); }
|
||||
void ps_tuneInAtcCom1();
|
||||
void ps_tuneInAtcCom2();
|
||||
void ps_requestTextMessage();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
*/
|
||||
|
||||
#include "simulatedaircraftview.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
@@ -27,5 +29,44 @@ namespace BlackGui
|
||||
{
|
||||
this->m_model->setAircraftMode(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatedAircraftView::customMenu(QMenu &menu) const
|
||||
{
|
||||
if (BlackMisc::CProject::isDebugBuild())
|
||||
{
|
||||
// tbd
|
||||
}
|
||||
|
||||
if (this->hasSelection())
|
||||
{
|
||||
CSimulatedAircraft aircraft(selectedObject());
|
||||
Q_ASSERT(!aircraft.getCallsign().isEmpty());
|
||||
menu.addAction(CIcons::appTextMessages16(), "Text message", this, SLOT(ps_requestTextMessage()));
|
||||
menu.addAction(CIcons::appAircrafts16(), aircraft.isEnabled() ? "disable aircraft" : "enabled aircraft", this, SLOT(ps_enableAircraft()));
|
||||
menu.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "normal updates" : "fast position updates", this, SLOT(ps_fastPositionUpdates()));
|
||||
menu.addSeparator();
|
||||
}
|
||||
CViewBase::customMenu(menu);
|
||||
}
|
||||
|
||||
void CSimulatedAircraftView::ps_requestTextMessage()
|
||||
{
|
||||
CSimulatedAircraft aircraft(selectedObject());
|
||||
if (aircraft.getCallsign().isEmpty()) { return; }
|
||||
emit requestTextMessage(aircraft.getCallsign());
|
||||
}
|
||||
|
||||
void CSimulatedAircraftView::ps_enableAircraft()
|
||||
{
|
||||
CSimulatedAircraft aircraft(selectedObject());
|
||||
if (aircraft.getCallsign().isEmpty()) { return; }
|
||||
}
|
||||
|
||||
void CSimulatedAircraftView::ps_fastPositionUpdates()
|
||||
{
|
||||
CSimulatedAircraft aircraft(selectedObject());
|
||||
if (aircraft.getCallsign().isEmpty()) { return; }
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "../models/simulatedaircraftlistmodel.h"
|
||||
#include <QMenu>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -22,6 +23,7 @@ namespace BlackGui
|
||||
//! Aircrafts view
|
||||
class CSimulatedAircraftView : public CViewBase<Models::CSimulatedAircraftListModel, BlackMisc::Simulation::CSimulatedAircraftList, BlackMisc::Simulation::CSimulatedAircraft>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
@@ -29,7 +31,21 @@ namespace BlackGui
|
||||
|
||||
//! Mode
|
||||
void setAircraftMode(Models::CSimulatedAircraftListModel::AircraftMode mode);
|
||||
|
||||
signals:
|
||||
//! Request a text message
|
||||
void requestTextMessage(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
protected:
|
||||
//! \copydoc CViewBase::customMenu
|
||||
virtual void customMenu(QMenu &menu) const override;
|
||||
|
||||
private slots:
|
||||
void ps_requestTextMessage();
|
||||
void ps_enableAircraft();
|
||||
void ps_fastPositionUpdates();
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
|
||||
@@ -87,6 +87,8 @@ namespace BlackGui
|
||||
}
|
||||
if (!menu.isEmpty()) { menu.addSeparator(); }
|
||||
menu.addAction(BlackMisc::CIcons::resize16(), "Full resize", this, SLOT(fullResizeToContents()));
|
||||
menu.addAction(BlackMisc::CIcons::resizeVertical16(), "Resize rows to content", this, SLOT(rowsResizeModeToContent()));
|
||||
menu.addAction(BlackMisc::CIcons::resizeVertical16(), "Resize rows interactive", this, SLOT(rowsResizeModeToInteractive()));
|
||||
|
||||
// resize to content might decrease performance,
|
||||
// so I only allow changing to "content resizing" if size matches
|
||||
@@ -126,7 +128,15 @@ namespace BlackGui
|
||||
this->horizontalHeader()->setStretchLastSection(true);
|
||||
this->verticalHeader()->setDefaultSectionSize(fh); // for height
|
||||
this->verticalHeader()->setMinimumSectionSize(fh); // for height
|
||||
this->initRowsResizeModeToInteractive();
|
||||
|
||||
switch (this->m_rowResizeMode)
|
||||
{
|
||||
case Interactive: this->rowsResizeModeToInteractive(); break;
|
||||
case Content: this->rowsResizeModeToContent(); break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int CViewBaseNonTemplate::ps_updateContainer(const CVariant &variant, bool sort, bool resize)
|
||||
@@ -141,13 +151,14 @@ namespace BlackGui
|
||||
this->m_filterDialog->show();
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::initRowsResizeModeToInteractive()
|
||||
void CViewBaseNonTemplate::rowsResizeModeToInteractive()
|
||||
{
|
||||
const int height = this->verticalHeader()->minimumSectionSize();
|
||||
QHeaderView *verticalHeader = this->verticalHeader();
|
||||
Q_ASSERT(verticalHeader);
|
||||
verticalHeader->setSectionResizeMode(QHeaderView::Interactive);
|
||||
verticalHeader->setDefaultSectionSize(height);
|
||||
this->m_rowResizeMode = Interactive;
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::rowsResizeModeToContent()
|
||||
@@ -155,6 +166,7 @@ namespace BlackGui
|
||||
QHeaderView *verticalHeader = this->verticalHeader();
|
||||
Q_ASSERT(verticalHeader);
|
||||
verticalHeader->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
this->m_rowResizeMode = Content;
|
||||
}
|
||||
|
||||
bool CViewBaseNonTemplate::performResizing() const
|
||||
@@ -240,26 +252,30 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType> void CViewBase<ModelClass, ContainerType, ObjectType>::insert(const ObjectType &value, bool resize)
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::insert(const ObjectType &value, bool resize)
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
this->m_model->insert(value);
|
||||
if (resize) { this->performResizeToContents(); }
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType> const ObjectType &CViewBase<ModelClass, ContainerType, ObjectType>::at(const QModelIndex &index) const
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
const ObjectType &CViewBase<ModelClass, ContainerType, ObjectType>::at(const QModelIndex &index) const
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->at(index);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType> const ContainerType &CViewBase<ModelClass, ContainerType, ObjectType>::getContainer() const
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
const ContainerType &CViewBase<ModelClass, ContainerType, ObjectType>::getContainer() const
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->getContainer();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType> ContainerType CViewBase<ModelClass, ContainerType, ObjectType>::selectedObjects() const
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
ContainerType CViewBase<ModelClass, ContainerType, ObjectType>::selectedObjects() const
|
||||
{
|
||||
if (!this->hasSelection()) { return ContainerType(); }
|
||||
ContainerType c;
|
||||
@@ -271,6 +287,13 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
ObjectType CViewBase<ModelClass, ContainerType, ObjectType>::selectedObject() const
|
||||
{
|
||||
ContainerType c = this->selectedObjects();
|
||||
return c.frontOrDefault();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewBase<ModelClass, ContainerType, ObjectType>::rowCount() const
|
||||
{
|
||||
|
||||
@@ -44,6 +44,13 @@ namespace BlackGui
|
||||
ResizingOff //!< never
|
||||
};
|
||||
|
||||
//! How rows are resizes
|
||||
enum RowsResizeMode
|
||||
{
|
||||
Interactive,
|
||||
Content
|
||||
};
|
||||
|
||||
//! When (rows count) to use asynchronous updates
|
||||
static const int asyncRowsCountThreshold = 50;
|
||||
|
||||
@@ -74,9 +81,6 @@ namespace BlackGui
|
||||
//! Filter dialog
|
||||
void setFilterDialog(QDialog *filterDialog);
|
||||
|
||||
//! Resize mode to content
|
||||
void rowsResizeModeToContent();
|
||||
|
||||
//! Main application window widget if any
|
||||
QWidget *mainApplicationWindowWidget() const;
|
||||
|
||||
@@ -100,6 +104,12 @@ namespace BlackGui
|
||||
//! Full resizing to content, might be slow
|
||||
virtual void fullResizeToContents();
|
||||
|
||||
//! Init as interactive, as this allows manually resizing
|
||||
void rowsResizeModeToInteractive();
|
||||
|
||||
//! Resize mode to content
|
||||
void rowsResizeModeToContent();
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CViewBaseNonTemplate(QWidget *parent);
|
||||
@@ -111,9 +121,6 @@ namespace BlackGui
|
||||
//! Perform resizing / non slot method for template
|
||||
virtual void performResizeToContents() = 0;
|
||||
|
||||
//! Init as interactive, as this allows manually resizing
|
||||
void initRowsResizeModeToInteractive();
|
||||
|
||||
//! Helper method with template free signature
|
||||
//! \param variant contains the container
|
||||
//! \param sort
|
||||
@@ -130,6 +137,7 @@ namespace BlackGui
|
||||
void init();
|
||||
|
||||
ResizeMode m_resizeMode = ResizingAuto; //!< mode
|
||||
RowsResizeMode m_rowResizeMode = Interactive; //!< row resize mode
|
||||
int m_resizeCount = 0; //!< flag / counter, how many resize activities
|
||||
int m_skipResizeThreshold = 40; //!< when to skip resize (rows count)
|
||||
int m_resizeAutoNthTime = 1; //!< with ResizeAuto, resize every n-th time
|
||||
@@ -201,6 +209,9 @@ namespace BlackGui
|
||||
//! Selected objects
|
||||
ContainerType selectedObjects() const;
|
||||
|
||||
//! Selected object (or default)
|
||||
ObjectType selectedObject() const;
|
||||
|
||||
//! Row count
|
||||
int rowCount() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user