Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0bdab1e
Add FileTag QML component
claucambra Apr 10, 2023
f763bd0
Add a FileTagModel
claucambra Apr 10, 2023
84c8392
Get account and relativeserverpath in constructor for FileTagModel
claucambra Apr 11, 2023
9cc241b
Add capability for FileTagModel to fetch tags
claucambra Apr 11, 2023
49b5fb3
Implement FileTagModel QAbstractListModel methods
claucambra Apr 11, 2023
213e374
Expose account and serverRelativePath of FileTagModel as QPROPERTYs
claucambra Apr 11, 2023
c6d29e7
Add ability to limit maximum amount of tags displayed
claucambra Apr 11, 2023
791eb87
Instantiate FileTagModel in FileDetails
claucambra Apr 11, 2023
a3fc467
Simplify FileTag component
claucambra Apr 11, 2023
cb8cab6
Display filetags in file details window
claucambra Apr 11, 2023
65e7f6d
Simplify file tag model updating in filedetails, only require folder …
claucambra Apr 12, 2023
e2bd9e6
Fix layout of tags with differing sizes and oversized tags
claucambra Apr 12, 2023
06b3dc9
Modernise PropfindJob with new for and const auto
claucambra Apr 19, 2023
43bcecd
Simplify Propfind XML parsing using QDomDocument instead of complex Q…
claucambra Apr 20, 2023
9324fe0
Use constexpr in networkjobs notModifiedStatusCode
claucambra Apr 20, 2023
a386d8f
Do not use magic string for propfind prop element tag name
claucambra Apr 20, 2023
6e9fed0
Clean up includes in networkjobs
claucambra Apr 20, 2023
b5cc4b4
Extract propfind result data processing into separate method
claucambra Apr 20, 2023
29c1713
Properly parse tags in propfind request
claucambra Apr 20, 2023
bfb720f
Extract propfind tag xml node processing into separate method
claucambra Apr 20, 2023
045541d
Implement support for system tags in propfindjob
claucambra Apr 20, 2023
b79a038
Add support for system tags in filetagmodel
claucambra Apr 20, 2023
955f4de
Add initial testing setup for file tag model
claucambra Apr 24, 2023
89d7e17
Add FakePropfindReply that accepts raw QByteArray as payload
claucambra Apr 24, 2023
ccb07af
Provide different propfind replies depending on request props in test…
claucambra Apr 24, 2023
6c68341
Add test for tags in filetagmodel
claucambra Apr 24, 2023
1bab57b
Notify change in tags when maxTags set in filetagmodel
claucambra Apr 25, 2023
73b94bc
Add test for maxTags in FileTagModel
claucambra Apr 25, 2023
ce22c40
Test important properties in testfiletagmodel
claucambra Apr 25, 2023
30830b4
Add overflow tag string property to filetagmodel which stringifies om…
claucambra Apr 27, 2023
b440e30
Display tooltip showing names of overflowing tags in FileDetailsPage'…
claucambra Apr 27, 2023
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
1 change: 1 addition & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<file>src/gui/filedetails/FileDetailsPage.qml</file>
<file>src/gui/filedetails/FileDetailsView.qml</file>
<file>src/gui/filedetails/FileDetailsWindow.qml</file>
<file>src/gui/filedetails/FileTag.qml</file>
<file>src/gui/filedetails/NCInputTextEdit.qml</file>
<file>src/gui/filedetails/NCInputTextField.qml</file>
<file>src/gui/filedetails/NCTabButton.qml</file>
Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ set(client_SRCS
editlocallyjob.cpp
editlocallymanager.h
editlocallymanager.cpp
filetagmodel.h
filetagmodel.cpp
folder.h
folder.cpp
foldercreationdialog.h
Expand Down
58 changes: 57 additions & 1 deletion src/gui/filedetails/FileDetailsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,19 @@ Page {
Layout.topMargin: root.topPadding

columns: root.showCloseButton ? 3 : 2
rows: showFileLockedString ? 3 : 2
rows: {
let rows = 2;

if (showFileLockedString) {
rows++;
}

if (root.fileDetails.fileTagModel.totalTags > 0) {
rows++;
}

return rows;
}

rowSpacing: Style.standardSpacing / 2
columnSpacing: Style.standardSpacing
Expand Down Expand Up @@ -154,6 +166,50 @@ Page {
wrapMode: Text.Wrap
visible: headerGridLayout.showFileLockedString
}

Row {
id: tagRow

Layout.fillWidth: true
Layout.rightMargin: headerGridLayout.textRightMargin

Repeater {
id: tagRepeater

readonly property var fileTagModel: root.fileDetails.fileTagModel
readonly property int maxTags: 3

model: fileTagModel
delegate: FileTag {
readonly property int availableLayoutSpace: tagRow.width - tagRow.spacing - overflowTag.width
readonly property int maxWidth: (availableLayoutSpace / tagRepeater.maxTags) - tagRow.spacing

width: Math.min(maxWidth, implicitWidth)
text: model.display
}

Component.onCompleted: fileTagModel.maxTags = 3
}

FileTag {
id: overflowTag

readonly property int totalFileTags: tagRepeater.fileTagModel.totalTags
readonly property int maxFileTags: tagRepeater.fileTagModel.maxTags

visible: totalFileTags > maxFileTags
text: "+" + String(totalFileTags - maxFileTags)

HoverHandler {
id: hoverHandler
}

NCToolTip {
visible: hoverHandler.hovered
text: tagRepeater.fileTagModel.overflowTagsString
}
}
}
}

TabBar {
Expand Down
33 changes: 33 additions & 0 deletions src/gui/filedetails/FileTag.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2023 by Claudio Cambra <claudio.cambra@nextcloud.com>
*
* 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.
*/

import QtQuick 2.15

import Style 1.0
import "../tray"

EnforcedPlainTextLabel {
id: internalLabel

background: Rectangle {
border.color: Style.lightHover
border.width: Style.normalBorderWidth
radius: Style.veryRoundedButtonRadius
color: "transparent"
}

color: Style.ncSecondaryTextColor
elide: Text.ElideRight
padding: Style.smallSpacing
}
19 changes: 19 additions & 0 deletions src/gui/filedetails/filedetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <QDateTime>

#include "accountstate.h"
#include "filedetails.h"
#include "folderman.h"

Expand Down Expand Up @@ -71,6 +72,7 @@ void FileDetails::setLocalPath(const QString &localPath)

_filelockState = _fileRecord._lockstate;
updateLockExpireString();
updateFileTagModel(folder);

Q_EMIT fileChanged();
}
Expand Down Expand Up @@ -153,4 +155,21 @@ bool FileDetails::isFolder() const
return _fileInfo.isDir();
}

