summaryrefslogtreecommitdiffstats
path: root/noatun-plugins/lyrics/historymanager.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch)
tree2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /noatun-plugins/lyrics/historymanager.cpp
downloadtdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz
tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'noatun-plugins/lyrics/historymanager.cpp')
-rw-r--r--noatun-plugins/lyrics/historymanager.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/noatun-plugins/lyrics/historymanager.cpp b/noatun-plugins/lyrics/historymanager.cpp
new file mode 100644
index 0000000..1524d7b
--- /dev/null
+++ b/noatun-plugins/lyrics/historymanager.cpp
@@ -0,0 +1,56 @@
+#include "historymanager.h"
+
+/** HISTORY MANAGER ***
+*** TODO: Add more complex support (like in Konqueror)
+ Maybe use Konqueror's History Manager */
+
+HistoryManager::HistoryManager(QObject *parent) : QObject(parent) {
+}
+
+HistoryManager::~HistoryManager() {
+}
+
+void HistoryManager::addURL(const KURL &url) {
+ /* push current URL to the back */
+ if (!currentURL.isEmpty()) {
+ if (back_stack.count() == 0)
+ emit uiChanged( Back, true );
+ back_stack.push(currentURL);
+ }
+ /* Make a copy of the new URL */
+ currentURL = url;
+ /* Clear the forward stack */
+ if (forward_stack.count() > 0)
+ emit uiChanged( Forward, false );
+ forward_stack.clear();
+}
+
+KURL HistoryManager::back() {
+ if (back_stack.count() <= 0)
+ return KURL();
+ /* The currentURL is now pushed in the forward_stack */
+ if (forward_stack.count() == 0)
+ emit uiChanged( Forward, true );
+ forward_stack.push(currentURL);
+ /* The last URL is the back stack is now popped as the current one */
+ if (back_stack.count() == 1)
+ emit uiChanged( Back, false );
+ currentURL = back_stack.pop();
+ return currentURL;
+}
+
+KURL HistoryManager::forward() {
+ if (forward_stack.count() <= 0)
+ return KURL();
+ /* Push the currentURL into the back_stack */
+ if (back_stack.count() == 0)
+ emit uiChanged( Back, true );
+ back_stack.push(currentURL);
+ /* Pop from the forward_stack into the currentURL */
+ if (forward_stack.count() == 1)
+ emit uiChanged( Forward, false );
+ currentURL = forward_stack.pop();
+ return currentURL;
+}
+
+#include "historymanager.moc"