diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:48:31 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:48:31 -0400 |
commit | 294b5ec5834affa57641475946b8d2aeca53c577 (patch) | |
tree | ca25b634d0f24ab5b1fc38eb805e72e0e993e0f1 /src/frontend/bookshelfmanager/installpage/btsourcearea.cpp | |
parent | e8a196082586bb68e0bf254a8f6f4b8f39071f32 (diff) |
Imported Upstream version 2.4
Diffstat (limited to 'src/frontend/bookshelfmanager/installpage/btsourcearea.cpp')
-rw-r--r-- | src/frontend/bookshelfmanager/installpage/btsourcearea.cpp | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp b/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp index cfdc8bb..ca85822 100644 --- a/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp +++ b/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp @@ -7,19 +7,7 @@ * **********/ -#include "btsourcearea.h" - -#include "frontend/bookshelfmanager/instbackend.h" - -#include "util/ctoolclass.h" -#include "util/cpointers.h" -#include "util/cresmgr.h" -#include "util/directoryutil.h" - -#include "backend/managers/cswordbackend.h" -#include "frontend/btaboutmoduledialog.h" - -#include <installmgr.h> +#include "frontend/bookshelfmanager/installpage/btsourcearea.h" #include <QString> #include <QWidget> @@ -32,9 +20,19 @@ #include <QTreeWidget> #include <QTreeWidgetItem> #include <QHeaderView> - #include <QDebug> #include <QTime> +#include "backend/managers/cswordbackend.h" +#include "frontend/bookshelfmanager/instbackend.h" +#include "frontend/btaboutmoduledialog.h" +#include "util/directory.h" +#include "util/cpointers.h" +#include "util/cresmgr.h" +#include "util/tool.h" + +// Sword includes: +#include <installmgr.h> + // **************************************************************** // ******** Installation source and module list widget ************ @@ -45,46 +43,40 @@ BtSourceArea::BtSourceArea(const QString& sourceName) m_sourceName(sourceName), m_treeAlreadyInitialized(false), m_remoteBackend(0) { //important! + setObjectName(sourceName); m_checkedModules = QMap<QString, bool>(); qDebug() << "BtSourceArea::BtSourceArea, " << m_sourceName; initView(); } BtSourceArea::~BtSourceArea() { + qDebug() << "BtSourceArea::~BtSourceArea" << m_sourceName; delete m_remoteBackend; } void BtSourceArea::initView() { - qDebug("BtSourceArea::initView"); + namespace DU = util::directory; + + qDebug() << "BtSourceArea::initView"; QVBoxLayout *mainLayout = new QVBoxLayout(this); - //QHBoxLayout *refreshLabelLayout = new QHBoxLayout(); - //QLabel *refreshLabel = new QLabel(tr("Last refreshed:")); - //m_refreshTimeLabel = new QLabel(); - //QSpacerItem *refreshLabelSpacer = new QSpacerItem(201, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - //refreshLabelLayout->addWidget(refreshLabel); - //refreshLabelLayout->addWidget(m_refreshTimeLabel); - //refreshLabelLayout->addItem(refreshLabelSpacer); - // TODO: or would it be better to integrate this information into the tooltip - // of the source tab? - //mainLayout->addLayout(refreshLabelLayout); // source related button row QHBoxLayout *sourceLayout = new QHBoxLayout(); m_refreshButton = new QPushButton(tr("Refresh...")); m_refreshButton->setToolTip(tr("Refresh the list of works from this source")); - m_refreshButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon)); + m_refreshButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon)); //m_refreshButton->setEnabled(false); QSpacerItem *sourceSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); //m_editButton = new QPushButton(tr("Edit...")); - //m_editButton->setEnabled(false); // TODO after writing the edit widget + /// \todo after writing the edit widget: + //m_editButton->setEnabled(false); m_deleteButton = new QPushButton(tr("Delete...")); m_deleteButton->setToolTip(tr("Delete this source")); - m_deleteButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon)); + m_deleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon)); //m_deleteButton->setEnabled(false); m_addButton = new QPushButton(tr("Add...")); m_addButton->setToolTip(tr("Add new source")); - m_addButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::installpage::add_icon)); + m_addButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::add_icon)); sourceLayout->addWidget(m_refreshButton); sourceLayout->addItem(sourceSpacer); @@ -96,7 +88,7 @@ void BtSourceArea::initView() { // There are no views for the stack yet, see initSources m_view = new QTreeWidget(this); m_view->setHeaderLabels(QStringList() << tr("Work") << tr("Description")); - m_view->setColumnWidth(0, CToolClass::mWidth(m_view, 20)); + m_view->setColumnWidth(0, util::tool::mWidth(m_view, 20)); mainLayout->addWidget(m_view); connect(m_view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(slotItemDoubleClicked(QTreeWidgetItem*, int))); @@ -104,6 +96,11 @@ void BtSourceArea::initView() { connect(this, SIGNAL(signalCreateTree()), SLOT(slotCreateTree()), Qt::QueuedConnection); } +void BtSourceArea::prepareRemove() { + // don't create tree anymore, this will be removed + disconnect(this, SIGNAL(signalCreateTree()), this, SLOT(slotCreateTree())); +} + QSize BtSourceArea::sizeHint() const { return QSize(100, m_refreshButton->height() + (m_view->header()->height() * 5)); } @@ -116,7 +113,7 @@ void BtSourceArea::initTreeFirstTime() { } void BtSourceArea::createModuleTree() { - qDebug("BtSourceArea::createModuleTree start"); + qDebug() << "BtSourceArea::createModuleTree start"; // Start creating tree with a queued connection. // This makes showing the dialog possible even before the tree is initialized. emit signalCreateTree(); @@ -133,8 +130,7 @@ void BtSourceArea::slotCreateTree() { disconnect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) ); m_view->clear(); - // TODO: if the tree already exists for this source, - // maybe the selections should be preserved + /// \todo if the tree already exists for this source, maybe the selections should be preserved m_checkedModules.clear(); sword::InstallSource is = instbackend::source(m_sourceName); @@ -181,11 +177,13 @@ void BtSourceArea::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem QString installedV; if (!installedModule) { - // possible TODO: save the module list of a source before refreshing, - // compare after refreshing, mark the newly added modules - //if not newly added: - //state: installable (no indicator) - //else: status: newly added, color yellow + /** + \todo maybe? save the module list of a source before refreshing, + compare after refreshing, mark the newly added modules if + not newly added: + state: installable (no indicator) + else: status: newly added, color yellow + */ } else { // the module is already installed QBrush bg(QColor(255, 153, 153)); /// \bug Possible color conflict widgetItem->setBackground(0, bg); @@ -206,7 +204,7 @@ void BtSourceArea::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem QString descr(mInfo->config(CSwordModuleInfo::Description)); - QString toolTipText = CToolClass::remoteModuleToolTip(mInfo, installedV); + QString toolTipText = util::tool::remoteModuleToolTip(mInfo, installedV); widgetItem->setText(1, descr); widgetItem->setToolTip(0, toolTipText); @@ -226,7 +224,7 @@ QMap<QString, bool>* BtSourceArea::selectedModules() { // when a module is checked/unchecked void BtSourceArea::slotSelectionChanged(QTreeWidgetItem* item, int column) { - //qDebug("BtSourceArea::slotSelectionChanged"); + //qDebug() << "BtSourceArea::slotSelectionChanged"; // modify the internal list of selected (actually checked) modules // if() leaves groups away if (!item->childCount() && column == 0) { @@ -269,7 +267,7 @@ bool BtSourceArea::InstalledFilter::filter(CSwordModuleInfo* mInfo) { //qDebug() << "BtSourceArea::InstalledFilter::filter, module " << mInfo->name(); CSwordModuleInfo* const installedModule = CPointers::backend()->findModuleByName(mInfo->name()); if (installedModule) { - //qDebug("already installed, check if it's an update..."); + //qDebug() << "already installed, check if it's an update..."; const sword::SWVersion installedVersion(installedModule->config(CSwordModuleInfo::ModuleVersion).toLatin1()); const sword::SWVersion newVersion(mInfo->config(CSwordModuleInfo::ModuleVersion).toLatin1()); if (installedVersion >= newVersion) { |