summaryrefslogtreecommitdiff
path: root/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/bookshelfmanager/indexpage/btindexpage.cpp')
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp59
1 files changed, 18 insertions, 41 deletions
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index 984700c..026aad5 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,20 +19,20 @@
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
-#include "frontend/cmoduleindexdialog.h"
+#include "frontend/btmoduleindexdialog.h"
#include "util/directory.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
#include "util/tool.h"
-BtIndexPage::BtIndexPage()
- : BtConfigPage() {
+BtIndexPage::BtIndexPage(QWidget *parent)
+ : BtConfigPage(parent)
+{
namespace DU = util::directory;
- QVBoxLayout *vboxLayout;
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ QVBoxLayout *vboxLayout = static_cast<QVBoxLayout*>(layout());
QHBoxLayout *hboxLayout;
- vboxLayout = new QVBoxLayout(this);
m_autoDeleteOrphanedIndicesBox = new QCheckBox(this);
m_autoDeleteOrphanedIndicesBox->setToolTip(tr("If selected, those indexes which have no corresponding work will be deleted when BibleTime starts"));
@@ -75,22 +75,20 @@ BtIndexPage::BtIndexPage()
// connect our signals/slots
connect(m_createButton, SIGNAL(clicked()), this, SLOT(createIndices()));
connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteIndices()));
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
+ connect(CSwordBackend::instance(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
populateModuleList();
}
BtIndexPage::~BtIndexPage() {
CBTConfig::set( CBTConfig::autoDeleteOrphanedIndices, m_autoDeleteOrphanedIndicesBox->isChecked() );
-
-}
-QString BtIndexPage::label() {
- return tr("Create new search indexes and delete created indexes for the installed works.");
}
-QString BtIndexPage::iconName() {
- return CResMgr::bookshelfmgr::indexpage::icon;
+
+const QIcon &BtIndexPage::icon() const {
+ return util::directory::getIcon(CResMgr::bookshelfmgr::indexpage::icon);
}
-QString BtIndexPage::header() {
+
+QString BtIndexPage::header() const {
return tr("Search Indexes");
}
@@ -114,7 +112,7 @@ void BtIndexPage::populateModuleList() {
- const QList<CSwordModuleInfo*> &modules(CPointers::backend()->moduleList());
+ const QList<CSwordModuleInfo*> &modules(CSwordBackend::instance()->moduleList());
for (MLCI it(modules.begin()); it != modules.end(); ++it) {
QTreeWidgetItem* item = 0;
@@ -138,11 +136,11 @@ void BtIndexPage::populateModuleList() {
/** Creates indices for selected modules if no index currently exists */
void BtIndexPage::createIndices() {
bool indicesCreated = false;
- QList<CSwordModuleInfo*> moduleList;
+ QList<const CSwordModuleInfo*> moduleList;
for (int i = 0; i < m_modsWithoutIndices->childCount(); i++) {
if (m_modsWithoutIndices->child(i)->checkState(0) == Qt::Checked) {
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithoutIndices->child(i)->text(0).toUtf8());
+ CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(m_modsWithoutIndices->child(i)->text(0).toUtf8());
if (module) {
moduleList.append( module );
indicesCreated = true;
@@ -152,7 +150,7 @@ void BtIndexPage::createIndices() {
//Shows the progress dialog
if (indicesCreated) {
- CModuleIndexDialog::getInstance()->indexAllModules( moduleList );
+ BtModuleIndexDialog::indexAllModules(moduleList);
populateModuleList();
}
}
@@ -163,7 +161,7 @@ void BtIndexPage::deleteIndices() {
for (int i = 0; i < m_modsWithIndices->childCount(); i++) {
if (m_modsWithIndices->child(i)->checkState(0) == Qt::Checked) {
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
+ CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
if (module) {
module->deleteIndex();
indicesDeleted = true;
@@ -177,27 +175,6 @@ void BtIndexPage::deleteIndices() {
}
}
-void BtIndexPage::deleteOrphanedIndices() {
- QDir dir(CSwordModuleInfo::getGlobalBaseIndexLocation());
- dir.setFilter(QDir::Dirs);
- CSwordModuleInfo* module;
-
- for (unsigned int i = 0; i < dir.count(); i++) {
- if (dir[i] != "." && dir[i] != "..") {
- if ( (module = CPointers::backend()->findModuleByName(dir[i])) ) { //mod exists
- if (!module->hasIndex()) { //index files found, but wrong version etc.
- CSwordModuleInfo::deleteIndexForModule( dir[i] );
- }
- }
- else { //no module exists
- if (CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) ) {
- CSwordModuleInfo::deleteIndexForModule( dir[i] );
- }
- }
- }
- }
-}
-
void BtIndexPage::slotSwordSetupChanged() {
populateModuleList();
}