diff options
Diffstat (limited to 'src/frontend/btbookshelfwidget.cpp')
-rw-r--r-- | src/frontend/btbookshelfwidget.cpp | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/src/frontend/btbookshelfwidget.cpp b/src/frontend/btbookshelfwidget.cpp index 2ce812e..819cabe 100644 --- a/src/frontend/btbookshelfwidget.cpp +++ b/src/frontend/btbookshelfwidget.cpp @@ -4,7 +4,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2014 by the BibleTime developers. +* Copyright 1999-2016 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License * version 2.0. * @@ -25,22 +25,21 @@ #include <QVBoxLayout> #include "backend/bookshelfmodel/btbookshelffiltermodel.h" #include "bibletimeapp.h" -#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h" -#include "frontend/bookshelfmanager/removepage/btremovepagetreemodel.h" #include "frontend/btbookshelfdockwidget.h" #include "frontend/btbookshelfgroupingmenu.h" #include "frontend/btbookshelfview.h" +#include "util/btassert.h" +#include "util/btconnect.h" #include "util/cresmgr.h" #include "util/directory.h" -#include "util/geticon.h" BtBookshelfWidget::BtBookshelfWidget(QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags) - , m_sourceModel(0) - , m_treeModel(0) - , m_leftCornerWidget(0) - , m_rightCornerWidget(0) + , m_sourceModel(nullptr) + , m_treeModel(nullptr) + , m_leftCornerWidget(nullptr) + , m_rightCornerWidget(nullptr) { // Setup post-filter: m_postFilterModel = new BtBookshelfFilterModel(this); @@ -55,27 +54,28 @@ BtBookshelfWidget::BtBookshelfWidget(QWidget *parent, Qt::WindowFlags flags) retranslateUi(); - connect(m_nameFilterEdit, SIGNAL(textEdited(QString)), - m_postFilterModel, SLOT(setNameFilterFixedString(QString))); - connect(m_treeView, SIGNAL(contextMenuActivated(QPoint)), - this, SLOT(slotShowContextMenu(QPoint))); - connect(m_treeView, SIGNAL(moduleContextMenuActivated(CSwordModuleInfo*, QPoint)), - this, SLOT(slotShowItemContextMenu(CSwordModuleInfo*, QPoint))); + BT_CONNECT(m_nameFilterEdit, SIGNAL(textEdited(QString)), + m_postFilterModel, SLOT(setNameFilterFixedString(QString))); + BT_CONNECT(m_treeView, SIGNAL(contextMenuActivated(QPoint)), + this, SLOT(slotShowContextMenu(QPoint))); + BT_CONNECT(m_treeView, + SIGNAL(moduleContextMenuActivated(CSwordModuleInfo *, QPoint)), + this, SLOT(slotShowItemContextMenu(CSwordModuleInfo *, QPoint))); } void BtBookshelfWidget::setSourceModel(QAbstractItemModel *model) { - Q_ASSERT(model != 0); + BT_ASSERT(model); m_sourceModel = model; - if (m_treeModel != 0) { + if (m_treeModel != nullptr) { m_treeModel->setSourceModel(model); } } void BtBookshelfWidget::setTreeModel(BtBookshelfTreeModel *model) { - Q_ASSERT(model != 0); - Q_ASSERT(m_treeModel == 0); + BT_ASSERT(model); + BT_ASSERT(!m_treeModel); m_treeModel = model; - if (m_sourceModel != 0) { + if (m_sourceModel != nullptr) { model->setSourceModel(m_sourceModel); } m_postFilterModel->setSourceModel(model); @@ -94,23 +94,22 @@ void BtBookshelfWidget::setRightCornerWidget(QWidget *w) { } void BtBookshelfWidget::initActions() { - namespace RM = CResMgr::mainIndex; - m_showHideAction = new QAction(this); - m_showHideAction->setIcon(util::getIcon("layer-visible-on.svg")); + m_showHideAction->setIcon(CResMgr::mainIndex::showHide::icon()); m_showHideAction->setCheckable(true); - connect(m_showHideAction, SIGNAL(toggled(bool)), - m_postFilterModel, SLOT(setShowHidden(bool))); + BT_CONNECT(m_showHideAction, SIGNAL(toggled(bool)), + m_postFilterModel, SLOT(setShowHidden(bool))); } void BtBookshelfWidget::initMenus() { - namespace DU = util::directory; - namespace RM = CResMgr::mainIndex; - // Grouping menu: m_groupingMenu = new BtBookshelfGroupingMenu(this); - connect(m_groupingMenu, SIGNAL(signalGroupingOrderChanged(BtBookshelfTreeModel::Grouping)), - this, SLOT(slotGroupingActionTriggered(BtBookshelfTreeModel::Grouping))); + BT_CONNECT(m_groupingMenu, + SIGNAL(signalGroupingOrderChanged( + BtBookshelfTreeModel::Grouping)), + this, + SLOT(slotGroupingActionTriggered( + BtBookshelfTreeModel::Grouping))); // Context menu m_contextMenu = new QMenu(this); @@ -162,7 +161,7 @@ void BtBookshelfWidget::retranslateUi() { } bool BtBookshelfWidget::eventFilter(QObject *object, QEvent *event) { - Q_ASSERT(object == m_nameFilterEdit); + BT_ASSERT(object == m_nameFilterEdit); if (event->type() == QEvent::KeyPress) { QKeyEvent *e = static_cast<QKeyEvent*>(event); switch (e->key()) { @@ -190,8 +189,10 @@ void BtBookshelfWidget::slotShowContextMenu(const QPoint &pos) { void BtBookshelfWidget::slotShowItemContextMenu(CSwordModuleInfo *module, const QPoint &pos) { - if (m_itemContextMenu != 0) { - m_itemContextMenu->setProperty("BtModule", qVariantFromValue((void*) module)); + if (m_itemContextMenu != nullptr) { + m_itemContextMenu->setProperty("BtModule", + qVariantFromValue( + static_cast<void *>(module))); m_itemContextMenu->popup(pos); } else { m_itemContextMenu = m_contextMenu; |