Implemented folder fetching.

This commit is contained in:
Klaas Freitag 2011-10-18 10:22:24 +02:00
parent 90f722e2da
commit 9d3a0e8596
6 changed files with 70 additions and 6 deletions

View file

@ -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 <i>%1</i> from your ownCloud?<br/>"
"This overwrites your local data in directory <i>%2</i>!").arg(alias).arg(f->path()),
QMessageBox::Yes|QMessageBox::No ) == QMessageBox::Yes ) {
SiteCopyFolder *sf = static_cast<SiteCopyFolder*>( 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());

View file

@ -46,6 +46,7 @@ protected slots:
void slotReparseConfiguration();
void slotAddFolder();
void slotRemoveFolder( const QString& );
void slotFetchFolder( const QString& );
void slotConfigure();
void slotFolderSyncStarted();

View file

@ -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"

View file

@ -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:

View file

@ -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"

View file

@ -49,10 +49,12 @@ public:
void setFolderList( QHash<QString, Folder*> );
signals:
void removeFolderAlias(const QString&);
void removeFolderAlias( const QString& );
void fetchFolderAlias( const QString& );
public slots:
void slotRemoveFolder();
void slotFetchFolder();
private:
QStandardItemModel *_model;