FileTagModel *FileDetails::fileTagModel() const
{
return _fileTagModel.get();
}

void FileDetails::updateFileTagModel(const Folder * const folder)
{
Q_ASSERT(folder);
const auto account = folder->accountState()->account();
Q_ASSERT(account);

const auto serverRelPath = QString(folder->remotePathTrailingSlash() + name());

_fileTagModel = std::make_unique<FileTagModel>(serverRelPath, account);
Q_EMIT fileTagModelChanged();
}

} // namespace OCC
10 changes: 10 additions & 0 deletions src/gui/filedetails/filedetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@

#include "common/syncjournalfilerecord.h"

#include "gui/filetagmodel.h"

namespace OCC {

class Folder;

class FileDetails : public QObject
{
Q_OBJECT
Expand All @@ -33,6 +37,7 @@ class FileDetails : public QObject
Q_PROPERTY(QString iconUrl READ iconUrl NOTIFY fileChanged)
Q_PROPERTY(QString lockExpireString READ lockExpireString NOTIFY lockExpireStringChanged)
Q_PROPERTY(bool isFolder READ isFolder NOTIFY isFolderChanged)
Q_PROPERTY(FileTagModel* fileTagModel READ fileTagModel NOTIFY fileTagModelChanged)

public:
explicit FileDetails(QObject *parent = nullptr);
Expand All @@ -44,6 +49,7 @@ class FileDetails : public QObject
[[nodiscard]] QString iconUrl() const;
[[nodiscard]] QString lockExpireString() const;
[[nodiscard]] bool isFolder() const;
[[nodiscard]] FileTagModel *fileTagModel() const;

public slots:
void setLocalPath(const QString &localPath);
Expand All @@ -53,10 +59,12 @@ public slots:
void fileChanged();
void lockExpireStringChanged();
void isFolderChanged();
void fileTagModelChanged();

private slots:
void refreshFileDetails();
void updateLockExpireString();
void updateFileTagModel(const OCC::Folder * const folder);

private:
QString _localPath;
Expand All @@ -70,6 +78,8 @@ private slots:
QTimer _filelockStateUpdateTimer;

QLocale _locale;

std::unique_ptr<FileTagModel> _fileTagModel;
};

} // namespace OCC
Loading