Performance optimization
This commit is contained in:
parent
b8791ff665
commit
41dfde3c87
17 changed files with 856 additions and 453 deletions
|
|
@ -421,9 +421,13 @@ CacheServer::CacheServer(QObject *parent) :
|
|||
QObject(parent)
|
||||
{
|
||||
server = new QHttpServer;
|
||||
|
||||
QObject::connect(server, SIGNAL(newRequest(QHttpRequest*, QHttpResponse*)),
|
||||
this, SLOT(handle(QHttpRequest*, QHttpResponse*)));
|
||||
server->listen(port);
|
||||
|
||||
if (!server->listen(port)) {
|
||||
qWarning() << "Cache server at localhost failed to start on" << this->port << "port!";
|
||||
}
|
||||
}
|
||||
|
||||
CacheServer::~CacheServer()
|
||||
|
|
@ -521,8 +525,10 @@ QString CacheServer::getUrlbyId(const QString &item)
|
|||
|
||||
QString CacheServer::getUrlbyUrl(const QString &url)
|
||||
{
|
||||
//qDebug() << "getUrlbyUrl, url=" << url << "hash=" << Utils::hash(url);
|
||||
|
||||
// If url is "image://" will not be hashed
|
||||
if (url.startsWith("image://")) {
|
||||
if (url.isEmpty() || url.startsWith("image://")) {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "databasemanager.h"
|
||||
|
||||
const QString DatabaseManager::version = QString("21");
|
||||
const QString DatabaseManager::version = QString("22");
|
||||
|
||||
DatabaseManager::DatabaseManager(QObject *parent) :
|
||||
QObject(parent)
|
||||
|
|
@ -127,7 +127,7 @@ bool DatabaseManager::isTableExists(const QString &name)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool DatabaseManager::alterDB_19to21()
|
||||
bool DatabaseManager::alterDB_19to22()
|
||||
{
|
||||
bool ret = true;
|
||||
if (db.isOpen()) {
|
||||
|
|
@ -136,6 +136,7 @@ bool DatabaseManager::alterDB_19to21()
|
|||
query.exec("PRAGMA journal_mode = MEMORY");
|
||||
query.exec("PRAGMA synchronous = OFF");
|
||||
|
||||
ret = query.exec("ALTER TABLE entries ADD COLUMN flag INTEGER DEFAULT 0;");
|
||||
ret = query.exec("ALTER TABLE entries ADD COLUMN annotations TEXT;");
|
||||
ret = query.exec("ALTER TABLE entries ADD COLUMN fresh_or INTEGER DEFAULT 0;");
|
||||
ret = query.exec("ALTER TABLE entries ADD COLUMN liked INTEGER DEFAULT 0;");
|
||||
|
|
@ -199,7 +200,7 @@ bool DatabaseManager::alterDB_19to21()
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = query.exec("UPDATE parameters SET value='21';");
|
||||
ret = query.exec("UPDATE parameters SET value='22';");
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
|
|
@ -214,7 +215,7 @@ bool DatabaseManager::alterDB_19to21()
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool DatabaseManager::alterDB_20to21()
|
||||
bool DatabaseManager::alterDB_20to22()
|
||||
{
|
||||
bool ret = true;
|
||||
if (db.isOpen()) {
|
||||
|
|
@ -223,6 +224,7 @@ bool DatabaseManager::alterDB_20to21()
|
|||
query.exec("PRAGMA journal_mode = MEMORY");
|
||||
query.exec("PRAGMA synchronous = OFF");
|
||||
|
||||
ret = query.exec("ALTER TABLE entries ADD COLUMN flag INTEGER DEFAULT 0;");
|
||||
ret = query.exec("ALTER TABLE entries ADD COLUMN annotations TEXT;");
|
||||
ret = query.exec("ALTER TABLE entries ADD COLUMN broadcast INTEGER DEFAULT 0;");
|
||||
ret = query.exec("ALTER TABLE actions ADD COLUMN text TEXT;");
|
||||
|
|
@ -232,7 +234,38 @@ bool DatabaseManager::alterDB_20to21()
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = query.exec("UPDATE parameters SET value='21';");
|
||||
ret = query.exec("UPDATE parameters SET value='22';");
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
return ret;
|
||||
}
|
||||
|
||||
} else {
|
||||
qWarning() << "DB is not opened!";
|
||||
return false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DatabaseManager::alterDB_21to22()
|
||||
{
|
||||
bool ret = true;
|
||||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
query.exec("PRAGMA journal_mode = MEMORY");
|
||||
query.exec("PRAGMA synchronous = OFF");
|
||||
|
||||
ret = query.exec("ALTER TABLE entries ADD COLUMN flag INTEGER DEFAULT 0;");
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = query.exec("UPDATE parameters SET value='22';");
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
|
|
@ -265,19 +298,26 @@ bool DatabaseManager::checkParameters()
|
|||
if (query.value(0).toString() != version) {
|
||||
qWarning() << "DB version mismatch!";
|
||||
|
||||
if (version == "21" && query.value(0).toString() == "1.9") {
|
||||
if (!alterDB_19to21()) {
|
||||
qWarning() << "DB migration 19->21 failed!";
|
||||
if (query.value(0).toString() == "1.9") {
|
||||
if (!alterDB_19to22()) {
|
||||
qWarning() << "DB migration 19->22 failed!";
|
||||
createDB = true;
|
||||
} else {
|
||||
qDebug() << "DB migration 19->21 succeed!";
|
||||
qDebug() << "DB migration 19->22 succeed!";
|
||||
}
|
||||
} else if (version == "21" && query.value(0).toString() == "2.0") {
|
||||
if (!alterDB_20to21()) {
|
||||
qWarning() << "DB migration 20->21 failed!";
|
||||
} else if (query.value(0).toString() == "2.0") {
|
||||
if (!alterDB_20to22()) {
|
||||
qWarning() << "DB migration 20->22 failed!";
|
||||
createDB = true;
|
||||
} else {
|
||||
qDebug() << "DB migration 20->21 succeed!";
|
||||
qDebug() << "DB migration 20->22 succeed!";
|
||||
}
|
||||
} else if (query.value(0).toString() == "21") {
|
||||
if (!alterDB_21to22()) {
|
||||
qWarning() << "DB migration 21->22 failed!";
|
||||
createDB = true;
|
||||
} else {
|
||||
qDebug() << "DB migration 21->22 succeed!";
|
||||
}
|
||||
} else {
|
||||
createDB = true;
|
||||
|
|
@ -629,6 +669,7 @@ bool DatabaseManager::createEntriesStructure()
|
|||
"liked INTEGER DEFAULT 0, "
|
||||
"cached INTEGER DEFAULT 0, "
|
||||
"broadcast INTEGER DEFAULT 0, "
|
||||
"flag INTEGER DEFAULT 0, "
|
||||
"created_at TIMESTAMP, "
|
||||
"published_at TIMESTAMP, "
|
||||
"cached_at TIMESTAMP, "
|
||||
|
|
@ -638,7 +679,7 @@ bool DatabaseManager::createEntriesStructure()
|
|||
");");
|
||||
ret = query.exec("CREATE INDEX IF NOT EXISTS entries_published_at "
|
||||
"ON entries(published_at DESC);");
|
||||
ret = query.exec("CREATE INDEX IF NOT EXISTS entries_date_by_stream "
|
||||
/*ret = query.exec("CREATE INDEX IF NOT EXISTS entries_date_by_stream "
|
||||
"ON entries(stream_id, published_at DESC);");
|
||||
ret = query.exec("CREATE INDEX IF NOT EXISTS entries_saved "
|
||||
"ON entries(saved, published_at);");
|
||||
|
|
@ -692,7 +733,7 @@ bool DatabaseManager::createEntriesStructure()
|
|||
ret = query.exec("CREATE INDEX IF NOT EXISTS entries_read_and_saved_by_stream_last_update "
|
||||
"ON entries(stream_id, read, saved, last_update);");
|
||||
ret = query.exec("CREATE INDEX IF NOT EXISTS entries_read_and_liked_by_stream_last_update "
|
||||
"ON entries(stream_id, read, liked, last_update);");
|
||||
"ON entries(stream_id, read, liked, last_update);");*/
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
|
|
@ -915,9 +956,34 @@ void DatabaseManager::writeEntry(const Entry &item)
|
|||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("INSERT INTO entries (id, stream_id, title, author, content, link, image, "
|
||||
bool ret = query.exec(QString("INSERT OR REPLACE INTO entries (id, stream_id, title, author, content, link, image, annotations, "
|
||||
"fresh, fresh_or, read, saved, liked, broadcast, created_at, published_at, crawl_time, timestamp, last_update, cached) "
|
||||
"VALUES ('%1','%2','%3','%4','%5','%6','%7','%8',%9,%10,%11,%12,%13,%14,%15,%16,%17,%18,%19, "
|
||||
"COALESCE((SELECT cached FROM entries WHERE id='%20'),0));")
|
||||
.arg(item.id)
|
||||
.arg(item.streamId)
|
||||
.arg(QString(item.title.toUtf8().toBase64()))
|
||||
.arg(QString(item.author.toUtf8().toBase64()))
|
||||
.arg(QString(item.content.toUtf8().toBase64()))
|
||||
.arg(QString(item.link.toUtf8().toBase64()))
|
||||
.arg(QString(item.image.toUtf8().toBase64()))
|
||||
.arg(QString(item.annotations.toUtf8().toBase64()))
|
||||
.arg(item.fresh)
|
||||
.arg(item.freshOR)
|
||||
.arg(item.read)
|
||||
.arg(item.saved)
|
||||
.arg(item.liked)
|
||||
.arg(item.broadcast)
|
||||
.arg(item.createdAt)
|
||||
.arg(item.publishedAt)
|
||||
.arg(item.crawlTime)
|
||||
.arg(item.timestamp)
|
||||
.arg(QDateTime::currentDateTimeUtc().toTime_t())
|
||||
.arg(item.id));
|
||||
|
||||
/*bool ret = query.exec(QString("INSERT INTO entries (id, stream_id, title, author, content, link, image, annotations, "
|
||||
"fresh, fresh_or, read, saved, liked, cached, broadcast, created_at, published_at, crawl_time, timestamp, last_update) "
|
||||
"VALUES ('%1','%2','%3','%4','%5','%6','%7',%8,%9,%10,%11,%12,%13,%14,%15,%16,%17,%18,%19);")
|
||||
"VALUES ('%1','%2','%3','%4','%5','%6','%7','%8',%9,%10,%11,%12,%13,%14,%15,%16,%17,%18,%19,%20);")
|
||||
.arg(item.id)
|
||||
.arg(item.streamId)
|
||||
.arg(QString(item.title.toUtf8().toBase64()))
|
||||
|
|
@ -925,6 +991,7 @@ void DatabaseManager::writeEntry(const Entry &item)
|
|||
.arg(QString(item.content.toUtf8().toBase64()))
|
||||
.arg(QString(item.link.toUtf8().toBase64()))
|
||||
.arg(QString(item.image.toUtf8().toBase64()))
|
||||
.arg(QString(item.annotations.toUtf8().toBase64()))
|
||||
.arg(item.fresh)
|
||||
.arg(item.freshOR)
|
||||
.arg(item.read)
|
||||
|
|
@ -939,12 +1006,13 @@ void DatabaseManager::writeEntry(const Entry &item)
|
|||
.arg(QDateTime::currentDateTimeUtc().toTime_t()));
|
||||
|
||||
if(!ret) {
|
||||
ret = query.exec(QString("UPDATE entries SET title='%1',author='%2',content='%3',link='%4',image='%5',fresh_or=%6,liked=%7,read=%8,saved=%9,broadcast=%10,timestamp=%11,last_update=%12,crawl_time=%13 WHERE id='%14';")
|
||||
ret = query.exec(QString("UPDATE entries SET title='%1',author='%2',content='%3',link='%4',image='%5',annotations='%6',fresh_or=%7,liked=%8,read=%9,saved=%10,broadcast=%11,timestamp=%12,last_update=%13,crawl_time=%14,flag=0 WHERE id='%15';")
|
||||
.arg(QString(item.title.toUtf8().toBase64()))
|
||||
.arg(QString(item.author.toUtf8().toBase64()))
|
||||
.arg(QString(item.content.toUtf8().toBase64()))
|
||||
.arg(QString(item.link.toUtf8().toBase64()))
|
||||
.arg(QString(item.image.toUtf8().toBase64()))
|
||||
.arg(QString(item.annotations.toUtf8().toBase64()))
|
||||
.arg(item.freshOR)
|
||||
.arg(item.liked)
|
||||
.arg(item.read)
|
||||
|
|
@ -954,7 +1022,7 @@ void DatabaseManager::writeEntry(const Entry &item)
|
|||
.arg(QDateTime::currentDateTimeUtc().toTime_t())
|
||||
.arg(item.crawlTime)
|
||||
.arg(item.id));
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
|
|
@ -981,6 +1049,22 @@ void DatabaseManager::updateEntriesFreshFlag(int flag)
|
|||
}
|
||||
}
|
||||
|
||||
void DatabaseManager::updateEntriesFlag(int flag)
|
||||
{
|
||||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("UPDATE entries SET flag=%1;").arg(flag));
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
}
|
||||
|
||||
} else {
|
||||
qWarning() << "DB is not opened!";
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseManager::updateEntriesCachedFlagByEntry(const QString &id, int cacheDate, int flag)
|
||||
{
|
||||
if (db.isOpen()) {
|
||||
|
|
@ -998,12 +1082,13 @@ void DatabaseManager::updateEntriesCachedFlagByEntry(const QString &id, int cach
|
|||
}
|
||||
}
|
||||
|
||||
void DatabaseManager::updateEntriesBroadcastFlagByEntry(const QString &id, int flag)
|
||||
void DatabaseManager::updateEntriesBroadcastFlagByEntry(const QString &id, int flag, const QString &annotations)
|
||||
{
|
||||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
bool ret = query.exec(QString("UPDATE entries SET broadcast=%1 WHERE id='%2';")
|
||||
bool ret = query.exec(QString("UPDATE entries SET broadcast=%1, annotations='%2' WHERE id='%3';")
|
||||
.arg(flag)
|
||||
.arg(QString(annotations.toUtf8().toBase64()))
|
||||
.arg(id));
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
|
|
@ -1618,6 +1703,33 @@ QList<QString> DatabaseManager::readCacheIdsOlderThan(int cacheDate, int limit)
|
|||
return list;
|
||||
}
|
||||
|
||||
/*QList<QString> DatabaseManager::readCacheIdsOlderThanByCrawlTime(int cacheDate, int limit)
|
||||
{
|
||||
QList<QString> list;
|
||||
|
||||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT id FROM cache WHERE entry_id IN "
|
||||
"(SELECT id FROM entries WHERE cached_at<%1 AND stream_id IN "
|
||||
"(SELECT stream_id FROM entries GROUP BY stream_id HAVING count(*)>%2));")
|
||||
.arg(cacheDate).arg(limit));
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
}
|
||||
|
||||
while(query.next()) {
|
||||
list.append(query.value(0).toString());
|
||||
}
|
||||
|
||||
} else {
|
||||
qWarning() << "DB is not open!";
|
||||
}
|
||||
|
||||
return list;
|
||||
}*/
|
||||
|
||||
QList<QString> DatabaseManager::readCacheFinalUrlsByStream(const QString &id, int limit)
|
||||
{
|
||||
QList<QString> list;
|
||||
|
|
@ -1626,7 +1738,7 @@ QList<QString> DatabaseManager::readCacheFinalUrlsByStream(const QString &id, in
|
|||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT c.final_url FROM cache as c, entries as e "
|
||||
"WHERE c.entry_id=e.id AND e.stream_id='%1' AND e.saved!=1 AND e.id NOT IN ("
|
||||
"WHERE c.entry_id=e.id AND e.stream_id='%1' AND e.saved!=1 AND e.broadcast!=1 AND e.liked!=1 AND e.id NOT IN ("
|
||||
"SELECT id FROM entries WHERE stream_id='%1' ORDER BY published_at DESC LIMIT %2"
|
||||
");").arg(id).arg(limit));
|
||||
|
||||
|
|
@ -2461,7 +2573,7 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesByStream(const QString
|
|||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, "
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, e.annotations, s.id, "
|
||||
"e.fresh, e.fresh_or, e.read, e.saved, e.liked, e.cached, e.broadcast, e.created_at, e.published_at, e.timestamp, e.crawl_time, e.last_update "
|
||||
"FROM entries as e, streams as s "
|
||||
"WHERE e.stream_id='%1' AND e.stream_id=s.id "
|
||||
|
|
@ -2483,17 +2595,19 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesByStream(const QString
|
|||
decodeBase64(query.value(6),item.image);
|
||||
decodeBase64(query.value(7),item.feedIcon);
|
||||
decodeBase64(query.value(8),item.feedTitle);
|
||||
item.fresh = query.value(9).toInt();
|
||||
item.freshOR = query.value(10).toInt();
|
||||
item.read = query.value(11).toInt();
|
||||
item.saved = query.value(12).toInt();
|
||||
item.liked = query.value(13).toInt();
|
||||
item.cached = query.value(14).toInt();
|
||||
item.broadcast = query.value(15).toInt();
|
||||
item.createdAt = query.value(16).toInt();
|
||||
item.publishedAt = query.value(17).toInt();
|
||||
item.timestamp = query.value(18).toInt();
|
||||
item.crawlTime = query.value(19).toInt();
|
||||
decodeBase64(query.value(9),item.annotations);
|
||||
item.feedId = query.value(10).toString();
|
||||
item.fresh = query.value(11).toInt();
|
||||
item.freshOR = query.value(12).toInt();
|
||||
item.read = query.value(13).toInt();
|
||||
item.saved = query.value(14).toInt();
|
||||
item.liked = query.value(15).toInt();
|
||||
item.cached = query.value(16).toInt();
|
||||
item.broadcast = query.value(17).toInt();
|
||||
item.createdAt = query.value(18).toInt();
|
||||
item.publishedAt = query.value(19).toInt();
|
||||
item.timestamp = query.value(20).toInt();
|
||||
item.crawlTime = query.value(21).toInt();
|
||||
list.append(item);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2510,7 +2624,7 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesByDashboard(const QStr
|
|||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, "
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, e.annotations, s.id, "
|
||||
"e.fresh, e.fresh_or, e.read, e.saved, e.liked, e.cached, e.broadcast, e.created_at, e.published_at, e.timestamp, e.crawl_time, e.last_update "
|
||||
"FROM entries as e, streams as s, module_stream as ms, modules as m, tabs as t "
|
||||
"WHERE e.stream_id=ms.stream_id AND e.stream_id=s.id AND ms.module_id=m.id AND m.tab_id=t.id "
|
||||
|
|
@ -2533,17 +2647,19 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesByDashboard(const QStr
|
|||
decodeBase64(query.value(6),item.image);
|
||||
decodeBase64(query.value(7),item.feedIcon);
|
||||
decodeBase64(query.value(8),item.feedTitle);
|
||||
item.fresh = query.value(9).toInt();
|
||||
item.freshOR = query.value(10).toInt();
|
||||
item.read = query.value(11).toInt();
|
||||
item.saved = query.value(12).toInt();
|
||||
item.liked = query.value(13).toInt();
|
||||
item.cached = query.value(14).toInt();
|
||||
item.broadcast = query.value(15).toInt();
|
||||
item.createdAt = query.value(16).toInt();
|
||||
item.publishedAt = query.value(17).toInt();
|
||||
item.timestamp = query.value(18).toInt();
|
||||
item.crawlTime = query.value(19).toInt();
|
||||
decodeBase64(query.value(9),item.annotations);
|
||||
item.feedId = query.value(10).toString();
|
||||
item.fresh = query.value(11).toInt();
|
||||
item.freshOR = query.value(12).toInt();
|
||||
item.read = query.value(13).toInt();
|
||||
item.saved = query.value(14).toInt();
|
||||
item.liked = query.value(15).toInt();
|
||||
item.cached = query.value(16).toInt();
|
||||
item.broadcast = query.value(17).toInt();
|
||||
item.createdAt = query.value(18).toInt();
|
||||
item.publishedAt = query.value(19).toInt();
|
||||
item.timestamp = query.value(20).toInt();
|
||||
item.crawlTime = query.value(21).toInt();
|
||||
list.append(item);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2560,7 +2676,7 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesUnreadByDashboard(cons
|
|||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, "
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, e.annotations, s.id, "
|
||||
"e.fresh, e.fresh_or, e.read, e.saved, e.liked, e.cached, e.broadcast, e.created_at, e.published_at, e.timestamp, e.crawl_time, e.last_update "
|
||||
"FROM entries as e, streams as s, module_stream as ms, modules as m, tabs as t "
|
||||
"WHERE e.stream_id=ms.stream_id AND e.stream_id=s.id AND ms.module_id=m.id AND m.tab_id=t.id "
|
||||
|
|
@ -2583,17 +2699,19 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesUnreadByDashboard(cons
|
|||
decodeBase64(query.value(6),item.image);
|
||||
decodeBase64(query.value(7),item.feedIcon);
|
||||
decodeBase64(query.value(8),item.feedTitle);
|
||||
item.fresh = query.value(9).toInt();
|
||||
item.freshOR = query.value(10).toInt();
|
||||
item.read = query.value(11).toInt();
|
||||
item.saved = query.value(12).toInt();
|
||||
item.liked = query.value(13).toInt();
|
||||
item.cached = query.value(14).toInt();
|
||||
item.broadcast = query.value(15).toInt();
|
||||
item.createdAt = query.value(16).toInt();
|
||||
item.publishedAt = query.value(17).toInt();
|
||||
item.timestamp = query.value(18).toInt();
|
||||
item.crawlTime = query.value(19).toInt();
|
||||
decodeBase64(query.value(9),item.annotations);
|
||||
item.feedId = query.value(10).toString();
|
||||
item.fresh = query.value(11).toInt();
|
||||
item.freshOR = query.value(12).toInt();
|
||||
item.read = query.value(13).toInt();
|
||||
item.saved = query.value(14).toInt();
|
||||
item.liked = query.value(15).toInt();
|
||||
item.cached = query.value(16).toInt();
|
||||
item.broadcast = query.value(17).toInt();
|
||||
item.createdAt = query.value(18).toInt();
|
||||
item.publishedAt = query.value(19).toInt();
|
||||
item.timestamp = query.value(20).toInt();
|
||||
item.crawlTime = query.value(21).toInt();
|
||||
list.append(item);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2610,7 +2728,7 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesSlowUnreadByDashboard(
|
|||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, "
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, e.annotations, s.id, "
|
||||
"e.fresh, e.fresh_or, e.read, e.saved, e.liked, e.cached, e.broadcast, e.created_at, e.published_at, e.timestamp, e.crawl_time, e.last_update "
|
||||
"FROM entries as e, streams as s, module_stream as ms, modules as m, tabs as t "
|
||||
"WHERE e.stream_id=ms.stream_id AND e.stream_id=s.id AND ms.module_id=m.id AND m.tab_id=t.id "
|
||||
|
|
@ -2633,17 +2751,19 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesSlowUnreadByDashboard(
|
|||
decodeBase64(query.value(6),item.image);
|
||||
decodeBase64(query.value(7),item.feedIcon);
|
||||
decodeBase64(query.value(8),item.feedTitle);
|
||||
item.fresh = query.value(9).toInt();
|
||||
item.freshOR = query.value(10).toInt();
|
||||
item.read = query.value(11).toInt();
|
||||
item.saved = query.value(12).toInt();
|
||||
item.liked = query.value(13).toInt();
|
||||
item.cached = query.value(14).toInt();
|
||||
item.broadcast = query.value(15).toInt();
|
||||
item.createdAt = query.value(16).toInt();
|
||||
item.publishedAt = query.value(17).toInt();
|
||||
item.timestamp = query.value(18).toInt();
|
||||
item.crawlTime = query.value(19).toInt();
|
||||
decodeBase64(query.value(9),item.annotations);
|
||||
item.feedId = query.value(10).toString();
|
||||
item.fresh = query.value(11).toInt();
|
||||
item.freshOR = query.value(12).toInt();
|
||||
item.read = query.value(13).toInt();
|
||||
item.saved = query.value(14).toInt();
|
||||
item.liked = query.value(15).toInt();
|
||||
item.cached = query.value(16).toInt();
|
||||
item.broadcast = query.value(17).toInt();
|
||||
item.createdAt = query.value(18).toInt();
|
||||
item.publishedAt = query.value(19).toInt();
|
||||
item.timestamp = query.value(20).toInt();
|
||||
item.crawlTime = query.value(21).toInt();
|
||||
list.append(item);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2660,7 +2780,7 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesByTab(const QString &i
|
|||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, "
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, e.annotations, s.id, "
|
||||
"e.fresh, e.fresh_or, e.read, e.saved, e.liked, e.cached, e.broadcast, e.created_at, e.published_at, e.timestamp, e.crawl_time, e.last_update "
|
||||
"FROM entries as e, streams as s, module_stream as ms, modules as m "
|
||||
"WHERE e.stream_id=ms.stream_id AND e.stream_id=s.id AND ms.module_id=m.id "
|
||||
|
|
@ -2683,17 +2803,19 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesByTab(const QString &i
|
|||
decodeBase64(query.value(6),item.image);
|
||||
decodeBase64(query.value(7),item.feedIcon);
|
||||
decodeBase64(query.value(8),item.feedTitle);
|
||||
item.fresh = query.value(9).toInt();
|
||||
item.freshOR = query.value(10).toInt();
|
||||
item.read = query.value(11).toInt();
|
||||
item.saved = query.value(12).toInt();
|
||||
item.liked = query.value(13).toInt();
|
||||
item.cached = query.value(14).toInt();
|
||||
item.broadcast = query.value(15).toInt();
|
||||
item.createdAt = query.value(16).toInt();
|
||||
item.publishedAt = query.value(17).toInt();
|
||||
item.timestamp = query.value(18).toInt();
|
||||
item.crawlTime = query.value(19).toInt();
|
||||
decodeBase64(query.value(9),item.annotations);
|
||||
item.feedId = query.value(10).toString();
|
||||
item.fresh = query.value(11).toInt();
|
||||
item.freshOR = query.value(12).toInt();
|
||||
item.read = query.value(13).toInt();
|
||||
item.saved = query.value(14).toInt();
|
||||
item.liked = query.value(15).toInt();
|
||||
item.cached = query.value(16).toInt();
|
||||
item.broadcast = query.value(17).toInt();
|
||||
item.createdAt = query.value(18).toInt();
|
||||
item.publishedAt = query.value(19).toInt();
|
||||
item.timestamp = query.value(20).toInt();
|
||||
item.crawlTime = query.value(21).toInt();
|
||||
list.append(item);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2710,7 +2832,7 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesUnreadByTab(const QStr
|
|||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, "
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, e.annotations, s.id, "
|
||||
"e.fresh, e.fresh_or, e.read, e.saved, e.liked, e.cached, e.broadcast, e.created_at, e.published_at, e.timestamp, e.crawl_time, e.last_update "
|
||||
"FROM entries as e, streams as s, module_stream as ms, modules as m "
|
||||
"WHERE e.stream_id=ms.stream_id AND e.stream_id=s.id AND ms.module_id=m.id "
|
||||
|
|
@ -2733,17 +2855,19 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesUnreadByTab(const QStr
|
|||
decodeBase64(query.value(6),item.image);
|
||||
decodeBase64(query.value(7),item.feedIcon);
|
||||
decodeBase64(query.value(8),item.feedTitle);
|
||||
item.fresh = query.value(9).toInt();
|
||||
item.freshOR = query.value(10).toInt();
|
||||
item.read = query.value(11).toInt();
|
||||
item.saved = query.value(12).toInt();
|
||||
item.liked = query.value(13).toInt();
|
||||
item.cached = query.value(14).toInt();
|
||||
item.broadcast = query.value(15).toInt();
|
||||
item.createdAt = query.value(16).toInt();
|
||||
item.publishedAt = query.value(17).toInt();
|
||||
item.timestamp = query.value(18).toInt();
|
||||
item.crawlTime = query.value(19).toInt();
|
||||
decodeBase64(query.value(9),item.annotations);
|
||||
item.feedId = query.value(10).toString();
|
||||
item.fresh = query.value(11).toInt();
|
||||
item.freshOR = query.value(12).toInt();
|
||||
item.read = query.value(13).toInt();
|
||||
item.saved = query.value(14).toInt();
|
||||
item.liked = query.value(15).toInt();
|
||||
item.cached = query.value(16).toInt();
|
||||
item.broadcast = query.value(17).toInt();
|
||||
item.createdAt = query.value(18).toInt();
|
||||
item.publishedAt = query.value(19).toInt();
|
||||
item.timestamp = query.value(20).toInt();
|
||||
item.crawlTime = query.value(21).toInt();
|
||||
list.append(item);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2760,7 +2884,7 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesSavedByDashboard(const
|
|||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, "
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, e.annotations, s.id, "
|
||||
"e.fresh, e.fresh_or, e.read, e.saved, e.liked, e.cached, e.broadcast, e.created_at, e.published_at, e.timestamp, e.crawl_time, e.last_update "
|
||||
"FROM entries as e, streams as s, module_stream as ms, modules as m, tabs as t "
|
||||
"WHERE e.stream_id=ms.stream_id AND e.stream_id=s.id AND ms.module_id=m.id AND m.tab_id=t.id "
|
||||
|
|
@ -2783,17 +2907,19 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesSavedByDashboard(const
|
|||
decodeBase64(query.value(6),item.image);
|
||||
decodeBase64(query.value(7),item.feedIcon);
|
||||
decodeBase64(query.value(8),item.feedTitle);
|
||||
item.fresh = query.value(9).toInt();
|
||||
item.freshOR = query.value(10).toInt();
|
||||
item.read = query.value(11).toInt();
|
||||
item.saved = query.value(12).toInt();
|
||||
item.liked = query.value(13).toInt();
|
||||
item.cached = query.value(14).toInt();
|
||||
item.broadcast = query.value(15).toInt();
|
||||
item.createdAt = query.value(16).toInt();
|
||||
item.publishedAt = query.value(17).toInt();
|
||||
item.timestamp = query.value(18).toInt();
|
||||
item.crawlTime = query.value(19).toInt();
|
||||
decodeBase64(query.value(9),item.annotations);
|
||||
item.feedId = query.value(10).toString();
|
||||
item.fresh = query.value(11).toInt();
|
||||
item.freshOR = query.value(12).toInt();
|
||||
item.read = query.value(13).toInt();
|
||||
item.saved = query.value(14).toInt();
|
||||
item.liked = query.value(15).toInt();
|
||||
item.cached = query.value(16).toInt();
|
||||
item.broadcast = query.value(17).toInt();
|
||||
item.createdAt = query.value(18).toInt();
|
||||
item.publishedAt = query.value(19).toInt();
|
||||
item.timestamp = query.value(20).toInt();
|
||||
item.crawlTime = query.value(21).toInt();
|
||||
list.append(item);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2810,7 +2936,7 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesSlowByDashboard(const
|
|||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, "
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, e.annotations, s.id, "
|
||||
"e.fresh, e.fresh_or, e.read, e.saved, e.liked, e.cached, e.broadcast, e.created_at, e.published_at, e.timestamp, e.crawl_time, e.last_update "
|
||||
"FROM entries as e, streams as s, module_stream as ms, modules as m, tabs as t "
|
||||
"WHERE e.stream_id=ms.stream_id AND e.stream_id=s.id AND ms.module_id=m.id AND m.tab_id=t.id "
|
||||
|
|
@ -2833,17 +2959,19 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesSlowByDashboard(const
|
|||
decodeBase64(query.value(6),item.image);
|
||||
decodeBase64(query.value(7),item.feedIcon);
|
||||
decodeBase64(query.value(8),item.feedTitle);
|
||||
item.fresh = query.value(9).toInt();
|
||||
item.freshOR = query.value(10).toInt();
|
||||
item.read = query.value(11).toInt();
|
||||
item.saved = query.value(12).toInt();
|
||||
item.liked = query.value(13).toInt();
|
||||
item.cached = query.value(14).toInt();
|
||||
item.broadcast = query.value(15).toInt();
|
||||
item.createdAt = query.value(16).toInt();
|
||||
item.publishedAt = query.value(17).toInt();
|
||||
item.timestamp = query.value(18).toInt();
|
||||
item.crawlTime = query.value(19).toInt();
|
||||
decodeBase64(query.value(9),item.annotations);
|
||||
item.feedId = query.value(10).toString();
|
||||
item.fresh = query.value(11).toInt();
|
||||
item.freshOR = query.value(12).toInt();
|
||||
item.read = query.value(13).toInt();
|
||||
item.saved = query.value(14).toInt();
|
||||
item.liked = query.value(15).toInt();
|
||||
item.cached = query.value(16).toInt();
|
||||
item.broadcast = query.value(17).toInt();
|
||||
item.createdAt = query.value(18).toInt();
|
||||
item.publishedAt = query.value(19).toInt();
|
||||
item.timestamp = query.value(20).toInt();
|
||||
item.crawlTime = query.value(21).toInt();
|
||||
list.append(item);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2860,7 +2988,7 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesUnreadByStream(const Q
|
|||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, "
|
||||
bool ret = query.exec(QString("SELECT e.id, e.stream_id, e.title, e.author, e.content, e.link, e.image, s.icon, s.title, e.annotations, s.id, "
|
||||
"e.fresh, e.fresh_or, e.read, e.saved, e.liked, e.cached, e.broadcast, e.created_at, e.published_at, e.timestamp, e.crawl_time, e.last_update "
|
||||
"FROM entries as e, streams as s "
|
||||
"WHERE e.stream_id='%1' AND e.stream_id=s.id AND e.read=0 "
|
||||
|
|
@ -2882,17 +3010,19 @@ QList<DatabaseManager::Entry> DatabaseManager::readEntriesUnreadByStream(const Q
|
|||
decodeBase64(query.value(6),item.image);
|
||||
decodeBase64(query.value(7),item.feedIcon);
|
||||
decodeBase64(query.value(8),item.feedTitle);
|
||||
item.fresh = query.value(9).toInt();
|
||||
item.freshOR = query.value(10).toInt();
|
||||
item.read = query.value(11).toInt();
|
||||
item.saved = query.value(12).toInt();
|
||||
item.liked = query.value(13).toInt();
|
||||
item.cached = query.value(14).toInt();
|
||||
item.broadcast = query.value(15).toInt();
|
||||
item.createdAt = query.value(16).toInt();
|
||||
item.publishedAt = query.value(17).toInt();
|
||||
item.timestamp = query.value(18).toInt();
|
||||
item.crawlTime = query.value(19).toInt();
|
||||
decodeBase64(query.value(9),item.annotations);
|
||||
item.feedId = query.value(10).toString();
|
||||
item.fresh = query.value(11).toInt();
|
||||
item.freshOR = query.value(12).toInt();
|
||||
item.read = query.value(13).toInt();
|
||||
item.saved = query.value(14).toInt();
|
||||
item.liked = query.value(15).toInt();
|
||||
item.cached = query.value(16).toInt();
|
||||
item.broadcast = query.value(17).toInt();
|
||||
item.createdAt = query.value(18).toInt();
|
||||
item.publishedAt = query.value(19).toInt();
|
||||
item.timestamp = query.value(20).toInt();
|
||||
item.crawlTime = query.value(21).toInt();
|
||||
list.append(item);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -3092,13 +3222,13 @@ void DatabaseManager::removeTabById(const QString &id)
|
|||
}
|
||||
}
|
||||
|
||||
void DatabaseManager::removeEntriesOlderThan(int cacheDate, int limit)
|
||||
/*void DatabaseManager::removeEntriesOlderThan(int cacheDate, int limit)
|
||||
{
|
||||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("DELETE FROM cache WHERE entry_id IN "
|
||||
"(SELECT id FROM entries WHERE saved!=1 AND cached_at<%1 AND stream_id IN "
|
||||
"(SELECT id FROM entries WHERE saved!=1 AND liked!=1 AND broadcast!=1 AND cached_at<%1 AND stream_id IN "
|
||||
"(SELECT stream_id FROM entries GROUP BY stream_id HAVING count(*)>%2));")
|
||||
.arg(cacheDate).arg(limit));
|
||||
|
||||
|
|
@ -3106,7 +3236,7 @@ void DatabaseManager::removeEntriesOlderThan(int cacheDate, int limit)
|
|||
checkError(query.lastError());
|
||||
}
|
||||
|
||||
ret = query.exec(QString("DELETE FROM entries WHERE saved!=1 AND cached_at<%1 AND stream_id IN "
|
||||
ret = query.exec(QString("DELETE FROM entries WHERE saved!=1 AND liked!=1 AND broadcast!=1 AND cached_at<%1 AND stream_id IN "
|
||||
"(SELECT stream_id FROM entries GROUP BY stream_id HAVING count(*)>%2);")
|
||||
.arg(cacheDate).arg(limit));
|
||||
|
||||
|
|
@ -3114,11 +3244,61 @@ void DatabaseManager::removeEntriesOlderThan(int cacheDate, int limit)
|
|||
checkError(query.lastError());
|
||||
}
|
||||
|
||||
} else {
|
||||
qWarning() << "DB is not open!";
|
||||
}
|
||||
}*/
|
||||
|
||||
void DatabaseManager::removeEntriesByFlag(int value)
|
||||
{
|
||||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("DELETE FROM cache WHERE entry_id IN "
|
||||
"(SELECT id FROM entries WHERE saved!=1 AND liked!=1 AND broadcast!=1 AND flag=%1);")
|
||||
.arg(value));
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
}
|
||||
|
||||
ret = query.exec(QString("DELETE FROM entries WHERE saved!=1 AND liked!=1 AND broadcast!=1 AND flag=%1;")
|
||||
.arg(value));
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
}
|
||||
|
||||
} else {
|
||||
qWarning() << "DB is not open!";
|
||||
}
|
||||
}
|
||||
|
||||
/*void DatabaseManager::removeEntriesOlderThanByCrawlTime(int cacheDate)
|
||||
{
|
||||
if (db.isOpen()) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
bool ret = query.exec(QString("DELETE FROM cache WHERE entry_id IN "
|
||||
"(SELECT id FROM entries WHERE saved!=1 AND liked!=1 AND broadcast!=1 AND crawl_time<%1);")
|
||||
.arg(cacheDate));
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
}
|
||||
|
||||
ret = query.exec(QString("DELETE FROM entries WHERE saved!=1 AND liked!=1 AND broadcast!=1 AND crawl_time<%1);")
|
||||
.arg(cacheDate));
|
||||
|
||||
if (!ret) {
|
||||
checkError(query.lastError());
|
||||
}
|
||||
|
||||
} else {
|
||||
qWarning() << "DB is not open!";
|
||||
}
|
||||
}*/
|
||||
|
||||
void DatabaseManager::removeEntriesByStream(const QString &id, int limit)
|
||||
{
|
||||
if (db.isOpen()) {
|
||||
|
|
@ -3148,6 +3328,8 @@ void DatabaseManager::removeEntriesByStream(const QString &id, int limit)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*void DatabaseManager::removeEntriesBySavedFlag(int flag)
|
||||
{
|
||||
if (db.isOpen()) {
|
||||
|
|
|
|||
|
|
@ -102,8 +102,10 @@ public:
|
|||
QString link;
|
||||
QString content;
|
||||
QString image;
|
||||
QString feedId;
|
||||
QString feedIcon;
|
||||
QString feedTitle;
|
||||
QString annotations;
|
||||
int fresh;
|
||||
int freshOR;
|
||||
int read;
|
||||
|
|
@ -186,8 +188,9 @@ public:
|
|||
void updateEntriesReadFlagByEntry(const QString &id, int flag);
|
||||
void updateEntriesSavedFlagByEntry(const QString &id, int flag);
|
||||
void updateEntriesCachedFlagByEntry(const QString &id, int cacheDate, int flag);
|
||||
void updateEntriesBroadcastFlagByEntry(const QString &id, int flag);
|
||||
void updateEntriesBroadcastFlagByEntry(const QString &id, int flag, const QString &annotations);
|
||||
void updateEntriesFreshFlag(int flag);
|
||||
void updateEntriesFlag(int flag);
|
||||
void updateEntriesSavedFlagByFlagAndDashboard(const QString &id, int flagOld, int flagNew);
|
||||
|
||||
void updateStreamSlowFlagById(const QString &id, int flag);
|
||||
|
|
@ -261,8 +264,10 @@ public:
|
|||
|
||||
void removeTabById(const QString &id);
|
||||
void removeStreamsByStream(const QString &id);
|
||||
void removeEntriesOlderThan(int cacheDate, int limit);
|
||||
//void removeEntriesOlderThan(int cacheDate, int limit);
|
||||
//void removeEntriesOlderThanByCrawlTime(int cacheDate);
|
||||
void removeEntriesByStream(const QString &id, int limit);
|
||||
void removeEntriesByFlag(int value);
|
||||
void removeActionsById(const QString &id);
|
||||
//void removeEntriesBySavedFlag(int flag);
|
||||
void removeCacheItems();
|
||||
|
|
@ -305,8 +310,9 @@ private:
|
|||
|
||||
bool openDB();
|
||||
bool createDB();
|
||||
bool alterDB_19to21();
|
||||
bool alterDB_20to21();
|
||||
bool alterDB_19to22();
|
||||
bool alterDB_20to22();
|
||||
bool alterDB_21to22();
|
||||
bool deleteDB();
|
||||
|
||||
bool createStructure();
|
||||
|
|
|
|||
|
|
@ -290,6 +290,8 @@ void DownloadManager::downloadFinished(QNetworkReply *reply)
|
|||
s->db->updateEntriesCachedFlagByEntry(item.entryId,QDateTime::currentDateTime().toTime_t(),5);
|
||||
break;
|
||||
case QNetworkReply::ContentNotFoundError:
|
||||
case QNetworkReply::ContentOperationNotPermittedError:
|
||||
case QNetworkReply::UnknownContentError:
|
||||
s->db->updateEntriesCachedFlagByEntry(item.entryId,QDateTime::currentDateTime().toTime_t(),6);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -323,6 +325,8 @@ void DownloadManager::downloadFinished(QNetworkReply *reply)
|
|||
item.flag = 5;
|
||||
break;
|
||||
case QNetworkReply::ContentNotFoundError:
|
||||
case QNetworkReply::ContentOperationNotPermittedError:
|
||||
case QNetworkReply::UnknownContentError:
|
||||
item.flag = 6;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -601,7 +605,7 @@ void DownloadManager::startFeedDownload()
|
|||
|
||||
//qDebug() << "DownloadManager::startFeedDownload()";
|
||||
if (!ncm.isOnline()) {
|
||||
qWarning() << "Network is Offline!";
|
||||
qWarning() << "Network is offline!";
|
||||
//emit networkNotAccessible();
|
||||
//return false;
|
||||
}
|
||||
|
|
@ -682,28 +686,48 @@ void DownloadManager::onlineDownload(const QString& id, const QString& url)
|
|||
item.type = "online-item";
|
||||
emit addDownload(item);
|
||||
return;
|
||||
|
||||
// Search by origUrl
|
||||
/*item = s->db->readCacheByOrigUrl(url);
|
||||
if (item.id == "") {
|
||||
qDebug() << "Search by origUrl not found";
|
||||
// No cache item -> downloaing
|
||||
//qDebug() << "No cache item -> downloaing";
|
||||
item.entryId = id;
|
||||
item.origUrl = url;
|
||||
item.finalUrl = url;
|
||||
item.baseUrl = url;
|
||||
item.type = "online-item";
|
||||
emit addDownload(item);
|
||||
return;
|
||||
}
|
||||
qDebug() << "Item found by origUrl! baseUrl=" << item.finalUrl;
|
||||
emit onlineDownloadReady("", item.baseUrl);*/
|
||||
}
|
||||
}
|
||||
|
||||
void CacheCleaner::run() {
|
||||
void CacheCleaner::run()
|
||||
{
|
||||
Settings *s = Settings::instance();
|
||||
if (s->getSigninType() < 10)
|
||||
cleanNv();
|
||||
else
|
||||
cleanOr();
|
||||
}
|
||||
|
||||
void CacheCleaner::cleanOr()
|
||||
{
|
||||
Settings *s = Settings::instance();
|
||||
|
||||
if (s->getRetentionDays()<1) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDir cacheDir(s->getDmCacheDir());
|
||||
QDateTime date = QDateTime::currentDateTime().addDays(0-s->getRetentionDays());
|
||||
|
||||
if (cacheDir.exists()) {
|
||||
QFileInfoList infoList = cacheDir.entryInfoList(QDir::Files,QDir::Time);
|
||||
Q_FOREACH(QFileInfo info, infoList){
|
||||
if (info.created() < date) {
|
||||
if (QFile::remove(info.absoluteFilePath())) {
|
||||
qDebug() << "Cache cleaner:" << info.fileName() << "deleted!";
|
||||
} else {
|
||||
qWarning() << "Cache cleaner:" << info.fileName() << " is old but can not be deleted!";
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
QThread::msleep(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CacheCleaner::cleanNv()
|
||||
{
|
||||
Settings *s = Settings::instance();
|
||||
QString cacheDir = s->getDmCacheDir();
|
||||
|
||||
|
|
|
|||
|
|
@ -90,11 +90,11 @@ class CacheCleaner : public QThread
|
|||
protected:
|
||||
void run();
|
||||
|
||||
/*signals:
|
||||
void ready();*/
|
||||
|
||||
private:
|
||||
static const int entriesLimit = 100;
|
||||
|
||||
void cleanNv();
|
||||
void cleanOr();
|
||||
};
|
||||
|
||||
class Checker: public QObject
|
||||
|
|
|
|||
|
|
@ -192,38 +192,41 @@ int EntryModel::createItems(int offset, int limit)
|
|||
if (dateRow>prevDateRow) {
|
||||
switch (dateRow) {
|
||||
case 1:
|
||||
appendRow(new EntryItem("daterow",tr("Today"),"","","","","","",false,false,false,0,0,0,0));
|
||||
appendRow(new EntryItem("daterow",tr("Today"),"","","","","","","","",false,false,false,0,0,0,0));
|
||||
break;
|
||||
case 2:
|
||||
appendRow(new EntryItem("daterow",tr("Yesterday"),"","","","","","",false,false,false,0,0,0,0));
|
||||
appendRow(new EntryItem("daterow",tr("Yesterday"),"","","","","","","","",false,false,false,0,0,0,0));
|
||||
break;
|
||||
case 3:
|
||||
appendRow(new EntryItem("daterow",tr("Current week"),"","","","","","",false,false,false,0,0,0,0));
|
||||
appendRow(new EntryItem("daterow",tr("Current week"),"","","","","","","","",false,false,false,0,0,0,0));
|
||||
break;
|
||||
case 4:
|
||||
appendRow(new EntryItem("daterow",tr("Current month"),"","","","","","",false,false,false,0,0,0,0));
|
||||
appendRow(new EntryItem("daterow",tr("Current month"),"","","","","","","","",false,false,false,0,0,0,0));
|
||||
break;
|
||||
case 5:
|
||||
appendRow(new EntryItem("daterow",tr("Previous month"),"","","","","","",false,false,false,0,0,0,0));
|
||||
appendRow(new EntryItem("daterow",tr("Previous month"),"","","","","","","","",false,false,false,0,0,0,0));
|
||||
break;
|
||||
case 6:
|
||||
appendRow(new EntryItem("daterow",tr("Current year"),"","","","","","",false,false,false,0,0,0,0));
|
||||
appendRow(new EntryItem("daterow",tr("Current year"),"","","","","","","","",false,false,false,0,0,0,0));
|
||||
break;
|
||||
default:
|
||||
appendRow(new EntryItem("daterow",tr("Previous year & older"),"","","","","","",false,false,false,0,0,0,0));
|
||||
appendRow(new EntryItem("daterow",tr("Previous year & older"),"","","","","","","","",false,false,false,0,0,0,0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
prevDateRow = dateRow;
|
||||
//qDebug() << "(*i).broadcast" << (*i).broadcast;
|
||||
//qDebug() << (*i).id << (*i).link;
|
||||
appendRow(new EntryItem((*i).id,
|
||||
title.remove(re),
|
||||
(*i).author,
|
||||
content,
|
||||
(*i).link,
|
||||
imageOk? (*i).image : "",
|
||||
(*i).feedId,
|
||||
(*i).feedIcon,
|
||||
(*i).feedTitle.remove(re),
|
||||
(*i).annotations,
|
||||
_db->isCacheExistsByEntryId((*i).id),
|
||||
(*i).broadcast==1,
|
||||
(*i).liked==1,
|
||||
|
|
@ -237,7 +240,7 @@ int EntryModel::createItems(int offset, int limit)
|
|||
|
||||
// Dummy row as workaround!
|
||||
if (list.count()>0)
|
||||
appendRow(new EntryItem("last","","","","","","","",false,false,false,0,0,0,0));
|
||||
appendRow(new EntryItem("last","","","","","","","","","",false,false,false,0,0,0,0));
|
||||
|
||||
return list.count();
|
||||
}
|
||||
|
|
@ -455,7 +458,7 @@ int EntryModel::count()
|
|||
return this->rowCount();
|
||||
}
|
||||
|
||||
void EntryModel::setData(int row, const QString &fieldName, QVariant newValue)
|
||||
void EntryModel::setData(int row, const QString &fieldName, QVariant newValue, QVariant newValue2)
|
||||
{
|
||||
EntryItem* item = static_cast<EntryItem*>(readRow(row));
|
||||
Settings *s = Settings::instance();
|
||||
|
|
@ -495,24 +498,29 @@ void EntryModel::setData(int row, const QString &fieldName, QVariant newValue)
|
|||
}
|
||||
|
||||
if (fieldName=="broadcast") {
|
||||
#ifdef KAKTUS_LIGHT
|
||||
return;
|
||||
#endif
|
||||
if (s->getSigninType() < 10) {
|
||||
// Broadcast not supported in API
|
||||
qWarning() << "Broadcast is not supported!";
|
||||
return;
|
||||
}
|
||||
item->setBroadcast(newValue.toBool());
|
||||
item->setBroadcast(newValue.toBool(),newValue2.toString());
|
||||
DatabaseManager::Action action;
|
||||
if (newValue.toBool()) {
|
||||
action.type = DatabaseManager::SetBroadcast;
|
||||
action.id1 = item->id();
|
||||
action.date1 = item->date();
|
||||
action.text = newValue2.toString();
|
||||
} else {
|
||||
action.type = DatabaseManager::UnSetBroadcast;
|
||||
action.id1 = item->id();
|
||||
action.date1 = item->date();
|
||||
action.text = newValue2.toString();
|
||||
}
|
||||
_db->writeAction(action);
|
||||
_db->updateEntriesReadFlagByEntry(item->id(),newValue.toInt());
|
||||
_db->updateEntriesBroadcastFlagByEntry(item->id(),newValue.toInt(),"");
|
||||
}
|
||||
|
||||
if (fieldName=="cached") {
|
||||
|
|
@ -528,8 +536,10 @@ EntryItem::EntryItem(const QString &uid,
|
|||
const QString &content,
|
||||
const QString &link,
|
||||
const QString &image,
|
||||
const QString &feedId,
|
||||
const QString &feedIcon,
|
||||
const QString &feedTitle,
|
||||
const QString &annotations,
|
||||
const bool cached,
|
||||
const bool broadcast,
|
||||
const bool liked,
|
||||
|
|
@ -545,8 +555,10 @@ EntryItem::EntryItem(const QString &uid,
|
|||
m_content(content),
|
||||
m_link(link),
|
||||
m_image(image),
|
||||
m_feedId(feedId),
|
||||
m_feedIcon(feedIcon),
|
||||
m_feedTitle(feedTitle),
|
||||
m_annotations(annotations),
|
||||
m_cached(cached),
|
||||
m_broadcast(broadcast),
|
||||
m_liked(liked),
|
||||
|
|
@ -565,8 +577,10 @@ QHash<int, QByteArray> EntryItem::roleNames() const
|
|||
names[ContentRole] = "content";
|
||||
names[LinkRole] = "link";
|
||||
names[ImageRole] = "image";
|
||||
names[FeedIdRole] = "feedId";
|
||||
names[FeedIconRole] = "feedIcon";
|
||||
names[FeedTitleRole] = "feedTitle";
|
||||
names[AnnotationsRole] = "annotations";
|
||||
names[CachedRole] = "cached";
|
||||
names[BroadcastRole] = "broadcast";
|
||||
names[LikedRole] = "liked";
|
||||
|
|
@ -592,10 +606,14 @@ QVariant EntryItem::data(int role) const
|
|||
return link();
|
||||
case ImageRole:
|
||||
return image();
|
||||
case FeedIdRole:
|
||||
return feedId();
|
||||
case FeedIconRole:
|
||||
return feedIcon();
|
||||
case FeedTitleRole:
|
||||
return feedTitle();
|
||||
case AnnotationsRole:
|
||||
return annotations();
|
||||
case CachedRole:
|
||||
return cached();
|
||||
case BroadcastRole:
|
||||
|
|
@ -631,10 +649,11 @@ void EntryItem::setRead(int value)
|
|||
}
|
||||
}
|
||||
|
||||
void EntryItem::setBroadcast(bool value)
|
||||
void EntryItem::setBroadcast(bool value, const QString &annotations)
|
||||
{
|
||||
if(m_broadcast!=value) {
|
||||
m_broadcast = value;
|
||||
m_annotations = annotations;
|
||||
emit dataChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,10 @@ public:
|
|||
ContentRole,
|
||||
LinkRole,
|
||||
ImageRole,
|
||||
FeedIdRole,
|
||||
FeedIconRole,
|
||||
FeedTitleRole,
|
||||
AnnotationsRole,
|
||||
CachedRole,
|
||||
BroadcastRole,
|
||||
LikedRole,
|
||||
|
|
@ -61,8 +63,10 @@ public:
|
|||
const QString &content,
|
||||
const QString &link,
|
||||
const QString &image,
|
||||
const QString &feedId,
|
||||
const QString &feedIcon,
|
||||
const QString &feedTitle,
|
||||
const QString &annotations,
|
||||
const bool cached,
|
||||
const bool broadcast,
|
||||
const bool liked,
|
||||
|
|
@ -80,8 +84,10 @@ public:
|
|||
inline QString content() const { return m_content; }
|
||||
inline QString link() const { return m_link; }
|
||||
inline QString image() const { return m_image; }
|
||||
inline QString feedId() const { return m_feedId; }
|
||||
inline QString feedIcon() const { return m_feedIcon; }
|
||||
inline QString feedTitle() const { return m_feedTitle; }
|
||||
inline QString annotations() const { return m_annotations; }
|
||||
inline bool cached() const { return m_cached; }
|
||||
inline bool broadcast() const { return m_broadcast; }
|
||||
inline bool liked() const { return m_liked; }
|
||||
|
|
@ -92,7 +98,7 @@ public:
|
|||
|
||||
void setReadlater(int value);
|
||||
void setRead(int value);
|
||||
void setBroadcast(bool value);
|
||||
void setBroadcast(bool value, const QString &annotations);
|
||||
void setCached(int value);
|
||||
|
||||
private:
|
||||
|
|
@ -102,8 +108,10 @@ private:
|
|||
QString m_content;
|
||||
QString m_link;
|
||||
QString m_image;
|
||||
QString m_feedId;
|
||||
QString m_feedIcon;
|
||||
QString m_feedTitle;
|
||||
QString m_annotations;
|
||||
bool m_cached;
|
||||
bool m_broadcast;
|
||||
bool m_liked;
|
||||
|
|
@ -123,7 +131,7 @@ public:
|
|||
explicit EntryModel(DatabaseManager* db, QObject *parent = 0);
|
||||
void init(const QString &feedId);
|
||||
|
||||
Q_INVOKABLE void setData(int row, const QString &fieldName, QVariant newValue);
|
||||
Q_INVOKABLE void setData(int row, const QString &fieldName, QVariant newValue, QVariant newValue2);
|
||||
|
||||
Q_INVOKABLE void setAllAsUnread();
|
||||
Q_INVOKABLE void setAllAsRead();
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include <QJsonValue>
|
||||
#include <QJsonArray>
|
||||
#else
|
||||
#include "qjson.h"
|
||||
#include "parser.h"
|
||||
#endif
|
||||
|
||||
#include "fetcher.h"
|
||||
|
|
@ -107,8 +107,6 @@ bool Fetcher::init()
|
|||
|
||||
setBusy(true, Fetcher::Initiating);
|
||||
|
||||
//TODO ....
|
||||
|
||||
signIn();
|
||||
emit progress(0,100);
|
||||
return true;
|
||||
|
|
@ -145,8 +143,6 @@ bool Fetcher::update()
|
|||
setBusy(true, Fetcher::Updating);
|
||||
}
|
||||
|
||||
//TODO ....
|
||||
|
||||
signIn();
|
||||
emit progress(0,100);
|
||||
return true;
|
||||
|
|
@ -154,7 +150,6 @@ bool Fetcher::update()
|
|||
|
||||
void Fetcher::cancel()
|
||||
{
|
||||
//disconnect(ncm, SIGNAL(onlineStateChanged(bool)), this, SLOT(delayedUpdate(bool)));
|
||||
if (busyType == Fetcher::UpdatingWaiting ||
|
||||
busyType == Fetcher::InitiatingWaiting ||
|
||||
busyType == Fetcher::CheckingCredentialsWaiting) {
|
||||
|
|
@ -185,8 +180,6 @@ bool Fetcher::checkCredentials()
|
|||
|
||||
setBusy(true, Fetcher::CheckingCredentials);
|
||||
|
||||
//TODO ...
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -245,8 +238,6 @@ bool Fetcher::delayedUpdate(bool state)
|
|||
return false;
|
||||
}
|
||||
|
||||
//TODO .....
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -265,12 +256,14 @@ void Fetcher::networkError(QNetworkReply::NetworkError e)
|
|||
int code = currentReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QByteArray phrase = currentReply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray();
|
||||
//emit error(500);
|
||||
qWarning() << "Network error!, error code:" << e << ", HTTP code:" << code << phrase << currentReply->readAll();
|
||||
qWarning() << "Network error!" << "Url:" << currentReply->url().toString() << "Error code:" << e
|
||||
<< "HTTP code:" << code << phrase << "Content:" << currentReply->readAll();
|
||||
}
|
||||
}
|
||||
|
||||
bool Fetcher::parse()
|
||||
{
|
||||
//qint64 date1 = QDateTime::currentMSecsSinceEpoch();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
||||
if (!doc.isObject()) {
|
||||
|
|
@ -279,7 +272,7 @@ bool Fetcher::parse()
|
|||
}
|
||||
jsonObj = doc.object();
|
||||
#else
|
||||
QJson qjson(this);
|
||||
QJson::Parser qjson;
|
||||
bool ok;
|
||||
jsonObj = qjson.parse(data, &ok).toMap();
|
||||
if (!ok) {
|
||||
|
|
@ -291,6 +284,7 @@ bool Fetcher::parse()
|
|||
return false;
|
||||
}
|
||||
#endif
|
||||
//qDebug() << "parse time:" << (QDateTime::currentMSecsSinceEpoch() - date1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include "databasemanager.h"
|
||||
#include "downloadmanager.h"
|
||||
#include "cacheserver.h"
|
||||
#include "netvibesfetcher.h"
|
||||
#include "utils.h"
|
||||
#include "settings.h"
|
||||
#include "networkaccessmanagerfactory.h"
|
||||
|
|
@ -42,9 +41,9 @@
|
|||
using namespace bb::cascades;
|
||||
|
||||
#ifdef KAKTUS_LIGHT
|
||||
static const char *VERSION = "1.3 (light edition)";
|
||||
static const char *VERSION = "2.0 (light edition)";
|
||||
#else
|
||||
static const char *VERSION = "1.3";
|
||||
static const char *VERSION = "2.0";
|
||||
#endif
|
||||
static const char *AUTHOR = "Michal Kosciesza <michal@mkiol.net>";
|
||||
static const char *PAGE = "https://github.com/mkiol/kaktus";
|
||||
|
|
@ -87,8 +86,6 @@ Q_DECL_EXPORT int main(int argc, char **argv)
|
|||
settings->dm = &dm;
|
||||
CacheServer cache(&db);
|
||||
settings->cache = &cache;
|
||||
NetvibesFetcher fetcher;
|
||||
settings->fetcher = &fetcher;
|
||||
Utils utils;
|
||||
bb::device::DisplayInfo display;
|
||||
|
||||
|
|
@ -96,7 +93,6 @@ Q_DECL_EXPORT int main(int argc, char **argv)
|
|||
model->setRootPath("app/");
|
||||
|
||||
settings->qml->setContextProperty("db", &db);
|
||||
settings->qml->setContextProperty("fetcher", &fetcher);
|
||||
settings->qml->setContextProperty("utils", &utils);
|
||||
settings->qml->setContextProperty("dm", &dm);
|
||||
settings->qml->setContextProperty("cache", &cache);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
//#include "oldreaderfetcher.h"
|
||||
#include "utils.h"
|
||||
#include "settings.h"
|
||||
#include "proxy.h"
|
||||
|
||||
static const char *APP_NAME = "Kaktus";
|
||||
static const char *AUTHOR = "Michal Kosciesza <michal@mkiol.net>";
|
||||
|
|
|
|||
|
|
@ -25,8 +25,9 @@
|
|||
#include <QJsonArray>
|
||||
#include <QStringList>
|
||||
#include <QDateTime>
|
||||
#include <math.h>
|
||||
#else
|
||||
#include "qjson.h"
|
||||
#include "parser.h"
|
||||
#endif
|
||||
|
||||
#include "oldreaderfetcher.h"
|
||||
|
|
@ -112,9 +113,6 @@ void OldReaderFetcher::setAction()
|
|||
|
||||
Settings *s = Settings::instance();
|
||||
|
||||
//qDebug() << "########### setAction";
|
||||
//qDebug() << action.type << action.id1 << action.id2 << action.date1 << action.date2;
|
||||
|
||||
if (currentReply != NULL) {
|
||||
currentReply->disconnect();
|
||||
currentReply->deleteLater();
|
||||
|
|
@ -176,7 +174,10 @@ void OldReaderFetcher::setAction()
|
|||
break;
|
||||
case DatabaseManager::SetBroadcast:
|
||||
url.setUrl("https://theoldreader.com/reader/api/0/edit-tag");
|
||||
body = QString("a=user/-/state/com.google/broadcast&i=%1").arg(action.id1);
|
||||
if (action.text == "")
|
||||
body = QString("a=user/-/state/com.google/broadcast&i=%1").arg(action.id1);
|
||||
else
|
||||
body = QString("a=user/-/state/com.google/broadcast&i=%1&annotation=%2").arg(action.id1).arg(action.text);
|
||||
break;
|
||||
case DatabaseManager::UnSetBroadcast:
|
||||
url.setUrl("https://theoldreader.com/reader/api/0/edit-tag");
|
||||
|
|
@ -195,8 +196,6 @@ void OldReaderFetcher::setAction()
|
|||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
request.setRawHeader("Authorization",QString("GoogleLogin auth=%1").arg(s->getCookie()).toLatin1());
|
||||
|
||||
//qDebug() << body;
|
||||
|
||||
currentReply = nam.post(request,body.toUtf8());
|
||||
|
||||
connect(currentReply, SIGNAL(finished()), this, SLOT(finishedSetAction()));
|
||||
|
|
@ -219,7 +218,6 @@ void OldReaderFetcher::fetchFriends()
|
|||
QUrl url("https://theoldreader.com/reader/api/0/friend/list?output=json");
|
||||
QNetworkRequest request(url);
|
||||
|
||||
// Authorization header
|
||||
request.setRawHeader("Authorization",QString("GoogleLogin auth=%1").arg(s->getCookie()).toLatin1());
|
||||
|
||||
currentReply = nam.get(request);
|
||||
|
|
@ -246,7 +244,6 @@ void OldReaderFetcher::fetchTabs()
|
|||
QUrl url("https://theoldreader.com/reader/api/0/tag/list?output=json");
|
||||
QNetworkRequest request(url);
|
||||
|
||||
// Authorization header
|
||||
request.setRawHeader("Authorization",QString("GoogleLogin auth=%1").arg(s->getCookie()).toLatin1());
|
||||
|
||||
currentReply = nam.get(request);
|
||||
|
|
@ -272,7 +269,6 @@ void OldReaderFetcher::fetchFeeds()
|
|||
QUrl url("https://theoldreader.com/reader/api/0/subscription/list?output=json");
|
||||
QNetworkRequest request(url);
|
||||
|
||||
// Authorization header
|
||||
request.setRawHeader("Authorization",QString("GoogleLogin auth=%1").arg(s->getCookie()).toLatin1());
|
||||
|
||||
currentReply = nam.get(request);
|
||||
|
|
@ -282,49 +278,8 @@ void OldReaderFetcher::fetchFeeds()
|
|||
connect(currentReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
void OldReaderFetcher::fetchStreamUpdate()
|
||||
{
|
||||
QString feedId = feedUpdateList.first().streamId;
|
||||
//qDebug() << "fetchStreamUpdate, feedId=" << feedId;
|
||||
|
||||
data.clear();
|
||||
|
||||
Settings *s = Settings::instance();
|
||||
|
||||
if (currentReply != NULL) {
|
||||
currentReply->disconnect();
|
||||
currentReply->deleteLater();
|
||||
currentReply = NULL;
|
||||
}
|
||||
|
||||
QUrl url;
|
||||
if (lastContinuation == "")
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&s=%2")
|
||||
.arg(limitAtOnceForUpdate).arg(feedId));
|
||||
else
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&s=%2&c=%3")
|
||||
.arg(limitAtOnceForUpdate).arg(feedId).arg(lastContinuation));
|
||||
QNetworkRequest request(url);
|
||||
|
||||
// Authorization header
|
||||
request.setRawHeader("Authorization",QString("GoogleLogin auth=%1").arg(s->getCookie()).toLatin1());
|
||||
|
||||
currentReply = nam.get(request);
|
||||
|
||||
connect(currentReply, SIGNAL(finished()), this, SLOT(finishedStreamUpdate()));
|
||||
connect(currentReply, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
||||
connect(currentReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
void OldReaderFetcher::fetchStream()
|
||||
{
|
||||
QString feedId;
|
||||
if (busyType == Fetcher::Updating)
|
||||
feedId = feedList.first().streamId;
|
||||
else
|
||||
feedId = feedUpdateList.first().streamId;
|
||||
//qDebug() << "fetchStream, feedId=" << feedId;
|
||||
|
||||
data.clear();
|
||||
|
||||
Settings *s = Settings::instance();
|
||||
|
|
@ -336,17 +291,35 @@ void OldReaderFetcher::fetchStream()
|
|||
}
|
||||
|
||||
QUrl url;
|
||||
if (lastContinuation == "")
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&s=%2")
|
||||
.arg(limitAtOnce).arg(feedId));
|
||||
else
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&s=%2&c=%3")
|
||||
.arg(limitAtOnce).arg(feedId).arg(lastContinuation));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
QString st(QUrl::toPercentEncoding("user/-/state/com.google/reading-list"));
|
||||
#else
|
||||
QString st = "user/-/state/com.google/reading-list";
|
||||
#endif
|
||||
int epoch = s->getRetentionDays() > 0 ?
|
||||
QDateTime::currentDateTimeUtc().addDays(0-s->getRetentionDays()).toTime_t() :
|
||||
0;
|
||||
if (lastContinuation == "") {
|
||||
if (epoch > 0)
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&ot=%2&s=%3")
|
||||
.arg(limitAtOnce).arg(epoch).arg(st));
|
||||
else
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&s=%2")
|
||||
.arg(limitAtOnce).arg(st));
|
||||
} else {
|
||||
if (epoch > 0)
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&c=%2&ot=%3&s=%4")
|
||||
.arg(limitAtOnce).arg(lastContinuation).arg(epoch).arg(st));
|
||||
else
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&c=%2&s=%3")
|
||||
.arg(limitAtOnce).arg(lastContinuation).arg(st));
|
||||
}
|
||||
QNetworkRequest request(url);
|
||||
|
||||
// Authorization header
|
||||
request.setRawHeader("Authorization",QString("GoogleLogin auth=%1").arg(s->getCookie()).toLatin1());
|
||||
|
||||
//qDebug() << url.toString();
|
||||
|
||||
currentReply = nam.get(request);
|
||||
|
||||
connect(currentReply, SIGNAL(finished()), this, SLOT(finishedStream()));
|
||||
|
|
@ -356,7 +329,6 @@ void OldReaderFetcher::fetchStream()
|
|||
|
||||
void OldReaderFetcher::fetchStarredStream()
|
||||
{
|
||||
//qDebug() << "fetchStarredStream, lastContinuation=" << lastContinuation << "continuationCount=" << continuationCount;
|
||||
data.clear();
|
||||
|
||||
Settings *s = Settings::instance();
|
||||
|
|
@ -368,15 +340,19 @@ void OldReaderFetcher::fetchStarredStream()
|
|||
}
|
||||
|
||||
QUrl url;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
QString st(QUrl::toPercentEncoding("user/-/state/com.google/starred"));
|
||||
#else
|
||||
QString st = "user/-/state/com.google/starred";
|
||||
#endif
|
||||
if (lastContinuation == "")
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&s=user/-/state/com.google/starred")
|
||||
.arg(limitAtOnceForStarred));
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&s=%2")
|
||||
.arg(limitAtOnce).arg(st));
|
||||
else
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&c=%2&s=user/-/state/com.google/starred")
|
||||
.arg(limitAtOnceForStarred).arg(lastContinuation));
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&c=%2&s=%3")
|
||||
.arg(limitAtOnce).arg(lastContinuation).arg(st));
|
||||
QNetworkRequest request(url);
|
||||
|
||||
// Authorization header
|
||||
request.setRawHeader("Authorization",QString("GoogleLogin auth=%1").arg(s->getCookie()).toLatin1());
|
||||
|
||||
currentReply = nam.get(request);
|
||||
|
|
@ -386,6 +362,114 @@ void OldReaderFetcher::fetchStarredStream()
|
|||
connect(currentReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
void OldReaderFetcher::fetchLikedStream()
|
||||
{
|
||||
data.clear();
|
||||
|
||||
Settings *s = Settings::instance();
|
||||
|
||||
if (currentReply != NULL) {
|
||||
currentReply->disconnect();
|
||||
currentReply->deleteLater();
|
||||
currentReply = NULL;
|
||||
}
|
||||
|
||||
QUrl url;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
QString st(QUrl::toPercentEncoding("user/-/state/com.google/liked"));
|
||||
#else
|
||||
QString st = "user/-/state/com.google/liked";
|
||||
#endif
|
||||
if (lastContinuation == "")
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&s=%2")
|
||||
.arg(limitAtOnce).arg(st));
|
||||
else
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&c=%2&s=%3")
|
||||
.arg(limitAtOnce).arg(lastContinuation).arg(st));
|
||||
QNetworkRequest request(url);
|
||||
|
||||
request.setRawHeader("Authorization",QString("GoogleLogin auth=%1").arg(s->getCookie()).toLatin1());
|
||||
|
||||
currentReply = nam.get(request);
|
||||
|
||||
connect(currentReply, SIGNAL(finished()), this, SLOT(finishedLikedStream()));
|
||||
connect(currentReply, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
||||
connect(currentReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
void OldReaderFetcher::fetchBroadcastStream()
|
||||
{
|
||||
data.clear();
|
||||
|
||||
Settings *s = Settings::instance();
|
||||
|
||||
if (currentReply != NULL) {
|
||||
currentReply->disconnect();
|
||||
currentReply->deleteLater();
|
||||
currentReply = NULL;
|
||||
}
|
||||
|
||||
QUrl url;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
QString st(QUrl::toPercentEncoding("user/-/state/com.google/broadcast"));
|
||||
#else
|
||||
QString st = "user/-/state/com.google/broadcast";
|
||||
#endif
|
||||
if (lastContinuation == "")
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&s=%2")
|
||||
.arg(limitAtOnce).arg(st));
|
||||
else
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&c=%2&s=%3")
|
||||
.arg(limitAtOnce).arg(lastContinuation).arg(st));
|
||||
QNetworkRequest request(url);
|
||||
|
||||
request.setRawHeader("Authorization",QString("GoogleLogin auth=%1").arg(s->getCookie()).toLatin1());
|
||||
|
||||
currentReply = nam.get(request);
|
||||
|
||||
connect(currentReply, SIGNAL(finished()), this, SLOT(finishedBroadcastStream()));
|
||||
connect(currentReply, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
||||
connect(currentReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
void OldReaderFetcher::fetchUnreadStream()
|
||||
{
|
||||
data.clear();
|
||||
|
||||
Settings *s = Settings::instance();
|
||||
|
||||
if (currentReply != NULL) {
|
||||
currentReply->disconnect();
|
||||
currentReply->deleteLater();
|
||||
currentReply = NULL;
|
||||
}
|
||||
|
||||
QUrl url;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
QString st1(QUrl::toPercentEncoding("user/-/state/com.google/reading-list"));
|
||||
QString st2(QUrl::toPercentEncoding("user/-/state/com.google/read"));
|
||||
#else
|
||||
QString st1 = "user/-/state/com.google/reading-list";
|
||||
QString st2 = "user/-/state/com.google/read";
|
||||
#endif
|
||||
if (lastContinuation == "")
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&s=%2&xt=%3")
|
||||
.arg(limitAtOnce).arg(st1, st2));
|
||||
else
|
||||
url.setUrl(QString("https://theoldreader.com/reader/api/0/stream/contents?output=json&n=%1&c=%2&s=%3&xt=%4")
|
||||
.arg(limitAtOnce)
|
||||
.arg(lastContinuation).arg(st1, st2));
|
||||
QNetworkRequest request(url);
|
||||
|
||||
request.setRawHeader("Authorization",QString("GoogleLogin auth=%1").arg(s->getCookie()).toLatin1());
|
||||
|
||||
currentReply = nam.get(request);
|
||||
|
||||
connect(currentReply, SIGNAL(finished()), this, SLOT(finishedUnreadStream()));
|
||||
connect(currentReply, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
||||
connect(currentReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedSignInOnlyCheck()
|
||||
{
|
||||
//qDebug() << data;
|
||||
|
|
@ -557,77 +641,19 @@ void OldReaderFetcher::finishedFeeds()
|
|||
|
||||
void OldReaderFetcher::finishedFeeds2()
|
||||
{
|
||||
// Proggres initiating, one step is one day
|
||||
Settings *s = Settings::instance();
|
||||
|
||||
// Proggres initiating
|
||||
proggressTotal = feedUpdateList.count() + 2;
|
||||
proggressTotal = s->getRetentionDays() > 0 ? log(s->getRetentionDays()) + 4 : 5;
|
||||
proggress = 1;
|
||||
lastDate = 0;
|
||||
emit progress(proggress, proggressTotal);
|
||||
|
||||
if (busyType == Fetcher::Updating) {
|
||||
prepareFeedLists();
|
||||
removeDeletedFeeds();
|
||||
//qDebug() << "New feeds:" << feedList.count() << "Feeds to update:" << feedUpdateList.count();
|
||||
fetchStreamUpdate();
|
||||
return;
|
||||
}
|
||||
/*if (busyType == Fetcher::Updating)
|
||||
removeDeletedFeeds();*/
|
||||
|
||||
if (busyType == Fetcher::Initiating) {
|
||||
s->db->cleanEntries();
|
||||
//feedUpdateList.clear();
|
||||
//qDebug() << "New feeds:" << feedUpdateList.count();
|
||||
s->db->updateEntriesFlag(1); // Marking as old
|
||||
|
||||
if (feedUpdateList.isEmpty()) {
|
||||
qWarning() << "No Feeds to download!";
|
||||
|
||||
// Proggres initiating
|
||||
proggressTotal = 2;
|
||||
proggress = 1;
|
||||
emit progress(proggress, proggressTotal);
|
||||
|
||||
fetchStarredStream();
|
||||
} else {
|
||||
fetchStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedStreamUpdate()
|
||||
{
|
||||
//qDebug() << data;
|
||||
if (currentReply->error()) {
|
||||
emit error(500);
|
||||
setBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
startJob(StoreStreamUpdate);
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedStreamUpdate2()
|
||||
{
|
||||
if (lastContinuation == "" ||
|
||||
continuationCount > continuationLimitForUpdate) {
|
||||
|
||||
++proggress;
|
||||
emit progress(proggress, proggressTotal);
|
||||
|
||||
lastContinuation = "";
|
||||
continuationCount = 0;
|
||||
|
||||
feedUpdateList.removeFirst();
|
||||
if (feedUpdateList.isEmpty()) {
|
||||
//qDebug() << "Streams update done. Starting New Streams download.";
|
||||
if (feedList.isEmpty()) {
|
||||
fetchStarredStream();
|
||||
} else {
|
||||
fetchStream();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fetchStreamUpdate();
|
||||
fetchStream();
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedStream()
|
||||
|
|
@ -644,32 +670,24 @@ void OldReaderFetcher::finishedStream()
|
|||
|
||||
void OldReaderFetcher::finishedStream2()
|
||||
{
|
||||
Settings *s = Settings::instance();
|
||||
if (s->getRetentionDays() > 0) {
|
||||
if (lastDate > s->getRetentionDays())
|
||||
lastDate = s->getRetentionDays();
|
||||
emit progress(proggress + log(lastDate), proggressTotal);
|
||||
}
|
||||
|
||||
if (lastContinuation == "" ||
|
||||
continuationCount > continuationLimit) {
|
||||
|
||||
++proggress;
|
||||
emit progress(proggress, proggressTotal);
|
||||
proggress += s->getRetentionDays() > 0 ? log(lastDate) : 1;
|
||||
|
||||
lastContinuation = "";
|
||||
continuationCount = 0;
|
||||
lastDate = 0;
|
||||
|
||||
if (busyType == Fetcher::Initiating) {
|
||||
feedUpdateList.removeFirst();
|
||||
if (feedUpdateList.isEmpty()) {
|
||||
//qDebug() << "New Streams download done.";
|
||||
fetchStarredStream();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (busyType == Fetcher::Updating) {
|
||||
feedList.removeFirst();
|
||||
if (feedList.isEmpty()) {
|
||||
//qDebug() << "New Streams download done.";
|
||||
fetchStarredStream();
|
||||
return;
|
||||
}
|
||||
}
|
||||
fetchStarredStream();
|
||||
return;
|
||||
}
|
||||
|
||||
fetchStream();
|
||||
|
|
@ -690,26 +708,108 @@ void OldReaderFetcher::finishedStarredStream()
|
|||
void OldReaderFetcher::finishedStarredStream2()
|
||||
{
|
||||
if (lastContinuation == "" ||
|
||||
continuationCount > continuationLimitForStarred) {
|
||||
continuationCount > continuationLimit) {
|
||||
|
||||
++proggress;
|
||||
emit progress(proggress, proggressTotal);
|
||||
|
||||
//taskEnd();
|
||||
startJob(MarkSlow);
|
||||
fetchLikedStream();
|
||||
return;
|
||||
}
|
||||
|
||||
fetchStarredStream();
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedLikedStream()
|
||||
{
|
||||
//qDebug() << data;
|
||||
if (currentReply->error()) {
|
||||
emit error(500);
|
||||
setBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
startJob(StoreLikedStream);
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedLikedStream2()
|
||||
{
|
||||
if (lastContinuation == "" ||
|
||||
continuationCount > continuationLimit) {
|
||||
|
||||
++proggress;
|
||||
emit progress(proggress, proggressTotal);
|
||||
|
||||
fetchBroadcastStream();
|
||||
return;
|
||||
}
|
||||
|
||||
fetchLikedStream();
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedBroadcastStream()
|
||||
{
|
||||
//qDebug() << data;
|
||||
if (currentReply->error()) {
|
||||
emit error(500);
|
||||
setBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
startJob(StoreBroadcastStream);
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedBroadcastStream2()
|
||||
{
|
||||
if (lastContinuation == "" ||
|
||||
continuationCount > continuationLimit) {
|
||||
|
||||
++proggress;
|
||||
emit progress(proggress, proggressTotal);
|
||||
|
||||
startJob(MarkSlow);
|
||||
return;
|
||||
}
|
||||
|
||||
fetchBroadcastStream();
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedUnreadStream()
|
||||
{
|
||||
//qDebug() << data;
|
||||
if (currentReply->error()) {
|
||||
emit error(500);
|
||||
setBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
startJob(StoreUnreadStream);
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedUnreadStream2()
|
||||
{
|
||||
if (lastContinuation == "" ||
|
||||
continuationCount > continuationLimit) {
|
||||
taskEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
fetchUnreadStream();
|
||||
}
|
||||
|
||||
void OldReaderFetcher::finishedSetAction()
|
||||
{
|
||||
//qDebug() << data;
|
||||
if (currentReply != NULL && currentReply->error()) {
|
||||
emit error(500);
|
||||
setBusy(false);
|
||||
return;
|
||||
int code = currentReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if (code == 404) {
|
||||
// Probably item already deleted -> skiping
|
||||
qWarning() << "Action request returns 404!";
|
||||
} else {
|
||||
emit error(500);
|
||||
setBusy(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Settings *s = Settings::instance();
|
||||
|
|
@ -719,7 +819,6 @@ void OldReaderFetcher::finishedSetAction()
|
|||
s->db->removeActionsById(action.id1);
|
||||
|
||||
if (actionsList.isEmpty()) {
|
||||
//qDebug() << "All action uploaded.";
|
||||
s->db->cleanDashboards();
|
||||
startFetching();
|
||||
return;
|
||||
|
|
@ -730,6 +829,10 @@ void OldReaderFetcher::finishedSetAction()
|
|||
|
||||
void OldReaderFetcher::finishedMarkSlow()
|
||||
{
|
||||
// Deleting old entries
|
||||
Settings *s = Settings::instance();
|
||||
s->db->removeEntriesByFlag(1);
|
||||
|
||||
taskEnd();
|
||||
return;
|
||||
}
|
||||
|
|
@ -760,10 +863,11 @@ void OldReaderFetcher::startFetching()
|
|||
s->db->cleanTabs();
|
||||
if(busyType == Fetcher::Initiating) {
|
||||
s->db->cleanCache();
|
||||
s->db->cleanEntries();
|
||||
}
|
||||
if (busyType == Fetcher::Updating) {
|
||||
s->db->updateEntriesFreshFlag(0); // Set current entries as not fresh
|
||||
storedFeedList = s->db->readStreamModuleTabList();
|
||||
//storedFeedList = s->db->readStreamModuleTabList();
|
||||
}
|
||||
s->db->cleanStreams();
|
||||
s->db->cleanModules();
|
||||
|
|
@ -822,15 +926,21 @@ void OldReaderFetcher::startJob(Job job)
|
|||
case StoreFeeds:
|
||||
connect(this, SIGNAL(finished()), this, SLOT(finishedFeeds2()));
|
||||
break;
|
||||
case StoreStreamUpdate:
|
||||
connect(this, SIGNAL(finished()), this, SLOT(finishedStreamUpdate2()));
|
||||
break;
|
||||
case StoreStream:
|
||||
connect(this, SIGNAL(finished()), this, SLOT(finishedStream2()));
|
||||
break;
|
||||
case StoreUnreadStream:
|
||||
connect(this, SIGNAL(finished()), this, SLOT(finishedUnreadStream2()));
|
||||
break;
|
||||
case StoreStarredStream:
|
||||
connect(this, SIGNAL(finished()), this, SLOT(finishedStarredStream2()));
|
||||
break;
|
||||
case StoreLikedStream:
|
||||
connect(this, SIGNAL(finished()), this, SLOT(finishedLikedStream2()));
|
||||
break;
|
||||
case StoreBroadcastStream:
|
||||
connect(this, SIGNAL(finished()), this, SLOT(finishedBroadcastStream2()));
|
||||
break;
|
||||
case MarkSlow:
|
||||
connect(this, SIGNAL(finished()), this, SLOT(finishedMarkSlow()));
|
||||
break;
|
||||
|
|
@ -856,11 +966,11 @@ void OldReaderFetcher::run()
|
|||
case StoreFeeds:
|
||||
storeFeeds();
|
||||
break;
|
||||
case StoreStreamUpdate:
|
||||
storeStream();
|
||||
break;
|
||||
case StoreStream:
|
||||
case StoreUnreadStream:
|
||||
case StoreStarredStream:
|
||||
case StoreLikedStream:
|
||||
case StoreBroadcastStream:
|
||||
storeStream();
|
||||
break;
|
||||
case MarkSlow:
|
||||
|
|
@ -961,7 +1071,7 @@ void OldReaderFetcher::getFromCategories(const QJsonArray &categories, QVariantM
|
|||
QJsonArray::const_iterator i = categories.constBegin();
|
||||
QJsonArray::const_iterator end = categories.constEnd();
|
||||
#else
|
||||
void OldReaderFetcher::getFolderFromCategories(const QVariantList &categories, QVariantMap &result)
|
||||
void OldReaderFetcher::getFromCategories(const QVariantList &categories, QVariantMap &result)
|
||||
{
|
||||
QVariantList::const_iterator i = categories.constBegin();
|
||||
QVariantList::const_iterator end = categories.constEnd();
|
||||
|
|
@ -1017,7 +1127,6 @@ void OldReaderFetcher::getFolderFromCategories(const QVariantList &categories, Q
|
|||
void OldReaderFetcher::storeFriends()
|
||||
{
|
||||
tabList.clear();
|
||||
feedUpdateList.clear();
|
||||
|
||||
Settings *s = Settings::instance();
|
||||
|
||||
|
|
@ -1069,12 +1178,11 @@ void OldReaderFetcher::storeFriends()
|
|||
m.streamList.append(st.id);
|
||||
s->db->writeModule(m);
|
||||
|
||||
DatabaseManager::StreamModuleTab smt;
|
||||
/*DatabaseManager::StreamModuleTab smt;
|
||||
smt.streamId = st.id;
|
||||
smt.moduleId = st.id;
|
||||
smt.tabId = m.tabId;
|
||||
feedList.append(smt);
|
||||
feedUpdateList.append(smt);
|
||||
feedList.append(smt);*/
|
||||
|
||||
++i;
|
||||
}
|
||||
|
|
@ -1096,8 +1204,6 @@ void OldReaderFetcher::storeFriends()
|
|||
|
||||
void OldReaderFetcher::storeFeeds()
|
||||
{
|
||||
//feedList.clear();
|
||||
//feedUpdateList.clear();
|
||||
Settings *s = Settings::instance();
|
||||
|
||||
bool subscriptionsFolderFeed = false;
|
||||
|
|
@ -1172,13 +1278,11 @@ void OldReaderFetcher::storeFeeds()
|
|||
m.streamList.append(st.id);
|
||||
s->db->writeModule(m);
|
||||
|
||||
DatabaseManager::StreamModuleTab smt;
|
||||
/*DatabaseManager::StreamModuleTab smt;
|
||||
smt.streamId = st.id;
|
||||
smt.moduleId = st.id;
|
||||
smt.tabId = tabId;
|
||||
|
||||
//feedList.append(smt);
|
||||
feedUpdateList.append(smt);
|
||||
feedList.append(smt);*/
|
||||
}
|
||||
|
||||
++i;
|
||||
|
|
@ -1198,9 +1302,13 @@ void OldReaderFetcher::storeStream()
|
|||
{
|
||||
Settings *s = Settings::instance();
|
||||
|
||||
//qDebug() << jsonObj;
|
||||
|
||||
double updated = 0;
|
||||
int retentionDays = s->getRetentionDays();
|
||||
|
||||
//qDebug() << "getRetentionDays" << retentionDays;
|
||||
//qint64 date1 = QDateTime::currentMSecsSinceEpoch();
|
||||
//int items = 0;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
if (jsonObj["updated"].isDouble()) {
|
||||
updated = jsonObj["updated"].toDouble();
|
||||
|
|
@ -1211,7 +1319,8 @@ void OldReaderFetcher::storeStream()
|
|||
QJsonArray::const_iterator i = jsonObj["items"].toArray().constBegin();
|
||||
QJsonArray::const_iterator end = jsonObj["items"].toArray().constEnd();
|
||||
#else
|
||||
if (jsonObj["updated"].type()==QVariant::Double) {
|
||||
//qDebug() << jsonObj["updated"].type();
|
||||
if (jsonObj["updated"].type()==QVariant::ULongLong) {
|
||||
updated = jsonObj["updated"].toDouble();
|
||||
} else {
|
||||
qWarning() << "No updated param in stream!";
|
||||
|
|
@ -1233,9 +1342,8 @@ void OldReaderFetcher::storeStream()
|
|||
if (obj["origin"].type() == QVariant::Map) {
|
||||
feedId = obj["origin"].toMap()["streamId"].toString();
|
||||
}
|
||||
//qDebug() << obj;
|
||||
#endif
|
||||
//qDebug() << feedId;
|
||||
|
||||
DatabaseManager::Entry e;
|
||||
e.id = obj["id"].toString();
|
||||
e.streamId = feedId;
|
||||
|
|
@ -1243,6 +1351,8 @@ void OldReaderFetcher::storeStream()
|
|||
e.author = obj["author"].toString();
|
||||
QVariantMap categories;
|
||||
|
||||
//qDebug() << e.id << e.title;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
if (obj["summary"].isObject())
|
||||
e.content = obj["summary"].toObject()["content"].toString();
|
||||
|
|
@ -1250,13 +1360,19 @@ void OldReaderFetcher::storeStream()
|
|||
e.link = obj["canonical"].toArray()[0].toObject()["href"].toString();
|
||||
if (obj["categories"].isArray())
|
||||
getFromCategories(obj["categories"].toArray(), categories);
|
||||
if (obj["annotations"].isArray() && !obj["annotations"].toArray().isEmpty())
|
||||
e.annotations = obj["annotations"].toArray()[0].toString();
|
||||
#else
|
||||
if (obj["summary"].type() == QVariant::Map)
|
||||
e.content = obj["summary"].toMap()["content"].toString();
|
||||
if (obj["canonical"].type() == QVariant::List && obj["canonical"].toList().isEmpty() && obj["canonical"].toList()[0].type() == QVariant::Map)
|
||||
if (obj["canonical"].type() == QVariant::List && !obj["canonical"].toList().isEmpty() && obj["canonical"].toList()[0].type() == QVariant::Map)
|
||||
e.link = obj["canonical"].toList()[0].toMap()["href"].toString();
|
||||
if (obj["categories"].type() == QVariant::List)
|
||||
getFromCategories(obj["categories"].toList(), categories);
|
||||
if (obj["annotations"].type() == QVariant::List && !obj["annotations"].toList().isEmpty()) {
|
||||
//qDebug() << e.id << e.title << obj["annotations"];
|
||||
e.annotations = obj["annotations"].toList()[0].toString();
|
||||
}
|
||||
#endif
|
||||
e.read = categories.value("read").toInt();
|
||||
e.saved = categories.value("starred").toInt();
|
||||
|
|
@ -1271,11 +1387,9 @@ void OldReaderFetcher::storeStream()
|
|||
QString crawlTime = obj["crawlTimeMsec"].toString();
|
||||
crawlTime.chop(3); // converting Msec to sec
|
||||
e.crawlTime = crawlTime.toDouble();
|
||||
e.crawlTime = updated;
|
||||
QString timestamp = obj["timestampUsec"].toString();
|
||||
timestamp.chop(6); // converting Usec to sec
|
||||
|
||||
//e.timestamp = timestamp.toDouble();
|
||||
e.timestamp = timestamp.toDouble();
|
||||
|
||||
/*qDebug() << ">>>>>>>>>>>>>>>";
|
||||
qDebug() << e.title << e.streamId;
|
||||
|
|
@ -1306,54 +1420,45 @@ void OldReaderFetcher::storeStream()
|
|||
|
||||
s->db->writeEntry(e);
|
||||
|
||||
// Progress, only for StoreStream
|
||||
//++items;
|
||||
if (currentJob == StoreStream && retentionDays > 0) {
|
||||
int newLastDate = QDateTime::fromTime_t(e.crawlTime).daysTo(QDateTime::currentDateTimeUtc());
|
||||
//qDebug() << "newLastDate" << newLastDate;
|
||||
if (newLastDate > retentionDays) {
|
||||
//qDebug() << "newLastDate > retentionDays";
|
||||
lastDate = retentionDays;
|
||||
lastContinuation = "";
|
||||
++continuationCount;
|
||||
|
||||
//qDebug() << "db write time:" << (QDateTime::currentMSecsSinceEpoch() - date1) << "items:" << items;
|
||||
return;
|
||||
} else {
|
||||
lastDate = newLastDate;
|
||||
}
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
//qDebug() << "db write time:" << (QDateTime::currentMSecsSinceEpoch() - date1) << "items:" << items;
|
||||
|
||||
QString continuation = jsonObj["continuation"].toString();
|
||||
lastContinuation = continuation;
|
||||
++continuationCount;
|
||||
}
|
||||
|
||||
void OldReaderFetcher::prepareFeedLists()
|
||||
{
|
||||
// Removing all new feeds form feedUpdateList
|
||||
QList<DatabaseManager::StreamModuleTab>::iterator ui = feedUpdateList.begin();
|
||||
|
||||
while (ui != feedUpdateList.end()) {
|
||||
bool newFeed = true;
|
||||
QList<DatabaseManager::StreamModuleTab>::iterator si = storedFeedList.begin();
|
||||
while (si != storedFeedList.end()) {
|
||||
if ((*si).streamId == (*ui).streamId) {
|
||||
newFeed = false;
|
||||
break;
|
||||
}
|
||||
++si;
|
||||
}
|
||||
|
||||
if (newFeed) {
|
||||
feedList.append((*ui)); // adding as new Feed
|
||||
ui = feedUpdateList.erase(ui);
|
||||
} else {
|
||||
++ui;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void OldReaderFetcher::removeDeletedFeeds()
|
||||
/*void OldReaderFetcher::removeDeletedFeeds()
|
||||
{
|
||||
// Removing all existing feeds form feedList
|
||||
QList<DatabaseManager::StreamModuleTab>::iterator si = storedFeedList.begin();
|
||||
|
||||
while (si != storedFeedList.end()) {
|
||||
bool newFeed = true;
|
||||
//qDebug() << ">>>>>>>> si:" << (*si).streamId;
|
||||
QList<DatabaseManager::StreamModuleTab>::iterator ui = feedUpdateList.begin();
|
||||
while (ui != feedUpdateList.end()) {
|
||||
//qDebug() << "ui:" << (*ui).streamId;
|
||||
QList<DatabaseManager::StreamModuleTab>::iterator ui = feedList.begin();
|
||||
while (ui != feedList.end()) {
|
||||
if ((*ui).streamId == (*si).streamId) {
|
||||
//qDebug() << " matched!";
|
||||
newFeed = false;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1368,7 +1473,7 @@ void OldReaderFetcher::removeDeletedFeeds()
|
|||
|
||||
++si;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
void OldReaderFetcher::uploadActions()
|
||||
{
|
||||
|
|
@ -1389,11 +1494,6 @@ void OldReaderFetcher::markSlowFeeds()
|
|||
QStringList::iterator it = list.begin();
|
||||
while (it != list.end()) {
|
||||
int n = s->db->countEntriesNewerThanByStream(*it, QDateTime::currentDateTime().addDays(-30));
|
||||
/*if (busyType == Fetcher::Updating)
|
||||
n = s->db->countEntriesNewerThanByStream(*it, QDateTime::fromTime_t(s->getLastUpdateDate()).addDays(-30));
|
||||
else
|
||||
n = s->db->countEntriesNewerThanByStream(*it, QDateTime::currentDateTime().addDays(-30));*/
|
||||
//qDebug() << "n:" << *it << n;
|
||||
if (n<5) {
|
||||
// Slow detected
|
||||
s->db->updateStreamSlowFlagById(*it, 1);
|
||||
|
|
|
|||
|
|
@ -52,47 +52,51 @@ private Q_SLOTS:
|
|||
void finishedFriends2();
|
||||
void finishedFeeds();
|
||||
void finishedFeeds2();
|
||||
void finishedStreamUpdate();
|
||||
void finishedStreamUpdate2();
|
||||
void finishedStream();
|
||||
void finishedStream2();
|
||||
void finishedStarredStream();
|
||||
void finishedStarredStream2();
|
||||
void finishedLikedStream();
|
||||
void finishedLikedStream2();
|
||||
void finishedBroadcastStream();
|
||||
void finishedBroadcastStream2();
|
||||
void finishedUnreadStream();
|
||||
void finishedUnreadStream2();
|
||||
void finishedSetAction();
|
||||
void finishedMarkSlow();
|
||||
|
||||
private:
|
||||
enum Job { Idle, StoreTabs, StoreFriends, StoreFeeds, StoreStreamUpdate, StoreStream, StoreStarredStream, MarkSlow };
|
||||
enum Job { Idle, StoreTabs, StoreFriends, StoreFeeds, StoreStream,
|
||||
StoreUnreadStream, StoreStarredStream, StoreLikedStream,
|
||||
StoreBroadcastStream, MarkSlow };
|
||||
|
||||
static const int limitAtOnce = 100;
|
||||
static const int limitAtOnceForUpdate = 100;
|
||||
static const int limitAtOnceForStarred = 100;
|
||||
static const int continuationLimit = 0;
|
||||
static const int continuationLimitForUpdate = 0;
|
||||
static const int continuationLimitForStarred = 5;
|
||||
static const int limitAtOnce = 400;
|
||||
static const int continuationLimit = 100;
|
||||
|
||||
Job currentJob;
|
||||
QStringList tabList;
|
||||
QList<DatabaseManager::StreamModuleTab> feedUpdateList;
|
||||
QList<DatabaseManager::StreamModuleTab> feedList;
|
||||
QList<DatabaseManager::StreamModuleTab> storedFeedList;
|
||||
//QList<DatabaseManager::StreamModuleTab> feedList;
|
||||
//QList<DatabaseManager::StreamModuleTab> storedFeedList;
|
||||
|
||||
QString lastContinuation;
|
||||
int continuationCount;
|
||||
int lastDate;
|
||||
|
||||
void signIn();
|
||||
void startFetching();
|
||||
|
||||
void uploadActions();
|
||||
|
||||
void prepareFeedLists();
|
||||
void removeDeletedFeeds();
|
||||
//void removeDeletedFeeds();
|
||||
|
||||
void fetchTabs();
|
||||
void fetchFriends();
|
||||
void fetchFeeds();
|
||||
void fetchStreamUpdate();
|
||||
void fetchStream();
|
||||
void fetchUnreadStream();
|
||||
void fetchStarredStream();
|
||||
void fetchLikedStream();
|
||||
void fetchBroadcastStream();
|
||||
void setAction();
|
||||
|
||||
void startJob(Job job);
|
||||
|
|
@ -101,7 +105,6 @@ private:
|
|||
void storeFriends();
|
||||
void storeFeeds();
|
||||
void storeStream();
|
||||
void storeStarredStream();
|
||||
void markSlowFeeds();
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
#include "downloadmanager.h"
|
||||
#include "databasemanager.h"
|
||||
#include "cacheserver.h"
|
||||
#include "netvibesfetcher.h"
|
||||
#include "simplecrypt.h"
|
||||
#include "../key.h"
|
||||
|
||||
|
|
@ -107,6 +106,19 @@ bool Settings::getShowOnlyUnread()
|
|||
return settings.value("showonlyunread", true).toBool();
|
||||
}
|
||||
|
||||
void Settings::setShowBroadcast(bool value)
|
||||
{
|
||||
if (getShowBroadcast() != value) {
|
||||
settings.setValue("showbroadcast", value);
|
||||
emit showBroadcastChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool Settings::getShowBroadcast()
|
||||
{
|
||||
return settings.value("showbroadcast", false).toBool();
|
||||
}
|
||||
|
||||
void Settings::setOfflineMode(bool value)
|
||||
{
|
||||
#ifdef KAKTUS_LIGHT
|
||||
|
|
@ -423,9 +435,8 @@ void Settings::setDmConnections(int value)
|
|||
|
||||
int Settings::getDmConnections()
|
||||
{
|
||||
//#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
|
||||
#if defined(Q_OS_SYMBIAN)
|
||||
return settings.value("connections", 1).toInt();
|
||||
#ifdef BB10
|
||||
return settings.value("connections", 10).toInt();
|
||||
#else
|
||||
return settings.value("connections", 10).toInt();
|
||||
#endif
|
||||
|
|
@ -516,6 +527,21 @@ void Settings::setFontSize(int value)
|
|||
}
|
||||
}
|
||||
|
||||
int Settings::getRetentionDays()
|
||||
{
|
||||
// Default is 14 days
|
||||
return settings.value("retentiondays", 14).toInt();
|
||||
}
|
||||
|
||||
void Settings::setRetentionDays(int value)
|
||||
{
|
||||
#ifdef KAKTUS_LIGHT
|
||||
if (value < 1 || value >= 30 )
|
||||
return;
|
||||
#endif
|
||||
settings.setValue("retentiondays", value);
|
||||
}
|
||||
|
||||
int Settings::getTheme()
|
||||
{
|
||||
// Default is Dark theme
|
||||
|
|
@ -607,5 +633,6 @@ void Settings::reset()
|
|||
setAuthUrl("");
|
||||
setHint1Done(false);
|
||||
setCachingMode(0);
|
||||
setRetentionDays(30);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ class Settings: public QObject
|
|||
Q_PROPERTY (int cachingMode READ getCachingMode WRITE setCachingMode NOTIFY cachingModeChanged)
|
||||
Q_PROPERTY (int theme READ getTheme WRITE setTheme NOTIFY themeChanged)
|
||||
Q_PROPERTY (int signinType READ getSigninType WRITE setSigninType NOTIFY signinTypeChanged)
|
||||
Q_PROPERTY (bool showBroadcast READ getShowBroadcast WRITE setShowBroadcast NOTIFY showBroadcastChanged)
|
||||
|
||||
public:
|
||||
static Settings* instance();
|
||||
|
|
@ -108,6 +109,9 @@ public:
|
|||
bool getShowStarredTab();
|
||||
void setShowStarredTab(bool value);
|
||||
|
||||
bool getShowBroadcast();
|
||||
void setShowBroadcast(bool value);
|
||||
|
||||
void setDashboardInUse(const QString &value);
|
||||
QString getDashboardInUse();
|
||||
|
||||
|
|
@ -154,9 +158,6 @@ public:
|
|||
|
||||
// ---
|
||||
|
||||
bool getShowOnlyUnread();
|
||||
void setShowOnlyUnread(bool value);
|
||||
|
||||
Q_INVOKABLE QString getSettingsDir();
|
||||
|
||||
QString getDmCacheDir();
|
||||
|
|
@ -176,11 +177,15 @@ public:
|
|||
Q_INVOKABLE void setAuthUrl(const QString &value);
|
||||
Q_INVOKABLE QString getAuthUrl();
|
||||
|
||||
// --------
|
||||
|
||||
Q_INVOKABLE void setDmUserAgent(const QString &value);
|
||||
Q_INVOKABLE QString getDmUserAgent();
|
||||
|
||||
Q_INVOKABLE void setRetentionDays(int value);
|
||||
Q_INVOKABLE int getRetentionDays();
|
||||
|
||||
bool getShowOnlyUnread();
|
||||
void setShowOnlyUnread(bool value);
|
||||
|
||||
void setDmConnections(int value);
|
||||
int getDmConnections();
|
||||
|
||||
|
|
@ -222,6 +227,7 @@ signals:
|
|||
void themeChanged();
|
||||
void cachingModeChanged();
|
||||
void signinTypeChanged();
|
||||
void showBroadcastChanged();
|
||||
|
||||
/*
|
||||
501 - Unable create settings dir
|
||||
|
|
|
|||
|
|
@ -563,6 +563,10 @@ QString Utils::getHumanFriendlyTimeString(int date)
|
|||
QDateTime qdate = QDateTime::fromTime_t(date);
|
||||
int secs = qdate.secsTo(QDateTime::currentDateTimeUtc());
|
||||
|
||||
//qDebug() << ">>>>>>>>date" << date << "QDateTime::fromTime_t(date)" << qdate;
|
||||
//qDebug() << "QDateTime::currentDateTimeUtc()" << QDateTime::currentDateTimeUtc();
|
||||
//qDebug() << "qdate.secsTo(QDateTime::currentDateTimeUtc())" << secs;
|
||||
|
||||
if (secs<=0) {
|
||||
return tr("just now");
|
||||
}
|
||||
|
|
@ -679,5 +683,10 @@ void Utils::resetFetcher(int type)
|
|||
}
|
||||
|
||||
if (s->fetcher != NULL)
|
||||
#ifdef BB10
|
||||
s->qml->setContextProperty("fetcher", s->fetcher);
|
||||
#else
|
||||
s->view->rootContext()->setContextProperty("fetcher", s->fetcher);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ QNetworkAccessManager * WebImageView::mNetManager = new QNetworkAccessManager();
|
|||
QNetworkDiskCache * WebImageView::mNetworkDiskCache = new QNetworkDiskCache();
|
||||
|
||||
const QString WebImageView::availableColors[5] = {"green", "blue", "orange", "pink", "grey"};
|
||||
const QString WebImageView::spriteMap[5][8] = {
|
||||
{"plus", "home", "label-2", "star", "label", "pin", "sheet", "power"},
|
||||
{"enveloppe", "happy-face", "rss", "calc", "clock", "pen", "bug"},
|
||||
{"cloud", "cog", "vbar", "pie", "table", "line", "magnifier"},
|
||||
{"lightbulb", "movie", "note", "camera", "mobile", "computer", "heart"},
|
||||
{"alert", "bill", "funnel", "eye", "bubble", "calendar", "check"}
|
||||
};
|
||||
const QString WebImageView::spriteMap[5][10] = {
|
||||
{"plus","home","label-2","star","label","pin","sheet","power","diamond","folder"},
|
||||
{"enveloppe","happy-face","rss","calc","clock","pen","bug","label-box","yen","snail"},
|
||||
{"cloud","cog","vbar","pie","table","line","magnifier","potion","pound","euro"},
|
||||
{"lightbulb","movie","note","camera","mobile","computer","heart","bubbles","dollars"},
|
||||
{"alert","bill","funnel","eye","bubble","calendar","check","crown","plane"}
|
||||
};
|
||||
|
||||
WebImageView::WebImageView() {
|
||||
// Initialize network cache
|
||||
|
|
@ -86,15 +86,33 @@ void WebImageView::setDoSizeCheck(bool value)
|
|||
}
|
||||
}
|
||||
|
||||
void WebImageView::setUrl(const QUrl& url) {
|
||||
// Variables
|
||||
void WebImageView::setUrl(const QUrl& url)
|
||||
{
|
||||
//qDebug() << "url" << url << "mUrl" << mUrl << (url==mUrl);
|
||||
if (url == mUrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
mUrl = url;
|
||||
mLoading = 0;
|
||||
mIsLoaded = false;
|
||||
|
||||
// Reset the image
|
||||
emit isLoadedChanged();
|
||||
resetImage();
|
||||
|
||||
if (url.isEmpty()) {
|
||||
emit urlChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
// Detecting if url is "asset:///"
|
||||
if (url.toString().startsWith("asset:///")) {
|
||||
this->setImageSource(url);
|
||||
mIsLoaded = true;
|
||||
emit isLoadedChanged();
|
||||
emit urlChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
// Detecting if url is "image://nvicons/"
|
||||
if (url.toString().startsWith("image://nvicons/")) {
|
||||
QStringList parts = url.toString().split('?');
|
||||
|
|
@ -105,6 +123,7 @@ void WebImageView::setUrl(const QUrl& url) {
|
|||
setImage(Image(fromQImage(QImage("app/native/assets/sprite-icons.png").copy(getPosition(icon, color)))));
|
||||
mIsLoaded = true;
|
||||
emit isLoadedChanged();
|
||||
emit urlChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -181,8 +200,13 @@ void WebImageView::imageLoaded() {
|
|||
sourceSize = size;
|
||||
emit sizeChanged();
|
||||
}*/
|
||||
if (reply->header(QNetworkRequest::ContentTypeHeader).toString() == "image/x-icon") {
|
||||
// BB does not support ICO image format -> must convert
|
||||
setImage(Image(fromQImage(QImage::fromData(imageData))));
|
||||
} else {
|
||||
setImage(Image(imageData));
|
||||
}
|
||||
|
||||
setImage(Image(imageData));
|
||||
mIsLoaded = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -227,7 +251,7 @@ QRect WebImageView::getPosition(const QString &icon, const QString &color)
|
|||
{
|
||||
int n = 16, s = 20, a = 16;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
for (int j = 0; j < 10; ++j) {
|
||||
if (spriteMap[i][j] == icon) {
|
||||
n += 100 * i;
|
||||
a += j * s;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ private:
|
|||
void setURLToRedirectedUrl(QNetworkReply *reply);
|
||||
|
||||
const static QString availableColors[5];
|
||||
const static QString spriteMap[5][8];
|
||||
const static QString spriteMap[5][10];
|
||||
|
||||
bb::ImageData fromQImage(const QImage &qImage);
|
||||
int getOffsetByColor(const QString &color);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue