Skip to content
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

Добавление параметров в аудиозапросы #4

Merged
merged 4 commits into from
Nov 23, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/api/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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, int count, int offset, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool withLyrics)
{
Q_D(AudioProvider);
QVariantMap args;
args.insert("q", query);
args.insert("auto_complete", autoComplete);
args.insert("sort", static_cast<int>(sort));
args.insert("lyrics", withLyrics);
args.insert("count", count);
args.insert("offset", offset);
args.insert("auto_complete", d->autoComplete);

auto reply = d->client->request<AudioItemListReply>("audio.search", args, AudioProviderPrivate::handleAudio);
return reply;
Expand Down
12 changes: 10 additions & 2 deletions src/api/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне показалось или оно пробелы на табы заменило?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наоборот. Были табы

AudioItemListReply *searchAudio(const QString& query, int count = 50, int offset = 0, bool autoComplete = true, Vreen::AudioProvider::SortOrder sort = SortByPopularity, bool withLyrics = false);
protected:
QScopedPointer<AudioProviderPrivate> d_ptr;
};
Expand Down
4 changes: 2 additions & 2 deletions src/qml/src/audiomodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, int count, int offset, bool autoComplete, Vreen::AudioProvider::SortOrder sort, bool withLyrics)
{
if (m_provider.data()) {
auto reply = m_provider.data()->searchAudio(query, count, offset);
auto reply = m_provider.data()->searchAudio(query, count, offset, autoComplete, sort, withLyrics);
connect(reply, SIGNAL(resultReady(QVariant)),
this, SLOT(onResultReady()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/qml/src/audiomodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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();
Expand Down