Move RtcomEventLogger DB path out into settings. Ideally, it'd be nice to have the...
authorJamie Thompson <jamie@.(none)>
Thu, 25 Aug 2011 00:45:47 +0000 (01:45 +0100)
committerJamie Thompson <jamie@.(none)>
Thu, 25 Aug 2011 00:45:47 +0000 (01:45 +0100)
Might revisit this later.

DBBackends/RtcomEventLogger.cpp
DBBackends/RtcomEventLogger.h
Settings.cpp
Settings.h

index aac4790..264b65a 100644 (file)
@@ -54,7 +54,7 @@ QDebug operator<<(QDebug, GList &);
 QDebug operator<<(QDebug, QList<RTComElAttachment*> &);
 
 RtcomEventLogger::RtcomEventLogger(const Settings &settings) :
-       m_Settings(settings), mk_DBPath("/.rtcom-eventlogger/el-v1.db")
+       m_Settings(settings)
 {
        RTComEl *el(rtcom_el_new());
        if(NULL != el)
@@ -77,7 +77,7 @@ RtcomEventLogger::RtcomEventLogger(const Settings &settings) :
 }
 
 RtcomEventLogger::RtcomEventLogger(const Settings &settings, const EventTypes::RtcomEvent &event) :
-       m_Settings(settings), mk_DBPath("/.rtcom-eventlogger/el-v1.db")
+       m_Settings(settings)
 {
 }
 
@@ -340,10 +340,10 @@ void RtcomEventLogger::ClearInsertedIDs()
 void RtcomEventLogger::Reindex()
 {
        // Set up the database connection...
-       QSqlDatabase db(QSqlDatabase::addDatabase( "QSQLITE" ));
+       QSqlDatabase db(QSqlDatabase::addDatabase("QSQLITE"));
 
-       db.setDatabaseName( QDir::homePath() + mk_DBPath );
-       if ( ! db.open() )
+       db.setDatabaseName(CurrentSettings().DBPath());
+       if(!db.open())
        {
                throw std::runtime_error("Cannot open database: Unable to establish database connection");
        }
index a2a5053..d82814d 100644 (file)
@@ -65,7 +65,6 @@ namespace DBBackends
                void Reindex();
 
                const Settings &m_Settings;
-               const QString mk_DBPath;
 
                QHash<EventTypes::eEventTypes, int> m_ServiceIDs;
 
index 0adaf34..cec9b44 100644 (file)
@@ -18,6 +18,8 @@
 
 #include "Settings.h"
 
+#include <QDir>
+
 Settings::Settings()
 {
        // Default to console
@@ -44,4 +46,7 @@ Settings::Settings()
 
        // It's OK to disable the radio by default
        setDisableCellular(true);
+
+       // Where it lives...
+       DBPath(QDir::homePath() + "/.rtcom-eventlogger/el-v1.db");
 }
index c8bad92..b308b6f 100644 (file)
@@ -70,6 +70,10 @@ private:
        // Is it OK to disable the cellular radio to prevent calls and messages?
        bool m_DisableCellular;
 
+       // RtcomEventLogger path
+       QString m_DBPath;
+       void DBPath(QString dbPath) { m_DBPath = dbPath; }
+
 public:
        Settings();
 
@@ -101,6 +105,8 @@ public:
 
        bool const DisableCellular() const { return m_DisableCellular; }
        bool const setDisableCellular(const bool disableCellular) { return m_DisableCellular = disableCellular; }
+
+       const QString &DBPath() const { return m_DBPath; }
 };
 
 #endif // SETTINGS_H