diff --git a/src/apps/qml/ShowThreadsInRoomDialog.qml b/src/apps/qml/ShowThreadsInRoomDialog.qml index 139eb231..10dbe1b3 100644 --- a/src/apps/qml/ShowThreadsInRoomDialog.qml +++ b/src/apps/qml/ShowThreadsInRoomDialog.qml @@ -1,120 +1,121 @@ /* 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: showThreadsInRoomDialog title: i18n("Threads") signal openThread(string threadMessageId) property QtObject threadsModel 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() { + threadsModel.clearFilter(); searchField.text = ""; searchField.forceActiveFocus(); open(); } //Add menu here ColumnLayout { LineEditWithClearButton { id: searchField placeholderText: i18n("Search Threads...") Layout.fillWidth: true onTextChanged: { threadsModel.setFilterString(text); } } QQC2.Label { text: listview.count === 0 ? i18n("No Thread 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: threadsModel delegate: Kirigami.BasicListItem { reserveSpaceForIcon: false RowLayout { ColumnLayout { QQC2.Label { text: description elide: Text.ElideRight wrapMode: QQC2.Label.Wrap } RowLayout { QQC2.Label { text: i18np("1 reply", "%1 replies", 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 Thread") elide: Text.ElideRight wrapMode: QQC2.Label.Wrap color: Kirigami.Theme.negativeTextColor MouseArea { anchors.fill: parent onClicked: { showThreadsInRoomDialog.openThread(threadmessageid) } } } } } } } } } diff --git a/src/ruqolacore/model/threadsfilterproxymodel.cpp b/src/ruqolacore/model/threadsfilterproxymodel.cpp index 439cf63f..ed0095e7 100644 --- a/src/ruqolacore/model/threadsfilterproxymodel.cpp +++ b/src/ruqolacore/model/threadsfilterproxymodel.cpp @@ -1,47 +1,52 @@ /* 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 "threadsfilterproxymodel.h" #include "threadsmodel.h" ThreadsFilterProxyModel::ThreadsFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent) { setDynamicSortFilter(true); setFilterCaseSensitivity(Qt::CaseInsensitive); setFilterRole(ThreadsModel::Description); sort(0); } ThreadsFilterProxyModel::~ThreadsFilterProxyModel() { } QHash ThreadsFilterProxyModel::roleNames() const { if (QAbstractItemModel *source = sourceModel()) { return source->roleNames(); } return QHash(); } void ThreadsFilterProxyModel::setFilterString(const QString &string) { setFilterFixedString(string); } + +void ThreadsFilterProxyModel::clearFilter() +{ + setFilterFixedString(QString()); +} diff --git a/src/ruqolacore/model/threadsfilterproxymodel.h b/src/ruqolacore/model/threadsfilterproxymodel.h index 9feaaa10..9f29f922 100644 --- a/src/ruqolacore/model/threadsfilterproxymodel.h +++ b/src/ruqolacore/model/threadsfilterproxymodel.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 THREADSFILTERPROXYMODEL_H #define THREADSFILTERPROXYMODEL_H #include #include "libruqola_private_export.h" class LIBRUQOLACORE_TESTS_EXPORT ThreadsFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT public: explicit ThreadsFilterProxyModel(QObject *parent = nullptr); ~ThreadsFilterProxyModel() override; Q_REQUIRED_RESULT QHash roleNames() const override; Q_INVOKABLE void setFilterString(const QString &string); + Q_INVOKABLE void clearFilter(); }; #endif // THREADSFILTERPROXYMODEL_H