Commit 7a9f8741 authored by Laurent Montel's avatar Laurent Montel 😁

Use nullptr + const'ref

parent 52300b02
......@@ -29,9 +29,9 @@
ApplicationsManager::ApplicationsManager(QWidget *parent):
QWidget(parent),
_wallet(0),
_connectedAppsModel(0),
_authorizedAppModel(0)
_wallet(nullptr),
_connectedAppsModel(nullptr),
_authorizedAppModel(nullptr)
{
setupUi(this);
}
......@@ -44,7 +44,7 @@ ApplicationsManager::~ApplicationsManager()
void ApplicationsManager::setWallet(KWallet::Wallet *wallet)
{
Q_ASSERT(wallet != 0);
Q_ASSERT(wallet != nullptr);
_wallet = wallet;
// create the disconnect widget menu
......
......@@ -23,7 +23,7 @@
AuthorizedApplicationsTable::AuthorizedApplicationsTable(QWidget *parent) :
QTableView(parent),
_wallet(0)
_wallet(nullptr)
{
}
......@@ -34,10 +34,10 @@ void AuthorizedApplicationsTable::setWallet(KWallet::Wallet *wallet)
void AuthorizedApplicationsTable::setModel(QAbstractItemModel *model)
{
Q_ASSERT(_wallet != 0);
Q_ASSERT(_wallet != nullptr);
AuthorizedAppModel *appModel = qobject_cast<AuthorizedAppModel *>(model);
Q_ASSERT(appModel != 0);
Q_ASSERT(appModel != nullptr);
QTableView::setModel(model);
for (int row = 0; row < model->rowCount(); row++) {
......
......@@ -67,6 +67,7 @@ void AuthorizedAppModel::removeApp(QString appName)
void AuthorizedAppModel::saveConfig()
{
QStringList appList;
appList.reserve(rowCount());
for (int r = 0; r < rowCount(); r++) {
appList << item(r)->text();
}
......
......@@ -26,7 +26,7 @@
ConnectedApplicationsTable::ConnectedApplicationsTable(QWidget *parent):
QTableView(parent),
_wallet(0)
_wallet(nullptr)
{
}
......@@ -37,10 +37,10 @@ void ConnectedApplicationsTable::setWallet(KWallet::Wallet *wallet)
void ConnectedApplicationsTable::setModel(QAbstractItemModel *model)
{
Q_ASSERT(_wallet != 0);
Q_ASSERT(_wallet != nullptr);
ConnectedAppModel *appModel = qobject_cast<ConnectedAppModel *>(model);
Q_ASSERT(appModel != 0);
Q_ASSERT(appModel != nullptr);
QTableView::setModel(model);
for (int row = 0; row < model->rowCount(); row++) {
......
......@@ -36,7 +36,7 @@ void ConnectedAppModel::refresh()
_connectedApps = KWallet::Wallet::users(_wallet->walletName());
int row = 0;
Q_FOREACH(QString appName, _connectedApps) {
Q_FOREACH(const QString &appName, _connectedApps) {
// for un unknown reason, kwalletd returs empty strings so lets avoid inserting them
// FIXME: find out why kwalletd returns empty strings here
if (appName.length() > 0) {
......@@ -51,7 +51,7 @@ void ConnectedAppModel::refresh()
}
}
void ConnectedAppModel::removeApp(QString appName)
void ConnectedAppModel::removeApp(const QString &appName)
{
if (_connectedAppsIndexMap.contains(appName)) {
QPersistentModelIndex idx = _connectedAppsIndexMap[appName];
......
......@@ -35,7 +35,7 @@ public:
public Q_SLOTS:
void refresh();
void removeApp(QString);
void removeApp(const QString &);
private:
KWallet::Wallet *_wallet;
......
......@@ -65,22 +65,22 @@
#include <assert.h>
#include <stdlib.h>
QAction *KWalletEditor::_newFolderAction = 0;
QAction *KWalletEditor::_deleteFolderAction = 0;
QAction *KWalletEditor::_exportAction = 0;
QAction *KWalletEditor::_mergeAction = 0;
QAction *KWalletEditor::_importAction = 0;
QAction *KWalletEditor::_newEntryAction = 0;
QAction *KWalletEditor::_renameEntryAction = 0;
QAction *KWalletEditor::_deleteEntryAction = 0;
QAction *KWalletEditor::_copyPassAction = 0;
QAction *KWalletEditor::_alwaysShowContentsAction = 0;
QAction *KWalletEditor::_alwaysHideContentsAction = 0;
QAction *KWalletEditor::_newFolderAction = nullptr;
QAction *KWalletEditor::_deleteFolderAction = nullptr;
QAction *KWalletEditor::_exportAction = nullptr;
QAction *KWalletEditor::_mergeAction = nullptr;
QAction *KWalletEditor::_importAction = nullptr;
QAction *KWalletEditor::_newEntryAction = nullptr;
QAction *KWalletEditor::_renameEntryAction = nullptr;
QAction *KWalletEditor::_deleteEntryAction = nullptr;
QAction *KWalletEditor::_copyPassAction = nullptr;
QAction *KWalletEditor::_alwaysShowContentsAction = nullptr;
QAction *KWalletEditor::_alwaysHideContentsAction = nullptr;
RegisterCreateActionsMethod KWalletEditor::_registerCreateActionMethod(&KWalletEditor::createActions);
KWalletEditor::KWalletEditor(QWidget *parent, const char *name)
: QWidget(parent), _displayedItem(0), _actionCollection(0), _alwaysShowContents(false)
: QWidget(parent), _displayedItem(0), _actionCollection(nullptr), _alwaysShowContents(false)
{
setupUi(this);
setObjectName(QLatin1String(name));
......@@ -156,17 +156,17 @@ KWalletEditor::~KWalletEditor()
cg.sync();
delete _w;
_w = 0L;
_w = nullptr;
if (_nonLocal) {
KWallet::Wallet::closeWallet(_walletName, true);
}
delete _contextMenu;
_contextMenu = NULL;
_contextMenu = nullptr;
}
void KWalletEditor::setWallet(KWallet::Wallet *wallet, bool isPath)
{
Q_ASSERT(wallet != 0);
Q_ASSERT(wallet != nullptr);
_walletName = wallet->walletName();
_nonLocal = isPath;
......@@ -191,7 +191,7 @@ void KWalletEditor::setWallet(KWallet::Wallet *wallet, bool isPath)
KActionCollection *KWalletEditor::actionCollection()
{
if (_actionCollection == 0) {
if (_actionCollection == nullptr) {
_actionCollection = new KActionCollection(this);
}
return _actionCollection;
......@@ -313,7 +313,7 @@ void KWalletEditor::disconnectActions()
void KWalletEditor::walletClosed()
{
_w = 0L;
_w = nullptr;
setEnabled(false);
emit enableWalletActions(false);
emit enableFolderActions(false);
......
......@@ -104,12 +104,12 @@ void KWalletManager::configUI() {
}
if (!isOpen && qApp->isSessionRestored()) {
delete _tray;
_tray = 0;
_tray = nullptr;
QTimer::singleShot(0, qApp, SLOT(quit()));
return;
}
} else {
_tray = 0;
_tray = nullptr;
}
_managerWidget = new KWalletManagerWidget(this);
......@@ -192,9 +192,9 @@ void KWalletManager::configUI() {
KWalletManager::~KWalletManager()
{
_tray = 0L;
_tray = nullptr;
delete m_kwalletdModule;
m_kwalletdModule = 0L;
m_kwalletdModule = nullptr;
}
void KWalletManager::kwalletdLaunch()
......
......@@ -37,9 +37,9 @@
WalletControlWidget::WalletControlWidget(QWidget *parent, const QString &walletName):
QWidget(parent),
_walletName(walletName),
_wallet(0),
_walletEditor(0),
_applicationsManager(0)
_wallet(nullptr),
_walletEditor(nullptr),
_applicationsManager(nullptr)
{
setupUi(this);
onSetupWidget();
......@@ -54,7 +54,7 @@ bool WalletControlWidget::openWallet()
result = true; // already opened
} else {
_wallet = KWallet::Wallet::openWallet(_walletName, effectiveWinId());
result = _wallet != 0;
result = _wallet != nullptr;
onSetupWidget();
}
return result;
......@@ -63,9 +63,9 @@ bool WalletControlWidget::openWallet()
void WalletControlWidget::onSetupWidget()
{
if (KWallet::Wallet::isOpen(_walletName)) {
if (0 == _wallet) {
if (nullptr == _wallet) {
_wallet = KWallet::Wallet::openWallet(_walletName, effectiveWinId());
if (0 == _wallet) {
if (nullptr == _wallet) {
qDebug() << "Weird situation: wallet could not be opened when setting-up the widget.";
}
}
......@@ -75,14 +75,14 @@ void WalletControlWidget::onSetupWidget()
connect(_wallet, &KWallet::Wallet::walletClosed, this, &WalletControlWidget::onWalletClosed);
_openClose->setText(i18n("&Close"));
if (0 == _walletEditor) {
if (nullptr == _walletEditor) {
_walletEditor = new KWalletEditor(_editorFrame);
_editorFrameLayout->addWidget(_walletEditor);
_walletEditor->setVisible(true);
}
_walletEditor->setWallet(_wallet);
if (0 == _applicationsManager) {
if (nullptr == _applicationsManager) {
_applicationsManager = new ApplicationsManager(_applicationsFrame);
_applicationsFrameLayout->addWidget(_applicationsManager);
_applicationsManager->setVisible(true);
......@@ -97,16 +97,16 @@ void WalletControlWidget::onSetupWidget()
if (_walletEditor) {
_walletEditor->setVisible(false);
delete _walletEditor, _walletEditor = 0;
delete _walletEditor, _walletEditor = nullptr;
}
if (_applicationsManager) {
_applicationsManager->setVisible(false);
delete _applicationsManager, _applicationsManager = 0;
delete _applicationsManager, _applicationsManager = nullptr;
}
_changePassword->setEnabled(false);
_stateLabel->setText(i18n("The wallet is currently closed"));
_tabs->setTabIcon(0, QIcon::fromTheme(QLatin1String("wallet-closed")).pixmap(16));
_tabs->setTabIcon(0, QIcon::fromTheme(QStringLiteral("wallet-closed")).pixmap(16));
}
}
......@@ -129,11 +129,11 @@ void WalletControlWidget::onOpenClose()
if (rc != 0) {
KMessageBox::sorry(this, i18n("Unable to force the wallet closed. Error code was %1.", rc));
} else {
_wallet = 0;
_wallet = nullptr;
}
}
} else {
_wallet = 0;
_wallet = nullptr;
}
} else {
_wallet = KWallet::Wallet::openWallet(_walletName, window()->winId());
......@@ -143,7 +143,7 @@ void WalletControlWidget::onOpenClose()
void WalletControlWidget::onWalletClosed()
{
_wallet = 0;
_wallet = nullptr;
onSetupWidget();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment