summaryrefslogtreecommitdiff
path: root/src/frontend/bookshelfmanager
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:33 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:33 -0400
commit4885bfcef4d89cf0cb391e00af617b9fd19c9cbb (patch)
treee8ba8579bd76a1b277231202ca6579eb19c1ab4b /src/frontend/bookshelfmanager
parent294b5ec5834affa57641475946b8d2aeca53c577 (diff)
Imported Upstream version 2.5
Diffstat (limited to 'src/frontend/bookshelfmanager')
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp9
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp2
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.h1
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp41
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp6
-rw-r--r--src/frontend/bookshelfmanager/instbackend.cpp22
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.cpp141
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.h44
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp59
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h30
12 files changed, 179 insertions, 182 deletions
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
index 47e274c..e326641 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
@@ -81,7 +81,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
- QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Save, Qt::Horizontal, this);
+ QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save, Qt::Horizontal, this);
util::prepareDialogBox(buttonBox);
QPushButton* getListButton = new QPushButton(tr("Get list..."), this);
getListButton->setToolTip(tr("Download a list of sources from CrossWire server and add sources"));
@@ -105,7 +105,8 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
sword::InstallSource is = instbackend::source(m_captionEdit->text());
if ( (QString)is.caption.c_str() == m_captionEdit->text() ) { //source already exists
util::showInformation( this, tr( "Error" ),
- tr("A source with this caption already exists.<br/>Please provide a different caption."));
+ /** \bug Double space in the following string: */
+ tr("A source with this caption already exists. Please provide a different caption."));
return;
}
@@ -153,7 +154,7 @@ void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
void CSwordSetupInstallSourcesDialog::slotGetListClicked() {
QString message(tr("List of sources will be downloaded from a remote server. Sources will be added to the current list. New source will replace an old one if it has the same label. You can later remove the sources you don't want to keep.\n\nDo you want to continue?"));
- QMessageBox::StandardButton answer = util::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
+ QMessageBox::StandardButton answer = util::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::No) {
return;
}
@@ -181,7 +182,7 @@ void CSwordSetupInstallSourcesDialog::slotGetListClicked() {
qDebug() << "download succeeded";
success = true;
m_progressDialog->setValue(100); //make sure the dialog closes
- m_remoteListAdded = true;
+ m_remoteListAdded = true;
accept();
}
else {
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
index 64c7f21..12df221 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
@@ -28,7 +28,9 @@ class CSwordSetupInstallSourcesDialog : public QDialog {
public:
sword::InstallSource getSource();
- bool wasRemoteListAdded() {return m_remoteListAdded;}
+ bool wasRemoteListAdded() {
+ return m_remoteListAdded;
+ }
CSwordSetupInstallSourcesDialog();
protected slots:
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index df388dd..984700c 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -165,7 +165,7 @@ void BtIndexPage::deleteIndices() {
if (m_modsWithIndices->child(i)->checkState(0) == Qt::Checked) {
CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
if (module) {
- CSwordModuleInfo::deleteIndexForModule( module->name() );
+ module->deleteIndex();
indicesDeleted = true;
}
}
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.h b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
index aa13eb0..795cc0b 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.h
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
@@ -11,7 +11,6 @@
#define BTINDEXPAGE_H
#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include "backend/btmoduletreeitem.h"
class QCheckBox;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
index ecdf7e3..b71599a 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
@@ -145,7 +145,7 @@ void BtInstallPage::initPathCombo() {
if (!dir.isReadable()) continue;
QFileInfo fi( dir.canonicalPath());
if (!fi.isWritable()) continue;
- m_pathCombo->addItem(util::directory::convertDirSeparators(*it));
+ m_pathCombo->addItem(util::directory::convertDirSeparators(*it));
}
// choose the current value from config but check whether we have so many items
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
index c6175d5..9efb9f0 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
@@ -125,19 +125,22 @@ void BtInstallPathDialog::updateTopLevelItems() {
if (m_writableItem->childCount()) {
m_writableItem->setHidden(false);
m_swordPathListBox->expandItem(m_writableItem);
- } else {
+ }
+ else {
m_writableItem->setHidden(true);
}
if (m_readableItem->childCount()) {
m_readableItem->setHidden(false);
m_swordPathListBox->expandItem(m_readableItem);
- } else {
+ }
+ else {
m_readableItem->setHidden(true);
}
if (m_nonexistingItem->childCount()) {
m_nonexistingItem->setHidden(false);
m_swordPathListBox->expandItem(m_nonexistingItem);
- } else {
+ }
+ else {
m_nonexistingItem->setHidden(true);
}
}
@@ -145,22 +148,24 @@ void BtInstallPathDialog::updateTopLevelItems() {
void BtInstallPathDialog::addPathToList(QString pathname) {
if (pathname.isEmpty()) return;
- QTreeWidgetItem* i = 0;
- QDir dir(pathname);
- if (!dir.exists()) {
- i = new QTreeWidgetItem(m_nonexistingItem, QStringList(pathname) );
- } else if (dir.isReadable()) {
- const QFileInfo fi( dir.canonicalPath() );
- if (fi.isWritable()) {
- i = new QTreeWidgetItem(m_writableItem, QStringList(pathname) );
- } else {
- i = new QTreeWidgetItem(m_readableItem, QStringList(pathname) );
- }
+ QTreeWidgetItem* i = 0;
+ QDir dir(pathname);
+ if (!dir.exists()) {
+ i = new QTreeWidgetItem(m_nonexistingItem, QStringList(pathname) );
+ }
+ else if (dir.isReadable()) {
+ const QFileInfo fi( dir.canonicalPath() );
+ if (fi.isWritable()) {
+ i = new QTreeWidgetItem(m_writableItem, QStringList(pathname) );
}
- if (i && QDir(pathname) == instbackend::swordDir()) {
- i->setFlags(Qt::NoItemFlags);
- i->setToolTip(0, tr("This default folder in your home directory can't be removed"));
+ else {
+ i = new QTreeWidgetItem(m_readableItem, QStringList(pathname) );
}
+ }
+ if (i && QDir(pathname) == instbackend::swordDir()) {
+ i->setFlags(Qt::NoItemFlags);
+ i->setToolTip(0, tr("This default folder in your home directory can't be removed"));
+ }
}
void BtInstallPathDialog::slotEditClicked() {
@@ -218,7 +223,7 @@ void BtInstallPathDialog::slotRemoveClicked() {
void BtInstallPathDialog::writeSwordConfig() {
qDebug() << "BtInstallPathDialog::writeSwordConfig";
QStringList targets;
- QTreeWidgetItemIterator it(m_swordPathListBox, QTreeWidgetItemIterator::NoChildren|QTreeWidgetItemIterator::Enabled|QTreeWidgetItemIterator::NotHidden);
+ QTreeWidgetItemIterator it(m_swordPathListBox, QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Enabled | QTreeWidgetItemIterator::NotHidden);
while (*it) {
if (!(*it)->text(0).isEmpty()) {
targets << (*it)->text(0);
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp b/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
index 8c43837..81e84fb 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
@@ -192,12 +192,12 @@ void BtSourceWidget::initSources() {
//first clear all sources
//int i = count();
- for (int i = count()-1; i >= 0; i--) {
+ for (int i = count() - 1; i >= 0; i--) {
BtSourceArea* a = dynamic_cast<BtSourceArea*>(widget(i));
a->prepareRemove();
}
- for (int i = count()-1; i >= 0; i--) {
- qDebug() << "remove tab"<<tabText(i);
+ for (int i = count() - 1; i >= 0; i--) {
+ qDebug() << "remove tab" << tabText(i);
QWidget* w = widget(i);
removeTab(i);
delete w;
diff --git a/src/frontend/bookshelfmanager/instbackend.cpp b/src/frontend/bookshelfmanager/instbackend.cpp
index d671430..463a6e5 100644
--- a/src/frontend/bookshelfmanager/instbackend.cpp
+++ b/src/frontend/bookshelfmanager/instbackend.cpp
@@ -120,7 +120,7 @@ bool deleteSource(QString name) {
sce = l.join("|").append("|");
it = range.first;
while (it != range.second) {
- qDebug() << it->second;
+ qDebug() << it->second;
if (it->second == sce) {
config["Sources"].erase(it);
break;
@@ -150,8 +150,8 @@ bool isRemote(const sword::InstallSource& source) {
}
const QString configPath() {
- QString confPath = util::directory::getUserHomeSwordDir().absolutePath();
- confPath.append("/InstallMgr");
+ QString confPath = util::directory::getUserHomeSwordDir().absolutePath();
+ confPath.append("/InstallMgr");
return confPath;
}
@@ -196,23 +196,23 @@ bool setTargetList( const QStringList& targets ) {
return false;
}
- filename = util::directory::convertDirSeparators(filename);
+ filename = util::directory::convertDirSeparators(filename);
SWConfig conf(filename.toLocal8Bit());
conf.Sections.clear();
#ifdef Q_WS_WIN
- // On Windows, add the sword directory to the config file.
- QString swordPath = DU::convertDirSeparators( DU::getApplicationSwordDir().absolutePath());
- conf["Install"].insert(
- std::make_pair( SWBuf("LocalePath"), swordPath.toLocal8Bit().data() )
- );
+ // On Windows, add the sword directory to the config file.
+ QString swordPath = DU::convertDirSeparators( DU::getApplicationSwordDir().absolutePath());
+ conf["Install"].insert(
+ std::make_pair( SWBuf("LocalePath"), swordPath.toLocal8Bit().data() )
+ );
#endif
bool setDataPath = false;
for (QStringList::const_iterator it = targets.begin(); it != targets.end(); ++it) {
- QString t = DU::convertDirSeparators(*it);
+ QString t = DU::convertDirSeparators(*it);
#ifdef Q_WS_WIN
- if (t.contains(DU::convertDirSeparators(DU::getUserHomeDir().canonicalPath().append("\\Sword")))) {
+ if (t.contains(DU::convertDirSeparators(DU::getUserHomeDir().canonicalPath().append("\\Sword")))) {
#else
if (t.contains(DU::getUserHomeDir().canonicalPath().append("/.sword"))) {
#endif
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
index 1cc6398..3f602e0 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
@@ -1,31 +1,28 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
*
**********/
#include "frontend/bookshelfmanager/removepage/btremovepage.h"
-#include <QDebug>
#include <QGridLayout>
-#include <QLabel>
+#include <QHeaderView>
#include <QList>
-#include <QMultiMap>
#include <QPushButton>
-#include <QString>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include "backend/btmoduletreeitem.h"
-#include "backend/config/cbtconfig.h"
+#include <QTreeView>
#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
#include "util/directory.h"
#include "util/dialogutil.h"
#include "util/cpointers.h"
#include "util/cresmgr.h"
-#include "util/tool.h"
// Sword includes:
#include <swmgr.h>
@@ -43,11 +40,14 @@ BtRemovePage::BtRemovePage()
layout->setColumnStretch(1, 1);
layout->setRowStretch(2, 1);
- m_view = new QTreeWidget(this);
- m_view->setHeaderLabels(QStringList() << tr("Work") << tr("Install path"));
- m_view->setColumnWidth(0, util::tool::mWidth(m_view, 20));
+ m_model = new BtRemovePageTreeModel(this);
+ m_model->setSourceModel(CPointers::backend()->model());
+
+ m_view = new QTreeView(this);
+ m_view->header()->setResizeMode(QHeaderView::ResizeToContents);
+ m_view->setModel(m_model);
- layout->addWidget( m_view, 2, 0, 1, 2);
+ layout->addWidget(m_view, 2, 0, 1, 2);
m_removeButton = new QPushButton(tr("Remove..."), this);
m_removeButton->setToolTip(tr("Remove the selected works"));
@@ -55,80 +55,36 @@ BtRemovePage::BtRemovePage()
m_removeButton->setEnabled(false);
layout->addWidget(m_removeButton, 3, 1, Qt::AlignRight);
- connect(m_view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(slotItemDoubleClicked(QTreeWidgetItem*, int)));
- connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveModules()));
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
- populateModuleList();
+ connect(m_removeButton, SIGNAL(clicked()),
+ this, SLOT(slotRemoveModules()));
+ connect(m_model, SIGNAL(moduleChecked(CSwordModuleInfo*, bool)),
+ this, SLOT(resetRemoveButton()));
+ connect(m_model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
+ this, SLOT(resetRemoveButton()));
}
QString BtRemovePage::label() {
return tr("Remove installed works. Select the works and click Remove button.");
}
+
QString BtRemovePage::iconName() {
return CResMgr::bookshelfmgr::removepage::icon;
}
+
QString BtRemovePage::header() {
return tr("Remove");
}
-
-void BtRemovePage::populateModuleList() {
-
- m_view->clear();
- m_selectedModules.clear();
-
- // disconnect the signal so that we don't have to run functions for every module
- disconnect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
-
- QList<BTModuleTreeItem::Filter*> empty;
- BTModuleTreeItem rootItem(empty, (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping));
- addToTree(&rootItem, m_view->invisibleRootItem());
-
- // receive signal when user checks modules
- connect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
- qDebug() << "BtSourceArea::createModuleTree end";
+void BtRemovePage::resetRemoveButton() {
+ m_removeButton->setEnabled(!m_model->checkedModules().empty());
}
-void BtRemovePage::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
- //qDebug()<<"BtRemovePage::addToTree "<<item->text();
- //qDebug() << "BTMTItem type: " << item->type();
-
- foreach (BTModuleTreeItem* i, item->children()) {
- addToTree(i, new QTreeWidgetItem(widgetItem));
- }
- if (item->type() != BTModuleTreeItem::Root) {
- CSwordModuleInfo* mInfo = item->moduleInfo();
- widgetItem->setText(0, item->text());
- if (item->type() == BTModuleTreeItem::Category || item->type() == BTModuleTreeItem::Language) {
- //qDebug() << "item"<<item->text()<< "was cat or lang";
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
- }
- if (item->type() == BTModuleTreeItem::Module) {
- //qDebug() << "item"<<item->text()<< "was a module";
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- widgetItem->setCheckState(0, Qt::Unchecked);
-
- /// \todo add the relevant information in to item or tooltip
- // (install path, is still available from some source)
-
- QString descr(mInfo->config(CSwordModuleInfo::AbsoluteDataPath));
- QString toolTipText = util::tool::moduleToolTip(mInfo);
- widgetItem->setText(1, descr);
- widgetItem->setToolTip(0, toolTipText);
- widgetItem->setToolTip(1, descr);
- }
- }
-}
-
-
-
void BtRemovePage::slotRemoveModules() {
- if ( m_selectedModules.empty() ) {
- return; //no message, just do nothing
- }
+ // Do nothing when this signal fires without anything selected to remove:
+ if (m_model->checkedModules().empty()) return;
QStringList moduleNames;
- foreach (CSwordModuleInfo* m, m_selectedModules) {
+ foreach (CSwordModuleInfo *m, m_model->checkedModules()) {
moduleNames.append(m->name());
}
const QString message = tr("You selected the following work(s): ")
@@ -175,44 +131,3 @@ void BtRemovePage::slotRemoveModules() {
mgrDict.clear();
}
}
-
-
-void BtRemovePage::slotSelectionChanged(QTreeWidgetItem* item, int column) {
- //qDebug() << "BtRemovePage::slotSelectionChanged";
- // modify the internal list of checked modules
- // if() leaves groups away
- if (!item->childCount() && column == 0) {
- CSwordModuleInfo* mInfo = 0;
- //qDebug() << "BtRemovePage::slotSelectionChanged";
- foreach (CSwordModuleInfo* module, CPointers::backend()->moduleList()) {
- if (module->name() == item->text(0) && module->config(CSwordModuleInfo::AbsoluteDataPath) == item->text(1)) {
- mInfo = module;
- break;
- }
- }
- Q_ASSERT(mInfo); // this should have been found
- if (item->checkState(0) == Qt::Checked) {
- //qDebug() << item->text(0) << "in" << item->text(1) << "was checked";
- m_selectedModules.append(mInfo);
- }
- else {
- //qDebug() << mInfo->name() << "was unchecked";
- m_selectedModules.removeAll(mInfo); // there is only one, it's a pointer
- }
-
- if (m_selectedModules.count() > 0) {
- m_removeButton->setEnabled(true);
- }
- else {
- m_removeButton->setEnabled(false);
- }
- }
-}
-
-void BtRemovePage::slotItemDoubleClicked(QTreeWidgetItem* /*item*/, int /*column*/) {
- // \todo Open the About dialog.
-}
-
-void BtRemovePage::slotSwordSetupChanged() {
- populateModuleList();
-}
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.h b/src/frontend/bookshelfmanager/removepage/btremovepage.h
index 920b1ee..2950619 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.h
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.h
@@ -1,9 +1,12 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
*
**********/
@@ -15,49 +18,32 @@
#include <QMultiMap>
#include <QString>
#include "backend/btmoduletreeitem.h"
+#include "frontend/bookshelfmanager/removepage/btremovepagetreemodel.h"
-class QTreeWidget;
-class QTreeWidgetItem;
class QPushButton;
+class QTreeView;
-class BtRemovePage : public BtConfigPage {
+class BtRemovePage: public BtConfigPage {
Q_OBJECT
public:
BtRemovePage();
- ~BtRemovePage() {}
-
- // BtConfigPage methods
+ // BtConfigPage methods:
QString header();
QString iconName();
QString label();
- void populateModuleList();
-
-//signals:
- //void swordSetupChanged();
-
- public slots:
- void slotSwordSetupChanged();
-
- private slots:
-
+ protected slots:
void slotRemoveModules();
- /** Handles activating the Remove button. */
- void slotSelectionChanged(QTreeWidgetItem* item, int column);
- void slotItemDoubleClicked(QTreeWidgetItem* item, int column);
-
- private: // methods
- void addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
+ void resetRemoveButton();
- private: // data
- QTreeWidget* m_view;
- QPushButton* m_removeButton;
- /** Map of module name and install path (absolute path from the moduleinfo config entry).*/
- QList<CSwordModuleInfo*> m_selectedModules;
+ protected:
+ BtRemovePageTreeModel *m_model;
+ QTreeView *m_view;
+ QPushButton *m_removeButton;
};
#endif
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
new file mode 100644
index 0000000..fe566d1
--- /dev/null
+++ b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
@@ -0,0 +1,59 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/bookshelfmanager/removepage/btremovepagetreemodel.h"
+
+
+BtRemovePageTreeModel::BtRemovePageTreeModel(QObject *parent)
+ : BtBookshelfTreeModel(parent) {
+ setCheckable(true);
+ setDefaultChecked(BtBookshelfTreeModel::UNCHECKED);
+}
+
+int BtRemovePageTreeModel::columnCount(const QModelIndex &parent) const {
+ Q_UNUSED(parent);
+
+ return 2;
+}
+
+QVariant BtRemovePageTreeModel::data(const QModelIndex &i, int role) const {
+ if (i.column() == 1) {
+ QModelIndex realIndex(index(i.row(), 0, i.parent()));
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::ToolTipRole:
+ return BtBookshelfTreeModel::data(realIndex, BtBookshelfModel::ModuleInstallPathRole);
+ default:
+ break;
+ }
+ }
+ else {
+ return BtBookshelfTreeModel::data(i, role);
+ }
+
+ return QVariant();
+}
+
+QVariant BtRemovePageTreeModel::headerData(int section,
+ Qt::Orientation orientation,
+ int role) const {
+ if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
+ if (section == 0) {
+ return tr("Work");
+ }
+ else if (section == 1) {
+ return tr("Install path");
+ }
+ }
+
+ return QVariant();
+}
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
new file mode 100644
index 0000000..619a1ff
--- /dev/null
+++ b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
@@ -0,0 +1,30 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTREMOVEPAGETREEMODEL_H
+#define BTREMOVEPAGETREEMODEL_H
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+
+class BtRemovePageTreeModel: public BtBookshelfTreeModel {
+ Q_OBJECT
+
+ public:
+ BtRemovePageTreeModel(QObject *parent = 0);
+
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+};
+
+#endif // BTREMOVEPAGETREEMODEL_H