2011-02-17 02:21:45 +03:00
|
|
|
#include <QAction>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QMutexLocker>
|
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
#include "mirall/constants.h"
|
|
|
|
#include "mirall/folder.h"
|
|
|
|
#include "mirall/folderwatcher.h"
|
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
|
|
|
Folder::Folder(const QString &path, QObject *parent)
|
|
|
|
: QObject(parent),
|
|
|
|
_path(path)
|
|
|
|
{
|
2011-02-17 13:27:05 +03:00
|
|
|
_openAction = new QAction(QIcon(FOLDER_ICON), path, this);
|
2011-02-17 17:10:06 +03:00
|
|
|
_openAction->setIconVisibleInMenu(true);
|
|
|
|
_openAction->setIcon(QIcon(FOLDER_ICON));
|
|
|
|
|
2011-02-17 13:27:05 +03:00
|
|
|
QObject::connect(_openAction, SIGNAL(triggered(bool)), SLOT(slotOpenFolder()));
|
2011-02-17 02:21:45 +03:00
|
|
|
|
|
|
|
_watcher = new Mirall::FolderWatcher(path, this);
|
2011-03-23 01:03:43 +03:00
|
|
|
QObject::connect(_watcher, SIGNAL(folderChanged(const QStringList &)),
|
|
|
|
SLOT(slotChanged(const QStringList &)));
|
2011-02-17 02:21:45 +03:00
|
|
|
}
|
|
|
|
|
2011-02-17 13:27:05 +03:00
|
|
|
QAction * Folder::openAction() const
|
2011-02-17 02:21:45 +03:00
|
|
|
{
|
2011-02-17 13:27:05 +03:00
|
|
|
return _openAction;
|
2011-02-17 02:21:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Folder::~Folder()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-02-17 17:10:06 +03:00
|
|
|
QString Folder::path() const
|
|
|
|
{
|
|
|
|
return _path;
|
|
|
|
}
|
|
|
|
|
2011-03-23 01:03:43 +03:00
|
|
|
void Folder::slotChanged(const QStringList &pathList)
|
2011-02-17 02:21:45 +03:00
|
|
|
{
|
2011-03-23 01:03:43 +03:00
|
|
|
qDebug() << "Changed >> " << pathList;
|
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Folder::slotOpenFolder()
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl(QUrl(_path));
|
|
|
|
}
|
|
|
|
|
2011-02-17 17:10:06 +03:00
|
|
|
void Folder::slotSyncStarted()
|
|
|
|
{
|
|
|
|
_openAction->setIcon(QIcon(FOLDER_SYNC_ICON));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Folder::slotSyncFinished()
|
|
|
|
{
|
|
|
|
_openAction->setIcon(QIcon(FOLDER_ICON));
|
|
|
|
}
|
2011-02-17 02:21:45 +03:00
|
|
|
|
|
|
|
} // namespace Mirall
|
|
|
|
|
|
|
|
#include "folder.moc"
|