diff --git a/linphone-app/src/components/timeline/TimelineProxyModel.cpp b/linphone-app/src/components/timeline/TimelineProxyModel.cpp index 56c2b8bbb..92cb7eaff 100644 --- a/linphone-app/src/components/timeline/TimelineProxyModel.cpp +++ b/linphone-app/src/components/timeline/TimelineProxyModel.cpp @@ -90,18 +90,36 @@ bool TimelineProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &sou const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); auto timeline = sourceModel()->data(index).value(); bool show = (mFilterFlags==0);// Show all at 0 (no hide all) - auto currentAddress = Utils::interpretUrl(CoreManager::getInstance()->getAccountSettingsModel()->getUsedSipAddressAsStringUriOnly()); bool isGroup = timeline->getChatRoomModel()->isGroupEnabled(); - if( !show && ( (mFilterFlags & TimelineFilter::SimpleChatRoom) == TimelineFilter::SimpleChatRoom)) - show = !isGroup && !timeline->getChatRoomModel()->haveEncryption(); - if( !show && ( (mFilterFlags & TimelineFilter::SecureChatRoom) == TimelineFilter::SecureChatRoom)) - show = !isGroup && timeline->getChatRoomModel()->haveEncryption(); - if( !show && ( (mFilterFlags & TimelineFilter::GroupChatRoom) == TimelineFilter::GroupChatRoom)) - show = isGroup && !timeline->getChatRoomModel()->haveEncryption(); - if( !show && ( (mFilterFlags & TimelineFilter::SecureGroupChatRoom) == TimelineFilter::SecureGroupChatRoom)) - show = isGroup && timeline->getChatRoomModel()->haveEncryption(); - if( !show && ( (mFilterFlags & TimelineFilter::EphemeralChatRoom) == TimelineFilter::EphemeralChatRoom)) - show = timeline->getChatRoomModel()->isEphemeralEnabled(); + bool haveEncryption = timeline->getChatRoomModel()->haveEncryption(); + bool isEphemeral = timeline->getChatRoomModel()->isEphemeralEnabled(); + + + if( mFilterFlags > 0) { + if( !show && ( (mFilterFlags & TimelineFilter::SimpleChatRoom) == TimelineFilter::SimpleChatRoom)) + show = !isGroup && !haveEncryption; + if( !show && ( (mFilterFlags & TimelineFilter::SecureChatRoom) == TimelineFilter::SecureChatRoom)) + show = !isGroup && haveEncryption; + if( !show && ( (mFilterFlags & TimelineFilter::GroupChatRoom) == TimelineFilter::GroupChatRoom)) + show = isGroup && !haveEncryption; + if( !show && ( (mFilterFlags & TimelineFilter::SecureGroupChatRoom) == TimelineFilter::SecureGroupChatRoom)) + show = isGroup && haveEncryption; + if( !show && ( (mFilterFlags & TimelineFilter::EphemeralChatRoom) == TimelineFilter::EphemeralChatRoom)) + show = isEphemeral; + + show = ( (mFilterFlags & AllChatRooms) == 0) || show; + if( show && ( (mFilterFlags & TimelineFilter::NoSimpleChatRoom) == TimelineFilter::NoSimpleChatRoom)) + show = !(!isGroup && !haveEncryption); + if( show && ( (mFilterFlags & TimelineFilter::NoSecureChatRoom) == TimelineFilter::NoSecureChatRoom)) + show = !(!isGroup && haveEncryption); + if( show && ( (mFilterFlags & TimelineFilter::NoGroupChatRoom) == TimelineFilter::NoGroupChatRoom)) + show = !(isGroup && !haveEncryption); + if( show && ( (mFilterFlags & TimelineFilter::NoSecureGroupChatRoom) == TimelineFilter::NoSecureGroupChatRoom)) + show = !(isGroup && haveEncryption); + if( show && ( (mFilterFlags & TimelineFilter::NoEphemeralChatRoom) == TimelineFilter::NoEphemeralChatRoom)) + show = !isEphemeral; + } + if(show && mFilterText != ""){ QRegularExpression search(QRegularExpression::escape(mFilterText), QRegularExpression::CaseInsensitiveOption | QRegularExpression::UseUnicodePropertiesOption); show = timeline->getChatRoomModel()->getSubject().contains(search) diff --git a/linphone-app/src/components/timeline/TimelineProxyModel.hpp b/linphone-app/src/components/timeline/TimelineProxyModel.hpp index 4bced99f6..d3f66f607 100644 --- a/linphone-app/src/components/timeline/TimelineProxyModel.hpp +++ b/linphone-app/src/components/timeline/TimelineProxyModel.hpp @@ -40,6 +40,12 @@ public: SecureGroupChatRoom=8, EphemeralChatRoom=16, + NoSimpleChatRoom=32, + NoSecureChatRoom=64, + NoGroupChatRoom=128, + NoSecureGroupChatRoom=256, + NoEphemeralChatRoom=512, + AllChatRooms = SimpleChatRoom+SecureChatRoom+GroupChatRoom+SecureGroupChatRoom+EphemeralChatRoom }; Q_ENUM(TimelineFilter) diff --git a/linphone-app/ui/modules/Common/Form/CheckBoxText.qml b/linphone-app/ui/modules/Common/Form/CheckBoxText.qml index e250a53bc..da9db6bc4 100644 --- a/linphone-app/ui/modules/Common/Form/CheckBoxText.qml +++ b/linphone-app/ui/modules/Common/Form/CheckBoxText.qml @@ -1,5 +1,6 @@ import QtQuick 2.7 import QtQuick.Controls 2.2 +import QtQuick.Shapes 1.10 import Common.Styles 1.0 @@ -8,64 +9,97 @@ import Common.Styles 1.0 // ============================================================================= CheckBox { - id: checkBox - - contentItem: Text { - color: checkBox.down - ? CheckBoxTextStyle.color.pressed - : ( - checkBox.hovered - ? CheckBoxTextStyle.color.hovered - : CheckBoxTextStyle.color.normal - ) - - elide: Text.ElideRight - font: checkBox.font - leftPadding: checkBox.indicator.width + checkBox.spacing - text: checkBox.text - - width: parent.width - wrapMode: Text.WordWrap - - verticalAlignment: Text.AlignVCenter - } - - font.pointSize: CheckBoxTextStyle.pointSize - hoverEnabled: true - - indicator: Rectangle { - border.color: checkBox.down - ? CheckBoxTextStyle.color.pressed - : ( - checkBox.hovered - ? CheckBoxTextStyle.color.hovered - : CheckBoxTextStyle.color.normal - ) - - implicitHeight: CheckBoxTextStyle.size - implicitWidth: CheckBoxTextStyle.size - - radius: CheckBoxTextStyle.radius - - x: checkBox.leftPadding - y: parent.height / 2 - height / 2 - - Rectangle { - color: checkBox.down - ? CheckBoxTextStyle.color.pressed - : (checkBox.hovered - ? CheckBoxTextStyle.color.hovered - : CheckBoxTextStyle.color.normal - ) - - height: parent.height - y * 2 - width: parent.width - x * 2 - - radius: CheckBoxTextStyle.radius - visible: checkBox.checked - - x: 4 // Fixed, no needed to use style file. - y: 4 // Same thing. - } - } + id: checkBox + + contentItem: Text { + color: checkBox.down + ? CheckBoxTextStyle.color.pressed + : ( + checkBox.hovered + ? CheckBoxTextStyle.color.hovered + : CheckBoxTextStyle.color.normal + ) + + elide: Text.ElideRight + font: checkBox.font + leftPadding: checkBox.indicator.width + checkBox.spacing + text: checkBox.text + + width: parent.width + wrapMode: Text.WordWrap + + verticalAlignment: Text.AlignVCenter + } + + font.pointSize: CheckBoxTextStyle.pointSize + hoverEnabled: true + + indicator: Rectangle { + border.color: checkBox.down + ? CheckBoxTextStyle.color.pressed + : ( + checkBox.hovered + ? CheckBoxTextStyle.color.hovered + : CheckBoxTextStyle.color.normal + ) + + implicitHeight: CheckBoxTextStyle.size + implicitWidth: CheckBoxTextStyle.size + + radius: CheckBoxTextStyle.radius + + x: checkBox.leftPadding + y: parent.height / 2 - height / 2 + + Rectangle { + color: checkBox.down + ? CheckBoxTextStyle.color.pressed + : (checkBox.hovered + ? CheckBoxTextStyle.color.hovered + : CheckBoxTextStyle.color.normal + ) + + height: parent.height - y * 2 + width: parent.width - x * 2 + + radius: CheckBoxTextStyle.radius + visible: checkBox.checkState == Qt.Checked + + x: 4 // Fixed, no needed to use style file. + y: 4 // Same thing. + } + Shape{ + id: partiallyShape + anchors.fill: parent + visible: checkBox.checkState == Qt.PartiallyChecked + ShapePath{ + strokeColor: checkBox.down + ? CheckBoxTextStyle.color.pressed + : (checkBox.hovered + ? CheckBoxTextStyle.color.hovered + : CheckBoxTextStyle.color.normal + ) + strokeWidth: 2 + fillColor: 'transparent' + joinStyle: ShapePath.MiterJoin + startX: 6 + startY: 6 + PathLine{x: partiallyShape.width - 6; y: partiallyShape.height - 6} + } + ShapePath{ + strokeColor: checkBox.down + ? CheckBoxTextStyle.color.pressed + : (checkBox.hovered + ? CheckBoxTextStyle.color.hovered + : CheckBoxTextStyle.color.normal + ) + strokeWidth: 2 + fillColor: 'transparent' + joinStyle: ShapePath.MiterJoin + startX: partiallyShape.width - 6 + startY: 6 + PathLine{x: 6; y: partiallyShape.height - 6} + } + } + } } diff --git a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml index 07e522ab2..bbf2c5329 100644 --- a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml +++ b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml @@ -141,40 +141,45 @@ Rectangle { //: 'Simple rooms' : Filter item //~ Mode Selecting it will show all simple rooms text:qsTr('timelineFilterSimpleRooms') - property var value : (checked?TimelineProxyModel.SimpleChatRoom:0) + property var value : (checkState==Qt.Checked?TimelineProxyModel.SimpleChatRoom: (checkState == Qt.PartiallyChecked ?TimelineProxyModel.NoSimpleChatRoom:0)) onValueChanged: timeline.model.filterFlags = filterChoices.getFilterFlags() + tristate: true } CheckBoxText { id:secureFilter //: 'Secure rooms' : Filter item //~ Mode Selecting it will show all secure rooms text:qsTr('timelineFilterSecureRooms') - property var value : (checked?TimelineProxyModel.SecureChatRoom:0) + property var value : (checkState==Qt.Checked?TimelineProxyModel.SecureChatRoom: (checkState == Qt.PartiallyChecked ?TimelineProxyModel.NoSecureChatRoom:0)) onValueChanged: timeline.model.filterFlags = filterChoices.getFilterFlags() + tristate: true } CheckBoxText { id:groupFilter //: 'Chat groups' : Filter item //~ Mode Selecting it will show all chat groups (with more than one participant) text:qsTr('timelineFilterChatGroups') - property var value : (checked?TimelineProxyModel.GroupChatRoom:0) + property var value : (checkState==Qt.Checked?TimelineProxyModel.GroupChatRoom: (checkState == Qt.PartiallyChecked ?TimelineProxyModel.NoGroupChatRoom:0)) onValueChanged: timeline.model.filterFlags = filterChoices.getFilterFlags() + tristate: true } CheckBoxText { id:secureGroupFilter //: 'Secure Chat Groups' : Filter item //~ Mode Selecting it will show all secure chat groups (with more than one participant) text:qsTr('timelineFilterSecureChatGroups') - property var value : (checked?TimelineProxyModel.SecureGroupChatRoom:0) + property var value : (checkState==Qt.Checked?TimelineProxyModel.SecureGroupChatRoom: (checkState == Qt.PartiallyChecked ?TimelineProxyModel.NoSecureGroupChatRoom:0)) onValueChanged: timeline.model.filterFlags = filterChoices.getFilterFlags() + tristate: true } CheckBoxText { id:ephemeralsFilter //: 'Ephemerals' : Filter item //~ Mode Selecting it will show all chat rooms where the ephemeral mode has been enabled. text:qsTr('timelineFilterEphemerals') - property var value : (checked?TimelineProxyModel.EphemeralChatRoom:0) + property var value : (checkState==Qt.Checked?TimelineProxyModel.EphemeralChatRoom: (checkState == Qt.PartiallyChecked ?TimelineProxyModel.NoEphemeralChatRoom:0)) onValueChanged: timeline.model.filterFlags = filterChoices.getFilterFlags() + tristate: true } }