Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplified navigation.

Fixed bug where a note was duplicated in the history after and
edit-display cycle.
  • Loading branch information...
commit cbbb352ebbb1d03bf68c5a43b39348ff57a27eeb 1 parent d155465
@pcapriotti authored
Showing with 31 additions and 26 deletions.
  1. +18 −20 mainwindow.cpp
  2. +1 −2  mainwindow.h
  3. +9 −3 webkitpart.cpp
  4. +3 −1 webkitpart.h
View
38 mainwindow.cpp
@@ -56,8 +56,6 @@ MainWindow::MainWindow(const QString& base)
setCentralWidget(m_stack);
m_notebook = new Notebook(base);
- m_note = m_notebook->index();
- kDebug() << "note path" << m_note->path();
Editor* editor = EditorChooser::editor();
Document* doc = editor->createDocument(this);
@@ -81,6 +79,8 @@ MainWindow::MainWindow(const QString& base)
setupGUI();
removeUnwantedActions();
+ m_note = m_notebook->index();
+ m_browser->openNote(m_note);
displayMode();
}
@@ -129,14 +129,9 @@ void MainWindow::setupActions()
void MainWindow::index()
{
m_note = m_notebook->open("index");
+ m_browser->openNote(m_note);
if (m_mode == EditMode)
- {
editMode();
- }
- else
- {
- displayMode();
- }
}
void MainWindow::removeUnwantedActions()
@@ -172,25 +167,28 @@ void MainWindow::refreshEditor()
void MainWindow::displayMode()
{
- displayCurrentNote();
+ // the current note is already loaded in the browser at this point
+
+ // save note
+ if (m_editor->document()->url().isValid())
+ m_editor->document()->save();
+
+ // rerender and redisplay note
+ m_browser->refresh();
+
+ // show browser
m_stack->setCurrentWidget(m_browser->widget());
+
+ // remove editor GUI
guiFactory()->removeClient(m_editor);
+
+ // update mode
m_mode = DisplayMode;
}
-void MainWindow::displayCurrentNote()
+void MainWindow::renderCurrentNote()
{
- kDebug() << m_note->name();
Q_ASSERT(m_note);
- if (m_editor->document()->url().isValid())
- m_editor->document()->save();
- displayNote(m_note);
-}
-
-void MainWindow::displayNote(NotePtr note)
-{
- QString path = note->rendered();
- m_browser->openNote(path);
}
void MainWindow::noteChanged(const QString& path)
View
3  mainwindow.h
@@ -64,8 +64,7 @@ public slots:
void displayMode();
void index();
- void displayNote(NotePtr note);
- void displayCurrentNote();
+ void renderCurrentNote();
void noteChanged(const QString& path);
};
View
12 webkitpart.cpp
@@ -28,6 +28,7 @@
#include <KDebug>
#include <KRun>
#include <KStandardDirs>
+#include <QAction>
#include <QWebView>
#include <QNetworkRequest>
@@ -59,9 +60,9 @@ bool WebKitPart::openUrl(const KUrl& url)
return true;
}
-bool WebKitPart::openNote(const QString& path)
+bool WebKitPart::openNote(NotePtr note)
{
- return openUrl(KUrl("hikki://note/" + path));
+ return openUrl(KUrl("hikki://note/" + note->name()));
}
bool WebKitPart::openFile()
@@ -74,6 +75,11 @@ KUrl WebKitPart::url() const
return m_view->url();
}
+void WebKitPart::refresh()
+{
+ m_view->pageAction(QWebPage::Reload)->trigger();
+}
+
void WebKitPart::onUrlChanged(const QUrl& url)
{
if (url.scheme() == "hikki") {
@@ -120,7 +126,7 @@ QNetworkReply* AccessManager::createRequest(
if (req.url().scheme() == "hikki") {
if (req.url().host() == "note") {
QString path = relativePath(req);
- NotePtr note = m_notebook->openFromRendered(path);
+ NotePtr note = m_notebook->open(path);
if (note->exists()) {
QNetworkRequest r(note->rendered());
QNetworkReply* reply =
View
4 webkitpart.h
@@ -40,11 +40,13 @@ class WebKitPart : public KParts::ReadOnlyPart
WebKitPart(QWidget* parent, Notebook* notebook);
virtual bool openUrl(const KUrl& url);
- virtual bool openNote(const QString& path);
+ virtual bool openNote(NotePtr note);
virtual bool openFile();
virtual KUrl url() const;
QWebView* view();
+
+ void refresh();
private slots:
void onUrlChanged(const QUrl& url);
signals:
Please sign in to comment.
Something went wrong with that request. Please try again.