-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filering on slow responsing time problem #64
Comments
Hello, |
UIPage.qml import QtQuick 2.0
import SongDataParser 1.0
import SortFilterProxyModel 0.2
import QtQuick.Controls 2.5
import "./Delegates"
Item {
property var laguages:["All", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "L", "M", "N"]
property var abc: ["All", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
property int currentLanguageIndex: 0
property int currentAbcIndex: 0
property int pageSize: 20
property int pageCount: sortFilterModel.count % pageSize === 0 ? sortFilterModel.count / pageSize : Math.round(sortFilterModel.count / pageSize) + 1
SongDataParser{
id: songDataParser
onDataLoaded: {
for(var i in songDatas())
{
var elementData = songDatas()[i];
songModel.append(elementData)
}
}
}
ListModel{
id: songModel
}
SortFilterProxyModel{
id: sortFilterModel
sourceModel: songModel
filters:[
ValueFilter{
roleName: "Language"
value: laguages[currentLanguageIndex]
enabled: currentLanguageIndex !== 0
},
RegExpFilter {
roleName: "PYStr1"
pattern: "^" + abc[currentAbcIndex] // 正则表达式匹配字符串
caseSensitivity: Qt.CaseInsensitive
enabled: currentAbcIndex !== 0
}
]
sorters: [
StringSorter{
id: aa
}
]
Component.onCompleted: {
// sortFilterModel.
}
}
Column{
anchors.fill: parent
spacing: 20
Item{
width: parent.width
height: 40
Row{
anchors.verticalCenter: parent.verticalCenter
spacing: 10
x: 20
Text{
anchors.verticalCenter: parent.verticalCenter
text: "Language: "
}
Repeater{
model: laguages
Rectangle{
width: 40
height: 30
radius: 3
color: currentLanguageIndex == index ? "#3af" : "#aaa"
Text{
anchors.centerIn: parent
text: modelData
color: "white"
}
MouseArea{
anchors.fill: parent
onClicked: {
currentLanguageIndex = index
}
}
}
}
}
}
Item{
width: parent.width
height: 40
Row{
anchors.verticalCenter: parent.verticalCenter
spacing: 10
x: 20
Text{
anchors.verticalCenter: parent.verticalCenter
text: "abc: "
}
Repeater{
model: abc
Rectangle{
width: 40
height: 30
radius: 3
color: currentAbcIndex == index ? "#3af" : "#aaa"
Text{
anchors.centerIn: parent
text: modelData
color: "white"
}
MouseArea{
anchors.fill: parent
onClicked: {
currentAbcIndex = index
}
}
}
}
}
}
Item{
width: parent.width
height: 500
Column{
anchors.fill: parent
ListView{
id:listView
orientation: ListView.Horizontal
width: parent.width
height: parent.height - 60
model: pageCount
highlightRangeMode : ListView.StrictlyEnforceRange
highlightMoveDuration: 200
highlightMoveVelocity: -1
snapMode: ListView.SnapOneItem
delegate: PageDelegate{
pageNo: index
source: sortFilterModel
sizeInPage: pageSize
width: listView.width
height: listView.height
}
}
Item{
width: parent.width
height: 60
Row{
anchors.centerIn: parent
spacing: 20
Button{
text: "Previous"
width: 70
height: 40
onClicked: {
if(listView.currentIndex > 0)
listView.currentIndex -= 1
}
}
Text{
text: String(listView.currentIndex + 1) + "/" + String(pageCount)
anchors.verticalCenter: parent.verticalCenter
}
Button{
text: "Next"
width: 70
height: 40
onClicked: {
if(listView.currentIndex < pageCount - 1)
listView.currentIndex += 1
}
}
}
}
}
}
}
Component.onCompleted: {
songDataParser.loadData("E:/MiniK/Bin/KVData/swsong.db", 1000);
}
}
PageDelegate.qml import QtQuick 2.0
import PageModel 1.0
Rectangle{
property int pageNo;
property QtObject source;
property int sizeInPage;
id: page
Grid{
anchors.centerIn: parent
spacing: 10
columns: 5
Repeater{
model: PageModel{
sourceModel: source
pageIndex: pageNo
pageSize: sizeInPage
}
delegate: SongDelegate{}
}
}
}
SongDelegate.qml import QtQuick 2.0
Rectangle{
width: 200
height: 100
border.width: 1
border.color: "#7799aa"
color: "#aaeeff"
radius: 4
Column{
anchors.centerIn: parent
spacing: 10
Text{
text: Name
}
Text{
text: PYStr1
}
Text{
text: Language
}
}
}
And the PageModel c++ implementation can read my articl open link(containing whole source code). |
Hello, is this problem continuing solving? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First filtering operation is very slow, and then it was well for nex filtering, what caused this problem?
problem above:
Amazing but why?
The text was updated successfully, but these errors were encountered: