summaryrefslogtreecommitdiff
path: root/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/bookshelfmanager/installpage/btinstallpage.cpp')
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp69
1 files changed, 37 insertions, 32 deletions
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
index 9c7955a..5f8bfb8 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,12 +16,12 @@
#include <QHeaderView>
#include <QLabel>
#include <QPushButton>
-#include <QSettings>
#include <QSharedPointer>
#include <QStackedLayout>
#include <QToolButton>
-#include "backend/config/cbtconfig.h"
+#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"
@@ -29,9 +29,10 @@
#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/dialogutil.h"
#include "util/directory.h"
+#include "util/geticon.h"
#include "util/tool.h"
@@ -39,6 +40,7 @@ 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
@@ -47,13 +49,13 @@ const QString selectedModuleKey("GUI/BookshelfManager/InstallPage/selectedModule
// *********************************************************
BtInstallPage::BtInstallPage(BtModuleManagerDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::installpage::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::bookshelfmgr::installpage::icon), parent)
, m_groupingOrder(groupingOrderKey)
, m_modulesSelected(0)
, m_modulesSelectedSources(0)
{
// Read settings:
- m_headerState = CBTConfig::getConfig()->value(headerStateKey).toByteArray();
+ m_headerState = btConfig().value<QByteArray>(headerStateKey, QByteArray());
// Initialize widgets:
initView();
@@ -71,8 +73,6 @@ QString BtInstallPage::selectedInstallPath() {
}
void BtInstallPage::initView() {
- namespace DU = util::directory;
-
// Warning label:
m_warningLabel = new QLabel(this);
@@ -85,10 +85,10 @@ void BtInstallPage::initView() {
initSourcesCombo();
m_sourceAddButton = new QPushButton(this);
- m_sourceAddButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
+ m_sourceAddButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
m_sourceDeleteButton = new QPushButton(this);
- m_sourceDeleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
+ m_sourceDeleteButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
QHBoxLayout *sourceChooserLayout = new QHBoxLayout();
sourceChooserLayout->setContentsMargins(0, 8, 0, 0);
@@ -119,10 +119,10 @@ void BtInstallPage::initView() {
initPathCombo();
m_configurePathButton = new QToolButton(this);
- m_configurePathButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
+ m_configurePathButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
m_installButton = new QPushButton(this);
- m_installButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
+ m_installButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
m_installButton->setEnabled(false);
QHBoxLayout *pathLayout = new QHBoxLayout();
@@ -175,7 +175,7 @@ void BtInstallPage::initPathCombo() {
}
// choose the current value from config but check whether we have so many items
- int configValue = CBTConfig::get(CBTConfig::installPathIndex);
+ int configValue = btConfig().value<int>(installPathKey, 0);
int index = configValue > (m_pathCombo->count() - 1) ? m_pathCombo->count() - 1 : configValue;
m_pathCombo->setCurrentIndex(index);
}
@@ -202,7 +202,7 @@ void BtInstallPage::initSourcesCombo() {
}
// Read selected module from config:
- QString selected = CBTConfig::getConfig()->value(selectedModuleKey).toString();
+ const QString selected = btConfig().value<QString>(selectedModuleKey, QString());
// Populate combo box
bool selectionOk = false;
@@ -219,7 +219,7 @@ void BtInstallPage::initSourcesCombo() {
// Set selection, if it wasn't properly configured:
if (!selectionOk) {
m_sourceComboBox->setCurrentIndex(0);
- CBTConfig::getConfig()->setValue(selectedModuleKey, sourceList.at(0));
+ btConfig().setValue(selectedModuleKey, sourceList.at(0));
}
}
@@ -268,7 +268,7 @@ void BtInstallPage::retranslateUi() {
m_sourceGroupBox->setTitle(tr("Select installation &source:"));
m_sourceAddButton->setText(tr("&Add..."));
- m_sourceAddButton ->setToolTip(tr("Add new source"));
+ m_sourceAddButton->setToolTip(tr("Add new source"));
m_sourceDeleteButton->setText(tr("&Delete..."));
m_sourceDeleteButton->setToolTip(tr("Delete this source"));
@@ -293,7 +293,7 @@ void BtInstallPage::slotHeaderChanged() {
Q_ASSERT(qobject_cast<IPWW*>(m_worksLayout->currentWidget()) != 0);
IPWW *w = static_cast<IPWW*>(m_worksLayout->currentWidget());
m_headerState = w->treeView()->header()->saveState();
- CBTConfig::getConfig()->setValue(headerStateKey, m_headerState);
+ btConfig().setValue(headerStateKey, m_headerState);
}
void BtInstallPage::slotInstall() {
@@ -310,7 +310,7 @@ void BtInstallPage::slotInstall() {
canWrite = false;
}
if (!canWrite) {
- const int result = util::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);
+ 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;
}
@@ -327,22 +327,17 @@ void BtInstallPage::slotInstall() {
}
if (dlg->exec() == QDialog::Accepted) {
- QSet<const CSwordModuleInfo*> cm;
- Q_FOREACH(const CSwordModuleInfo *m, dlg->checkedModules()) {
- cm.insert(m);
- }
-
- if (cm.empty())
+ 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
- BtInstallProgressDialog *progressDialog = new BtInstallProgressDialog(cm, selectedInstallPath(), this);
-
+ 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();
@@ -351,7 +346,7 @@ void BtInstallPage::slotInstall() {
}
void BtInstallPage::slotPathChanged(const QString& /*pathText*/) {
- CBTConfig::set(CBTConfig::installPathIndex, m_pathCombo->currentIndex( ) );
+ btConfig().setValue(installPathKey, m_pathCombo->currentIndex());
}
void BtInstallPage::slotEditPaths() {
@@ -390,26 +385,35 @@ void BtInstallPage::slotSourceAdd() {
void BtInstallPage::slotSourceDelete() {
typedef BtInstallPageWorksWidget IPWW;
- int ret = util::showWarning(this, tr("Delete Source?"),
+ 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) index = 0;
+ if (index < 0) {
+ if(!m_sourceComboBox->count())
+ return;
+ index = 0;
+ }
/// \todo use pointers instead of text
QString moduleName = m_sourceComboBox->itemText(index);
- CBTConfig::getConfig()->setValue(selectedModuleKey, moduleName);
+ btConfig().setValue(selectedModuleKey, moduleName);
activateSource(BtInstallBackend::source(moduleName));
}
@@ -431,9 +435,10 @@ void BtInstallPage::slotSelectedModulesChanged() {
void BtInstallPage::slotSwordSetupChanged() {
QString moduleName = m_sourceComboBox->currentText();
- initSourcesCombo();
+ // 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;