File tree Expand file tree Collapse file tree 6 files changed +34
-15
lines changed
Expand file tree Collapse file tree 6 files changed +34
-15
lines changed Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ MBSETTINGS mbCoreDialogDataViewItem::cachedSettings() const
157157 MBSETTINGS m;
158158 const Strings &s = Strings::instance ();
159159 const mbCoreDataViewItem::Strings &sItem = mbCoreDataViewItem::Strings::instance ();
160- const QString &prefix = Strings () .settings_prefix ;
160+ const QString &prefix = s .settings_prefix ;
161161
162162 mb::Address adr;
163163 adr.type = mb::toModbusMemoryType (m_ui.cmbAdrType ->currentText ());
Original file line number Diff line number Diff line change 2626#include < project/core_project.h>
2727
2828mbCoreDialogProject::Strings::Strings () :
29- title(QStringLiteral(" Project" ))
29+ title(QStringLiteral(" Project" )),
30+ settings_prefix(QStringLiteral(" Ui.Dialogs.Project." ))
3031{
3132}
3233
@@ -52,6 +53,29 @@ mbCoreDialogProject::~mbCoreDialogProject()
5253 delete ui;
5354}
5455
56+ MBSETTINGS mbCoreDialogProject::cachedSettings () const
57+ {
58+ MBSETTINGS m;
59+ const mbCoreProject::Strings &s = mbCoreProject::Strings::instance ();
60+ const QString &prefix = Strings::instance ().settings_prefix ;
61+ m[prefix+s.name ] = ui->lnName ->text ();
62+ m[prefix+s.author ] = ui->lnAuthor ->text ();
63+ m[prefix+s.comment ] = ui->txtComment ->toPlainText ();
64+ return m;
65+ }
66+
67+ void mbCoreDialogProject::setCachedSettings (const MBSETTINGS &m)
68+ {
69+ const mbCoreProject::Strings &s = mbCoreProject::Strings::instance ();
70+ const QString &prefix = Strings::instance ().settings_prefix ;
71+ MBSETTINGS::const_iterator it;
72+ MBSETTINGS::const_iterator end = m.end ();
73+
74+ it = m.find (prefix+s.name ); if (it != end) ui->lnName ->setText (it.value ().toString ());
75+ it = m.find (prefix+s.author ); if (it != end) ui->lnAuthor ->setText (it.value ().toString ());
76+ it = m.find (prefix+s.comment ); if (it != end) ui->txtComment ->setPlainText (it.value ().toString ());
77+ }
78+
5579MBSETTINGS mbCoreDialogProject::getSettings (const MBSETTINGS &settings, const QString &title)
5680{
5781 MBSETTINGS r;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ class MB_EXPORT mbCoreDialogProject : public mbCoreDialogSettings
3737 struct MB_EXPORT Strings
3838 {
3939 const QString title;
40+ const QString settings_prefix;
4041 Strings ();
4142 static const Strings &instance ();
4243 };
@@ -45,6 +46,10 @@ class MB_EXPORT mbCoreDialogProject : public mbCoreDialogSettings
4546 mbCoreDialogProject (QWidget *parent = nullptr );
4647 ~mbCoreDialogProject ();
4748
49+ public:
50+ MBSETTINGS cachedSettings () const override ;
51+ void setCachedSettings (const MBSETTINGS &settings) override ;
52+
4853public:
4954 MBSETTINGS getSettings (const MBSETTINGS &settings, const QString &title = QString()) override ;
5055
Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ MBSETTINGS mbCoreDialogs::cachedSettings() const
145145 mb::unite (r, m_device->cachedSettings ());
146146 mb::unite (r, m_dataView->cachedSettings ());
147147 mb::unite (r, m_dataViewItem->cachedSettings ());
148+ mb::unite (r, m_project->cachedSettings ());
148149
149150 r[s.settings_lastDir ] = m_lastDir;
150151 return r;
@@ -161,6 +162,7 @@ void mbCoreDialogs::setCachedSettings(const MBSETTINGS &settings)
161162 m_device->setCachedSettings (settings);
162163 m_dataView->setCachedSettings (settings);
163164 m_dataViewItem->setCachedSettings (settings);
165+ m_project->setCachedSettings (settings);
164166
165167 it = settings.find (s.settings_lastDir );
166168 if (it != end)
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class MB_EXPORT mbCoreDialogSettings : public QDialog
3434
3535public:
3636 virtual MBSETTINGS cachedSettings () const { return MBSETTINGS (); }
37- virtual void setCachedSettings (const MBSETTINGS &settings ) {}
37+ virtual void setCachedSettings (const MBSETTINGS &) {}
3838
3939public:
4040 virtual MBSETTINGS getSettings (const MBSETTINGS &settings = MBSETTINGS(), const QString &title = QString()) = 0;
Original file line number Diff line number Diff line change 2929#include < server.h>
3030#include < project/server_port.h>
3131
32- mbServerDialogPort::Strings::Strings () :
33- title(QStringLiteral(" Port" ))
34- {
35- }
36-
37- const mbServerDialogPort::Strings &mbServerDialogPort::Strings::instance ()
38- {
39- static const Strings s;
40- return s;
41- }
42-
43-
4432mbServerDialogPort::mbServerDialogPort (QWidget *parent) :
4533 mbCoreDialogPort(parent),
4634 ui(new Ui::mbServerDialogPort)
You can’t perform that action at this time.
0 commit comments