diff options
| author | Yoann Lopes <yoann.lopes@nokia.com> | 2011-11-03 20:17:46 +0100 |
|---|---|---|
| committer | Yoann Lopes <yoann.lopes@nokia.com> | 2011-11-03 20:17:46 +0100 |
| commit | 2618d786b29510c6077dee67ab00b81852d4558f (patch) | |
| tree | e3a7b44590e0051cf8db784fbbdad181d86924ec | |
| parent | 8ead54b40e873da5fde5fb95ab54ca599eadf6ec (diff) | |
Added search suggestion when no results are found.
| -rw-r--r-- | libQtSpotify/qspotifysearch.cpp | 12 | ||||
| -rw-r--r-- | libQtSpotify/qspotifysearch.h | 14 | ||||
| -rw-r--r-- | qml/ArtistPage.qml | 16 | ||||
| -rw-r--r-- | qml/SearchPage.qml | 33 |
4 files changed, 59 insertions, 16 deletions
diff --git a/libQtSpotify/qspotifysearch.cpp b/libQtSpotify/qspotifysearch.cpp index 3c87243..07a7871 100644 --- a/libQtSpotify/qspotifysearch.cpp +++ b/libQtSpotify/qspotifysearch.cpp @@ -5,22 +5,22 @@ ** Contact: Yoann Lopes (yoann.lopes@nokia.com) ** ** This file is part of the MeeSpot project. -** +** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: -** +** ** Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. -** +** ** Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. -** +** ** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its ** contributors may be used to endorse or promote products derived from ** this software without specific prior written permission. -** +** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -180,6 +180,8 @@ void QSpotifySearch::populateResults() QSpotifyArtist *artist = new QSpotifyArtist(sp_search_artist(m_sp_search, i)); m_artistResults.append((QObject *)artist); } + + m_didYouMean = QString::fromUtf8(sp_search_did_you_mean(m_sp_search)); } m_busy = false; diff --git a/libQtSpotify/qspotifysearch.h b/libQtSpotify/qspotifysearch.h index c6d15d0..38aa413 100644 --- a/libQtSpotify/qspotifysearch.h +++ b/libQtSpotify/qspotifysearch.h @@ -5,22 +5,22 @@ ** Contact: Yoann Lopes (yoann.lopes@nokia.com) ** ** This file is part of the MeeSpot project. -** +** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: -** +** ** Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. -** +** ** Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. -** +** ** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its ** contributors may be used to endorse or promote products derived from ** this software without specific prior written permission. -** +** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -54,6 +54,7 @@ class QSpotifySearch : public QObject Q_PROPERTY(QList<QObject *> tracks READ tracks NOTIFY resultsChanged) Q_PROPERTY(QList<QObject *> albums READ albums NOTIFY resultsChanged) Q_PROPERTY(QList<QObject *> artists READ artists NOTIFY resultsChanged) + Q_PROPERTY(QString didYouMean READ didYouMean NOTIFY resultsChanged) Q_PROPERTY(bool busy READ busy NOTIFY busyChanged) public: @@ -67,6 +68,8 @@ public: QList<QObject *> albums() const { return m_albumResults; } QList<QObject *> artists() const { return m_artistResults; } + QString didYouMean() const { return m_didYouMean; } + void setTracksLimit(int l) { m_tracksLimit = l; } void setAlbumsLimit(int l) { m_albumsLimit = l; } void setArtistsLimit(int l) { m_artistsLimit = l; } @@ -94,6 +97,7 @@ private: QSpotifyTrackList *m_trackResults; QList<QObject *> m_albumResults; QList<QObject *> m_artistResults; + QString m_didYouMean; bool m_busy; int m_tracksLimit; diff --git a/qml/ArtistPage.qml b/qml/ArtistPage.qml index 289ec9d..f1c4e9b 100644 --- a/qml/ArtistPage.qml +++ b/qml/ArtistPage.qml @@ -247,13 +247,17 @@ Page { } } - Scrollbar { listView: artistView } - } + Label { + anchors.horizontalCenter: parent.horizontalCenter + y: 100 + visible: selector.selectedIndex == 2 && artistView.count === 0 && !browse.busy + text: "No biography available" + font.pixelSize: UI.FONT_LARGE + font.family: UI.FONT_FAMILY_LIGHT + font.weight: Font.Light + } - Label { - anchors.centerIn: parent - visible: selector.selectedIndex == 2 && artistView.count === 0 && !browse.busy - text: "No biography available" + Scrollbar { listView: artistView } } BusyIndicator { diff --git a/qml/SearchPage.qml b/qml/SearchPage.qml index 84c7cb2..eb88a4e 100644 --- a/qml/SearchPage.qml +++ b/qml/SearchPage.qml @@ -232,6 +232,39 @@ Page { } } + Label { + id: errorMessage + anchors.horizontalCenter: parent.horizontalCenter + y: 80 + visible: results.count === 0 && search.query.length > 0 && !search.busy + font.pixelSize: UI.FONT_LARGE + font.family: UI.FONT_FAMILY_LIGHT + font.weight: Font.Light + wrapMode: Text.WordWrap + width: parent.width - UI.MARGIN_XLARGE * 2 + horizontalAlignment: Text.AlignHCenter + + text: search.didYouMean.length > 0 ? "Did you mean" + : (selector.selectedIndex === 0 ? "No tracks found" : + selector.selectedIndex == 1 ? "No albums found" : + "No artists found") + } + Label { + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: errorMessage.bottom + visible: results.count === 0 && search.query.length > 0 && !search.busy && search.didYouMean.length > 0 + font.pixelSize: UI.FONT_LARGE + font.family: UI.FONT_FAMILY_LIGHT + font.weight: Font.Light + wrapMode: Text.WordWrap + width: parent.width - UI.MARGIN_XLARGE * 2 + horizontalAlignment: Text.AlignHCenter + + text: "<style type=text/css> a { text-decoration: underline; color:" + UI.SPOTIFY_COLOR + "} </style><a href='didyoumean'>" + search.didYouMean + "</a> ?" + + onLinkActivated: searchField.text = search.didYouMean + } + Scrollbar { listView: results } } } |
