Mercurial > dedupe
diff DataController.cpp @ 93:308a718812ba
Small refactoring to allow lazy commits.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Tue, 22 Oct 2013 11:53:54 +0200 |
| parents | cfd2a417475a |
| children | c7da835ea912 |
line wrap: on
line diff
--- a/DataController.cpp Mon Oct 21 20:03:39 2013 +0200 +++ b/DataController.cpp Tue Oct 22 11:53:54 2013 +0200 @@ -99,11 +99,12 @@ } int n = 0; - emit populateProgress(n); + int max = paths.size(); + emit populateProgress(n, max); foreach(QString filename, paths) { try { - dblink.updateIfModified(filename); + dblink.updateIfModified(filename, true); } catch (const PermissionException& e) { dblink.deleteFileFromDB(filename); @@ -117,7 +118,7 @@ e.raise(); } - emit populateProgress(++n); + emit populateProgress(++n, max); QDateTime now = QDateTime::currentDateTime(); if (last.msecsTo(now) > 1000) { @@ -125,6 +126,7 @@ last = now; } } + dblink.commit(); } @@ -186,6 +188,8 @@ QMultiMap<QDateTime, QSharedPointer<FileDBLink::DBInfo> > mtimeLUP; QMultiMap<QByteArray, QSharedPointer<FileDBLink::DBInfo> > checksumLUP; + int max = elems.size() - 1; + foreach(QSharedPointer<FileDBLink::DBInfo> line, elems) { if (showNameDups) { nameLUP.insertMulti(line->name(), line); @@ -304,7 +308,7 @@ if (item) tw->addTopLevelItem(item); - emit populateProgress(++n); + emit populateProgress(++n, max); if (n % 64 == 0) { QCoreApplication::processEvents(); } @@ -422,22 +426,28 @@ setup(QString(), QString(), showGUI); } -void DataController::progressUpdate(int p) +void DataController::progressUpdate(int p, int max) { QString str; if (p == 0) - str.sprintf("Progress %6.2f%%", p * 100.0 / progressMax); - else if (p == progressMax) { + str.sprintf("Progress %6.2f%%", p * 100.0 / max); + else if (p == max) { str.sprintf("\b\b\b\b\b\b\b%6.2f%%\n", 100.0); } else { - str.sprintf("\b\b\b\b\b\b\b%6.2f%%", p * 100.0 / progressMax); + str.sprintf("\b\b\b\b\b\b\b%6.2f%%", p * 100.0 / max); } std::cout<<str.toStdString(); std::cout.flush(); } +void DataController::progressUpdate(int p) +{ + progressUpdate(p, progressMax); +} + + void DataController::deleteFile() { QString path = contextMenuItem->data(0, 32).toString(); @@ -475,7 +485,7 @@ contextMenu = 0; - connect(this, SIGNAL(populateProgress(int)), + connect(this, SIGNAL(populateProgress(int, int)), this, SLOT(progressUpdate(int))); QString dbpath; @@ -492,6 +502,11 @@ dblink = new MemoryDBLink(); #endif + connect(dblink, SIGNAL(progressUpdate(int, int)), + this, SLOT(progressUpdate(int, int))); + + + setDir((searchPath_in.size() > 0) ? searchPath_in : QDir(".")); showFullPath = false;
