Browse Source

WebUI: Improve btjson.* indentation.

adaptive-webui-19844
Vladimir Golovnev (Glassez) 10 years ago
parent
commit
c24610ec80
  1. 20
      src/webui/btjson.cpp
  2. 3
      src/webui/btjson.h

20
src/webui/btjson.cpp

@ -160,9 +160,11 @@ static QVariantMap toMap(const QTorrentHandle& h) @@ -160,9 +160,11 @@ static QVariantMap toMap(const QTorrentHandle& h)
state = "error";
else
state = h.is_seed(status) ? "pausedUP" : "pausedDL";
} else {
if (QBtSession::instance()->isQueueingEnabled() && h.is_queued(status))
}
else {
if (QBtSession::instance()->isQueueingEnabled() && h.is_queued(status)) {
state = h.is_seed(status) ? "queuedUP" : "queuedDL";
}
else {
switch (status.state) {
case torrent_status::finished:
@ -213,13 +215,16 @@ static QVariantMap toMap(const QTorrentHandle& h) @@ -213,13 +215,16 @@ static QVariantMap toMap(const QTorrentHandle& h)
*/
QByteArray btjson::getTorrents()
{
CACHED_VARIABLE(QVariantList, torrent_list, CACHE_DURATION_MS);
QVariantList torrent_list;
std::vector<torrent_handle> torrents = QBtSession::instance()->getTorrents();
std::vector<torrent_handle>::const_iterator it = torrents.begin();
std::vector<torrent_handle>::const_iterator end = torrents.end();
for( ; it != end; ++it) {
torrent_list.append(toMap(QTorrentHandle(*it)));
}
return json::toJson(torrent_list);
}
@ -262,7 +267,8 @@ QByteArray btjson::getTrackersForTorrent(const QString& hash) @@ -262,7 +267,8 @@ QByteArray btjson::getTrackersForTorrent(const QString& hash)
tracker_list.append(tracker_dict);
}
} catch(const std::exception& e) {
}
catch(const std::exception& e) {
qWarning() << Q_FUNC_INFO << "Invalid torrent: " << misc::toQStringU(e.what());
return QByteArray();
}
@ -323,7 +329,8 @@ QByteArray btjson::getPropertiesForTorrent(const QString& hash) @@ -323,7 +329,8 @@ QByteArray btjson::getPropertiesForTorrent(const QString& hash)
data[KEY_PROP_CONNECT_COUNT_LIMIT] = status.connections_limit;
const qreal ratio = QBtSession::instance()->getRealRatio(status);
data[KEY_PROP_RATIO] = ratio > 100. ? -1 : ratio;
} catch(const std::exception& e) {
}
catch(const std::exception& e) {
qWarning() << Q_FUNC_INFO << "Invalid torrent: " << misc::toQStringU(e.what());
return QByteArray();
}
@ -368,7 +375,8 @@ QByteArray btjson::getFilesForTorrent(const QString& hash) @@ -368,7 +375,8 @@ QByteArray btjson::getFilesForTorrent(const QString& hash)
file_list.append(file_dict);
}
} catch (const std::exception& e) {
}
catch (const std::exception& e) {
qWarning() << Q_FUNC_INFO << "Invalid torrent: " << misc::toQStringU(e.what());
return QByteArray();
}

3
src/webui/btjson.h

@ -34,7 +34,8 @@ @@ -34,7 +34,8 @@
#include <QCoreApplication>
#include <QString>
class btjson {
class btjson
{
Q_DECLARE_TR_FUNCTIONS(misc)
private:

Loading…
Cancel
Save