From 9b04b435887f37d4362972fcbf7fa1d1e1bef1f6 Mon Sep 17 00:00:00 2001 From: jaime <29511627+ea4k@users.noreply.github.com> Date: Sun, 11 Jan 2015 18:48:25 +0000 Subject: [PATCH] VACUUM worked and DB is compressed each exit --- Changelog | 2 + TODO | 12 +- database.cpp | 24 +++- database.h | 3 + dataproxy.cpp | 6 +- dataproxy.h | 1 + dataproxy_sqlite.cpp | 31 +++--- dataproxy_sqlite.h | 1 + filemanager.cpp | 8 +- klog.pro.user | 257 ------------------------------------------- main.cpp | 4 +- mainwindow.cpp | 13 ++- setuppagecolors.cpp | 2 +- 13 files changed, 72 insertions(+), 292 deletions(-) delete mode 100644 klog.pro.user diff --git a/Changelog b/Changelog index 6cbbca67..cad0b6ec 100644 --- a/Changelog +++ b/Changelog @@ -6,9 +6,11 @@ December-2013 - 0.9.0.3RC1 - Bugfix: Search results showed the default Station Callsign if non was in the QSO. This lead to errors if QRZ was not the default. - KLog recognizes now .ADIF files (instead of only .ADI). - KLog shows now the WAZ status. +- Added a very basic support of DX Marathon (http://www.dxmarathon.com/) - DXCluster filters are now working. - The user can manually assign the DXCC entity for a DX. - Improved the function to update the DB from one release to the following. +- DB file is compressed everytime KLog finishes. - It is possible to find QSL pending to receive. - It is possible to modify entities data in the World Editor in preferences. - It is possible to choose in preferences whether to keep my Data Tab from one QSO to the next or not. diff --git a/TODO b/TODO index e571588a..a87f31ed 100644 --- a/TODO +++ b/TODO @@ -5,28 +5,28 @@ Feel free to request any roadmap change if you have any suggestion. Bug: Check if the dxcluster configuration to show or not confirmed/worked works properly KLog 0.9.1 -TODO: when File New: - Clean the DB & query.exec("VACUUM"); TODO: When Saving As, KLog should offer the default filename. -TODO: Adapt to ADIF 3.0.4 TODO: Make a tool to mark and export QSO from the right button. (i.e. To mark several QSO to print and export the ADIF file with just those QSO) TODO: Add the awards functionality (to manage awa files, TPEA, WAS, ...) TODO: Check the colors in the searchBox, they may be not correct. -TODO: Add CQ DX Marathon support. +TODO: Keep adapting to ADIF 3.0.4 + KLog 0.9.2 TODO: Add Satellite support (maybe another Tab) (look this file (below) for details. TODO: Add another tab in the botton to list the DXCC status. -TBD - Added the feature to add and manage several logs. +TBD - Add the feature to add and manage several logs. TODO: Add an option to auto-complete info (QTH, Locator, Name, QSL Manager(qsl_via), IOTA, AWARD, Entity...) from previously worked QSO. TODO: UI: Modify the DX-Cluster tab to show the data in a table: DX de/Freq/DX/Comment/Time/Loc +TODO: Keep adapting to ADIF 3.0.4 KLog 0.9.3 TODO: Support CQ WW SSB (Including Cabrillo Import/Export) TODO: Support CQ WW CW (Including Cabrillo Import/Export) KLog 0.9.4 -TODO: Hamlib support (Linux) +TODO: Hamlib support (Linux). +TODO: Add a DXCluster bandmap. KLog 0.9.5 TODO: Support CQ WPX SSB (Including Cabrillo Import/Export) diff --git a/database.cpp b/database.cpp index e5935ce0..f3bd55bd 100644 --- a/database.cpp +++ b/database.cpp @@ -41,6 +41,21 @@ DataBase::~DataBase() //qDebug() << "DataBase::~DataBase" << endl; } +void DataBase::compress() +{ + //qDebug() << "DataBase::compress " << endl; + + QSqlDatabase db = QSqlDatabase::database(); + if (!db.open()) { + QMessageBox::warning(0, QObject::tr("Database Error"), + db.lastError().text()); + } + else + { + db.exec("VACUUM;"); + } + +} bool DataBase::createConnection() { @@ -72,7 +87,8 @@ bool DataBase::createConnection() } else { - //qDebug() << "DataBase::createConnection: creted?" << endl; + //qDebug() << "DataBase::createConnection: created?" << endl; + if (isTheDBCreated()) { @@ -1140,7 +1156,7 @@ bool DataBase::updateToLatest() * The updateXXX are recursive calls that calls the previous one. * */ - qDebug() << "DataBase::updateToLatest-003 " << endl; + //qDebug() << "DataBase::updateToLatest-003 " << endl; return updateTo004(); } @@ -1156,7 +1172,7 @@ bool DataBase::updateTo003() * QString stringQuery = QString ("ALTER TABLE award_enumeration ADD COLUMN dxcc INTEGER;"); * */ - qDebug() << "DataBase::updateTo003" << endl; + //qDebug() << "DataBase::updateTo003" << endl; bool IAmIn003 = false; bool IAmIn002 = false; bool ErrorUpdating = false; @@ -1201,7 +1217,7 @@ bool DataBase::updateTo004() * QString stringQuery = QString ("ALTER TABLE award_enumeration ADD COLUMN dxcc INTEGER;"); * */ - qDebug() << "DataBase::updateTo004" << endl; + //qDebug() << "DataBase::updateTo004" << endl; bool IAmIn004 = false; bool IAmIn003 = false; bool ErrorUpdating = false; diff --git a/database.h b/database.h index d6eb1738..fb0e5a22 100644 --- a/database.h +++ b/database.h @@ -69,6 +69,7 @@ public: bool unMarkAllQSO(); bool updateIfNeeded(); + void compress(); @@ -94,6 +95,8 @@ private: QMap bandQMap; QMap modeQMap; + //QSqlDatabase *db; + }; #endif // DATABASE_H diff --git a/dataproxy.cpp b/dataproxy.cpp index 2a8d952d..9fa1adbd 100644 --- a/dataproxy.cpp +++ b/dataproxy.cpp @@ -30,7 +30,7 @@ DataProxy::DataProxy() { - // qDebug() << "DataProxy::DataProxy" << endl; + //qDebug() << "DataProxy::DataProxy" << endl; } @@ -165,6 +165,10 @@ QStringList DataProxy::getOperatingYears(const int _currentLog) return QStringList(); } +void DataProxy::compressDB() +{ + +} diff --git a/dataproxy.h b/dataproxy.h index d66dc19b..d25ea4bc 100644 --- a/dataproxy.h +++ b/dataproxy.h @@ -47,6 +47,7 @@ public: virtual QString getCallFromId(const int _qsoId); virtual QStringList getOperatingYears(const int _currentLog); + virtual void compressDB(); /* virtual bool addDXMarathonQSO(const int _year, const int _dxcc, const int _cqz, const int _power, const int _mode, const int qsoid, const int _currentLog); virtual int getDXMarathonTotalScore(const int _year); diff --git a/dataproxy_sqlite.cpp b/dataproxy_sqlite.cpp index 15624ba7..8aebcf2b 100644 --- a/dataproxy_sqlite.cpp +++ b/dataproxy_sqlite.cpp @@ -520,7 +520,7 @@ int DataProxy_SQLite::isWorkedB4(const QString _qrz, const int _currentLog) bool DataProxy_SQLite::isDXCCConfirmed(const int _dxcc, const int _currentLog) { - qDebug() << "DataProxy_SQLite::isDXCCConfirmed: " << QString::number(_dxcc) << "/" << QString::number(_currentLog) << endl; + //qDebug() << "DataProxy_SQLite::isDXCCConfirmed: " << QString::number(_dxcc) << "/" << QString::number(_currentLog) << endl; QString queryString = QString("SELECT confirmed from awarddxcc WHERE dxcc='%1' AND lognumber='%2'").arg(_dxcc).arg(_currentLog); QSqlQuery query; @@ -531,27 +531,27 @@ bool DataProxy_SQLite::isDXCCConfirmed(const int _dxcc, const int _currentLog) { if ( (query.value(0)).toInt() == 1) { - qDebug() << "DataProxy_SQLite::isDXCCConfrmed: TRUE" << endl; + //qDebug() << "DataProxy_SQLite::isDXCCConfrmed: TRUE" << endl; return true; } else { - qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE1" << endl; + //qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE1" << endl; return false; } } else { - qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE2" << endl; + //qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE2" << endl; return false; } } else { - qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE3" << endl; + //qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE3" << endl; return false; } - qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE4" << endl; + //qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE4" << endl; return false; } @@ -559,12 +559,12 @@ bool DataProxy_SQLite::isHF(const int _band) { if ((_band>=18) && (_band<=27)) { - qDebug() << "DataProxy_SQLite::isHF: TRUE" << endl; + //qDebug() << "DataProxy_SQLite::isHF: TRUE" << endl; return true; } else { - qDebug() << "DataProxy_SQLite::isHF: FALSE" << endl; + //qDebug() << "DataProxy_SQLite::isHF: FALSE" << endl; return false; } } @@ -573,12 +573,12 @@ bool DataProxy_SQLite::isWARC(const int _band) { if ((_band == 19) || (_band==21) ||(_band==23) ) { - qDebug() << "DataProxy_SQLite::isWARC: tRUE" << endl; + //qDebug() << "DataProxy_SQLite::isWARC: tRUE" << endl; return true; } else { - qDebug() << "DataProxy_SQLite::isWARC: FALSE" << endl; + //qDebug() << "DataProxy_SQLite::isWARC: FALSE" << endl; return false; } } @@ -587,19 +587,19 @@ bool DataProxy_SQLite::isVHF(const int _band) { if (_band<=17) { - qDebug() << "DataProxy_SQLite::isVHF: TRUE" << endl; + //qDebug() << "DataProxy_SQLite::isVHF: TRUE" << endl; return true; } else { - qDebug() << "DataProxy_SQLite::isVHF: FALSE" << endl; + //qDebug() << "DataProxy_SQLite::isVHF: FALSE" << endl; return false; } } QStringList DataProxy_SQLite::getOperatingYears(const int _currentLog) { - qDebug() << "DataProxy_SQLite::getYearsOperating: " << QString::number(_currentLog) << endl; + //qDebug() << "DataProxy_SQLite::getYearsOperating: " << QString::number(_currentLog) << endl; QStringList years = QStringList(); QSqlQuery query; QString queryString = QString("SELECT DISTINCT (substr (qso_date, 0, 5)) FROM log WHERE lognumber='%0'").arg(_currentLog); @@ -626,3 +626,8 @@ QStringList DataProxy_SQLite::getOperatingYears(const int _currentLog) } } + +void DataProxy_SQLite::compressDB() +{ + db->compress(); +} diff --git a/dataproxy_sqlite.h b/dataproxy_sqlite.h index ab8b8d71..741e3d90 100644 --- a/dataproxy_sqlite.h +++ b/dataproxy_sqlite.h @@ -44,6 +44,7 @@ public: QString getCallFromId(const int _qsoId); QStringList getOperatingYears(const int _currentLog); + void compressDB(); bool clearLog(); diff --git a/filemanager.cpp b/filemanager.cpp index dae699dd..cc1e9403 100644 --- a/filemanager.cpp +++ b/filemanager.cpp @@ -29,7 +29,7 @@ FileManager::FileManager() { -qDebug() << "FileManager::FileManager()" << endl; + //qDebug() << "FileManager::FileManager()" << endl; ignoreUnknownAlways = false; world = new World(); awards = new Awards(); @@ -143,7 +143,7 @@ bool FileManager::adifLogExport(const QString& _fileName) } bool FileManager::adifLogExportToFile(const QString& _fileName, bool justMarked, bool _qslRequested ){ -qDebug() << "FileManager::adifLogExportToFile: " << _fileName << endl; + //qDebug() << "FileManager::adifLogExportToFile: " << _fileName << endl; bool exportJustMarkedQSO = justMarked; bool marked = false; bool exportOnlyQSLRequested = _qslRequested; @@ -1683,7 +1683,7 @@ bool FileManager::cabrilloLogExport(const QString& _fileName, const int _contest bool FileManager::cabrilloLogExportCQWWToFile(const QString& _fileName, const int logNconst) { -qDebug() << "FileManager::cabrilloLogExportCQWWToFile" << _fileName, endl; + //qDebug() << "FileManager::cabrilloLogExportCQWWToFile" << _fileName, endl; /* START-OF-LOG: ARRL-SECTION: @@ -1935,7 +1935,7 @@ QFile file(_fileName); bool FileManager::cabrilloLogExportToFile(const QString& _fileName, const int logNconst) { -qDebug() << "FileManager::cabrilloLogExportToFile" << endl; + //qDebug() << "FileManager::cabrilloLogExportToFile" << endl; //TODO: Message "You must select a proper file format QMessageBox msgBox; diff --git a/klog.pro.user b/klog.pro.user deleted file mode 100644 index bb08d322..00000000 --- a/klog.pro.user +++ /dev/null @@ -1,257 +0,0 @@ - - - - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - true - 1 - true - 0 - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - mi kit - mi kit - {31e882c5-4f69-48a6-94f6-f45bc581a7e6} - 1 - 0 - 0 - - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - /Users/jaime/Desktop/devel/build-klog-mi_kit-Debug - true - - - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - /Users/jaime/Desktop/devel/build-klog-mi_kit-Release - true - - 2 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy locally - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - true - - false - false - false - false - true - 0.01 - 10 - true - 25 - - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - klog - - Qt4ProjectManager.Qt4RunConfiguration:/Users/jaime/Desktop/devel/klog/klog.pro - - klog.pro - false - false - - 3768 - true - false - false - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.EnvironmentId - {b0d8e9d0-533e-4d6a-921f-d47a63d739aa} - - - ProjectExplorer.Project.Updater.FileVersion - 14 - - diff --git a/main.cpp b/main.cpp index b90aa649..ea946e8a 100644 --- a/main.cpp +++ b/main.cpp @@ -154,12 +154,12 @@ int main(int argc, char *argv[]) } else { - //qDebug() << "MAIN: Not the first time that is executed! " << endl; MainWindow mw(kontestDir, version); mw.show(); + return app.exec(); } - return app.exec(); + //return app.exec(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index cd980f9f..936869a2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -180,6 +180,7 @@ MainWindow::MainWindow(const QString _kontestDir, const QString tversion) + //qDebug() << "MainWindow::MainWindow: 1 " << endl; world = new World(kontestDir, softwareVersion); @@ -416,6 +417,8 @@ MainWindow::MainWindow(const QString _kontestDir, const QString tversion) readConfigData(); if (needToEnd) { + //QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); + db->compress(); exit(0); } @@ -2612,7 +2615,7 @@ void MainWindow::slotSearchBoxReSearchButtonClicked() /* void MainWindow::slotSearchBoxOnItemChanged( QTreeWidgetItem * item, int column) { - qDebug() << "MainWindow::slotSearchBoxOnItemChanged: " << (item->data (0, Qt::DisplayRole)).toString() << QString::number(column) << endl; + //qDebug() << "MainWindow::slotSearchBoxOnItemChanged: " << (item->data (0, Qt::DisplayRole)).toString() << QString::number(column) << endl; //searchResultsTreeWidget //item->data (0, Qt::DisplayRole) @@ -3154,6 +3157,8 @@ void MainWindow::closeEvent(QCloseEvent *event) { db->unMarkAllQSO(); //slotFileClose(); + dataProxy->compressDB(); + //db->compress(); event->accept(); } else @@ -8113,7 +8118,7 @@ void MainWindow::slotToolSearchQSL(const int actionQSL) if (stationCallSignShownInSearch) { - qDebug() << "MainWindow::slotToolSearchQSL: stationCallSign "<< endl; + //qDebug() << "MainWindow::slotToolSearchQSL: stationCallSign "<< endl; nameCol = rec.indexOf("station_callsign"); if (((query.value(nameCol)).toString()).length()>=3) @@ -8351,9 +8356,9 @@ void MainWindow::selectCorrectComboBoxEntity(const int _ent) int MainWindow::getDXCCFromComboBox() { - qDebug() << "MainWindow::getDXCCFromComboBox" << endl; + //qDebug() << "MainWindow::getDXCCFromComboBox" << endl; QString pref = (entityNameComboBox->currentText()).split('-').at(0); - qDebug() << "MainWindow::getDXCCFromComboBox: " << pref << "/" << QString::number(world->getQRZARRLId(pref))<< endl; + //qDebug() << "MainWindow::getDXCCFromComboBox: " << pref << "/" << QString::number(world->getQRZARRLId(pref))<< endl; return world->getQRZARRLId(pref); } diff --git a/setuppagecolors.cpp b/setuppagecolors.cpp index 2fc6a462..da3ce049 100644 --- a/setuppagecolors.cpp +++ b/setuppagecolors.cpp @@ -31,7 +31,7 @@ SetupPageColors::SetupPageColors(QWidget *parent) : QWidget(parent) { -// qDebug() << "SetupPageColors::SetupPageColors" << endl; +//Debug() << "SetupPageColors::SetupPageColors" << endl; newOneColorButton = new QPushButton; neededColorButton = new QPushButton;