Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorClaudio Cambra <claudio.cambra@gmail.com>2022-03-05 15:44:03 +0300
committerClaudio Cambra <claudio.cambra@gmail.com>2022-03-16 10:38:14 +0300
commit02f3a1aed6e8023b691b74c52300b1c1a3aacb84 (patch)
tree8562b6a9bb1d4dd436037b0c1d54392647308266 /src/gui
parentc94e7595a5d43801c7d1a93cd1b0302dddfae95a (diff)
File activity dialog now works for all file actions activities (e.g. deleted files)
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/fileactivitylistmodel.cpp17
-rw-r--r--src/gui/fileactivitylistmodel.h4
-rw-r--r--src/gui/socketapi/socketapi.cpp2
-rw-r--r--src/gui/socketapi/socketapi.h2
-rw-r--r--src/gui/systray.h2
-rw-r--r--src/gui/tray/ActivityList.qml4
-rw-r--r--src/gui/tray/Window.qml24
-rw-r--r--src/gui/tray/activitydata.h2
-rw-r--r--src/gui/tray/activitylistmodel.cpp11
-rw-r--r--src/gui/tray/activitylistmodel.h3
-rw-r--r--src/gui/tray/usermodel.cpp2
11 files changed, 36 insertions, 37 deletions
diff --git a/src/gui/fileactivitylistmodel.cpp b/src/gui/fileactivitylistmodel.cpp
index 104ff317c..ee7360ef2 100644
--- a/src/gui/fileactivitylistmodel.cpp
+++ b/src/gui/fileactivitylistmodel.cpp
@@ -26,7 +26,7 @@ FileActivityListModel::FileActivityListModel(QObject *parent)
setDisplayActions(false);
}
-void FileActivityListModel::load(AccountState *accountState, const QString &localPath)
+void FileActivityListModel::load(AccountState *accountState, const int objectId)
{
Q_ASSERT(accountState);
if (!accountState || currentlyFetching()) {
@@ -34,18 +34,7 @@ void FileActivityListModel::load(AccountState *accountState, const QString &loca
}
setAccountState(accountState);
- const auto folder = FolderMan::instance()->folderForPath(localPath);
- if (!folder) {
- return;
- }
-
- const auto file = folder->fileFromLocalPath(localPath);
- SyncJournalFileRecord fileRecord;
- if (!folder->journalDb()->getFileRecord(file, &fileRecord) || !fileRecord.isValid()) {
- return;
- }
-
- _fileId = fileRecord._fileId;
+ _objectId = objectId;
slotRefreshActivity();
}
@@ -64,7 +53,7 @@ void FileActivityListModel::startFetchJob()
QUrlQuery params;
params.addQueryItem(QStringLiteral("sort"), QStringLiteral("asc"));
params.addQueryItem(QStringLiteral("object_type"), "files");
- params.addQueryItem(QStringLiteral("object_id"), _fileId);
+ params.addQueryItem(QStringLiteral("object_id"), QString::number(_objectId));
job->addQueryParams(params);
setDoneFetching(true);
setHideOldActivities(true);
diff --git a/src/gui/fileactivitylistmodel.h b/src/gui/fileactivitylistmodel.h
index 421c58128..2c698ddde 100644
--- a/src/gui/fileactivitylistmodel.h
+++ b/src/gui/fileactivitylistmodel.h
@@ -27,12 +27,12 @@ public:
explicit FileActivityListModel(QObject *parent = nullptr);
public slots:
- void load(AccountState *accountState, const QString &fileId);
+ void load(AccountState *accountState, const int objectId);
protected:
void startFetchJob() override;
private:
- QString _fileId;
+ int _objectId;
};
}
diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp
index 6eaa3a6b5..88d8e2852 100644
--- a/src/gui/socketapi/socketapi.cpp
+++ b/src/gui/socketapi/socketapi.cpp
@@ -497,7 +497,7 @@ void SocketApi::broadcastMessage(const QString &msg, bool doWait)
void SocketApi::processFileActivityRequest(const QString &localFile)
{
const auto fileData = FileData::get(localFile);
- emit fileActivityCommandReceived(fileData.serverRelativePath, fileData.localPath);
+ emit fileActivityCommandReceived(fileData.serverRelativePath, fileData.journalRecord().numericFileId().toInt());
}
void SocketApi::processShareRequest(const QString &localFile, SocketListener *listener, ShareDialogStartPage startPage)
diff --git a/src/gui/socketapi/socketapi.h b/src/gui/socketapi/socketapi.h
index 5183985b5..112527bb3 100644
--- a/src/gui/socketapi/socketapi.h
+++ b/src/gui/socketapi/socketapi.h
@@ -64,7 +64,7 @@ public slots:
signals:
void shareCommandReceived(const QString &sharePath, const QString &localPath, ShareDialogStartPage startPage);
- void fileActivityCommandReceived(const QString &sharePath, const QString &localPath);
+ void fileActivityCommandReceived(const QString &objectName, const int objectId);
private slots:
void slotNewConnection();
diff --git a/src/gui/systray.h b/src/gui/systray.h
index 6b63d6797..a4a6cbc64 100644
--- a/src/gui/systray.h
+++ b/src/gui/systray.h
@@ -90,7 +90,7 @@ signals:
void hideWindow();
void showWindow();
void openShareDialog(const QString &sharePath, const QString &localPath);
- void showFileActivityDialog(const QString &sharePath, const QString &localPath);
+ void showFileActivityDialog(const QString &objectName, const int objectId);
public slots:
void slotNewUserSelected();
diff --git a/src/gui/tray/ActivityList.qml b/src/gui/tray/ActivityList.qml
index ced4ad2d6..fe66267f9 100644
--- a/src/gui/tray/ActivityList.qml
+++ b/src/gui/tray/ActivityList.qml
@@ -9,7 +9,7 @@ ScrollView {
property bool isFileActivityList: false
- signal showFileActivity(string displayPath, string absolutePath)
+ signal showFileActivity(string objectName, int objectId)
signal activityItemClicked(int index)
contentWidth: availableWidth
@@ -39,7 +39,7 @@ ScrollView {
flickable: activityList
onClicked: {
if (model.isCurrentUserFileActivity) {
- showFileActivity(model.displayPath, model.absolutePath)
+ showFileActivity(model.objectName, model.objectId)
} else {
activityItemClicked(model.index)
}
diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml
index 262e55920..fdf1d51c6 100644
--- a/src/gui/tray/Window.qml
+++ b/src/gui/tray/Window.qml
@@ -23,13 +23,13 @@ Window {
flags: Systray.useNormalWindow ? Qt.Window : Qt.Dialog | Qt.FramelessWindowHint
- property var fileActivityDialogAbsolutePath: ""
+ property int fileActivityDialogObjectId: -1
readonly property int maxMenuHeight: Style.trayWindowHeight - Style.trayWindowHeaderHeight - 2 * Style.trayWindowBorderWidth
- function openFileActivityDialog(displayPath, absolutePath) {
- fileActivityDialogLoader.displayPath = displayPath
- fileActivityDialogLoader.absolutePath = absolutePath
- fileActivityDialogLoader.refresh()
+ function openFileActivityDialog(objectName, objectId) {
+ fileActivityDialogLoader.objectName = objectName;
+ fileActivityDialogLoader.objectId = objectId;
+ fileActivityDialogLoader.refresh();
}
Component.onCompleted: Systray.forceWindowInit(trayWindow)
@@ -81,8 +81,8 @@ Window {
Systray.setClosed();
}
- function onShowFileActivityDialog(displayPath, absolutePath) {
- openFileActivityDialog(displayPath, absolutePath)
+ function onShowFileActivityDialog(objectName, objectId) {
+ openFileActivityDialog(objectName, objectId)
}
}
@@ -745,7 +745,7 @@ Window {
activeFocusOnTab: true
model: activityModel
onShowFileActivity: {
- openFileActivityDialog(displayPath, absolutePath)
+ openFileActivityDialog(objectName, objectId)
}
onActivityItemClicked: {
model.slotTriggerDefaultAction(index)
@@ -755,18 +755,18 @@ Window {
Loader {
id: fileActivityDialogLoader
- property string displayPath: ""
- property string absolutePath: ""
+ property string objectName: ""
+ property int objectId: -1
function refresh() {
active = true
- item.model.load(activityModel.accountState, absolutePath)
+ item.model.load(activityModel.accountState, objectId)
item.show()
}
active: false
sourceComponent: FileActivityDialog {
- title: qsTr("%1 - File activity").arg(fileActivityDialogLoader.displayPath)
+ title: qsTr("%1 - File activity").arg(fileActivityDialogLoader.objectName)
onClosing: fileActivityDialogLoader.active = false
}
diff --git a/src/gui/tray/activitydata.h b/src/gui/tray/activitydata.h
index 31114e115..49ffd5f3b 100644
--- a/src/gui/tray/activitydata.h
+++ b/src/gui/tray/activitydata.h
@@ -80,7 +80,9 @@ public:
Type _type;
qlonglong _id;
QString _fileAction;
+ int _objectId;
QString _objectType;
+ QString _objectName;
QString _subject;
QString _subjectRich;
QHash<QString, RichSubjectParameter> _subjectRichParameters;
diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp
index ef0546f38..a67f8aa94 100644
--- a/src/gui/tray/activitylistmodel.cpp
+++ b/src/gui/tray/activitylistmodel.cpp
@@ -57,7 +57,6 @@ QHash<int, QByteArray> ActivityListModel::roleNames() const
auto roles = QAbstractListModel::roleNames();
roles[DisplayPathRole] = "displayPath";
roles[PathRole] = "path";
- roles[AbsolutePathRole] = "absolutePath";
roles[DisplayLocationRole] = "displayLocation";
roles[LinkRole] = "link";
roles[MessageRole] = "message";
@@ -69,6 +68,8 @@ QHash<int, QByteArray> ActivityListModel::roleNames() const
roles[ActionsLinksForActionButtonsRole] = "linksForActionButtons";
roles[ActionTextColorRole] = "activityTextTitleColor";
roles[ObjectTypeRole] = "objectType";
+ roles[ObjectIdRole] = "objectId";
+ roles[ObjectNameRole] = "objectName";
roles[PointInTimeRole] = "dateTime";
roles[DisplayActions] = "displayActions";
roles[ShareableRole] = "isShareable";
@@ -179,8 +180,6 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
return getDisplayPath();
case PathRole:
return QFileInfo(getFilePath()).path();
- case AbsolutePathRole:
- return getFilePath();
case DisplayLocationRole:
return displayLocation();
case ActionsLinksRole: {
@@ -239,6 +238,10 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
}
case ObjectTypeRole:
return a._objectType;
+ case ObjectIdRole:
+ return a._objectId;
+ case ObjectNameRole:
+ return a._objectName;
case ActionRole: {
switch (a._type) {
case Activity::ActivityType:
@@ -371,6 +374,8 @@ void ActivityListModel::activitiesReceived(const QJsonDocument &json, int status
const auto activityUser = json.value(QStringLiteral("user")).toString();
a._type = Activity::ActivityType;
a._objectType = json.value(QStringLiteral("object_type")).toString();
+ a._objectId = json.value(QStringLiteral("object_id")).toInt();
+ a._objectName = json.value(QStringLiteral("object_name")).toString();
a._accName = ast->account()->displayName();
a._id = json.value(QStringLiteral("activity_id")).toInt();
a._fileAction = json.value(QStringLiteral("type")).toString();
diff --git a/src/gui/tray/activitylistmodel.h b/src/gui/tray/activitylistmodel.h
index 34c591c2f..126ecc28e 100644
--- a/src/gui/tray/activitylistmodel.h
+++ b/src/gui/tray/activitylistmodel.h
@@ -48,6 +48,8 @@ public:
ActionIconRole = Qt::UserRole + 1,
AccountRole,
ObjectTypeRole,
+ ObjectIdRole,
+ ObjectNameRole,
ActionsLinksRole,
ActionsLinksContextMenuRole,
ActionsLinksForActionButtonsRole,
@@ -57,7 +59,6 @@ public:
MessageRole,
DisplayPathRole,
PathRole,
- AbsolutePathRole,
DisplayLocationRole, // Provides the display path to a file's parent folder, relative to Nextcloud root
LinkRole,
PointInTimeRole,
diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp
index 44e9f1a0a..8adae3682 100644
--- a/src/gui/tray/usermodel.cpp
+++ b/src/gui/tray/usermodel.cpp
@@ -505,6 +505,8 @@ void User::processCompletedSyncItem(const Folder *folder, const SyncFileItemPtr
activity._file = item->_file;
activity._folder = folder->alias();
activity._fileAction = "";
+ activity._objectId = item->_fileId.toInt();
+ activity._objectName = item->_file;
const auto fileName = QFileInfo(item->_originalFile).fileName();