Minor improvements

Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
Dominique Fuchs 2020-01-13 11:46:49 +01:00
parent 1ebcd3a0fb
commit 96a74d9ef0
3 changed files with 94 additions and 58 deletions

View file

@ -42,7 +42,9 @@ ActivityListModel::ActivityListModel(AccountState *accountState, QObject* parent
QHash<int, QByteArray> ActivityListModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[DisplayPathRole] = "displaypath";
roles[PathRole] = "path";
roles[LinkRole] = "link";
roles[MessageRole] = "message";
roles[ActionRole] = "type";
roles[ActionIconRole] = "icon";
@ -65,11 +67,25 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
QStringList list;
switch (role) {
case DisplayPathRole:
if (!a._file.isEmpty()) {
auto folder = FolderMan::instance()->folder(a._folder);
QString relPath(a._file);
if (folder) {
relPath.prepend(folder->remotePath());
}
list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account());
if (list.count() > 0) {
return list.at(0);
}
}
return QString();
case PathRole:
if (!a._file.isEmpty()) {
auto folder = FolderMan::instance()->folder(a._folder);
QString relPath(a._file);
if(folder) relPath.prepend(folder->remotePath());
if (folder)
relPath.prepend(folder->remotePath());
list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account());
if (list.count() > 0) {
QString path = "file:///" + QString(list.at(0));
@ -141,8 +157,13 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
return QString("No description available.");
}
return a._message;
case LinkRole:
case LinkRole: {
if (a._link.isEmpty()) {
return "";
} else {
return a._link;
}
}
case AccountRole:
return a._accName;
case PointInTimeRole:
@ -231,13 +252,15 @@ void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int st
combineActivityLists();
}
void ActivityListModel::addErrorToActivityList(Activity activity) {
void ActivityListModel::addErrorToActivityList(Activity activity)
{
qCInfo(lcActivity) << "Error successfully added to the notification list: " << activity._subject;
_notificationErrorsLists.prepend(activity);
combineActivityLists();
}
void ActivityListModel::addIgnoredFileToList(Activity newActivity) {
void ActivityListModel::addIgnoredFileToList(Activity newActivity)
{
qCInfo(lcActivity) << "First checking for duplicates then add file to the notification list of ignored files: " << newActivity._file;
bool duplicate = false;
@ -260,44 +283,52 @@ void ActivityListModel::addIgnoredFileToList(Activity newActivity) {
}
}
void ActivityListModel::addNotificationToActivityList(Activity activity) {
void ActivityListModel::addNotificationToActivityList(Activity activity)
{
qCInfo(lcActivity) << "Notification successfully added to the notification list: " << activity._subject;
_notificationLists.prepend(activity);
combineActivityLists();
}
void ActivityListModel::clearNotifications() {
void ActivityListModel::clearNotifications()
{
qCInfo(lcActivity) << "Clear the notifications";
_notificationLists.clear();
combineActivityLists();
}
void ActivityListModel::removeActivityFromActivityList(int row) {
void ActivityListModel::removeActivityFromActivityList(int row)
{
Activity activity = _finalList.at(row);
removeActivityFromActivityList(activity);
combineActivityLists();
}
void ActivityListModel::addSyncFileItemToActivityList(Activity activity) {
void ActivityListModel::addSyncFileItemToActivityList(Activity activity)
{
qCInfo(lcActivity) << "Successfully added to the activity list: " << activity._subject;
_syncFileItemLists.prepend(activity);
combineActivityLists();
}
void ActivityListModel::removeActivityFromActivityList(Activity activity) {
void ActivityListModel::removeActivityFromActivityList(Activity activity)
{
qCInfo(lcActivity) << "Activity/Notification/Error successfully dismissed: " << activity._subject;
qCInfo(lcActivity) << "Trying to remove Activity/Notification/Error from view... ";
int index = -1;
if (activity._type == Activity::ActivityType) {
index = _activityLists.indexOf(activity);
if(index != -1) _activityLists.removeAt(index);
if (index != -1)
_activityLists.removeAt(index);
} else if (activity._type == Activity::NotificationType) {
index = _notificationLists.indexOf(activity);
if(index != -1) _notificationLists.removeAt(index);
if (index != -1)
_notificationLists.removeAt(index);
} else {
index = _notificationErrorsLists.indexOf(activity);
if(index != -1) _notificationErrorsLists.removeAt(index);
if (index != -1)
_notificationErrorsLists.removeAt(index);
}
if (index != -1) {
@ -342,7 +373,8 @@ void ActivityListModel::combineActivityLists()
endInsertRows();
}
bool ActivityListModel::canFetchActivities() const {
bool ActivityListModel::canFetchActivities() const
{
return _accountState->isConnected() && _accountState->account()->capabilities().hasActivities();
}

View file

@ -47,6 +47,7 @@ public:
ActionTextRole,
ActionRole,
MessageRole,
DisplayPathRole,
PathRole,
LinkRole,
PointInTimeRole,

View file

@ -61,7 +61,6 @@ Window {
trayWindow.setX( systrayBackend.calcTrayWindowX());
trayWindow.setY( systrayBackend.calcTrayWindowY());
systrayBackend.setOpened();
userModelBackend.fetchCurrentActivityModel();
}
onHideWindow: {
trayWindow.hide();
@ -470,7 +469,7 @@ Window {
}
Column {
id: activityTextColumn
Layout.leftMargin: 6
Layout.leftMargin: 4
spacing: 4
Layout.alignment: Qt.AlignLeft
Text {
@ -482,7 +481,7 @@ Window {
}
Text {
id: activityTextInfo
text: path
text: displaypath
width: 220
elide: Text.ElideRight
font.pointSize: 8
@ -499,13 +498,12 @@ Window {
Layout.alignment: Qt.AlignRight
flat: true
hoverEnabled: false
visible: (path === "") ? false : true
visible: (path !== "") ? true : false
display: AbstractButton.IconOnly
icon.source: "qrc:///client/resources/files.svg"
icon.color: "transparent"
onClicked:
{
onClicked: {
Qt.openUrlExternally(path)
}
}
@ -515,14 +513,19 @@ Window {
Layout.alignment: Qt.AlignRight
flat: true
hoverEnabled: false
visible: (link !== "") ? true : false
display: AbstractButton.IconOnly
icon.source: "qrc:///client/resources/public.svg"
icon.color: "transparent"
onClicked: {
Qt.openUrlExternally(link)
}
}
}
populate: Transition {
NumberAnimation { properties: "y"; from: -60; duration: 100; easing.type: Easing.Linear }
// prevent animations on initial list population
}
add: Transition {