aboutsummaryrefslogtreecommitdiff
path: root/notebookmodel.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-06-14 17:39:26 +0200
committerJavier <dev.git@javispedro.com>2015-06-14 17:39:26 +0200
commit247b7d55be4c9caea3cbc05f6f543280f207d895 (patch)
tree7fd437e728726117cb8914dd1658adffaabcf3ac /notebookmodel.cc
parente3c4aa5dffecc8f62958c44035b2e58de0228eb4 (diff)
downloadscribiu-247b7d55be4c9caea3cbc05f6f543280f207d895.tar.gz
scribiu-247b7d55be4c9caea3cbc05f6f543280f207d895.zip
allow changing data path, improve icon
Diffstat (limited to 'notebookmodel.cc')
-rw-r--r--notebookmodel.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/notebookmodel.cc b/notebookmodel.cc
index 2139ee7..6db93d1 100644
--- a/notebookmodel.cc
+++ b/notebookmodel.cc
@@ -1,4 +1,5 @@
#include <QtCore/QDebug>
+#include <QtCore/QSettings>
#include <QtGui/QApplication>
#include <QtGui/QIcon>
#include <QtGui/QDesktopServices>
@@ -12,7 +13,7 @@
NotebookModel::NotebookModel(QObject *parent) :
QAbstractItemModel(parent),
- _dataDir(QDesktopServices::storageLocation(QDesktopServices::DataLocation)),
+ _dataDir(userDataDirectory()),
_watcher()
{
if (!_dataDir.exists()) {
@@ -25,6 +26,26 @@ NotebookModel::NotebookModel(QObject *parent) :
refresh();
}
+QString NotebookModel::defaultDataDirectory()
+{
+ QString path = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+ if (path.isEmpty()) {
+ path = QDir::home().absoluteFilePath(".scribiu");
+ }
+ return path;
+}
+
+QString NotebookModel::userDataDirectory()
+{
+ QSettings settings;
+ QString path = settings.value("data/directory").toString();
+ if (path.isEmpty()) {
+ path = defaultDataDirectory();
+ settings.setValue("data/directory", QString());
+ }
+ return path;
+}
+
QString NotebookModel::penDirectory(const QString &name) const
{
return _dataDir.filePath(name + ".pen");