diff --git a/src/apps/qml/ShowDiscussionsInRoomDialog.qml b/src/apps/qml/ShowDiscussionsInRoomDialog.qml index 5fdd2dfe..a7bcdab6 100644 --- a/src/apps/qml/ShowDiscussionsInRoomDialog.qml +++ b/src/apps/qml/ShowDiscussionsInRoomDialog.qml @@ -1,119 +1,120 @@ /* Copyright (c) 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.Layouts 1.12 import QtQuick.Controls 2.5 as QQC2 import QtQuick.Window 2.2 import QtQuick 2.9 import org.kde.kirigami 2.7 as Kirigami QQC2.Dialog { id: showDiscussionsInRoomDialog title: i18n("Discussions") signal openDiscussion(string discussionId) property QtObject discussionsModel property string roomId x: parent.width / 2 - width / 2 y: parent.height / 2 - height / 2 modal: true focus: true standardButtons: QQC2.Dialog.Close function initializeAndOpen() { + discussionsModel.clearFilter(); searchField.text = ""; searchField.forceActiveFocus(); open(); } ColumnLayout { LineEditWithClearButton { id: searchField placeholderText: i18n("Search Discussions...") Layout.fillWidth: true onTextChanged: { discussionsModel.setFilterString(text); } } QQC2.Label { text: listview.count === 0 ? i18n("No Discussion found") : "" Component.onCompleted: { font.italic = true font.bold = true } } ListView { id: listview width: 400; height: 200 clip: true // Scrollars QQC2.ScrollIndicator.vertical: QQC2.ScrollIndicator { } QQC2.ScrollIndicator.horizontal: QQC2.ScrollIndicator { } model: discussionsModel delegate: Kirigami.BasicListItem { reserveSpaceForIcon: false RowLayout { ColumnLayout { QQC2.Label { text: description elide: Text.ElideRight wrapMode: QQC2.Label.Wrap } RowLayout { QQC2.Label { text: i18np("1 message", "%1 messages", numberofmessages) elide: Text.ElideRight wrapMode: QQC2.Label.Wrap Component.onCompleted: { font.bold = true } } QQC2.Label { id: timestampText Layout.alignment: Qt.AlignTop | Qt.AlignRight text: lastmessage opacity: .5 } } QQC2.Label { text: i18n("Open Discussion") elide: Text.ElideRight wrapMode: QQC2.Label.Wrap color: Kirigami.Theme.negativeTextColor MouseArea { anchors.fill: parent onClicked: { showDiscussionsInRoomDialog.openDiscussion(discussionid) showDiscussionsInRoomDialog.close() } } } } } } } } } diff --git a/src/ruqolacore/model/discussionsfilterproxymodel.cpp b/src/ruqolacore/model/discussionsfilterproxymodel.cpp index 27114b3e..38ceab5a 100644 --- a/src/ruqolacore/model/discussionsfilterproxymodel.cpp +++ b/src/ruqolacore/model/discussionsfilterproxymodel.cpp @@ -1,46 +1,51 @@ /* Copyright (c) 2019 Montel Laurent 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. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "discussionsfilterproxymodel.h" #include "discussionsmodel.h" DiscussionsFilterProxyModel::DiscussionsFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent) { setDynamicSortFilter(true); setFilterCaseSensitivity(Qt::CaseInsensitive); setFilterRole(DiscussionsModel::Description); sort(0); } DiscussionsFilterProxyModel::~DiscussionsFilterProxyModel() { } QHash DiscussionsFilterProxyModel::roleNames() const { if (QAbstractItemModel *source = sourceModel()) { return source->roleNames(); } return QHash(); } void DiscussionsFilterProxyModel::setFilterString(const QString &string) { setFilterFixedString(string); } + +void DiscussionsFilterProxyModel::clearFilter() +{ + setFilterFixedString(QString()); +} diff --git a/src/ruqolacore/model/discussionsfilterproxymodel.h b/src/ruqolacore/model/discussionsfilterproxymodel.h index c8bc7f88..50ec5e21 100644 --- a/src/ruqolacore/model/discussionsfilterproxymodel.h +++ b/src/ruqolacore/model/discussionsfilterproxymodel.h @@ -1,37 +1,38 @@ /* Copyright (c) 2019 Montel Laurent 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. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DISCUSSIONSFILTERPROXYMODEL_H #define DISCUSSIONSFILTERPROXYMODEL_H #include #include "libruqola_private_export.h" class LIBRUQOLACORE_TESTS_EXPORT DiscussionsFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT public: explicit DiscussionsFilterProxyModel(QObject *parent = nullptr); ~DiscussionsFilterProxyModel() override; Q_REQUIRED_RESULT QHash roleNames() const override; Q_INVOKABLE void setFilterString(const QString &string); + Q_INVOKABLE void clearFilter(); }; #endif // DISCUSSIONSFILTERPROXYMODEL_H