diff options
Diffstat (limited to 'notebookmodel.cc')
-rw-r--r-- | notebookmodel.cc | 23 |
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"); |