From e35004358ab0b290a5fefd893c7c9aab9cce6440 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 14 Nov 2011 17:41:28 +0100 Subject: let history, bookmarks and passwords sync on change (first bits) --- src/sync/syncmanager.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/sync/syncmanager.cpp') diff --git a/src/sync/syncmanager.cpp b/src/sync/syncmanager.cpp index 53149ee1..f4a2fdf4 100644 --- a/src/sync/syncmanager.cpp +++ b/src/sync/syncmanager.cpp @@ -32,6 +32,9 @@ #include "rekonq.h" // Local Includes +#include "application.h" +#include "bookmarkprovider.h" +#include "historymanager.h" #include "syncwidget.h" // KDE Includes @@ -46,7 +49,6 @@ SyncManager::SyncManager(QObject *parent) : QObject(parent) , _firstTimeSynced(false) - , _syncTimer(0) { loadSettings(); } @@ -62,20 +64,27 @@ void SyncManager::loadSettings() { if (ReKonfig::syncEnabled()) { - if (_syncTimer) - return; + firstTimeSync(); - _syncTimer = new QTimer(this); - connect(_syncTimer, SIGNAL(timeout()), this, SLOT(sync())); - _syncTimer->start(60 * 1000); // sync every minute + // bookmarks + ReKonfig::syncBookmarks() + ? connect(rApp->bookmarkProvider(), SIGNAL(changed()), this, SLOT(syncBookmarks())) + : disconnect(rApp->bookmarkProvider(), SIGNAL(changed()), this, SLOT(syncBookmarks())) + ; + + // history + ReKonfig::syncHistory() + ? connect(rApp->historyManager(), SIGNAL(historySaved()), this, SLOT(syncHistory())) + : disconnect(rApp->historyManager(), SIGNAL(historySaved()), this, SLOT(syncHistory())) + ; } else { - if (_syncTimer) - { - _syncTimer->stop(); - delete _syncTimer; - } + // bookmarks + disconnect(rApp->bookmarkProvider(), SIGNAL(changed()), this, SLOT(syncBookmarks())); + + // history + disconnect(rApp->historyManager(), SIGNAL(historySaved()), this, SLOT(syncHistory())); } } -- cgit v1.2.1