mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Fix multi filtering, replace checkboxes by combobox and avoid hidding filter bar if no results.
This commit is contained in:
parent
79137f71c3
commit
655953675d
3 changed files with 68 additions and 55 deletions
|
|
@ -101,18 +101,12 @@ bool TimelineProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &sou
|
|||
return false;
|
||||
|
||||
if( mFilterFlags > 0) {
|
||||
if( !show && ( (mFilterFlags & TimelineFilter::SimpleChatRoom) == TimelineFilter::SimpleChatRoom))
|
||||
show = !isGroup;
|
||||
if( !show && ( (mFilterFlags & TimelineFilter::SecureChatRoom) == TimelineFilter::SecureChatRoom))
|
||||
show = haveEncryption;
|
||||
if( !show && ( (mFilterFlags & TimelineFilter::GroupChatRoom) == TimelineFilter::GroupChatRoom))
|
||||
show = isGroup;
|
||||
if( !show && ( (mFilterFlags & TimelineFilter::StandardChatRoom) == TimelineFilter::StandardChatRoom))
|
||||
show = !haveEncryption;
|
||||
if( !show && ( (mFilterFlags & TimelineFilter::EphemeralChatRoom) == TimelineFilter::EphemeralChatRoom))
|
||||
show = isEphemeral;
|
||||
if( !show && ( (mFilterFlags & TimelineFilter::NoEphemeralChatRoom) == TimelineFilter::NoEphemeralChatRoom))
|
||||
show = !isEphemeral;
|
||||
show = !(( ( (mFilterFlags & TimelineFilter::SimpleChatRoom) == TimelineFilter::SimpleChatRoom) && isGroup)
|
||||
|| ( ( (mFilterFlags & TimelineFilter::SecureChatRoom) == TimelineFilter::SecureChatRoom) && !haveEncryption)
|
||||
|| ( ( (mFilterFlags & TimelineFilter::GroupChatRoom) == TimelineFilter::GroupChatRoom) && !isGroup)
|
||||
|| ( ( (mFilterFlags & TimelineFilter::StandardChatRoom) == TimelineFilter::StandardChatRoom) && haveEncryption)
|
||||
|| ( ( (mFilterFlags & TimelineFilter::EphemeralChatRoom) == TimelineFilter::EphemeralChatRoom) && !isEphemeral)
|
||||
|| ( ( (mFilterFlags & TimelineFilter::NoEphemeralChatRoom) == TimelineFilter::NoEphemeralChatRoom) && isEphemeral));
|
||||
}
|
||||
|
||||
if(show && mFilterText != ""){
|
||||
|
|
|
|||
|
|
@ -15,17 +15,20 @@ Controls.ComboBox {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
property var iconRole
|
||||
property bool haveBorder: true
|
||||
property bool haveMargin: true
|
||||
property color backgroundColor: ComboBoxStyle.background.color.normal
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
background: Rectangle {
|
||||
border {
|
||||
color: ComboBoxStyle.background.border.color
|
||||
width: ComboBoxStyle.background.border.width
|
||||
width: comboBox.haveBorder ? ComboBoxStyle.background.border.width : 0
|
||||
}
|
||||
|
||||
color: comboBox.enabled
|
||||
? ComboBoxStyle.background.color.normal
|
||||
? comboBox.backgroundColor
|
||||
: ComboBoxStyle.background.color.readOnly
|
||||
|
||||
radius: ComboBoxStyle.background.radius
|
||||
|
|
@ -43,7 +46,7 @@ Controls.ComboBox {
|
|||
RowLayout {
|
||||
anchors {
|
||||
fill: parent
|
||||
leftMargin: ComboBoxStyle.contentItem.leftMargin
|
||||
leftMargin: comboBox.haveMargin ? ComboBoxStyle.contentItem.leftMargin : 0
|
||||
}
|
||||
|
||||
spacing: ComboBoxStyle.contentItem.spacing
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ Rectangle {
|
|||
Layout.preferredHeight: TimelineStyle.legend.height
|
||||
Layout.alignment: Qt.AlignTop
|
||||
color: showHistory.containsMouse?TimelineStyle.legend.backgroundColor.hovered:TimelineStyle.legend.backgroundColor.normal
|
||||
visible:view.count > 0 || timeline.isFilterVisible
|
||||
visible:view.count > 0 || timeline.isFilterVisible || timeline.model.filterFlags > 0
|
||||
|
||||
MouseArea{// no more showing history
|
||||
id:showHistory
|
||||
|
|
@ -160,60 +160,76 @@ Rectangle {
|
|||
anchors.right:parent.right
|
||||
spacing:-4
|
||||
function getFilterFlags(){
|
||||
return secureFilter.value | groupFilter.value | ephemeralsFilter.value;
|
||||
return secureFilter.model.get(secureFilter.currentIndex).value | groupFilter.model.get(groupFilter.currentIndex).value | ephemeralsFilter.model.get(ephemeralsFilter.currentIndex).value;
|
||||
}
|
||||
function getNextState(checkState){
|
||||
if(checkState === Qt.Unchecked)
|
||||
return Qt.Checked;
|
||||
else if(checkState === Qt.Checked)
|
||||
return Qt.PartiallyChecked;
|
||||
else
|
||||
return Qt.Unchecked;
|
||||
}
|
||||
CheckBoxText {
|
||||
ComboBox {
|
||||
Layout.fillWidth: true
|
||||
id:secureFilter
|
||||
//: 'Secure rooms' : Filter item. Selecting it will show all secure rooms.
|
||||
text: checkState === Qt.Checked ? qsTr('timelineFilterSecureRooms') : checkState === Qt.Unchecked
|
||||
currentIndex: 0
|
||||
textRole: "key"
|
||||
model: ListModel {
|
||||
ListElement {
|
||||
//: 'All security levels' : Filter item. Selecting it will not do any filter on security level.
|
||||
? qsTr('timelineFilterAllSecureLevelRooms')
|
||||
//: 'Standard rooms' : Filter item. Selecting it will show all simple rooms.
|
||||
: qsTr('timelineFilterStandardRooms')
|
||||
property var value : (checkState==Qt.Checked?TimelineProxyModel.SecureChatRoom: (checkState == Qt.PartiallyChecked ?TimelineProxyModel.StandardChatRoom:0))
|
||||
onValueChanged: timeline.model.filterFlags = filterChoices.getFilterFlags()
|
||||
tristate: true
|
||||
key: qsTr('timelineFilterAllSecureLevelRooms'); value: 0}
|
||||
ListElement {
|
||||
//: 'Standard rooms' : Filter item. Selecting it will show all simple rooms.
|
||||
key: qsTr('timelineFilterStandardRooms'); value: TimelineProxyModel.StandardChatRoom}
|
||||
ListElement {
|
||||
//: 'Secure rooms' : Filter item. Selecting it will show all secure rooms.
|
||||
key: qsTr('timelineFilterSecureRooms'); value: TimelineProxyModel.SecureChatRoom}
|
||||
}
|
||||
|
||||
haveBorder: false
|
||||
haveMargin: false
|
||||
backgroundColor: 'transparent'
|
||||
visible: SettingsModel.secureChatEnabled && SettingsModel.standardChatEnabled
|
||||
nextCheckState: function(){ return parent.getNextState(checkState)}
|
||||
onActivated: timeline.model.filterFlags = filterChoices.getFilterFlags()
|
||||
}
|
||||
CheckBoxText {
|
||||
ComboBox {
|
||||
Layout.fillWidth: true
|
||||
id:groupFilter
|
||||
Layout.fillWidth: true
|
||||
//: 'Chat groups' : Filter item. Selecting it will show all chat groups (with more than one participant).
|
||||
text: checkState === Qt.Checked ? qsTr('timelineFilterChatGroups') : checkState === Qt.Unchecked
|
||||
currentIndex: 0
|
||||
textRole: "key"
|
||||
model: ListModel {
|
||||
ListElement {
|
||||
//: 'Any conversations' : Filter item. Selecting it will not do any filter on the type of conversations.
|
||||
? qsTr('timelineFilterAnyChatRooms')
|
||||
key: qsTr('timelineFilterAnyChatRooms'); value: 0}
|
||||
ListElement {
|
||||
//: 'Simple rooms' : Filter item. Selecting it will show all secure chat groups (with more than one participant).
|
||||
: qsTr('timelineFilterSimpleRooms')
|
||||
property var value : (checkState==Qt.Checked?TimelineProxyModel.GroupChatRoom: (checkState == Qt.PartiallyChecked ?TimelineProxyModel.SimpleChatRoom:0))
|
||||
onValueChanged: timeline.model.filterFlags = filterChoices.getFilterFlags()
|
||||
tristate: true
|
||||
key: qsTr('timelineFilterSimpleRooms'); value: TimelineProxyModel.SimpleChatRoom}
|
||||
ListElement {
|
||||
//: 'Chat groups' : Filter item. Selecting it will show all chat groups (with more than one participant).
|
||||
key: qsTr('timelineFilterChatGroups'); value: TimelineProxyModel.GroupChatRoom}
|
||||
}
|
||||
|
||||
haveBorder: false
|
||||
haveMargin: false
|
||||
backgroundColor: 'transparent'
|
||||
visible: SettingsModel.secureChatEnabled || SettingsModel.standardChatEnabled
|
||||
nextCheckState: function(){ return parent.getNextState(checkState)}
|
||||
onActivated: timeline.model.filterFlags = filterChoices.getFilterFlags()
|
||||
}
|
||||
CheckBoxText {
|
||||
id:ephemeralsFilter
|
||||
ComboBox {
|
||||
Layout.fillWidth: true
|
||||
//: 'Ephemerals' : Filter item. Selecting it will show all chat rooms where the ephemeral mode has been enabled.
|
||||
text: checkState === Qt.Checked ? qsTr('timelineFilterEphemerals') : checkState === Qt.Unchecked
|
||||
id:ephemeralsFilter
|
||||
currentIndex: 0
|
||||
textRole: "key"
|
||||
model: ListModel {
|
||||
ListElement {
|
||||
//: 'Ephemerals on/off' : Filter item. Selecting it will not do any filter on ephemerals activation.
|
||||
? qsTr('timelineFilterAnyEphemerals')
|
||||
key: qsTr('timelineFilterAnyEphemerals'); value: 0}
|
||||
ListElement {
|
||||
//: 'No Ephemerals' : Filter item. Selecting it will hide all chat rooms where the ephemeral mode has been enabled.
|
||||
: qsTr('timelineFilterNoEphemerals')
|
||||
property var value : (checkState==Qt.Checked?TimelineProxyModel.EphemeralChatRoom: (checkState == Qt.PartiallyChecked ?TimelineProxyModel.NoEphemeralChatRoom:0))
|
||||
key: qsTr('timelineFilterNoEphemerals'); value: TimelineProxyModel.NoEphemeralChatRoom}
|
||||
ListElement {
|
||||
//: 'Ephemerals' : Filter item. Selecting it will show all chat rooms where the ephemeral mode has been enabled.
|
||||
key: qsTr('timelineFilterEphemerals'); value: TimelineProxyModel.EphemeralChatRoom}
|
||||
}
|
||||
|
||||
haveBorder: false
|
||||
haveMargin: false
|
||||
backgroundColor: 'transparent'
|
||||
visible: SettingsModel.secureChatEnabled || SettingsModel.standardChatEnabled
|
||||
onValueChanged: timeline.model.filterFlags = filterChoices.getFilterFlags()
|
||||
tristate: true
|
||||
nextCheckState: function(){ return parent.getNextState(checkState)}
|
||||
onActivated: timeline.model.filterFlags = filterChoices.getFilterFlags()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue