Skip to content

Commit

Permalink
read notes path from settings file
Browse files Browse the repository at this point in the history
  • Loading branch information
digikata committed Jun 14, 2013
1 parent c7453af commit 159017f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.user
tmp.db
18 changes: 13 additions & 5 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand All @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QStringList>
#include <QMainWindow>
#include <QListWidget>
#include <QSettings>

#include "searcher.h"

Expand All @@ -23,15 +24,17 @@ class MainWindow : public QMainWindow
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

QString getNotesPath();

public slots:
void elideNotes(const QStringList&);

private:
Ui::MainWindow *ui;
Searcher* search;
QStringList* notelist;

QString getNotesPath();
QSettings* settings;
QString notespath;

// title, path
typedef std::function<void (const QString&)> noteFunc;
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>Upnote</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down
2 changes: 0 additions & 2 deletions notes.txt

This file was deleted.

Empty file added notes/readme.txt
Empty file.

0 comments on commit 159017f

Please sign in to comment.