diff options
author | Dmitrijs Ledkovs <xnox@debian.org> | 2012-04-14 18:11:50 +0100 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:48:45 -0400 |
commit | 1da8254d16a30cc96f545d198975e9f3a4d847be (patch) | |
tree | 6d94b7a0d34cb80e14287ae50994f1c46d39a154 /src/frontend/bookshelfmanager | |
parent | bc6baa3433b5781439754ff2a2a4d475986ec393 (diff) | |
parent | 00bc0a3de99e088902379dcb2905fb1546c7eca2 (diff) |
Imported Debian patch 2.9.1-1
Diffstat (limited to 'src/frontend/bookshelfmanager')
18 files changed, 273 insertions, 302 deletions
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.cpp b/src/frontend/bookshelfmanager/btconfigdialog.cpp index 3d02388..3b82560 100644 --- a/src/frontend/bookshelfmanager/btconfigdialog.cpp +++ b/src/frontend/bookshelfmanager/btconfigdialog.cpp @@ -17,16 +17,17 @@ #include <QLabel> #include <QListWidget> #include <QListView> -#include <QListWidgetItem> #include <QStackedWidget> #include <QVBoxLayout> -BtConfigDialog::BtConfigDialog(QWidget* parent) - : QDialog(parent), - m_maxItemWidth(0), - m_previousPageIndex(-2) { - setWindowFlags(Qt::Window); +BtConfigDialog::BtConfigDialog(QWidget* parent, Qt::WindowFlags flags) + : QDialog(parent, flags) + , m_buttonBoxRuler(0) + , m_buttonBox(0) + , m_maxItemWidth(0) + , m_previousPageIndex(-2) +{ m_contentsList = new QListWidget(this); m_contentsList->setViewMode(QListView::IconMode); m_contentsList->setMovement(QListView::Static); @@ -34,35 +35,27 @@ BtConfigDialog::BtConfigDialog(QWidget* parent) m_pageWidget = new QStackedWidget(this); m_pageWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - QHBoxLayout *mainLayout = new QHBoxLayout; - setLayout(mainLayout); - mainLayout->addWidget(m_contentsList); m_pageLayout = new QVBoxLayout; - mainLayout->addLayout(m_pageLayout); - m_pageLayout->addWidget(m_pageWidget); - connect(m_contentsList, - SIGNAL(currentRowChanged(int)), - this, SLOT(slotChangePage(int)) - ); + QHBoxLayout *mainLayout = new QHBoxLayout(this); + mainLayout->addWidget(m_contentsList); + mainLayout->addLayout(m_pageLayout); + connect(m_contentsList, SIGNAL(currentRowChanged(int)), + this, SLOT(slotChangePage(int))); } -BtConfigDialog::~BtConfigDialog() {} - -void BtConfigDialog::addPage(BtConfigPage* pageWidget) { - // this is a friend - pageWidget->m_parentDialog = this; +void BtConfigDialog::addPage(Page* pageWidget) { m_pageWidget->addWidget(pageWidget); - QListWidgetItem* item = new QListWidgetItem(m_contentsList); item->setIcon(pageWidget->icon()); - item->setText(pageWidget->header()); + item->setText(pageWidget->headerText()); item->setTextAlignment(Qt::AlignHCenter); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + pageWidget->setListWidgetItem(item); //set the list width - it may bee too wide (if there were no pages) or too narrow if (m_maxItemWidth < m_contentsList->visualItemRect(item).width()) { @@ -74,23 +67,29 @@ void BtConfigDialog::addPage(BtConfigPage* pageWidget) { m_contentsList->item(i)->setSizeHint(QSize(m_maxItemWidth, m_contentsList->visualItemRect(m_contentsList->item(i)).height()) ); } - slotChangePage(m_contentsList->row(item)); + setCurrentPage(m_contentsList->row(item)); } -void BtConfigDialog::addButtonBox(QDialogButtonBox* box) { +void BtConfigDialog::setButtonBox(QDialogButtonBox *box) { + Q_ASSERT(box != 0); + Q_ASSERT(m_buttonBox == 0); + Q_ASSERT(m_buttonBoxRuler == 0); + + m_buttonBox = box; + // First add a horizontal ruler: - QFrame *line = new QFrame(); - line->setGeometry(QRect(1, 1, 1, 3)); - line->setFrameShape(QFrame::HLine); - line->setFrameShadow(QFrame::Sunken); - line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - m_pageLayout->addWidget(line); + m_buttonBoxRuler = new QFrame(this); + m_buttonBoxRuler->setGeometry(QRect(1, 1, 1, 3)); + m_buttonBoxRuler->setFrameShape(QFrame::HLine); + m_buttonBoxRuler->setFrameShadow(QFrame::Sunken); + m_buttonBoxRuler->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + m_pageLayout->addWidget(m_buttonBoxRuler); // Add button box: m_pageLayout->addWidget(box); } -void BtConfigDialog::slotChangePage(int newIndex) { +void BtConfigDialog::setCurrentPage(int newIndex) { if (m_previousPageIndex != newIndex) { m_previousPageIndex = newIndex; m_contentsList->setCurrentRow(newIndex); @@ -98,15 +97,13 @@ void BtConfigDialog::slotChangePage(int newIndex) { } } - - -BtConfigPage::BtConfigPage(QWidget *parent) - : QWidget(parent) - , m_parentDialog(0) -{ - setLayout(new QVBoxLayout); -} - -BtConfigPage::~BtConfigPage() { - // Intentionally empty +void BtConfigDialog::slotChangePage(int newIndex) { + /* + This check is in place here because this slot is indirectly called by the + setCurrentPage method. + */ + if (m_previousPageIndex != newIndex) { + m_previousPageIndex = newIndex; + m_pageWidget->setCurrentIndex(newIndex); + } } diff --git a/src/frontend/bookshelfmanager/btconfigdialog.h b/src/frontend/bookshelfmanager/btconfigdialog.h index dce22ab..e90c3ed 100644 --- a/src/frontend/bookshelfmanager/btconfigdialog.h +++ b/src/frontend/bookshelfmanager/btconfigdialog.h @@ -12,15 +12,13 @@ #include <QDialog> -#include <QDebug> -#include <QWidget> +#include <QIcon> +#include <QListWidgetItem> class BtConfigPage; class QDialogButtonBox; -class QLabel; -class QListWidget; -class QListWidgetItem; +class QFrame; class QStackedWidget; class QVBoxLayout; @@ -33,60 +31,78 @@ class QVBoxLayout; * an auto-destroying window. */ class BtConfigDialog : public QDialog { + Q_OBJECT - public: - BtConfigDialog(QWidget *parent = 0); - virtual ~BtConfigDialog(); + + public: /* Types: */ + + /** Base class for configuration dialog pages. */ + class Page : public QWidget { + + friend class BtConfigDialog; + + public: /* Methods: */ + + inline Page(BtConfigDialog *parent) + : QWidget(parent), m_listWidgetItem(0) {} + inline Page(const QIcon &icon, BtConfigDialog *parent) + : QWidget(parent), m_icon(icon), m_listWidgetItem(0) {} + + inline const QIcon &icon() const { return m_icon; } + inline void setIcon(const QIcon &icon) { + m_icon = icon; + if (m_listWidgetItem != 0) + m_listWidgetItem->setIcon(icon); + } + + inline const QString &headerText() const { return m_headerText; } + inline void setHeaderText(const QString &headerText) { + m_headerText = headerText; + if (m_listWidgetItem != 0) + m_listWidgetItem->setText(headerText); + } + + private: /* Methods: */ + + void setListWidgetItem(QListWidgetItem *item) { + m_listWidgetItem = item; + } + + private: /* Fields: */ + + QIcon m_icon; + QString m_headerText; + QListWidgetItem *m_listWidgetItem; + + }; + + public: /* Methods: */ + + BtConfigDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); /** Adds a BtConfigPage to the paged widget stack. The new page will be the current page.*/ - void addPage(BtConfigPage* pageWidget); + void addPage(Page *pageWidget); + /** Adds a button box to the lower edge of the dialog. */ - void addButtonBox(QDialogButtonBox* buttonBox); + void setButtonBox(QDialogButtonBox* buttonBox); - public slots: /** Changes the current page using the given index number. */ + void setCurrentPage(int newIndex); + + private slots: + void slotChangePage(int newIndex); - private: + private: /* Fields: */ + QListWidget* m_contentsList; QStackedWidget* m_pageWidget; QVBoxLayout* m_pageLayout; + QFrame *m_buttonBoxRuler; + QDialogButtonBox *m_buttonBox; int m_maxItemWidth; int m_previousPageIndex; -}; - - -/** -* Base class for configuration dialog pages. -*/ -class BtConfigPage : public QWidget { - Q_OBJECT - friend class BtConfigDialog; - - public: - /** - Constructs a configuration dialog base, with QVBoxLayout as layout() and a header - label as the first widget in this layout. - \param[in] parent The parent widget. - */ - BtConfigPage(QWidget *parent = 0); - virtual ~BtConfigPage(); - - /** Implement these to return the correct values. - * For example: header(){return tr("General");} - */ - virtual const QIcon &icon() const = 0; - virtual QString header() const = 0; - - inline BtConfigDialog *parentDialog() const { - return m_parentDialog; - } - - private: - BtConfigDialog *m_parentDialog; }; - #endif - diff --git a/src/frontend/bookshelfmanager/btinstallmgr.cpp b/src/frontend/bookshelfmanager/btinstallmgr.cpp index 756fcae..652ff04 100644 --- a/src/frontend/bookshelfmanager/btinstallmgr.cpp +++ b/src/frontend/bookshelfmanager/btinstallmgr.cpp @@ -11,7 +11,6 @@ #include "backend/managers/cswordbackend.h" #include "backend/btinstallbackend.h" -#include <QDebug> #include <QList> #include <QObject> #include <QString> @@ -28,7 +27,6 @@ BtInstallMgr::BtInstallMgr() : InstallMgr(BtInstallBackend::configPath().toLatin1(), this), m_totalBytes(1), m_completedBytes(0), m_firstCallOfPreStatus(true) { //use this class also as status reporter - qDebug() << "BtInstallMgr::BtInstallMgr"; this->setFTPPassive(true); } @@ -44,7 +42,6 @@ bool BtInstallMgr::isUserDisclaimerConfirmed() const { } void BtInstallMgr::statusUpdate(double dltotal, double dlnow) { - //qDebug() << "BtInstallMgr::statusUpdate"; if (dlnow > dltotal) dlnow = dltotal; @@ -65,7 +62,6 @@ void BtInstallMgr::statusUpdate(double dltotal, double dlnow) { filePercent = 0; } //qApp->processEvents(); - //qDebug() << "status: total"<<totalPercent<<"file"<<filePercent; emit percentCompleted(totalPercent, filePercent); } @@ -75,7 +71,6 @@ void BtInstallMgr::preStatus(long totalBytes, long completedBytes, const char* m m_firstCallOfPreStatus = false; emit downloadStarted(); } - qDebug() << "BtInstallMgr::preStatus:" << (int)totalBytes << "/" << (int)completedBytes << QString(message); m_completedBytes = completedBytes; m_totalBytes = (totalBytes > 0) ? totalBytes : 1; //avoid division by zero } diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp index f0547b8..42febaa 100644 --- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp +++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp @@ -18,34 +18,39 @@ static BtModuleManagerDialog *m_staticModuleManagerDialog = 0; -BtModuleManagerDialog* BtModuleManagerDialog::getInstance(QWidget* parent) { - if (!m_staticModuleManagerDialog) { - m_staticModuleManagerDialog = new BtModuleManagerDialog(parent); - }; +BtModuleManagerDialog* BtModuleManagerDialog::getInstance(QWidget *parent, + Qt::WindowFlags flags) +{ + if (m_staticModuleManagerDialog) { + m_staticModuleManagerDialog->setParent(parent, flags); + } else { + m_staticModuleManagerDialog = new BtModuleManagerDialog(parent, flags); + } Q_ASSERT(m_staticModuleManagerDialog); return m_staticModuleManagerDialog; } -BtModuleManagerDialog::BtModuleManagerDialog(QWidget* parent) - : BtConfigDialog(parent) { +BtModuleManagerDialog::BtModuleManagerDialog(QWidget *parent, + Qt::WindowFlags flags) + : BtConfigDialog(parent, + flags | Qt::CustomizeWindowHint | Qt::WindowTitleHint + | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint) +{ setAttribute(Qt::WA_DeleteOnClose); - setWindowTitle(tr("Bookshelf Manager")); - // Install page - BtInstallPage* installPage = new BtInstallPage(); - addPage(installPage); + addPage(new BtInstallPage()); + addPage(new BtRemovePage()); + addPage(new BtIndexPage()); - //Uninstall page - BtRemovePage* removePage = new BtRemovePage(); - addPage(removePage); + retranslateUi(); - //Index page - BtIndexPage* indexPage = new BtIndexPage(); - addPage(indexPage); + loadDialogSettings(); + setCurrentPage(0); - slotChangePage(0); +} - loadDialogSettings(); +void BtModuleManagerDialog::retranslateUi() { + setWindowTitle(tr("Bookshelf Manager")); } BtModuleManagerDialog::~BtModuleManagerDialog() { @@ -53,17 +58,12 @@ BtModuleManagerDialog::~BtModuleManagerDialog() { m_staticModuleManagerDialog = 0; } -// The QWidget close() sends close event, so does closing by the window X button. -void BtModuleManagerDialog::closeEvent(QCloseEvent*) { - qDebug() << "BtModuleManagerDialog::closeEvent"; -} - void BtModuleManagerDialog::loadDialogSettings() { resize(CBTConfig::get(CBTConfig::bookshelfWidth), CBTConfig::get(CBTConfig::bookshelfHeight)); move(CBTConfig::get(CBTConfig::bookshelfPosX), CBTConfig::get(CBTConfig::bookshelfPosY)); } -void BtModuleManagerDialog::saveDialogSettings() { +void BtModuleManagerDialog::saveDialogSettings() const { CBTConfig::set(CBTConfig::bookshelfWidth, size().width()); CBTConfig::set(CBTConfig::bookshelfHeight, size().height()); CBTConfig::set(CBTConfig::bookshelfPosX, x()); diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h index 0392cc2..01ef594 100644 --- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h +++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h @@ -13,38 +13,31 @@ #include "frontend/bookshelfmanager/btconfigdialog.h" -class QWidget; - /** * The Bookshelf Manager dialog. Includes pages for Install, Remove, Indexes. */ -class BtModuleManagerDialog : public BtConfigDialog { +class BtModuleManagerDialog: public BtConfigDialog { + Q_OBJECT public: - static BtModuleManagerDialog* getInstance(QWidget* parent); + static BtModuleManagerDialog *getInstance(QWidget *parent = 0, + Qt::WindowFlags flags = 0); ~BtModuleManagerDialog(); + private: - //void slotClose(); - protected: - /** Reimplementation from QWidget. */ - virtual void closeEvent(QCloseEvent* event); + BtModuleManagerDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); - /** Adds the pages and the button box. */ - BtModuleManagerDialog(QWidget* parent); + void retranslateUi(); - private: - // Load the settings from the resource file + /** Loads the settings from the resource file. */ void loadDialogSettings(); - // Save the settings to the resource file - void saveDialogSettings(); - + /** Saves the settings to the resource file. */ + void saveDialogSettings() const; -//signals: -// void swordSetupChanged(); }; diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp index 14aecb9..f40d8c3 100644 --- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp +++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp @@ -24,7 +24,6 @@ #include <QDialogButtonBox> #include <QProgressDialog> #include <QApplication> -#include <QDebug> #include "backend/btinstallbackend.h" #include "util/dialogutil.h" @@ -157,7 +156,6 @@ void CSwordSetupInstallSourcesDialog::slotGetListClicked() { if (answer == QMessageBox::No) { return; } - qDebug() << "Ok, create installmgr"; BtInstallMgr iMgr; m_progressDialog = new QProgressDialog("", tr("Cancel"), 0 , 100, this); @@ -174,11 +172,9 @@ void CSwordSetupInstallSourcesDialog::slotGetListClicked() { m_progressDialog->setLabelText(tr("Connecting...")); m_progressDialog->setValue(0); qApp->processEvents(); - qWarning() << "Start downloading the list of sources"; int ret = iMgr.refreshRemoteSourceConfiguration(); if ( !ret ) { //make sure the sources were updated sucessfully - qDebug() << "download succeeded"; m_progressDialog->setValue(100); //make sure the dialog closes m_remoteListAdded = true; accept(); diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp index 026aad5..960f5c8 100644 --- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp +++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp @@ -19,24 +19,22 @@ #include "backend/config/cbtconfig.h" #include "backend/drivers/cswordmoduleinfo.h" #include "backend/managers/cswordbackend.h" +#include "frontend/bookshelfmanager/btmodulemanagerdialog.h" #include "frontend/btmoduleindexdialog.h" #include "util/directory.h" #include "util/cresmgr.h" #include "util/tool.h" -BtIndexPage::BtIndexPage(QWidget *parent) - : BtConfigPage(parent) +BtIndexPage::BtIndexPage(BtModuleManagerDialog *parent) + : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::indexpage::icon), parent) { namespace DU = util::directory; - Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0); - QVBoxLayout *vboxLayout = static_cast<QVBoxLayout*>(layout()); + QVBoxLayout *vboxLayout = new QVBoxLayout(this); QHBoxLayout *hboxLayout; m_autoDeleteOrphanedIndicesBox = new QCheckBox(this); - m_autoDeleteOrphanedIndicesBox->setToolTip(tr("If selected, those indexes which have no corresponding work will be deleted when BibleTime starts")); - m_autoDeleteOrphanedIndicesBox->setText(tr("Automatically delete orphaned indexes when BibleTime starts")); vboxLayout->addWidget(m_autoDeleteOrphanedIndicesBox); m_moduleList = new QTreeWidget(this); @@ -48,19 +46,15 @@ BtIndexPage::BtIndexPage(QWidget *parent) hboxLayout->addItem(spacerItem); m_deleteButton = new QPushButton(this); - m_deleteButton->setToolTip(tr("Delete the selected indexes")); - m_deleteButton->setText(tr("Delete")); hboxLayout->addWidget(m_deleteButton); m_createButton = new QPushButton(this); - m_createButton->setToolTip(tr("Create new indexes for the selected works")); - m_createButton->setText(tr("Create...")); hboxLayout->addWidget(m_createButton); vboxLayout->addLayout(hboxLayout); // configure the list view - m_moduleList->setHeaderLabels( (QStringList(tr("Work")) << tr("Index size")) ); + m_moduleList->setHeaderLabels( (QStringList(tr("Work")) << tr("Index size")) ); /// \todo Move to retranslateUi() m_moduleList->setRootIsDecorated(true); m_moduleList->setColumnWidth(0, util::tool::mWidth(m_moduleList, 20) ); //m_moduleList->setTextAlignment(1, Qt::AlignRight); see doc... @@ -73,26 +67,20 @@ BtIndexPage::BtIndexPage(QWidget *parent) m_deleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::indexpage::delete_icon)); // connect our signals/slots - connect(m_createButton, SIGNAL(clicked()), this, SLOT(createIndices())); - connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteIndices())); - connect(CSwordBackend::instance(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged())); - - populateModuleList(); + connect(m_createButton, SIGNAL(clicked()), + this, SLOT(createIndices())); + connect(m_deleteButton, SIGNAL(clicked()), + this, SLOT(deleteIndices())); + connect(CSwordBackend::instance(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), + this, SLOT(slotSwordSetupChanged())); + + retranslateUi(); // also calls populateModuleList(); } BtIndexPage::~BtIndexPage() { CBTConfig::set( CBTConfig::autoDeleteOrphanedIndices, m_autoDeleteOrphanedIndicesBox->isChecked() ); } -const QIcon &BtIndexPage::icon() const { - return util::directory::getIcon(CResMgr::bookshelfmgr::indexpage::icon); -} - -QString BtIndexPage::header() const { - return tr("Search Indexes"); -} - - /** Populates the module list with installed modules and orphaned indices */ void BtIndexPage::populateModuleList() { typedef QList<CSwordModuleInfo*>::const_iterator MLCI; @@ -110,8 +98,6 @@ void BtIndexPage::populateModuleList() { m_modsWithoutIndices->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate); m_modsWithoutIndices->setExpanded(true); - - const QList<CSwordModuleInfo*> &modules(CSwordBackend::instance()->moduleList()); for (MLCI it(modules.begin()); it != modules.end(); ++it) { QTreeWidgetItem* item = 0; @@ -119,20 +105,35 @@ void BtIndexPage::populateModuleList() { if ((*it)->hasIndex()) { item = new QTreeWidgetItem(m_modsWithIndices); item->setText(0, (*it)->name()); - item->setText(1, QString("%1 ").arg((*it)->indexSize() / 1024) + tr("KiB")); + item->setText(1, tr("%1 KiB").arg((*it)->indexSize() / 1024)); item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); item->setCheckState(0, Qt::Unchecked); } else { item = new QTreeWidgetItem(m_modsWithoutIndices); item->setText(0, (*it)->name()); - item->setText(1, QString("0 ") + tr("KiB")); + item->setText(1, tr("0 KiB")); item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); item->setCheckState(0, Qt::Checked); } } } +void BtIndexPage::retranslateUi() { + setHeaderText(tr("Search Indexes")); + + m_autoDeleteOrphanedIndicesBox->setToolTip(tr("If selected, those indexes which have no corresponding work will be deleted when BibleTime starts")); + m_autoDeleteOrphanedIndicesBox->setText(tr("Automatically delete orphaned indexes when BibleTime starts")); + + m_deleteButton->setToolTip(tr("Delete the selected indexes")); + m_deleteButton->setText(tr("Delete")); + + m_createButton->setToolTip(tr("Create new indexes for the selected works")); + m_createButton->setText(tr("Create...")); + + populateModuleList(); +} + /** Creates indices for selected modules if no index currently exists */ void BtIndexPage::createIndices() { bool indicesCreated = false; diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.h b/src/frontend/bookshelfmanager/indexpage/btindexpage.h index 89a7e35..303c6ab 100644 --- a/src/frontend/bookshelfmanager/indexpage/btindexpage.h +++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.h @@ -13,27 +13,26 @@ #include "frontend/bookshelfmanager/btconfigdialog.h" +class BtModuleManagerDialog; class QCheckBox; class QTreeWidget; class QTreeWidgetItem; +/** \todo add void retranslateUi(); */ + /** * This class encapsulates the "Manage search indices" page of the Bookshelf * Manager. It allows for creation and deletion of search indicies for each * installed module. It also allows for deletion of orphaned indices. */ -class BtIndexPage : public BtConfigPage { +class BtIndexPage: public BtConfigDialog::Page { + Q_OBJECT public: - BtIndexPage(QWidget *parent = 0); - ~BtIndexPage(); - - /** Reimplemented from BtConfigPage. */ - virtual QString header() const; - /** Reimplemented from BtConfigPage. */ - virtual const QIcon &icon() const; + BtIndexPage(BtModuleManagerDialog *parent = 0); + ~BtIndexPage(); public slots: void slotSwordSetupChanged(); @@ -45,7 +44,7 @@ class BtIndexPage : public BtConfigPage { */ void populateModuleList(); - + void retranslateUi(); public slots: /** @@ -66,6 +65,7 @@ class BtIndexPage : public BtConfigPage { QTreeWidgetItem* m_modsWithIndices; QTreeWidgetItem* m_modsWithoutIndices; + }; diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp index d3bac59..9c7955a 100644 --- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp +++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp @@ -46,8 +46,8 @@ const QString selectedModuleKey("GUI/BookshelfManager/InstallPage/selectedModule // *********** Config dialog page: Install/Update ********** // ********************************************************* -BtInstallPage::BtInstallPage(QWidget *parent) - : BtConfigPage(parent) +BtInstallPage::BtInstallPage(BtModuleManagerDialog *parent) + : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::installpage::icon), parent) , m_groupingOrder(groupingOrderKey) , m_modulesSelected(0) , m_modulesSelectedSources(0) @@ -58,10 +58,11 @@ BtInstallPage::BtInstallPage(QWidget *parent) // Initialize widgets: initView(); initConnections(); + + retranslateUi(); } void BtInstallPage::setInstallEnabled(bool b) { - qDebug() << "void BtInstallPage::setInstallEnabled(bool b) start"; m_installButton->setEnabled(b); } @@ -73,36 +74,31 @@ void BtInstallPage::initView() { namespace DU = util::directory; // Warning label: - - m_warningLabel = util::tool::explanationLabel(this, tr("WARNING!!!"), - tr("If you live in a persecuted country and don't want to risk " - "detection don't use remote sources.")); + m_warningLabel = new QLabel(this); // Source chooser: - m_sourceGroupBox = new QGroupBox(tr("Select installation &source:"), this); + m_sourceGroupBox = new QGroupBox(this); m_sourceGroupBox->setFlat(true); m_sourceComboBox = new QComboBox(this); m_sourceComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); initSourcesCombo(); - m_sourceAddButton = new QPushButton(tr("&Add...")); - m_sourceAddButton ->setToolTip(tr("Add new source")); + m_sourceAddButton = new QPushButton(this); m_sourceAddButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::add_icon)); - m_sourceDeleteButton = new QPushButton(tr("&Delete...")); - m_sourceDeleteButton->setToolTip(tr("Delete this source")); + m_sourceDeleteButton = new QPushButton(this); m_sourceDeleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon)); QHBoxLayout *sourceChooserLayout = new QHBoxLayout(); - sourceChooserLayout->setContentsMargins(0, 0, 0, 0); + sourceChooserLayout->setContentsMargins(0, 8, 0, 0); sourceChooserLayout->addWidget(m_sourceComboBox, 1); sourceChooserLayout->addWidget(m_sourceAddButton); sourceChooserLayout->addWidget(m_sourceDeleteButton); m_sourceGroupBox->setLayout(sourceChooserLayout); // Works chooser: - m_worksGroupBox = new QGroupBox(tr("Select &works to install:"), this); + m_worksGroupBox = new QGroupBox(this); m_worksGroupBox->setFlat(true); m_worksLayout = new QStackedLayout(); m_worksGroupBox->setLayout(m_worksLayout); @@ -113,35 +109,31 @@ void BtInstallPage::initView() { m_installGroupBox->setFlat(true); retranslateInstallGroupBox(); - m_pathLabel = new QLabel(tr("Install &folder:")); + m_pathLabel = new QLabel(this); m_pathCombo = new QComboBox(this); m_pathCombo->setMinimumContentsLength(20); m_pathCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon); m_pathCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - m_pathCombo->setToolTip(tr("The folder where the new works will be installed")); m_pathCombo->view()->setTextElideMode(Qt::ElideMiddle); m_pathLabel->setBuddy(m_pathCombo); initPathCombo(); m_configurePathButton = new QToolButton(this); - m_configurePathButton->setToolTip(tr("Configure folders where works are installed and found")); m_configurePathButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::path_icon)); - m_installButton = new QPushButton(tr("&Install..."), this); - m_installButton->setToolTip(tr("Install or update selected works")); + m_installButton = new QPushButton(this); m_installButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::install_icon)); m_installButton->setEnabled(false); QHBoxLayout *pathLayout = new QHBoxLayout(); - pathLayout->setContentsMargins(0, 0, 0, 0); + pathLayout->setContentsMargins(0, 8, 0, 0); pathLayout->addWidget(m_pathLabel); pathLayout->addWidget(m_pathCombo); pathLayout->addWidget(m_configurePathButton); pathLayout->addWidget(m_installButton); m_installGroupBox->setLayout(pathLayout); - Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0); - QVBoxLayout *mainLayout = static_cast<QVBoxLayout*>(layout()); + QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(m_warningLabel); mainLayout->addWidget(m_sourceGroupBox); mainLayout->addWidget(m_worksGroupBox, 1); @@ -232,11 +224,10 @@ void BtInstallPage::initSourcesCombo() { } void BtInstallPage::activateSource(const sword::InstallSource &src) { - qDebug() << "Selected source" << src.caption; qApp->setOverrideCursor(Qt::WaitCursor); BtInstallPageWorksWidget *w = m_sourceMap.value(QString(src.caption), 0); if (w == 0) { - if (parentDialog() != 0) parentDialog()->setEnabled(false); + window()->setEnabled(false); qApp->processEvents(); w = new BtInstallPageWorksWidget(src, m_groupingOrder, this); m_sourceMap.insert(QString(src.caption), w); @@ -245,7 +236,7 @@ void BtInstallPage::activateSource(const sword::InstallSource &src) { this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&))); connect(w->treeModel(), SIGNAL(moduleChecked(CSwordModuleInfo*,bool)), this, SLOT(slotSelectedModulesChanged())); - if (parentDialog() != 0) parentDialog()->setEnabled(true); + window()->setEnabled(true); } else { disconnect(w->treeView()->header(), SIGNAL(geometriesChanged()), this, SLOT(slotHeaderChanged())); @@ -268,6 +259,30 @@ void BtInstallPage::retranslateInstallGroupBox() { } } +void BtInstallPage::retranslateUi() { + setHeaderText(tr("Install/Update")); + + util::tool::initExplanationLabel(m_warningLabel, tr("WARNING!!!"), + tr("If you live in a persecuted country and don't want to risk " + "detection don't use remote sources.")); + + m_sourceGroupBox->setTitle(tr("Select installation &source:")); + m_sourceAddButton->setText(tr("&Add...")); + m_sourceAddButton ->setToolTip(tr("Add new source")); + m_sourceDeleteButton->setText(tr("&Delete...")); + m_sourceDeleteButton->setToolTip(tr("Delete this source")); + + m_worksGroupBox->setTitle(tr("Select &works to install:")); + + m_pathLabel->setText(tr("Install &folder:")); + m_pathCombo->setToolTip(tr("The folder where the new works will be installed")); + m_configurePathButton->setToolTip(tr("Configure folders where works are installed and found")); + m_installButton->setText(tr("&Install...")); + m_installButton->setToolTip(tr("Install or update selected works")); + + retranslateInstallGroupBox(); +} + void BtInstallPage::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) { m_groupingOrder = g; m_groupingOrder.saveTo(groupingOrderKey); @@ -282,8 +297,6 @@ void BtInstallPage::slotHeaderChanged() { } void BtInstallPage::slotInstall() { - qDebug() << "BtInstallPage::slotInstall"; - // check that the destination path is writable, do nothing if not and user doesn't want to continue QDir dir = selectedInstallPath(); bool canWrite = true; @@ -319,23 +332,20 @@ void BtInstallPage::slotInstall() { cm.insert(m); } - if (cm.empty()) return; + if (cm.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...) - BtModuleManagerDialog *parentDlg = dynamic_cast<BtModuleManagerDialog*>(parentDialog()); - - BtInstallProgressDialog *dlg = new BtInstallProgressDialog(cm, selectedInstallPath(), parentDlg); - - if (!parentDlg) qDebug() << "error, wrong parent!"; + // progressDialog is WA_DeleteOnClose + BtInstallProgressDialog *progressDialog = new BtInstallProgressDialog(cm, selectedInstallPath(), this); m_installButton->setEnabled(false); // the progress dialog is now modal, it can be made modeless later. - dlg->exec(); + progressDialog->exec(); - qDebug() << "BtSourceWidget::slotInstallAccepted end"; } delete dlg; } @@ -358,7 +368,10 @@ void BtInstallPage::slotSourceAdd() { QSharedPointer<SSISD> dlg(new SSISD()); if (dlg->exec() == QDialog::Accepted) { - if (!dlg->wasRemoteListAdded()) { + if (dlg->wasRemoteListAdded()) { + initSourcesCombo(); + } + else { sword::InstallSource newSource = dlg->getSource(); if ( !((QString)newSource.type.c_str()).isEmpty() ) { // we have a valid source to add BtInstallBackend::addSource(newSource); @@ -415,16 +428,6 @@ void BtInstallPage::slotSelectedModulesChanged() { retranslateInstallGroupBox(); } -// implement the BtConfigPage methods - -const QIcon &BtInstallPage::icon() const { - return util::directory::getIcon(CResMgr::bookshelfmgr::installpage::icon); -} - -QString BtInstallPage::header() const { - return tr("Install/Update"); -} - void BtInstallPage::slotSwordSetupChanged() { QString moduleName = m_sourceComboBox->currentText(); diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.h b/src/frontend/bookshelfmanager/installpage/btinstallpage.h index 88d1f92..0cb6724 100644 --- a/src/frontend/bookshelfmanager/installpage/btinstallpage.h +++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.h @@ -20,8 +20,10 @@ class InstallSource; } class BtInstallPageWorksWidget; +class BtModuleManagerDialog; class QComboBox; class QGroupBox; +class QLabel; class QPushButton; class QStackedLayout; class QToolButton; @@ -29,17 +31,13 @@ class QToolButton; /** * The Install page includes module path chooser, source/module handler and install button. */ -class BtInstallPage: public BtConfigPage { +class BtInstallPage: public BtConfigDialog::Page { + Q_OBJECT public: - BtInstallPage(QWidget *parent = 0); - - /** Reimplemented from BtConfigPage. */ - virtual const QIcon &icon() const; - /** Reimplemented from BtConfigPage. */ - virtual QString header() const; + BtInstallPage(BtModuleManagerDialog *parent = 0); void setInstallEnabled(bool b); @@ -48,6 +46,10 @@ class BtInstallPage: public BtConfigPage { public slots: void slotSwordSetupChanged(); + protected: + + void retranslateUi(); + private: void initView(); void initConnections(); diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp index 6b9fb53..0bb8829 100644 --- a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp +++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp @@ -57,8 +57,6 @@ BtInstallPageWorksWidget::BtInstallPageWorksWidget( { namespace DU = util::directory; - qDebug() << "Creating new BtInstallPageWorksWidget for source" << source.caption; - setTreeModel(new BtInstallPageModel(g, this)); treeView()->setHeaderHidden(false); @@ -79,8 +77,6 @@ BtInstallPageWorksWidget::BtInstallPageWorksWidget( } BtInstallPageWorksWidget::~BtInstallPageWorksWidget() { - qDebug() << "Deleting BtInstallPageWorksWidget for source" << m_source.caption; - delete m_backend; } diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp index a272d89..b4deb51 100644 --- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp +++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp @@ -120,7 +120,6 @@ BtInstallPathDialog::~BtInstallPathDialog() { } void BtInstallPathDialog::updateTopLevelItems() { - qDebug() << "BtInstallPathDialog::updateTopLevelItems"; if (m_writableItem->childCount()) { m_writableItem->setHidden(false); m_swordPathListBox->expandItem(m_writableItem); @@ -209,18 +208,14 @@ void BtInstallPathDialog::slotAddClicked() { } void BtInstallPathDialog::slotRemoveClicked() { - qDebug() << "BtInstallPathDialog::slotRemoveClicked"; QTreeWidgetItem* i = m_swordPathListBox->selectedItems().value(0); - qDebug() << i; if (i && i->parent() != m_swordPathListBox->invisibleRootItem()) { - qDebug() << "delete" << i; delete i; } updateTopLevelItems(); } void BtInstallPathDialog::writeSwordConfig() { - qDebug() << "BtInstallPathDialog::writeSwordConfig"; QStringList targets; QTreeWidgetItemIterator it(m_swordPathListBox, QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Enabled | QTreeWidgetItemIterator::NotHidden); while (*it) { diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp index 465ec03..288be4e 100644 --- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp +++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp @@ -91,13 +91,11 @@ void BtInstallProgressDialog::startThreads() { //foreach (QString mName, m_threadsByModule.keys()) { //} //QList<CSwordModuleInfo*> CSwordBackend::instance()()->takeModulesFromList(m_threadsByModule.keys()); - qDebug() << "start threads..."; //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(); -// qDebug() << sourceName; // if (m_runningThreads.values(sourceName).count() < 3) { // BtInstallThread* t = threadIterator.value(); // m_runningThreads.insert(sourceName, t); @@ -117,13 +115,8 @@ void BtInstallProgressDialog::startThreads() { threadIterator = m_waitingThreads.erase(threadIterator); t->start(); } - - qDebug() << "BtInstallProgressDialog::startThreads end"; } -BtInstallProgressDialog::~BtInstallProgressDialog() {} - - void BtInstallProgressDialog::slotOneItemCompleted(QString module, QString source, int status) { QString message; //status comes from the sword installer. @@ -156,9 +149,7 @@ void BtInstallProgressDialog::oneItemStoppedOrCompleted(QString module, QString //concurrency is disabled for now // //start a waiting thread if there are any // QList<BtInstallThread*> threadsForSource = m_waitingThreads.values(source); -// qDebug() << threadsForSource; // if (!threadsForSource.isEmpty()) { -// qDebug() << "Threads are waiting for turn"; // BtInstallThread* thread = threadsForSource.at(0); // m_waitingThreads.remove(source, thread); // m_runningThreads.insert(source, thread); @@ -167,7 +158,7 @@ void BtInstallProgressDialog::oneItemStoppedOrCompleted(QString module, QString //non-concurrent QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end(); - if (m_runningThreads.size() == 0 && threadIterator != m_waitingThreads.begin()) { + if (m_runningThreads.isEmpty() && threadIterator != m_waitingThreads.begin()) { threadIterator--; // the last item QString sourceName = threadIterator.key(); BtInstallThread* t = threadIterator.value(); @@ -199,8 +190,6 @@ void BtInstallProgressDialog::slotStopInstall() { } void BtInstallProgressDialog::slotStatusUpdated(QString module, int status) { - //qDebug() << "BtInstallProgressDialog::slotStatusUpdated"; - //qDebug() << "module:" << module << "status:" << 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); @@ -212,7 +201,6 @@ void BtInstallProgressDialog::slotInstallStarted(QString module, QString) { } void BtInstallProgressDialog::slotDownloadStarted(QString module) { - qDebug() << "BtInstallProgressDialog::slotDownloadStarted" << module; getItem(module)->setText(1, QString::null); //m_statusWidget->itemWidget(getItem(module), 1)->setVisible(true); @@ -223,13 +211,10 @@ void BtInstallProgressDialog::slotDownloadStarted(QString module) { } QTreeWidgetItem* BtInstallProgressDialog::getItem(QString moduleName) { - //qDebug() << "BtInstallProgressDialog::getItem" << moduleName; return m_statusWidget->findItems(moduleName, Qt::MatchExactly).at(0); } void BtInstallProgressDialog::closeEvent(QCloseEvent* event) { - qDebug() << "BtInstallProgressDialog::closeEvent"; - if (event->spontaneous()) { event->ignore(); return; @@ -239,5 +224,5 @@ void BtInstallProgressDialog::closeEvent(QCloseEvent* event) { } bool BtInstallProgressDialog::threadsDone() { - return (m_waitingThreads.count() == 0 && m_runningThreads.count() == 0); + return (m_waitingThreads.isEmpty() && m_runningThreads.isEmpty()); } diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h index 8b990ad..a72b280 100644 --- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h +++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h @@ -28,8 +28,6 @@ class BtInstallProgressDialog : public QDialog { const QString &destination, QWidget *parent = 0, Qt::WindowFlags flags = 0); - ~BtInstallProgressDialog(); - public slots: void slotOneItemCompleted(QString module, QString source, int status); void slotOneItemStopped(QString module, QString source); diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp index 2d04a51..3b25f02 100644 --- a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp +++ b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp @@ -75,7 +75,6 @@ void BtInstallThread::run() { sword::SWMgr lMgr( m_destination.toLatin1() ); if (BtInstallBackend::isRemote(*m_installSource)) { - qDebug() << "calling install"; int status = m_iMgr->installModule(&lMgr, 0, m_module.toLatin1(), m_installSource.data()); if (status != 0) { qWarning() << "Error with install: " << status << "module:" << m_module; @@ -109,7 +108,6 @@ void BtInstallThread::slotStopInstall() { 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 - qDebug() << "BtInstallThread::slotStopInstall 2"; //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); @@ -120,11 +118,9 @@ void BtInstallThread::slotStopInstall() { delete m_iMgr; // this makes sure the ftp library will be cleaned up in the destroyer m_iMgr = 0; } - qDebug() << "BtInstallThread::slotStopInstall 3"; // cleanup: remove the module, remove the temp files // if installation has already started if (m_installSource.data() != 0) { - qDebug() << "BtInstallThread::slotStopInstall 4"; // remove the installed module, just to be sure because mgr may // have been terminated when copying files removeModule(); @@ -136,17 +132,14 @@ void BtInstallThread::slotStopInstall() { } void BtInstallThread::slotManagerStatusUpdated(int totalProgress, int /*fileProgress*/) { - //qDebug() << "BtInstallThread::slotManagerStatusUpdated"; emit statusUpdated(m_module, totalProgress); } void BtInstallThread::slotDownloadStarted() { - qDebug() << "BtInstallThread::slotDownloadStarted"; emit downloadStarted(m_module); } void BtInstallThread::removeModule() { - qDebug() << "BtInstallThread::removeModule start"; CSwordModuleInfo* m; m = CSwordBackend::instance()->findModuleByName(m_module); if (!m) { @@ -177,8 +170,6 @@ void BtInstallThread::removeModule() { } void BtInstallThread::removeTempFiles() { - qDebug() << "BtInstallThread::removeTempFiles start"; - // (take the remote conf file for this module, take DataPath, // take the absolute path of the InstallMgr) diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp index 3666888..949c82e 100644 --- a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp +++ b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp @@ -1,7 +1,6 @@ #include "frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h" #include <QApplication> -#include <QDebug> #include "backend/btinstallbackend.h" #include "util/dialogutil.h" @@ -12,8 +11,6 @@ BtRefreshProgressDialog::BtRefreshProgressDialog(sword::InstallSource &source, : QProgressDialog(parent, flags) , m_source(source) { - qDebug() << "Creating BtRefreshProgressDialog for source" << source.caption; - Q_ASSERT(BtInstallBackend::isRemote(source)); setWindowTitle(tr("Refreshing source %1").arg(QString(source.caption))); setCancelButtonText(tr("&Cancel")); @@ -31,21 +28,15 @@ BtRefreshProgressDialog::BtRefreshProgressDialog(sword::InstallSource &source, } void BtRefreshProgressDialog::slotPercentCompleted(int, int current) { - qDebug() << "BtRefreshProgressDialog progress:" << current; - setValue(current); qApp->processEvents(); } void BtRefreshProgressDialog::slotCanceled() { - qDebug() << "BtRefreshProgressDialog cancel clicked."; - m_installMgr.terminate(); } bool BtRefreshProgressDialog::runAndDelete() { - qDebug() << "BtRefreshProgressDialog runAndDelete()"; - show(); qApp->processEvents(); bool r = (m_installMgr.refreshRemoteSource(&m_source) == 0); diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp index a19ab89..6c664a8 100644 --- a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp +++ b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp @@ -13,6 +13,7 @@ #include "frontend/bookshelfmanager/removepage/btremovepage.h" #include <QAction> +#include <QDebug> #include <QGroupBox> #include <QHBoxLayout> #include <QHeaderView> @@ -22,6 +23,7 @@ #include <QVBoxLayout> #include "backend/bookshelfmodel/btbookshelffiltermodel.h" #include "backend/managers/cswordbackend.h" +#include "frontend/bookshelfmanager/btmodulemanagerdialog.h" #include "frontend/btbookshelfview.h" #include "frontend/btbookshelfwidget.h" #include "util/cresmgr.h" @@ -37,12 +39,12 @@ namespace { const QString groupingOrderKey("GUI/BookshelfManager/RemovePage/grouping"); } -BtRemovePage::BtRemovePage(QWidget *parent) - : BtConfigPage(parent) +BtRemovePage::BtRemovePage(BtModuleManagerDialog *parent) + : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::removepage::icon), parent) { namespace DU = util::directory; - m_worksGroupBox = new QGroupBox(tr("Select &works to uninstall:"), this); + m_worksGroupBox = new QGroupBox(this); m_worksGroupBox->setFlat(true); QVBoxLayout *wLayout = new QVBoxLayout; wLayout->setContentsMargins(0, 0, 0, 0); @@ -65,20 +67,17 @@ BtRemovePage::BtRemovePage(QWidget *parent) m_uninstallGroupBox = new QGroupBox(this); m_uninstallGroupBox->setFlat(true); - retranslateUninstallGroupBox(); QHBoxLayout *uLayout = new QHBoxLayout; uLayout->setContentsMargins(0, 0, 0, 0); m_uninstallGroupBox->setLayout(uLayout); uLayout->addStretch(1); - m_removeButton = new QPushButton(tr("&Remove..."), this); - m_removeButton->setToolTip(tr("Remove the selected works")); + m_removeButton = new QPushButton(this); m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::removepage::remove_icon)); m_removeButton->setEnabled(false); uLayout->addWidget(m_removeButton, 0, Qt::AlignRight); - Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0); - QVBoxLayout *mainLayout = static_cast<QVBoxLayout*>(layout()); + QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(m_worksGroupBox, 1); mainLayout->addWidget(m_uninstallGroupBox); @@ -88,14 +87,19 @@ BtRemovePage::BtRemovePage(QWidget *parent) this, SLOT(slotResetRemoveButton())); connect(m_bookshelfWidget->treeModel(), SIGNAL(rowsRemoved(const QModelIndex&,int,int)), this, SLOT(slotResetRemoveButton())); -} -const QIcon &BtRemovePage::icon() const { - return util::directory::getIcon(CResMgr::bookshelfmgr::removepage::icon); + retranslateUi(); } -QString BtRemovePage::header() const { - return tr("Remove"); +void BtRemovePage::retranslateUi() { + setHeaderText(tr("Remove")); + + m_worksGroupBox->setTitle(tr("Select &works to uninstall:")); + + m_removeButton->setText(tr("&Remove...")); + m_removeButton->setToolTip(tr("Remove the selected works")); + + retranslateUninstallGroupBox(); } void BtRemovePage::retranslateUninstallGroupBox() { @@ -118,6 +122,7 @@ void BtRemovePage::slotRemoveModules() { if (m_bookshelfWidget->treeModel()->checkedModules().empty()) return; QStringList moduleNames; + QStringList prettyModuleNames; const int textHeight = fontMetrics().height(); /// \bug <nobr> is not working, Qt bug const QString moduleString("<nobr><img src=\"%1\" width=\"%2\" height=\"%3\"/> %4</nobr>"); @@ -127,15 +132,16 @@ void BtRemovePage::slotRemoveModules() { { const QIcon icon = CSwordModuleInfo::moduleIcon(m); const QSize iconSize = icon.actualSize(QSize(textHeight, textHeight)); - moduleNames.append(moduleString - .arg(iconDir + CSwordModuleInfo::moduleIconFilename(m)) - .arg(iconSize.width()) - .arg(iconSize.height()) - .arg(m->name())); + prettyModuleNames.append(moduleString + .arg(iconDir + CSwordModuleInfo::moduleIconFilename(m)) + .arg(iconSize.width()) + .arg(iconSize.height()) + .arg(m->name())); + moduleNames.append(m->name()); } const QString message = tr("You selected the following work(s): ") .append("<br/><br/> ") - .append(moduleNames.join(", ")) + .append(prettyModuleNames.join(", ")) .append("<br/><br/>") .append(tr("Do you really want to remove them from your system?")); @@ -143,6 +149,7 @@ void BtRemovePage::slotRemoveModules() { // Update the module list before really removing. Remember deleting the pointers later. QList<CSwordModuleInfo*> toBeDeleted = CSwordBackend::instance()->takeModulesFromList(moduleNames); + Q_ASSERT(toBeDeleted.size() == moduleNames.size()); sword::InstallMgr installMgr; QMap<QString, sword::SWMgr*> mgrDict; //maps config paths to SWMgr objects diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.h b/src/frontend/bookshelfmanager/removepage/btremovepage.h index 11017d0..02ff88e 100644 --- a/src/frontend/bookshelfmanager/removepage/btremovepage.h +++ b/src/frontend/bookshelfmanager/removepage/btremovepage.h @@ -22,35 +22,40 @@ class BtBookshelfWidget; +class BtModuleManagerDialog; class QGroupBox; class QPushButton; -class BtRemovePage: public BtConfigPage { +class BtRemovePage: public BtConfigDialog::Page { + Q_OBJECT - public: - BtRemovePage(QWidget *parent = 0); + public: /* Methods: */ + + BtRemovePage(BtModuleManagerDialog *parent = 0); + + public: /* Methods: */ - /** Reimplemented from BtConfigPage. */ - virtual QString header() const; + void retranslateUi(); - /** Reimplemented from BtConfigPage. */ - virtual const QIcon &icon() const; + private: /* Methods: */ - private: void retranslateUninstallGroupBox(); private slots: + void slotRemoveModules(); void slotResetRemoveButton(); void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g); - private: + private: /* Fields: */ + QGroupBox *m_worksGroupBox; BtBookshelfWidget *m_bookshelfWidget; QGroupBox *m_uninstallGroupBox; QPushButton *m_removeButton; + }; #endif |