summaryrefslogtreecommitdiff
path: root/src/frontend/btmenuview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/btmenuview.cpp')
-rw-r--r--src/frontend/btmenuview.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/frontend/btmenuview.cpp b/src/frontend/btmenuview.cpp
index 919602b..d422de2 100644
--- a/src/frontend/btmenuview.cpp
+++ b/src/frontend/btmenuview.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.
*
@@ -13,15 +13,17 @@
#include "frontend/btmenuview.h"
#include <QActionGroup>
+#include "util/btassert.h"
+#include "util/btconnect.h"
BtMenuView::BtMenuView(QWidget *parent)
- : QMenu(parent), m_model(0), m_parentIndex(QModelIndex()), m_actions(0)
+ : QMenu(parent), m_model(nullptr), m_parentIndex(QModelIndex()), m_actions(nullptr)
{
- connect(this, SIGNAL(aboutToShow()),
- this, SLOT(slotAboutToShow()));
- connect(this, SIGNAL(triggered(QAction*)),
- this, SLOT(slotActionTriggered(QAction*)));
+ BT_CONNECT(this, SIGNAL(aboutToShow()),
+ this, SLOT(slotAboutToShow()));
+ BT_CONNECT(this, SIGNAL(triggered(QAction*)),
+ this, SLOT(slotActionTriggered(QAction*)));
}
BtMenuView::~BtMenuView() {
@@ -31,7 +33,7 @@ BtMenuView::~BtMenuView() {
void BtMenuView::setModel(QAbstractItemModel *model) {
m_model = model;
delete m_actions;
- m_actions = 0;
+ m_actions = nullptr;
m_indexMap.clear();
m_parentIndex = QModelIndex();
}
@@ -91,10 +93,10 @@ QAction *BtMenuView::newAction(QMenu *parentMenu, const QModelIndex &itemIndex)
// Set checked:
QVariant checkData(m_model->data(itemIndex, Qt::CheckStateRole));
bool ok;
- Qt::CheckState state = (Qt::CheckState) checkData.toInt(&ok);
- if (ok) {
+ Qt::CheckState const state =
+ static_cast<Qt::CheckState>(checkData.toInt(&ok));
+ if (ok)
childAction->setChecked(state == Qt::Checked);
- }
return childAction;
}
@@ -137,8 +139,8 @@ QMenu *BtMenuView::newMenu(QMenu *parentMenu, const QModelIndex &itemIndex) {
}
void BtMenuView::buildMenu(QMenu *parentMenu, const QModelIndex &parentIndex) {
- Q_ASSERT(m_model != 0);
- Q_ASSERT(m_actions != 0);
+ BT_ASSERT(m_model);
+ BT_ASSERT(m_actions);
int children = m_model->rowCount(parentIndex);
for (int i = 0; i < children; i++) {
@@ -147,7 +149,7 @@ void BtMenuView::buildMenu(QMenu *parentMenu, const QModelIndex &parentIndex) {
if (m_model->rowCount(childIndex) > 0) {
QMenu *childMenu = newMenu(parentMenu, childIndex);
- if (childMenu != 0) {
+ if (childMenu != nullptr) {
// Add the child menu and populate it:
parentMenu->addMenu(childMenu);
buildMenu(childMenu, childIndex);
@@ -155,7 +157,7 @@ void BtMenuView::buildMenu(QMenu *parentMenu, const QModelIndex &parentIndex) {
} else {
QAction *childAction = newAction(parentMenu, childIndex);
- if (childAction != 0) {
+ if (childAction != nullptr) {
// Map index
m_indexMap.insert(childAction, childIndex);
@@ -175,12 +177,12 @@ void BtMenuView::slotAboutToShow() {
// to remove the menus here.
removeMenus();
delete m_actions;
- m_actions = 0;
+ m_actions = nullptr;
m_indexMap.clear();
preBuildMenu();
- if (m_model != 0) {
+ if (m_model != nullptr) {
m_actions = new QActionGroup(this);
buildMenu(this, m_parentIndex);