summaryrefslogtreecommitdiff
path: root/src/frontend/bookshelfmanager/installpage
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/bookshelfmanager/installpage')
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp83
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h55
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp129
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h43
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp447
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.h101
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp83
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h32
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp118
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h57
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp236
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h51
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp163
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h69
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp53
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h40
16 files changed, 0 insertions, 1760 deletions
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
deleted file mode 100644
index a689c05..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License
-* version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
-
-#include <QAction>
-#include <QHeaderView>
-#include <QToolButton>
-#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
-#include "frontend/btbookshelfview.h"
-#include "util/tool.h"
-
-
-namespace {
-const QString groupingOrderKey("GUI/BookshelfManager/InstallConfirmDialog/grouping");
-}
-
-BtInstallModuleChooserDialog::BtInstallModuleChooserDialog(const BtBookshelfTreeModel::Grouping &g,
- QWidget *parent,
- Qt::WindowFlags flags)
- : BtModuleChooserDialog(parent, flags), m_shown(false)
-{
- resize(550, 340);
-
- // Read grouping order from settings or the default from argument:
- BtBookshelfTreeModel::Grouping groupingOrder(false);
- if (!groupingOrder.loadFrom(groupingOrderKey)) {
- groupingOrder = g;
- }
-
- BtInstallModuleChooserDialogModel *treeModel;
- treeModel = new BtInstallModuleChooserDialogModel(groupingOrder, this);
- connect(treeModel, SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
- this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
-
- m_bookshelfModel = new BtBookshelfModel(this);
- bookshelfWidget()->postFilterModel()->setShowShown(true);
- bookshelfWidget()->setTreeModel(treeModel);
- bookshelfWidget()->setSourceModel(m_bookshelfModel);
- bookshelfWidget()->showHideAction()->setVisible(false);
- bookshelfWidget()->showHideButton()->hide();
- bookshelfWidget()->treeView()->header()->show();
-
- retranslateUi();
-}
-
-void BtInstallModuleChooserDialog::addModuleItem(CSwordModuleInfo *module,
- const QString &sourceName)
-{
- module->setProperty("installSourceName", sourceName);
- m_bookshelfModel->addModule(module);
-}
-
-void BtInstallModuleChooserDialog::retranslateUi() {
- setWindowTitle(tr("Install/Update works?"));
- util::tool::initExplanationLabel(
- label(), QString::null,
- tr("Do you really want to install these works?") + "<br/><br/><small>" +
- tr("Only one version of a work can be installed at the same time. Select only "
- "one if there are items marked with red.") + "</small>");
-}
-
-void BtInstallModuleChooserDialog::showEvent(QShowEvent *event) {
- Q_UNUSED(event);
-
- if (m_shown) return;
- bookshelfWidget()->treeView()->expandAll();
- bookshelfWidget()->treeView()->header()->resizeSections(QHeaderView::ResizeToContents);
- m_shown = true;
-}
-
-void BtInstallModuleChooserDialog::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
- g.saveTo(groupingOrderKey);
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
deleted file mode 100644
index 49f1978..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License
-* version 2.0.
-*
-**********/
-
-#ifndef BTINSTALLMODULECHOOSERDIALOG_H
-#define BTINSTALLMODULECHOOSERDIALOG_H
-
-#include "frontend/btmodulechooserdialog.h"
-
-#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h"
-
-
-class BtBookshelfModel;
-class BtInstallModuleChooserDialogModel;
-class CSwordModuleInfo;
-
-/**
-* Confirmation dialog for installation. Lets the user
-* uncheck modules from the list.
-*/
-class BtInstallModuleChooserDialog: public BtModuleChooserDialog {
- Q_OBJECT
- public:
- BtInstallModuleChooserDialog(const BtBookshelfTreeModel::Grouping &g,
- QWidget *parent = 0,
- Qt::WindowFlags flags = 0);
-
- inline const QSet<CSwordModuleInfo*> &checkedModules() const {
- return bookshelfWidget()->treeModel()->checkedModules();
- }
-
- void addModuleItem(CSwordModuleInfo *module, const QString &sourceName);
-
- protected:
- void retranslateUi();
- void showEvent(QShowEvent *event);
-
- protected slots:
- void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g);
-
- private:
- BtBookshelfModel *m_bookshelfModel;
-
- bool m_shown;
-};
-
-#endif // BTINSTALLMODULECHOOSERDIALOG_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
deleted file mode 100644
index 6f0fc9b..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License
-* version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h"
-
-#include <QBrush>
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-
-
-#define MODULEPOINTERFORINDEX(i) static_cast<CSwordModuleInfo *>(\
- BtBookshelfTreeModel::data((i), BtBookshelfModel::ModulePointerRole).value<void*>())
-
-BtInstallModuleChooserDialogModel::BtInstallModuleChooserDialogModel(
- const Grouping &grouping,
- QObject *parent)
- : BtBookshelfTreeModel(grouping, parent), m_dataChangedFired(false)
-{
- setDefaultChecked(BtBookshelfTreeModel::CHECKED);
- setCheckable(true);
- connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
- this, SLOT(parentDataChanged(QModelIndex,QModelIndex)),
- Qt::DirectConnection);
-}
-
-QVariant BtInstallModuleChooserDialogModel::data(const QModelIndex &i, int role) const {
- switch (role) {
- case Qt::BackgroundRole:
- if (isMulti(i)) return QBrush(Qt::red);
- return BtBookshelfTreeModel::data(i, role);
- case Qt::ForegroundRole:
- if (isMulti(i)) return QBrush(Qt::white);
- return BtBookshelfTreeModel::data(i, role);
- case Qt::DisplayRole:
- switch (i.column()) {
- case 0:
- return BtBookshelfTreeModel::data(i, role);
- case 1:
- {
- CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
- if (module != 0) return module->property("installSourceName");
- break;
- }
- case 2:
- {
- CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
- if (module == 0) break;
- CSwordBackend *b = CSwordBackend::instance();
- CSwordModuleInfo *imodule = b->findModuleByName(module->name());
- if (imodule == 0) {
- return module->config(CSwordModuleInfo::ModuleVersion);
- } else {
- return imodule->config(CSwordModuleInfo::ModuleVersion)
- + " => "
- + module->config(CSwordModuleInfo::ModuleVersion);
- }
- }
- default: break;
- }
- default:
- if (i.column() == 0) return BtBookshelfTreeModel::data(i, role);
- }
-
- return QVariant();
-}
-
-int BtInstallModuleChooserDialogModel::columnCount(const QModelIndex &parent) const {
- Q_UNUSED(parent);
-
- return 3;
-}
-
-QVariant BtInstallModuleChooserDialogModel::headerData(int section,
- Qt::Orientation orientation,
- int role) const
-{
- if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
- switch (section) {
- case 0: return tr("Work");
- case 1: return tr("Installation source");
- case 2: return tr("Version");
- default: break;
- }
- }
-
- return QVariant();
-}
-
-void BtInstallModuleChooserDialogModel::parentDataChanged(const QModelIndex &topLeft,
- const QModelIndex &bottomRight)
-{
- Q_UNUSED(topLeft);
- Q_UNUSED(bottomRight);
-
- if (m_dataChangedFired) return;
- m_dataChangedFired = true;
- resetData();
- m_dataChangedFired = false;
-}
-
-bool BtInstallModuleChooserDialogModel::isMulti(CSwordModuleInfo * m1) const {
- if (m1 != 0 && checkedModules().contains(m1))
- Q_FOREACH (CSwordModuleInfo * m2, modules())
- if (m1 != m2 && checkedModules().contains(m2) && m1->name() == m2->name())
- return true;
- return false;
-}
-
-bool BtInstallModuleChooserDialogModel::isMulti(const QModelIndex &i) const {
- if (!i.isValid()) return false;
-
- if (!hasChildren(i)) {
- return isMulti(MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent())));
- } else {
- for (int row = 0; row < rowCount(i); row++) {
- if (isMulti(i.child(row, 0))) return true;
- }
- }
- return false;
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
deleted file mode 100644
index 406b89c..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License
-* version 2.0.
-*
-**********/
-
-#ifndef BTINSTALLMODULECHOOSERDIALOGMODEL_H
-#define BTINSTALLMODULECHOOSERDIALOGMODEL_H
-
-#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-
-#include <QMap>
-
-
-class BtInstallModuleChooserDialogModel: public BtBookshelfTreeModel {
- Q_OBJECT
- public:
- BtInstallModuleChooserDialogModel(const Grouping &grouping, QObject *parent = 0);
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
-
- private slots:
- void parentDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
-
- private:
- bool isMulti(CSwordModuleInfo *module) const;
- bool isMulti(const QModelIndex &index) const;
-
- private:
- QMap<QString, int> m_nameCounts;
- bool m_dataChangedFired;
-};
-
-#endif // BTINSTALLMODULECHOOSERDIALOGMODEL_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
deleted file mode 100644
index 5f8bfb8..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ /dev/null
@@ -1,447 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
-
-#include <QApplication>
-#include <QComboBox>
-#include <QGroupBox>
-#include <QHBoxLayout>
-#include <QHeaderView>
-#include <QLabel>
-#include <QPushButton>
-#include <QSharedPointer>
-#include <QStackedLayout>
-#include <QToolButton>
-#include "backend/config/btconfig.h"
-#include "backend/btinstallbackend.h"
-#include "bibletimeapp.h"
-#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
-#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
-#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
-#include "frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h"
-#include "frontend/bookshelfmanager/installpage/btinstallpathdialog.h"
-#include "frontend/bookshelfmanager/installpage/btinstallprogressdialog.h"
-#include "frontend/btbookshelfview.h"
-#include "frontend/messagedialog.h"
-#include "util/cresmgr.h"
-#include "util/directory.h"
-#include "util/geticon.h"
-#include "util/tool.h"
-
-
-namespace {
-const QString groupingOrderKey ("GUI/BookshelfManager/InstallPage/grouping");
-const QString headerStateKey ("GUI/BookshelfManager/InstallPage/headerState");
-const QString selectedModuleKey("GUI/BookshelfManager/InstallPage/selectedModule");
-const QString installPathKey ("GUI/BookshelfManager/InstallPage/installPathIndex");
-} // anonymous namespace
-
-
-// *********************************************************
-// *********** Config dialog page: Install/Update **********
-// *********************************************************
-
-BtInstallPage::BtInstallPage(BtModuleManagerDialog *parent)
- : BtConfigDialog::Page(util::getIcon(CResMgr::bookshelfmgr::installpage::icon), parent)
- , m_groupingOrder(groupingOrderKey)
- , m_modulesSelected(0)
- , m_modulesSelectedSources(0)
-{
- // Read settings:
- m_headerState = btConfig().value<QByteArray>(headerStateKey, QByteArray());
-
- // Initialize widgets:
- initView();
- initConnections();
-
- retranslateUi();
-}
-
-void BtInstallPage::setInstallEnabled(bool b) {
- m_installButton->setEnabled(b);
-}
-
-QString BtInstallPage::selectedInstallPath() {
- return m_pathCombo->currentText();
-}
-
-void BtInstallPage::initView() {
- // Warning label:
- m_warningLabel = new QLabel(this);
-
- // Source chooser:
- m_sourceGroupBox = new QGroupBox(this);
- m_sourceGroupBox->setFlat(true);
-
- m_sourceComboBox = new QComboBox(this);
- m_sourceComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
- initSourcesCombo();
-
- m_sourceAddButton = new QPushButton(this);
- m_sourceAddButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
-
- m_sourceDeleteButton = new QPushButton(this);
- m_sourceDeleteButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
-
- QHBoxLayout *sourceChooserLayout = new QHBoxLayout();
- sourceChooserLayout->setContentsMargins(0, 8, 0, 0);
- sourceChooserLayout->addWidget(m_sourceComboBox, 1);
- sourceChooserLayout->addWidget(m_sourceAddButton);
- sourceChooserLayout->addWidget(m_sourceDeleteButton);
- m_sourceGroupBox->setLayout(sourceChooserLayout);
-
- // Works chooser:
- m_worksGroupBox = new QGroupBox(this);
- m_worksGroupBox->setFlat(true);
- m_worksLayout = new QStackedLayout();
- m_worksGroupBox->setLayout(m_worksLayout);
- slotSourceIndexChanged(m_sourceComboBox->currentIndex());
-
- // Installation path chooser:
- m_installGroupBox = new QGroupBox(this);
- m_installGroupBox->setFlat(true);
- retranslateInstallGroupBox();
-
- m_pathLabel = new QLabel(this);
- m_pathCombo = new QComboBox(this);
- m_pathCombo->setMinimumContentsLength(20);
- m_pathCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
- m_pathCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
- m_pathCombo->view()->setTextElideMode(Qt::ElideMiddle);
- m_pathLabel->setBuddy(m_pathCombo);
- initPathCombo();
-
- m_configurePathButton = new QToolButton(this);
- m_configurePathButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
-
- m_installButton = new QPushButton(this);
- m_installButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
- m_installButton->setEnabled(false);
-
- QHBoxLayout *pathLayout = new QHBoxLayout();
- pathLayout->setContentsMargins(0, 8, 0, 0);
- pathLayout->addWidget(m_pathLabel);
- pathLayout->addWidget(m_pathCombo);
- pathLayout->addWidget(m_configurePathButton);
- pathLayout->addWidget(m_installButton);
- m_installGroupBox->setLayout(pathLayout);
-
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
- mainLayout->addWidget(m_warningLabel);
- mainLayout->addWidget(m_sourceGroupBox);
- mainLayout->addWidget(m_worksGroupBox, 1);
- mainLayout->addWidget(m_installGroupBox);
-}
-
-void BtInstallPage::initConnections() {
- connect(m_sourceComboBox, SIGNAL(currentIndexChanged(int)),
- this, SLOT(slotSourceIndexChanged(int)));
- connect(m_sourceAddButton, SIGNAL(clicked()),
- this, SLOT(slotSourceAdd()));
- connect(m_sourceDeleteButton, SIGNAL(clicked()),
- this, SLOT(slotSourceDelete()));
- connect(m_installButton, SIGNAL(clicked()),
- this, SLOT(slotInstall()));
- connect(m_pathCombo, SIGNAL(activated(const QString&)),
- this , SLOT(slotPathChanged(const QString&)));
- connect(m_configurePathButton, SIGNAL(clicked()),
- this, SLOT(slotEditPaths()));
- connect(CSwordBackend::instance(),
- SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)),
- this, SLOT(slotSwordSetupChanged()));
-}
-
-void BtInstallPage::initPathCombo() {
- //populate the combo list
- m_pathCombo->clear();
-
- QStringList targets = BtInstallBackend::targetList();
- for (QStringList::iterator it = targets.begin(); it != targets.end(); ++it) {
- // Add the path only if it's writable
- if ((*it).isEmpty()) continue;
- QDir dir(*it);
- if (!dir.exists()) continue;
- if (!dir.isReadable()) continue;
- QFileInfo fi( dir.canonicalPath());
- if (!fi.isWritable()) continue;
- m_pathCombo->addItem(util::directory::convertDirSeparators(*it));
- }
-
- // choose the current value from config but check whether we have so many items
- int configValue = btConfig().value<int>(installPathKey, 0);
- int index = configValue > (m_pathCombo->count() - 1) ? m_pathCombo->count() - 1 : configValue;
- m_pathCombo->setCurrentIndex(index);
-}
-
-void BtInstallPage::initSourcesCombo() {
- /// \todo Implement a proper model for this
-
- m_sourceComboBox->clear();
- QStringList sourceList = BtInstallBackend::sourceNameList();
-
- // Add a default entry, the Crosswire main repository
- if (sourceList.empty()) {
- /// \todo Open a dialog which asks whether to get list from server and add sources
- sword::InstallSource is("FTP"); //default return value
- is.caption = "CrossWire Bible Society";
- is.source = "ftp.crosswire.org";
- is.directory = "/pub/sword/raw";
- // passive ftp is not needed here, it's the default
-
- BtInstallBackend::addSource(is);
-
- sourceList = BtInstallBackend::sourceNameList();
- Q_ASSERT(!sourceList.empty());
- }
-
- // Read selected module from config:
- const QString selected = btConfig().value<QString>(selectedModuleKey, QString());
-
- // Populate combo box
- bool selectionOk = false;
- for (int i = 0; i < sourceList.size(); i++) {
- m_sourceComboBox->addItem(sourceList.at(i));
-
- // Select configured item:
- if (!selectionOk && sourceList.at(i) == selected) {
- m_sourceComboBox->setCurrentIndex(i);
- selectionOk = true;
- }
- }
-
- // Set selection, if it wasn't properly configured:
- if (!selectionOk) {
- m_sourceComboBox->setCurrentIndex(0);
- btConfig().setValue(selectedModuleKey, sourceList.at(0));
- }
-}
-
-void BtInstallPage::activateSource(const sword::InstallSource &src) {
- qApp->setOverrideCursor(Qt::WaitCursor);
- BtInstallPageWorksWidget *w = m_sourceMap.value(QString(src.caption), 0);
- if (w == 0) {
- window()->setEnabled(false);
- qApp->processEvents();
- w = new BtInstallPageWorksWidget(src, m_groupingOrder, this);
- m_sourceMap.insert(QString(src.caption), w);
- m_worksLayout->addWidget(w);
- connect(w->treeModel(), SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
- this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
- connect(w->treeModel(), SIGNAL(moduleChecked(CSwordModuleInfo*,bool)),
- this, SLOT(slotSelectedModulesChanged()));
- window()->setEnabled(true);
- } else {
- disconnect(w->treeView()->header(), SIGNAL(geometriesChanged()),
- this, SLOT(slotHeaderChanged()));
- }
- m_worksLayout->setCurrentWidget(w);
- w->treeModel()->setGroupingOrder(m_groupingOrder);
- w->treeView()->header()->restoreState(m_headerState);
- connect(w->treeView()->header(), SIGNAL(geometriesChanged()),
- this, SLOT(slotHeaderChanged()));
- qApp->restoreOverrideCursor();
-}
-
-void BtInstallPage::retranslateInstallGroupBox() {
- if (m_modulesSelected > 0) {
- m_installGroupBox->setTitle(tr("Start installation of %1 works from %2 sources:")
- .arg(m_modulesSelected)
- .arg(m_modulesSelectedSources));
- } else {
- m_installGroupBox->setTitle(tr("Start installation:"));
- }
-}
-
-void BtInstallPage::retranslateUi() {
- setHeaderText(tr("Install/Update"));
-
- util::tool::initExplanationLabel(m_warningLabel, tr("WARNING!!!"),
- tr("If you live in a persecuted country and don't want to risk "
- "detection don't use remote sources."));
-
- m_sourceGroupBox->setTitle(tr("Select installation &source:"));
- m_sourceAddButton->setText(tr("&Add..."));
- m_sourceAddButton->setToolTip(tr("Add new source"));
- m_sourceDeleteButton->setText(tr("&Delete..."));
- m_sourceDeleteButton->setToolTip(tr("Delete this source"));
-
- m_worksGroupBox->setTitle(tr("Select &works to install:"));
-
- m_pathLabel->setText(tr("Install &folder:"));
- m_pathCombo->setToolTip(tr("The folder where the new works will be installed"));
- m_configurePathButton->setToolTip(tr("Configure folders where works are installed and found"));
- m_installButton->setText(tr("&Install..."));
- m_installButton->setToolTip(tr("Install or update selected works"));
-
- retranslateInstallGroupBox();
-}
-
-void BtInstallPage::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
- m_groupingOrder = g;
- m_groupingOrder.saveTo(groupingOrderKey);
-}
-
-void BtInstallPage::slotHeaderChanged() {
- typedef BtInstallPageWorksWidget IPWW;
- Q_ASSERT(qobject_cast<IPWW*>(m_worksLayout->currentWidget()) != 0);
- IPWW *w = static_cast<IPWW*>(m_worksLayout->currentWidget());
- m_headerState = w->treeView()->header()->saveState();
- btConfig().setValue(headerStateKey, m_headerState);
-}
-
-void BtInstallPage::slotInstall() {
- // check that the destination path is writable, do nothing if not and user doesn't want to continue
- QDir dir = selectedInstallPath();
- bool canWrite = true;
- if (dir.isReadable()) {
- const QFileInfo fi( dir.canonicalPath() );
- if (!fi.exists() || !fi.isWritable()) {
- canWrite = false;
- }
- }
- else {
- canWrite = false;
- }
- if (!canWrite) {
- const int result = message::showWarning(this, tr("Warning"), tr("The destination directory is not writable or does not exist. Installation will fail unless this has first been fixed."), QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Cancel);
- if (result != QMessageBox::Ignore) {
- return;
- }
- }
-
- // create the confirmation dialog
- BtInstallModuleChooserDialog *dlg = new BtInstallModuleChooserDialog(m_groupingOrder, this);
-
- // Add all checked modules from all tabs:
- Q_FOREACH (BtInstallPageWorksWidget *w, m_sourceMap.values()) {
- Q_FOREACH (CSwordModuleInfo *module, w->treeModel()->checkedModules()) {
- dlg->addModuleItem(module, QString(w->installSource().caption));
- }
- }
-
- if (dlg->exec() == QDialog::Accepted) {
- QList<CSwordModuleInfo *> modules(dlg->checkedModules().toList());
- if (modules.empty())
- return;
-
- /// \todo first remove all modules which will be updated from the module list
- // but what modules? all with the same real name? (there may be _n modules...)
-
- // progressDialog is WA_DeleteOnClose
- typedef BtInstallProgressDialog BIPD;
- BIPD * const progressDialog = new BIPD(modules, selectedInstallPath(), this);
- m_installButton->setEnabled(false);
- // the progress dialog is now modal, it can be made modeless later.
- progressDialog->exec();
-
- }
- delete dlg;
-}
-
-void BtInstallPage::slotPathChanged(const QString& /*pathText*/) {
- btConfig().setValue(installPathKey, m_pathCombo->currentIndex());
-}
-
-void BtInstallPage::slotEditPaths() {
- BtInstallPathDialog* dlg = new BtInstallPathDialog();
- int result = dlg->exec();
- if (result == QDialog::Accepted) {
- //dynamic_cast<BtModuleManagerDialog*>(parentDialog())->slotSwordSetupChanged();
- CSwordBackend::instance()->reloadModules(CSwordBackend::PathChanged);
- }
-}
-
-void BtInstallPage::slotSourceAdd() {
- typedef CSwordSetupInstallSourcesDialog SSISD;
-
- QSharedPointer<SSISD> dlg(new SSISD());
- if (dlg->exec() == QDialog::Accepted) {
- if (dlg->wasRemoteListAdded()) {
- initSourcesCombo();
- }
- else {
- sword::InstallSource newSource = dlg->getSource();
- if ( !((QString)newSource.type.c_str()).isEmpty() ) { // we have a valid source to add
- BtInstallBackend::addSource(newSource);
- }
- initSourcesCombo();
- for (int i = 0; i < m_sourceComboBox->count(); i++) {
- if (m_sourceComboBox->itemText(i) == newSource.caption) {
- m_sourceComboBox->setCurrentIndex(i);
- break;
- }
- }
- }
- }
-}
-
-void BtInstallPage::slotSourceDelete() {
- typedef BtInstallPageWorksWidget IPWW;
-
- int ret = message::showWarning(this, tr("Delete Source?"),
- tr("Do you really want to delete this source?"),
- QMessageBox::Yes | QMessageBox::No);
-
- if (ret == QMessageBox::Yes) {
- qApp->setOverrideCursor(Qt::WaitCursor);
- window()->setEnabled(false);
- Q_ASSERT(qobject_cast<IPWW*>(m_worksLayout->currentWidget()));
- IPWW *w = static_cast<IPWW*>(m_worksLayout->currentWidget());
- m_sourceMap.remove(QString(w->installSource().caption));
- w->deleteSource();
- initSourcesCombo();
- slotSourceIndexChanged(m_sourceComboBox->currentIndex());
- delete w;
- window()->setEnabled(true);
- qApp->restoreOverrideCursor();
- }
-}
-
-void BtInstallPage::slotSourceIndexChanged(int index) {
- if (index < 0) {
- if(!m_sourceComboBox->count())
- return;
- index = 0;
- }
-
- /// \todo use pointers instead of text
- QString moduleName = m_sourceComboBox->itemText(index);
- btConfig().setValue(selectedModuleKey, moduleName);
- activateSource(BtInstallBackend::source(moduleName));
-}
-
-void BtInstallPage::slotSelectedModulesChanged() {
- m_modulesSelected = 0;
- m_modulesSelectedSources = 0;
- Q_FOREACH (BtInstallPageWorksWidget *w, m_sourceMap.values()) {
- int selected = w->treeModel()->checkedModules().size();
- if (selected > 0) {
- m_modulesSelectedSources++;
- m_modulesSelected += selected;
- }
- }
-
- m_installButton->setEnabled(m_modulesSelected > 0);
- retranslateInstallGroupBox();
-}
-
-void BtInstallPage::slotSwordSetupChanged() {
- QString moduleName = m_sourceComboBox->currentText();
-
- // clean m_sourceMap before initSourcesCombo() make too much work
- qDeleteAll(m_sourceMap.values());
- m_sourceMap.clear();
- initSourcesCombo();
- m_sourceComboBox->setCurrentIndex(m_sourceComboBox->findText(moduleName));
- initPathCombo();
- m_modulesSelected = 0;
- m_modulesSelectedSources = 0;
- retranslateInstallGroupBox();
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.h b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
deleted file mode 100644
index fe791cf..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTINSTALLPAGE_H
-#define BTINSTALLPAGE_H
-
-#include "frontend/bookshelfmanager/btconfigdialog.h"
-
-#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-
-
-namespace sword {
-class InstallSource;
-}
-
-class BtInstallPageWorksWidget;
-class BtModuleManagerDialog;
-class QComboBox;
-class QGroupBox;
-class QLabel;
-class QPushButton;
-class QStackedLayout;
-class QToolButton;
-
-/**
-* The Install page includes module path chooser, source/module handler and install button.
-*/
-class BtInstallPage: public BtConfigDialog::Page {
-
- Q_OBJECT
-
- public:
-
- BtInstallPage(BtModuleManagerDialog *parent = 0);
-
- void setInstallEnabled(bool b);
-
- QString selectedInstallPath();
-
- public slots:
- void slotSwordSetupChanged();
-
- protected:
-
- void retranslateUi();
-
- private:
- void initView();
- void initConnections();
- void initPathCombo();
- void initSourcesCombo();
-
- void activateSource(const sword::InstallSource &src);
- void retranslateInstallGroupBox();
-
- private slots:
- void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g);
- void slotHeaderChanged();
- void slotInstall();
- void slotPathChanged(const QString& pathText);
- void slotEditPaths();
- void slotSourceAdd();
- void slotSourceDelete();
- void slotSourceIndexChanged(int index);
- void slotSelectedModulesChanged();
-
- private:
- BtBookshelfTreeModel::Grouping m_groupingOrder;
- QByteArray m_headerState;
-
- QMap<QString, BtInstallPageWorksWidget*> m_sourceMap;
-
- QLabel *m_warningLabel;
-
- QGroupBox *m_sourceGroupBox;
- QComboBox *m_sourceComboBox;
- QPushButton *m_sourceAddButton;
- QPushButton *m_sourceDeleteButton;
-
- QGroupBox *m_worksGroupBox;
- QStackedLayout *m_worksLayout;
-
- QGroupBox *m_installGroupBox;
- QLabel *m_pathLabel;
- QComboBox *m_pathCombo;
- QToolButton *m_configurePathButton;
- QPushButton *m_installButton;
-
- unsigned m_modulesSelected;
- unsigned m_modulesSelectedSources;
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
deleted file mode 100644
index 06e97f8..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License
-* version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btinstallpagemodel.h"
-
-
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-
-
-#define MODULEPOINTERFORINDEX(i) static_cast<CSwordModuleInfo *>(\
- BtBookshelfTreeModel::data((i), BtBookshelfModel::ModulePointerRole).value<void*>())
-
-BtInstallPageModel::BtInstallPageModel(const Grouping &grouping, QObject *parent)
- : BtBookshelfTreeModel(grouping, parent)
-{
- setDefaultChecked(BtBookshelfTreeModel::UNCHECKED);
- setCheckable(true);
-}
-
-QVariant BtInstallPageModel::data(const QModelIndex &i, int role) const {
- switch (role) {
- case Qt::DisplayRole:
- switch (i.column()) {
- case 0:
- return BtBookshelfTreeModel::data(i, role);
- case 1:
- {
- CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
- if (module == 0) break;
- CSwordBackend *b = CSwordBackend::instance();
- CSwordModuleInfo *imodule = b->findModuleByName(module->name());
- if (imodule == 0) {
- return module->config(CSwordModuleInfo::ModuleVersion);
- } else {
- return imodule->config(CSwordModuleInfo::ModuleVersion)
- + " => "
- + module->config(CSwordModuleInfo::ModuleVersion);
- }
- }
- case 2:
- {
- CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
- if (module != 0) return module->config(CSwordModuleInfo::Description);
- }
- default: break;
- }
- default:
- if (i.column() == 0) return BtBookshelfTreeModel::data(i, role);
- }
-
- return QVariant();
-}
-
-int BtInstallPageModel::columnCount(const QModelIndex &parent) const {
- Q_UNUSED(parent);
-
- return 3;
-}
-
-QVariant BtInstallPageModel::headerData(int section, Qt::Orientation orientation,
- int role) const
-{
- if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
- switch (section) {
- case 0: return tr("Work");
- case 1: return tr("Version");
- case 2: return tr("Description");
- default: break;
- }
- }
-
- return QVariant();
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
deleted file mode 100644
index 009aa15..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License
-* version 2.0.
-*
-**********/
-
-#ifndef BTINSTALLPAGEMODEL_H
-#define BTINSTALLPAGEMODEL_H
-
-#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-
-#include <QMap>
-
-
-class BtInstallPageModel: public BtBookshelfTreeModel {
- Q_OBJECT
- public:
- BtInstallPageModel(const Grouping &grouping, QObject *parent = 0);
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
-};
-
-#endif // BTINSTALLPAGEMODEL_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
deleted file mode 100644
index 629a69c..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h"
-
-#include <QApplication>
-#include <QAction>
-#include <QDebug>
-#include <QTimer>
-#include <QToolButton>
-#include "backend/btinstallbackend.h"
-#include "backend/managers/cswordbackend.h"
-#include "bibletimeapp.h"
-#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
-#include "frontend/bookshelfmanager/installpage/btinstallpagemodel.h"
-#include "frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h"
-#include "frontend/btbookshelfview.h"
-#include "util/cresmgr.h"
-#include "util/geticon.h"
-
-
-namespace {
-
-/** Filters out already installed modules which can't be updated right now. */
-bool filter(CSwordModuleInfo *mInfo) {
- typedef CSwordModuleInfo CSMI;
- typedef sword::SWVersion SV;
-
- const CSMI *installedModule = CSwordBackend::instance()->findModuleByName(mInfo->name());
- if (installedModule) {
- // Already installed, check if it's an update:
- const SV curVersion(installedModule->config(CSMI::ModuleVersion).toLatin1());
- const SV newVersion(mInfo->config(CSMI::ModuleVersion).toLatin1());
- if (curVersion >= newVersion) {
- return false;
- }
- }
- return true;
-}
-
-}
-
-BtInstallPageWorksWidget::BtInstallPageWorksWidget(
- const sword::InstallSource &source,
- const BtBookshelfTreeModel::Grouping &g,
- BtInstallPage *parent, Qt::WindowFlags flags)
- : BtBookshelfWidget(parent, flags)
- , m_source(source)
- , m_parent(parent)
- , m_backend(0)
- , m_myModel(0)
-{
-
- setTreeModel(new BtInstallPageModel(g, this));
-
- treeView()->setHeaderHidden(false);
- showHideButton()->hide();
- showHideAction()->setVisible(false);
-
- m_sourceRefreshButton = new QToolButton(this);
- m_sourceRefreshButton->setAutoRaise(true);
- m_sourceRefreshButton->setToolTip(tr("Refresh the list of works from this source"));
- m_sourceRefreshButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon));
- setRightCornerWidget(m_sourceRefreshButton);
-
- connect(m_sourceRefreshButton, SIGNAL(clicked()),
- this, SLOT(slotSourceRefresh()));
-
- m_backend = BtInstallBackend::backend(m_source);
- Q_ASSERT(m_backend != 0);
- m_myModel = new BtBookshelfModel(this);
- Q_FOREACH(CSwordModuleInfo *module, m_backend->moduleList()) {
- if (filter(module)) m_myModel->addModule(module);
- }
- setSourceModel(m_myModel);
-}
-
-BtInstallPageWorksWidget::~BtInstallPageWorksWidget() {
- delete m_backend;
-}
-
-void BtInstallPageWorksWidget::deleteSource() {
- qDebug() << "Deleting source" << m_source.caption;
-
- m_myModel->clear();
- BtInstallBackend::deleteSource(QString(m_source.caption));
-}
-
-void BtInstallPageWorksWidget::updateTree() {
- qDebug() << "Updating BtInstallPageWorksWidget tree for source" << m_source.caption;
-
- m_myModel->clear();
-
- // Is this necessary?
- m_source = BtInstallBackend::source(QString(m_source.caption));
- m_backend = BtInstallBackend::backend(m_source);
-
- // Repopulate model:
- Q_FOREACH(CSwordModuleInfo *module, m_backend->moduleList()) {
- if (filter(module)) m_myModel->addModule(module);
- }
-}
-
-void BtInstallPageWorksWidget::slotSourceRefresh() {
- qDebug() << "Refreshing source" << m_source.caption;
-
- if (BtInstallBackend::isRemote(m_source)) {
- BtRefreshProgressDialog d(m_source, this);
- if (!d.runAndDelete()) return;
- }
- updateTree();
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
deleted file mode 100644
index d02e99e..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTINSTALLPAGEWORKSWIDGET_H
-#define BTINSTALLPAGEWORKSWIDGET_H
-
-
-#include "frontend/btbookshelfwidget.h"
-
-// Sword includes
-#include <installmgr.h>
-
-
-class BtInstallPage;
-
-class BtInstallPageWorksWidget: public BtBookshelfWidget {
- Q_OBJECT
-
- public: /* Methods: */
-
- BtInstallPageWorksWidget(const sword::InstallSource &source,
- const BtBookshelfTreeModel::Grouping &g,
- BtInstallPage *parent, Qt::WindowFlags f = 0);
-
- ~BtInstallPageWorksWidget();
-
- inline const sword::InstallSource &installSource() const {
- return m_source;
- }
- void deleteSource();
-
- private: /* Methods: */
-
- void updateTree();
-
- private slots:
-
- void slotSourceRefresh();
-
- private: /* Fields: */
-
- sword::InstallSource m_source;
- BtInstallPage *m_parent;
- QToolButton *m_sourceRefreshButton;
- CSwordBackend *m_backend;
- BtBookshelfModel *m_myModel;
-};
-
-#endif // BTINSTALLPAGEWORKSWIDGET_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
deleted file mode 100644
index 109bbd9..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btinstallpathdialog.h"
-
-#include <QDebug>
-#include <QDialog>
-#include <QDialogButtonBox>
-#include <QDir>
-#include <QFileDialog>
-#include <QGridLayout>
-#include <QLabel>
-#include <QPushButton>
-#include <QString>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include "backend/btinstallbackend.h"
-#include "bibletimeapp.h"
-#include "frontend/messagedialog.h"
-#include "util/directory.h"
-#include "util/cresmgr.h"
-#include "util/geticon.h"
-#include "util/tool.h"
-
-
-BtInstallPathDialog::BtInstallPathDialog() {
- namespace DU = util::directory;
-
- setWindowTitle(tr("Bookshelf Folders"));
-
- QVBoxLayout *mainLayout;
- QHBoxLayout *viewLayout;
-
- mainLayout = new QVBoxLayout(this);
- viewLayout = new QHBoxLayout();
-
- QString l1 = tr("Works can be installed in one or more folders. After setting up folders here you can choose one of them in Install page.");
- /// \bug The following string has an extra space character:
- QString l2 = tr("BibleTime and the SWORD library find the works from all of these folders. If a folder is removed here it still exists in the system with all the works in it.");
-
- QLabel* mainLabel = util::tool::explanationLabel(this,
- tr("Configure bookshelf folders"), l1 + QString("<small><br/><br/>") + l2 + QString("</small>"));
- mainLayout->addWidget(mainLabel);
-
- QString swordConfPath = BtInstallBackend::swordConfigFilename();
- /// \todo After releasing 2.4, change the following line to: QLabel *confPathLabel = new QLabel(tr("Configuration file for the folders is: <b>%1</b>").arg(swordConfPath), this);
- QLabel* confPathLabel = new QLabel(tr("Configuration file for the folders is: ").append("<b>%1</b>").arg(swordConfPath), this);
- confPathLabel->setWordWrap(true);
- mainLayout->addWidget(confPathLabel);
-
-
- m_swordPathListBox = new QTreeWidget(this);
- m_swordPathListBox->setHeaderHidden(true);
-
- QString rwfolderitem(tr("Folders where new works can be installed"));
- m_writableItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(rwfolderitem));;
- m_writableItem->setFlags(Qt::ItemIsEnabled);
- m_readableItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(tr("Read-only folders")));;
- m_readableItem->setFlags(Qt::ItemIsEnabled);
- m_nonexistingItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(tr("Nonexistent folders")));;
- m_nonexistingItem->setFlags(Qt::ItemIsEnabled);
-
- QStringList targets = BtInstallBackend::targetList();
-
- foreach (QString pathname, targets) {
- addPathToList(pathname);
- }
- updateTopLevelItems();
-
- viewLayout->addWidget(m_swordPathListBox);
-
- QVBoxLayout* buttonLayout = new QVBoxLayout();
-
- m_addButton = new QPushButton(tr("&Add..."), this);
- m_addButton->setToolTip(tr("Add new folder"));
- m_addButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::paths::add_icon));
- connect(m_addButton, SIGNAL(clicked()), this, SLOT(slotAddClicked()));
- buttonLayout->addWidget(m_addButton);
-
- m_editButton = new QPushButton(tr("&Edit..."), this);
- m_editButton->setToolTip(tr("Edit the selected folder"));
- m_editButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::paths::edit_icon));
- connect(m_editButton, SIGNAL(clicked()), this, SLOT(slotEditClicked()));
- buttonLayout->addWidget(m_editButton);
-
- m_removeButton = new QPushButton(tr("&Remove"), this);
- m_removeButton->setToolTip(tr("Remove the selected folder"));
- m_removeButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
- connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
- buttonLayout->addWidget(m_removeButton);
-
- QSpacerItem* spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
- buttonLayout->addItem(spacerItem);
-
- viewLayout->addLayout(buttonLayout);
- mainLayout->addLayout(viewLayout);
-
- QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
- buttonBox->setOrientation(Qt::Horizontal);
- buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok);
- message::prepareDialogBox(buttonBox);
- mainLayout->addWidget(buttonBox);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
- //clumsy way to set width. Could someone please fix Qt to have an easy way to set widget sizes?
- int textWidth = fontMetrics().width(rwfolderitem.append("MMMMMMMMMM"));
- int buttonWidth = m_addButton->width();
- resize(textWidth + buttonWidth, size().height());
-}
-
-BtInstallPathDialog::~BtInstallPathDialog() {
- m_swordPathListBox->invisibleRootItem()->takeChildren();
- delete m_readableItem;
- delete m_writableItem;
- delete m_nonexistingItem;
-}
-
-void BtInstallPathDialog::updateTopLevelItems() {
- if (m_writableItem->childCount()) {
- m_writableItem->setHidden(false);
- m_swordPathListBox->expandItem(m_writableItem);
- }
- else {
- m_writableItem->setHidden(true);
- }
- if (m_readableItem->childCount()) {
- m_readableItem->setHidden(false);
- m_swordPathListBox->expandItem(m_readableItem);
- }
- else {
- m_readableItem->setHidden(true);
- }
- if (m_nonexistingItem->childCount()) {
- m_nonexistingItem->setHidden(false);
- m_swordPathListBox->expandItem(m_nonexistingItem);
- }
- else {
- m_nonexistingItem->setHidden(true);
- }
-}
-
-
-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) );
- }
- }
- if (i && QDir(pathname) == BtInstallBackend::swordDir()) {
- i->setFlags(Qt::NoItemFlags);
- i->setToolTip(0, tr("This default folder in your home directory can't be removed"));
- }
-}
-
-void BtInstallPathDialog::slotEditClicked() {
- if (QTreeWidgetItem* i = m_swordPathListBox->currentItem()) {
- QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), i->text(0), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
-
- if (dirname.isEmpty()) { // if user cancelled the dialog
- return;
- }
- QDir dir = QDir(dirname);
- if (dir.isReadable()) {
- const QFileInfo fi( dir.canonicalPath() );
- if (!fi.exists() || !fi.isWritable()) {
- const int result = message::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you want to use this folder instead of the previous value?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
- if (result != QMessageBox::Yes) return;
- }
- //i->setText(0, dir.absolutePath()); // absolute, not canonical
- addPathToList(dir.absolutePath());
- delete i;
- updateTopLevelItems();
- }
- }
-}
-
-void BtInstallPathDialog::slotAddClicked() {
- QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
- if (dirname.isEmpty()) { // if user cancelled the dialog
- return;
- }
- QDir dir = QDir(dirname);
- if (dir.isReadable()) {
- const QFileInfo fi( dir.canonicalPath() );
- if (!fi.exists() || !fi.isWritable()) {
- const int result = message::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you still want to add it to the list of bookshelf folders?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
- if (result != QMessageBox::Yes) {
- return;
- }
- }
- addPathToList(util::directory::convertDirSeparators(dir.canonicalPath()));
- updateTopLevelItems();
- }
-}
-
-void BtInstallPathDialog::slotRemoveClicked() {
- QTreeWidgetItem* i = m_swordPathListBox->selectedItems().value(0);
- if (i && i->parent() != m_swordPathListBox->invisibleRootItem()) {
- delete i;
- }
- updateTopLevelItems();
-}
-
-void BtInstallPathDialog::writeSwordConfig() {
- QStringList targets;
- QTreeWidgetItemIterator it(m_swordPathListBox, QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Enabled | QTreeWidgetItemIterator::NotHidden);
- while (*it) {
- if (!(*it)->text(0).isEmpty()) {
- targets << (*it)->text(0);
- }
- ++it;
- }
- qDebug() << "save the target list" << targets;
- BtInstallBackend::setTargetList(targets); //creates new Sword config
-}
-
-void BtInstallPathDialog::accept() {
- writeSwordConfig();
- QDialog::accept();
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
deleted file mode 100644
index de4c69a..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTINSTALLPATHDIALOG_H
-#define BTINSTALLPATHDIALOG_H
-
-#include <QDialog>
-
-
-class QPushButton;
-class QTreeWidget;
-class QTreeWidgetItem;
-
-class BtInstallPathDialog : public QDialog {
- Q_OBJECT
- public:
- BtInstallPathDialog();
- ~BtInstallPathDialog();
-
- public slots:
- virtual void accept();
-
- private slots:
- void slotAddClicked();
- void slotRemoveClicked();
- void slotEditClicked();
-
- private:
- void writeSwordConfig();
- void updateTopLevelItems();
- void addPathToList(QString path);
-
- private:
- QPushButton* m_editButton;
- QPushButton* m_addButton;
- QPushButton* m_removeButton;
- QTreeWidget* m_swordPathListBox;
- QTreeWidgetItem* m_writableItem;
- QTreeWidgetItem* m_readableItem;
- QTreeWidgetItem* m_nonexistingItem;
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
deleted file mode 100644
index 53fd274..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btinstallprogressdialog.h"
-
-#include <QApplication>
-#include <QCloseEvent>
-#include <QDebug>
-#include <QDialog>
-#include <QHeaderView>
-#include <QMultiMap>
-#include <QProgressBar>
-#include <QPushButton>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include <QVBoxLayout>
-#include "backend/managers/cswordbackend.h"
-#include "backend/btinstallthread.h"
-
-
-BtInstallProgressDialog::BtInstallProgressDialog(const QList<CSwordModuleInfo *> & modules,
- const QString & destination,
- QWidget * parent,
- Qt::WindowFlags flags)
- : QDialog(parent, flags)
- , m_nextInstallIndex(0)
-{
- // we want this dialog to be deleted when user closes it or the downloads are completed
- setAttribute(Qt::WA_DeleteOnClose, true);
-
- setWindowTitle(tr("Install Progress"));
-
- m_statusWidget = new QTreeWidget();
- m_statusWidget->setRootIsDecorated(false);
- m_statusWidget->setHeaderLabels(QStringList(tr("Work")) << tr("Progress"));
- m_statusWidget->header()->setStretchLastSection(false);
-#if QT_VERSION < 0x050000
- m_statusWidget->header()->setResizeMode(1, QHeaderView::Stretch);
- m_statusWidget->header()->setMovable(false);
-#else
- m_statusWidget->header()->setSectionResizeMode(1, QHeaderView::Stretch);
- m_statusWidget->header()->setSectionsMovable(false);
-#endif
-
- Q_FOREACH(const CSwordModuleInfo * module, modules) {
- QTreeWidgetItem * progressItem = new QTreeWidgetItem(m_statusWidget);
- progressItem->setText(0, module->name());
- progressItem->setIcon(0, module->moduleIcon());
- progressItem->setText(1, tr("Waiting for turn..."));
- progressItem->setFlags(Qt::ItemIsEnabled);
- }
-
- m_statusWidget->setMinimumWidth(m_statusWidget->size().width());
- m_stopAllButton = new QPushButton(tr("Stop All"), this);
-
- QVBoxLayout * layout = new QVBoxLayout(this);
- layout->addWidget(m_statusWidget);
- layout->addWidget(m_stopAllButton);
-
- connect(m_stopAllButton, SIGNAL(clicked()),
- this, SLOT(slotStopInstall()));
-
- m_thread = new BtInstallThread(modules, destination, this);
- // Connect the signals between the dialog, items and threads
- connect(m_thread, SIGNAL(preparingInstall(int)),
- this, SLOT(slotInstallStarted(int)),
- Qt::QueuedConnection);
- connect(m_thread, SIGNAL(downloadStarted(int)),
- this, SLOT(slotDownloadStarted(int)),
- Qt::QueuedConnection);
- connect(m_thread, SIGNAL(statusUpdated(int, int)),
- this, SLOT(slotStatusUpdated(int, int)),
- Qt::QueuedConnection);
- connect(m_thread, SIGNAL(installCompleted(int, bool)),
- this, SLOT(slotOneItemCompleted(int, bool)),
- Qt::QueuedConnection);
- connect(m_thread, SIGNAL(finished()),
- this, SLOT(slotThreadFinished()),
- Qt::QueuedConnection);
- #if QT_VERSION < 0x050000
- connect(m_thread, SIGNAL(terminated()),
- this, SLOT(slotThreadFinished()),
- Qt::QueuedConnection);
- #endif
- m_thread->start();
-}
-
-BtInstallProgressDialog::~BtInstallProgressDialog() {
- m_thread->wait();
- delete m_thread;
-}
-
-void BtInstallProgressDialog::slotStopInstall() {
- m_stopAllButton->setDisabled(true);
- m_thread->stopInstall();
- for (int i = m_nextInstallIndex; i < m_statusWidget->topLevelItemCount(); i++) {
- QTreeWidgetItem * const item = m_statusWidget->topLevelItem(i);
- item->setText(1, QString::null);
- item->setDisabled(true);
- }
-}
-
-void BtInstallProgressDialog::slotInstallStarted(int moduleIndex) {
- Q_ASSERT(moduleIndex == m_nextInstallIndex);
- m_nextInstallIndex++;
- QTreeWidgetItem * const item = m_statusWidget->topLevelItem(moduleIndex);
- item->setText(1, tr("Preparing install..."));
- m_statusWidget->scrollToItem(item);
-}
-
-void BtInstallProgressDialog::slotDownloadStarted(int moduleIndex) {
- QTreeWidgetItem * const item = m_statusWidget->topLevelItem(moduleIndex);
- item->setText(1, QString::null);
- getOrCreateProgressBar(item)->setValue(0);
-}
-
-void BtInstallProgressDialog::slotStatusUpdated(int moduleIndex, int status) {
- // find the progress bar for this module and update the value
- getOrCreateProgressBar(moduleIndex)->setValue(status);
-}
-
-void BtInstallProgressDialog::slotOneItemCompleted(int moduleIndex, bool successful) {
-QTreeWidgetItem * const item = m_statusWidget->topLevelItem(moduleIndex);
- // update the list item
- m_statusWidget->setItemWidget(item, 1, NULL);
- item->setText(1, successful ? tr("Completed") : tr("Failed"));
- item->setDisabled(true);
-}
-
-void BtInstallProgressDialog::slotThreadFinished() {
- close();
-}
-
-void BtInstallProgressDialog::closeEvent(QCloseEvent * event) {
- if (event->spontaneous()) {
- event->ignore();
- slotStopInstall();
- return;
- }
- // other parts of the UI/engine must be updated
- CSwordBackend::instance()->reloadModules(CSwordBackend::AddedModules);
-}
-
-QProgressBar * BtInstallProgressDialog::getOrCreateProgressBar(int moduleIndex) {
- return getOrCreateProgressBar(m_statusWidget->topLevelItem(moduleIndex));
-}
-
-QProgressBar * BtInstallProgressDialog::getOrCreateProgressBar(QTreeWidgetItem * item) {
- QWidget * const itemWidget = m_statusWidget->itemWidget(item, 1);
- QProgressBar * progressBar = dynamic_cast<QProgressBar *>(itemWidget);
- if (!progressBar) {
- progressBar = new QProgressBar(m_statusWidget);
- progressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- m_statusWidget->setItemWidget(item, 1, progressBar);
- }
- return progressBar;
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
deleted file mode 100644
index e6add1c..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTINSTALLPROGRESSDIALOG_H
-#define BTINSTALLPROGRESSDIALOG_H
-
-#include <QDialog>
-
-#include <QString>
-
-
-class BtInstallThread;
-class CSwordModuleInfo;
-class QProgressBar;
-class QTreeWidget;
-class QTreeWidgetItem;
-
-class BtInstallProgressDialog: public QDialog {
-
- Q_OBJECT
-
-public: /* Methods: */
-
- BtInstallProgressDialog(const QList<CSwordModuleInfo *> & modules,
- const QString & destination,
- QWidget * parent = 0,
- Qt::WindowFlags flags = 0);
- ~BtInstallProgressDialog();
-
-public slots:
-
- void slotStopInstall();
- void slotInstallStarted(int moduleIndex);
- void slotDownloadStarted(int moduleIndex);
- void slotStatusUpdated(int moduleIndex, int status);
- void slotOneItemCompleted(int moduleIndex, bool status);
- void slotThreadFinished();
-
-protected: /* Methods: */
-
- /**
- Handles closing by the window close button, Cancel (Stop) All button, or
- completing the downloads.
- */
- virtual void closeEvent(QCloseEvent * event);
-
-private: /* Methods: */
-
- QProgressBar * getOrCreateProgressBar(int moduleIndex);
- QProgressBar * getOrCreateProgressBar(QTreeWidgetItem * item);
-
-private: /* Fields: */
-
- QTreeWidget * m_statusWidget;
- QPushButton * m_stopAllButton;
- BtInstallThread * m_thread;
- int m_nextInstallIndex;
-
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
deleted file mode 100644
index 856f58b..0000000
--- a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h"
-
-#include <QApplication>
-#include "backend/btinstallbackend.h"
-#include "frontend/messagedialog.h"
-
-
-BtRefreshProgressDialog::BtRefreshProgressDialog(sword::InstallSource &source,
- QWidget *parent,
- Qt::WindowFlags flags)
- : QProgressDialog(parent, flags)
- , m_source(source)
-{
- Q_ASSERT(BtInstallBackend::isRemote(source));
- setWindowTitle(tr("Refreshing source %1").arg(QString(source.caption)));
- setCancelButtonText(tr("&Cancel"));
- setLabelText(tr("Connecting..."));
- Q_ASSERT(minimum() == 0);
- setMaximum(100);
- setValue(0);
- setWindowModality(Qt::ApplicationModal);
- setMinimumDuration(1000);
-
- connect(this, SIGNAL(canceled()),
- this, SLOT(slotCanceled()));
- connect(&m_installMgr, SIGNAL(percentCompleted(int,int)),
- this, SLOT(slotPercentCompleted(int,int)));
-}
-
-void BtRefreshProgressDialog::slotPercentCompleted(int, int current) {
- setValue(current);
- qApp->processEvents();
-}
-
-void BtRefreshProgressDialog::slotCanceled() {
- m_installMgr.terminate();
-}
-
-bool BtRefreshProgressDialog::runAndDelete() {
- show();
- qApp->processEvents();
- bool r = (m_installMgr.refreshRemoteSource(&m_source) == 0);
- if (r) {
- setValue(100);
- qApp->processEvents();
- } else {
- message::showWarning(this, tr("Warning"),
- tr("Failed to refresh source %1")
- .arg(QString(m_source.caption)));
- }
- deleteLater();
- return r;
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
deleted file mode 100644
index 03f82c9..0000000
--- a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*********
-*
-* 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-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTREFRESHPROGRESSDIALOG_H
-#define BTREFRESHPROGRESSDIALOG_H
-
-#include <QProgressDialog>
-
-#include "backend/btinstallmgr.h"
-
-
-class BtRefreshProgressDialog: public QProgressDialog {
- Q_OBJECT
-
- public: /* Methods: */
- BtRefreshProgressDialog(sword::InstallSource &source,
- QWidget *parent = 0, Qt::WindowFlags f = 0);
-
- bool runAndDelete();
-
- private slots:
-
- void slotPercentCompleted(int, int);
- void slotCanceled();
-
- private: /* Fields: */
-
- sword::InstallSource m_source;
- BtInstallMgr m_installMgr;
-};
-
-#endif // BTREFRESHPROGRESSDIALOG_H