Commit 8eef793f authored by Lamarque Souza's avatar Lamarque Souza
Browse files

Add signal finishedListingChanged to MetadataModel so that we can stop

the busy indicator in ViewSearch.qml when the nepomuk query finishes.

CCBUG: 296958
parent d54c76f7
......@@ -207,7 +207,7 @@ PlasmaComponents.Page {
Connections {
target: metadataModel
onModelReset: selectedModel.clear()
onCountChanged: { searchBox.restartBusyTimer() }
onFinishedListingChanged: { searchBox.setIdle() }
}
Image {
......
......@@ -83,7 +83,7 @@ PlasmaCore.FrameSvgItem {
}
Connections {
target: filterModel
onCountChanged: { searchBox.restartBusyTimer() }
onFinishedListingChanged: { searchBox.setIdle() }
}
opacity: viewer.scale==1?0:1
Behavior on opacity {
......
......@@ -327,7 +327,6 @@ void MetadataModel::doQuery()
// we must prepend and append "*" to the file name for the default Nepomuk match type (Contains) really work.
Nepomuk::Query::ComparisonTerm term(propertyUrl(key), Nepomuk::Query::LiteralTerm(parameter));
if (negation) {
rootTerm.addSubTerm(Nepomuk::Query::NegationTerm::negateTerm(term));
} else {
......@@ -470,6 +469,9 @@ void MetadataModel::doQuery()
if (m_pageSize < 1) {
fetchResultsPage(0);
}
// Nepomuk::Query::QueryServiceClient does not emit finishedListing signal when there is no new entries (no matches).
QTimer::singleShot(5000, this, SIGNAL(finishedListingChanged()));
}
void MetadataModel::fetchResultsPage(int page)
......@@ -757,6 +759,8 @@ void MetadataModel::finishedListing()
}
}
}
emit finishedListingChanged();
}
......
......@@ -180,6 +180,7 @@ Q_SIGNALS:
void lazyLoadingChanged();
void scoreResourcesChanged();
void thumbnailSizeChanged();
void finishedListingChanged();
protected Q_SLOTS:
void countQueryResult(const QList< Nepomuk::Query::Result > &entries);
......
......@@ -31,8 +31,16 @@ Item {
property int delay : 100
property bool busy: false
// hide busy indicator after busyTimeout miliseconds.
property alias busyTimeout: busyTimer.interval
onSearchQueryChanged: {
searchField.text = searchQuery
busy = true
if (busyTimeout > 0) {
busyTimer.restart()
}
}
width: searchField.width
......@@ -55,17 +63,17 @@ Item {
height: searchField.height
width: searchField.height
visible: searchFieldContainer.busy
running: searchFieldContainer.busy
running: visible
}
function restartBusyTimer() {
busyTimer.restart()
function setIdle() {
searchFieldContainer.busy = false
}
Timer {
id: busyTimer
repeat: false
interval: 1000
interval: 0
running: false
onTriggered: { searchFieldContainer.busy = false }
}
......
......@@ -88,12 +88,18 @@ MouseArea {
RunnerModels.RunnerModel {
id: runnerModel
runners: [ "services", "nepomuksearch", "recentdocuments", "desktopsessions" , "PowerDevil", "calculator" ]
onCountChanged: { searchField.restartBusyTimer() }
Component.onCompleted: {
runnerModel.finishedListingChanged.connect(searchField.setIdle)
}
}
MobileComponents.ViewSearch {
id: searchField
// set the timeout for the busy indicator.
busyTimeout: 1000
anchors {
left: parent.left
right: parent.right
......@@ -111,7 +117,6 @@ MouseArea {
} else {
appGrid.model = runnerModel
runnerModel.query = searchQuery
busy = true
}
}
......
......@@ -112,10 +112,15 @@ PlasmaComponents.TabBar {
id: topComponent
ResourceBrowser {
model: MetadataModels.MetadataModel {
id: topModel
sortOrder: Qt.DescendingOrder
activityId: "!"+activitySource.data["Status"]["Current"]
scoreResources: true
queryString: "*" + searchField.searchQuery + "*"
Component.onCompleted: {
topModel.finishedListingChanged.connect(searchField.setIdle)
}
}
}
}
......@@ -138,6 +143,10 @@ PlasmaComponents.TabBar {
sortRole: "name"
filterRole: "name"
filterRegExp: ".*"+searchField.searchQuery+".*"
Component.onCompleted: {
appsModel.finishedListingChanged.connect(searchField.setIdle)
}
}
}
}
......@@ -146,10 +155,15 @@ PlasmaComponents.TabBar {
id: bookmarksComponent
ResourceBrowser {
model: MetadataModels.MetadataModel {
id: bookmarksModel
sortOrder: Qt.AscendingOrder
activityId: "!"+activitySource.data["Status"]["Current"]
sortBy: ["nie:url"]
resourceType: "nfo:Bookmark"
Component.onCompleted: {
bookmarksModel.finishedListingChanged.connect(searchField.setIdle)
}
}
}
}
......@@ -158,11 +172,16 @@ PlasmaComponents.TabBar {
id: contactsComponent
ResourceBrowser {
model: MetadataModels.MetadataModel {
id: contactsModel
sortOrder: Qt.AscendingOrder
activityId: "!"+activitySource.data["Status"]["Current"]
sortBy: ["nco:fullname"]
resourceType: "nco:Contact"
queryString: "*" + searchField.searchQuery + "*"
Component.onCompleted: {
contactsModel.finishedListingChanged.connect(searchField.setIdle)
}
}
}
}
......@@ -171,11 +190,16 @@ PlasmaComponents.TabBar {
id: documentsComponent
ResourceBrowser {
model: MetadataModels.MetadataModel {
id: documentsModel
sortBy: ["nfo:fileName"]
activityId: "!"+activitySource.data["Status"]["Current"]
sortOrder: Qt.AscendingOrder
resourceType: "nfo:Document"
queryString: "*" + searchField.searchQuery + "*"
Component.onCompleted: {
documentsModel.finishedListingChanged.connect(searchField.setIdle)
}
}
}
}
......@@ -184,11 +208,16 @@ PlasmaComponents.TabBar {
id: imagesComponent
ResourceBrowser {
model: MetadataModels.MetadataModel {
id: imagesModel
sortBy: ["nfo:fileName"]
activityId: "!"+activitySource.data["Status"]["Current"]
sortOrder: Qt.AscendingOrder
resourceType: "nfo:Image"
queryString: "*" + searchField.searchQuery + "*"
Component.onCompleted: {
imagesModel.finishedListingChanged.connect(searchField.setIdle)
}
}
}
}
......@@ -197,11 +226,16 @@ PlasmaComponents.TabBar {
id: musicComponent
ResourceBrowser {
model: MetadataModels.MetadataModel {
id: musicModel
sortBy: ["nie:title"]
activityId: "!"+activitySource.data["Status"]["Current"]
sortOrder: Qt.AscendingOrder
resourceType: "nfo:Audio"
queryString: "*" + searchField.searchQuery + "*"
Component.onCompleted: {
musicModel.finishedListingChanged.connect(searchField.setIdle)
}
}
}
}
......@@ -210,11 +244,16 @@ PlasmaComponents.TabBar {
id: videoComponent
ResourceBrowser {
model: MetadataModels.MetadataModel {
id: videoModel
sortBy: ["nfo:fileName"]
activityId: "!"+activitySource.data["Status"]["Current"]
sortOrder: Qt.AscendingOrder
resourceType: "nfo:Video"
queryString: "*" + searchField.searchQuery + "*"
Component.onCompleted: {
videoModel.finishedListingChanged.connect(searchField.setIdle)
}
}
}
}
......
......@@ -130,9 +130,6 @@ PlasmaComponents.Sheet {
onSearchQueryChanged: {
if (stack.depth == 1 && searchQuery.length > 3) {
stack.push(globalSearchComponent)
busy = true
} else {
busy = false
}
}
},
......@@ -163,7 +160,9 @@ PlasmaComponents.Sheet {
stack.pop()
}
}
onCountChanged: { searchField.restartBusyTimer() }
Component.onCompleted: {
runnerModel.finishedListingChanged.connect(searchField.setIdle)
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment