2015-10-19 15:41:53 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <QtGui>
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
|
|
#include <QtWidgets>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "activitywidget.h"
|
|
|
|
#include "configfile.h"
|
|
|
|
#include "syncresult.h"
|
|
|
|
#include "logger.h"
|
|
|
|
#include "utility.h"
|
|
|
|
#include "theme.h"
|
|
|
|
#include "folderman.h"
|
|
|
|
#include "syncfileitem.h"
|
|
|
|
#include "folder.h"
|
|
|
|
#include "openfilemanager.h"
|
|
|
|
#include "owncloudpropagator.h"
|
2015-11-02 00:27:33 +03:00
|
|
|
#include "account.h"
|
|
|
|
#include "accountstate.h"
|
|
|
|
#include "accountmanager.h"
|
2015-11-03 19:54:37 +03:00
|
|
|
#include "activityitemdelegate.h"
|
2015-11-10 17:12:35 +03:00
|
|
|
#include "protocolwidget.h"
|
2015-11-10 20:10:58 +03:00
|
|
|
#include "QProgressIndicator.h"
|
2015-10-19 15:41:53 +03:00
|
|
|
|
|
|
|
#include "ui_activitywidget.h"
|
|
|
|
|
|
|
|
#include <climits>
|
|
|
|
|
|
|
|
namespace OCC {
|
|
|
|
|
2015-11-02 00:27:33 +03:00
|
|
|
void ActivityList::setAccountName( const QString& name )
|
|
|
|
{
|
|
|
|
_accountName = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ActivityList::accountName() const
|
|
|
|
{
|
|
|
|
return _accountName;
|
|
|
|
}
|
|
|
|
|
2015-11-16 17:38:08 +03:00
|
|
|
/* ==================================================================== */
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
ActivityListModel::ActivityListModel(QWidget *parent)
|
|
|
|
:QAbstractListModel(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant ActivityListModel::data(const QModelIndex &index, int role) const
|
|
|
|
{
|
2015-11-02 17:44:13 +03:00
|
|
|
Activity a;
|
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
if (!index.isValid())
|
|
|
|
return QVariant();
|
|
|
|
|
2015-11-03 19:54:37 +03:00
|
|
|
a = _finalList.at(index.row());
|
2015-11-12 19:52:00 +03:00
|
|
|
AccountStatePtr ast = AccountManager::instance()->account(a._accName);
|
2015-11-16 17:07:02 +03:00
|
|
|
QStringList list;
|
2015-11-03 19:54:37 +03:00
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
if (role == Qt::EditRole)
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
switch (role) {
|
2015-11-16 17:31:24 +03:00
|
|
|
case ActivityItemDelegate::PathRole:
|
2015-11-16 17:07:02 +03:00
|
|
|
list = FolderMan::instance()->findFileInLocalFolders(a._file);
|
|
|
|
if( list.count() > 0 ) {
|
|
|
|
return QVariant(list.at(0));
|
|
|
|
}
|
2015-11-02 17:44:13 +03:00
|
|
|
return QVariant();
|
2015-10-19 15:41:53 +03:00
|
|
|
break;
|
2015-11-03 19:54:37 +03:00
|
|
|
case ActivityItemDelegate::ActionIconRole:
|
|
|
|
return QVariant(); // FIXME once the action can be quantified, display on Icon
|
|
|
|
break;
|
|
|
|
case ActivityItemDelegate::UserIconRole:
|
|
|
|
return QIcon(QLatin1String(":/client/resources/account.png"));
|
|
|
|
break;
|
2015-11-16 18:44:52 +03:00
|
|
|
case Qt::ToolTipRole:
|
2015-11-03 19:54:37 +03:00
|
|
|
case ActivityItemDelegate::ActionTextRole:
|
|
|
|
return a._subject;
|
|
|
|
break;
|
|
|
|
case ActivityItemDelegate::LinkRole:
|
2015-11-12 19:52:00 +03:00
|
|
|
return a._link;
|
2015-11-03 19:54:37 +03:00
|
|
|
break;
|
|
|
|
case ActivityItemDelegate::AccountRole:
|
2015-11-12 19:52:00 +03:00
|
|
|
return a._accName;
|
2015-11-03 19:54:37 +03:00
|
|
|
break;
|
|
|
|
case ActivityItemDelegate::PointInTimeRole:
|
2015-11-16 20:08:25 +03:00
|
|
|
return Utility::timeAgoInWords(a._dateTime);
|
2015-11-12 19:52:00 +03:00
|
|
|
break;
|
|
|
|
case ActivityItemDelegate::AccountConnectedRole:
|
|
|
|
return (ast && ast->isConnected());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return QVariant();
|
2015-11-03 19:54:37 +03:00
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
}
|
2015-11-03 19:54:37 +03:00
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
int ActivityListModel::rowCount(const QModelIndex&) const
|
|
|
|
{
|
2015-11-02 17:44:13 +03:00
|
|
|
return _finalList.count();
|
2015-11-02 00:27:33 +03:00
|
|
|
}
|
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
// current strategy: Fetch 100 items per Account
|
|
|
|
bool ActivityListModel::canFetchMore(const QModelIndex& ) const
|
2015-11-02 00:27:33 +03:00
|
|
|
{
|
2015-11-02 17:44:13 +03:00
|
|
|
if( _activityLists.count() == 0 ) return true;
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-11-04 18:40:22 +03:00
|
|
|
QMap<AccountState*, ActivityList>::const_iterator i = _activityLists.begin();
|
2015-11-02 17:44:13 +03:00
|
|
|
while (i != _activityLists.end()) {
|
2015-11-04 18:40:22 +03:00
|
|
|
AccountState *ast = i.key();
|
2015-11-12 19:52:00 +03:00
|
|
|
if( !ast->isConnected() ) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-02 18:39:33 +03:00
|
|
|
ActivityList activities = i.value();
|
2015-11-12 19:52:00 +03:00
|
|
|
if( activities.count() == 0 &&
|
2015-11-02 18:39:33 +03:00
|
|
|
! _currentlyFetching.contains(ast) ) {
|
2015-11-02 17:44:13 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
return false;
|
2015-10-19 15:41:53 +03:00
|
|
|
}
|
|
|
|
|
2015-11-04 18:40:22 +03:00
|
|
|
void ActivityListModel::startFetchJob(AccountState* s)
|
2015-10-19 15:41:53 +03:00
|
|
|
{
|
2015-11-12 19:52:00 +03:00
|
|
|
if( !s->isConnected() ) {
|
|
|
|
return;
|
|
|
|
}
|
2015-11-02 17:44:13 +03:00
|
|
|
JsonApiJob *job = new JsonApiJob(s->account(), QLatin1String("ocs/v1.php/cloud/activity"), this);
|
|
|
|
QObject::connect(job, SIGNAL(jsonRecieved(QVariantMap)), this, SLOT(slotActivitiesReceived(QVariantMap)));
|
2015-11-04 18:40:22 +03:00
|
|
|
job->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(s));
|
2015-10-19 15:41:53 +03:00
|
|
|
|
2015-11-02 19:51:12 +03:00
|
|
|
QList< QPair<QString,QString> > params;
|
2015-11-17 20:07:26 +03:00
|
|
|
params.append(qMakePair(QString::fromLatin1("page"), QString::fromLatin1("0")));
|
|
|
|
params.append(qMakePair(QString::fromLatin1("pagesize"), QString::fromLatin1("100")));
|
2015-11-02 19:51:12 +03:00
|
|
|
job->addQueryParams(params);
|
2015-10-19 15:41:53 +03:00
|
|
|
|
2015-11-02 19:51:12 +03:00
|
|
|
_currentlyFetching.insert(s);
|
2015-11-17 16:44:48 +03:00
|
|
|
qDebug() << "Start fetching activities for " << s->account()->displayName();
|
2015-11-02 19:51:12 +03:00
|
|
|
job->start();
|
2015-11-02 17:44:13 +03:00
|
|
|
}
|
2015-10-19 15:41:53 +03:00
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
void ActivityListModel::slotActivitiesReceived(const QVariantMap& json)
|
|
|
|
{
|
|
|
|
auto activities = json.value("ocs").toMap().value("data").toList();
|
|
|
|
qDebug() << "*** activities" << activities;
|
|
|
|
|
|
|
|
ActivityList list;
|
2015-11-04 18:40:22 +03:00
|
|
|
AccountState* ai = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
|
2015-11-02 17:44:13 +03:00
|
|
|
_currentlyFetching.remove(ai);
|
|
|
|
list.setAccountName( ai->account()->displayName());
|
|
|
|
foreach( auto activ, activities ) {
|
|
|
|
auto json = activ.toMap();
|
|
|
|
|
|
|
|
Activity a;
|
|
|
|
a._accName = ai->account()->displayName();
|
|
|
|
a._id = json.value("id").toLongLong();
|
|
|
|
a._subject = json.value("subject").toString();
|
|
|
|
a._message = json.value("message").toString();
|
|
|
|
a._file = json.value("file").toString();
|
|
|
|
a._link = json.value("link").toUrl();
|
|
|
|
a._dateTime = json.value("date").toDateTime();
|
|
|
|
list.append(a);
|
|
|
|
}
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
_activityLists[ai] = list;
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-11-17 16:44:48 +03:00
|
|
|
combineActivityLists();
|
2015-10-19 15:41:53 +03:00
|
|
|
}
|
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
|
|
|
|
void ActivityListModel::combineActivityLists()
|
2015-11-02 00:27:33 +03:00
|
|
|
{
|
2015-11-02 17:44:13 +03:00
|
|
|
ActivityList resultList;
|
|
|
|
|
|
|
|
foreach( ActivityList list, _activityLists.values() ) {
|
|
|
|
resultList.append(list);
|
2015-11-02 00:27:33 +03:00
|
|
|
}
|
2015-11-02 17:44:13 +03:00
|
|
|
|
|
|
|
std::sort( resultList.begin(), resultList.end() );
|
|
|
|
|
|
|
|
beginInsertRows(QModelIndex(), 0, resultList.count()-1);
|
|
|
|
_finalList = resultList;
|
|
|
|
endInsertRows();
|
2015-11-02 00:27:33 +03:00
|
|
|
}
|
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
void ActivityListModel::fetchMore(const QModelIndex &)
|
2015-11-02 00:27:33 +03:00
|
|
|
{
|
2015-11-02 17:44:13 +03:00
|
|
|
QList<AccountStatePtr> accounts = AccountManager::instance()->accounts();
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
foreach (AccountStatePtr asp, accounts) {
|
2015-11-17 16:46:13 +03:00
|
|
|
bool newItem = false;
|
2015-11-02 17:44:13 +03:00
|
|
|
// if the account is not yet managed, add an empty list.
|
2015-11-04 18:40:22 +03:00
|
|
|
if( !_activityLists.contains(asp.data()) ) {
|
|
|
|
_activityLists[asp.data()] = ActivityList();
|
2015-11-17 16:46:13 +03:00
|
|
|
newItem = true;
|
2015-11-02 17:44:13 +03:00
|
|
|
}
|
2015-11-04 18:40:22 +03:00
|
|
|
ActivityList activities = _activityLists[asp.data()];
|
2015-11-17 16:46:13 +03:00
|
|
|
if( newItem ) {
|
2015-11-04 18:40:22 +03:00
|
|
|
startFetchJob(asp.data());
|
2015-11-02 17:44:13 +03:00
|
|
|
}
|
2015-11-02 00:27:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-04 18:40:22 +03:00
|
|
|
void ActivityListModel::slotRefreshActivity(AccountState *ast)
|
2015-11-02 19:52:04 +03:00
|
|
|
{
|
|
|
|
if(ast && _activityLists.contains(ast)) {
|
2015-11-12 17:39:07 +03:00
|
|
|
qDebug() << "**** Refreshing Activity list for" << ast->account()->displayName();
|
2015-11-17 16:46:13 +03:00
|
|
|
_activityLists.remove(ast);
|
2015-11-02 19:52:04 +03:00
|
|
|
}
|
|
|
|
startFetchJob(ast);
|
|
|
|
}
|
|
|
|
|
2015-11-12 17:39:07 +03:00
|
|
|
void ActivityListModel::slotRemoveAccount(AccountState *ast )
|
|
|
|
{
|
|
|
|
if( _activityLists.contains(ast) ) {
|
|
|
|
int i = 0;
|
|
|
|
const QString accountToRemove = ast->account()->displayName();
|
|
|
|
|
|
|
|
QMutableListIterator<Activity> it(_finalList);
|
|
|
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
Activity activity = it.next();
|
|
|
|
if( activity._accName == accountToRemove ) {
|
|
|
|
beginRemoveRows(QModelIndex(), i, i+1);
|
|
|
|
it.remove();
|
|
|
|
endRemoveRows();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_activityLists.remove(ast);
|
|
|
|
_currentlyFetching.remove(ast);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
/* ==================================================================== */
|
|
|
|
|
|
|
|
ActivityWidget::ActivityWidget(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
_ui(new Ui::ActivityWidget)
|
2015-11-02 00:27:33 +03:00
|
|
|
{
|
2015-11-02 17:44:13 +03:00
|
|
|
_ui->setupUi(this);
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
// Adjust copyToClipboard() when making changes here!
|
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
_ui->_activityList->setMinimumWidth(400);
|
|
|
|
#endif
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
_model = new ActivityListModel(this);
|
2015-11-03 19:54:37 +03:00
|
|
|
ActivityItemDelegate *delegate = new ActivityItemDelegate;
|
|
|
|
delegate->setParent(this);
|
|
|
|
_ui->_activityList->setItemDelegate(delegate);
|
2015-11-04 15:22:03 +03:00
|
|
|
_ui->_activityList->setAlternatingRowColors(true);
|
2015-11-02 17:44:13 +03:00
|
|
|
_ui->_activityList->setModel(_model);
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-11-10 17:12:35 +03:00
|
|
|
_ui->_headerLabel->setText(tr("Server Activities"));
|
|
|
|
|
2015-11-02 17:44:13 +03:00
|
|
|
_copyBtn = _ui->_dialogButtonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
|
|
|
|
_copyBtn->setToolTip( tr("Copy the activity list to the clipboard."));
|
2015-11-10 17:12:35 +03:00
|
|
|
connect(_copyBtn, SIGNAL(clicked()), SIGNAL(copyToClipboard()));
|
2015-11-10 20:10:58 +03:00
|
|
|
|
|
|
|
connect(_model, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(rowsInserted()));
|
2015-11-16 17:31:24 +03:00
|
|
|
|
|
|
|
connect( _ui->_activityList, SIGNAL(activated(QModelIndex)), this,
|
|
|
|
SLOT(slotOpenFile(QModelIndex)));
|
2015-11-02 00:27:33 +03:00
|
|
|
}
|
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
ActivityWidget::~ActivityWidget()
|
|
|
|
{
|
|
|
|
delete _ui;
|
|
|
|
}
|
|
|
|
|
2015-11-04 18:40:22 +03:00
|
|
|
void ActivityWidget::slotRefresh(AccountState *ptr)
|
|
|
|
{
|
|
|
|
_model->slotRefreshActivity(ptr);
|
|
|
|
}
|
|
|
|
|
2015-11-12 17:39:07 +03:00
|
|
|
void ActivityWidget::slotRemoveAccount( AccountState *ptr )
|
|
|
|
{
|
|
|
|
_model->slotRemoveAccount(ptr);
|
|
|
|
}
|
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
// FIXME: Reused from protocol widget. Move over to utilities.
|
|
|
|
QString ActivityWidget::timeString(QDateTime dt, QLocale::FormatType format) const
|
|
|
|
{
|
|
|
|
const QLocale loc = QLocale::system();
|
|
|
|
QString dtFormat = loc.dateTimeFormat(format);
|
|
|
|
static const QRegExp re("(HH|H|hh|h):mm(?!:s)");
|
|
|
|
dtFormat.replace(re, "\\1:mm:ss");
|
|
|
|
return loc.toString(dt, dtFormat);
|
|
|
|
}
|
|
|
|
|
2015-11-10 17:12:35 +03:00
|
|
|
void ActivityWidget::storeActivityList( QTextStream& ts )
|
|
|
|
{
|
|
|
|
ActivityList activities = _model->activityList();
|
|
|
|
|
|
|
|
foreach( Activity activity, activities ) {
|
|
|
|
ts << left
|
|
|
|
// account name
|
|
|
|
<< qSetFieldWidth(30)
|
|
|
|
<< activity._accName
|
|
|
|
// date and time
|
|
|
|
<< qSetFieldWidth(34)
|
|
|
|
<< activity._dateTime.toString()
|
|
|
|
// subject
|
|
|
|
<< qSetFieldWidth(10)
|
|
|
|
<< activity._subject
|
|
|
|
// file
|
|
|
|
<< qSetFieldWidth(30)
|
|
|
|
<< activity._file
|
|
|
|
// message (mostly empty)
|
|
|
|
<< qSetFieldWidth(55)
|
|
|
|
<< activity._message
|
|
|
|
//
|
|
|
|
<< qSetFieldWidth(0)
|
|
|
|
<< endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-16 17:31:24 +03:00
|
|
|
void ActivityWidget::slotOpenFile(QModelIndex indx)
|
2015-10-19 15:41:53 +03:00
|
|
|
{
|
2015-11-16 17:31:24 +03:00
|
|
|
if( indx.isValid() ) {
|
|
|
|
QString fullPath = indx.data(ActivityItemDelegate::PathRole).toString();
|
|
|
|
|
|
|
|
if (QFile::exists(fullPath)) {
|
2015-10-19 15:41:53 +03:00
|
|
|
showInFileManager(fullPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-16 17:38:08 +03:00
|
|
|
/* ==================================================================== */
|
2015-11-10 17:12:35 +03:00
|
|
|
|
|
|
|
ActivitySettings::ActivitySettings(QWidget *parent)
|
|
|
|
:QWidget(parent)
|
|
|
|
{
|
|
|
|
QHBoxLayout *hbox = new QHBoxLayout(this);
|
|
|
|
setLayout(hbox);
|
|
|
|
|
|
|
|
// create a tab widget for the three activity views
|
|
|
|
_tab = new QTabWidget(this);
|
|
|
|
hbox->addWidget(_tab);
|
|
|
|
_activityWidget = new ActivityWidget(this);
|
|
|
|
_tab->addTab(_activityWidget, Theme::instance()->applicationIcon(), tr("Server Activity"));
|
|
|
|
connect(_activityWidget, SIGNAL(copyToClipboard()), this, SLOT(slotCopyToClipboard()));
|
|
|
|
|
2015-11-10 20:10:58 +03:00
|
|
|
|
2015-11-10 17:12:35 +03:00
|
|
|
_protocolWidget = new ProtocolWidget(this);
|
|
|
|
_tab->addTab(_protocolWidget, Theme::instance()->syncStateIcon(SyncResult::Success), tr("Sync Protocol"));
|
|
|
|
connect(_protocolWidget, SIGNAL(copyToClipboard()), this, SLOT(slotCopyToClipboard()));
|
|
|
|
|
|
|
|
// Add the not-synced list into the tab
|
|
|
|
QWidget *w = new QWidget;
|
2015-11-10 20:10:58 +03:00
|
|
|
QVBoxLayout *vbox2 = new QVBoxLayout(this);
|
|
|
|
vbox2->addWidget(new QLabel(tr("List of ignored or errornous files"), this));
|
|
|
|
vbox2->addWidget(_protocolWidget->issueWidget());
|
2015-11-10 17:12:35 +03:00
|
|
|
QDialogButtonBox *dlgButtonBox = new QDialogButtonBox(this);
|
2015-11-10 20:10:58 +03:00
|
|
|
vbox2->addWidget(dlgButtonBox);
|
2015-11-10 17:12:35 +03:00
|
|
|
QPushButton *_copyBtn = dlgButtonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
|
|
|
|
_copyBtn->setToolTip( tr("Copy the activity list to the clipboard."));
|
|
|
|
_copyBtn->setEnabled(true);
|
|
|
|
connect(_copyBtn, SIGNAL(clicked()), this, SLOT(slotCopyToClipboard()));
|
|
|
|
|
2015-11-10 20:10:58 +03:00
|
|
|
w->setLayout(vbox2);
|
2015-11-10 17:12:35 +03:00
|
|
|
_tab->addTab(w, Theme::instance()->syncStateIcon(SyncResult::Problem), tr("Not Synced"));
|
2015-11-10 20:10:58 +03:00
|
|
|
|
|
|
|
// Add a progress indicator to spin if the acitivity list is updated.
|
|
|
|
_progressIndicator = new QProgressIndicator(this);
|
|
|
|
_tab->setCornerWidget(_progressIndicator);
|
|
|
|
|
|
|
|
// connect a model signal to stop the animation.
|
|
|
|
connect(_activityWidget, SIGNAL(rowsInserted()), _progressIndicator, SLOT(stopAnimation()));
|
2015-11-10 17:12:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActivitySettings::slotCopyToClipboard()
|
|
|
|
{
|
|
|
|
QString text;
|
|
|
|
QTextStream ts(&text);
|
|
|
|
|
|
|
|
int idx = _tab->currentIndex();
|
|
|
|
QString theSubject;
|
|
|
|
|
|
|
|
if( idx == 0 ) {
|
|
|
|
// the activity widget
|
|
|
|
_activityWidget->storeActivityList(ts);
|
|
|
|
theSubject = tr("server activity list");
|
|
|
|
} else if(idx == 1 ) {
|
|
|
|
// the protocol widget
|
|
|
|
_protocolWidget->storeSyncActivity(ts);
|
|
|
|
theSubject = tr("sync activity list");
|
|
|
|
} else if(idx == 2 ) {
|
|
|
|
// issues Widget
|
|
|
|
theSubject = tr("not syned items list");
|
|
|
|
_protocolWidget->storeSyncIssues(ts);
|
|
|
|
}
|
|
|
|
|
|
|
|
QApplication::clipboard()->setText(text);
|
|
|
|
emit guiLog(tr("Copied to clipboard"), tr("The %1 has been copied to the clipboard.").arg(theSubject));
|
|
|
|
}
|
|
|
|
|
2015-11-12 17:39:07 +03:00
|
|
|
void ActivitySettings::slotRemoveAccount( AccountState *ptr )
|
|
|
|
{
|
|
|
|
_activityWidget->slotRemoveAccount(ptr);
|
|
|
|
}
|
|
|
|
|
2015-11-10 17:12:35 +03:00
|
|
|
void ActivitySettings::slotRefresh( AccountState* ptr )
|
|
|
|
{
|
2015-11-18 17:25:29 +03:00
|
|
|
if( ptr && ptr->isConnected() && isVisible()) {
|
2015-11-17 17:05:54 +03:00
|
|
|
_progressIndicator->startAnimation();
|
|
|
|
_activityWidget->slotRefresh(ptr);
|
|
|
|
}
|
2015-11-10 17:12:35 +03:00
|
|
|
}
|
|
|
|
|
2015-11-18 17:25:29 +03:00
|
|
|
bool ActivitySettings::event(QEvent* e)
|
|
|
|
{
|
|
|
|
if (e->type() == QEvent::Show) {
|
|
|
|
AccountManager *am = AccountManager::instance();
|
|
|
|
foreach (AccountStatePtr a, am->accounts()) {
|
|
|
|
slotRefresh(a.data());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QWidget::event(e);
|
|
|
|
}
|
|
|
|
|
2015-11-10 17:12:35 +03:00
|
|
|
ActivitySettings::~ActivitySettings()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
}
|