From 177aaef501dc867bff643070140db942cf4b96a1 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 6 Apr 2015 13:25:51 +0000 Subject: [PATCH] Fix another issue with station details not being saved Due to what appears to be a Qt bug, any in progress user edit to a table fields is not updated in the underlying data models until QDialog::accept() is called, this means that model validation before calling QDialog::accept() is tricky. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5164 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Configuration.cpp | 9 +++++++-- FrequencyList.cpp | 4 +--- FrequencyList.hpp | 2 +- StationList.cpp | 5 ++--- StationList.hpp | 10 +++++----- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index fb0ea3ea8..7a9318cc9 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -1490,6 +1490,13 @@ void Configuration::impl::accept () { return; // not accepting } + + QDialog::accept(); // do this before accessing custom + // models so that any changes in + // delegates in views get flushed to + // the underlying models before we + // access them + sync_transceiver (true); // force an update // @@ -1637,8 +1644,6 @@ void Configuration::impl::accept () } write_settings (); // make visible to all - - QDialog::accept(); } void Configuration::impl::reject () diff --git a/FrequencyList.cpp b/FrequencyList.cpp index 6a864194d..76cac1f15 100644 --- a/FrequencyList.cpp +++ b/FrequencyList.cpp @@ -58,7 +58,6 @@ FrequencyList::FrequencyList (Frequencies frequencies, QObject * parent) : QSortFilterProxyModel {parent} , m_ {frequencies, parent} { - // setDynamicSortFilter (true); setSourceModel (&*m_); setSortRole (SortRole); } @@ -73,9 +72,8 @@ FrequencyList& FrequencyList::operator = (Frequencies frequencies) return *this; } -auto FrequencyList::frequencies () -> Frequencies +auto FrequencyList::frequencies () const -> Frequencies { - submit (); return m_->frequencies (); } diff --git a/FrequencyList.hpp b/FrequencyList.hpp index 5ad288444..c22659231 100644 --- a/FrequencyList.hpp +++ b/FrequencyList.hpp @@ -41,7 +41,7 @@ public: // Load and store contents FrequencyList& operator = (Frequencies); - Frequencies frequencies (); + Frequencies frequencies () const; // Model API QModelIndex add (Frequency); diff --git a/StationList.cpp b/StationList.cpp index 7eca4b049..87689c2f6 100644 --- a/StationList.cpp +++ b/StationList.cpp @@ -119,7 +119,6 @@ StationList::StationList (Bands const * bands, Stations stations, QObject * pare : QSortFilterProxyModel {parent} , m_ {bands, stations, parent} { - // setDynamicSortFilter (true); setSourceModel (&*m_); setSortRole (SortRole); } @@ -134,9 +133,8 @@ StationList& StationList::operator = (Stations stations) return *this; } -auto StationList::stations () -> Stations +auto StationList::stations () const -> Stations { - submit (); return m_->stations (); } @@ -432,6 +430,7 @@ bool StationList::impl::setData (QModelIndex const& model_index, QVariant const& case 2: stations_[row].antenna_description_ = value.toString (); + qDebug () << "stations edited:" << stations_; Q_EMIT dataChanged (model_index, model_index, roles); changed = true; break; diff --git a/StationList.hpp b/StationList.hpp index f869953fe..75f641275 100644 --- a/StationList.hpp +++ b/StationList.hpp @@ -65,7 +65,7 @@ public: // Load and store contents. StationList& operator = (Stations); - Stations stations (); + Stations stations () const; // // Model API @@ -83,6 +83,10 @@ private: pimpl m_; }; +#if !defined (QT_NO_DEBUG_STREAM) +QDebug operator << (QDebug debug, StationList::Station const&); +#endif + // Station equivalence inline bool operator == (StationList::Station const& lhs, StationList::Station const& rhs) @@ -95,8 +99,4 @@ bool operator == (StationList::Station const& lhs, StationList::Station const& r Q_DECLARE_METATYPE (StationList::Station); Q_DECLARE_METATYPE (StationList::Stations); -#if !defined (QT_NO_DEBUG_STREAM) -QDebug operator << (QDebug debug, StationList::Station const&); -#endif - #endif