//-- Now figure out the count for tiles unique to this set
quint32ucount=0;
quint64usize=0;
sq=QString("SELECT COUNT(size), SUM(size) FROM Tiles WHERE tileID IN (SELECT A.tileID FROM SetTiles A join SetTiles B on A.tileID = B.tileID WHERE B.setID = %1 GROUP by A.tileID HAVING COUNT(A.tileID) = 1)").arg(set->id());
if(subquery.exec(sq)){
if(subquery.next()){
//-- This is only accurate when all tiles are downloaded
ucount=subquery.value(0).toUInt();
usize=subquery.value(1).toULongLong();
}
}
//-- If we haven't downloaded it all, estimate size of unique tiles
s=QString("SELECT COUNT(size), SUM(size) FROM Tiles");
s=QString("SELECT COUNT(size), SUM(size) FROM Tiles");
qCDebug(QGCTileCacheLog)<<"_updateTotals(): "<<s;
if(query.exec(s)){
if(query.exec(s)){
if(query.next()){
if(query.next()){
_totalCount=query.value(0).toUInt();
_totalCount=query.value(0).toUInt();
_totalSize=query.value(1).toULongLong();
_totalSize=query.value(1).toULongLong();
}
}
}
}
s=QString("SELECT COUNT(size), SUM(size) FROM Tiles A INNER JOIN SetTiles B on A.tileID = B.tileID WHERE B.setID = %1").arg(_getDefaultTileSet());
s=QString("SELECT COUNT(size), SUM(size) FROM Tiles WHERE tileID IN (SELECT A.tileID FROM SetTiles A join SetTiles B on A.tileID = B.tileID WHERE B.setID = %1 GROUP by A.tileID HAVING COUNT(A.tileID) = 1)").arg(_getDefaultTileSet());
s=QString("SELECT tileID, size, hash FROM Tiles WHERE tileID IN (SELECT tileID FROM SetTiles WHERE setID = %1) ORDER BY DATE ASC LIMIT 128").arg(_getDefaultTileSet());
//-- Select tiles in default set only, sorted by oldest.
s=QString("SELECT tileID, size, hash FROM Tiles WHERE tileID IN (SELECT A.tileID FROM SetTiles A join SetTiles B on A.tileID = B.tileID WHERE B.setID = %1 GROUP by A.tileID HAVING COUNT(A.tileID) = 1) ORDER BY DATE ASC LIMIT 128").arg(_getDefaultTileSet());
s=QString("DELETE FROM Tiles WHERE tileID IN (SELECT tileID FROM SetTiles WHERE setID = %1)").arg(task->setID());
//-- Only delete tiles unique to this set
s=QString("DELETE FROM Tiles WHERE tileID IN (SELECT A.tileID FROM SetTiles A JOIN SetTiles B ON A.tileID = B.tileID WHERE B.setID = %1 GROUP BY A.tileID HAVING COUNT(A.tileID) = 1)").arg(task->setID());
query.exec(s);
query.exec(s);
s=QString("DELETE FROM TilesDownload WHERE setID = %1").arg(task->setID());
s=QString("DELETE FROM TilesDownload WHERE setID = %1").arg(task->setID());