summaryrefslogtreecommitdiff
path: root/src/frontend/bookshelfmanager
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/bookshelfmanager')
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.cpp2
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.cpp76
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.h62
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp16
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp56
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h7
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp19
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.h4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp17
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h3
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp69
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.h4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp6
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h3
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp42
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h8
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp18
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp250
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h88
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.cpp185
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.h99
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h6
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.cpp23
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.h2
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp2
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h2
32 files changed, 303 insertions, 786 deletions
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.cpp b/src/frontend/bookshelfmanager/btconfigdialog.cpp
index 3b82560..e5d0fd1 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.cpp
+++ b/src/frontend/bookshelfmanager/btconfigdialog.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.
*
**********/
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.h b/src/frontend/bookshelfmanager/btconfigdialog.h
index e90c3ed..2525bd8 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.h
+++ b/src/frontend/bookshelfmanager/btconfigdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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-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.
*
**********/
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.cpp b/src/frontend/bookshelfmanager/btinstallmgr.cpp
deleted file mode 100644
index 652ff04..0000000
--- a/src/frontend/bookshelfmanager/btinstallmgr.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-
-#include "backend/managers/cswordbackend.h"
-#include "backend/btinstallbackend.h"
-#include <QList>
-#include <QObject>
-#include <QString>
-#include <QStringList>
-
-// Sword includes:
-#include <installmgr.h>
-#include <ftptrans.h>
-
-
-using namespace sword;
-
-BtInstallMgr::BtInstallMgr()
- : InstallMgr(BtInstallBackend::configPath().toLatin1(), this),
- m_totalBytes(1), m_completedBytes(0), m_firstCallOfPreStatus(true)
-{ //use this class also as status reporter
- this->setFTPPassive(true);
-}
-
-BtInstallMgr::~BtInstallMgr() {
- //doesn't really help because it only sets a flag
- terminate(); //make sure to close the connection
-}
-
-bool BtInstallMgr::isUserDisclaimerConfirmed() const {
- // \todo Check from config if it's been confirmed with "don't show this anymore" checked.
- // Create a dialog with the message, checkbox and Continue/Cancel, Cancel as default.
- return true;
-}
-
-void BtInstallMgr::statusUpdate(double dltotal, double dlnow) {
- if (dlnow > dltotal)
- dlnow = dltotal;
-
- int totalPercent = (int)((float)(dlnow + m_completedBytes) / (float)(m_totalBytes) * 100.0);
-
- if (totalPercent > 100) {
- totalPercent = 100;
- }
- else if (totalPercent < 0) {
- totalPercent = 0;
- }
-
- int filePercent = (int)((float)(dlnow) / (float)(dltotal + 1) * 100.0);
- if (filePercent > 100) {
- filePercent = 100;
- }
- else if (filePercent < 0) {
- filePercent = 0;
- }
- //qApp->processEvents();
- emit percentCompleted(totalPercent, filePercent);
-}
-
-
-void BtInstallMgr::preStatus(long totalBytes, long completedBytes, const char* message) {
- if (m_firstCallOfPreStatus) {
- m_firstCallOfPreStatus = false;
- emit downloadStarted();
- }
- m_completedBytes = completedBytes;
- m_totalBytes = (totalBytes > 0) ? totalBytes : 1; //avoid division by zero
-}
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.h b/src/frontend/bookshelfmanager/btinstallmgr.h
deleted file mode 100644
index 7d39440..0000000
--- a/src/frontend/bookshelfmanager/btinstallmgr.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef NEWBTINSTALLMGR_H
-#define NEWBTINSTALLMGR_H
-
-#include <QObject>
-
-#include <QList>
-#include <QString>
-#include <QStringList>
-
-// Sword includes:
-#include <installmgr.h>
-#include <ftptrans.h>
-
-
-/**
-* Our own reimplementation to provide installation and status bar updates.
-*/
-class BtInstallMgr : public QObject, public sword::InstallMgr, public sword::StatusReporter {
- Q_OBJECT
- public:
- BtInstallMgr();
- ~BtInstallMgr();
-
- /** Re-implemented from sword::InstallMgr. */
- bool isUserDisclaimerConfirmed() const;
-
- signals:
- /** Download status. Percent of total and file.*/
- void percentCompleted(const int total, const int file);
- void downloadStarted();
-
- protected:
- /**
- Reimplementation of sword::StatusReporter::statusUpdate().
- */
- void statusUpdate(double dltotal, double dlnow);
-
- /**
- * Reimplementation of sword::StatusReporter::preStatus().
- * \warning This method is not always called before statusUpdate().
- * Called before starting to download each file of the module package.
- * The sword message is not i18n'ed, it's in the form "Downloading (1 of 6): nt.bzs".
- * This function is not utilized in the UI ATM.
- */
- void preStatus(long totalBytes, long completedBytes, const char *message);
-
- private:
- long m_totalBytes;
- long m_completedBytes;
- bool m_firstCallOfPreStatus;
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
index 42febaa..8eebde6 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
@@ -2,20 +2,24 @@
*
* 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.
*
**********/
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cswordbackend.h"
#include "frontend/bookshelfmanager/indexpage/btindexpage.h"
#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
#include "frontend/bookshelfmanager/removepage/btremovepage.h"
+namespace {
+const QString GeometryKey = "GUI/BookshelfManager/ModuleManagerDialog/geometry";
+} // anonymous namespace
+
static BtModuleManagerDialog *m_staticModuleManagerDialog = 0;
BtModuleManagerDialog* BtModuleManagerDialog::getInstance(QWidget *parent,
@@ -59,13 +63,9 @@ BtModuleManagerDialog::~BtModuleManagerDialog() {
}
void BtModuleManagerDialog::loadDialogSettings() {
- resize(CBTConfig::get(CBTConfig::bookshelfWidth), CBTConfig::get(CBTConfig::bookshelfHeight));
- move(CBTConfig::get(CBTConfig::bookshelfPosX), CBTConfig::get(CBTConfig::bookshelfPosY));
+ restoreGeometry(btConfig().value<QByteArray>(GeometryKey, QByteArray()));
}
void BtModuleManagerDialog::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::bookshelfWidth, size().width());
- CBTConfig::set(CBTConfig::bookshelfHeight, size().height());
- CBTConfig::set(CBTConfig::bookshelfPosX, x());
- CBTConfig::set(CBTConfig::bookshelfPosY, y());
+ btConfig().setValue(GeometryKey, saveGeometry());
}
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
index 01ef594..4d94026 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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-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.
*
**********/
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
index f40d8c3..646efab 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.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.
*
**********/
@@ -25,10 +25,13 @@
#include <QProgressDialog>
#include <QApplication>
#include "backend/btinstallbackend.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
const QString PROTO_FILE( QObject::tr("Local") ); //Local path
-const QString PROTO_FTP( QObject::tr("Remote") ); //Remote path
+const QString PROTO_FTP( QObject::tr("Remote FTP") ); //Remote path
+const QString PROTO_SFTP( QObject::tr("Remote SFTP") );
+const QString PROTO_HTTP( QObject::tr("Remote HTTP") );
+const QString PROTO_HTTPS( QObject::tr("Remote HTTPS") );
CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *parent*/)
: QDialog(),
@@ -39,7 +42,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->setMargin( 10 );
mainLayout->setSpacing( 5 );
- QHBoxLayout *captionLayout = new QHBoxLayout( this );
+ QHBoxLayout *captionLayout = new QHBoxLayout;
mainLayout->addLayout(captionLayout);
QLabel *label = new QLabel( tr("Caption"), this );
captionLayout->addWidget( label );
@@ -50,7 +53,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
- QGridLayout* layout = new QGridLayout( this );
+ QGridLayout* layout = new QGridLayout;
layout->setSpacing(3);
layout->setMargin(3);
mainLayout->addLayout(layout);
@@ -68,6 +71,9 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
m_protocolCombo = new QComboBox( this );
layout->addWidget(m_protocolCombo, 1, 0);
m_protocolCombo->addItem( PROTO_FTP );
+ m_protocolCombo->addItem( PROTO_SFTP );
+ m_protocolCombo->addItem( PROTO_HTTP );
+ m_protocolCombo->addItem( PROTO_HTTPS);
m_protocolCombo->addItem( PROTO_FILE );
m_serverEdit = new QLineEdit( this );
@@ -81,7 +87,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save, Qt::Horizontal, this);
- util::prepareDialogBox(buttonBox);
+ message::prepareDialogBox(buttonBox);
QPushButton* getListButton = new QPushButton(tr("Get list..."), this);
getListButton->setToolTip(tr("Download a list of sources from CrossWire server and add sources"));
buttonBox->addButton(getListButton, QDialogButtonBox::ActionRole);
@@ -95,7 +101,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
void CSwordSetupInstallSourcesDialog::slotOk() {
//run a few tests to validate the input first
if ( m_captionEdit->text().trimmed().isEmpty() ) { //no caption
- util::showInformation( this, tr( "Error" ), tr("Please provide a caption."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a caption."));
return;
}
@@ -103,25 +109,25 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
//sword::InstallSource is = BTInstallMgr::Tool::RemoteConfig::source( &iMgr, m_captionEdit->text() );
sword::InstallSource is = BtInstallBackend::source(m_captionEdit->text());
if ( (QString)is.caption.c_str() == m_captionEdit->text() ) { //source already exists
- util::showInformation( this, tr( "Error" ),
+ message::showInformation( this, tr( "Error" ),
tr("A source with this caption already exists. Please provide a different caption."));
return;
}
- if ( m_protocolCombo->currentText() == PROTO_FTP &&
+ if ( this->isRemote(m_protocolCombo->currentText()) &&
m_serverEdit->text().trimmed().isEmpty() ) { //no server name
- util::showInformation( this, tr( "Error" ), tr("Please provide a server name."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a server name."));
return;
}
if ( m_protocolCombo->currentText() == PROTO_FILE) {
const QFileInfo fi( m_pathEdit->text() );
if (!fi.exists() || !fi.isReadable()) { //no valid and readable path
- util::showInformation( this, tr( "Error" ), tr("Please provide a valid, readable path."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a valid, readable path."));
return;
}
else if ( m_pathEdit->text().isEmpty() ) {
- util::showInformation( this, tr( "Error" ), tr("Please provide a path."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a path."));
}
}
@@ -130,7 +136,7 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
}
void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
- if (m_protocolCombo->currentText() == PROTO_FTP) { //REMOTE
+ if (this->isRemote(m_protocolCombo->currentText())) { //REMOTE
m_serverLabel->setEnabled(true);
m_serverEdit->setEnabled(true);
}
@@ -152,7 +158,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 = message::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::No) {
return;
}
@@ -206,9 +212,20 @@ void CSwordSetupInstallSourcesDialog::slotRefreshCanceled() {
sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
sword::InstallSource newSource(""); //empty, invalid Source
- if (m_protocolCombo->currentText() == PROTO_FTP) {
- newSource.type = "FTP";
- newSource.source = m_serverEdit->text().toUtf8();
+ if (this->isRemote(m_protocolCombo->currentText())) {
+ if (m_protocolCombo->currentText() == PROTO_FTP) {
+ newSource.type = "FTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_SFTP) {
+ newSource.type = "SFTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_HTTP) {
+ newSource.type = "HTTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_HTTPS) {
+ newSource.type = "HTTPS";
+ }
+ newSource.source = m_serverEdit->text().toUtf8();
//a message to the user would be nice, but we're in message freeze right now (1.5.1)
if (m_serverEdit->text().right(1) == "/") { //remove a trailing slash
newSource.source = m_serverEdit->text().mid(0, m_serverEdit->text().length() - 1).toUtf8();
@@ -225,4 +242,7 @@ sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
return newSource;
}
-
+bool CSwordSetupInstallSourcesDialog::isRemote(const QString& sourceType) {
+ return sourceType == PROTO_FTP || sourceType == PROTO_SFTP ||
+ sourceType == PROTO_HTTP || sourceType == PROTO_HTTPS;
+}
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
index e69e9a9..20bf461 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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-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.
*
**********/
@@ -12,7 +14,7 @@
#include <QDialog>
-#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "backend/btinstallmgr.h"
// Sword includes:
#include <installmgr.h>
@@ -41,6 +43,7 @@ class CSwordSetupInstallSourcesDialog : public QDialog {
void slotRefreshProgress(const int, const int current);
private:
+ bool isRemote(const QString&);
QLabel *m_serverLabel;
QLineEdit *m_captionEdit, *m_serverEdit, *m_pathEdit;
QComboBox *m_protocolCombo;
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index 960f5c8..b117f80 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-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,21 +16,20 @@
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QVBoxLayout>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
#include "frontend/btmoduleindexdialog.h"
-#include "util/directory.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
BtIndexPage::BtIndexPage(BtModuleManagerDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::indexpage::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::bookshelfmgr::indexpage::icon), parent)
{
- namespace DU = util::directory;
-
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
QHBoxLayout *hboxLayout;
@@ -60,11 +59,11 @@ BtIndexPage::BtIndexPage(BtModuleManagerDialog *parent)
//m_moduleList->setTextAlignment(1, Qt::AlignRight); see doc...
m_moduleList->setSortingEnabled(false);
- m_autoDeleteOrphanedIndicesBox->setChecked( CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) );
+ m_autoDeleteOrphanedIndicesBox->setChecked( btConfig().value<bool>("settings/behaviour/autoDeleteOrphanedIndices", true) );
// icons for our buttons
- m_createButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::indexpage::create_icon));
- m_deleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::indexpage::delete_icon));
+ m_createButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::indexpage::create_icon));
+ m_deleteButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::indexpage::delete_icon));
// connect our signals/slots
connect(m_createButton, SIGNAL(clicked()),
@@ -78,7 +77,7 @@ BtIndexPage::BtIndexPage(BtModuleManagerDialog *parent)
}
BtIndexPage::~BtIndexPage() {
- CBTConfig::set( CBTConfig::autoDeleteOrphanedIndices, m_autoDeleteOrphanedIndicesBox->isChecked() );
+ btConfig().setValue("settings/behaviour/autoDeleteOrphanedIndices", m_autoDeleteOrphanedIndicesBox->isChecked() );
}
/** Populates the module list with installed modules and orphaned indices */
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.h b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
index 303c6ab..100de17 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.h
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
@@ -1,8 +1,10 @@
/*********
*
+* 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-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.
*
**********/
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
index 01ca55b..a689c05 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
@@ -4,7 +4,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.
*
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
index 070df6f..49f1978 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
@@ -4,7 +4,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.
*
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
index 880ea6a..6f0fc9b 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
@@ -4,7 +4,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.
*
@@ -32,10 +32,6 @@ BtInstallModuleChooserDialogModel::BtInstallModuleChooserDialogModel(
Qt::DirectConnection);
}
-BtInstallModuleChooserDialogModel::~BtInstallModuleChooserDialogModel() {
- // Intentionally empty
-}
-
QVariant BtInstallModuleChooserDialogModel::data(const QModelIndex &i, int role) const {
switch (role) {
case Qt::BackgroundRole:
@@ -111,14 +107,11 @@ void BtInstallModuleChooserDialogModel::parentDataChanged(const QModelIndex &top
m_dataChangedFired = false;
}
-bool BtInstallModuleChooserDialogModel::isMulti(CSwordModuleInfo *m1) const {
- if (m1 != 0 && checkedModules().contains(m1)) {
- Q_FOREACH(CSwordModuleInfo *m2, m_modules.keys()) {
- if (m1 != m2 && checkedModules().contains(m2) && m1->name() == m2->name()) {
+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;
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
index 6120fa8..406b89c 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
@@ -4,7 +4,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.
*
@@ -22,7 +22,6 @@ class BtInstallModuleChooserDialogModel: public BtBookshelfTreeModel {
Q_OBJECT
public:
BtInstallModuleChooserDialogModel(const Grouping &grouping, QObject *parent = 0);
- ~BtInstallModuleChooserDialogModel();
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
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;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.h b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
index 0cb6724..fe791cf 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
@@ -1,8 +1,10 @@
/*********
*
+* 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-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.
*
**********/
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
index 9aa6743..06e97f8 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
@@ -4,7 +4,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.
*
@@ -27,10 +27,6 @@ BtInstallPageModel::BtInstallPageModel(const Grouping &grouping, QObject *parent
setCheckable(true);
}
-BtInstallPageModel::~BtInstallPageModel() {
- // Intentionally empty
-}
-
QVariant BtInstallPageModel::data(const QModelIndex &i, int role) const {
switch (role) {
case Qt::DisplayRole:
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
index 8a02409..009aa15 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
@@ -4,7 +4,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.
*
@@ -22,7 +22,6 @@ class BtInstallPageModel: public BtBookshelfTreeModel {
Q_OBJECT
public:
BtInstallPageModel(const Grouping &grouping, QObject *parent = 0);
- ~BtInstallPageModel();
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
index 0bb8829..629a69c 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.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,13 @@
#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/directory.h"
+#include "util/geticon.h"
namespace {
@@ -55,7 +56,6 @@ BtInstallPageWorksWidget::BtInstallPageWorksWidget(
, m_backend(0)
, m_myModel(0)
{
- namespace DU = util::directory;
setTreeModel(new BtInstallPageModel(g, this));
@@ -65,15 +65,20 @@ BtInstallPageWorksWidget::BtInstallPageWorksWidget(
m_sourceRefreshButton = new QToolButton(this);
m_sourceRefreshButton->setAutoRaise(true);
- m_sourceRefreshButton ->setToolTip(tr("Refresh the list of works from this source"));
- m_sourceRefreshButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon));
+ 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()));
- // Delayed init, part 1 - disable parent:
- parent->setEnabled(false);
+ 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() {
@@ -83,7 +88,6 @@ BtInstallPageWorksWidget::~BtInstallPageWorksWidget() {
void BtInstallPageWorksWidget::deleteSource() {
qDebug() << "Deleting source" << m_source.caption;
- setEnabled(false);
m_myModel->clear();
BtInstallBackend::deleteSource(QString(m_source.caption));
}
@@ -103,28 +107,6 @@ void BtInstallPageWorksWidget::updateTree() {
}
}
-void BtInstallPageWorksWidget::paintEvent(QPaintEvent *e) {
- // Delayed init, part 2 - queue init when painted:
- if (m_myModel == 0) {
- QTimer::singleShot(0, this, SLOT(slotDelayedInit()));
- }
- BtBookshelfWidget::paintEvent(e);
-}
-
-void BtInstallPageWorksWidget::slotDelayedInit() {
- // Delayed init, part 3 - initialize + reenable parent
- qApp->setOverrideCursor(Qt::WaitCursor);
- 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);
- m_parent->setEnabled(true);
- qApp->restoreOverrideCursor();
-}
-
void BtInstallPageWorksWidget::slotSourceRefresh() {
qDebug() << "Refreshing source" << m_source.caption;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
index 1a9bd8f..d02e99e 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
@@ -1,8 +1,10 @@
/*********
*
+* 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-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.
*
**********/
@@ -39,12 +41,8 @@ class BtInstallPageWorksWidget: public BtBookshelfWidget {
void updateTree();
- /** Reimplemented from QWidget. */
- virtual void paintEvent(QPaintEvent *e);
-
private slots:
- void slotDelayedInit();
void slotSourceRefresh();
private: /* Fields: */
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
index b4deb51..109bbd9 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.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.
*
**********/
@@ -21,9 +21,11 @@
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include "backend/btinstallbackend.h"
-#include "util/dialogutil.h"
+#include "bibletimeapp.h"
+#include "frontend/messagedialog.h"
#include "util/directory.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
@@ -77,19 +79,19 @@ BtInstallPathDialog::BtInstallPathDialog() {
m_addButton = new QPushButton(tr("&Add..."), this);
m_addButton->setToolTip(tr("Add new folder"));
- m_addButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::add_icon));
+ 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(DU::getIcon(CResMgr::bookshelfmgr::paths::edit_icon));
+ 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(DU::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
+ m_removeButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
buttonLayout->addWidget(m_removeButton);
@@ -102,7 +104,7 @@ BtInstallPathDialog::BtInstallPathDialog() {
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok);
- util::prepareDialogBox(buttonBox);
+ message::prepareDialogBox(buttonBox);
mainLayout->addWidget(buttonBox);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
@@ -177,7 +179,7 @@ void BtInstallPathDialog::slotEditClicked() {
if (dir.isReadable()) {
const QFileInfo fi( dir.canonicalPath() );
if (!fi.exists() || !fi.isWritable()) {
- const int result = util::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);
+ 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
@@ -197,7 +199,7 @@ void BtInstallPathDialog::slotAddClicked() {
if (dir.isReadable()) {
const QFileInfo fi( dir.canonicalPath() );
if (!fi.exists() || !fi.isWritable()) {
- const int result = util::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);
+ 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;
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
index 9adf6bc..de4c69a 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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-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.
*
**********/
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
index cc862fa..53fd274 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.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.
*
**********/
@@ -21,21 +21,24 @@
#include <QTreeWidgetItem>
#include <QVBoxLayout>
#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/installpage/btinstallthread.h"
+#include "backend/btinstallthread.h"
-BtInstallProgressDialog::BtInstallProgressDialog(
- const QSet<const CSwordModuleInfo*> &modules,
- const QString &destination, QWidget *parent, Qt::WindowFlags flags)
+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"));
- //create the dialog which shows the status and lets the user stop installation
+
m_statusWidget = new QTreeWidget();
m_statusWidget->setRootIsDecorated(false);
- m_statusWidget->setHeaderLabels(QStringList(tr("Work")) << tr("Progress") << QString::null);
+ m_statusWidget->setHeaderLabels(QStringList(tr("Work")) << tr("Progress"));
m_statusWidget->header()->setStretchLastSection(false);
#if QT_VERSION < 0x050000
m_statusWidget->header()->setResizeMode(1, QHeaderView::Stretch);
@@ -44,190 +47,117 @@ BtInstallProgressDialog::BtInstallProgressDialog(
m_statusWidget->header()->setSectionResizeMode(1, QHeaderView::Stretch);
m_statusWidget->header()->setSectionsMovable(false);
#endif
- //m_statusWidget->setColumnWidth(1, util::tool::mWidth(m_statusWidget, 2));
-
- Q_FOREACH(const CSwordModuleInfo *module, modules) {
- const QString sourceName(module->property("installSourceName").toString());
- // create a thread for this module
- BtInstallThread* thread = new BtInstallThread(module->name(), sourceName, destination);
- m_waitingThreads.insert(sourceName, thread);
- m_threadsByModule.insert(module->name(), thread);
- // progress widget/item
- QPushButton* stopButton = new QPushButton(tr("Stop"), m_statusWidget);
- stopButton->setFixedSize(stopButton->sizeHint());
-
- // the item
- QTreeWidgetItem* progressItem = new QTreeWidgetItem(m_statusWidget);
- m_statusWidget->setColumnWidth(2, stopButton->sizeHint().width());
- progressItem->setSizeHint(2, stopButton->sizeHint());
+
+ Q_FOREACH(const CSwordModuleInfo * module, modules) {
+ QTreeWidgetItem * progressItem = new QTreeWidgetItem(m_statusWidget);
progressItem->setText(0, module->name());
- progressItem->setFlags(Qt::ItemIsEnabled);
- m_statusWidget->setItemWidget(progressItem, 2, stopButton);
+ progressItem->setIcon(0, module->moduleIcon());
progressItem->setText(1, tr("Waiting for turn..."));
-
- //connect the signals between the dialog, items and threads
- QObject::connect(stopButton, SIGNAL(clicked()), thread, SLOT(slotStopInstall()), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(installStopped(QString, QString)), this, SLOT(slotOneItemStopped(QString, QString)), Qt::QueuedConnection);
- //is this needed or is statusUpdated enough?
- QObject::connect(thread, SIGNAL(installCompleted(QString, QString, int)), this, SLOT(slotOneItemCompleted(QString, QString, int)), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(statusUpdated(QString, int)), this, SLOT(slotStatusUpdated(QString, int)), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(downloadStarted(QString)), this, SLOT(slotDownloadStarted(QString)), Qt::QueuedConnection);
-
- QObject::connect(thread, SIGNAL(preparingInstall(QString, QString)), this, SLOT(slotInstallStarted(QString, QString)), Qt::QueuedConnection);
+ progressItem->setFlags(Qt::ItemIsEnabled);
}
m_statusWidget->setMinimumWidth(m_statusWidget->size().width());
- QPushButton* stopAllButton = new QPushButton(tr("Stop All"), this);
+ m_stopAllButton = new QPushButton(tr("Stop All"), this);
- QVBoxLayout* layout = new QVBoxLayout(this);
+ QVBoxLayout * layout = new QVBoxLayout(this);
layout->addWidget(m_statusWidget);
- layout->addWidget(stopAllButton);
-
- connect(stopAllButton, SIGNAL(clicked()), SLOT(slotStopInstall()) );
-
- qApp->processEvents();
-
- startThreads();
-
+ 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();
}
-void BtInstallProgressDialog::startThreads() {
- // remove all the updated modules from the backend module list at once
- //foreach (QString mName, m_threadsByModule.keys()) {
- //}
- //QList<CSwordModuleInfo*> CSwordBackend::instance()()->takeModulesFromList(m_threadsByModule.keys());
- //loop through the multimap of the waiting threads, start at most 3 threads for each source
- QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
-// concurrency is disabled for now
-// while (threadIterator != m_waitingThreads.end()) {
-// QString sourceName = threadIterator.key();
-// if (m_runningThreads.values(sourceName).count() < 3) {
-// BtInstallThread* t = threadIterator.value();
-// m_runningThreads.insert(sourceName, t);
-// threadIterator = m_waitingThreads.erase(threadIterator);
-// t->start();
-// }
-// else ++threadIterator;
-// }
- //non-concurrent
- if (threadIterator != m_waitingThreads.begin()) {
- // go to the last item which is actually the first in the visible list
- // because the iterator is reversed compared to insert order
- threadIterator--;
- QString sourceName = threadIterator.key();
- BtInstallThread* t = threadIterator.value();
- m_runningThreads.insert(sourceName, t);
- threadIterator = m_waitingThreads.erase(threadIterator);
- t->start();
- }
+BtInstallProgressDialog::~BtInstallProgressDialog() {
+ m_thread->wait();
+ delete m_thread;
}
-void BtInstallProgressDialog::slotOneItemCompleted(QString module, QString source, int status) {
- QString message;
- //status comes from the sword installer.
- /// \todo Additionally we should check that there are files really installed.
- if (status != 0) {
- message = tr("Failed");
- }
- else {
- message = tr("Completed");
+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);
}
- oneItemStoppedOrCompleted(module, source, message);
-}
-
-void BtInstallProgressDialog::slotOneItemStopped(QString module, QString source) {
- oneItemStoppedOrCompleted(module, source, tr("Cancelled"));
}
-void BtInstallProgressDialog::oneItemStoppedOrCompleted(QString module, QString source, QString statusMessage) {
- qDebug() << "\n**********************************\nBtInstallProgressDialog::oneItemStoppedOrCompleted" << module << statusMessage << "\n******************************************";
- // update the list item
- m_statusWidget->setItemWidget(getItem(module), 1, 0);
- getItem(module)->setText(1, statusMessage);
- m_statusWidget->itemWidget(getItem(module), 2)->setEnabled(false);
- getItem(module)->setDisabled(true);
-
- qDebug() << "remove from threads maps" << source << m_threadsByModule.value(module);
- m_runningThreads.remove(source, m_threadsByModule.value(module));
- m_waitingThreads.remove(source, m_threadsByModule.value(module));
-
-//concurrency is disabled for now
-// //start a waiting thread if there are any
-// QList<BtInstallThread*> threadsForSource = m_waitingThreads.values(source);
-// if (!threadsForSource.isEmpty()) {
-// BtInstallThread* thread = threadsForSource.at(0);
-// m_waitingThreads.remove(source, thread);
-// m_runningThreads.insert(source, thread);
-// thread->start();
-// }
-
- //non-concurrent
- QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
- if (m_runningThreads.isEmpty() && threadIterator != m_waitingThreads.begin()) {
- threadIterator--; // the last item
- QString sourceName = threadIterator.key();
- BtInstallThread* t = threadIterator.value();
- m_runningThreads.insert(sourceName, t);
- threadIterator = m_waitingThreads.erase(threadIterator);
- t->start();
- }
-
- if (threadsDone()) {
- qDebug() << "close the dialog";
- close();
- }
+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::slotStopInstall() {
- qDebug() << "BtInstallProgressDialog::slotStopInstall";
-
- // Clear the waiting threads map, stop all running threads.
-
- m_waitingThreads.clear();
- if (m_runningThreads.count() > 0) {
- foreach(BtInstallThread* thread, m_runningThreads) {
- thread->slotStopInstall();
- }
- }
- else {
- close();
- }
+void BtInstallProgressDialog::slotDownloadStarted(int moduleIndex) {
+ QTreeWidgetItem * const item = m_statusWidget->topLevelItem(moduleIndex);
+ item->setText(1, QString::null);
+ getOrCreateProgressBar(item)->setValue(0);
}
-void BtInstallProgressDialog::slotStatusUpdated(QString module, int status) {
+void BtInstallProgressDialog::slotStatusUpdated(int moduleIndex, int status) {
// find the progress bar for this module and update the value
- QWidget* itemWidget = m_statusWidget->itemWidget(getItem(module) , 1);
- QProgressBar* bar = dynamic_cast<QProgressBar*>(itemWidget);
- if (bar) bar->setValue(status);
-}
-
-void BtInstallProgressDialog::slotInstallStarted(QString module, QString) {
- getItem(module)->setText(1, tr("Preparing install..."));
+ getOrCreateProgressBar(moduleIndex)->setValue(status);
}
-void BtInstallProgressDialog::slotDownloadStarted(QString module) {
- getItem(module)->setText(1, QString::null);
- //m_statusWidget->itemWidget(getItem(module), 1)->setVisible(true);
-
- QProgressBar* bar = new QProgressBar(m_statusWidget);
- bar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- bar->setValue(0);
- m_statusWidget->setItemWidget(getItem(module), 1, bar);
+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);
}
-QTreeWidgetItem* BtInstallProgressDialog::getItem(QString moduleName) {
- return m_statusWidget->findItems(moduleName, Qt::MatchExactly).at(0);
+void BtInstallProgressDialog::slotThreadFinished() {
+ close();
}
-void BtInstallProgressDialog::closeEvent(QCloseEvent* event) {
+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);
}
-bool BtInstallProgressDialog::threadsDone() {
- return (m_waitingThreads.isEmpty() && m_runningThreads.isEmpty());
+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
index a72b280..e6add1c 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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-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.
*
**********/
@@ -12,56 +14,56 @@
#include <QDialog>
-#include <QMultiMap>
#include <QString>
class BtInstallThread;
class CSwordModuleInfo;
+class QProgressBar;
class QTreeWidget;
class QTreeWidgetItem;
-class BtInstallProgressDialog : public QDialog {
- Q_OBJECT
- public:
- BtInstallProgressDialog(const QSet<const CSwordModuleInfo*> &modules,
- const QString &destination, QWidget *parent = 0,
- Qt::WindowFlags flags = 0);
-
- public slots:
- void slotOneItemCompleted(QString module, QString source, int status);
- void slotOneItemStopped(QString module, QString source);
- void slotStopInstall();
- void slotStatusUpdated(QString module, int status);
- void slotDownloadStarted(QString module);
- void slotInstallStarted(QString module, QString);
-
- protected:
- /**
- * Handles closing by the window close button, Cancel (Stop) All button, or completing
- * the downloads.
- */
- virtual void closeEvent(QCloseEvent* event);
-
-//signals:
-// void swordSetupChanged();
-
- private:
-
- /// \todo using maps is tedious and error prone. Find better solution for handling the modules
- // and their states.
- QMultiMap<QString, BtInstallThread*> m_waitingThreads;
- QMultiMap<QString, BtInstallThread*> m_runningThreads;
- QMap<QString, BtInstallThread*> m_threadsByModule;
- //QList<BtInstallThread*> m_doneThreads;
-
- QTreeWidget* m_statusWidget;
-
- private:
- QTreeWidgetItem* getItem(QString moduleName);
- bool threadsDone();
- void startThreads();
- void oneItemStoppedOrCompleted(QString module, QString source, QString message);
+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/btinstallthread.cpp b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
deleted file mode 100644
index 3b25f02..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btinstallthread.h"
-
-#include <QApplication>
-#include <QDebug>
-#include <QDir>
-#include <QString>
-#include <QThread>
-#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "backend/btinstallbackend.h"
-
-// Sword includes:
-#include <filemgr.h>
-
-
-BtInstallThread::BtInstallThread(const QString &moduleName, const QString &sourceName,
- const QString &destinationName, QObject *parent)
- : QThread(parent),
- done(false),
- m_module(moduleName),
- m_destination(destinationName),
- m_source(sourceName),
- m_cancelled(false) {
- m_iMgr = new BtInstallMgr();
-}
-
-
-BtInstallThread::~BtInstallThread() {
- delete m_iMgr;
-}
-
-void BtInstallThread::run() {
- qDebug() << "****************************************\nBtInstallThread::run, mod:" << m_module << "\n************************************";
-
-
- emit preparingInstall(m_module, m_source);
- //This is 0 before set here - remember when using the value when cancelling
- // the installation before this has been run
- m_installSource = QSharedPointer<sword::InstallSource>(new sword::InstallSource(BtInstallBackend::source(m_source)));
- m_backendForSource = QSharedPointer<CSwordBackend>(BtInstallBackend::backend(*m_installSource));
-
- //make sure target/mods.d and target/modules exist
- /// \todo move this to some common precondition
- QDir dir(m_destination);
- if (!dir.exists()) {
- dir.mkdir(m_destination);
- qDebug() << "made directory" << m_destination;
- }
- if (!dir.exists("modules")) {
- dir.mkdir("modules");
- qDebug() << "made directory" << m_destination << "/modules";
- }
- if (!dir.exists("mods.d")) {
- dir.mkdir("mods.d");
- qDebug() << "made directory" << m_destination << "/mods.d";
- }
-
- QObject::connect(m_iMgr, SIGNAL(percentCompleted(int, int)), this, SLOT(slotManagerStatusUpdated(int, int)), Qt::QueuedConnection);
- QObject::connect(m_iMgr, SIGNAL(downloadStarted()), this, SLOT(slotDownloadStarted()), Qt::QueuedConnection);
-
- //check whether it's an update. If yes, remove existing module first
- /// \todo silently removing without undo if the user cancels the update is WRONG!!!
- removeModule();
-
- // manager for the destination path
- sword::SWMgr lMgr( m_destination.toLatin1() );
-
- if (BtInstallBackend::isRemote(*m_installSource)) {
- int status = m_iMgr->installModule(&lMgr, 0, m_module.toLatin1(), m_installSource.data());
- if (status != 0) {
- qWarning() << "Error with install: " << status << "module:" << m_module;
- }
- else {
- done = true;
- emit installCompleted(m_module, m_source, status);
- }
- }
- else { //local source
- emit statusUpdated(m_module, 0);
- int status = m_iMgr->installModule(&lMgr, m_installSource->directory.c_str(), m_module.toLatin1());
- if (status > 0) {
- qWarning() << "Error with install: " << status << "module:" << m_module;
- }
- else if (status == -1) {
- // it was terminated, do nothing
- }
- else {
- emit statusUpdated(m_module, 100);
- done = true;
- emit installCompleted(m_module, m_source, status);
- }
- }
-}
-
-void BtInstallThread::slotStopInstall() {
- qDebug() << "*************************************\nBtInstallThread::slotStopInstall" << m_module << "\n********************************";
- if (!done) {
- done = true;
- qDebug() << "*********************************\nBtInstallThread::slotStopInstall, installing" << m_module << "was cancelled\n**************************************";
- m_iMgr->terminate();
- //this->terminate(); // It's dangerous to forcibly stop, but we will clean up the files
- //qApp->processEvents();
- // wait to terminate for some secs. We rather let the execution go on and cleaning up to fail than the app to freeze
- int notRun = this->wait(25000);
- if (notRun) {
- this->terminate();
- this->wait(10000);
- qDebug() << "installthread (" << m_module << ") terminated, delete m_iMgr";
- delete m_iMgr; // this makes sure the ftp library will be cleaned up in the destroyer
- m_iMgr = 0;
- }
- // cleanup: remove the module, remove the temp files
- // if installation has already started
- if (m_installSource.data() != 0) {
- // remove the installed module, just to be sure because mgr may
- // have been terminated when copying files
- removeModule();
- removeTempFiles();
- qDebug() << "BtInstallThread::slotStopInstall will emit installStopped...";
- }
- emit installStopped(m_module, m_source);
- }
-}
-
-void BtInstallThread::slotManagerStatusUpdated(int totalProgress, int /*fileProgress*/) {
- emit statusUpdated(m_module, totalProgress);
-}
-
-void BtInstallThread::slotDownloadStarted() {
- emit downloadStarted(m_module);
-}
-
-void BtInstallThread::removeModule() {
- CSwordModuleInfo* m;
- m = CSwordBackend::instance()->findModuleByName(m_module);
- if (!m) {
- m = BtInstallBackend::backend(BtInstallBackend::source(m_destination.toLatin1()))->findModuleByName(m_module);
- }
- if (m) { //module found?
- qDebug() << "BtInstallThread::removeModule, module" << m_module << "found";
- QString prefixPath = m->config(CSwordModuleInfo::AbsoluteDataPath) + "/";
- QString dataPath = m->config(CSwordModuleInfo::DataPath);
- if (dataPath.left(2) == "./") {
- dataPath = dataPath.mid(2);
- }
-
- if (prefixPath.contains(dataPath)) {
- prefixPath.remove( prefixPath.indexOf(dataPath), dataPath.length() );
- }
- else {
- prefixPath = QString::fromLatin1(CSwordBackend::instance()->prefixPath);
- }
-
- sword::SWMgr mgr(prefixPath.toLatin1());
- BtInstallMgr iMgr;
- iMgr.removeModule(&mgr, m->name().toLatin1());
- }
- else {
- qDebug() << "BtInstallThread::removeModule, module" << m_module << "not found";
- }
-}
-
-void BtInstallThread::removeTempFiles() {
- // (take the remote conf file for this module, take DataPath,
- // take the absolute path of the InstallMgr)
-
- //sword::InstallSource is = BtInstallBackend::source(m_source);
- if (BtInstallBackend::isRemote(*m_installSource)) {
- // get the path for the module temp files
- CSwordModuleInfo* mInfo = m_backendForSource->findModuleByName(m_module);
- QString dataPath = mInfo->config(CSwordModuleInfo::AbsoluteDataPath);
- qDebug() << "Delete path:" << dataPath;
- // it's easier to use sword than qt
- sword::FileMgr::removeDir(dataPath.toLatin1().data());
- }
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.h b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
deleted file mode 100644
index 8bb660d..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTINSTALLTHREAD_H
-#define BTINSTALLTHREAD_H
-
-#include <QThread>
-
-#include <QSharedPointer>
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-
-
-class BtInstallProgressDialog;
-class CSwordBackend;
-
-/**
-* Thread for installing a module.
-*
-* See the Qt thread documents. We have to be careful with signals and slots,
-* with other things.
-
-The main thread creates and owns the BtInstallThread object.
-When the install thread (the run() method) has been started
-the install thread object receives status update signals
-from the installmgr object. This works because these signals are sent
-from the running install thread but received in the thread object which
-lives in the main thread (note the difference between a thread object and a
-running thread). The slot of the thread object is executed in the main thread
-event loop, not in the install thread.
-
-The running thread sends update signals to the progress dialog.
-(This works because the signals are queued, i.e. the dialog is running
-in the main app event loop which queues the signals. ???)
-
-When the user cancels installing the main thread sends signal to a slot
-in the thread object. The slot is then run in the main thread, not
-in the install thread (note again the difference between a thread object and a
-running thread). That slot terminates the running install thread immediately.
-That is not the cleanest way to do it, but the Sword library has no good
-support for threads. Terminating a Sword InstallMgr takes time and leads to
-slow response. Therefore we stop installing by force and clean up the
-temporary files manually.
-
-* Terminating a thread forcibly is "dangerous and discouraged" but we have to do it,
-* I couldn't get cancelling work reliably otherwise. The Sword library is bad for threads.
-* We use ftp connection and file resources; the connection can be ignored but the files
-* have to be cleaned up after termination.
-*/
-class BtInstallThread : public QThread {
- Q_OBJECT
- public:
- BtInstallThread(const QString &moduleName, const QString &sourceName,
- const QString &destinationName, QObject *parent = 0);
-
- ~BtInstallThread();
-
- public slots:
- void slotStopInstall();
- void slotManagerStatusUpdated(int totalProgress, int fileProgress);
- void slotDownloadStarted();
-
- public: // data member
- bool done;
-
- protected:
- virtual void run();
- void removeModule();
- void removeTempFiles();
-
- QString m_module;
- QString m_destination;
- QString m_source;
- bool m_cancelled;
- BtInstallMgr* m_iMgr;
- //BtInstallMgr m_iMgr;
- QSharedPointer<sword::InstallSource> m_installSource;
- /// \todo it would be best to get the backend from the bookshelf manager install page
- // where it has already been created. Could fasten the progress dialog startup.
- QSharedPointer<CSwordBackend> m_backendForSource;
-
- signals:
- /** Emitted when the install progress status is updated. */
- void statusUpdated(QString module, int progressPercent);
- /** Emitted when installing has been stopped/cancelled. */
- void installStopped(QString module, QString source);
- /** Emitted when installing is complete. */
- void installCompleted(QString module, QString source, int errorStatus);
- /** Emitted when the first file download has been started. */
- void downloadStarted(QString module);
- void preparingInstall(QString module, QString source);
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
index 949c82e..856f58b 100644
--- a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
@@ -2,7 +2,7 @@
#include <QApplication>
#include "backend/btinstallbackend.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
BtRefreshProgressDialog::BtRefreshProgressDialog(sword::InstallSource &source,
@@ -44,7 +44,7 @@ bool BtRefreshProgressDialog::runAndDelete() {
setValue(100);
qApp->processEvents();
} else {
- util::showWarning(this, tr("Warning"),
+ message::showWarning(this, tr("Warning"),
tr("Failed to refresh source %1")
.arg(QString(m_source.caption)));
}
diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
index dfabcf6..03f82c9 100644
--- a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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-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.
*
**********/
@@ -12,7 +14,7 @@
#include <QProgressDialog>
-#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "backend/btinstallmgr.h"
class BtRefreshProgressDialog: public QProgressDialog {
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
index 8b9dd3c..57879ea 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
@@ -4,7 +4,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.
*
@@ -17,18 +17,19 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <QHeaderView>
-#include <QMessageBox>
#include <QPushButton>
#include <QToolButton>
#include <QVBoxLayout>
#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
#include "frontend/btbookshelfview.h"
#include "frontend/btbookshelfwidget.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
-#include "util/dialogutil.h"
#include "util/directory.h"
+#include "util/geticon.h"
// Sword includes:
#include <swmgr.h>
@@ -40,10 +41,8 @@ const QString groupingOrderKey("GUI/BookshelfManager/RemovePage/grouping");
}
BtRemovePage::BtRemovePage(BtModuleManagerDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::removepage::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::bookshelfmgr::removepage::icon), parent)
{
- namespace DU = util::directory;
-
m_worksGroupBox = new QGroupBox(this);
m_worksGroupBox->setFlat(true);
QVBoxLayout *wLayout = new QVBoxLayout;
@@ -77,7 +76,7 @@ BtRemovePage::BtRemovePage(BtModuleManagerDialog *parent)
uLayout->addStretch(1);
m_removeButton = new QPushButton(this);
- m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::removepage::remove_icon));
+ m_removeButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::removepage::remove_icon));
m_removeButton->setEnabled(false);
uLayout->addWidget(m_removeButton, 0, Qt::AlignRight);
@@ -131,13 +130,13 @@ void BtRemovePage::slotRemoveModules() {
/// \bug <nobr> is not working, Qt bug
const QString moduleString("<nobr><img src=\"%1\" width=\"%2\" height=\"%3\"/>&nbsp;%4</nobr>");
const QString iconDir = util::directory::getIconDir().canonicalPath() + '/';
- Q_FOREACH(const CSwordModuleInfo *m,
+ Q_FOREACH(const CSwordModuleInfo * m,
m_bookshelfWidget->treeModel()->checkedModules())
{
- const QIcon icon = CSwordModuleInfo::moduleIcon(m);
+ const QIcon icon = CSwordModuleInfo::moduleIcon(*m);
const QSize iconSize = icon.actualSize(QSize(textHeight, textHeight));
prettyModuleNames.append(moduleString
- .arg(iconDir + CSwordModuleInfo::moduleIconFilename(m))
+ .arg(iconDir + CSwordModuleInfo::moduleIconFilename(*m))
.arg(iconSize.width())
.arg(iconSize.height())
.arg(m->name()));
@@ -149,7 +148,7 @@ void BtRemovePage::slotRemoveModules() {
.append("<br/><br/>")
.append(tr("Do you really want to remove them from your system?"));
- if ((util::showQuestion(this, tr("Remove Works?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)) { //Yes was pressed.
+ if ((message::showQuestion(this, tr("Remove Works?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)) { //Yes was pressed.
// Update the module list before really removing. Remember deleting the pointers later.
QList<CSwordModuleInfo*> toBeDeleted = CSwordBackend::instance()->takeModulesFromList(moduleNames);
@@ -180,7 +179,7 @@ void BtRemovePage::slotRemoveModules() {
mgr = mgrDict[ prefixPath ];
}
qDebug() << "Removing the module" << mInfo->name() << "...";
- installMgr.removeModule(mgr, mInfo->module()->Name());
+ installMgr.removeModule(mgr, mInfo->module()->getName());
}
//delete the removed moduleinfo pointers
qDeleteAll(toBeDeleted);
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.h b/src/frontend/bookshelfmanager/removepage/btremovepage.h
index 02ff88e..a9600d8 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.h
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.h
@@ -4,7 +4,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.
*
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
index a0955b2..9fce7ab 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
+++ b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
@@ -4,7 +4,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.
*
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
index 14e0a67..50da32b 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
+++ b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
@@ -4,7 +4,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.
*