From 00bc0a3de99e088902379dcb2905fb1546c7eca2 Mon Sep 17 00:00:00 2001 From: "Roberto C. Sanchez" Date: Tue, 21 Oct 2014 22:48:40 -0400 Subject: Imported Upstream version 2.9.1 --- .../bookshelfmanager/installpage/btinstallpage.cpp | 95 +++++++++++----------- .../bookshelfmanager/installpage/btinstallpage.h | 16 ++-- .../installpage/btinstallpageworkswidget.cpp | 4 - .../installpage/btinstallpathdialog.cpp | 5 -- .../installpage/btinstallprogressdialog.cpp | 19 +---- .../installpage/btinstallprogressdialog.h | 2 - .../installpage/btinstallthread.cpp | 9 -- .../installpage/btrefreshprogressdialog.cpp | 9 -- 8 files changed, 60 insertions(+), 99 deletions(-) (limited to 'src/frontend/bookshelfmanager/installpage') 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(layout()) != 0); - QVBoxLayout *mainLayout = static_cast(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(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 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 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::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 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::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(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 -#include #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); -- cgit v1.2.3