Commit 3d01e041 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent 982cf5b1
Pipeline #135227 passed with stage
in 1 minute and 45 seconds
......@@ -239,14 +239,14 @@ QModelIndex FolderViewContextManagerItem::findClosestIndex(const QModelIndex &pa
if (!index.isValid()) {
index = findRootIndex(wantedUrl);
if (!index.isValid()) {
return QModelIndex();
return {};
}
}
QUrl url = mModel->urlForIndex(index);
if (!url.isParentOf(wantedUrl)) {
qCWarning(GWENVIEW_APP_LOG) << url << "is not a parent of" << wantedUrl << "!";
return QModelIndex();
return {};
}
QString relativePath = QDir(url.path()).relativeFilePath(wantedUrl.path());
......
......@@ -254,7 +254,7 @@ struct SemanticInfoContextManagerItemPrivate : public Ui_SemanticInfoSideBarItem
const QStringList labels(labelMap.values());
for (const QString &label : labels) {
DecoratedTag *decoratedTag = new DecoratedTag(label);
auto *decoratedTag = new DecoratedTag(label);
mTagLayout->addWidget(decoratedTag);
}
mTagLayout->addWidget(mEditLabel);
......
......@@ -201,9 +201,7 @@ SideBarTabBar::SideBarTabBar(QWidget *parent)
setIconSize(QSize(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium));
}
SideBarTabBar::~SideBarTabBar()
{
}
SideBarTabBar::~SideBarTabBar() = default;
SideBarTabBar::TabButtonStyle SideBarTabBar::tabButtonStyle() const
{
......
......@@ -368,7 +368,7 @@ struct ViewMainPagePrivate {
QUrl url = view->url();
if (!url.isValid()) {
qCWarning(GWENVIEW_APP_LOG) << "View does not display any document!";
return QModelIndex();
return {};
}
SortedDirModel *dirModel = mGvCore->sortedDirModel();
......@@ -607,7 +607,7 @@ Document::Ptr ViewMainPage::currentDocument() const
{
if (!d->currentView()) {
LOG("!d->documentView()");
return Document::Ptr();
return {};
}
return d->currentView()->document();
......
......@@ -330,13 +330,13 @@ struct ThumbnailPagePrivate : public Ui_ThumbnailPage {
{
QUrl url = mUrlMap.value(mSrcBaseUrl);
if (!url.isValid()) {
return QUrl();
return {};
}
KIO::StatJob *job = KIO::stat(url);
KJobWidgets::setWindow(job, q);
if (!job->exec()) {
return QUrl();
return {};
}
KFileItem item(job->statResult(), url, true /* delayedMimeTypes */);
return item.isDir() ? url : QUrl();
......
......@@ -62,7 +62,7 @@ QString protocolForMimeType(const QString &mimeType)
// We don't want .svgz to be considered as archives because QtSvg knows
// how to decode gzip-ed svg files
cache.insert(mimeType, QString());
return QString();
return {};
}
QString protocol = KProtocolManager::protocolForArchiveMimetype(mimeType);
......
......@@ -28,8 +28,6 @@ BinderInternal::BinderInternal(QObject *parent)
{
}
BinderInternal::~BinderInternal()
{
}
BinderInternal::~BinderInternal() = default;
} // namespace
......@@ -50,9 +50,7 @@ DecoratedTag::DecoratedTag(const QString &text, QWidget *parent, Qt::WindowFlags
d->updateMargins();
}
Gwenview::DecoratedTag::~DecoratedTag() noexcept
{
}
Gwenview::DecoratedTag::~DecoratedTag() noexcept = default;
void DecoratedTag::changeEvent(QEvent *event)
{
......
......@@ -41,9 +41,7 @@ namespace Gwenview
class GWENVIEWLIB_EXPORT AbstractDocumentEditor
{
public:
virtual ~AbstractDocumentEditor()
{
}
virtual ~AbstractDocumentEditor() = default;
/**
* Replaces the current image with image.
......
......@@ -73,7 +73,7 @@ public:
virtual QByteArray rawData() const
{
return QByteArray();
return {};
}
virtual bool isEditable() const
......
......@@ -34,9 +34,7 @@ EmptyDocumentImpl::EmptyDocumentImpl(Document *document)
{
}
EmptyDocumentImpl::~EmptyDocumentImpl()
{
}
EmptyDocumentImpl::~EmptyDocumentImpl() = default;
void EmptyDocumentImpl::init()
{
......
......@@ -196,7 +196,7 @@ public:
}
Document::Ptr document() const override
{
return Document::Ptr();
return {};
}
void setDocument(const Document::Ptr &) override
{
......
......@@ -17,9 +17,7 @@ AlphaBackgroundItem::AlphaBackgroundItem(AbstractImageView *parent)
{
}
AlphaBackgroundItem::~AlphaBackgroundItem()
{
}
AlphaBackgroundItem::~AlphaBackgroundItem() = default;
AbstractImageView::AlphaBackgroundMode AlphaBackgroundItem::mode() const
{
......
......@@ -112,7 +112,7 @@ struct DocumentViewControllerPrivate {
setBackgroundColorModeIcons(mBackgroundColorModeAuto, mBackgroundColorModeLight, mBackgroundColorModeNeutral, mBackgroundColorModeDark);
QActionGroup *actionGroup = new QActionGroup(q);
auto *actionGroup = new QActionGroup(q);
actionGroup->addAction(mBackgroundColorModeAuto);
actionGroup->addAction(mBackgroundColorModeLight);
actionGroup->addAction(mBackgroundColorModeNeutral);
......
......@@ -231,7 +231,7 @@ struct ImageMetaInfoModelPrivate {
{
if (index.internalId() == NoGroup) {
if (index.column() != 0) {
return QVariant();
return {};
}
QString label = mMetaInfoGroupVector[index.row()]->label();
return QVariant(label);
......@@ -485,7 +485,7 @@ QString ImageMetaInfoModel::getValueForKey(const QString &key) const
QString ImageMetaInfoModel::keyForIndex(const QModelIndex &index) const
{
if (index.internalId() == NoGroup) {
return QString();
return {};
}
MetaInfoGroup *group = d->mMetaInfoGroupVector[index.internalId()];
return group->getKeyAt(index.row());
......@@ -494,19 +494,19 @@ QString ImageMetaInfoModel::keyForIndex(const QModelIndex &index) const
QModelIndex ImageMetaInfoModel::index(int row, int col, const QModelIndex &parent) const
{
if (col < 0 || col > 1) {
return QModelIndex();
return {};
}
if (!parent.isValid()) {
// This is a group
if (row < 0 || row >= d->mMetaInfoGroupVector.size()) {
return QModelIndex();
return {};
}
return createIndex(row, col, col == 0 ? NoGroup : NoGroupSpace);
} else {
// This is an entry
int group = parent.row();
if (row < 0 || row >= d->mMetaInfoGroupVector[group]->size()) {
return QModelIndex();
return {};
}
return createIndex(row, col, group);
}
......@@ -515,10 +515,10 @@ QModelIndex ImageMetaInfoModel::index(int row, int col, const QModelIndex &paren
QModelIndex ImageMetaInfoModel::parent(const QModelIndex &index) const
{
if (!index.isValid()) {
return QModelIndex();
return {};
}
if (index.internalId() == NoGroup || index.internalId() == NoGroupSpace) {
return QModelIndex();
return {};
} else {
return createIndex(index.internalId(), 0, NoGroup);
}
......@@ -543,21 +543,21 @@ int ImageMetaInfoModel::columnCount(const QModelIndex & /*parent*/) const
QVariant ImageMetaInfoModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) {
return QVariant();
return {};
}
switch (role) {
case Qt::DisplayRole:
return d->displayData(index);
default:
return QVariant();
return {};
}
}
QVariant ImageMetaInfoModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Vertical || role != Qt::DisplayRole) {
return QVariant();
return {};
}
QString caption;
......
......@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
// KF
// libjpeg
#include <stdio.h>
#include <cstdio>
#define XMD_H
extern "C" {
#include <jpeglib.h>
......
......@@ -21,10 +21,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "jpegcontent.h"
// System
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
extern "C" {
#include <jpeglib.h> // Must be included before transupp.h
......
......@@ -80,8 +80,8 @@ private:
struct Private;
Private *d;
JpegContent(const JpegContent &);
void operator=(const JpegContent &);
JpegContent(const JpegContent &) = delete;
void operator=(const JpegContent &) = delete;
void applyPendingTransformation();
int dotsPerMeter(const QString &keyName) const;
};
......
......@@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef JPEGERRORMANAGER_H
#define JPEGERRORMANAGER_H
#include <setjmp.h>
#include <csetjmp>
extern "C" {
#define XMD_H
......
......@@ -32,9 +32,7 @@ MprisMediaPlayer2::MprisMediaPlayer2(const QString &objectDBusPath, QAction *ful
connect(mFullScreenAction, &QAction::toggled, this, &MprisMediaPlayer2::onFullScreenActionToggled);
}
MprisMediaPlayer2::~MprisMediaPlayer2()
{
}
MprisMediaPlayer2::~MprisMediaPlayer2() = default;
bool MprisMediaPlayer2::canQuit() const
{
......@@ -80,12 +78,12 @@ QString MprisMediaPlayer2::desktopEntry() const
QStringList MprisMediaPlayer2::supportedUriSchemes() const
{
return QStringList();
return {};
}
QStringList MprisMediaPlayer2::supportedMimeTypes() const
{
return QStringList();
return {};
}
bool MprisMediaPlayer2::isFullscreen() const
......
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