From: APTX Date: Thu, 12 Jan 2012 20:06:51 +0000 (+0100) Subject: Fix File: actually reduce number of commands sent and make updateState work(). X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=445198f2cfd8b5c9b68ced5eeea913b50c5823eb;p=anidbudpclient.git Fix File: actually reduce number of commands sent and make updateState work(). --- diff --git a/file.cpp b/file.cpp index e1f2191..61f8bd9 100644 --- a/file.cpp +++ b/file.cpp @@ -181,18 +181,21 @@ void File::updateState() actionsQueue.enqueue(Adding); actionsQueue.enqueue(SettingState); + if (notWorking) work(); } void File::setState(const MyListState &state) { m_state = state; useDefaultState = false; + stateSet = false; } void File::clearState() { m_state = MyListState(); useDefaultState = true; + stateSet = false; } MyListState File::state() const @@ -266,17 +269,13 @@ qDebug() << "finishRenaming"; { bool ok; m_lid = fileReply->value(FileFlag::Lid).toInt(&ok); - +#ifdef ANIDBUDPCLIENT_FILE_DEBUG +qDebug() << "lid = " << m_lid; +#endif if (!ok) m_lid = 0; } - if (m_lid && actionsQueue.removeAll(Adding)) - { - updateStatus(Adding, Success); - AniDBUdpClient::Client::instance()->cancel(addReply); - } - QString name = fileReply->value(FileAnimeFlag::RomajiName).toString(); if (name.isEmpty()) name = fileReply->value(FileAnimeFlag::EnglishName).toString(); @@ -336,13 +335,9 @@ void File::finishAdding(bool success) } m_lid = addReply->lid(); + stateSet = addReply->stateSet(); updateStatus(Adding, Success); - - if ((addReply->replyCode() == MYLIST_ENTRY_ADDED - || addReply->replyCode() == MYLIST_ENTRY_EDITED) - && actionsQueue.removeAll(SettingState)) - updateStatus(SettingState, Success); } void File::finishMarking(bool success) @@ -362,6 +357,9 @@ void File::finishSetState(bool success) updateStatus(SettingState, Failure); return; } + + stateSet = addReply->stateSet(); + updateStatus(SettingState, Finished); } @@ -553,6 +551,12 @@ void File::startSetState() return; } + if (stateSet) + { + updateStatus(SettingState, Finished); + return; + } + MyListAddCommand setStateCommand; if (m_lid) setStateCommand = MyListAddCommand(m_lid); @@ -576,6 +580,7 @@ void File::init() staticInit(); m_lid = 0; + stateSet = false; m_size = 0; diff --git a/file.h b/file.h index 77a77ed..fc1235c 100644 --- a/file.h +++ b/file.h @@ -130,6 +130,7 @@ private: void updateStatus(Action action, ActionState actionState); int m_lid; + bool stateSet; QQueue actionsQueue;