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

Nmc/2244-ActivityListModel #32

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 13 additions & 15 deletions src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,41 +227,36 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const

const auto generateIconPath = [&]() {
auto colorIconPath = role == DarkIconRole ? QStringLiteral("qrc:///client/theme/white/") : QStringLiteral("qrc:///client/theme/black/");
if (a._type == Activity::NotificationType && !a._talkNotificationData.userAvatar.isEmpty()) {
if (a._type == Activity::NotificationType /*&& !a._talkNotificationData.userAvatar.isEmpty()*/) {
return QStringLiteral("qrc:///client/theme/colored/talk-bordered.svg");
} else if (a._type == Activity::SyncResultType) {
colorIconPath.append("state-error.svg");
return QStringLiteral("qrc:///client/theme/black/state-error.svg");//colorIconPath.append("state-error.svg");
return colorIconPath;
} else if (a._type == Activity::SyncFileItemType) {
if (a._syncFileItemStatus == SyncFileItem::NormalError
|| a._syncFileItemStatus == SyncFileItem::FatalError
|| a._syncFileItemStatus == SyncFileItem::DetailError
|| a._syncFileItemStatus == SyncFileItem::BlacklistedError) {
colorIconPath.append("state-error.svg");
return colorIconPath;
return QStringLiteral("qrc:///client/theme/black/state-error.svg");//colorIconPath.append("state-error.svg");
} else if (a._syncFileItemStatus == SyncFileItem::SoftError
|| a._syncFileItemStatus == SyncFileItem::Conflict
|| a._syncFileItemStatus == SyncFileItem::Restoration
|| a._syncFileItemStatus == SyncFileItem::FileLocked
|| a._syncFileItemStatus == SyncFileItem::FileNameInvalid
|| a._syncFileItemStatus == SyncFileItem::FileNameInvalidOnServer
|| a._syncFileItemStatus == SyncFileItem::FileNameClash) {
colorIconPath.append("state-warning.svg");
return QStringLiteral("qrc:///client/theme/black/state-warning.svg");//colorIconPath.append("state-warning.svg");
return colorIconPath;
} else if (a._syncFileItemStatus == SyncFileItem::FileIgnored) {
colorIconPath.append("state-info.svg");
return colorIconPath;
return QStringLiteral("qrc:///client/theme/black/state-info.svg");// colorIconPath.append("state-info.svg");
} else {
// File sync successful
if (a._fileAction == "file_created") {
return a._previews.empty() ? QStringLiteral("qrc:///client/theme/colored/add.svg")
: QStringLiteral("qrc:///client/theme/colored/add-bordered.svg");
return QStringLiteral("qrc:///client/theme/black/add-circle.svg");
} else if (a._fileAction == "file_deleted") {
return a._previews.empty() ? QStringLiteral("qrc:///client/theme/colored/delete.svg")
: QStringLiteral("qrc:///client/theme/colored/delete-bordered.svg");
return QStringLiteral("qrc:///client/theme/black/delete.svg");
} else {
return a._previews.empty() ? colorIconPath % QStringLiteral("change.svg")
: QStringLiteral("qrc:///client/theme/colored/change-bordered.svg");
return QStringLiteral("qrc:///client/theme/refresh.svg");
}
}
} else {
Expand Down Expand Up @@ -401,8 +396,11 @@ int ActivityListModel::rowCount(const QModelIndex &parent) const
if(parent.isValid()) {
return 0;
}

return _finalList.count();
//MagentaCustomizationV25
if(_finalList.count()<maxVisibleActivities)
return _finalList.count();
else
return maxVisibleActivities;
}

bool ActivityListModel::canFetchMore(const QModelIndex &) const
Expand Down
4 changes: 3 additions & 1 deletion src/gui/tray/activitylistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class ActivityListModel : public QAbstractListModel
};
Q_ENUM(DataRole)

static const int maxVisibleActivities = 30;

enum class ErrorType {
SyncError,
NetworkError,
Expand Down Expand Up @@ -197,7 +199,7 @@ private slots:
bool _displayActions = true;

int _currentItem = 0;
int _maxActivities = 100;
int _maxActivities = 30;
int _maxActivitiesDays = 30;
bool _showMoreActivitiesAvailableEntry = false;

Expand Down
8 changes: 8 additions & 0 deletions src/gui/tray/sortedactivitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ SortedActivityListModel::SortedActivityListModel(QObject *parent)
sort(0, Qt::AscendingOrder);
}

bool SortedActivityListModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
if ( sourceRow < 30)
return true;

return false;
}

