diff options
Diffstat (limited to 'src/frontend/btopenworkaction.cpp')
-rw-r--r-- | src/frontend/btopenworkaction.cpp | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/src/frontend/btopenworkaction.cpp b/src/frontend/btopenworkaction.cpp index a398412..2a5aae3 100644 --- a/src/frontend/btopenworkaction.cpp +++ b/src/frontend/btopenworkaction.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. * @@ -16,13 +16,17 @@ #include "backend/managers/cswordbackend.h" #include "bibletimeapp.h" #include "frontend/btbookshelfgroupingmenu.h" -#include "util/geticon.h" +#include "util/btconnect.h" +#include "util/cresmgr.h" BtOpenWorkActionMenu::BtOpenWorkActionMenu(const QString &groupingConfigKey, QWidget *parent) - : BtMenuView(parent), m_treeModel(0), m_postFilterModel(0), - m_groupingConfigKey(groupingConfigKey) + : BtMenuView(parent) + , m_treeModel(nullptr) + , m_postFilterModel(nullptr) + , m_groupingMenu(nullptr) + , m_groupingConfigKey(groupingConfigKey) { // Setup models: m_treeModel = new BtBookshelfTreeModel(groupingConfigKey, this); @@ -30,8 +34,8 @@ BtOpenWorkActionMenu::BtOpenWorkActionMenu(const QString &groupingConfigKey, m_postFilterModel->setSourceModel(m_treeModel); setModel(m_postFilterModel); - connect(this, SIGNAL(triggered(QModelIndex)), - this, SLOT(slotIndexTriggered(QModelIndex))); + BT_CONNECT(this, SIGNAL(triggered(QModelIndex)), + this, SLOT(slotIndexTriggered(QModelIndex))); } void BtOpenWorkActionMenu::setSourceModel(QAbstractItemModel *model) { @@ -39,6 +43,8 @@ void BtOpenWorkActionMenu::setSourceModel(QAbstractItemModel *model) { } void BtOpenWorkActionMenu::retranslateUi() { + if (!m_groupingMenu) + return; m_groupingMenu->setTitle(tr("&Grouping order")); m_groupingMenu->setStatusTip(tr("Sets the grouping order for the items in " "this menu.")); @@ -48,8 +54,12 @@ void BtOpenWorkActionMenu::postBuildMenu() { addSeparator(); m_groupingMenu = new BtBookshelfGroupingMenu(false, 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))); retranslateUi(); addMenu(m_groupingMenu); @@ -60,7 +70,7 @@ void BtOpenWorkActionMenu::slotIndexTriggered(const QModelIndex &index) { CSwordModuleInfo *i; i = static_cast<CSwordModuleInfo *>(model()->data(index, MPR).value<void*>()); - if (i != 0) { + if (i != nullptr) { emit triggered(i); } } @@ -78,21 +88,21 @@ BtOpenWorkAction::BtOpenWorkAction(const QString &groupingConfigKey, m_menu->setSourceModel(CSwordBackend::instance()->model()); setMenu(m_menu); - setIcon(util::getIcon("folder-open.svg")); + setIcon(CResMgr::mainWindow::icon_openAction()); retranslateUi(); slotModelChanged(); BtBookshelfFilterModel *filterModel = m_menu->postFilterModel(); - connect(m_menu, SIGNAL(triggered(CSwordModuleInfo*)), - this, SIGNAL(triggered(CSwordModuleInfo*))); - connect(filterModel, SIGNAL(layoutChanged()), - this, SLOT(slotModelChanged())); - connect(filterModel, SIGNAL(modelReset()), - this, SLOT(slotModelChanged())); - connect(filterModel, SIGNAL(rowsInserted(QModelIndex, int, int)), - this, SLOT(slotModelChanged())); - connect(filterModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), - this, SLOT(slotModelChanged())); + BT_CONNECT(m_menu, SIGNAL(triggered(CSwordModuleInfo *)), + this, SIGNAL(triggered(CSwordModuleInfo *))); + BT_CONNECT(filterModel, SIGNAL(layoutChanged()), + this, SLOT(slotModelChanged())); + BT_CONNECT(filterModel, SIGNAL(modelReset()), + this, SLOT(slotModelChanged())); + BT_CONNECT(filterModel, SIGNAL(rowsInserted(QModelIndex, int, int)), + this, SLOT(slotModelChanged())); + BT_CONNECT(filterModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), + this, SLOT(slotModelChanged())); } BtOpenWorkAction::~BtOpenWorkAction() { |