From: APTX Date: Fri, 14 Dec 2012 14:36:27 +0000 (+0100) Subject: Return default QSettings to allow clients store additional settings X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=50da2d3d45fddc4f87c247bd342ed4576bc47786;p=localmylist.git Return default QSettings to allow clients store additional settings --- diff --git a/localmylist/mylist.cpp b/localmylist/mylist.cpp index b123d27..7612d65 100644 --- a/localmylist/mylist.cpp +++ b/localmylist/mylist.cpp @@ -25,6 +25,7 @@ MyList::MyList() m_renameHandler = 0; m_directoryWatcher = 0; workThread = 0; + m_defaultLocalQSettings = new QSettings(QSettings::IniFormat, QSettings::UserScope, organizationName, libraryName, this); db = new Database("main"); connect(db, SIGNAL(connected()), this, SLOT(setupHostInfo())); @@ -60,6 +61,11 @@ int MyList::runningTaskCount() return tasks.count(); } +QSettings *MyList::defaultLocalQSettings() const +{ + return m_defaultLocalQSettings; +} + void MyList::setHostName(QString name) { hostInfo.name = name; @@ -157,7 +163,7 @@ void MyList::setupHostInfo() { qWarning("Unknown host!"); } -// qDebug() << "host id" << hostId(); + // qDebug() << "host id" << hostId(); } void MyList::loadLocalSettings(QSettings &s) @@ -178,13 +184,12 @@ void MyList::loadLocalSettings(QSettings &s) void MyList::loadLocalSettings() { - QSettings s(QSettings::IniFormat, QSettings::UserScope, organizationName, libraryName); - loadLocalSettings(s); + loadLocalSettings(*defaultLocalQSettings()); } void MyList::saveLocalSettings() { - QSettings s(QSettings::IniFormat, QSettings::UserScope, organizationName, libraryName); + QSettings &s = *defaultLocalQSettings(); s.beginGroup("host"); s.setValue("hostName", hostInfo.name); s.endGroup(); @@ -278,6 +283,7 @@ void MyList::taskFinished() emit allTasksFinished(); } + MyList *MyList::instance() { if (!m_instance) diff --git a/localmylist/mylist.h b/localmylist/mylist.h index b36054c..0179adc 100644 --- a/localmylist/mylist.h +++ b/localmylist/mylist.h @@ -46,6 +46,8 @@ public: int runningTaskCount(); + QSettings *defaultLocalQSettings() const; + public slots: void markWatched(int fid, QDateTime when = QDateTime::currentDateTime()); @@ -87,6 +89,8 @@ private: QSet tasks; + QSettings *m_defaultLocalQSettings; + public: static MyList *instance(); static void destroy(); @@ -96,6 +100,7 @@ public: static const char *organizationName; static const char *libraryName; + private: static void init(); static MyList *m_instance;