diff --git a/src/apps/qml/AddUserDialog.qml b/src/apps/qml/AddUserDialog.qml index 0a736960..cb495ce5 100644 --- a/src/apps/qml/AddUserDialog.qml +++ b/src/apps/qml/AddUserDialog.qml @@ -1,98 +1,102 @@ /* Copyright (c) 2017-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.9 import QtQuick.Layouts 1.12 import QtQuick.Controls 2.5 as QQC2 import QtQuick.Window 2.2 import KDE.Ruqola.RocketChatAccount 1.0 import KDE.Ruqola.UserCompleterFilterModelProxy 1.0 import org.kde.kirigami 2.7 as Kirigami QQC2.Dialog { id: addUserDialog property QtObject completerModel signal searchUserName(string pattern) signal addUser(string userId, string rid, string channelType) property QtObject roomInfo property string roomId: "" title: i18n("Add Users") standardButtons: QQC2.Dialog.Close width: parent.width * 9 / 10 height: parent.height * 9 / 10 anchors.centerIn: parent modal: true focus: true function initializeAndOpen() { username.text = ""; + completerModel.clear(); username.forceActiveFocus(); open(); } contentItem: ColumnLayout { LineEditWithClearButton { id: username placeholderText: i18n("Search User...") Layout.fillWidth: true onTextChanged: { addUserDialog.searchUserName(username.text) } } ListView { id: listview Layout.fillWidth: true Layout.fillHeight: true clip: true model: completerModel - delegate: + delegate: Kirigami.BasicListItem { + reserveSpaceForIcon: false + reserveSpaceForLabel: false RowLayout { - Kirigami.Icon { - source: "list-add" - height: Kirigami.Units.iconSizes.medium - width: height - MouseArea { - anchors.fill: parent - onClicked: { - addUserDialog.addUser(userid, roomId, roomInfo.channelType) + Kirigami.Icon { + source: "list-add" + height: Kirigami.Units.iconSizes.medium + width: height + MouseArea { + anchors.fill: parent + onClicked: { + addUserDialog.addUser(userid, roomId, roomInfo.channelType) + } } } - } - Kirigami.Icon { - source: iconstatus - height: Kirigami.Units.iconSizes.medium - width: height - } - QQC2.Label { - text: username + Kirigami.Icon { + source: iconstatus + height: Kirigami.Units.iconSizes.medium + width: height + } + QQC2.Label { + text: username + } } } } } } diff --git a/src/apps/qml/PrivateChannelInfoDialog.qml b/src/apps/qml/PrivateChannelInfoDialog.qml index 5d3fbe32..5613199f 100644 --- a/src/apps/qml/PrivateChannelInfoDialog.qml +++ b/src/apps/qml/PrivateChannelInfoDialog.qml @@ -1,65 +1,68 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.9 import QtQuick.Layouts 1.12 import QtQuick.Controls 2.5 as QQC2 import QtQuick.Window 2.2 import KDE.Ruqola.DebugCategory 1.0 import KDE.Ruqola.RocketChatAccount 1.0 import "common" QQC2.Dialog { id: privateChannelInfoDlg property QtObject roomInfo signal blockUser(string rid, bool block) title: i18n("Info About this user") standardButtons: QQC2.Dialog.Close modal: true focus: true width: parent.width * 9 / 10 height: parent.height * 9 / 10 anchors.centerIn: parent function initializeAndOpen() { avatarRect.avatarurl = appid.rocketChatAccount.avatarUrlFromDirectChannel(roomInfo.rid) open(); } contentItem: ColumnLayout { AvatarImage { id: avatarRect implicitHeight: 160 implicitWidth: 160 } QQC2.Button { id: blockUnblockUser Layout.fillWidth: true text: roomInfo === null ? "" : (roomInfo.blocker ? i18n("Unblock user") : i18n("Block user")) onClicked: { privateChannelInfoDialog.blockUser(roomInfo.rid, !roomInfo.blocker) } } + Item { + Layout.fillHeight: true + } } } diff --git a/src/ruqolacore/model/usercompleterfilterproxymodel.cpp b/src/ruqolacore/model/usercompleterfilterproxymodel.cpp index 2e28000f..0181ab90 100644 --- a/src/ruqolacore/model/usercompleterfilterproxymodel.cpp +++ b/src/ruqolacore/model/usercompleterfilterproxymodel.cpp @@ -1,57 +1,62 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "usercompleterfilterproxymodel.h" #include "usercompletermodel.h" UserCompleterFilterProxyModel::UserCompleterFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent) { setDynamicSortFilter(true); setFilterCaseSensitivity(Qt::CaseInsensitive); setFilterRole(UserCompleterModel::UserName); sort(0); } UserCompleterFilterProxyModel::~UserCompleterFilterProxyModel() { } QHash UserCompleterFilterProxyModel::roleNames() const { if (QAbstractItemModel *source = sourceModel()) { return source->roleNames(); } return QHash(); } +void UserCompleterFilterProxyModel::clear() +{ + return static_cast(sourceModel())->clear(); +} + bool UserCompleterFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { if (!sourceModel()) { return false; } if (left.isValid() && right.isValid()) { const QString leftString = sourceModel()->data(left, UserCompleterModel::UserName).toString(); const QString rightString = sourceModel()->data(right, UserCompleterModel::UserName).toString(); return QString::localeAwareCompare(leftString, rightString) < 0; } else { return false; } } diff --git a/src/ruqolacore/model/usercompleterfilterproxymodel.h b/src/ruqolacore/model/usercompleterfilterproxymodel.h index 30f30c7d..a3db799f 100644 --- a/src/ruqolacore/model/usercompleterfilterproxymodel.h +++ b/src/ruqolacore/model/usercompleterfilterproxymodel.h @@ -1,40 +1,41 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef USERCOMPLETERMODELFILTERMODELPROXY_H #define USERCOMPLETERMODELFILTERMODELPROXY_H #include "libruqola_private_export.h" #include class LIBRUQOLACORE_TESTS_EXPORT UserCompleterFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT public: explicit UserCompleterFilterProxyModel(QObject *parent = nullptr); ~UserCompleterFilterProxyModel() override; Q_REQUIRED_RESULT QHash roleNames() const override; + Q_INVOKABLE void clear(); protected: bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; }; #endif // USERCOMPLETERMODELFILTERMODELPROXY_H