Move more stuff to settings module
This commit is contained in:
@@ -31,6 +31,8 @@ ecm_add_qml_module(Settings GENERATE_PLUGIN_SOURCE
|
||||
RoomGeneralPage.qml
|
||||
RoomSecurityPage.qml
|
||||
ColorScheme.qml
|
||||
ConfirmDeactivateAccountDialog.qml
|
||||
ConfirmEncryptionDialog.qml
|
||||
DevicesCard.qml
|
||||
DeviceDelegate.qml
|
||||
EmoticonFormCard.qml
|
||||
@@ -38,6 +40,9 @@ ecm_add_qml_module(Settings GENERATE_PLUGIN_SOURCE
|
||||
IgnoredUsersDialog.qml
|
||||
NotificationRuleItem.qml
|
||||
PasswordSheet.qml
|
||||
PowerLevelDialog.qml
|
||||
SelectParentDialog.qml
|
||||
SelectSpacesDialog.qml
|
||||
ThemeRadioButton.qml
|
||||
ThreePIdCard.qml
|
||||
ImportKeysDialog.qml
|
||||
@@ -54,6 +59,7 @@ ecm_add_qml_module(Settings GENERATE_PLUGIN_SOURCE
|
||||
models/emoticonfiltermodel.cpp
|
||||
models/permissionsmodel.cpp
|
||||
models/pushrulemodel.cpp
|
||||
models/roomsortparametermodel.cpp
|
||||
models/threepidmodel.cpp
|
||||
)
|
||||
|
||||
|
||||
52
src/settings/ConfirmDeactivateAccountDialog.qml
Normal file
52
src/settings/ConfirmDeactivateAccountDialog.qml
Normal file
@@ -0,0 +1,52 @@
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls as QQC2
|
||||
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.neochat
|
||||
|
||||
Kirigami.PromptDialog {
|
||||
id: root
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
title: i18nc("@title:dialog", "Confirm Account Deactivation")
|
||||
subtitle: i18n("Your account will be permanently disabled.\nThis cannot be undone.\nYour Matrix ID will not be available for new accounts.\nYour messages will stay available.")
|
||||
|
||||
dialogType: Kirigami.PromptDialog.Warning
|
||||
|
||||
mainItem: ColumnLayout {
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: passwordField
|
||||
label: i18nc("@label:textbox", "Password")
|
||||
echoMode: TextInput.Password
|
||||
horizontalPadding: 0
|
||||
bottomPadding: 0
|
||||
}
|
||||
|
||||
FormCard.FormCheckDelegate {
|
||||
id: eraseDelegate
|
||||
text: i18nc("@label:checkbox", "Erase Data")
|
||||
description: i18nc("@info", "Request your server to delete as much user data as possible.")
|
||||
visible: connection.canEraseData
|
||||
}
|
||||
}
|
||||
|
||||
footer: QQC2.DialogButtonBox {
|
||||
standardButtons: QQC2.Dialog.Cancel
|
||||
|
||||
QQC2.Button {
|
||||
text: i18n("Deactivate account")
|
||||
icon.name: "emblem-warning"
|
||||
enabled: passwordField.text.length > 0
|
||||
onClicked: {
|
||||
root.connection.deactivateAccount(passwordField.text, eraseDelegate.checked);
|
||||
root.closeDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
src/settings/ConfirmEncryptionDialog.qml
Normal file
36
src/settings/ConfirmEncryptionDialog.qml
Normal file
@@ -0,0 +1,36 @@
|
||||
// SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
|
||||
// SPDX-FileCopyrightText: 2022 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
Kirigami.PromptDialog {
|
||||
id: root
|
||||
|
||||
title: i18nc("@title:dialog", "Activate Encryption")
|
||||
subtitle: i18n("It will not be possible to deactivate the encryption after it is enabled.")
|
||||
dialogType: Kirigami.PromptDialog.Warning
|
||||
|
||||
property NeoChatRoom room
|
||||
|
||||
onRejected: {
|
||||
root.close();
|
||||
}
|
||||
|
||||
footer: QQC2.DialogButtonBox {
|
||||
standardButtons: QQC2.Dialog.Cancel
|
||||
|
||||
QQC2.Button {
|
||||
text: i18n("Activate Encryption")
|
||||
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
|
||||
onClicked: {
|
||||
root.room.activateEncryption();
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
src/settings/PowerLevelDialog.qml
Normal file
52
src/settings/PowerLevelDialog.qml
Normal file
@@ -0,0 +1,52 @@
|
||||
// SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
Kirigami.Dialog {
|
||||
id: root
|
||||
title: i18nc("@title", "Edit User Power Level")
|
||||
|
||||
property NeoChatRoom room
|
||||
property var userId
|
||||
property int powerLevel
|
||||
|
||||
width: Kirigami.Units.gridUnit * 24
|
||||
|
||||
standardButtons: QQC2.Dialog.NoButton
|
||||
|
||||
onOpened: {
|
||||
if (root.opened) {
|
||||
powerLevelComboBox.currentIndex = powerLevelComboBox.indexOfValue(root.powerLevel);
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
FormCard.FormComboBoxDelegate {
|
||||
id: powerLevelComboBox
|
||||
|
||||
text: i18n("New power level")
|
||||
model: PowerLevelModel {}
|
||||
textRole: "name"
|
||||
valueRole: "value"
|
||||
}
|
||||
}
|
||||
customFooterActions: [
|
||||
Kirigami.Action {
|
||||
text: i18n("Confirm")
|
||||
icon.name: "dialog-ok"
|
||||
onTriggered: {
|
||||
root.room.setUserPowerLevel(root.userId, powerLevelComboBox.currentValue);
|
||||
root.close();
|
||||
root.destroy();
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
177
src/settings/SelectParentDialog.qml
Normal file
177
src/settings/SelectParentDialog.qml
Normal file
@@ -0,0 +1,177 @@
|
||||
// SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
import org.kde.kirigamiaddons.labs.components as Components
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
/**
|
||||
* @brief A dialog to select a parent space to add to a given room.
|
||||
*/
|
||||
Kirigami.Dialog {
|
||||
id: root
|
||||
|
||||
/**
|
||||
* @brief The current room that a parent is being selected for.
|
||||
*/
|
||||
required property NeoChatRoom room
|
||||
|
||||
title: i18nc("@title", "Select new official parent")
|
||||
|
||||
width: Math.min(applicationWindow().width, Kirigami.Units.gridUnit * 24)
|
||||
leftPadding: 0
|
||||
rightPadding: 0
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
|
||||
standardButtons: Kirigami.Dialog.Cancel
|
||||
customFooterActions: [
|
||||
Kirigami.Action {
|
||||
enabled: chosenRoomDelegate.visible && root.room.canModifyParent(chosenRoomDelegate.roomId)
|
||||
text: i18n("OK")
|
||||
icon.name: "dialog-ok"
|
||||
onTriggered: {
|
||||
root.room.addParent(chosenRoomDelegate.roomId, makeCanonicalCheck.checked, existingOfficialCheck.checked);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
spacing: 0
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: !chosenRoomDelegate.visible
|
||||
text: i18nc("@action:button", "Pick room")
|
||||
onClicked: {
|
||||
let dialog = QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ExploreRoomsPage'), {
|
||||
connection: root.room.connection,
|
||||
showOnlySpaces: true,
|
||||
showOnlySpacesButton: false
|
||||
}, {
|
||||
title: i18nc("@title", "Choose Parent Space")
|
||||
});
|
||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||
chosenRoomDelegate.roomId = roomId;
|
||||
chosenRoomDelegate.displayName = displayName;
|
||||
chosenRoomDelegate.avatarUrl = avatarUrl;
|
||||
chosenRoomDelegate.alias = alias;
|
||||
chosenRoomDelegate.topic = topic;
|
||||
chosenRoomDelegate.memberCount = memberCount;
|
||||
chosenRoomDelegate.isJoined = isJoined;
|
||||
chosenRoomDelegate.visible = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
FormCard.AbstractFormDelegate {
|
||||
id: chosenRoomDelegate
|
||||
property string roomId
|
||||
property string displayName
|
||||
property url avatarUrl
|
||||
property string alias
|
||||
property string topic
|
||||
property int memberCount
|
||||
property bool isJoined
|
||||
|
||||
visible: false
|
||||
|
||||
contentItem: RowLayout {
|
||||
Components.Avatar {
|
||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
|
||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||
|
||||
source: chosenRoomDelegate.avatarUrl
|
||||
name: chosenRoomDelegate.displayName
|
||||
}
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Kirigami.Heading {
|
||||
Layout.fillWidth: true
|
||||
level: 4
|
||||
text: chosenRoomDelegate.displayName
|
||||
font.bold: true
|
||||
textFormat: Text.PlainText
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
QQC2.Label {
|
||||
visible: chosenRoomDelegate.isJoined
|
||||
text: i18n("Joined")
|
||||
color: Kirigami.Theme.linkColor
|
||||
}
|
||||
}
|
||||
QQC2.Label {
|
||||
Layout.fillWidth: true
|
||||
visible: text
|
||||
text: chosenRoomDelegate.topic ? chosenRoomDelegate.topic.replace(/(\r\n\t|\n|\r\t)/gm, " ") : ""
|
||||
textFormat: Text.PlainText
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Kirigami.Icon {
|
||||
source: "user"
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
implicitHeight: Kirigami.Units.iconSizes.small
|
||||
implicitWidth: Kirigami.Units.iconSizes.small
|
||||
}
|
||||
QQC2.Label {
|
||||
text: chosenRoomDelegate.memberCount + " " + (chosenRoomDelegate.alias ?? chosenRoomDelegate.roomId)
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
elide: Text.ElideRight
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
let dialog = pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ExploreRoomsPage'), {
|
||||
connection: root.room.connection,
|
||||
showOnlySpaces: true,
|
||||
showOnlySpacesButton: false
|
||||
}, {
|
||||
title: i18nc("@title", "Explore Rooms")
|
||||
});
|
||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||
chosenRoomDelegate.roomId = roomId;
|
||||
chosenRoomDelegate.displayName = displayName;
|
||||
chosenRoomDelegate.avatarUrl = avatarUrl;
|
||||
chosenRoomDelegate.alias = alias;
|
||||
chosenRoomDelegate.topic = topic;
|
||||
chosenRoomDelegate.memberCount = memberCount;
|
||||
chosenRoomDelegate.isJoined = isJoined;
|
||||
chosenRoomDelegate.visible = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
FormCard.FormCheckDelegate {
|
||||
id: existingOfficialCheck
|
||||
property NeoChatRoom space: root.room.connection.room(chosenRoomDelegate.roomId)
|
||||
text: i18n("Set this room as a child of the space %1", space?.displayName ?? "")
|
||||
checked: enabled
|
||||
|
||||
enabled: chosenRoomDelegate.visible && space && space.canSendState("m.space.child")
|
||||
}
|
||||
FormCard.FormTextDelegate {
|
||||
visible: chosenRoomDelegate.visible && !root.room.canModifyParent(chosenRoomDelegate.roomId)
|
||||
text: existingOfficialCheck.space ? (existingOfficialCheck.space.isSpace ? i18n("You do not have a high enough privilege level in the parent to set this state") : i18n("The selected room is not a space")) : i18n("You do not have the privileges to complete this action")
|
||||
textItem.color: Kirigami.Theme.negativeTextColor
|
||||
}
|
||||
FormCard.FormCheckDelegate {
|
||||
id: makeCanonicalCheck
|
||||
text: i18n("Make this space the canonical parent")
|
||||
checked: enabled
|
||||
|
||||
enabled: chosenRoomDelegate.visible
|
||||
}
|
||||
}
|
||||
}
|
||||
78
src/settings/SelectSpacesDialog.qml
Normal file
78
src/settings/SelectSpacesDialog.qml
Normal file
@@ -0,0 +1,78 @@
|
||||
// SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
import org.kde.kirigamiaddons.labs.components as Components
|
||||
|
||||
import Quotient
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
Kirigami.Dialog {
|
||||
id: root
|
||||
|
||||
/**
|
||||
* @brief The current room this dialog is opened for.
|
||||
*/
|
||||
required property NeoChatRoom room
|
||||
|
||||
/**
|
||||
* @brief The current list of space IDs that members of can join this room.
|
||||
*/
|
||||
property list<string> restrictedIds: room.restrictedIds
|
||||
|
||||
parent: applicationWindow().overlay
|
||||
|
||||
leftPadding: 0
|
||||
rightPadding: 0
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
|
||||
width: Math.min(applicationWindow().width, Kirigami.Units.gridUnit * 24)
|
||||
title: i18nc("@title", "Select Spaces")
|
||||
|
||||
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
|
||||
onAccepted: {
|
||||
let ids = [];
|
||||
for (var i in spaceGroup.buttons) {
|
||||
if (spaceGroup.buttons[i].checked) {
|
||||
ids.push(spaceGroup.buttons[i].modelData.id);
|
||||
}
|
||||
}
|
||||
root.room.setJoinRule(JoinRule.Restricted, ids);
|
||||
}
|
||||
|
||||
QQC2.ButtonGroup {
|
||||
id: spaceGroup
|
||||
exclusive: false
|
||||
}
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
spacing: 0
|
||||
Repeater {
|
||||
model: root.room.parentObjects(true)
|
||||
|
||||
delegate: FormCard.FormCheckDelegate {
|
||||
required property var modelData
|
||||
|
||||
text: modelData.displayName
|
||||
description: modelData.canonicalAlias
|
||||
checked: root.restrictedIds.includes(modelData.id)
|
||||
QQC2.ButtonGroup.group: spaceGroup
|
||||
|
||||
leading: Components.Avatar {
|
||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
|
||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||
|
||||
source: modelData.avatarUrl.toString().length > 0 ? connection.makeMediaUrl(modelData.avatarUrl) : ""
|
||||
name: modelData.displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
108
src/settings/models/roomsortparametermodel.cpp
Normal file
108
src/settings/models/roomsortparametermodel.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
#include "roomsortparametermodel.h"
|
||||
|
||||
#include "enums/roomsortparameter.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
RoomSortParameterModel::RoomSortParameterModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
m_currentParameters = RoomSortParameter::currentParameterList();
|
||||
}
|
||||
|
||||
RoomSortParameterModel::RoomSortParameterModel(QList<RoomSortParameter::Parameter> parameters, QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
m_currentParameters = parameters;
|
||||
}
|
||||
|
||||
QList<int> RoomSortParameterModel::currentParameterList() const
|
||||
{
|
||||
QList<int> intList;
|
||||
std::transform(m_currentParameters.constBegin(), m_currentParameters.constEnd(), std::back_inserter(intList), [](RoomSortParameter::Parameter param) {
|
||||
return static_cast<int>(param);
|
||||
});
|
||||
return intList;
|
||||
}
|
||||
|
||||
QVariant RoomSortParameterModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.row() < 0 || index.row() >= rowCount()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto parameter = m_currentParameters.at(index.row());
|
||||
if (role == Name) {
|
||||
return RoomSortParameter::parameterName(parameter);
|
||||
}
|
||||
if (role == Description) {
|
||||
return RoomSortParameter::parameterDescription(parameter);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
int RoomSortParameterModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return m_currentParameters.size();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> RoomSortParameterModel::roleNames() const
|
||||
{
|
||||
return {
|
||||
{Name, "name"},
|
||||
{Description, "description"},
|
||||
};
|
||||
}
|
||||
|
||||
void RoomSortParameterModel::addParameter(RoomSortParameter::Parameter parameter)
|
||||
{
|
||||
if (m_currentParameters.contains(parameter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginInsertRows({}, rowCount(), rowCount());
|
||||
m_currentParameters.append(parameter);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void RoomSortParameterModel::removeRow(int row)
|
||||
{
|
||||
if (rowCount() <= 1 || row < 0 || row >= rowCount()) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginRemoveRows({}, row, row);
|
||||
m_currentParameters.remove(row);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
void RoomSortParameterModel::moveRowUp(int row)
|
||||
{
|
||||
if (row < 1 || row >= rowCount()) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginMoveRows({}, row, row, {}, row - 1);
|
||||
m_currentParameters.move(row, row - 1);
|
||||
endMoveRows();
|
||||
}
|
||||
|
||||
void RoomSortParameterModel::moveRowDown(int row)
|
||||
{
|
||||
if (row < 0 || row >= rowCount() - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginMoveRows({}, row, row, {}, row + 2);
|
||||
m_currentParameters.move(row, row + 1);
|
||||
endMoveRows();
|
||||
}
|
||||
|
||||
RoomSortParameterModel *RoomSortParameterModel::allParameterModel() const
|
||||
{
|
||||
return new RoomSortParameterModel(RoomSortParameter::allParameterList());
|
||||
}
|
||||
98
src/settings/models/roomsortparametermodel.h
Normal file
98
src/settings/models/roomsortparametermodel.h
Normal file
@@ -0,0 +1,98 @@
|
||||
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QQmlEngine>
|
||||
|
||||
#include <KLazyLocalizedString>
|
||||
#include <qlist.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
#include "enums/roomsortparameter.h"
|
||||
|
||||
/**
|
||||
* @class RoomSortParameterModel
|
||||
*
|
||||
* This model is used to visualize and modify the current sorting priorities.
|
||||
*/
|
||||
class RoomSortParameterModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
|
||||
/**
|
||||
* @brief The current list of sorting paramters as an int list.
|
||||
*/
|
||||
Q_PROPERTY(QList<int> currentParameterList READ currentParameterList NOTIFY currentParameterListChanged)
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Defines the model roles.
|
||||
*/
|
||||
enum Roles {
|
||||
Name = Qt::DisplayRole, /**< The name of the sort parameter. */
|
||||
Description, /**< The description of the sort parameter. */
|
||||
};
|
||||
Q_ENUM(Roles)
|
||||
|
||||
explicit RoomSortParameterModel(QObject *parent = nullptr);
|
||||
explicit RoomSortParameterModel(QList<RoomSortParameter::Parameter> parameters, QObject *parent = nullptr);
|
||||
|
||||
QList<int> currentParameterList() const;
|
||||
|
||||
/**
|
||||
* @brief Get the given role value at the given index.
|
||||
*
|
||||
* @sa QAbstractItemModel::data
|
||||
*/
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
/**
|
||||
* @brief Number of rows in the model.
|
||||
*
|
||||
* @sa QAbstractItemModel::rowCount
|
||||
*/
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* @brief Returns a mapping from Role enum values to role names.
|
||||
*
|
||||
* @sa EventRoles, QAbstractItemModel::roleNames()
|
||||
*/
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
/**
|
||||
* @brief Add the given parameter to the model.
|
||||
*
|
||||
* If the Parameter is already in the model nothing will happen.
|
||||
*/
|
||||
Q_INVOKABLE void addParameter(RoomSortParameter::Parameter parameter);
|
||||
|
||||
/**
|
||||
* @brief Remove the given row from the model.
|
||||
*/
|
||||
Q_INVOKABLE void removeRow(int row);
|
||||
|
||||
/**
|
||||
* @brief Move the given row up one.
|
||||
*/
|
||||
Q_INVOKABLE void moveRowUp(int row);
|
||||
|
||||
/**
|
||||
* @brief Move the given row down one.
|
||||
*/
|
||||
Q_INVOKABLE void moveRowDown(int row);
|
||||
|
||||
/**
|
||||
* @brief Return a RoomSortParameterModel with all available parameters.
|
||||
*/
|
||||
Q_INVOKABLE RoomSortParameterModel *allParameterModel() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void currentParameterListChanged();
|
||||
|
||||
private:
|
||||
QList<RoomSortParameter::Parameter> m_currentParameters;
|
||||
};
|
||||
Reference in New Issue
Block a user