From: Peter Penz Date: Wed, 9 Feb 2011 18:21:58 +0000 (+0100) Subject: Coding style update for pointer comparison X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/d3496b12310d9fec0e52e537c341e87fcaa2f8b5 Coding style update for pointer comparison Most developers seem to prefer if (ptr) ... if (!ptr) ... in comparison to if (ptr != 0) ... if (ptr == 0) ... Adjusted the Dolphin-code to use the "most-prefered style" to make contributors happy. --- diff --git a/src/dolphinapplication.cpp b/src/dolphinapplication.cpp index d37fa78de..468c7a0f7 100644 --- a/src/dolphinapplication.cpp +++ b/src/dolphinapplication.cpp @@ -37,7 +37,7 @@ DolphinApplication::DolphinApplication() : DolphinApplication::~DolphinApplication() { // cleanup what ever is left from the MainWindows - while (m_mainWindows.count() != 0) { + while (!m_mainWindows.isEmpty()) { delete m_mainWindows.takeFirst(); } } diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index d7de33cb4..9b6512aa2 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -81,7 +81,7 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, const DolphinView* view = m_mainWindow->activeViewContainer()->view(); m_selectedItems = view->selectedItems(); - if (m_keyInfo != 0) { + if (m_keyInfo) { if (m_keyInfo->isKeyPressed(Qt::Key_Shift) || m_keyInfo->isKeyLatched(Qt::Key_Shift)) { m_shiftPressed = true; } @@ -306,7 +306,7 @@ void DolphinContextMenu::openItemContextMenu() m_popup->addAction(propertiesAction); QAction* activatedAction = m_popup->exec(QCursor::pos()); - if (activatedAction != 0) { + if (activatedAction) { if (activatedAction == addToPlacesAction) { const KUrl selectedUrl(m_fileInfo.url()); if (selectedUrl.isValid()) { @@ -374,7 +374,7 @@ void DolphinContextMenu::openViewportContextMenu() KPropertiesDialog* dialog = new KPropertiesDialog(url, m_mainWindow); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); - } else if ((addToPlacesAction != 0) && (action == addToPlacesAction)) { + } else if (addToPlacesAction && (action == addToPlacesAction)) { const KUrl& url = m_mainWindow->activeViewContainer()->url(); if (url.isValid()) { DolphinSettings::instance().placesModel()->addPlace(placesName(url), url); @@ -459,7 +459,7 @@ QAction* DolphinContextMenu::createPasteAction() KFileItemListProperties& DolphinContextMenu::selectedItemsProperties() { - if (m_selectedItemsProperties == 0) { + if (!m_selectedItemsProperties) { m_selectedItemsProperties = new KFileItemListProperties(m_selectedItems); } return *m_selectedItemsProperties; @@ -467,7 +467,7 @@ KFileItemListProperties& DolphinContextMenu::selectedItemsProperties() KFileItem DolphinContextMenu::baseFileItem() { - if (m_baseFileItem == 0) { + if (!m_baseFileItem) { m_baseFileItem = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_baseUrl); } return *m_baseFileItem; diff --git a/src/dolphindockwidget.cpp b/src/dolphindockwidget.cpp index f7ee16fdc..72e06a656 100644 --- a/src/dolphindockwidget.cpp +++ b/src/dolphindockwidget.cpp @@ -64,7 +64,7 @@ void DolphinDockWidget::setLocked(bool lock) m_locked = lock; if (lock) { - if (m_dockTitleBar == 0) { + if (!m_dockTitleBar) { m_dockTitleBar = new DolphinDockTitleBar(this); } setTitleBarWidget(m_dockTitleBar); diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index f0335a4cd..11597fe1e 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -213,7 +213,7 @@ void DolphinMainWindow::openFiles(const QList& files) const int tabCount = m_viewTab.count(); for (int i = 0; i < tabCount; ++i) { m_viewTab[i].primaryView->view()->markUrlsAsSelected(files); - if (m_viewTab[i].secondaryView != 0) { + if (m_viewTab[i].secondaryView) { m_viewTab[i].secondaryView->view()->markUrlsAsSelected(files); } } @@ -256,7 +256,7 @@ void DolphinMainWindow::showCommand(CommandType command) void DolphinMainWindow::refreshViews() { - Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0); + Q_ASSERT(m_viewTab[m_tabIndex].primaryView); // remember the current active view, as because of // the refreshing the active view might change to @@ -266,7 +266,7 @@ void DolphinMainWindow::refreshViews() const int tabCount = m_viewTab.count(); for (int i = 0; i < tabCount; ++i) { m_viewTab[i].primaryView->refresh(); - if (m_viewTab[i].secondaryView != 0) { + if (m_viewTab[i].secondaryView) { m_viewTab[i].secondaryView->refresh(); } } @@ -279,8 +279,8 @@ void DolphinMainWindow::refreshViews() // Synchronize the split-view setting with the active view: const bool splitView = generalSettings->splitView(); const ViewTab& activeTab = m_viewTab[m_tabIndex]; - const bool toggle = ( splitView && (activeTab.secondaryView == 0)) - || (!splitView && (activeTab.secondaryView != 0)); + const bool toggle = ( splitView && !activeTab.secondaryView) + || (!splitView && activeTab.secondaryView); if (toggle) { toggleSplitView(); } @@ -302,7 +302,7 @@ void DolphinMainWindow::changeUrl(const KUrl& url) } DolphinViewContainer* view = activeViewContainer(); - if (view != 0) { + if (view) { view->setUrl(url); updateEditActions(); updateViewActions(); @@ -328,9 +328,9 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) { updateEditActions(); - Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0); + Q_ASSERT(m_viewTab[m_tabIndex].primaryView); int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedItemsCount(); - if (m_viewTab[m_tabIndex].secondaryView != 0) { + if (m_viewTab[m_tabIndex].secondaryView) { selectedUrlsCount += m_viewTab[m_tabIndex].secondaryView->view()->selectedItemsCount(); } @@ -356,13 +356,13 @@ void DolphinMainWindow::updateHistory() QAction* backAction = actionCollection()->action("go_back"); backAction->setToolTip(i18nc("@info", "Go back")); - if (backAction != 0) { + if (backAction) { backAction->setEnabled(index < urlNavigator->historySize() - 1); } QAction* forwardAction = actionCollection()->action("go_forward"); forwardAction->setToolTip(i18nc("@info", "Go forward")); - if (forwardAction != 0) { + if (forwardAction) { forwardAction->setEnabled(index > 0); } } @@ -434,7 +434,7 @@ void DolphinMainWindow::openNewTab(const KUrl& url) m_viewTab[tabIndex].isPrimaryViewActive = false; } - if (focusWidget != 0) { + if (focusWidget) { // The DolphinViewContainer grabbed the keyboard focus. As the tab is opened // in background, assure that the previous focused widget gets the focus back. focusWidget->setFocus(); @@ -494,13 +494,13 @@ void DolphinMainWindow::openInNewWindow() void DolphinMainWindow::toggleActiveView() { - if (m_viewTab[m_tabIndex].secondaryView == 0) { + if (!m_viewTab[m_tabIndex].secondaryView) { // only one view is available return; } - Q_ASSERT(m_activeViewContainer != 0); - Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0); + Q_ASSERT(m_activeViewContainer); + Q_ASSERT(m_viewTab[m_tabIndex].primaryView); DolphinViewContainer* left = m_viewTab[m_tabIndex].primaryView; DolphinViewContainer* right = m_viewTab[m_tabIndex].secondaryView; @@ -576,7 +576,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) if (m_filterDockIsTemporaryVisible) { QDockWidget* filterDock = findChild("filterDock"); - if (filterDock != 0) { + if (filterDock) { filterDock->hide(); } m_filterDockIsTemporaryVisible = false; @@ -598,7 +598,7 @@ void DolphinMainWindow::saveProperties(KConfigGroup& group) cont->urlNavigator()->isUrlEditable()); cont = m_viewTab[i].secondaryView; - if (cont != 0) { + if (cont) { group.writeEntry(tabProperty("Secondary URL", i), cont->url().url()); group.writeEntry(tabProperty("Secondary Editable", i), cont->urlNavigator()->isUrlEditable()); @@ -619,18 +619,18 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group) cont = m_viewTab[i].secondaryView; const QString secondaryUrl = group.readEntry(tabProperty("Secondary URL", i)); if (!secondaryUrl.isEmpty()) { - if (cont == 0) { + if (!cont) { // a secondary view should be shown, but no one is available // currently -> create a new view toggleSplitView(); cont = m_viewTab[i].secondaryView; - Q_ASSERT(cont != 0); + Q_ASSERT(cont); } cont->setUrl(secondaryUrl); const bool editable = group.readEntry(tabProperty("Secondary Editable", i), false); cont->urlNavigator()->setUrlEditable(editable); - } else if (cont != 0) { + } else if (cont) { // no secondary view should be shown, but the default setting shows // one already -> close the view toggleSplitView(); @@ -676,7 +676,7 @@ void DolphinMainWindow::showErrorMessage(const QString& message) void DolphinMainWindow::slotUndoAvailable(bool available) { QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo)); - if (undoAction != 0) { + if (undoAction) { undoAction->setEnabled(available); } } @@ -713,7 +713,7 @@ void DolphinMainWindow::restoreClosedTab(QAction* action) void DolphinMainWindow::slotUndoTextChanged(const QString& text) { QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo)); - if (undoAction != 0) { + if (undoAction) { undoAction->setText(text); } } @@ -779,7 +779,7 @@ void DolphinMainWindow::invertSelection() void DolphinMainWindow::toggleSplitView() { - if (m_viewTab[m_tabIndex].secondaryView == 0) { + if (!m_viewTab[m_tabIndex].secondaryView) { createSecondaryView(m_tabIndex); setActiveViewContainer(m_viewTab[m_tabIndex].secondaryView); } else if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) { @@ -859,7 +859,7 @@ void DolphinMainWindow::togglePanelLockState() const bool newLockState = !generalSettings->lockPanels(); foreach (QObject* child, children()) { DolphinDockWidget* dock = qobject_cast(child); - if (dock != 0) { + if (dock) { dock->setLocked(newLockState); } } @@ -935,7 +935,7 @@ void DolphinMainWindow::compareFiles() // - both in the secondary view // - one in the primary view and the other in the secondary // view - Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0); + Q_ASSERT(m_viewTab[m_tabIndex].primaryView); KUrl urlA; KUrl urlB; @@ -944,7 +944,7 @@ void DolphinMainWindow::compareFiles() switch (items.count()) { case 0: { - Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0); + Q_ASSERT(m_viewTab[m_tabIndex].secondaryView); items = m_viewTab[m_tabIndex].secondaryView->view()->selectedItems(); Q_ASSERT(items.count() == 2); urlA = items[0].url(); @@ -954,7 +954,7 @@ void DolphinMainWindow::compareFiles() case 1: { urlA = items[0].url(); - Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0); + Q_ASSERT(m_viewTab[m_tabIndex].secondaryView); items = m_viewTab[m_tabIndex].secondaryView->view()->selectedItems(); Q_ASSERT(items.count() == 1); urlB = items[0].url(); @@ -1006,7 +1006,7 @@ void DolphinMainWindow::openTerminal() void DolphinMainWindow::editSettings() { - if (m_settingsDialog == 0) { + if (!m_settingsDialog) { const KUrl url = activeViewContainer()->url(); m_settingsDialog = new DolphinSettingsDialog(url, this); m_settingsDialog->setAttribute(Qt::WA_DeleteOnClose); @@ -1028,7 +1028,7 @@ void DolphinMainWindow::setActiveTab(int index) ViewTab& hiddenTab = m_viewTab[m_tabIndex]; hiddenTab.isPrimaryViewActive = hiddenTab.primaryView->isActive(); hiddenTab.primaryView->setActive(false); - if (hiddenTab.secondaryView != 0) { + if (hiddenTab.secondaryView) { hiddenTab.secondaryView->setActive(false); } QSplitter* splitter = m_viewTab[m_tabIndex].splitter; @@ -1041,7 +1041,7 @@ void DolphinMainWindow::setActiveTab(int index) ViewTab& viewTab = m_viewTab[index]; m_centralWidgetLayout->addWidget(viewTab.splitter, 1); viewTab.primaryView->show(); - if (viewTab.secondaryView != 0) { + if (viewTab.secondaryView) { viewTab.secondaryView->show(); } viewTab.splitter->show(); @@ -1073,7 +1073,7 @@ void DolphinMainWindow::closeTab(int index) // delete tab m_viewTab[index].primaryView->deleteLater(); - if (m_viewTab[index].secondaryView != 0) { + if (m_viewTab[index].secondaryView) { m_viewTab[index].secondaryView->deleteLater(); } m_viewTab[index].splitter->deleteLater(); @@ -1113,21 +1113,21 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos) QAction* selectedAction = menu.exec(pos); if (selectedAction == newTabAction) { const ViewTab& tab = m_viewTab[index]; - Q_ASSERT(tab.primaryView != 0); - const KUrl url = (tab.secondaryView != 0) && tab.secondaryView->isActive() ? + Q_ASSERT(tab.primaryView); + const KUrl url = tab.secondaryView && tab.secondaryView->isActive() ? tab.secondaryView->url() : tab.primaryView->url(); openNewTab(url); m_tabBar->setCurrentIndex(m_viewTab.count() - 1); } else if (selectedAction == detachTabAction) { const ViewTab& tab = m_viewTab[index]; - Q_ASSERT(tab.primaryView != 0); + Q_ASSERT(tab.primaryView); const KUrl primaryUrl = tab.primaryView->url(); DolphinMainWindow* window = DolphinApplication::app()->createMainWindow(); window->changeUrl(primaryUrl); - if (tab.secondaryView != 0) { + if (tab.secondaryView) { const KUrl secondaryUrl = tab.secondaryView->url(); - if (window->m_viewTab[0].secondaryView == 0) { + if (!window->m_viewTab[0].secondaryView) { window->toggleSplitView(); } window->m_viewTab[0].secondaryView->setUrl(secondaryUrl); @@ -1228,7 +1228,7 @@ void DolphinMainWindow::slotSearchModeChanged(bool enabled) } QDockWidget* filterDock = findChild("filterDock"); - if (filterDock == 0) { + if (!filterDock) { return; } @@ -1375,7 +1375,7 @@ void DolphinMainWindow::init() void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer) { - Q_ASSERT(viewContainer != 0); + Q_ASSERT(viewContainer); Q_ASSERT((viewContainer == m_viewTab[m_tabIndex].primaryView) || (viewContainer == m_viewTab[m_tabIndex].secondaryView)); if (m_activeViewContainer == viewContainer) { @@ -1796,7 +1796,7 @@ void DolphinMainWindow::rememberClosedTab(int index) ClosedTab closedTab; closedTab.primaryUrl = m_viewTab[index].primaryView->url(); - if (m_viewTab[index].secondaryView != 0) { + if (m_viewTab[index].secondaryView) { closedTab.secondaryUrl = m_viewTab[index].secondaryView->url(); closedTab.isSplit = true; } else { @@ -1866,7 +1866,7 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) void DolphinMainWindow::updateSplitAction() { QAction* splitAction = actionCollection()->action("split_view"); - if (m_viewTab[m_tabIndex].secondaryView != 0) { + if (m_viewTab[m_tabIndex].secondaryView) { if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) { splitAction->setText(i18nc("@action:intoolbar Close right view", "Close")); splitAction->setToolTip(i18nc("@info", "Close right view")); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index af333ba4f..0ecdaf685 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -259,7 +259,7 @@ void DolphinViewContainer::setUrl(const KUrl& newUrl) void DolphinViewContainer::setFilterBarVisible(bool visible) { - Q_ASSERT(m_filterBar != 0); + Q_ASSERT(m_filterBar); if (visible) { m_filterBar->show(); m_filterBar->setFocus(); @@ -338,7 +338,7 @@ void DolphinViewContainer::slotFinishedPathLoading() m_statusBar->setProgress(100); } - if (isSearchUrl(url()) && (m_view->items().count() == 0)) { + if (isSearchUrl(url()) && m_view->items().isEmpty()) { // The dir lister has been completed on a Nepomuk-URI and no items have been found. Instead // of showing the default status bar information ("0 items") a more helpful information is given: m_statusBar->setMessage(i18nc("@info:status", "No items found."), DolphinStatusBar::Information); diff --git a/src/panels/filter/filterpanel.cpp b/src/panels/filter/filterpanel.cpp index 12cf642db..e4d352ba6 100644 --- a/src/panels/filter/filterpanel.cpp +++ b/src/panels/filter/filterpanel.cpp @@ -95,7 +95,7 @@ void FilterPanel::showEvent(QShowEvent* event) QVBoxLayout* layout = new QVBoxLayout(this); layout->setMargin(0); - Q_ASSERT(m_facetWidget == 0); + Q_ASSERT(!m_facetWidget); m_facetWidget = new Nepomuk::Utils::FacetWidget(this); layout->addWidget(m_facetWidget, 1); @@ -133,7 +133,7 @@ void FilterPanel::showEvent(QShowEvent* event) m_facetWidget->addFacet(Nepomuk::Utils::Facet::createRatingFacet()); m_facetWidget->addFacet(Nepomuk::Utils::Facet::createTagFacet()); - Q_ASSERT(m_lastSetUrlStatJob == 0); + Q_ASSERT(!m_lastSetUrlStatJob); m_lastSetUrlStatJob = KIO::stat(url(), KIO::HideProgressInfo); connect(m_lastSetUrlStatJob, SIGNAL(result(KJob*)), this, SLOT(slotSetUrlStatFinished(KJob*))); diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 4e4efed44..ccdf13dec 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -73,7 +73,7 @@ FoldersPanel::~FoldersPanel() void FoldersPanel::setShowHiddenFiles(bool show) { FoldersPanelSettings::setShowHiddenFiles(show); - if (m_dirLister != 0) { + if (m_dirLister) { m_dirLister->setShowingDotFiles(show); m_dirLister->openUrl(m_dirLister->url(), KDirLister::Reload); } @@ -118,7 +118,7 @@ bool FoldersPanel::urlChanged() return false; } - if (m_dirLister != 0) { + if (m_dirLister) { m_setLeafVisible = true; loadTree(url()); } @@ -133,7 +133,7 @@ void FoldersPanel::showEvent(QShowEvent* event) return; } - if (m_dirLister == 0) { + if (!m_dirLister) { // Postpone the creating of the dir lister to the first show event. // This assures that no performance and memory overhead is given when the TreeView is not // used at all (see FoldersPanel::setUrl()). @@ -146,18 +146,18 @@ void FoldersPanel::showEvent(QShowEvent* event) m_dirLister->setShowingDotFiles(FoldersPanelSettings::showHiddenFiles()); connect(m_dirLister, SIGNAL(completed()), this, SLOT(slotDirListerCompleted())); - Q_ASSERT(m_dolphinModel == 0); + Q_ASSERT(!m_dolphinModel); m_dolphinModel = new DolphinModel(this); m_dolphinModel->setDirLister(m_dirLister); m_dolphinModel->setDropsAllowed(DolphinModel::DropOnDirectory); connect(m_dolphinModel, SIGNAL(expand(const QModelIndex&)), this, SLOT(expandToDir(const QModelIndex&))); - Q_ASSERT(m_proxyModel == 0); + Q_ASSERT(!m_proxyModel); m_proxyModel = new DolphinSortFilterProxyModel(this); m_proxyModel->setSourceModel(m_dolphinModel); - Q_ASSERT(m_treeView == 0); + Q_ASSERT(!m_treeView); m_treeView = new PanelTreeView(this); m_treeView->setModel(m_proxyModel); m_proxyModel->setSorting(DolphinView::SortByName); @@ -278,7 +278,7 @@ void FoldersPanel::slotVerticalScrollBarMoved(int value) void FoldersPanel::loadTree(const KUrl& url) { - Q_ASSERT(m_dirLister != 0); + Q_ASSERT(m_dirLister); m_leafDir = url; KUrl baseUrl; diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp index f1530c72c..9bfb711c6 100644 --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -52,7 +52,7 @@ void InformationPanel::setSelection(const KFileItemList& selection) return; } - if ((selection.count() == 0) && (m_selection.count() == 0)) { + if (selection.isEmpty() && m_selection.isEmpty()) { // The selection has not really changed, only the current index. // QItemSelectionModel emits a signal in this case and it is less // expensive doing the check this way instead of patching diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index b820be0a0..08121e78a 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -192,7 +192,7 @@ void InformationPanelContent::showItem(const KFileItem& item) } } - if (m_metaDataWidget != 0) { + if (m_metaDataWidget) { m_metaDataWidget->show(); m_metaDataWidget->setItems(KFileItemList() << item); } @@ -234,7 +234,7 @@ void InformationPanelContent::showItems(const KFileItemList& items) m_preview->setPixmap(icon); setNameLabelText(i18ncp("@info", "%1 item selected", "%1 items selected", items.count())); - if (m_metaDataWidget != 0) { + if (m_metaDataWidget) { m_metaDataWidget->setItems(items); } @@ -289,7 +289,7 @@ void InformationPanelContent::configureSettings(const QList& customCon // Open the popup and adjust the settings for the // selected action. QAction* action = popup.exec(QCursor::pos()); - if (action == 0) { + if (!action) { return; } @@ -418,7 +418,7 @@ void InformationPanelContent::adjustWidgetSizes(int width) // The metadata widget also contains a text widget which may return // a large preferred width. - if (m_metaDataWidget != 0) { + if (m_metaDataWidget) { m_metaDataWidget->setMaximumWidth(maxWidth); } diff --git a/src/panels/information/phononwidget.cpp b/src/panels/information/phononwidget.cpp index b6da339ea..5accf4d87 100644 --- a/src/panels/information/phononwidget.cpp +++ b/src/panels/information/phononwidget.cpp @@ -118,7 +118,7 @@ void PhononWidget::showEvent(QShowEvent *event) return; } - if (m_topLayout == 0) { + if (!m_topLayout) { m_topLayout = new QVBoxLayout(this); m_topLayout->setMargin(0); m_topLayout->setSpacing(KDialog::spacingHint()); @@ -185,7 +185,7 @@ void PhononWidget::play() { switch (m_mode) { case Audio: - if (m_audioMedia == 0) { + if (!m_audioMedia) { m_audioMedia = Phonon::createPlayer(Phonon::MusicCategory, m_url); m_audioMedia->setParent(this); } @@ -195,7 +195,7 @@ void PhononWidget::play() break; case Video: - if (m_videoPlayer == 0) { + if (!m_videoPlayer) { m_videoPlayer = new EmbeddedVideoPlayer(Phonon::VideoCategory, this); m_topLayout->insertWidget(0, m_videoPlayer); } @@ -209,7 +209,7 @@ void PhononWidget::play() break; } - Q_ASSERT(m_media != 0); + Q_ASSERT(m_media); connect(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged(Phonon::State))); m_seekSlider->setMediaObject(m_media); @@ -219,7 +219,7 @@ void PhononWidget::play() void PhononWidget::stop() { - if (m_media != 0) { + if (m_media) { m_media->stop(); disconnect(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged(Phonon::State))); @@ -229,14 +229,14 @@ void PhononWidget::stop() m_playButton->show(); } - if (m_videoPlayer != 0) { + if (m_videoPlayer) { m_videoPlayer->hide(); } } void PhononWidget::applyVideoSize() { - if ((m_videoPlayer != 0) && m_videoSize.isValid()) { + if ((m_videoPlayer) && m_videoSize.isValid()) { m_videoPlayer->setSizeHint(m_videoSize); } } diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index d928380d8..61d80cbfa 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -58,9 +58,7 @@ bool TerminalPanel::urlChanged() return false; } - const bool sendInput = (m_terminal != 0) - && (m_terminal->foregroundProcessId() == -1) - && isVisible(); + const bool sendInput = m_terminal && (m_terminal->foregroundProcessId() == -1) && isVisible(); if (sendInput) { changeDir(url()); } @@ -75,18 +73,18 @@ void TerminalPanel::showEvent(QShowEvent* event) return; } - if (m_terminal == 0) { + if (!m_terminal) { m_clearTerminal = true; KPluginFactory* factory = KPluginLoader("libkonsolepart").factory(); KParts::ReadOnlyPart* part = factory ? (factory->create(this)) : 0; - if (part != 0) { + if (part) { connect(part, SIGNAL(destroyed(QObject*)), this, SLOT(terminalExited())); m_terminalWidget = part->widget(); m_layout->addWidget(m_terminalWidget); m_terminal = qobject_cast(part); } } - if (m_terminal != 0) { + if (m_terminal) { m_terminal->showShellInDir(url().toLocalFile()); changeDir(url()); m_terminalWidget->setFocus(); diff --git a/src/search/filenamesearchprotocol.cpp b/src/search/filenamesearchprotocol.cpp index ddc23789c..4d6f59fa4 100644 --- a/src/search/filenamesearchprotocol.cpp +++ b/src/search/filenamesearchprotocol.cpp @@ -89,7 +89,7 @@ void FileNameSearchProtocol::searchDirectory(const KUrl& directory) const KFileItemList items = dirLister->items(); foreach (const KFileItem& item, items) { bool addItem = false; - if ((m_regExp == 0) || item.name().contains(*m_regExp)) { + if (!m_regExp || item.name().contains(*m_regExp)) { addItem = true; } else if (m_checkContent && item.mimetype().startsWith(QLatin1String("text/"))) { addItem = contentContainsPattern(item.url()); @@ -129,7 +129,7 @@ void FileNameSearchProtocol::searchDirectory(const KUrl& directory) bool FileNameSearchProtocol::contentContainsPattern(const KUrl& fileName) const { - Q_ASSERT(m_regExp != 0); + Q_ASSERT(m_regExp); QString path; KTemporaryFile tempFile; diff --git a/src/settings/applyviewpropsjob.cpp b/src/settings/applyviewpropsjob.cpp index 4aa86ce4d..4010ab477 100644 --- a/src/settings/applyviewpropsjob.cpp +++ b/src/settings/applyviewpropsjob.cpp @@ -61,7 +61,7 @@ void ApplyViewPropsJob::slotEntries(KIO::Job*, const KIO::UDSEntryList& list) KUrl url(m_dir); url.addPath(name); - Q_ASSERT(m_viewProps != 0); + Q_ASSERT(m_viewProps); ViewProperties props(url); props.setDirProperties(*m_viewProps); diff --git a/src/settings/viewpropertiesdialog.cpp b/src/settings/viewpropertiesdialog.cpp index 0ea197363..2a35f7eb8 100644 --- a/src/settings/viewpropertiesdialog.cpp +++ b/src/settings/viewpropertiesdialog.cpp @@ -73,7 +73,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : m_applyToAllFolders(0), m_useAsDefault(0) { - Q_ASSERT(dolphinView != 0); + Q_ASSERT(dolphinView); const bool useGlobalViewProps = DolphinSettings::instance().generalSettings()->globalViewProps(); setCaption(i18nc("@title:window", "View Properties")); @@ -332,8 +332,7 @@ void ViewPropertiesDialog::applyViewProperties() return; } - const bool applyToSubFolders = (m_applyToSubFolders != 0) && - m_applyToSubFolders->isChecked(); + const bool applyToSubFolders = m_applyToSubFolders && m_applyToSubFolders->isChecked(); if (applyToSubFolders) { const QString text(i18nc("@info", "The view properties of all sub-folders will be changed. Do you want to continue?")); if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) { @@ -348,13 +347,11 @@ void ViewPropertiesDialog::applyViewProperties() info->show(); } - const bool applyToAllFolders = (m_applyToAllFolders != 0) && - m_applyToAllFolders->isChecked(); + const bool applyToAllFolders = m_applyToAllFolders && m_applyToAllFolders->isChecked(); // If the user selected 'Apply To All Folders' the view properties implicitely // are also used as default for new folders. - const bool useAsDefault = applyToAllFolders || - ((m_useAsDefault != 0) && m_useAsDefault->isChecked()); + const bool useAsDefault = applyToAllFolders || (m_useAsDefault && m_useAsDefault->isChecked()); if (useAsDefault) { // For directories where no .directory file is available, the .directory // file stored for the global view properties is used as fallback. To update diff --git a/src/settings/viewpropsprogressinfo.cpp b/src/settings/viewpropsprogressinfo.cpp index 2be0258ef..9b7797d02 100644 --- a/src/settings/viewpropsprogressinfo.cpp +++ b/src/settings/viewpropsprogressinfo.cpp @@ -104,12 +104,12 @@ void ViewPropsProgressInfo::closeEvent(QCloseEvent* event) void ViewPropsProgressInfo::updateProgress() { - if (m_dirSizeJob != 0) { + if (m_dirSizeJob) { const int subdirs = m_dirSizeJob->totalSubdirs(); m_label->setText(i18nc("@info:progress", "Counting folders: %1", subdirs)); } - if (m_applyViewPropsJob != 0) { + if (m_applyViewPropsJob) { const int progress = m_applyViewPropsJob->progress(); m_progressBar->setValue(progress); } @@ -134,12 +134,12 @@ void ViewPropsProgressInfo::applyViewProperties() void ViewPropsProgressInfo::cancelApplying() { - if (m_dirSizeJob != 0) { + if (m_dirSizeJob) { m_dirSizeJob->kill(); m_dirSizeJob = 0; } - if (m_applyViewPropsJob != 0) { + if (m_applyViewPropsJob) { m_applyViewPropsJob->kill(); m_applyViewPropsJob = 0; } diff --git a/src/tests/dolphinviewtest_allviewmodes.cpp b/src/tests/dolphinviewtest_allviewmodes.cpp index 743ce9fd4..8d7a5bd0d 100644 --- a/src/tests/dolphinviewtest_allviewmodes.cpp +++ b/src/tests/dolphinviewtest_allviewmodes.cpp @@ -409,7 +409,7 @@ void DolphinViewTest_AllViewModes::verifySelectedItemsCount(int itemsCount) cons QCOMPARE(m_view->selectedItemsCount(), itemsCount); QCOMPARE(spySelectionChanged.count(), 1); QCOMPARE(qvariant_cast(spySelectionChanged.at(0).at(0)).count(), itemsCount); - if (itemsCount != 0) { + if (itemsCount) { QVERIFY(m_view->hasSelection()); } else { diff --git a/src/views/dolphincolumnview.cpp b/src/views/dolphincolumnview.cpp index 6b0f43cd9..fec0879ea 100644 --- a/src/views/dolphincolumnview.cpp +++ b/src/views/dolphincolumnview.cpp @@ -90,7 +90,7 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, m_resizeWidget->installEventFilter(this); const ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings(); - Q_ASSERT(settings != 0); + Q_ASSERT(settings); if (settings->useSystemFont()) { m_font = KGlobalSettings::generalFont(); @@ -241,7 +241,7 @@ void DolphinColumnView::setSelectionModel(QItemSelectionModel* model) // If a change of the selection is done although the view is not active // (e. g. by the selection markers), the column must be activated. This // is done by listening to the current selectionChanged() signal. - if (selectionModel() != 0) { + if (selectionModel()) { disconnect(selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(requestActivation())); } @@ -507,7 +507,7 @@ void DolphinColumnView::requestActivation() void DolphinColumnView::updateFont() { const ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings(); - Q_ASSERT(settings != 0); + Q_ASSERT(settings); if (settings->useSystemFont()) { m_font = KGlobalSettings::generalFont(); diff --git a/src/views/dolphincolumnviewcontainer.cpp b/src/views/dolphincolumnviewcontainer.cpp index 7baded96c..3216dd2b6 100644 --- a/src/views/dolphincolumnviewcontainer.cpp +++ b/src/views/dolphincolumnviewcontainer.cpp @@ -49,8 +49,8 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent, m_activeUrlTimer(0), m_assureVisibleActiveColumnTimer(0) { - Q_ASSERT(dolphinViewController != 0); - Q_ASSERT(viewModeController != 0); + Q_ASSERT(dolphinViewController); + Q_ASSERT(viewModeController); setAcceptDrops(true); setFocusPolicy(Qt::NoFocus); @@ -392,7 +392,7 @@ void DolphinColumnViewContainer::removeAllColumns() void DolphinColumnViewContainer::deleteColumn(DolphinColumnView* column) { - if (column == 0) { + if (!column) { return; } @@ -412,7 +412,7 @@ void DolphinColumnViewContainer::deleteColumn(DolphinColumnView* column) // during drag operations" is used). Deleting the view // during an ongoing drag operation is not allowed, so // this will postponed. - if (m_dragSource != 0) { + if (m_dragSource) { // the old stored view is obviously not the drag source anymore m_dragSource->deleteLater(); m_dragSource = 0; diff --git a/src/views/dolphindetailsview.cpp b/src/views/dolphindetailsview.cpp index 482925aaa..5c2e9576f 100644 --- a/src/views/dolphindetailsview.cpp +++ b/src/views/dolphindetailsview.cpp @@ -59,9 +59,9 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, m_decorationSize() { const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); - Q_ASSERT(settings != 0); - Q_ASSERT(dolphinViewController != 0); - Q_ASSERT(viewModeController != 0); + Q_ASSERT(settings); + Q_ASSERT(dolphinViewController); + Q_ASSERT(viewModeController); setLayoutDirection(Qt::LeftToRight); setAcceptDrops(true); @@ -388,7 +388,7 @@ void DolphinDetailsView::configureSettings(const QPoint& pos) popup.addSeparator(); QAction* activatedAction = popup.exec(header()->mapToGlobal(pos)); - if (activatedAction != 0) { + if (activatedAction) { const bool show = activatedAction->isChecked(); const int columnIndex = activatedAction->data().toInt(); @@ -574,7 +574,7 @@ void DolphinDetailsView::slotGlobalSettingsChanged(int category) Q_UNUSED(category); const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); - Q_ASSERT(settings != 0); + Q_ASSERT(settings); if (settings->useSystemFont()) { m_font = KGlobalSettings::generalFont(); } diff --git a/src/views/dolphindetailsviewexpander.cpp b/src/views/dolphindetailsviewexpander.cpp index c2734ed3a..cc4bc67be 100644 --- a/src/views/dolphindetailsviewexpander.cpp +++ b/src/views/dolphindetailsviewexpander.cpp @@ -34,16 +34,16 @@ DolphinDetailsViewExpander::DolphinDetailsViewExpander(DolphinDetailsView* paren m_dolphinModel(0), m_proxyModel(0) { - Q_ASSERT(parent != 0); + Q_ASSERT(parent); m_proxyModel = qobject_cast(parent->model()); - Q_ASSERT(m_proxyModel != 0); + Q_ASSERT(m_proxyModel); m_dolphinModel = qobject_cast(m_proxyModel->sourceModel()); - Q_ASSERT(m_dolphinModel != 0); + Q_ASSERT(m_dolphinModel); m_dirLister = m_dolphinModel->dirLister(); - Q_ASSERT(m_dirLister != 0); + Q_ASSERT(m_dirLister); // The URLs must be sorted. E.g. /home/user/ cannot be expanded before /home/ // because it is not known to the dir model before. diff --git a/src/views/dolphiniconsview.cpp b/src/views/dolphiniconsview.cpp index 6527c8611..a863de72d 100644 --- a/src/views/dolphiniconsview.cpp +++ b/src/views/dolphiniconsview.cpp @@ -54,8 +54,8 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, m_itemSize(), m_dropRect() { - Q_ASSERT(dolphinViewController != 0); - Q_ASSERT(viewModeController != 0); + Q_ASSERT(dolphinViewController); + Q_ASSERT(viewModeController); setModel(proxyModel); setLayoutDirection(Qt::LeftToRight); @@ -93,7 +93,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, // apply the icons mode settings to the widget const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); - Q_ASSERT(settings != 0); + Q_ASSERT(settings); if (settings->useSystemFont()) { m_font = KGlobalSettings::generalFont(); @@ -405,7 +405,7 @@ void DolphinIconsView::slotGlobalSettingsChanged(int category) Q_UNUSED(category); const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); - Q_ASSERT(settings != 0); + Q_ASSERT(settings); if (settings->useSystemFont()) { m_font = KGlobalSettings::generalFont(); } @@ -449,7 +449,7 @@ void DolphinIconsView::categoryDrawerActionRequested(int action, const QModelInd void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount) { const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); - Q_ASSERT(settings != 0); + Q_ASSERT(settings); int itemWidth = settings->itemWidth(); int itemHeight = settings->itemHeight(); @@ -510,7 +510,7 @@ void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount) setGridSizeOwn(QSize(itemWidth + spacing * 2, itemHeight + spacing)); KFileItemDelegate* delegate = dynamic_cast(itemDelegate()); - if (delegate != 0) { + if (delegate) { delegate->setMaximumSize(m_itemSize); } } diff --git a/src/views/dolphinremoteencoding.cpp b/src/views/dolphinremoteencoding.cpp index f3bd15772..475769e91 100644 --- a/src/views/dolphinremoteencoding.cpp +++ b/src/views/dolphinremoteencoding.cpp @@ -169,7 +169,7 @@ void DolphinRemoteEncoding::slotAboutToShow() void DolphinRemoteEncoding::slotItemSelected(QAction* action) { - if (action != 0) { + if (action) { int id = action->data().toInt(); KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1()); @@ -200,7 +200,7 @@ void DolphinRemoteEncoding::slotDefault() // Remove the exact name match... domains << m_currentURL.host(); - while (partList.count()) { + while (!partList.isEmpty()) { if (partList.count() == 2) { if (partList[0].length() <= 2 && partList[1].length() == 2) { break; diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 534eabfee..4ab16e052 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -290,7 +290,7 @@ KFileItemList DolphinView::selectedItems() const { KFileItemList itemList; const QAbstractItemView* view = m_viewAccessor.itemView(); - if (view == 0) { + if (!view) { return itemList; } @@ -310,7 +310,7 @@ KFileItemList DolphinView::selectedItems() const int DolphinView::selectedItemsCount() const { const QAbstractItemView* view = m_viewAccessor.itemView(); - if (view == 0) { + if (!view) { return 0; } @@ -886,7 +886,7 @@ void DolphinView::updateAdditionalInfoActions(KActionCollection* collection) foreach (const KFileItemDelegate::Information& info, infoKeys) { const QString name = infoAccessor.actionCollectionName(info, AdditionalInfoAccessor::AdditionalInfoType); QAction* action = collection->action(name); - Q_ASSERT(action != 0); + Q_ASSERT(action); action->setEnabled(enable); action->setChecked(checkedInfo.contains(info)); } @@ -929,7 +929,7 @@ void DolphinView::restoreState(QDataStream& stream) QSet urlsToExpand; stream >> urlsToExpand; const DolphinDetailsViewExpander* expander = m_viewAccessor.setExpandedUrls(urlsToExpand); - if (expander != 0) { + if (expander) { m_expanderActive = true; connect (expander, SIGNAL(completed()), this, SLOT(slotLoadingCompleted())); } @@ -944,7 +944,7 @@ void DolphinView::saveState(QDataStream& stream) KFileItem currentItem; const QAbstractItemView* view = m_viewAccessor.itemView(); - if (view != 0) { + if (view) { const QModelIndex proxyIndex = view->currentIndex(); const QModelIndex dirModelIndex = m_viewAccessor.proxyModel()->mapToSource(proxyIndex); currentItem = m_viewAccessor.dirModel()->itemForIndex(dirModelIndex); @@ -972,7 +972,7 @@ void DolphinView::saveState(QDataStream& stream) bool DolphinView::hasSelection() const { const QAbstractItemView* view = m_viewAccessor.itemView(); - return (view != 0) && view->selectionModel()->hasSelection(); + return view && view->selectionModel()->hasSelection(); } void DolphinView::observeCreatedItem(const KUrl& url) @@ -1011,7 +1011,7 @@ void DolphinView::restoreContentsPosition() m_restoredContentsPosition = QPoint(); QAbstractItemView* view = m_viewAccessor.itemView(); - Q_ASSERT(view != 0); + Q_ASSERT(view); view->horizontalScrollBar()->setValue(x); view->verticalScrollBar()->setValue(y); } @@ -1163,12 +1163,12 @@ void DolphinView::applyViewProperties() updateZoomLevel(oldZoomLevel); } - if (m_viewAccessor.itemView() == 0) { + if (!m_viewAccessor.itemView()) { createView(); } - Q_ASSERT(m_viewAccessor.itemView() != 0); - Q_ASSERT(m_viewAccessor.itemDelegate() != 0); + Q_ASSERT(m_viewAccessor.itemView()); + Q_ASSERT(m_viewAccessor.itemDelegate()); const bool showHiddenFiles = props.showHiddenFiles(); if (showHiddenFiles != m_viewAccessor.dirLister()->showingDotFiles()) { @@ -1224,12 +1224,12 @@ void DolphinView::createView() { deleteView(); - Q_ASSERT(m_viewAccessor.itemView() == 0); - Q_ASSERT(m_dolphinViewController->itemView() == 0); + Q_ASSERT(!m_viewAccessor.itemView()); + Q_ASSERT(!m_dolphinViewController->itemView()); m_viewAccessor.createView(this, m_dolphinViewController, m_viewModeController, m_mode); QAbstractItemView* view = m_viewAccessor.itemView(); - Q_ASSERT(view != 0); + Q_ASSERT(view); view->installEventFilter(this); view->viewport()->installEventFilter(this); @@ -1247,10 +1247,10 @@ void DolphinView::createView() void DolphinView::deleteView() { QAbstractItemView* view = m_viewAccessor.itemView(); - Q_ASSERT((m_dolphinViewController->itemView() == 0) || (m_dolphinViewController->itemView() == view)); + Q_ASSERT(!m_dolphinViewController->itemView() || (m_dolphinViewController->itemView() == view)); m_dolphinViewController->setItemView(0); - if (view != 0) { + if (view) { disconnectViewAccessor(); if (hasFocus()) { @@ -1303,7 +1303,7 @@ KUrl::List DolphinView::simplifiedSelectedUrls() const QMimeData* DolphinView::selectionMimeData() const { const QAbstractItemView* view = m_viewAccessor.itemView(); - Q_ASSERT((view != 0) && (view->selectionModel() != 0)); + Q_ASSERT((view) && (view->selectionModel())); const QItemSelection selection = m_viewAccessor.proxyModel()->mapSelectionToSource(view->selectionModel()->selection()); return m_viewAccessor.dirModel()->mimeData(selection.indexes()); } @@ -1438,7 +1438,7 @@ void DolphinView::ViewAccessor::createView(QWidget* parent, const ViewModeController* viewModeController, Mode mode) { - Q_ASSERT(itemView() == 0); + Q_ASSERT(!itemView()); switch (mode) { case IconsView: @@ -1474,14 +1474,14 @@ void DolphinView::ViewAccessor::createView(QWidget* parent, void DolphinView::ViewAccessor::deleteView() { - if (m_columnsContainer != 0) { + if (m_columnsContainer) { m_columnsContainer->close(); m_columnsContainer->disconnect(); m_columnsContainer->deleteLater(); m_columnsContainer = 0; } else { QAbstractItemView* view = itemView(); - if (view != 0) { + if (view) { view->close(); view->disconnect(); @@ -1490,7 +1490,7 @@ void DolphinView::ViewAccessor::deleteView() // during drag operations" is used). Deleting the view // during an ongoing drag operation is not allowed, so // this will postponed. - if (m_dragSource != 0) { + if (m_dragSource) { // the old stored view is obviously not the drag source anymore m_dragSource->deleteLater(); m_dragSource = 0; @@ -1510,22 +1510,22 @@ void DolphinView::ViewAccessor::deleteView() void DolphinView::ViewAccessor::prepareUrlChange(const KUrl& url) { - if (m_columnsContainer != 0) { + if (m_columnsContainer) { m_columnsContainer->showColumn(url); } } QAbstractItemView* DolphinView::ViewAccessor::itemView() const { - if (m_iconsView != 0) { + if (m_iconsView) { return m_iconsView; } - if (m_detailsView != 0) { + if (m_detailsView) { return m_detailsView; } - if (m_columnsContainer != 0) { + if (m_columnsContainer) { return m_columnsContainer->activeColumn(); } @@ -1539,7 +1539,7 @@ KFileItemDelegate* DolphinView::ViewAccessor::itemDelegate() const QWidget* DolphinView::ViewAccessor::layoutTarget() const { - if (m_columnsContainer != 0) { + if (m_columnsContainer) { return m_columnsContainer; } return itemView(); @@ -1552,7 +1552,7 @@ void DolphinView::ViewAccessor::setRootUrl(const KUrl& rootUrl) KUrl DolphinView::ViewAccessor::rootUrl() const { - return (m_columnsContainer != 0) ? m_columnsContainer->rootUrl() : m_rootUrl; + return m_columnsContainer ? m_columnsContainer->rootUrl() : m_rootUrl; } bool DolphinView::ViewAccessor::supportsCategorizedSorting() const @@ -1562,12 +1562,12 @@ bool DolphinView::ViewAccessor::supportsCategorizedSorting() const bool DolphinView::ViewAccessor::itemsExpandable() const { - return (m_detailsView != 0) && m_detailsView->itemsExpandable(); + return m_detailsView && m_detailsView->itemsExpandable(); } QSet DolphinView::ViewAccessor::expandedUrls() const { - if (m_detailsView != 0) { + if (m_detailsView) { return m_detailsView->expandedUrls(); } @@ -1576,7 +1576,7 @@ QSet DolphinView::ViewAccessor::expandedUrls() const const DolphinDetailsViewExpander* DolphinView::ViewAccessor::setExpandedUrls(const QSet& urlsToExpand) { - if ((m_detailsView != 0) && m_detailsView->itemsExpandable() && !urlsToExpand.isEmpty()) { + if (m_detailsView && m_detailsView->itemsExpandable() && !urlsToExpand.isEmpty()) { // Check if another expander is already active and stop it if necessary. if(!m_detailsViewExpander.isNull()) { m_detailsViewExpander->stop(); @@ -1604,7 +1604,7 @@ DolphinModel* DolphinView::ViewAccessor::dirModel() const DolphinSortFilterProxyModel* DolphinView::ViewAccessor::proxyModel() const { - if (m_columnsContainer != 0) { + if (m_columnsContainer) { return static_cast(m_columnsContainer->activeColumn()->model()); } return m_proxyModel; diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index 0959a03f7..6046abc8c 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -320,7 +320,7 @@ KActionCollection* DolphinViewActionHandler::actionCollection() void DolphinViewActionHandler::updateViewActions() { QAction* viewModeAction = m_actionCollection->action(currentViewModeActionName()); - if (viewModeAction != 0) { + if (viewModeAction) { viewModeAction->setChecked(true); QAction* viewModeMenu = m_actionCollection->action("view_mode"); @@ -484,7 +484,7 @@ void DolphinViewActionHandler::slotSortingChanged(DolphinView::Sorting sorting) } } - if (action != 0) { + if (action) { action->setChecked(true); QAction* sortByMenu = m_actionCollection->action("sort"); @@ -495,12 +495,12 @@ void DolphinViewActionHandler::slotSortingChanged(DolphinView::Sorting sorting) void DolphinViewActionHandler::slotZoomLevelChanged(int level) { QAction* zoomInAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomIn)); - if (zoomInAction != 0) { + if (zoomInAction) { zoomInAction->setEnabled(level < ZoomLevelInfo::maximumLevel()); } QAction* zoomOutAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomOut)); - if (zoomOutAction != 0) { + if (zoomOutAction) { zoomOutAction->setEnabled(level > ZoomLevelInfo::minimumLevel()); } } diff --git a/src/views/dolphinviewautoscroller.cpp b/src/views/dolphinviewautoscroller.cpp index 4f645d026..5b338cc37 100644 --- a/src/views/dolphinviewautoscroller.cpp +++ b/src/views/dolphinviewautoscroller.cpp @@ -131,13 +131,13 @@ void DolphinViewAutoScroller::scrollViewport() } QScrollBar* verticalScrollBar = m_itemView->verticalScrollBar(); - if (verticalScrollBar != 0) { + if (verticalScrollBar) { const int value = verticalScrollBar->value(); verticalScrollBar->setValue(value + m_verticalScrollInc); } QScrollBar* horizontalScrollBar = m_itemView->horizontalScrollBar(); - if (horizontalScrollBar != 0) { + if (horizontalScrollBar) { const int value = horizontalScrollBar->value(); horizontalScrollBar->setValue(value + m_horizontalScrollInc); @@ -156,9 +156,9 @@ void DolphinViewAutoScroller::scrollViewport() void DolphinViewAutoScroller::triggerAutoScroll() { - const bool verticalScrolling = (m_itemView->verticalScrollBar() != 0) && + const bool verticalScrolling = m_itemView->verticalScrollBar() && m_itemView->verticalScrollBar()->isVisible(); - const bool horizontalScrolling = (m_itemView->horizontalScrollBar() != 0) && + const bool horizontalScrolling = m_itemView->horizontalScrollBar() && m_itemView->horizontalScrollBar()->isVisible(); if (!verticalScrolling && !horizontalScrolling) { // no scrollbars are shown at all, so no autoscrolling is necessary diff --git a/src/views/dolphinviewcontroller.cpp b/src/views/dolphinviewcontroller.cpp index f8f27ea38..672cffe65 100644 --- a/src/views/dolphinviewcontroller.cpp +++ b/src/views/dolphinviewcontroller.cpp @@ -53,14 +53,14 @@ void DolphinViewController::requestUrlChange(const KUrl& url) void DolphinViewController::setItemView(QAbstractItemView* view) { - if (m_itemView != 0) { + if (m_itemView) { disconnect(m_itemView, SIGNAL(pressed(const QModelIndex&)), this, SLOT(updateMouseButtonState())); } m_itemView = view; - if (m_itemView != 0) { + if (m_itemView) { // TODO: this is a workaround until Qt-issue 176832 has been fixed connect(m_itemView, SIGNAL(pressed(const QModelIndex&)), this, SLOT(updateMouseButtonState())); @@ -126,7 +126,7 @@ QList DolphinViewController::versionControlActions(const KFileItemList void DolphinViewController::handleKeyPressEvent(QKeyEvent* event) { - if (m_itemView == 0) { + if (!m_itemView) { return; } @@ -194,9 +194,9 @@ void DolphinViewController::emitItemTriggered(const KFileItem& item) KFileItem DolphinViewController::itemForIndex(const QModelIndex& index) const { - if (m_itemView != 0) { + if (m_itemView) { QAbstractProxyModel* proxyModel = static_cast(m_itemView->model()); - if (proxyModel != 0) { + if (proxyModel) { KDirModel* dirModel = static_cast(proxyModel->sourceModel()); const QModelIndex dirIndex = proxyModel->mapToSource(index); return dirModel->itemForIndex(dirIndex); @@ -212,7 +212,7 @@ void DolphinViewController::triggerItem(const QModelIndex& index) const KFileItem item = itemForIndex(index); if (index.isValid() && (index.column() == KDirModel::Name)) { emit itemTriggered(item); - } else if (m_itemView != 0) { + } else if (m_itemView) { m_itemView->clearSelection(); emit itemEntered(KFileItem()); } diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp index 24d5156e5..f7508e094 100644 --- a/src/views/draganddrophelper.cpp +++ b/src/views/draganddrophelper.cpp @@ -62,11 +62,11 @@ void DragAndDropHelper::startDrag(QAbstractItemView* itemView, const QModelIndexList indexes = itemView->selectionModel()->selectedIndexes(); if (!indexes.isEmpty()) { QMimeData *data = itemView->model()->mimeData(indexes); - if (data == 0) { + if (!data) { return; } - if (dolphinViewController != 0) { + if (dolphinViewController) { dolphinViewController->requestToolTipHiding(); } @@ -83,7 +83,7 @@ void DragAndDropHelper::startDrag(QAbstractItemView* itemView, bool DragAndDropHelper::isDragSource(QAbstractItemView* itemView) const { - return (m_dragSource != 0) && (m_dragSource == itemView); + return m_dragSource && (m_dragSource == itemView); } void DragAndDropHelper::dropUrls(const KFileItem& destItem, diff --git a/src/views/folderexpander.cpp b/src/views/folderexpander.cpp index 4e22fdb0a..a9f5971c2 100644 --- a/src/views/folderexpander.cpp +++ b/src/views/folderexpander.cpp @@ -39,14 +39,11 @@ FolderExpander::FolderExpander(QAbstractItemView *view, QSortFilterProxyModel *p m_autoExpandTriggerTimer(0), m_autoExpandPos() { - if (m_view == 0) { - return; - } - if (m_proxyModel == 0) { + if (!m_view || !m_proxyModel) { return; } KDirModel *m_dirModel = qobject_cast(m_proxyModel->sourceModel()); - if (m_dirModel == 0) { + if (!m_dirModel) { return; } @@ -100,7 +97,7 @@ void FolderExpander::autoExpandTimeout() QModelIndex proxyIndexToExpand = m_view->indexAt(m_autoExpandPos); QModelIndex indexToExpand = m_proxyModel->mapToSource(proxyIndexToExpand); KDirModel* m_dirModel = qobject_cast< KDirModel* >(m_proxyModel->sourceModel()); - Q_ASSERT(m_dirModel != 0); + Q_ASSERT(m_dirModel); KFileItem itemToExpand = m_dirModel->itemForIndex(indexToExpand); if (itemToExpand.isNull() || itemToExpand == m_dirModel->itemForIndex(QModelIndex())) { @@ -111,7 +108,7 @@ void FolderExpander::autoExpandTimeout() if (itemToExpand.isDir()) { QTreeView* treeView = qobject_cast(m_view); - if ((treeView != 0) && treeView->itemsExpandable()) { + if (treeView && treeView->itemsExpandable()) { // Toggle expanded state of this directory. treeView->setExpanded(proxyIndexToExpand, !treeView->isExpanded(proxyIndexToExpand)); } diff --git a/src/views/selectionmanager.cpp b/src/views/selectionmanager.cpp index 6befc2199..7a9e81412 100644 --- a/src/views/selectionmanager.cpp +++ b/src/views/selectionmanager.cpp @@ -71,7 +71,7 @@ bool SelectionManager::eventFilter(QObject* watched, QEvent* event) if (watched == m_view->viewport()) { switch (event->type()) { case QEvent::Leave: - if (m_toggle != 0) { + if (m_toggle) { m_toggle->hide(); } restoreCursor(); @@ -81,7 +81,7 @@ bool SelectionManager::eventFilter(QObject* watched, QEvent* event) // Set the toggle invisible, if a mouse button has been pressed // outside the toggle boundaries. This e.g. assures, that the toggle // gets invisible during dragging items. - if (m_toggle != 0) { + if (m_toggle) { const QRect toggleBounds(m_toggle->mapToGlobal(QPoint(0, 0)), m_toggle->size()); m_toggle->setVisible(toggleBounds.contains(QCursor::pos())); } @@ -111,7 +111,7 @@ bool SelectionManager::eventFilter(QObject* watched, QEvent* event) void SelectionManager::reset() { - if (m_toggle != 0) { + if (m_toggle) { m_toggle->reset(); } } @@ -147,7 +147,7 @@ void SelectionManager::slotEntered(const QModelIndex& index) m_connected = false; } - if (m_toggle == 0) { + if (!m_toggle) { return; } @@ -187,7 +187,7 @@ void SelectionManager::slotEntered(const QModelIndex& index) void SelectionManager::slotViewportEntered() { - if (m_toggle != 0) { + if (m_toggle) { m_toggle->hide(); } restoreCursor(); @@ -197,7 +197,7 @@ void SelectionManager::setItemSelected(bool selected) { emit selectionChanged(); - if ((m_toggle != 0) && !m_toggle->url().isEmpty()) { + if (m_toggle && !m_toggle->url().isEmpty()) { const QModelIndex index = indexForUrl(m_toggle->url()); if (index.isValid()) { QItemSelectionModel* selModel = m_view->selectionModel(); @@ -216,7 +216,7 @@ void SelectionManager::slotRowsRemoved(const QModelIndex& parent, int start, int Q_UNUSED(parent); Q_UNUSED(start); Q_UNUSED(end); - if (m_toggle != 0) { + if (m_toggle) { m_toggle->hide(); } restoreCursor(); @@ -228,7 +228,7 @@ void SelectionManager::slotSelectionChanged(const QItemSelection& selected, // The selection has been changed outside the scope of the selection manager // (e. g. by the rubberband or the "Select All" action). Take care updating // the state of the toggle button. - if ((m_toggle != 0) && !m_toggle->url().isEmpty()) { + if (m_toggle && !m_toggle->url().isEmpty()) { const QModelIndex index = indexForUrl(m_toggle->url()); if (index.isValid()) { if (selected.contains(index)) { diff --git a/src/views/selectiontoggle.cpp b/src/views/selectiontoggle.cpp index e08a0220e..d602600c5 100644 --- a/src/views/selectiontoggle.cpp +++ b/src/views/selectiontoggle.cpp @@ -125,7 +125,7 @@ void SelectionToggle::enterEvent(QEvent* event) // if the mouse cursor is above the selection toggle, display // it immediately without fading timer m_isHovered = true; - if (m_fadingTimeLine != 0) { + if (m_fadingTimeLine) { m_fadingTimeLine->stop(); } m_fadingValue = 255; @@ -192,7 +192,7 @@ void SelectionToggle::setFadingValue(int value) { m_fadingValue = value; if (m_fadingValue >= 255) { - Q_ASSERT(m_fadingTimeLine != 0); + Q_ASSERT(m_fadingTimeLine); m_fadingTimeLine->stop(); } update(); @@ -215,7 +215,7 @@ void SelectionToggle::refreshIcon() void SelectionToggle::startFading() { - Q_ASSERT(m_fadingTimeLine == 0); + Q_ASSERT(!m_fadingTimeLine); const bool animate = KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects; const int duration = animate ? 600 : 1; @@ -230,7 +230,7 @@ void SelectionToggle::startFading() void SelectionToggle::stopFading() { - if (m_fadingTimeLine != 0) { + if (m_fadingTimeLine) { m_fadingTimeLine->stop(); delete m_fadingTimeLine; m_fadingTimeLine = 0; diff --git a/src/views/tooltips/filemetadatatooltip.cpp b/src/views/tooltips/filemetadatatooltip.cpp index 0705d09b2..cef553060 100644 --- a/src/views/tooltips/filemetadatatooltip.cpp +++ b/src/views/tooltips/filemetadatatooltip.cpp @@ -84,7 +84,7 @@ void FileMetaDataToolTip::setPreview(const QPixmap& pixmap) QPixmap FileMetaDataToolTip::preview() const { - if (m_preview->pixmap() != 0) { + if (m_preview->pixmap()) { return *m_preview->pixmap(); } return QPixmap(); diff --git a/src/views/tooltips/tooltipmanager.cpp b/src/views/tooltips/tooltipmanager.cpp index fdf83d13d..cb86b3355 100644 --- a/src/views/tooltips/tooltipmanager.cpp +++ b/src/views/tooltips/tooltipmanager.cpp @@ -51,7 +51,7 @@ ToolTipManager::ToolTipManager(QAbstractItemView* parent, m_enabledPlugins() { static FileMetaDataToolTip* sharedToolTip = 0; - if (sharedToolTip == 0) { + if (!sharedToolTip) { sharedToolTip = new FileMetaDataToolTip(); // TODO: Using K_GLOBAL_STATIC would be preferable to maintain the // instance, but the cleanup of KFileMetaDataWidget at this stage does diff --git a/src/views/versioncontrol/pendingthreadsmaintainer.cpp b/src/views/versioncontrol/pendingthreadsmaintainer.cpp index fc463aeb3..ee143a94a 100644 --- a/src/views/versioncontrol/pendingthreadsmaintainer.cpp +++ b/src/views/versioncontrol/pendingthreadsmaintainer.cpp @@ -41,7 +41,7 @@ PendingThreadsMaintainer::~PendingThreadsMaintainer() void PendingThreadsMaintainer::append(QThread* thread) { - Q_ASSERT(thread != 0); + Q_ASSERT(thread); m_threads.append(thread); m_timer->start(); } diff --git a/src/views/versioncontrol/pendingthreadsmaintainer.h b/src/views/versioncontrol/pendingthreadsmaintainer.h index a1ad35516..3e99c8657 100644 --- a/src/views/versioncontrol/pendingthreadsmaintainer.h +++ b/src/views/versioncontrol/pendingthreadsmaintainer.h @@ -38,7 +38,7 @@ class QTimer; * \code * ThreadCreator::~ThreadCreator() * { - * if (m_thread != 0) { + * if (m_thread) { * PendingThreadsMaintainer::instance().append(m_thread); * m_thread = 0; * } diff --git a/src/views/versioncontrol/updateitemstatesthread.cpp b/src/views/versioncontrol/updateitemstatesthread.cpp index b04d66f17..e6bd761cc 100644 --- a/src/views/versioncontrol/updateitemstatesthread.cpp +++ b/src/views/versioncontrol/updateitemstatesthread.cpp @@ -53,7 +53,7 @@ void UpdateItemStatesThread::setData(KVersionControlPlugin* plugin, void UpdateItemStatesThread::run() { Q_ASSERT(!m_itemStates.isEmpty()); - Q_ASSERT(m_plugin != 0); + Q_ASSERT(m_plugin); // The items from m_itemStates may be located in different directory levels. The version // plugin requires the root directory for KVersionControlPlugin::beginRetrieval(). Instead diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp index 26528f974..62f50f30b 100644 --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@ -49,13 +49,14 @@ VersionControlObserver::VersionControlObserver(QAbstractItemView* view) : m_plugin(0), m_updateItemStatesThread(0) { - Q_ASSERT(view != 0); + Q_ASSERT(view); QAbstractProxyModel* proxyModel = qobject_cast(view->model()); - m_dolphinModel = (proxyModel == 0) ? - qobject_cast(view->model()) : - qobject_cast(proxyModel->sourceModel()); - if (m_dolphinModel != 0) { + m_dolphinModel = proxyModel ? + qobject_cast(proxyModel->sourceModel()) : + qobject_cast(view->model()); + + if (m_dolphinModel) { m_dirLister = m_dolphinModel->dirLister(); connect(m_dirLister, SIGNAL(completed()), this, SLOT(delayedDirectoryVerification())); @@ -75,7 +76,7 @@ VersionControlObserver::VersionControlObserver(QAbstractItemView* view) : VersionControlObserver::~VersionControlObserver() { - if (m_updateItemStatesThread != 0) { + if (m_updateItemStatesThread) { if (m_updateItemStatesThread->isFinished()) { delete m_updateItemStatesThread; m_updateItemStatesThread = 0; @@ -91,7 +92,7 @@ VersionControlObserver::~VersionControlObserver() } } - if (m_plugin != 0) { + if (m_plugin) { m_plugin->disconnect(); m_plugin = 0; } @@ -137,12 +138,12 @@ void VersionControlObserver::verifyDirectory() return; } - if (m_plugin != 0) { + if (m_plugin) { m_plugin->disconnect(); } m_plugin = searchPlugin(versionControlUrl); - if (m_plugin != 0) { + if (m_plugin) { connect(m_plugin, SIGNAL(versionStatesChanged()), this, SLOT(silentDirectoryVerification())); connect(m_plugin, SIGNAL(infoMessage(QString)), @@ -180,7 +181,7 @@ void VersionControlObserver::verifyDirectory() void VersionControlObserver::slotThreadFinished() { - if (m_plugin == 0) { + if (!m_plugin) { return; } @@ -222,8 +223,8 @@ void VersionControlObserver::slotThreadFinished() void VersionControlObserver::updateItemStates() { - Q_ASSERT(m_plugin != 0); - if (m_updateItemStatesThread == 0) { + Q_ASSERT(m_plugin); + if (!m_updateItemStatesThread) { m_updateItemStatesThread = new UpdateItemStatesThread(); connect(m_updateItemStatesThread, SIGNAL(finished()), this, SLOT(slotThreadFinished())); @@ -282,7 +283,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) { if (enabledPlugins.contains((*it)->name())) { KVersionControlPlugin* plugin = (*it)->createInstance(); - if (plugin != 0) { + if (plugin) { plugins.append(plugin); } } @@ -330,7 +331,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director bool VersionControlObserver::isVersioned() const { - return m_dolphinModel->hasVersionData() && (m_plugin != 0); + return m_dolphinModel->hasVersionData() && m_plugin; } #include "versioncontrolobserver.moc" diff --git a/src/views/viewextensionsfactory.cpp b/src/views/viewextensionsfactory.cpp index adf9da3fc..1a395dea9 100644 --- a/src/views/viewextensionsfactory.cpp +++ b/src/views/viewextensionsfactory.cpp @@ -155,7 +155,7 @@ bool ViewExtensionsFactory::autoFolderExpandingEnabled() const bool ViewExtensionsFactory::eventFilter(QObject* watched, QEvent* event) { Q_UNUSED(watched); - if ((event->type() == QEvent::Wheel) && (m_selectionManager != 0)) { + if ((event->type() == QEvent::Wheel) && m_selectionManager) { m_selectionManager->reset(); } return false; @@ -164,7 +164,7 @@ bool ViewExtensionsFactory::eventFilter(QObject* watched, QEvent* event) void ViewExtensionsFactory::slotZoomLevelChanged() { m_previewGenerator->updateIcons(); - if (m_selectionManager != 0) { + if (m_selectionManager) { m_selectionManager->reset(); } }