bool SortedActivityListModel::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const
{
if (!sourceLeft.isValid() || !sourceRight.isValid()) {
Expand Down
2 changes: 2 additions & 0 deletions src/gui/tray/sortedactivitylistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class SortedActivityListModel : public QSortFilterProxyModel

public:
explicit SortedActivityListModel(QObject *parent = nullptr);
bool filterAcceptsRow(int sourceRow,const QModelIndex &sourceParent) const override;


protected:
[[nodiscard]] bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override;
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if (WIN32)
)

nextcloud_add_test(SyncCfApi)
nextcloud_add_test(CfApiShellExtensionsIPC)
nextcloud_add_test(CfApiShellExtensionsIPC)
target_sources(CfApiShellExtensionsIPCTest PRIVATE "${CMAKE_SOURCE_DIR}/src/libsync/vfs/cfapi/shellext/thumbnailprovideripc.cpp" "${CMAKE_SOURCE_DIR}/src/libsync/vfs/cfapi/shellext/customstateprovideripc.cpp" "${CMAKE_SOURCE_DIR}/src/libsync/vfs/cfapi/shellext/ipccommon.cpp")
elseif(LINUX) # elseif(LINUX OR APPLE)
nextcloud_add_test(SyncXAttr)
Expand Down
14 changes: 7 additions & 7 deletions test/testactivitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ private slots:
model->startFetchJob();
QSignalSpy activitiesJob(model.data(), &TestingALM::activitiesProcessed);
QVERIFY(activitiesJob.wait(3000));
QCOMPARE(model->rowCount(), 50);
QCOMPARE(model->rowCount(), 30);
};

// Test receiving activity from local user action
Expand Down Expand Up @@ -620,7 +620,7 @@ private slots:
QSignalSpy activitiesJob(model.data(), &TestingALM::activitiesProcessed);
QVERIFY(activitiesJob.wait(3000));
// Test the dummy was removed
QCOMPARE(model->rowCount(), 50);
QCOMPARE(model->rowCount(), 30);
}

// Test getting the data from the model
Expand All @@ -632,19 +632,19 @@ private slots:
model->startFetchJob();
QSignalSpy activitiesJob(model.data(), &TestingALM::activitiesProcessed);
QVERIFY(activitiesJob.wait(3000));
QCOMPARE(model->rowCount(), 50);
QCOMPARE(model->rowCount(), 30);

model->addSyncFileItemToActivityList(testSyncFileItemActivity);
QCOMPARE(model->rowCount(), 51);
QCOMPARE(model->rowCount(), 30);

model->addErrorToActivityList(testSyncResultErrorActivity, OCC::ActivityListModel::ErrorType::SyncError);
QCOMPARE(model->rowCount(), 52);
QCOMPARE(model->rowCount(), 30);

model->addIgnoredFileToList(testFileIgnoredActivity);
QCOMPARE(model->rowCount(), 53);
QCOMPARE(model->rowCount(), 30);

model->addNotificationToActivityList(testNotificationActivity);
QCOMPARE(model->rowCount(), 54);
QCOMPARE(model->rowCount(), 30);

// Test all rows for things in common
for (int i = 0; i < model->rowCount(); i++) {
Expand Down
4 changes: 4 additions & 0 deletions theme.qrc.in
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,16 @@
<file>theme/black/user.svg</file>
<file>theme/white/add.svg</file>
<file>theme/black/add.svg</file>
<file>theme/black/add-circle.svg</file>
<file>theme/black/activity.svg</file>
<file>theme/black/bell.svg</file>
<file>theme/black/wizard-talk.svg</file>
<file>theme/black/calendar.svg</file>
<file>theme/black/deck.svg</file>
<file>theme/black/refresh.svg</file>
<file>theme/black/state-info.svg</file>
<file>theme/lock.svg</file>
<file>theme/black/delete.svg</file>
<file>theme/close.svg</file>
<file>theme/black/close.svg</file>
<file>theme/white/close.svg</file>
Expand Down
7 changes: 7 additions & 0 deletions theme/black/add-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions theme/black/delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions theme/black/refresh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion theme/black/state-info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion theme/black/state-offline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 3 additions & 19 deletions theme/colored/talk-bordered.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.