diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp
index d30e8ca94..64c3bca1b 100644
--- a/src/mirall/application.cpp
+++ b/src/mirall/application.cpp
@@ -53,6 +53,9 @@ Application::Application(int argc, char **argv) :
connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)),
SLOT(slotRemoveFolder(const QString&)));
+ connect( _statusDialog, SIGNAL(fetchFolderAlias(const QString&)),
+ SLOT(slotFetchFolder( const QString&)));
+
setupActions();
setupSystemTray();
@@ -248,6 +251,30 @@ void Application::slotRemoveFolder( const QString& alias )
}
}
+void Application::slotFetchFolder( const QString& alias )
+{
+ qDebug() << "start to fetch folder with alias " << alias;
+
+ if( ! _folderMap.contains( alias ) ) {
+ qDebug() << "!! Can not fetch alias " << alias << ", can not be found in folderMap.";
+ return;
+ }
+
+ Folder *f = _folderMap[alias];
+
+ if( f->backend() == "sitecopy" ) {
+ if( QMessageBox::question( 0, tr("Confirm Folder Fetch"), tr("Do you really want to fetch the folder with alias %1 from your ownCloud?
"
+ "This overwrites your local data in directory %2!").arg(alias).arg(f->path()),
+ QMessageBox::Yes|QMessageBox::No ) == QMessageBox::Yes ) {
+ SiteCopyFolder *sf = static_cast( f );
+ sf->fetchFromOC();
+ } else {
+ qDebug() << "!! Can only fetch backend type sitecopy, this one has " << f->backend();
+ }
+ }
+
+}
+
void Application::slotConfigure()
{
_owncloudSetup->startWizard();
@@ -290,9 +317,9 @@ void Application::setupFolderFromConfigFile(const QString &file) {
return;
}
- QVariant backend = settings.value("folder/backend");
- if (!backend.isNull()) {
- if( backend.toString() == "sitecopy") {
+ QString backend = settings.value("folder/backend").toString();
+ if (!backend.isEmpty()) {
+ if( backend == "sitecopy") {
SiteCopyFolder *scf = new SiteCopyFolder( file,
path.toString(),
@@ -301,13 +328,13 @@ void Application::setupFolderFromConfigFile(const QString &file) {
folder = scf;
}
- else if (backend.toString() == "unison") {
+ else if (backend == "unison") {
folder = new UnisonFolder(file,
path.toString(),
settings.value("backend:unison/secondPath").toString(),
this);
}
- else if (backend.toString() == "csync") {
+ else if (backend == "csync") {
#ifdef WITH_CSYNC
folder = new CSyncFolder(file,
path.toString(),
@@ -322,6 +349,7 @@ void Application::setupFolderFromConfigFile(const QString &file) {
return;
}
}
+ folder->setBackend( backend );
folder->setOnlyOnlineEnabled(settings.value("folder/onlyOnline", false).toBool());
folder->setOnlyThisLANEnabled(settings.value("folder/onlyThisLAN", false).toBool());
diff --git a/src/mirall/application.h b/src/mirall/application.h
index b6b36400a..e0b57c81e 100644
--- a/src/mirall/application.h
+++ b/src/mirall/application.h
@@ -46,6 +46,7 @@ protected slots:
void slotReparseConfiguration();
void slotAddFolder();
void slotRemoveFolder( const QString& );
+ void slotFetchFolder( const QString& );
void slotConfigure();
void slotFolderSyncStarted();
diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index 8a82294c9..aad8ae03b 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -209,6 +209,16 @@ void Folder::slotSyncFinished(const SyncResult &result)
_pollTimer->start();
}
+void Folder::setBackend( const QString& b )
+{
+ _backend = b;
+}
+
+QString Folder::backend() const
+{
+ return _backend;
+}
+
} // namespace Mirall
#include "folder.moc"
diff --git a/src/mirall/folder.h b/src/mirall/folder.h
index fc935ff03..a5c4efa41 100644
--- a/src/mirall/folder.h
+++ b/src/mirall/folder.h
@@ -115,6 +115,15 @@ public:
*/
SyncResult lastSyncResult() const;
+ /**
+ * set the backend description string.
+ */
+ void setBackend( const QString& );
+ /**
+ * get the backend description string.
+ */
+ QString backend() const;
+
protected:
/**
* The minimum amounts of seconds to wait before
@@ -157,6 +166,7 @@ private:
bool _online;
bool _enabled;
SyncResult _lastSyncResult;
+ QString _backend;
protected slots:
diff --git a/src/mirall/statusdialog.cpp b/src/mirall/statusdialog.cpp
index 505e38bba..b419d583e 100644
--- a/src/mirall/statusdialog.cpp
+++ b/src/mirall/statusdialog.cpp
@@ -116,6 +116,7 @@ StatusDialog::StatusDialog(QWidget *parent) :
connect(_ButtonClose, SIGNAL(clicked()), this, SLOT(accept()));
connect(_ButtonRemove, SIGNAL(clicked()), this, SLOT(slotRemoveFolder()));
+ connect(_ButtonFetch, SIGNAL(clicked()), this, SLOT(slotFetchFolder()));
}
void StatusDialog::setFolderList( Folder::Map folders )
@@ -162,6 +163,18 @@ void StatusDialog::slotRemoveFolder()
}
}
+void StatusDialog::slotFetchFolder()
+{
+ QModelIndex selected = _folderList->selectionModel()->currentIndex();
+ if( selected.isValid() ) {
+ QString alias = _model->data( selected, FolderViewDelegate::FolderNameRole ).toString();
+ qDebug() << "Fetch Folder alias " << alias;
+ if( !alias.isEmpty() ) {
+ emit(fetchFolderAlias( alias ));
+ }
+ }
+}
+
}
#include "statusdialog.moc"
diff --git a/src/mirall/statusdialog.h b/src/mirall/statusdialog.h
index fd46ecf59..279465ca3 100644
--- a/src/mirall/statusdialog.h
+++ b/src/mirall/statusdialog.h
@@ -49,10 +49,12 @@ public:
void setFolderList( QHash );
signals:
- void removeFolderAlias(const QString&);
+ void removeFolderAlias( const QString& );
+ void fetchFolderAlias( const QString& );
public slots:
void slotRemoveFolder();
+ void slotFetchFolder();
private:
QStandardItemModel *_model;