From 159017fa20683a17bd6c9daf0931f08f41fe5107 Mon Sep 17 00:00:00 2001 From: Alan C Date: Thu, 13 Jun 2013 22:59:55 -0700 Subject: [PATCH] read notes path from settings file --- .gitignore | 1 + mainwindow.cpp | 18 +++++++++++++----- mainwindow.h | 7 +++++-- mainwindow.ui | 2 +- notes.txt | 2 -- notes/readme.txt | 0 6 files changed, 20 insertions(+), 10 deletions(-) delete mode 100644 notes.txt create mode 100644 notes/readme.txt diff --git a/.gitignore b/.gitignore index 8a9d35c..bde6f8c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.user +tmp.db diff --git a/mainwindow.cpp b/mainwindow.cpp index 674ed5e..cab34ea 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -11,12 +11,13 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); search = new Searcher(this); notelist = 0; + settings = 0; connect( ui->mainline, SIGNAL(textChanged(QString)), search, SLOT(search_update(QString))); - connect( search, SIGNAL(search_status(QString)), - ui->statusBar, SLOT(showMessage(QString))); +// connect( search, SIGNAL(search_status(QString)), +// ui->statusBar, SLOT(showMessage(QString))); connect( search, SIGNAL(search_results(QStringList)), this, SLOT(elideNotes(QStringList))); @@ -41,19 +42,26 @@ MainWindow::MainWindow(QWidget *parent) : loadNote(item->text()); }); - } MainWindow::~MainWindow() { delete ui; + delete settings; } QString MainWindow::getNotesPath() { - //TODO: replace with value from QSettings - return QString("../corpus"); + if( settings == 0) + { + const QString orgval("Upnote"); + settings = new QSettings(QSettings::NativeFormat, + QSettings::UserScope, + orgval, QString(), this ); + } + notespath = settings->value("notes_path", QString("./notes") ).toString(); + return notespath; } void MainWindow::elideNotes(const QStringList & notefiles) diff --git a/mainwindow.h b/mainwindow.h index fb7b5cf..cc0349e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "searcher.h" @@ -23,6 +24,8 @@ class MainWindow : public QMainWindow explicit MainWindow(QWidget *parent = 0); ~MainWindow(); + QString getNotesPath(); + public slots: void elideNotes(const QStringList&); @@ -30,8 +33,8 @@ public slots: Ui::MainWindow *ui; Searcher* search; QStringList* notelist; - - QString getNotesPath(); + QSettings* settings; + QString notespath; // title, path typedef std::function noteFunc; diff --git a/mainwindow.ui b/mainwindow.ui index bb34795..8852ce3 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -11,7 +11,7 @@ - MainWindow + Upnote diff --git a/notes.txt b/notes.txt deleted file mode 100644 index 51733e5..0000000 --- a/notes.txt +++ /dev/null @@ -1,2 +0,0 @@ -Qfilesystemwatcher -Qsettings diff --git a/notes/readme.txt b/notes/readme.txt new file mode 100644 index 0000000..e69de29