From 1abd300957d99c52ba1dc814f069164b25ece6a7 Mon Sep 17 00:00:00 2001 From: Alexey Shmalko Date: Fri, 23 Nov 2012 21:44:55 +0200 Subject: [PATCH 1/4] Add extra parameters to audio API calls --- src/api/audio.cpp | 19 ++++++++++++------- src/api/audio.h | 12 ++++++++++-- src/qml/src/audiomodel.cpp | 4 ++-- src/qml/src/audiomodel.h | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/api/audio.cpp b/src/api/audio.cpp index df84800..5274d01 100644 --- a/src/api/audio.cpp +++ b/src/api/audio.cpp @@ -35,10 +35,9 @@ class AudioProviderPrivate { Q_DECLARE_PUBLIC(AudioProvider) public: - AudioProviderPrivate(AudioProvider *q, Client *client) : q_ptr(q), client(client), autoComplete(true) {} + AudioProviderPrivate(AudioProvider *q, Client *client) : q_ptr(q), client(client) {} AudioProvider *q_ptr; Client *client; - bool autoComplete; static QVariant handleAudio(const QVariant &response) { AudioItemList items; @@ -85,7 +84,8 @@ AudioItemListReply *AudioProvider::getContactAudio(int uid, int count, int offse { Q_D(AudioProvider); QVariantMap args; - args.insert(uid > 0 ? "uid" : "gid", qAbs(uid)); + if (uid) + args.insert(uid > 0 ? "uid" : "gid", qAbs(uid)); args.insert("count", count); args.insert("offset", offset); @@ -95,19 +95,24 @@ AudioItemListReply *AudioProvider::getContactAudio(int uid, int count, int offse /*! * \brief AudioProvider::searchAudio \link http://vk.com/developers.php?oid=-1&p=audio.search + * * \param query + * \param autocomplete + * \param lyrics * \param count * \param offset - * \return - */ -AudioItemListReply *AudioProvider::searchAudio(const QString &query, int count, int offset) + * \return reply + **/ +AudioItemListReply *AudioProvider::searchAudio(const QString& query, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool lyrics, int count, int offset) { Q_D(AudioProvider); QVariantMap args; args.insert("q", query); + args.insert("auto_complete", autoComplete); + args.insert("sort", static_cast(sort)); + args.insert("lyrics", lyrics); args.insert("count", count); args.insert("offset", offset); - args.insert("auto_complete", d->autoComplete); auto reply = d->client->request("audio.search", args, AudioProviderPrivate::handleAudio); return reply; diff --git a/src/api/audio.h b/src/api/audio.h index 68c5608..da1a35b 100644 --- a/src/api/audio.h +++ b/src/api/audio.h @@ -40,11 +40,19 @@ class VK_SHARED_EXPORT AudioProvider : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(AudioProvider) + Q_ENUMS(SortOrder) public: + + enum SortOrder { + SortByDate = 0, + SortByDuration, + SortByPopularity + }; + AudioProvider(Client *client); virtual ~AudioProvider(); - AudioItemListReply *getContactAudio(int uid, int count = 50, int offset = 0); - AudioItemListReply *searchAudio(const QString &query, int count = 50, int offset = 0); + AudioItemListReply *getContactAudio(int uid = 0, int count = 50, int offset = 0); + AudioItemListReply *searchAudio(const QString &query, bool autoComplete = true, SortOrder sort = SortByPopularity, bool lyrics = false, int count = 50, int offset = 0); protected: QScopedPointer d_ptr; }; diff --git a/src/qml/src/audiomodel.cpp b/src/qml/src/audiomodel.cpp index f904cc6..e77bab9 100644 --- a/src/qml/src/audiomodel.cpp +++ b/src/qml/src/audiomodel.cpp @@ -57,10 +57,10 @@ void AudioModel::getAudio(int count, int offset) } } -void AudioModel::searchAudio(const QString &query, int count, int offset) +void AudioModel::searchAudio(const QString& query, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool lyrics, int count, int offset) { if (m_provider.data()) { - auto reply = m_provider.data()->searchAudio(query, count, offset); + auto reply = m_provider.data()->searchAudio(query, autoComplete, sort, lyrics, count, offset); connect(reply, SIGNAL(resultReady(QVariant)), this, SLOT(onResultReady())); } diff --git a/src/qml/src/audiomodel.h b/src/qml/src/audiomodel.h index 82b393e..0c54100 100644 --- a/src/qml/src/audiomodel.h +++ b/src/qml/src/audiomodel.h @@ -43,7 +43,7 @@ class AudioModel : public Vreen::AudioModel void setOwner(Vreen::Contact* owner); public slots: void getAudio(int count = 100, int offset = 0); - void searchAudio(const QString &query, int count = 50, int offset = 0); + void searchAudio(const QString& query, bool autoComplete = true, Vreen::AudioProvider::SortOrder sort = Vreen::AudioProvider::SortByPopularity, bool lyrics = false, int count = 50, int offset = 0); signals: void ownerChanged(Vreen::Contact*); void requestFinished(); From 01e242ae015e8e24bead188c8ea74c2ec878c440 Mon Sep 17 00:00:00 2001 From: Alexey Shmalko Date: Fri, 23 Nov 2012 21:59:27 +0200 Subject: [PATCH 2/4] Move and rename searchAudio params --- src/api/audio.cpp | 4 ++-- src/api/audio.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/audio.cpp b/src/api/audio.cpp index 5274d01..ba25400 100644 --- a/src/api/audio.cpp +++ b/src/api/audio.cpp @@ -103,14 +103,14 @@ AudioItemListReply *AudioProvider::getContactAudio(int uid, int count, int offse * \param offset * \return reply **/ -AudioItemListReply *AudioProvider::searchAudio(const QString& query, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool lyrics, int count, int offset) +AudioItemListReply *AudioProvider::searchAudio(const QString& query, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool withLyrics, int count, int offset) { Q_D(AudioProvider); QVariantMap args; args.insert("q", query); args.insert("auto_complete", autoComplete); args.insert("sort", static_cast(sort)); - args.insert("lyrics", lyrics); + args.insert("lyrics", withLyrics); args.insert("count", count); args.insert("offset", offset); diff --git a/src/api/audio.h b/src/api/audio.h index da1a35b..c09c27b 100644 --- a/src/api/audio.h +++ b/src/api/audio.h @@ -52,7 +52,7 @@ class VK_SHARED_EXPORT AudioProvider : public QObject AudioProvider(Client *client); virtual ~AudioProvider(); AudioItemListReply *getContactAudio(int uid = 0, int count = 50, int offset = 0); - AudioItemListReply *searchAudio(const QString &query, bool autoComplete = true, SortOrder sort = SortByPopularity, bool lyrics = false, int count = 50, int offset = 0); + AudioItemListReply *searchAudio(const QString& query, bool autoComplete = true, Vreen::AudioProvider::SortOrder sort = SortByPopularity, bool withLyrics = false, int count = 50, int offset = 0); protected: QScopedPointer d_ptr; }; From 490b20738f6c7ed600cb99c96d384f7f15c8fed7 Mon Sep 17 00:00:00 2001 From: Alexey Shmalko Date: Fri, 23 Nov 2012 22:05:28 +0200 Subject: [PATCH 3/4] Forgot to realy move --- src/api/audio.cpp | 2 +- src/api/audio.h | 2 +- src/qml/src/audiomodel.cpp | 4 ++-- src/qml/src/audiomodel.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/audio.cpp b/src/api/audio.cpp index ba25400..284ba3e 100644 --- a/src/api/audio.cpp +++ b/src/api/audio.cpp @@ -103,7 +103,7 @@ AudioItemListReply *AudioProvider::getContactAudio(int uid, int count, int offse * \param offset * \return reply **/ -AudioItemListReply *AudioProvider::searchAudio(const QString& query, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool withLyrics, int count, int offset) +AudioItemListReply *AudioProvider::searchAudio(const QString& query, int count, int offset, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool withLyrics) { Q_D(AudioProvider); QVariantMap args; diff --git a/src/api/audio.h b/src/api/audio.h index c09c27b..6293e15 100644 --- a/src/api/audio.h +++ b/src/api/audio.h @@ -52,7 +52,7 @@ class VK_SHARED_EXPORT AudioProvider : public QObject AudioProvider(Client *client); virtual ~AudioProvider(); AudioItemListReply *getContactAudio(int uid = 0, int count = 50, int offset = 0); - AudioItemListReply *searchAudio(const QString& query, bool autoComplete = true, Vreen::AudioProvider::SortOrder sort = SortByPopularity, bool withLyrics = false, int count = 50, int offset = 0); + AudioItemListReply *searchAudio(const QString& query, int count = 50, int offset = 0, bool autoComplete = true, Vreen::AudioProvider::SortOrder sort = SortByPopularity, bool withLyrics = false); protected: QScopedPointer d_ptr; }; diff --git a/src/qml/src/audiomodel.cpp b/src/qml/src/audiomodel.cpp index e77bab9..fb20912 100644 --- a/src/qml/src/audiomodel.cpp +++ b/src/qml/src/audiomodel.cpp @@ -57,10 +57,10 @@ void AudioModel::getAudio(int count, int offset) } } -void AudioModel::searchAudio(const QString& query, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool lyrics, int count, int offset) +void AudioModel::searchAudio(const QString& query, int count, int offset, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool withLyrics) { if (m_provider.data()) { - auto reply = m_provider.data()->searchAudio(query, autoComplete, sort, lyrics, count, offset); + auto reply = m_provider.data()->searchAudio(query, count, offset, autoComplete, sort, withLyrics); connect(reply, SIGNAL(resultReady(QVariant)), this, SLOT(onResultReady())); } diff --git a/src/qml/src/audiomodel.h b/src/qml/src/audiomodel.h index 0c54100..7ea7130 100644 --- a/src/qml/src/audiomodel.h +++ b/src/qml/src/audiomodel.h @@ -43,7 +43,7 @@ class AudioModel : public Vreen::AudioModel void setOwner(Vreen::Contact* owner); public slots: void getAudio(int count = 100, int offset = 0); - void searchAudio(const QString& query, bool autoComplete = true, Vreen::AudioProvider::SortOrder sort = Vreen::AudioProvider::SortByPopularity, bool lyrics = false, int count = 50, int offset = 0); + void searchAudio(const QString& query, int count, int offset, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool withLyrics); signals: void ownerChanged(Vreen::Contact*); void requestFinished(); From f7196e5a7364e2be970204ae343399e0a31f4fa4 Mon Sep 17 00:00:00 2001 From: Alexey Shmalko Date: Fri, 23 Nov 2012 22:08:42 +0200 Subject: [PATCH 4/4] Return default parameters --- src/qml/src/audiomodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/src/audiomodel.h b/src/qml/src/audiomodel.h index 7ea7130..472e506 100644 --- a/src/qml/src/audiomodel.h +++ b/src/qml/src/audiomodel.h @@ -43,7 +43,7 @@ class AudioModel : public Vreen::AudioModel void setOwner(Vreen::Contact* owner); public slots: void getAudio(int count = 100, int offset = 0); - void searchAudio(const QString& query, int count, int offset, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool withLyrics); + void searchAudio(const QString& query, int count = 50, int offset = 0, bool autoComplete = true, Vreen::AudioProvider::SortOrder sort = Vreen::AudioProvider::SortByPopularity, bool withLyrics = false); signals: void ownerChanged(Vreen::Contact*); void requestFinished();