mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 15:06:08 +03:00
ActivityListModel: Code cleanups
based on review feedback.
This commit is contained in:
parent
97f1694f7e
commit
9d219a18f3
4 changed files with 15 additions and 25 deletions
|
@ -44,9 +44,6 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
|
|||
AccountStatePtr ast = AccountManager::instance()->account(a._accName);
|
||||
QStringList list;
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
return QVariant();
|
||||
|
||||
switch (role) {
|
||||
case ActivityItemDelegate::PathRole:
|
||||
list = FolderMan::instance()->findFileInLocalFolders(a._file, ast->account());
|
||||
|
@ -134,19 +131,17 @@ void ActivityListModel::startFetchJob(AccountState* s)
|
|||
job->addQueryParams(params);
|
||||
|
||||
_currentlyFetching.insert(s);
|
||||
qDebug() << "Start fetching activities for " << s->account()->displayName();
|
||||
qDebug() << Q_FUNC_INFO << "Start fetching activities for " << s->account()->displayName();
|
||||
job->start();
|
||||
}
|
||||
|
||||
void ActivityListModel::slotActivitiesReceived(const QVariantMap& json, int statusCode)
|
||||
{
|
||||
auto activities = json.value("ocs").toMap().value("data").toList();
|
||||
// qDebug() << "*** activities" << activities;
|
||||
|
||||
ActivityList list;
|
||||
AccountState* ast = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
|
||||
_currentlyFetching.remove(ast);
|
||||
list.setAccountName( ast->account()->displayName());
|
||||
|
||||
foreach( auto activ, activities ) {
|
||||
auto json = activ.toMap();
|
||||
|
@ -182,7 +177,11 @@ void ActivityListModel::combineActivityLists()
|
|||
|
||||
std::sort( resultList.begin(), resultList.end() );
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, resultList.count()-1);
|
||||
beginRemoveRows(QModelIndex(), 0, _finalList.count() );
|
||||
_finalList.clear();
|
||||
endRemoveRows();
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, resultList.count());
|
||||
_finalList = resultList;
|
||||
endInsertRows();
|
||||
}
|
||||
|
@ -192,13 +191,9 @@ void ActivityListModel::fetchMore(const QModelIndex &)
|
|||
QList<AccountStatePtr> accounts = AccountManager::instance()->accounts();
|
||||
|
||||
foreach (AccountStatePtr asp, accounts) {
|
||||
bool newItem = false;
|
||||
|
||||
if( !_activityLists.contains(asp.data()) && asp->isConnected() ) {
|
||||
_activityLists[asp.data()] = ActivityList();
|
||||
newItem = true;
|
||||
}
|
||||
if( newItem ) {
|
||||
startFetchJob(asp.data());
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +202,6 @@ void ActivityListModel::fetchMore(const QModelIndex &)
|
|||
void ActivityListModel::slotRefreshActivity(AccountState *ast)
|
||||
{
|
||||
if(ast && _activityLists.contains(ast)) {
|
||||
qDebug() << "**** Refreshing Activity list for" << ast->account()->displayName();
|
||||
_activityLists.remove(ast);
|
||||
}
|
||||
startFetchJob(ast);
|
||||
|
|
|
@ -110,7 +110,7 @@ void ActivityWidget::slotRefresh(AccountState *ptr)
|
|||
|
||||
snh->slotFetchNotifications(ptr);
|
||||
} else {
|
||||
qDebug() << "========> notification request counter not zero.";
|
||||
qDebug() << Q_FUNC_INFO << "========> notification request counter not zero.";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ void ActivityWidget::storeActivityList( QTextStream& ts )
|
|||
|
||||
void ActivityWidget::slotOpenFile(QModelIndex indx)
|
||||
{
|
||||
qDebug() << indx.isValid() << indx.data(ActivityItemDelegate::PathRole).toString() << QFile::exists(indx.data(ActivityItemDelegate::PathRole).toString());
|
||||
qDebug() << Q_FUNC_INFO << indx.isValid() << indx.data(ActivityItemDelegate::PathRole).toString() << QFile::exists(indx.data(ActivityItemDelegate::PathRole).toString());
|
||||
if( indx.isValid() ) {
|
||||
QString fullPath = indx.data(ActivityItemDelegate::PathRole).toString();
|
||||
|
||||
|
@ -299,7 +299,7 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList& list)
|
|||
|
||||
void ActivityWidget::slotSendNotificationRequest(const QString& accountName, const QString& link, const QString& verb)
|
||||
{
|
||||
qDebug() << "Server Notification Request " << verb << link << "on account" << accountName;
|
||||
qDebug() << Q_FUNC_INFO << "Server Notification Request " << verb << link << "on account" << accountName;
|
||||
NotificationWidget *theSender = qobject_cast<NotificationWidget*>(sender());
|
||||
|
||||
const QStringList validVerbs = QStringList() << "GET" << "PUT" << "POST" << "DELETE";
|
||||
|
@ -322,7 +322,7 @@ void ActivityWidget::slotSendNotificationRequest(const QString& accountName, con
|
|||
_notificationRequests++;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Notification Links: Invalid verb:" << verb;
|
||||
qDebug() << Q_FUNC_INFO << "Notification Links: Invalid verb:" << verb;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ void ActivityWidget::slotNotifyNetworkError( QNetworkReply *reply)
|
|||
}
|
||||
|
||||
endNotificationRequest(job->widget(), resultCode);
|
||||
qDebug() << "Server notify job failed.";
|
||||
qDebug() << Q_FUNC_INFO << "Server notify job failed with code " << resultCode;
|
||||
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ void ActivityWidget::slotNotifyServerFinished( const QString& reply, int replyCo
|
|||
|
||||
endNotificationRequest(job->widget(), replyCode);
|
||||
// FIXME: remove the widget after a couple of seconds
|
||||
qDebug() << "Server Notification reply code"<< replyCode << reply;
|
||||
qDebug() << Q_FUNC_INFO << "Server Notification reply code"<< replyCode << reply;
|
||||
}
|
||||
|
||||
/* ==================================================================== */
|
||||
|
@ -453,7 +453,6 @@ void ActivitySettings::slotRemoveAccount( AccountState *ptr )
|
|||
void ActivitySettings::slotRefresh( AccountState* ptr )
|
||||
{
|
||||
if( ptr && ptr->isConnected() && isVisible()) {
|
||||
qDebug() << "Refreshing Activity list for " << ptr->account()->displayName();
|
||||
_progressIndicator->startAnimation();
|
||||
_activityWidget->slotRefresh(ptr);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ void NotificationWidget::slotButtonClicked()
|
|||
// if the button was found, the link must be called
|
||||
if( index > -1 && index < _myActivity._links.count() ) {
|
||||
ActivityLink triggeredLink = _myActivity._links.at(index);
|
||||
qDebug() << "Notification Link: "<< triggeredLink._verb << triggeredLink._link;
|
||||
qDebug() << Q_FUNC_INFO << "Notification Link: "<< triggeredLink._verb << triggeredLink._link;
|
||||
_progressIndi->startAnimation();
|
||||
emit sendNotificationRequest( _accountName, triggeredLink._link, triggeredLink._verb );
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ void ServerNotificationHandler::slotFetchNotifications(AccountState *ptr)
|
|||
// not yet valid, its assumed that notifications are available.
|
||||
if( ptr->account() && ptr->account()->capabilities().isValid() ) {
|
||||
if( ! ptr->account()->capabilities().notificationsAvailable() ) {
|
||||
qDebug() << "Account" << ptr->account()->displayName() << "does not have notifications enabled.";
|
||||
qDebug() << Q_FUNC_INFO << "Account" << ptr->account()->displayName() << "does not have notifications enabled.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -48,14 +48,13 @@ void ServerNotificationHandler::slotFetchNotifications(AccountState *ptr)
|
|||
this, SLOT(slotNotificationsReceived(QVariantMap, int)));
|
||||
_notificationJob->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(ptr));
|
||||
|
||||
qDebug() << "Start fetching notifications for " << ptr->account()->displayName();
|
||||
_notificationJob->start();
|
||||
}
|
||||
|
||||
void ServerNotificationHandler::slotNotificationsReceived(const QVariantMap& json, int statusCode)
|
||||
{
|
||||
if( statusCode != 200 ) {
|
||||
qDebug() << "Failed for Notifications";
|
||||
qDebug() << Q_FUNC_INFO << "Notifications failed with status code " << statusCode;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -63,8 +62,6 @@ void ServerNotificationHandler::slotNotificationsReceived(const QVariantMap& jso
|
|||
|
||||
AccountState* ai = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
|
||||
|
||||
// qDebug() << "Notifications for " << ai->account()->displayName() << notifies;
|
||||
|
||||
ActivityList list;
|
||||
|
||||
foreach( auto element, notifies ) {
|
||||
|
|
Loading…
Reference in a new issue