| 47 | } |
| 48 | |
| 49 | void ScreenshotManager::initHistory() |
| 50 | { |
| 51 | if (mHistoryInitialized) { |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | // Creating the SQLite database. |
| 56 | QSqlDatabase history = QSqlDatabase::addDatabase("QSQLITE"); |
| 57 | |
| 58 | QDir historyPath(mHistoryPath); |
| 59 | |
| 60 | if (!historyPath.exists()) { |
| 61 | historyPath.mkpath(mHistoryPath); |
| 62 | } |
| 63 | |
| 64 | history.setHostName("localhost"); |
| 65 | history.setDatabaseName(mHistoryPath + "history.sqlite"); |
| 66 | |
| 67 | if (history.open()) { |
| 68 | QSqlQuery tableQuery; |
| 69 | mHistoryInitialized = tableQuery.exec("CREATE TABLE IF NOT EXISTS history (fileName text, URL text, deleteURL text, time integer)"); |
| 70 | |
| 71 | history.exec("CREATE INDEX IF NOT EXISTS fileName_index ON history(fileName)"); |
| 72 | } else { |
| 73 | qCritical() << "Could not open SQLite DB."; |
| 74 | mHistoryInitialized = false; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | int ScreenshotManager::activeCount() const |
| 79 | { |