mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-26 00:08:13 +00:00
Allow to remove items in filter timelines criteria
This commit is contained in:
parent
7557744608
commit
cbdf9cf3f5
4 changed files with 139 additions and 76 deletions
|
|
@ -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<TimelineModel*>();
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue