mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Fixes in model set form as described by RP
https://swift-project.slack.com/archives/G96QTUBEG/p1544353355002400 * fixed missing radio button groups * return values for some functions to detect "changes" * minor style fixes
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <QtGlobal>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Components;
|
||||
@@ -59,7 +60,7 @@ namespace BlackGui
|
||||
const bool hasPreferences = this->hasDistributorPreferences();
|
||||
ui->cb_SortByPreferences->setChecked(hasPreferences);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_SortByPreferences, !hasPreferences);
|
||||
ui->comp_SimulatorSelector->setValue(this->m_simulator);
|
||||
ui->comp_SimulatorSelector->setValue(m_simulator);
|
||||
this->setDistributorView(hasPreferences);
|
||||
this->initDistributorDisplay();
|
||||
}
|
||||
@@ -142,29 +143,23 @@ namespace BlackGui
|
||||
{
|
||||
ui->tvp_Distributors->setDistributorMode(hasPreferences ? CDistributorListModel::MinimalWithOrder : CDistributorListModel::Minimal);
|
||||
ui->tvp_Distributors->fullResizeToContents();
|
||||
if (hasPreferences)
|
||||
{
|
||||
ui->tvp_Distributors->setSorting(CDistributor::IndexOrder);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->tvp_Distributors->setSorting(CDistributor::IndexDbStringKey);
|
||||
}
|
||||
const CPropertyIndex i = hasPreferences ? CPropertyIndex(CDistributor::IndexOrder) : CPropertyIndex(CDistributor::IndexDbStringKey);
|
||||
ui->tvp_Distributors->sortByPropertyIndex(i);
|
||||
}
|
||||
|
||||
CDistributorList COwnModelSetForm::getDistributorsFromPreferences() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
const CDistributorListPreferences prefs(this->m_distributorPreferences.get());
|
||||
const CDistributorList distributors(prefs.getDistributors(this->m_simulator));
|
||||
Q_ASSERT_X(m_simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
const CDistributorListPreferences prefs(m_distributorPreferences.get());
|
||||
const CDistributorList distributors(prefs.getDistributors(m_simulator));
|
||||
return distributors;
|
||||
}
|
||||
|
||||
CDistributorList COwnModelSetForm::getAllDistributors() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
Q_ASSERT_X(m_simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services");
|
||||
return sGui->getWebDataServices()->getDistributors().matchesSimulator(this->m_simulator);
|
||||
return sGui->getWebDataServices()->getDistributors().matchesSimulator(m_simulator);
|
||||
}
|
||||
|
||||
CDistributorList COwnModelSetForm::getDistributorsBasedOnOptions() const
|
||||
@@ -199,8 +194,8 @@ namespace BlackGui
|
||||
|
||||
bool COwnModelSetForm::hasDistributorPreferences() const
|
||||
{
|
||||
const CDistributorListPreferences prefs(this->m_distributorPreferences.get());
|
||||
return !prefs.getDistributors(this->m_simulator).isEmpty();
|
||||
const CDistributorListPreferences prefs(m_distributorPreferences.get());
|
||||
return !prefs.getDistributors(m_simulator).isEmpty();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>350</height>
|
||||
<width>350</width>
|
||||
<height>376</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@@ -37,11 +37,21 @@
|
||||
<property name="title">
|
||||
<string>Selection</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_Selection">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Mode">
|
||||
<layout class="QGridLayout" name="gl_Selection" columnstretch="0,1,1,1">
|
||||
<item row="0" column="1" colspan="3" alignment="Qt::AlignLeft">
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Simulator">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
<string>Simulator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -54,24 +64,24 @@
|
||||
<string>full</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Mode</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Mode">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Simulator">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SelectSourceSet">
|
||||
<property name="text">
|
||||
<string>Simulator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QRadioButton" name="rb_Incremental">
|
||||
<property name="toolTip">
|
||||
<string>add to existing set</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>incremental</string>
|
||||
<string>Source set:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -86,6 +96,22 @@
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_SourceSet</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QRadioButton" name="rb_Incremental">
|
||||
<property name="toolTip">
|
||||
<string>add to existing set</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>incremental</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Mode</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
@@ -99,6 +125,9 @@
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_SourceSet</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
@@ -111,23 +140,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SelectSourceSet">
|
||||
<property name="text">
|
||||
<string>Source set:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="3">
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QRadioButton" name="rb_DbDataOnly">
|
||||
<property name="toolTip">
|
||||
@@ -136,6 +148,22 @@
|
||||
<property name="text">
|
||||
<string>DB data only</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_SourceSet</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QRadioButton" name="rb_DistributorsFromBelow">
|
||||
<property name="text">
|
||||
<string>all from below</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Distributors</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
@@ -150,20 +178,9 @@
|
||||
<property name="text">
|
||||
<string>selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QRadioButton" name="rb_DisplayPreferencesDistributors">
|
||||
<property name="text">
|
||||
<string>from preferences</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QRadioButton" name="rb_DistributorsFromBelow">
|
||||
<property name="text">
|
||||
<string>all from below</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Distributors</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
@@ -174,26 +191,9 @@
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QRadioButton" name="rb_DisplayAllDistributors">
|
||||
<property name="text">
|
||||
<string>all distributors</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QCheckBox" name="cb_SortByPreferences">
|
||||
<property name="toolTip">
|
||||
<string>If checked the distributors from the settings page will be used</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>sort by dist. preferences</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Distributors</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -205,6 +205,57 @@
|
||||
<string>Distributors</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Distributors">
|
||||
<item>
|
||||
<widget class="QWidget" name="wi_DistributionButtons" native="true">
|
||||
<layout class="QGridLayout" name="gl_DistributorButtons">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="rb_DisplayPreferencesDistributors">
|
||||
<property name="text">
|
||||
<string>from preferences</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Displayed</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="rb_DisplayAllDistributors">
|
||||
<property name="text">
|
||||
<string>all distributors</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Displayed</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="cb_SortByPreferences">
|
||||
<property name="toolTip">
|
||||
<string>If checked the distributors from the settings page will be used</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>sort by dist. preferences</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CDistributorView" name="tvp_Distributors">
|
||||
<property name="selectionBehavior">
|
||||
@@ -236,12 +287,27 @@
|
||||
<header>blackgui/views/distributorview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>rb_Full</tabstop>
|
||||
<tabstop>rb_Incremental</tabstop>
|
||||
<tabstop>cb_ConsolidateModelSet</tabstop>
|
||||
<tabstop>rb_DbDataOnly</tabstop>
|
||||
<tabstop>rb_DbIcaoCodesOnly</tabstop>
|
||||
<tabstop>rb_WithIcaoData</tabstop>
|
||||
<tabstop>rb_DistributorsSelected</tabstop>
|
||||
<tabstop>rb_DistributorsFromBelow</tabstop>
|
||||
<tabstop>rb_DistributorsAll</tabstop>
|
||||
<tabstop>rb_DisplayPreferencesDistributors</tabstop>
|
||||
<tabstop>rb_DisplayAllDistributors</tabstop>
|
||||
<tabstop>cb_SortByPreferences</tabstop>
|
||||
<tabstop>tvp_Distributors</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="bg_SourceSet"/>
|
||||
<buttongroup name="bg_Distributors"/>
|
||||
<buttongroup name="bg_Mode"/>
|
||||
<buttongroup name="bg_DisplayedDistributors"/>
|
||||
<buttongroup name="bg_Displayed"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
||||
@@ -97,15 +97,20 @@ namespace BlackGui
|
||||
this->sort(column, order);
|
||||
}
|
||||
|
||||
void CListModelBaseNonTemplate::setSortColumnByPropertyIndex(const CPropertyIndex &propertyIndex)
|
||||
bool CListModelBaseNonTemplate::setSortColumnByPropertyIndex(const CPropertyIndex &propertyIndex)
|
||||
{
|
||||
m_sortColumn = m_columns.propertyIndexToColumn(propertyIndex);
|
||||
const int column = m_columns.propertyIndexToColumn(propertyIndex);
|
||||
if (m_sortColumn == column) { return false; } // not changed
|
||||
m_sortColumn = column;
|
||||
return true; // changed
|
||||
}
|
||||
|
||||
void CListModelBaseNonTemplate::setSorting(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
|
||||
bool CListModelBaseNonTemplate::setSorting(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
|
||||
{
|
||||
this->setSortColumnByPropertyIndex(propertyIndex);
|
||||
const bool changedColumn = this->setSortColumnByPropertyIndex(propertyIndex);
|
||||
const bool changedOrder = (m_sortOrder == order);
|
||||
m_sortOrder = order;
|
||||
return changedColumn || changedOrder;
|
||||
}
|
||||
|
||||
bool CListModelBaseNonTemplate::hasValidSortColumn() const
|
||||
|
||||
@@ -85,10 +85,10 @@ namespace BlackGui
|
||||
|
||||
//! Set column for sorting
|
||||
//! \param propertyIndex index of column to be sorted
|
||||
virtual void setSortColumnByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex);
|
||||
virtual bool setSortColumnByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex);
|
||||
|
||||
//! Sorting
|
||||
virtual void setSorting(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
virtual bool setSorting(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
|
||||
//! Get sort column property index
|
||||
virtual int getSortColumn() const { return m_sortColumn; }
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace BlackGui
|
||||
QVariant CListModelDbObjects<ObjectType, ContainerType, KeyType, UseCompare>::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::BackgroundRole) { return CListModelBase<ObjectType, ContainerType, UseCompare>::data(index, role); }
|
||||
if (isHighlightedIndex(index)) { return QBrush(m_highlightColor); }
|
||||
if (isHighlightedIndex(index) ) { return QBrush(m_highlightColor); }
|
||||
return CListModelBase<ObjectType, ContainerType, UseCompare>::data(index, role);
|
||||
}
|
||||
|
||||
@@ -91,10 +91,10 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
template <typename ObjectType, typename ContainerType, typename KeyType, bool UseCompare>
|
||||
void COrderableListModelDbObjects<ObjectType, ContainerType, KeyType, UseCompare>::setSortColumnToOrder()
|
||||
bool COrderableListModelDbObjects<ObjectType, ContainerType, KeyType, UseCompare>::setSortColumnToOrder()
|
||||
{
|
||||
// force sorted by order, otherwise display looks confusing
|
||||
this->setSorting(IOrderable::IndexOrder);
|
||||
return this->setSorting(IOrderable::IndexOrder);
|
||||
}
|
||||
|
||||
template <typename ObjectType, typename ContainerType, typename KeyType, bool UseCompare>
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace BlackGui
|
||||
//! @}
|
||||
|
||||
//! Sort order to order property BlackMisc::IOrderable::IndexOrder
|
||||
void setSortColumnToOrder();
|
||||
bool setSortColumnToOrder();
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
|
||||
@@ -468,10 +468,10 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::setSorting(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
|
||||
bool CViewBase<ModelClass, ContainerType, ObjectType>::setSorting(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
m_model->setSorting(propertyIndex, order);
|
||||
return m_model->setSorting(propertyIndex, order);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace BlackGui
|
||||
virtual bool isOrderable() const = 0;
|
||||
|
||||
//! \copydoc BlackGui::Models::CListModelBaseNonTemplate::setSorting
|
||||
virtual void setSorting(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) = 0;
|
||||
virtual bool setSorting(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) = 0;
|
||||
|
||||
//! Sort by index
|
||||
virtual void sortByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) = 0;
|
||||
@@ -700,7 +700,7 @@ namespace BlackGui
|
||||
virtual bool isDropAllowed() const override;
|
||||
virtual void dropEvent(QDropEvent *event) override;
|
||||
virtual bool acceptDrop(const QMimeData *mimeData) const override;
|
||||
virtual void setSorting(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) override;
|
||||
virtual bool setSorting(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) override;
|
||||
virtual void sortByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) override;
|
||||
//! @}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackMisc
|
||||
QString IOrderable::getOrderAsString() const
|
||||
{
|
||||
if (this->hasValidOrder()) { return QString::number(this->getOrder()); }
|
||||
return "-";
|
||||
return QStringLiteral("-");
|
||||
}
|
||||
|
||||
bool IOrderable::hasValidOrder() const
|
||||
@@ -37,7 +37,7 @@ namespace BlackMisc
|
||||
bool IOrderable::canHandleIndex(const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isEmpty()) { return false; }
|
||||
int i = index.frontCasted<int>();
|
||||
const int i = index.frontCasted<int>();
|
||||
return (i >= static_cast<int>(IndexOrder)) && (i <= static_cast<int>(IndexOrderString));
|
||||
}
|
||||
|
||||
@@ -45,15 +45,12 @@ namespace BlackMisc
|
||||
{
|
||||
if (!index.isEmpty())
|
||||
{
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexOrder:
|
||||
return CVariant::fromValue(this->m_order);
|
||||
case IndexOrderString:
|
||||
return CVariant::fromValue(this->getOrderAsString());
|
||||
default:
|
||||
break;
|
||||
case IndexOrder: return CVariant::fromValue(this->m_order);
|
||||
case IndexOrderString: return CVariant::fromValue(this->getOrderAsString());
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
const QString m = QString("Cannot handle index %1").arg(index.toQString());
|
||||
@@ -65,12 +62,10 @@ namespace BlackMisc
|
||||
{
|
||||
if (!index.isEmpty())
|
||||
{
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexOrder:
|
||||
this->setOrder(variant.toInt());
|
||||
return;
|
||||
case IndexOrder: this->setOrder(variant.toInt()); return;
|
||||
case IndexOrderString:
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user