Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Activity View #4083

Merged
merged 32 commits into from
Nov 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0c14802
SyncLog Dialog WIP
Sep 30, 2015
afd081f
Settings: Move synclog widget to a seperate dialog.
Oct 1, 2015
a8eb913
SyncLogDialog: Do not delete SyncLogDialog after close.
Oct 7, 2015
4ad165c
Utility: add method fileNameForGuiUse(), pimp up filename for GUI
Oct 19, 2015
c66c259
SettingsDialog: Add new widet called ActivityWidget.
Oct 19, 2015
9279bcd
Add a tabwidget to Settings dialog for activity.
Oct 30, 2015
302d6b3
ActivityWidget: Add a job to fetch activities, Activity object added
Nov 1, 2015
3b8e1dc
SettingsDialog: Make ActivityWidget a member.
Nov 1, 2015
4895683
ActivityWidget: Do a proper asynchronous model to display the activity.
Nov 2, 2015
3fb43d2
ActivityWidget UI: Remove the preconfigured tabs from the tabwidget.
Nov 2, 2015
060f4f2
SettingsDialog: Add a tab with the SyncProtocol to ActivityWidget.
Nov 2, 2015
6c6ee35
ActivityListModel: Check if the account is connected when fetching more.
Nov 2, 2015
9545af0
JSONApiJob: Add method to add additional query parameter.
Nov 2, 2015
71849c4
ActivityListModel: Add the page and pagesize parameter to ocs query.
Nov 2, 2015
b600ac8
ActivityListModel: Add method to refresh one Account (WIP)
Nov 2, 2015
cb4fba7
ActivityWidget: Created a delegate for prettier display of the activi…
Nov 3, 2015
3bccfb8
ActivityView: Add information about the account.
Nov 4, 2015
cb1571c
ActivityWidget: Rather use accountState pointer directly.
Nov 4, 2015
a1551ef
ActivityDelegate: Make the row height public accessible.
Nov 6, 2015
cf9fec7
ActivityView: Add a second treeview for sync issues.
Nov 6, 2015
0e0b602
Activity: Unify the GUI, and reactivate copy to clipboard for all.
Nov 10, 2015
5e98894
ActivityView: Add a progress indicator widget to indicate action.
Nov 10, 2015
ff4a8c9
GeneralSettings: Remove references to protocolwidget.
Nov 11, 2015
aa38f7a
ActivityWidget: implement removeAccount.
Nov 12, 2015
81296fa
AccountManager: new method to return AccountStatePtr from the name.
Nov 12, 2015
731a13c
ActivityWidget: Take the account state (connected or not) in account.
Nov 12, 2015
ddcec29
ActivityDelegate: Gray out font if account is not connected.
Nov 13, 2015
caba719
Folderman: Added method to find local files for a rel. server path.
Nov 16, 2015
631cb09
ActivityWidget: Show the local path in a tooltip.
Nov 16, 2015
a56926b
ActivityWidget: open local file in file manager if exists.
Nov 16, 2015
ff76a84
Added some documentation.
Nov 16, 2015
ccb871c
ActivityWidget: Show the subject in the Tooltip.
Nov 16, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ set(client_UI
ignorelisteditor.ui
networksettings.ui
protocolwidget.ui
activitywidget.ui
synclogdialog.ui
settingsdialog.ui
sharedialog.ui
sslerrordialog.ui
Expand Down Expand Up @@ -54,6 +56,8 @@ set(client_SRCS
owncloudgui.cpp
owncloudsetupwizard.cpp
protocolwidget.cpp
activitywidget.cpp
activityitemdelegate.cpp
selectivesyncdialog.cpp
settingsdialog.cpp
sharedialog.cpp
Expand All @@ -68,6 +72,7 @@ set(client_SRCS
authenticationdialog.cpp
proxyauthhandler.cpp
proxyauthdialog.cpp
synclogdialog.cpp
creds/credentialsfactory.cpp
creds/httpcredentialsgui.cpp
creds/shibbolethcredentials.cpp
Expand Down
10 changes: 10 additions & 0 deletions src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ AccountPtr AccountManager::load(QSettings& settings)
return acc;
}

AccountStatePtr AccountManager::account(const QString& name)
{
foreach (const auto& acc, _accounts) {
if (acc->account()->displayName() == name) {
return acc;
}
}
return AccountStatePtr();
}

AccountState *AccountManager::addAccount(const AccountPtr& newAccount)
{
auto id = newAccount->id();
Expand Down
5 changes: 5 additions & 0 deletions src/gui/accountmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class AccountManager : public QObject {
*/
QList<AccountStatePtr> accounts() { return _accounts; }

/**
* Return the account state pointer for an account identified by its display name
*/
AccountStatePtr account(const QString& name);

/**
* Delete the AccountState
*/
Expand Down
153 changes: 153 additions & 0 deletions src/gui/activityitemdelegate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* Copyright (C) by Klaas Freitag <[email protected]>
* Copyright (C) by Olivier Goffart <[email protected]>
*
*
* 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; either version 2 of the License, or
* (at your option) any later version.
*
* 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 "activityitemdelegate.h"
#include "folderstatusmodel.h"
#include "folderman.h"
#include "accountstate.h"
#include "utility.h"
#include <theme.h>
#include <account.h>

#include <QFileIconProvider>
#include <QPainter>
#include <QApplication>

namespace OCC {

int ActivityItemDelegate::_iconHeight = 0;
int ActivityItemDelegate::_margin = 0;

int ActivityItemDelegate::iconHeight()
{
if( _iconHeight == 0 ) {
QStyleOptionViewItem option;
QFont font = option.font;

QFontMetrics fm(font);

_iconHeight = qRound(fm.height() / 5.0 * 8.0);
}
return _iconHeight;
}

int ActivityItemDelegate::rowHeight()
{
if( _margin == 0 ) {
QStyleOptionViewItem opt;

QFont f = opt.font;
QFontMetrics fm(f);

_margin = fm.height()/4;
}
return iconHeight() + 2 * _margin;
}

QSize ActivityItemDelegate::sizeHint(const QStyleOptionViewItem & option ,
const QModelIndex & /* index */) const
{
QFont font = option.font;

return QSize( 0, rowHeight() );
}

void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter,option,index);

QFont font = option.font;

QFontMetrics fm( font );
int margin = fm.height()/4;

painter->save();

QIcon actionIcon = qvariant_cast<QIcon>(index.data(ActionIconRole));
QIcon userIcon = qvariant_cast<QIcon>(index.data(UserIconRole));
QString actionText = qvariant_cast<QString>(index.data(ActionTextRole));
QString pathText = qvariant_cast<QString>(index.data(PathRole));

QString remoteLink = qvariant_cast<QString>(index.data(LinkRole));
QString timeText = qvariant_cast<QString>(index.data(PointInTimeRole));
QString accountRole = qvariant_cast<QString>(index.data(AccountRole));
bool accountOnline = qvariant_cast<bool> (index.data(AccountConnectedRole));

QRect actionIconRect = option.rect;
QRect userIconRect = option.rect;

int iconHeight = qRound(fm.height() / 5.0 * 8.0);
int iconWidth = iconHeight;

actionIconRect.setLeft( option.rect.left() + margin );
actionIconRect.setWidth( iconWidth );
actionIconRect.setHeight( iconHeight );
actionIconRect.setTop( actionIconRect.top() + margin );
userIconRect.setLeft( actionIconRect.right() + margin );
userIconRect.setWidth( iconWidth );
userIconRect.setHeight( iconHeight );
userIconRect.setTop( actionIconRect.top() );

int textTopOffset = qRound( (iconHeight - fm.height())/ 2.0 );
// time rect
QRect timeBox;
int timeBoxWidth = fm.boundingRect(QLatin1String("4 hour(s) ago on longlongdomain.org")).width(); // FIXME.
timeBox.setTop( actionIconRect.top()+textTopOffset);
timeBox.setLeft( option.rect.right() - timeBoxWidth- margin );
timeBox.setWidth( timeBoxWidth);
timeBox.setHeight( fm.height() );

QRect actionTextBox = timeBox;
actionTextBox.setLeft( userIconRect.right()+margin );
actionTextBox.setRight( timeBox.left()-margin );

/* === start drawing === */
QPixmap pm = actionIcon.pixmap(iconWidth, iconHeight, QIcon::Normal);
painter->drawPixmap(QPoint(actionIconRect.left(), actionIconRect.top()), pm);

pm = userIcon.pixmap(iconWidth, iconHeight, QIcon::Normal);
painter->drawPixmap(QPoint(userIconRect.left(), userIconRect.top()), pm);

const QString elidedAction = fm.elidedText(actionText, Qt::ElideRight, actionTextBox.width());
painter->drawText(actionTextBox, elidedAction);

int atPos = accountRole.indexOf(QLatin1Char('@'));
if( atPos > -1 ) {
accountRole.remove(0, atPos+1);
}

QString timeStr = tr("%1 on %2").arg(timeText).arg(accountRole);
if( !accountOnline ) {
QPalette p = option.palette;
painter->setPen(p.color(QPalette::Disabled, QPalette::Text));
timeStr.append(" ");
timeStr.append(tr("(disconnected)"));
}
const QString elidedTime = fm.elidedText(timeStr, Qt::ElideRight, timeBox.width());

painter->drawText(timeBox, elidedTime);
painter->restore();

}

bool ActivityItemDelegate::editorEvent ( QEvent * event, QAbstractItemModel * model,
const QStyleOptionViewItem & option, const QModelIndex & index )
{
return QStyledItemDelegate::editorEvent(event, model, option, index);
}

} // namespace OCC
53 changes: 53 additions & 0 deletions src/gui/activityitemdelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (C) by Klaas Freitag <[email protected]>
* Copyright (C) by Olivier Goffart <[email protected]>
*
* 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; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*/

#pragma once
#include <QStyledItemDelegate>

namespace OCC {

/**
* @brief The ActivityItemDelegate class
* @ingroup gui
*/
class ActivityItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:

enum datarole { ActionIconRole = Qt::UserRole + 1,
UserIconRole,
AccountRole,
ActionTextRole,
PathRole,
LinkRole,
PointInTimeRole,
AccountConnectedRole };

void paint( QPainter*, const QStyleOptionViewItem&, const QModelIndex& ) const Q_DECL_OVERRIDE;
QSize sizeHint( const QStyleOptionViewItem&, const QModelIndex& ) const Q_DECL_OVERRIDE;
bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option,
const QModelIndex& index ) Q_DECL_OVERRIDE;

static int rowHeight();
static int iconHeight();

private:
static int _margin;
static int _iconHeight;
};

} // namespace OCC

Loading