From e981dd6081aed1ea2ef2c8baf7f4cce893869cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Mon, 20 May 2019 12:39:42 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@533 a8b55f48-bf90-11e4-a774-851b48703e85 --- qad/utils/propertystorage.cpp | 17 +++++++++++++++++ qad/utils/propertystorage.h | 9 ++++++++- qad/widgets/session_manager.cpp | 2 +- qad/widgets/session_manager.h | 9 +++++---- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/qad/utils/propertystorage.cpp b/qad/utils/propertystorage.cpp index 94de614..794a32c 100644 --- a/qad/utils/propertystorage.cpp +++ b/qad/utils/propertystorage.cpp @@ -146,3 +146,20 @@ PropertyStorage::Property PropertyStorage::parsePropertyLine(QString l) { } return ret; } + + +PropertyStorage::Property & PropertyStorage::operator[](const QString & name) { + for (int i = 0; i < props.size(); ++i) + if (props[i].name == name) + return props[i]; + addProperty(name, ""); + return props.back(); +} + + +const PropertyStorage::Property PropertyStorage::operator[](const QString & name) const { + for (int i = 0; i < props.size(); ++i) + if (props[i].name == name) + return props[i]; + return Property(); +} diff --git a/qad/utils/propertystorage.h b/qad/utils/propertystorage.h index 1f5e174..f8e4490 100644 --- a/qad/utils/propertystorage.h +++ b/qad/utils/propertystorage.h @@ -17,6 +17,11 @@ public: struct Property { Property(const QString & n = QString(), const QString & c = QString(), const QVariant & v = QVariant(), int f = 0): name(n), comment(c), value(v), flags(f) {} + bool toBool() const {return value.toBool();} + int toInt() const {return value.toInt();} + float toFloat() const {return value.toFloat();} + double toDouble() const {return value.toDouble();} + QString toString() const {return value.toString();} QString name; QString comment; QVariant value; @@ -77,7 +82,9 @@ public: PropertyStorage & operator <<(const PropertyStorage & p) {props << p.props; return *this;} Property & operator[](int i) {return props[i];} const Property & operator[](int i) const {return props[i];} - + Property & operator[](const QString & name); + const Property operator[](const QString & name) const; + static Property parsePropertyLine(QString l); protected: diff --git a/qad/widgets/session_manager.cpp b/qad/widgets/session_manager.cpp index 33d16cf..a602cf5 100644 --- a/qad/widgets/session_manager.cpp +++ b/qad/widgets/session_manager.cpp @@ -96,8 +96,8 @@ void SessionManager::save() { sr.setValue(o->objectName(), value, false); } //qDebug() << mcl.size(); - sr.writeAll(); emit saving(sr); + sr.writeAll(); } diff --git a/qad/widgets/session_manager.h b/qad/widgets/session_manager.h index 40c8d91..3a8a5aa 100644 --- a/qad/widgets/session_manager.h +++ b/qad/widgets/session_manager.h @@ -66,10 +66,6 @@ public: void addEntry(const QString & name, float * e) {floats.push_back(QPair(name, e));} void addMainWidget(const QString & name, QWidget * e) {widgets.push_back(QPair(name, e));} - void save(); - void load(bool onlyMainwindow = false); - void clear(bool with_filename = true); - private: QMap metaFunctions(const QSet & objects, QByteArray fname); @@ -94,6 +90,11 @@ private: QVector > floats; QString file_; +public slots: + void save(); + void load(bool onlyMainwindow = false); + void clear(bool with_filename = true); + signals: void loading(QPIConfig & ); void saving(QPIConfig & );