diff --git a/iso/iso.cpp b/iso/iso.cpp --- a/iso/iso.cpp +++ b/iso/iso.cpp @@ -77,7 +77,7 @@ kio_isoProtocol::kio_isoProtocol(const QByteArray &pool, const QByteArray &app) : SlaveBase("iso", pool, app) { //qDebug() << "kio_isoProtocol::kio_isoProtocol" << endl; - m_isoFile = 0L; + m_isoFile = nullptr; } kio_isoProtocol::~kio_isoProtocol() @@ -115,7 +115,7 @@ if (m_isoFile) { m_isoFile->close(); delete m_isoFile; - m_isoFile = 0L; + m_isoFile = nullptr; } // Find where the iso file is in the full path @@ -174,7 +174,7 @@ if (!m_isoFile->open(QIODevice::ReadOnly)) { //qDebug() << "Opening " << isoFile << " failed." << endl; delete m_isoFile; - m_isoFile = 0L; + m_isoFile = nullptr; return false; } @@ -234,7 +234,7 @@ finished(); // And let go of the iso file - for people who want to unmount a cdrom after that delete m_isoFile; - m_isoFile = 0L; + m_isoFile = nullptr; return; } @@ -316,7 +316,7 @@ // And let go of the iso file - for people who want to unmount a cdrom after that delete m_isoFile; - m_isoFile = 0L; + m_isoFile = nullptr; return; } @@ -342,7 +342,7 @@ unsigned long long size, pos = 0; bool mime = false, zlib = false; QByteArray fileData, pointer_block, inbuf, outbuf; - char *pptr = 0; + char *pptr = nullptr; compressed_file_header *hdr; int block_shift; unsigned long nblocks; @@ -492,7 +492,7 @@ return; } - const KIsoFile* isoFileEntry = static_cast(isoEntry); + const auto* isoFileEntry = dynamic_cast(isoEntry); if (!isoEntry->symLinkTarget().isEmpty()) { //qDebug() << "Redirection to " << isoEntry->symLinkTarget() << endl; QUrl realURL = QUrl(url).resolved(QUrl(isoEntry->symLinkTarget())); diff --git a/iso/kiso.cpp b/iso/kiso.cpp --- a/iso/kiso.cpp +++ b/iso/kiso.cpp @@ -102,12 +102,12 @@ class KIso::KIsoPrivate { public: - KIsoPrivate() {} + KIsoPrivate() = default; QStringList dirList; }; KIso::KIso(const QString& filename, const QString & _mimetype) - : KArchive(0L) + : KArchive(nullptr) { KRFUNC; KRDEBUG("Starting KIso: " << filename << " - type: " << _mimetype); @@ -229,14 +229,14 @@ { KRFUNC; - KIso *iso = static_cast(udata); + auto *iso = static_cast(udata); QString path, user, group, symlink; int i; int access; int time, cdate, adate; rr_entry rr; bool special = false; - KArchiveEntry *entry = NULL, *oldentry = NULL; + KArchiveEntry *entry = nullptr, *oldentry = nullptr; char z_algo[2], z_params[2]; long long z_size = 0; @@ -296,20 +296,20 @@ } else { entry = new KIsoFile(iso, path, access, time, adate, cdate, user, group, symlink, (long long)(isonum_733(idr->extent)) << (long long)11, isonum_733(idr->size)); - if (z_size)(static_cast (entry))->setZF(z_algo, z_params, z_size); + if (z_size)(dynamic_cast (entry))->setZF(z_algo, z_params, z_size); } iso->dirent->addEntry(entry); } if ((idr->flags[0] & 2) && (iso->level == 0 || !special)) { if (iso->level) { oldentry = iso->dirent; - iso->dirent = static_cast(entry); + iso->dirent = dynamic_cast(entry); } iso->level++; ProcessDir(&readf, isonum_733(idr->extent), isonum_733(idr->size), &mycallb, udata); iso->level--; - if (iso->level) iso->dirent = static_cast(oldentry); + if (iso->level) iso->dirent = dynamic_cast(oldentry); } return 0; } diff --git a/iso/kisodirectory.cpp b/iso/kisodirectory.cpp --- a/iso/kisodirectory.cpp +++ b/iso/kisodirectory.cpp @@ -32,5 +32,4 @@ } KIsoDirectory::~KIsoDirectory() -{ -} += default; diff --git a/iso/kisofile.cpp b/iso/kisofile.cpp --- a/iso/kisofile.cpp +++ b/iso/kisofile.cpp @@ -33,8 +33,7 @@ } KIsoFile::~KIsoFile() -{ -} += default; void KIsoFile::setZF(char algo[2], char parms[2], long long realsize) { diff --git a/iso/qfilehack.cpp b/iso/qfilehack.cpp --- a/iso/qfilehack.cpp +++ b/iso/qfilehack.cpp @@ -21,16 +21,14 @@ #include "qfilehack.h" QFileHack::QFileHack() -{ -} += default; QFileHack::QFileHack(const QString & name) : QFile(name) { } QFileHack::~QFileHack() -{ -} += default; bool QFileHack::open(QFile::OpenMode m) { diff --git a/krArc/krarc.h b/krArc/krarc.h --- a/krArc/krarc.h +++ b/krArc/krarc.h @@ -46,15 +46,15 @@ Q_OBJECT public: kio_krarcProtocol(const QByteArray &pool_socket, const QByteArray &app_socket); - virtual ~kio_krarcProtocol(); - virtual void stat(const QUrl &url) Q_DECL_OVERRIDE; - virtual void get(const QUrl &url) Q_DECL_OVERRIDE; - virtual void put(const QUrl &url, int permissions, KIO::JobFlags flags) Q_DECL_OVERRIDE; - virtual void mkdir(const QUrl &url, int permissions) Q_DECL_OVERRIDE; - virtual void listDir(const QUrl &url) Q_DECL_OVERRIDE; - virtual void del(QUrl const & url, bool isFile) Q_DECL_OVERRIDE; - virtual void copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags) Q_DECL_OVERRIDE; - virtual void rename(const QUrl &src, const QUrl & dest, KIO::JobFlags flags) Q_DECL_OVERRIDE; + ~kio_krarcProtocol() override; + void stat(const QUrl &url) Q_DECL_OVERRIDE; + void get(const QUrl &url) Q_DECL_OVERRIDE; + void put(const QUrl &url, int permissions, KIO::JobFlags flags) Q_DECL_OVERRIDE; + void mkdir(const QUrl &url, int permissions) Q_DECL_OVERRIDE; + void listDir(const QUrl &url) Q_DECL_OVERRIDE; + void del(QUrl const & url, bool isFile) Q_DECL_OVERRIDE; + void copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags) Q_DECL_OVERRIDE; + void rename(const QUrl &src, const QUrl & dest, KIO::JobFlags flags) Q_DECL_OVERRIDE; public slots: void receivedData(KProcess *, QByteArray &); @@ -68,10 +68,10 @@ virtual bool setArcFile(const QUrl &url); virtual QString getPassword(); virtual void invalidatePassword(); - QString getPath(const QUrl &url, QUrl::FormattingOptions options = 0); + QString getPath(const QUrl &url, QUrl::FormattingOptions options = nullptr); QString localeEncodedString(QString str); - QByteArray encodeString(QString); + QByteArray encodeString(const QString&); QString decodeString(char *); // archive specific commands @@ -96,8 +96,8 @@ /** find the UDSEntry of a file in a directory. */ KIO::UDSEntry* findFileEntry(const QUrl &url); /** add a new directory (file list container). */ - KIO::UDSEntryList* addNewDir(QString path); - QString fullPathName(QString name); + KIO::UDSEntryList* addNewDir(const QString& path); + QString fullPathName(const QString& name); static QString detectFullPathName(QString name); bool checkWriteSupport(); diff --git a/krArc/krarc.cpp b/krArc/krarc.cpp --- a/krArc/krarc.cpp +++ b/krArc/krarc.cpp @@ -71,23 +71,23 @@ { public: KrArcCodec(QTextCodec * codec) : originalCodec(codec) {} - virtual ~KrArcCodec() {} + ~KrArcCodec() override = default; - virtual QByteArray name() const Q_DECL_OVERRIDE { + QByteArray name() const Q_DECL_OVERRIDE { return originalCodec->name(); } - virtual QList aliases() const Q_DECL_OVERRIDE { + QList aliases() const Q_DECL_OVERRIDE { return originalCodec->aliases(); } - virtual int mibEnum() const Q_DECL_OVERRIDE { + int mibEnum() const Q_DECL_OVERRIDE { return originalCodec->mibEnum(); } protected: - virtual QString convertToUnicode(const char *in, int length, ConverterState *state) const Q_DECL_OVERRIDE { + QString convertToUnicode(const char *in, int length, ConverterState *state) const Q_DECL_OVERRIDE { return originalCodec->toUnicode(in, length, state); } - virtual QByteArray convertFromUnicode(const QChar *in, int length, ConverterState *state) const Q_DECL_OVERRIDE { + QByteArray convertFromUnicode(const QChar *in, int length, ConverterState *state) const Q_DECL_OVERRIDE { // the QByteArray is embedded into the unicode charset (QProcess hell) QByteArray result; for (int i = 0; i != length; i++) { @@ -139,8 +139,8 @@ #ifdef KRARC_ENABLED kio_krarcProtocol::kio_krarcProtocol(const QByteArray &pool_socket, const QByteArray &app_socket) - : SlaveBase("kio_krarc", pool_socket, app_socket), archiveChanged(true), arcFile(0L), extArcReady(false), - password(QString()), krConf("krusaderrc"), codec(0) + : SlaveBase("kio_krarc", pool_socket, app_socket), archiveChanged(true), arcFile(nullptr), extArcReady(false), + password(QString()), krConf("krusaderrc"), codec(nullptr) { KRFUNC; confGrp = KConfigGroup(&krConf, "Dependencies"); @@ -193,7 +193,7 @@ void kio_krarcProtocol::receivedData(KProcess *, QByteArray &d) { KRFUNC; - QByteArray buf(d); + const QByteArray& buf(d); data(buf); processedSize(d.length()); decompressedLen += d.length(); @@ -874,7 +874,7 @@ KRFUNC; KRDEBUG(url.fileName()); QString path = getPath(url); - time_t currTime = time(0); + time_t currTime = time(nullptr); archiveChanged = true; newArchiveURL = true; // is the file already set ? @@ -886,7 +886,7 @@ currentCharset = metaData("Charset"); codec = QTextCodec::codecForName(currentCharset.toLatin1()); - if (codec == 0) + if (codec == nullptr) codec = QTextCodec::codecForMib(4 /* latin-1 */); delete arcFile; @@ -908,7 +908,7 @@ if (arcFile) { delete arcFile; password.clear(); - arcFile = 0L; + arcFile = nullptr; } QString newPath = path; if (newPath.right(1) != DIR_SEPARATOR) newPath = newPath + DIR_SEPARATOR; @@ -929,7 +929,7 @@ currentCharset = metaData("Charset"); codec = QTextCodec::codecForName(currentCharset.toLatin1()); - if (codec == 0) + if (codec == nullptr) codec = QTextCodec::codecForMib(4 /* latin-1 */); } @@ -1018,7 +1018,7 @@ dirDict.clear(); // add the "/" directory - UDSEntryList* root = new UDSEntryList(); + auto* root = new UDSEntryList(); dirDict.insert(DIR_SEPARATOR, root); // and the "/" UDSEntry UDSEntry entry; @@ -1116,11 +1116,11 @@ { KRFUNC; QString arcDir = findArcDirectory(url); - if (arcDir.isEmpty()) return 0; + if (arcDir.isEmpty()) return nullptr; QHash::iterator itef = dirDict.find(arcDir); if (itef == dirDict.end()) - return 0; + return nullptr; UDSEntryList* dirList = itef.value(); QString name = getPath(url); @@ -1137,7 +1137,7 @@ (entry->stringValue(KIO::UDSEntry::UDS_NAME) == name)) return &(*entry); } - return 0; + return nullptr; } QString kio_krarcProtocol::nextWord(QString &s, char d) @@ -1177,7 +1177,7 @@ return mode; } -UDSEntryList* kio_krarcProtocol::addNewDir(QString path) +UDSEntryList* kio_krarcProtocol::addNewDir(const QString& path) { KRFUNC; UDSEntryList* dir; @@ -1231,7 +1231,7 @@ QString perm; mode_t mode = 0666; size_t size = 0; - time_t time = ::time(0); + time_t time = ::time(nullptr); QString fullName; if (arcType == "zip") { @@ -1322,7 +1322,7 @@ // next field is md5sum, ignore it nextWord(line); // permissions - mode = nextWord(line).toULong(0, 8); + mode = nextWord(line).toULong(nullptr, 8); // Owner & Group owner = nextWord(line); group = nextWord(line); @@ -1849,9 +1849,9 @@ name = name + EXEC_SUFFIX; QStringList path = QString::fromLocal8Bit(qgetenv("PATH")).split(':'); - for (QStringList::Iterator it = path.begin(); it != path.end(); ++it) { - if (QDir(*it).exists(name)) { - QString dir = *it; + for (auto & it : path) { + if (QDir(it).exists(name)) { + QString dir = it; if (!dir.endsWith(DIR_SEPARATOR)) dir += DIR_SEPARATOR; @@ -1861,7 +1861,7 @@ return name; } -QString kio_krarcProtocol::fullPathName(QString name) +QString kio_krarcProtocol::fullPathName(const QString& name) { // Note: KRFUNC was not used here in order to avoid filling the log with too much information KRDEBUG(name); @@ -1893,7 +1893,7 @@ return result; } -QByteArray kio_krarcProtocol::encodeString(QString str) +QByteArray kio_krarcProtocol::encodeString(const QString& str) { // Note: KRFUNC was not used here in order to avoid filling the log with too much information if (noencoding) diff --git a/krArc/krarcbasemanager.h b/krArc/krarcbasemanager.h --- a/krArc/krarcbasemanager.h +++ b/krArc/krarcbasemanager.h @@ -49,7 +49,7 @@ public: KrArcBaseManager() {} - QString detectArchive(bool &, QString, bool = true, bool = false); + QString detectArchive(bool &, const QString&, bool = true, bool = false); virtual void checkIf7zIsEncrypted(bool &, QString) = 0; static QString getShortTypeFromMime(const QString &); virtual ~KrArcBaseManager() {} diff --git a/krArc/krarcbasemanager.cpp b/krArc/krarcbasemanager.cpp --- a/krArc/krarcbasemanager.cpp +++ b/krArc/krarcbasemanager.cpp @@ -58,7 +58,7 @@ return exitCode == 0; } -QString KrArcBaseManager::detectArchive(bool &encrypted, QString fileName, bool checkEncrypted, bool fast) +QString KrArcBaseManager::detectArchive(bool &encrypted, const QString& fileName, bool checkEncrypted, bool fast) { encrypted = false; diff --git a/krArc/krlinecountingprocess.cpp b/krArc/krlinecountingprocess.cpp --- a/krArc/krlinecountingprocess.cpp +++ b/krArc/krlinecountingprocess.cpp @@ -21,7 +21,7 @@ #include "krlinecountingprocess.h" -KrLinecountingProcess::KrLinecountingProcess() : KProcess() +KrLinecountingProcess::KrLinecountingProcess() { setOutputChannelMode(KProcess::SeparateChannels); // without this output redirection has no effect! connect(this, &KrLinecountingProcess::readyReadStandardError, this, &KrLinecountingProcess::receivedError); diff --git a/krusader/ActionMan/actionman.h b/krusader/ActionMan/actionman.h --- a/krusader/ActionMan/actionman.h +++ b/krusader/ActionMan/actionman.h @@ -33,8 +33,8 @@ { Q_OBJECT public: - explicit ActionMan(QWidget* parent = 0); - ~ActionMan(); + explicit ActionMan(QWidget* parent = nullptr); + ~ActionMan() override; protected slots: void slotClose(); diff --git a/krusader/ActionMan/actionman.cpp b/krusader/ActionMan/actionman.cpp --- a/krusader/ActionMan/actionman.cpp +++ b/krusader/ActionMan/actionman.cpp @@ -38,7 +38,7 @@ setWindowModality(Qt::WindowModal); setWindowTitle(i18n("ActionMan - Manage Your Useractions")); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); userActionPage = new UserActionPage(this); @@ -61,8 +61,7 @@ } ActionMan::~ActionMan() -{ -} += default; void ActionMan::slotClose() { diff --git a/krusader/ActionMan/actionproperty.h b/krusader/ActionMan/actionproperty.h --- a/krusader/ActionMan/actionproperty.h +++ b/krusader/ActionMan/actionproperty.h @@ -32,8 +32,8 @@ { Q_OBJECT public: - explicit ActionProperty(QWidget *parent = 0, KrAction *action = 0); - ~ActionProperty(); + explicit ActionProperty(QWidget *parent = nullptr, KrAction *action = nullptr); + ~ActionProperty() override; /** * @return the currently displayed action @@ -48,15 +48,15 @@ * It also resets the changed() state. * @param action the action which should be displayd */ - void updateGUI(KrAction *action = 0); + void updateGUI(KrAction *action = nullptr); /** * This writes the displayed properties back into the action. * If no action is provided, the last used will be taken! * It also resets the changed() state. * @param action the action which should be manipulated */ - void updateAction(KrAction *action = 0); + void updateAction(KrAction *action = nullptr); /** * clears everything diff --git a/krusader/ActionMan/actionproperty.cpp b/krusader/ActionMan/actionproperty.cpp --- a/krusader/ActionMan/actionproperty.cpp +++ b/krusader/ActionMan/actionproperty.cpp @@ -94,8 +94,7 @@ } ActionProperty::~ActionProperty() -{ -} += default; void ActionProperty::changedShortcut(const QKeySequence& shortcut) { @@ -105,7 +104,7 @@ void ActionProperty::clear() { - _action = 0; + _action = nullptr; // This prevents the changed-signal from being emitted during the GUI-update _modified = true; // The real state is set at the end of this function. @@ -338,7 +337,7 @@ void ActionProperty::editProtocol() { - if (lbShowonlyProtocol->currentItem() == 0) + if (lbShowonlyProtocol->currentItem() == nullptr) return; bool ok; @@ -355,7 +354,7 @@ void ActionProperty::removeProtocol() { - if (lbShowonlyProtocol->currentItem() != 0) { + if (lbShowonlyProtocol->currentItem() != nullptr) { delete lbShowonlyProtocol->currentItem(); setModified(); } @@ -372,7 +371,7 @@ void ActionProperty::editPath() { - if (lbShowonlyPath->currentItem() == 0) + if (lbShowonlyPath->currentItem() == nullptr) return; bool ok; @@ -389,7 +388,7 @@ void ActionProperty::removePath() { - if (lbShowonlyPath->currentItem() != 0) { + if (lbShowonlyPath->currentItem() != nullptr) { delete lbShowonlyPath->currentItem(); setModified(); } @@ -413,7 +412,7 @@ void ActionProperty::editMime() { - if (lbShowonlyMime->currentItem() == 0) + if (lbShowonlyMime->currentItem() == nullptr) return; bool ok; @@ -430,7 +429,7 @@ void ActionProperty::removeMime() { - if (lbShowonlyMime->currentItem() != 0) { + if (lbShowonlyMime->currentItem() != nullptr) { delete lbShowonlyMime->currentItem(); setModified(); } @@ -454,7 +453,7 @@ void ActionProperty::editFile() { - if (lbShowonlyFile->currentItem() == 0) + if (lbShowonlyFile->currentItem() == nullptr) return; bool ok; @@ -471,7 +470,7 @@ void ActionProperty::removeFile() { - if (lbShowonlyFile->currentItem() != 0) { + if (lbShowonlyFile->currentItem() != nullptr) { delete lbShowonlyFile->currentItem(); setModified(); } diff --git a/krusader/ActionMan/addplaceholderpopup.cpp b/krusader/ActionMan/addplaceholderpopup.cpp --- a/krusader/ActionMan/addplaceholderpopup.cpp +++ b/krusader/ActionMan/addplaceholderpopup.cpp @@ -108,7 +108,7 @@ QString AddPlaceholderPopup::getPlaceholder(const QPoint& pos) { QAction *res = exec(pos); - if (res == 0) + if (res == nullptr) return QString(); // add the selected flag to the command line @@ -126,7 +126,7 @@ // KMessageBox::sorry( this, "BOFH Excuse #93:\nFeature not yet implemented" ); // return QString(); // } - ParameterDialog* parameterDialog = new ParameterDialog(currentPlaceholder, this); + auto* parameterDialog = new ParameterDialog(currentPlaceholder, this); QString panel, parameter = parameterDialog->getParameter(); delete parameterDialog; // indicate the panel with 'a' 'o', 'l', 'r' or '_'. @@ -154,15 +154,15 @@ ParameterDialog::ParameterDialog(const exp_placeholder* currentPlaceholder, QWidget *parent) : QDialog(parent) { setWindowTitle(i18n("User Action Parameter Dialog")); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); _parameter.clear(); _parameterCount = currentPlaceholder->parameterCount(); QWidget *page = new QWidget(this); mainLayout->addWidget(page); - QVBoxLayout* layout = new QVBoxLayout(page); + auto* layout = new QVBoxLayout(page); layout->setSpacing(11); layout->setContentsMargins(0, 0, 0, 0); @@ -261,7 +261,7 @@ ///////////// ParameterText ParameterText::ParameterText(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); @@ -293,14 +293,14 @@ ///////////// ParameterPlaceholder ParameterPlaceholder::ParameterPlaceholder(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(new QLabel(i18n(parameter.description().toUtf8()), this)); QWidget * hboxWidget = new QWidget(this); layout->addWidget(hboxWidget); - QHBoxLayout * hbox = new QHBoxLayout(hboxWidget); + auto * hbox = new QHBoxLayout(hboxWidget); hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); @@ -333,16 +333,16 @@ } void ParameterPlaceholder::addPlaceholder() { - AddPlaceholderPopup* popup = new AddPlaceholderPopup(this); + auto* popup = new AddPlaceholderPopup(this); QString exp = popup->getPlaceholder(mapToGlobal(QPoint(_button->pos().x() + _button->width() + 6, _button->pos().y() + _button->height() / 2))); _lineEdit->insert(exp); delete popup; } ///////////// ParameterYes ParameterYes::ParameterYes(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); @@ -373,7 +373,7 @@ ///////////// ParameterNo ParameterNo::ParameterNo(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); @@ -404,15 +404,15 @@ ///////////// ParameterFile ParameterFile::ParameterFile(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(new QLabel(i18n(parameter.description().toUtf8()), this)); QWidget * hboxWidget = new QWidget(this); layout->addWidget(hboxWidget); - QHBoxLayout * hbox = new QHBoxLayout(hboxWidget); + auto * hbox = new QHBoxLayout(hboxWidget); hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); @@ -452,7 +452,7 @@ ///////////// ParameterChoose ParameterChoose::ParameterChoose(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); @@ -481,7 +481,7 @@ ///////////// ParameterSelect ParameterSelect::ParameterSelect(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); @@ -517,14 +517,14 @@ ///////////// ParameterGoto ParameterGoto::ParameterGoto(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(new QLabel(i18n(parameter.description().toUtf8()), this)); QWidget * hboxWidget = new QWidget(this); - QHBoxLayout * hbox = new QHBoxLayout(hboxWidget); + auto * hbox = new QHBoxLayout(hboxWidget); hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); @@ -569,16 +569,16 @@ } void ParameterGoto::addPlaceholder() { - AddPlaceholderPopup* popup = new AddPlaceholderPopup(this); + auto* popup = new AddPlaceholderPopup(this); QString exp = popup->getPlaceholder(mapToGlobal(QPoint(_placeholderButton->pos().x() + _placeholderButton->width() + 6, _placeholderButton->pos().y() + _placeholderButton->height() / 2))); _lineEdit->insert(exp); delete popup; } ///////////// ParameterSyncprofile ParameterSyncprofile::ParameterSyncprofile(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); @@ -608,7 +608,7 @@ ///////////// ParameterSearch ParameterSearch::ParameterSearch(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); @@ -638,7 +638,7 @@ ///////////// ParameterPanelprofile ParameterPanelprofile::ParameterPanelprofile(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); @@ -668,7 +668,7 @@ ///////////// ParameterInt ParameterInt::ParameterInt(const exp_parameter& parameter, QWidget* parent) : ParameterBase(parameter, parent) { - QHBoxLayout* layout = new QHBoxLayout(this); + auto* layout = new QHBoxLayout(this); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); diff --git a/krusader/ActionMan/useractionlistview.h b/krusader/ActionMan/useractionlistview.h --- a/krusader/ActionMan/useractionlistview.h +++ b/krusader/ActionMan/useractionlistview.h @@ -33,18 +33,18 @@ Q_OBJECT public: - explicit UserActionListView(QWidget* parent = 0); - ~UserActionListView(); - virtual QSize sizeHint() const Q_DECL_OVERRIDE; + explicit UserActionListView(QWidget* parent = nullptr); + ~UserActionListView() override; + QSize sizeHint() const Q_DECL_OVERRIDE; void update(); void update(KrAction* action); UserActionListViewItem* insertAction(KrAction* action); KrAction* currentAction() const; void setCurrentAction(const KrAction*); - QDomDocument dumpSelectedActions(QDomDocument* mergeDoc = 0) const; + QDomDocument dumpSelectedActions(QDomDocument* mergeDoc = nullptr) const; void removeSelectedActions(); @@ -69,16 +69,16 @@ public: UserActionListViewItem(QTreeWidget* view, KrAction* action); UserActionListViewItem(QTreeWidgetItem* item, KrAction* action); - ~UserActionListViewItem(); + ~UserActionListViewItem() override; void setAction(KrAction* action); KrAction* action() const; void update(); /** * This reimplements qt's compare-function in order to have categories on the top of the list */ - virtual bool operator<(const QTreeWidgetItem &other) const Q_DECL_OVERRIDE; + bool operator<(const QTreeWidgetItem &other) const Q_DECL_OVERRIDE; private: KrAction* _action; diff --git a/krusader/ActionMan/useractionlistview.cpp b/krusader/ActionMan/useractionlistview.cpp --- a/krusader/ActionMan/useractionlistview.cpp +++ b/krusader/ActionMan/useractionlistview.cpp @@ -53,8 +53,7 @@ } UserActionListView::~UserActionListView() -{ -} += default; QSize UserActionListView::sizeHint() const { @@ -90,7 +89,7 @@ UserActionListViewItem* UserActionListView::insertAction(KrAction* action) { if (! action) - return 0; + return nullptr; UserActionListViewItem* item; @@ -118,28 +117,28 @@ return *it; it++; } - return 0; + return nullptr; } UserActionListViewItem* UserActionListView::findActionItem(const KrAction* action) { QTreeWidgetItemIterator it(this); while (*it) { - if (UserActionListViewItem* item = dynamic_cast(*it)) { + if (auto* item = dynamic_cast(*it)) { if (item->action() == action) return item; } it++; } - return 0; + return nullptr; } KrAction * UserActionListView::currentAction() const { - if (UserActionListViewItem* item = dynamic_cast(currentItem())) + if (auto* item = dynamic_cast(currentItem())) return item->action(); else - return 0; + return nullptr; } void UserActionListView::setCurrentAction(const KrAction* action) @@ -154,7 +153,7 @@ { QTreeWidgetItemIterator it(this); while (*it) { - if (UserActionListViewItem* item = dynamic_cast(*it)) { + if (auto* item = dynamic_cast(*it)) { setCurrentItem(item); break; } @@ -179,9 +178,8 @@ doc = UserAction::createEmptyDoc(); QDomElement root = doc.documentElement(); - for (int i = 0; i < list.size(); ++i) { - QTreeWidgetItem* item = list.at(i); - if (UserActionListViewItem* actionItem = dynamic_cast(item)) + for (auto item : list) { + if (auto* actionItem = dynamic_cast(item)) root.appendChild(actionItem->action()->xmlDump(doc)); } @@ -192,9 +190,8 @@ { QList list = selectedItems(); - for (int i = 0; i < list.size(); ++i) { - QTreeWidgetItem* item = list.at(i); - if (UserActionListViewItem* actionItem = dynamic_cast(item)) { + for (auto item : list) { + if (auto* actionItem = dynamic_cast(item)) { delete actionItem->action(); // remove the action itself delete actionItem; // remove the action from the list } // if @@ -216,8 +213,7 @@ } UserActionListViewItem::~UserActionListViewItem() -{ -} += default; void UserActionListViewItem::setAction(KrAction * action) { diff --git a/krusader/ActionMan/useractionpage.h b/krusader/ActionMan/useractionpage.h --- a/krusader/ActionMan/useractionpage.h +++ b/krusader/ActionMan/useractionpage.h @@ -34,7 +34,7 @@ Q_OBJECT public: explicit UserActionPage(QWidget* parent); - ~UserActionPage(); + ~UserActionPage() override; /** * Be sure to call this function before you delete this page!! diff --git a/krusader/ActionMan/useractionpage.cpp b/krusader/ActionMan/useractionpage.cpp --- a/krusader/ActionMan/useractionpage.cpp +++ b/krusader/ActionMan/useractionpage.cpp @@ -54,12 +54,12 @@ UserActionPage::UserActionPage(QWidget* parent) : QWidget(parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + auto* layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(6); // 0px margin, 6px item-spacing // ======== pseudo-toolbar start ======== - QHBoxLayout* toolbarLayout = new QHBoxLayout; // neither margin nor spacing for the toolbar with autoRaise + auto* toolbarLayout = new QHBoxLayout; // neither margin nor spacing for the toolbar with autoRaise toolbarLayout->setSpacing(0); toolbarLayout->setContentsMargins(0, 0, 0, 0); @@ -114,7 +114,7 @@ ); */ layout->addLayout(toolbarLayout); - QSplitter *split = new QSplitter(this); + auto *split = new QSplitter(this); layout->addWidget(split, 1000); // again a very large stretch-factor to fix the height of the toolbar actionTree = new UserActionListView(split); @@ -138,8 +138,7 @@ } UserActionPage::~UserActionPage() -{ -} += default; bool UserActionPage::continueInSpiteOfChanges() { diff --git a/krusader/Archive/abstractthreadedjob.h b/krusader/Archive/abstractthreadedjob.h --- a/krusader/Archive/abstractthreadedjob.h +++ b/krusader/Archive/abstractthreadedjob.h @@ -112,9 +112,9 @@ QUrl downloadIfRemote(const QUrl &baseUrl, const QStringList & files); void countLocalFiles(const QUrl &baseUrl, const QStringList &names, unsigned long &totalFiles); - void sendError(int errorCode, QString message); - void sendInfo(QString message, QString a1 = QString(), QString a2 = QString(), QString a3 = QString(), QString a4 = QString()); - void sendReset(QString message, QString a1 = QString(""), QString a2 = QString(""), QString a3 = QString(""), QString a4 = QString("")); + void sendError(int errorCode, const QString& message); + void sendInfo(const QString& message, const QString& a1 = QString(), const QString& a2 = QString(), const QString& a3 = QString(), const QString& a4 = QString()); + void sendReset(const QString& message, const QString& a1 = QString(""), const QString& a2 = QString(""), const QString& a3 = QString(""), const QString& a4 = QString("")); void sendSuccess(); void sendMessage(const QString &message); void sendMaxProgressValue(qulonglong value); diff --git a/krusader/Archive/abstractthreadedjob.cpp b/krusader/Archive/abstractthreadedjob.cpp --- a/krusader/Archive/abstractthreadedjob.cpp +++ b/krusader/Archive/abstractthreadedjob.cpp @@ -41,8 +41,8 @@ extern KRarcHandler arcHandler; -AbstractThreadedJob::AbstractThreadedJob() : KIO::Job(), _locker(), _waiter(), _stack(), _maxProgressValue(0), - _currentProgress(0), _exiting(false), _jobThread(0) +AbstractThreadedJob::AbstractThreadedJob() : _maxProgressValue(0), + _currentProgress(0), _exiting(false), _jobThread(nullptr) { } @@ -72,14 +72,14 @@ bool AbstractThreadedJob::event(QEvent *e) { if (e->type() == QEvent::User) { - UserEvent *event = (UserEvent*) e; + auto *event = (UserEvent*) e; switch (event->command()) { case CMD_SUCCESS: { emitResult(); } break; case CMD_ERROR: { - int error = event->args()[ 0 ].value(); + auto error = event->args()[ 0 ].value(); QString errorText = event->args()[ 1 ].value(); setError(error); @@ -139,13 +139,13 @@ } break; case CMD_MAXPROGRESSVALUE: { - qulonglong maxValue = event->args()[ 0 ].value(); + auto maxValue = event->args()[ 0 ].value(); _maxProgressValue = maxValue; _currentProgress = 0; } break; case CMD_ADD_PROGRESS: { - qulonglong progress = event->args()[ 0 ].value(); + auto progress = event->args()[ 0 ].value(); _currentProgress += progress; if (_maxProgressValue != 0) { setPercent(100 * _currentProgress / _maxProgressValue); @@ -167,16 +167,16 @@ QString path = event->args()[ 0 ].value(); QString password = KRarcHandler::getPassword(path); - QList *resultResp = new QList (); + auto *resultResp = new QList (); (*resultResp) << password; addEventResponse(resultResp); } break; case CMD_MESSAGE: { QString message = event->args()[ 0 ].value(); - KIO::JobUiDelegate *ui = static_cast(uiDelegate()); - KMessageBox::information(ui ? ui->window() : 0, message); - QList *resultResp = new QList (); + auto *ui = dynamic_cast(uiDelegate()); + KMessageBox::information(ui ? ui->window() : nullptr, message); + auto *resultResp = new QList (); addEventResponse(resultResp); } break; @@ -201,7 +201,7 @@ QApplication::postEvent(this, event); _waiter.wait(&_locker); if (_exiting) - return 0; + return nullptr; QList *resp = _stack.pop(); _locker.unlock(); return resp; @@ -214,7 +214,7 @@ void AbstractThreadedJob::slotDownloadResult(KJob* job) { - QList *resultResp = new QList (); + auto *resultResp = new QList (); if (job) { (*resultResp) << QVariant(job->error()); (*resultResp) << QVariant(job->errorText()); @@ -256,57 +256,57 @@ AbstractJobThread * _jobThread; public: explicit AbstractJobObserver(AbstractJobThread * thread): _jobThread(thread) {} - virtual ~AbstractJobObserver() {} + ~AbstractJobObserver() override = default; - virtual void processEvents() Q_DECL_OVERRIDE { + void processEvents() Q_DECL_OVERRIDE { usleep(1000); qApp->processEvents(); } - virtual void subJobStarted(const QString & jobTitle, int count) Q_DECL_OVERRIDE { + void subJobStarted(const QString & jobTitle, int count) Q_DECL_OVERRIDE { _jobThread->sendReset(jobTitle); _jobThread->sendMaxProgressValue(count); } - virtual void subJobStopped() Q_DECL_OVERRIDE { + void subJobStopped() Q_DECL_OVERRIDE { } - virtual bool wasCancelled() Q_DECL_OVERRIDE { + bool wasCancelled() Q_DECL_OVERRIDE { return _jobThread->_exited; } - virtual void error(const QString & error) Q_DECL_OVERRIDE { + void error(const QString & error) Q_DECL_OVERRIDE { _jobThread->sendError(KIO::ERR_NO_CONTENT, error); } - virtual void detailedError(const QString & error, const QString & details) Q_DECL_OVERRIDE { + void detailedError(const QString & error, const QString & details) Q_DECL_OVERRIDE { _jobThread->sendError(KIO::ERR_NO_CONTENT, error + '\n' + details); } - virtual void incrementProgress(int c) Q_DECL_OVERRIDE { + void incrementProgress(int c) Q_DECL_OVERRIDE { _jobThread->sendAddProgress(c, _jobThread->_progressTitle); } }; -AbstractJobThread::AbstractJobThread() : _job(0), _downloadTempDir(0), _observer(0), _tempFile(0), - _tempDir(0), _exited(false) +AbstractJobThread::AbstractJobThread() : _job(nullptr), _downloadTempDir(nullptr), _observer(nullptr), _tempFile(nullptr), + _tempDir(nullptr), _exited(false) { } AbstractJobThread::~AbstractJobThread() { if (_downloadTempDir) { delete _downloadTempDir; - _downloadTempDir = 0; + _downloadTempDir = nullptr; } if (_observer) { delete _observer; - _observer = 0; + _observer = nullptr; } if (_tempFile) { delete _tempFile; - _tempFile = 0; + _tempFile = nullptr; } } @@ -318,7 +318,7 @@ _loop = threadLoop; threadLoop->exec(); - _loop = 0; + _loop = nullptr; delete threadLoop; } @@ -363,12 +363,12 @@ args << KrServices::toStringList(urlList); args << dest; - UserEvent * downloadEvent = new UserEvent(CMD_DOWNLOAD_FILES, args); + auto * downloadEvent = new UserEvent(CMD_DOWNLOAD_FILES, args); QList * result = _job->getEventResponse(downloadEvent); - if (result == 0) + if (result == nullptr) return QUrl(); - int errorCode = (*result)[ 0 ].value(); + auto errorCode = (*result)[ 0 ].value(); QString errorText = (*result)[ 1 ].value(); delete result; @@ -418,54 +418,54 @@ QList args; - UserEvent * errorEvent = new UserEvent(CMD_SUCCESS, args); + auto * errorEvent = new UserEvent(CMD_SUCCESS, args); _job->sendEvent(errorEvent); } -void AbstractJobThread::sendError(int errorCode, QString message) +void AbstractJobThread::sendError(int errorCode, const QString& message) { terminate(); QList args; args << errorCode; args << message; - UserEvent * errorEvent = new UserEvent(CMD_ERROR, args); + auto * errorEvent = new UserEvent(CMD_ERROR, args); _job->sendEvent(errorEvent); } -void AbstractJobThread::sendInfo(QString message, QString a1, QString a2, QString a3, QString a4) +void AbstractJobThread::sendInfo(const QString& message, const QString& a1, const QString& a2, const QString& a3, const QString& a4) { QList args; args << message; args << a1; args << a2; args << a3; args << a4; - UserEvent * infoEvent = new UserEvent(CMD_INFO, args); + auto * infoEvent = new UserEvent(CMD_INFO, args); _job->sendEvent(infoEvent); } -void AbstractJobThread::sendReset(QString message, QString a1, QString a2, QString a3, QString a4) +void AbstractJobThread::sendReset(const QString& message, const QString& a1, const QString& a2, const QString& a3, const QString& a4) { QList args; args << message; args << a1; args << a2; args << a3; args << a4; - UserEvent * infoEvent = new UserEvent(CMD_RESET, args); + auto * infoEvent = new UserEvent(CMD_RESET, args); _job->sendEvent(infoEvent); } void AbstractJobThread::sendMaxProgressValue(qulonglong value) { QList args; args << value; - UserEvent * infoEvent = new UserEvent(CMD_MAXPROGRESSVALUE, args); + auto * infoEvent = new UserEvent(CMD_MAXPROGRESSVALUE, args); _job->sendEvent(infoEvent); } @@ -477,7 +477,7 @@ if (!progress.isNull()) args << progress; - UserEvent * infoEvent = new UserEvent(CMD_ADD_PROGRESS, args); + auto * infoEvent = new UserEvent(CMD_ADD_PROGRESS, args); _job->sendEvent(infoEvent); } @@ -489,7 +489,7 @@ return; } - for (const QString name : dir.entryList()) { + for (const QString& name : dir.entryList()) { if (stop) return; @@ -507,7 +507,7 @@ FileSystem *calcSpaceFileSystem = FileSystemProvider::instance().getFilesystem(baseUrl); calcSpaceFileSystem->scanDir(baseUrl); - for (const QString name : names) { + for (const QString& name : names) { if (_exited) return; @@ -531,7 +531,7 @@ bool AbstractJobThread::uploadTempFiles() { - if (_tempFile != 0 || _tempDir != 0) { + if (_tempFile != nullptr || _tempDir != nullptr) { sendInfo(i18n("Uploading to remote destination")); if (_tempFile) { @@ -542,12 +542,12 @@ args << KrServices::toStringList(urlList); args << _tempFileTarget; - UserEvent * uploadEvent = new UserEvent(CMD_UPLOAD_FILES, args); + auto * uploadEvent = new UserEvent(CMD_UPLOAD_FILES, args); QList * result = _job->getEventResponse(uploadEvent); - if (result == 0) + if (result == nullptr) return false; - int errorCode = (*result)[ 0 ].value(); + auto errorCode = (*result)[ 0 ].value(); QString errorText = (*result)[ 1 ].value(); delete result; @@ -574,12 +574,12 @@ args << KrServices::toStringList(urlList); args << _tempDirTarget; - UserEvent * uploadEvent = new UserEvent(CMD_UPLOAD_FILES, args); + auto * uploadEvent = new UserEvent(CMD_UPLOAD_FILES, args); QList * result = _job->getEventResponse(uploadEvent); - if (result == 0) + if (result == nullptr) return false; - int errorCode = (*result)[ 0 ].value(); + auto errorCode = (*result)[ 0 ].value(); QString errorText = (*result)[ 1 ].value(); delete result; @@ -598,9 +598,9 @@ QList args; args << path; - UserEvent * getPasswdEvent = new UserEvent(CMD_GET_PASSWORD, args); + auto * getPasswdEvent = new UserEvent(CMD_GET_PASSWORD, args); QList * result = _job->getEventResponse(getPasswdEvent); - if (result == 0) + if (result == nullptr) return QString(); QString password = (*result)[ 0 ].value(); @@ -616,9 +616,9 @@ QList args; args << message; - UserEvent * getPasswdEvent = new UserEvent(CMD_MESSAGE, args); + auto * getPasswdEvent = new UserEvent(CMD_MESSAGE, args); QList * result = _job->getEventResponse(getPasswdEvent); - if (result == 0) + if (result == nullptr) return; delete result; } diff --git a/krusader/Archive/kr7zencryptionchecker.h b/krusader/Archive/kr7zencryptionchecker.h --- a/krusader/Archive/kr7zencryptionchecker.h +++ b/krusader/Archive/kr7zencryptionchecker.h @@ -38,7 +38,7 @@ Kr7zEncryptionChecker(); protected: - virtual void setupChildProcess() Q_DECL_OVERRIDE; + void setupChildProcess() Q_DECL_OVERRIDE; public slots: void receivedOutput(); diff --git a/krusader/Archive/kr7zencryptionchecker.cpp b/krusader/Archive/kr7zencryptionchecker.cpp --- a/krusader/Archive/kr7zencryptionchecker.cpp +++ b/krusader/Archive/kr7zencryptionchecker.cpp @@ -21,7 +21,7 @@ #include "kr7zencryptionchecker.h" -Kr7zEncryptionChecker::Kr7zEncryptionChecker() : KProcess(), encrypted(false), lastData() +Kr7zEncryptionChecker::Kr7zEncryptionChecker() : encrypted(false), lastData() { setOutputChannelMode(KProcess::SeparateChannels); // without this output redirection has no effect! connect(this, &Kr7zEncryptionChecker::readyReadStandardOutput, this, [=]() {receivedOutput(); }); diff --git a/krusader/Archive/krarchandler.h b/krusader/Archive/krarchandler.h --- a/krusader/Archive/krarchandler.h +++ b/krusader/Archive/krarchandler.h @@ -38,7 +38,7 @@ { Q_OBJECT public: - virtual ~KRarcObserver() {} + ~KRarcObserver() override = default; virtual void processEvents() = 0; virtual void subJobStarted(const QString & jobTitle, int count) = 0; @@ -56,28 +56,28 @@ Q_OBJECT public: // return the number of files in the archive - static long arcFileCount(QString archive, QString type, QString password, KRarcObserver *observer); + static long arcFileCount(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer); // unpack an archive to destination directory - static bool unpack(QString archive, QString type, QString password, QString dest, KRarcObserver *observer ); + static bool unpack(QString archive, const QString& type, const QString& password, const QString& dest, KRarcObserver *observer ); // pack an archive to destination directory - static bool pack(QStringList fileNames, QString type, QString dest, long count, QMap extraProps, KRarcObserver *observer ); + static bool pack(QStringList fileNames, QString type, const QString& dest, long count, QMap extraProps, KRarcObserver *observer ); // test an archive - static bool test(QString archive, QString type, QString password, KRarcObserver *observer, long count = 0L ); + static bool test(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer, long count = 0L ); // returns `true` if the right unpacker exist in the system static bool arcSupported(QString type); // return the list of supported packers static QStringList supportedPackers(); // returns `true` if the url is an archive (ie: tar:/home/test/file.tar.bz2) static bool isArchive(const QUrl &url); // used to determine the type of the archive - QString getType(bool &encrypted, QString fileName, QString mime, bool checkEncrypted = true, bool fast = false); + QString getType(bool &encrypted, QString fileName, const QString& mime, bool checkEncrypted = true, bool fast = false); // queries the password from the user - static QString getPassword(QString path); + static QString getPassword(const QString& path); // detects the archive type void checkIf7zIsEncrypted(bool &, QString) Q_DECL_OVERRIDE; private: //! checks if a returned status ("exit code") of an archiving-related process is OK - static bool checkStatus(QString type, int exitCode); + static bool checkStatus(const QString& type, int exitCode); static bool openWallet(); diff --git a/krusader/Archive/krarchandler.cpp b/krusader/Archive/krarchandler.cpp --- a/krusader/Archive/krarchandler.cpp +++ b/krusader/Archive/krarchandler.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "kr7zencryptionchecker.h" #include "../krglobal.h" @@ -83,7 +84,7 @@ static QStringList arcProtocols = QString("tar;bzip;bzip2;lzma;xz;gzip;krarc;zip").split(';'); -KWallet::Wallet * KRarcHandler::wallet = 0; +KWallet::Wallet * KRarcHandler::wallet = nullptr; QStringList KRarcHandler::supportedPackers() { @@ -152,7 +153,7 @@ || (type == "7z" && lst.contains("7z")); } -long KRarcHandler::arcFileCount(QString archive, QString type, QString password, KRarcObserver *observer) +long KRarcHandler::arcFileCount(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer) { int divideWith = 1; @@ -231,7 +232,7 @@ return count / divideWith; } -bool KRarcHandler::unpack(QString archive, QString type, QString password, QString dest, KRarcObserver *observer) +bool KRarcHandler::unpack(QString archive, const QString& type, const QString& password, const QString& dest, KRarcObserver *observer) { KConfigGroup group(krConfig, "Archives"); if (group.readEntry("Test Before Unpack", _TestBeforeUnpack)) { @@ -361,7 +362,7 @@ return true; // SUCCESS } -bool KRarcHandler::test(QString archive, QString type, QString password, KRarcObserver *observer, long count) +bool KRarcHandler::test(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer, long count) { // choose the right packer for the job QStringList packer; @@ -427,7 +428,7 @@ return true; // SUCCESS } -bool KRarcHandler::pack(QStringList fileNames, QString type, QString dest, long count, QMap extraProps, KRarcObserver *observer) +bool KRarcHandler::pack(QStringList fileNames, QString type, const QString& dest, long count, QMap extraProps, KRarcObserver *observer) { // set the right packer to do the job QStringList packer; @@ -525,8 +526,8 @@ KrLinecountingProcess proc; proc << packer << dest; - for (QStringList::Iterator file = fileNames.begin(); file != fileNames.end(); ++file) { - proc << *file; + for (auto & fileName : fileNames) { + proc << fileName; } // tell the user to wait @@ -573,19 +574,19 @@ wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), actWindow->effectiveWinId()); } - return (wallet != 0); + return (wallet != nullptr); } -QString KRarcHandler::getPassword(QString path) +QString KRarcHandler::getPassword(const QString& path) { QString password; QString key = "krarc-" + path; if (!KWallet::Wallet::keyDoesNotExist(KWallet::Wallet::NetworkWallet(), KWallet::Wallet::PasswordFolder(), key)) { - if (!KWallet::Wallet::isOpen(KWallet::Wallet::NetworkWallet()) && wallet != 0) { + if (!KWallet::Wallet::isOpen(KWallet::Wallet::NetworkWallet()) && wallet != nullptr) { delete wallet; - wallet = 0; + wallet = nullptr; } if (openWallet() && wallet->hasFolder(KWallet::Wallet::PasswordFolder())) { wallet->setFolder(KWallet::Wallet::PasswordFolder()); @@ -600,16 +601,16 @@ bool keep = true; QString user = "archive"; - QPointer passDlg = new KPasswordDialog(0L, KPasswordDialog::ShowKeepPassword); + QPointer passDlg = new KPasswordDialog(nullptr, KPasswordDialog::ShowKeepPassword); passDlg->setPrompt(i18n("This archive is encrypted, please supply the password:") ), passDlg->setUsername(user); passDlg->setPassword(password); if (passDlg->exec() == KPasswordDialog::Accepted) { password = passDlg->password(); if (keep) { - if (!KWallet::Wallet::isOpen(KWallet::Wallet::NetworkWallet()) && wallet != 0) { + if (!KWallet::Wallet::isOpen(KWallet::Wallet::NetworkWallet()) && wallet != nullptr) { delete wallet; - wallet = 0; + wallet = nullptr; } if (openWallet()) { bool ok = true; @@ -640,17 +641,17 @@ else return false; } -QString KRarcHandler::getType(bool &encrypted, QString fileName, QString mime, bool checkEncrypted, bool fast) +QString KRarcHandler::getType(bool &encrypted, QString fileName, const QString& mime, bool checkEncrypted, bool fast) { - QString result = detectArchive(encrypted, fileName, checkEncrypted, fast); + QString result = detectArchive(encrypted, std::move(fileName), checkEncrypted, fast); if (result.isNull()) { // Then the type is based on the mime type return getShortTypeFromMime(mime); } return result; } -bool KRarcHandler::checkStatus(QString type, int exitCode) +bool KRarcHandler::checkStatus(const QString& type, int exitCode) { return KrArcBaseManager::checkStatus(type, exitCode); } diff --git a/krusader/Archive/packjob.h b/krusader/Archive/packjob.h --- a/krusader/Archive/packjob.h +++ b/krusader/Archive/packjob.h @@ -48,10 +48,10 @@ public: PackThread(const QUrl &srcUrl, const QUrl &destUrl, const QStringList & fileNames, const QString &type, const QMap &packProps); - virtual ~PackThread() {} + ~PackThread() override = default; protected slots: - virtual void slotStart() Q_DECL_OVERRIDE; + void slotStart() Q_DECL_OVERRIDE; private: QUrl _sourceUrl; @@ -80,10 +80,10 @@ public: TestArchiveThread(const QUrl &srcUrl, const QStringList & fileNames); - virtual ~TestArchiveThread() {} + ~TestArchiveThread() override = default; protected slots: - virtual void slotStart() Q_DECL_OVERRIDE; + void slotStart() Q_DECL_OVERRIDE; private: QUrl _sourceUrl; @@ -110,10 +110,10 @@ public: UnpackThread(const QUrl &srcUrl, const QUrl &destUrl, const QStringList & fileNames); - virtual ~UnpackThread() {} + ~UnpackThread() override = default; protected slots: - virtual void slotStart() Q_DECL_OVERRIDE; + void slotStart() Q_DECL_OVERRIDE; private: QUrl _sourceUrl; diff --git a/krusader/Archive/packjob.cpp b/krusader/Archive/packjob.cpp --- a/krusader/Archive/packjob.cpp +++ b/krusader/Archive/packjob.cpp @@ -31,7 +31,7 @@ extern KRarcHandler arcHandler; -PackJob::PackJob(const QUrl &srcUrl, const QUrl &destUrl, const QStringList & fileNames, const QString &type, const QMap &packProps) : AbstractThreadedJob() +PackJob::PackJob(const QUrl &srcUrl, const QUrl &destUrl, const QStringList & fileNames, const QString &type, const QMap &packProps) { startAbstractJobThread(new PackThread(srcUrl, destUrl, fileNames, type, packProps)); } @@ -43,7 +43,7 @@ PackThread::PackThread(const QUrl &srcUrl, const QUrl &destUrl, const QStringList & fileNames, const QString &type, const QMap &packProps) : - AbstractJobThread(), _sourceUrl(srcUrl), _destUrl(destUrl), _fileNames(fileNames), + _sourceUrl(srcUrl), _destUrl(destUrl), _fileNames(fileNames), _type(type), _packProperties(packProps) { } @@ -82,7 +82,7 @@ sendSuccess(); } -TestArchiveJob::TestArchiveJob(const QUrl &srcUrl, const QStringList & fileNames) : AbstractThreadedJob() +TestArchiveJob::TestArchiveJob(const QUrl &srcUrl, const QStringList & fileNames) { startAbstractJobThread(new TestArchiveThread(srcUrl, fileNames)); } @@ -92,7 +92,7 @@ return new TestArchiveJob(srcUrl, fileNames); } -TestArchiveThread::TestArchiveThread(const QUrl &srcUrl, const QStringList & fileNames) : AbstractJobThread(), +TestArchiveThread::TestArchiveThread(const QUrl &srcUrl, const QStringList & fileNames) : _sourceUrl(srcUrl), _fileNames(fileNames) { } @@ -121,7 +121,7 @@ } -UnpackJob::UnpackJob(const QUrl &srcUrl, const QUrl &destUrl, const QStringList & fileNames) : AbstractThreadedJob() +UnpackJob::UnpackJob(const QUrl &srcUrl, const QUrl &destUrl, const QStringList & fileNames) { startAbstractJobThread(new UnpackThread(srcUrl, destUrl, fileNames)); } @@ -132,7 +132,7 @@ } UnpackThread::UnpackThread(const QUrl &srcUrl, const QUrl &destUrl, const QStringList & fileNames) : - AbstractJobThread(), _sourceUrl(srcUrl), _destUrl(destUrl), _fileNames(fileNames) + _sourceUrl(srcUrl), _destUrl(destUrl), _fileNames(fileNames) { } diff --git a/krusader/BookMan/kraddbookmarkdlg.h b/krusader/BookMan/kraddbookmarkdlg.h --- a/krusader/BookMan/kraddbookmarkdlg.h +++ b/krusader/BookMan/kraddbookmarkdlg.h @@ -38,7 +38,7 @@ { Q_OBJECT public: - explicit KrAddBookmarkDlg(QWidget *parent, QUrl url = QUrl()); + explicit KrAddBookmarkDlg(QWidget *parent, const QUrl& url = QUrl()); QUrl url() const { return QUrl::fromUserInput(_url->text(), QString(), QUrl::AssumeLocalFile); } diff --git a/krusader/BookMan/kraddbookmarkdlg.cpp b/krusader/BookMan/kraddbookmarkdlg.cpp --- a/krusader/BookMan/kraddbookmarkdlg.cpp +++ b/krusader/BookMan/kraddbookmarkdlg.cpp @@ -35,16 +35,16 @@ #include -KrAddBookmarkDlg::KrAddBookmarkDlg(QWidget *parent, QUrl url): +KrAddBookmarkDlg::KrAddBookmarkDlg(QWidget *parent, const QUrl& url): QDialog(parent) { setWindowModality(Qt::WindowModal); setWindowTitle(i18n("Add Bookmark")); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); - QGridLayout *layout = new QGridLayout; // expanding + auto *layout = new QGridLayout; // expanding // name and url QLabel *lb1 = new QLabel(i18n("Name:"), this); _name = new KLineEdit(this); @@ -112,7 +112,7 @@ _createIn->setRootIsDecorated(true); _createIn->setAlternatingRowColors(false); // disable alternate coloring - QTreeWidgetItem *item = new QTreeWidgetItem(_createIn); + auto *item = new QTreeWidgetItem(_createIn); item->setText(0, i18n("Bookmarks")); _createIn->expandItem(item); item->setSelected(true); @@ -141,7 +141,7 @@ while (it.hasNext()) { KrBookmark *bm = it.next(); if (bm->isFolder()) { - QTreeWidgetItem *item = new QTreeWidgetItem(parent); + auto *item = new QTreeWidgetItem(parent); item->setText(0, bm->text()); item->treeWidget()->expandItem(item); _xr[item] = bm; @@ -167,7 +167,7 @@ krBookMan->addBookmark(bm, _xr[ items[ 0 ]]); // fix the gui - QTreeWidgetItem *item = new QTreeWidgetItem(items[ 0 ]); + auto *item = new QTreeWidgetItem(items[ 0 ]); item->setText(0, bm->text()); _xr[item] = bm; @@ -179,7 +179,7 @@ { QList items = _createIn->selectedItems(); if (items.count() == 0) - return 0; + return nullptr; return _xr[ items[ 0 ] ]; } diff --git a/krusader/BookMan/krbookmark.h b/krusader/BookMan/krbookmark.h --- a/krusader/BookMan/krbookmark.h +++ b/krusader/BookMan/krbookmark.h @@ -36,14 +36,14 @@ { Q_OBJECT public: - KrBookmark(QString name, QUrl url, KActionCollection *parent, QString iconName = "", QString actionName = QString()); - explicit KrBookmark(QString name, QString iconName = ""); // creates a folder - ~KrBookmark(); + KrBookmark(const QString& name, QUrl url, KActionCollection *parent, const QString& iconName = "", const QString& actionName = QString()); + explicit KrBookmark(const QString& name, const QString& iconName = ""); // creates a folder + ~KrBookmark() override; // text() and setText() to change the name of the bookmark // icon() and setIcon() to change icons - void setIconName(QString iconName); + void setIconName(const QString& iconName); inline const QString& iconName() const { return _iconName; @@ -65,13 +65,13 @@ return _children; } - static KrBookmark * getExistingBookmark(QString actionName, KActionCollection *collection); + static KrBookmark * getExistingBookmark(const QString& actionName, KActionCollection *collection); // ----- special bookmarks static KrBookmark * trash(KActionCollection *collection); static KrBookmark * virt(KActionCollection *collection); static KrBookmark * lan(KActionCollection *collection); - static QAction * jumpBackAction(KActionCollection *collection, bool isSetter = false, ListPanelActions *sourceActions = 0); + static QAction * jumpBackAction(KActionCollection *collection, bool isSetter = false, ListPanelActions *sourceActions = nullptr); static KrBookmark * separator(); signals: diff --git a/krusader/BookMan/krbookmark.cpp b/krusader/BookMan/krbookmark.cpp --- a/krusader/BookMan/krbookmark.cpp +++ b/krusader/BookMan/krbookmark.cpp @@ -28,15 +28,16 @@ #include #include +#include #define BM_NAME(X) (QString("Bookmark:")+X) static const char* NAME_TRASH = I18N_NOOP("Trash bin"); static const char* NAME_VIRTUAL = I18N_NOOP("Virtual Filesystem"); static const char* NAME_LAN = I18N_NOOP("Local Network"); -KrBookmark::KrBookmark(QString name, QUrl url, KActionCollection *parent, QString iconName, QString actionName) : - QAction(parent), _url(url), _iconName(iconName), _folder(false), _separator(false), _autoDelete(true) +KrBookmark::KrBookmark(const QString& name, QUrl url, KActionCollection *parent, const QString& iconName, const QString& actionName) : + QAction(parent), _url(std::move(url)), _iconName(iconName), _folder(false), _separator(false), _autoDelete(true) { QString actName = actionName.isNull() ? BM_NAME(name) : BM_NAME(actionName); setText(name); @@ -46,8 +47,8 @@ setIconName(iconName); } -KrBookmark::KrBookmark(QString name, QString iconName) : - QAction(Icon(iconName), name, 0), _iconName(iconName), _folder(true), _separator(false), _autoDelete(false) +KrBookmark::KrBookmark(const QString& name, const QString& iconName) : + QAction(Icon(iconName), name, nullptr), _iconName(iconName), _folder(true), _separator(false), _autoDelete(false) { setIcon(Icon(iconName == "" ? "folder" : iconName)); } @@ -62,7 +63,7 @@ } } -void KrBookmark::setIconName(QString iconName) +void KrBookmark::setIconName(const QString& iconName) { if (!iconName.isEmpty()) { setIcon(Icon(iconName)); @@ -75,9 +76,9 @@ } } -KrBookmark * KrBookmark::getExistingBookmark(QString actionName, KActionCollection *collection) +KrBookmark * KrBookmark::getExistingBookmark(const QString& actionName, KActionCollection *collection) { - return static_cast(collection->action(BM_NAME(actionName))); + return dynamic_cast(collection->action(BM_NAME(actionName))); } KrBookmark * KrBookmark::trash(KActionCollection *collection) diff --git a/krusader/BookMan/krbookmarkhandler.h b/krusader/BookMan/krbookmarkhandler.h --- a/krusader/BookMan/krbookmarkhandler.h +++ b/krusader/BookMan/krbookmarkhandler.h @@ -48,16 +48,16 @@ enum Actions { BookmarkCurrent = 0, ManageBookmarks }; public: explicit KrBookmarkHandler(KrMainWindow *mainWindow); - ~KrBookmarkHandler(); + ~KrBookmarkHandler() override; void populate(QMenu *menu); - void addBookmark(KrBookmark *bm, KrBookmark *parent = 0); + void addBookmark(KrBookmark *bm, KrBookmark *parent = nullptr); void bookmarkCurrent(QUrl url); protected: void deleteBookmark(KrBookmark *bm); void importFromFile(); - bool importFromFileBookmark(QDomElement &e, KrBookmark *parent, QString path, QString *errorMsg); - bool importFromFileFolder(QDomNode &first, KrBookmark *parent, QString path, QString *errorMsg); + bool importFromFileBookmark(QDomElement &e, KrBookmark *parent, const QString& path, QString *errorMsg); + bool importFromFileFolder(QDomNode &first, KrBookmark *parent, const QString& path, QString *errorMsg); void exportToFile(); void exportToFileFolder(QDomDocument &doc, QDomElement &parent, KrBookmark *folder); void exportToFileBookmark(QDomDocument &doc, QDomElement &where, KrBookmark *bm); diff --git a/krusader/BookMan/krbookmarkhandler.cpp b/krusader/BookMan/krbookmarkhandler.cpp --- a/krusader/BookMan/krbookmarkhandler.cpp +++ b/krusader/BookMan/krbookmarkhandler.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #define SPECIAL_BOOKMARKS true @@ -59,8 +60,7 @@ QObject(mainWindow->widget()), _mainWindow(mainWindow), _middleClick(false), - _mainBookmarkPopup(0), - _specialBookmarks(), + _mainBookmarkPopup(nullptr), _quickSearchAction(nullptr), _quickSearchBar(nullptr), _quickSearchMenu(nullptr) @@ -103,7 +103,7 @@ void KrBookmarkHandler::bookmarkCurrent(QUrl url) { - QPointer dlg = new KrAddBookmarkDlg(_mainWindow->widget(), url); + QPointer dlg = new KrAddBookmarkDlg(_mainWindow->widget(), std::move(url)); if (dlg->exec() == QDialog::Accepted) { KrBookmark *bm = new KrBookmark(dlg->name(), dlg->url(), _collection); addBookmark(bm, dlg->folder()); @@ -113,7 +113,7 @@ void KrBookmarkHandler::addBookmark(KrBookmark *bm, KrBookmark *folder) { - if (folder == 0) + if (folder == nullptr) folder = _root; // add to the list (bottom) @@ -230,7 +230,7 @@ } } -bool KrBookmarkHandler::importFromFileBookmark(QDomElement &e, KrBookmark *parent, QString path, QString *errorMsg) +bool KrBookmarkHandler::importFromFileBookmark(QDomElement &e, KrBookmark *parent, const QString& path, QString *errorMsg) { QString url, name, iconName; // verify tag @@ -266,7 +266,7 @@ return true; } -bool KrBookmarkHandler::importFromFileFolder(QDomNode &first, KrBookmark *parent, QString path, QString *errorMsg) +bool KrBookmarkHandler::importFromFileFolder(QDomNode &first, KrBookmark *parent, const QString& path, QString *errorMsg) { QString name; QDomNode n = first; @@ -392,7 +392,7 @@ KrBookmark *bm = it.next(); if (!bm->isFolder()) continue; - QMenu *newMenu = new QMenu(menu); + auto *newMenu = new QMenu(menu); newMenu->setIcon(Icon(bm->iconName())); newMenu->setTitle(bm->text()); QAction *menuAction = menu->addMenu(newMenu); @@ -427,7 +427,7 @@ menu->addSeparator(); // add the popular links submenu - QMenu *newMenu = new QMenu(menu); + auto *newMenu = new QMenu(menu); newMenu->setTitle(i18n("Popular URLs")); newMenu->setIcon(Icon("folder-bookmark")); QAction *bmfAct = menu->addMenu(newMenu); @@ -519,7 +519,7 @@ _specialBookmarks.append(bmAct); // make sure the menu is connected to us - disconnect(menu, SIGNAL(triggered(QAction*)), 0, 0); + disconnect(menu, SIGNAL(triggered(QAction*)), nullptr, nullptr); } menu->installEventFilter(this); @@ -552,7 +552,7 @@ bool KrBookmarkHandler::eventFilter(QObject *obj, QEvent *ev) { auto eventType = ev->type(); - QMenu *menu = qobject_cast(obj); + auto *menu = qobject_cast(obj); if (eventType == QEvent::Show && menu) { _setQuickSearchText(""); @@ -588,7 +588,7 @@ // Having it occur on keypress is consistent with other shortcuts, // such as Ctrl+W and accelerator keys if (eventType == QEvent::KeyPress && menu) { - QKeyEvent *kev = static_cast(ev); + auto *kev = dynamic_cast(ev); QList acts = menu->actions(); bool quickSearchStarted = false; bool searchInSpecialItems = KConfigGroup(krConfig, "Look&Feel").readEntry("Search in special items", false); @@ -696,24 +696,24 @@ } if (eventType == QEvent::MouseButtonRelease) { - switch (static_cast(ev)->button()) { + switch (dynamic_cast(ev)->button()) { case Qt::RightButton: _middleClick = false; if (obj->inherits("QMenu")) { - QMenu *menu = static_cast(obj); - QAction *act = menu->actionAt(static_cast(ev)->pos()); + auto *menu = dynamic_cast(obj); + QAction *act = menu->actionAt(dynamic_cast(ev)->pos()); if (obj == _mainBookmarkPopup && _specialBookmarks.contains(act)) { rightClickOnSpecialBookmark(); return true; } - KrBookmark *bm = qobject_cast(act); - if (bm != 0) { + auto *bm = qobject_cast(act); + if (bm != nullptr) { rightClicked(menu, bm); return true; } else if (act && act->data().canConvert()) { - KrBookmark *bm = act->data().value(); + auto *bm = act->data().value(); rightClicked(menu, bm); } } diff --git a/krusader/Dialogs/checksumdlg.h b/krusader/Dialogs/checksumdlg.h --- a/krusader/Dialogs/checksumdlg.h +++ b/krusader/Dialogs/checksumdlg.h @@ -59,7 +59,7 @@ Q_OBJECT public: ChecksumProcess(QObject *parent, const QString &path); - ~ChecksumProcess(); + ~ChecksumProcess() override; QStringList stdOutput() const { return m_outputLines; } QStringList errOutput() const { return m_errorLines; } @@ -84,7 +84,7 @@ Q_OBJECT public: explicit ChecksumWizard(const QString &path); - virtual ~ChecksumWizard(); + ~ChecksumWizard() override; private slots: void slotCurrentIdChanged(int id); @@ -99,7 +99,7 @@ QWizardPage *createProgressPage(const QString &title); - bool checkExists(const QString type); + bool checkExists(const QString& type); void runProcess(const QString &type, const QStringList &args); void addChecksumLine(KrTreeWidget *tree, const QString &line); diff --git a/krusader/Dialogs/checksumdlg.cpp b/krusader/Dialogs/checksumdlg.cpp --- a/krusader/Dialogs/checksumdlg.cpp +++ b/krusader/Dialogs/checksumdlg.cpp @@ -72,7 +72,7 @@ { const QDir baseDir(path); QStringList allFiles; - for (const QString fileName : fileNames) { + for (const QString& fileName : fileNames) { if (stopListFiles) return QStringList(); @@ -116,37 +116,37 @@ ChecksumProcess::~ChecksumProcess() { - disconnect(this, 0, this, 0); // QProcess emits finished() on destruction + disconnect(this, nullptr, this, nullptr); // QProcess emits finished() on destruction close(); } void ChecksumProcess::slotError(QProcess::ProcessError error) { if (error == QProcess::FailedToStart) { - KMessageBox::error(0, i18n("Could not start %1.", program().join(" "))); + KMessageBox::error(nullptr, i18n("Could not start %1.", program().join(" "))); } } void ChecksumProcess::slotFinished(int, QProcess::ExitStatus exitStatus) { if (exitStatus != QProcess::NormalExit) { - KMessageBox::error(0, i18n("There was an error while running %1.", + KMessageBox::error(nullptr, i18n("There was an error while running %1.", program().join(" "))); return; } // parse result files if (!KrServices::fileToStringList(&m_tmpOutFile, m_outputLines) || !KrServices::fileToStringList(&m_tmpErrFile, m_errorLines)) { - KMessageBox::error(0, i18n("Error reading stdout or stderr")); + KMessageBox::error(nullptr, i18n("Error reading stdout or stderr")); return; } emit resultReady(); } // ------------- Generic Checksum Wizard -ChecksumWizard::ChecksumWizard(const QString &path) : QWizard(krApp), m_path(path), m_process(0) +ChecksumWizard::ChecksumWizard(const QString &path) : QWizard(krApp), m_path(path), m_process(nullptr) { setAttribute(Qt::WA_DeleteOnClose); @@ -176,7 +176,7 @@ if (m_process) { // we are coming from the result page; delete m_process; - m_process = 0; + m_process = nullptr; restart(); } else { button(QWizard::BackButton)->hide(); @@ -190,26 +190,26 @@ QWizardPage *ChecksumWizard::createProgressPage(const QString &title) { - QWizardPage *page = new QWizardPage; + auto *page = new QWizardPage; page->setTitle(title); page->setPixmap(QWizard::LogoPixmap, Icon("process-working").pixmap(32)); page->setSubTitle(i18n("Please wait...")); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; page->setLayout(mainLayout); // "busy" indicator - QProgressBar *bar = new QProgressBar(); + auto *bar = new QProgressBar(); bar->setRange(0,0); mainLayout->addWidget(bar); return page; } -bool ChecksumWizard::checkExists(const QString type) +bool ChecksumWizard::checkExists(const QString& type) { if (!KrServices::cmdExist(m_checksumTools[type])) { KMessageBox::error( @@ -223,7 +223,7 @@ void ChecksumWizard::runProcess(const QString &type, const QStringList &args) { - Q_ASSERT(m_process == 0); + Q_ASSERT(m_process == nullptr); m_process = new ChecksumProcess(this, m_path); m_process->setProgram(KrServices::fullPathName(m_checksumTools[type]), args); @@ -235,7 +235,7 @@ void ChecksumWizard::addChecksumLine(KrTreeWidget *tree, const QString &line) { - QTreeWidgetItem *item = new QTreeWidgetItem(tree); + auto *item = new QTreeWidgetItem(tree); const int hashLength = line.indexOf(' '); // delimiter is either " " or " *" item->setText(0, line.left(hashLength)); QString fileName = line.mid(hashLength + 2); @@ -247,7 +247,7 @@ // ------------- Create Wizard CreateWizard::CreateWizard(const QString &path, const QStringList &_files) : ChecksumWizard(path), - m_fileNames(_files), m_listFilesWatcher() + m_fileNames(_files) { m_introId = addPage(createIntroPage()); @@ -263,30 +263,30 @@ QWizardPage *CreateWizard::createIntroPage() { - QWizardPage *page = new QWizardPage; + auto *page = new QWizardPage; page->setTitle(i18n("Create Checksums")); page->setPixmap(QWizard::LogoPixmap, Icon("document-edit-sign").pixmap(32)); page->setSubTitle(i18n("About to calculate checksum for the following files or directories:")); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; page->setLayout(mainLayout); // file list - KrListWidget *listWidget = new KrListWidget; + auto *listWidget = new KrListWidget; listWidget->addItems(m_fileNames); mainLayout->addWidget(listWidget); // checksum method - QHBoxLayout *hLayout = new QHBoxLayout; + auto *hLayout = new QHBoxLayout; QLabel *methodLabel = new QLabel(i18n("Select the checksum method:")); hLayout->addWidget(methodLabel); m_methodBox = new KComboBox; // -- fill the combo with available methods - for (const QString type: m_checksumTools.keys()) + for (const QString& type: m_checksumTools.keys()) m_methodBox->addItem(type); m_methodBox->setFocus(); hLayout->addWidget(m_methodBox); @@ -298,11 +298,11 @@ QWizardPage *CreateWizard::createResultPage() { - QWizardPage *page = new QWizardPage; + auto *page = new QWizardPage; page->setTitle(i18n("Checksum Results")); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; page->setLayout(mainLayout); m_hashesTreeWidget = new KrTreeWidget(this); @@ -373,7 +373,7 @@ m_hashesTreeWidget->clear(); m_hashesTreeWidget->setVisible(successes); if (successes) { - for (const QString line : outputLines) + for (const QString& line : outputLines) addChecksumLine(m_hashesTreeWidget, line); //m_hashesTreeWidget->sortItems(1, Qt::AscendingOrder); } @@ -393,7 +393,7 @@ const QString type = m_suggestedFilePath.mid(m_suggestedFilePath.lastIndexOf('.')); krApp->startWaiting(i18n("Saving checksum files..."), 0); - for (const QString line : m_process->stdOutput()) { + for (const QString& line : m_process->stdOutput()) { const QString filename = line.mid(line.indexOf(' ') + 2) + type; if (!saveChecksumFile(QStringList() << line, filename)) { KMessageBox::error(this, i18n("Errors occurred while saving multiple checksums. Stopping")); @@ -418,7 +418,7 @@ QFile file(filePath); if (file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); - for (const QString line : data) + for (const QString& line : data) stream << line << "\n"; file.close(); } @@ -476,24 +476,24 @@ QWizardPage *VerifyWizard::createIntroPage() { - QWizardPage *page = new QWizardPage; + auto *page = new QWizardPage; page->setTitle(i18n("Verify Checksum File")); page->setPixmap(QWizard::LogoPixmap, Icon("document-edit-verify").pixmap(32)); page->setSubTitle(i18n("About to verify the following checksum file")); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; page->setLayout(mainLayout); // checksum file - QHBoxLayout *hLayout = new QHBoxLayout; + auto *hLayout = new QHBoxLayout; QLabel *checksumFileLabel = new QLabel(i18n("Checksum file:")); hLayout->addWidget(checksumFileLabel); - KUrlRequester *checksumFileReq = new KUrlRequester; + auto *checksumFileReq = new KUrlRequester; QString typesFilter; - for (const QString ext: m_checksumTools.keys()) + for (const QString& ext: m_checksumTools.keys()) typesFilter += ("*." + ext + ' '); checksumFileReq->setFilter(typesFilter); checksumFileReq->setText(m_checksumFile); @@ -515,11 +515,11 @@ QWizardPage *VerifyWizard::createResultPage() { - QWizardPage *page = new QWizardPage; + auto *page = new QWizardPage; page->setTitle(i18n("Verify Result")); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; page->setLayout(mainLayout); m_outputLabel = new QLabel(i18n("Result output:")); diff --git a/krusader/Dialogs/krdialogs.h b/krusader/Dialogs/krdialogs.h --- a/krusader/Dialogs/krdialogs.h +++ b/krusader/Dialogs/krdialogs.h @@ -89,7 +89,7 @@ KUrlRequester *urlRequester(); protected: - virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; private slots: void slotQueueButtonClicked(); @@ -105,7 +105,7 @@ { Q_OBJECT public: - explicit KRGetDate(QDate date = QDate::currentDate(), QWidget *parent = 0); + explicit KRGetDate(QDate date = QDate::currentDate(), QWidget *parent = nullptr); QDate getDate(); private slots: diff --git a/krusader/Dialogs/krdialogs.cpp b/krusader/Dialogs/krdialogs.cpp --- a/krusader/Dialogs/krdialogs.cpp +++ b/krusader/Dialogs/krdialogs.cpp @@ -100,7 +100,7 @@ { setWindowModality(modal ? Qt::WindowModal : Qt::NonModal); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); mainLayout->addWidget(new QLabel(_text)); diff --git a/krusader/Dialogs/krmaskchoice.h b/krusader/Dialogs/krmaskchoice.h --- a/krusader/Dialogs/krmaskchoice.h +++ b/krusader/Dialogs/krmaskchoice.h @@ -35,8 +35,8 @@ Q_OBJECT public: - explicit KRMaskChoice(QWidget* parent = 0); - ~KRMaskChoice(); + explicit KRMaskChoice(QWidget* parent = nullptr); + ~KRMaskChoice() override; KComboBox* selection; QLabel* PixmapLabel1; diff --git a/krusader/Dialogs/krmaskchoice.cpp b/krusader/Dialogs/krmaskchoice.cpp --- a/krusader/Dialogs/krmaskchoice.cpp +++ b/krusader/Dialogs/krmaskchoice.cpp @@ -51,9 +51,9 @@ resize(401, 314); setWindowTitle(i18n("Choose Files")); - QVBoxLayout* MainLayout = new QVBoxLayout(this); + auto* MainLayout = new QVBoxLayout(this); - QHBoxLayout* HeaderLayout = new QHBoxLayout(); + auto* HeaderLayout = new QHBoxLayout(); MainLayout->addLayout(HeaderLayout); PixmapLabel1 = new QLabel(this); @@ -71,18 +71,18 @@ selection->setAutoCompletion(true); MainLayout->addWidget(selection); - QGroupBox* GroupBox1 = new QGroupBox(this); + auto* GroupBox1 = new QGroupBox(this); GroupBox1->setTitle(i18n("Predefined Selections")); MainLayout->addWidget(GroupBox1); - QHBoxLayout* gbLayout = new QHBoxLayout(GroupBox1); + auto* gbLayout = new QHBoxLayout(GroupBox1); preSelections = new KrListWidget(GroupBox1); preSelections->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); preSelections->setWhatsThis(i18n("A predefined selection is a file-mask which you often use.\nSome examples are: \"*.c, *.h\", \"*.c, *.o\", etc.\nYou can add these masks to the list by typing them and pressing the Add button.\nDelete removes a predefined selection and Clear removes all of them.\nNotice that the line in which you edit the mask has its own history, you can scroll it, if needed.")); gbLayout->addWidget(preSelections); - QVBoxLayout* vbox = new QVBoxLayout(); + auto* vbox = new QVBoxLayout(); gbLayout->addLayout(vbox); PushButton7 = new QPushButton(GroupBox1); diff --git a/krusader/Dialogs/krpleasewait.h b/krusader/Dialogs/krpleasewait.h --- a/krusader/Dialogs/krpleasewait.h +++ b/krusader/Dialogs/krpleasewait.h @@ -43,7 +43,7 @@ public slots: - void startWaiting(QString msg, int count = 0, bool cancel = false); + void startWaiting(const QString& msg, int count = 0, bool cancel = false); void stopWait(); void cycleProgress(); void incProgress(int i); @@ -65,16 +65,16 @@ { Q_OBJECT public: - KRPleaseWait(QString msg, QWidget *parent, int count = 0 , bool cancel = false); + KRPleaseWait(const QString& msg, QWidget *parent, int count = 0 , bool cancel = false); public slots: void incProgress(int howMuch); void cycleProgress(); protected: bool inc; QTimer* timer; - virtual void closeEvent(QCloseEvent * e) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent * e) Q_DECL_OVERRIDE; bool canClose; }; diff --git a/krusader/Dialogs/krpleasewait.cpp b/krusader/Dialogs/krpleasewait.cpp --- a/krusader/Dialogs/krpleasewait.cpp +++ b/krusader/Dialogs/krpleasewait.cpp @@ -37,8 +37,8 @@ #include "../krglobal.h" -KRPleaseWait::KRPleaseWait(QString msg, QWidget *parent, int count, bool cancel): - QProgressDialog(cancel ? 0 : parent) , inc(true) +KRPleaseWait::KRPleaseWait(const QString& msg, QWidget *parent, int count, bool cancel): + QProgressDialog(cancel ? nullptr : parent) , inc(true) { setModal(!cancel); @@ -51,7 +51,7 @@ connect(timer, &QTimer::timeout, this, &KRPleaseWait::cycleProgress); - QProgressBar* progress = new QProgressBar(this); + auto* progress = new QProgressBar(this); progress->setMaximum(count); progress->setMinimum(0); setBar(progress); @@ -91,23 +91,23 @@ } KRPleaseWaitHandler::KRPleaseWaitHandler(QWidget *parentWindow) - : QObject(parentWindow), _parentWindow(parentWindow), job(), dlg(0) + : QObject(parentWindow), _parentWindow(parentWindow), dlg(nullptr) { } void KRPleaseWaitHandler::stopWait() { - if (dlg != 0) delete dlg; - dlg = 0; + if (dlg != nullptr) delete dlg; + dlg = nullptr; cycleMutex = incMutex = false; // return cursor to normal arrow _parentWindow->setCursor(Qt::ArrowCursor); } -void KRPleaseWaitHandler::startWaiting(QString msg, int count , bool cancel) +void KRPleaseWaitHandler::startWaiting(const QString& msg, int count , bool cancel) { - if (dlg == 0) { + if (dlg == nullptr) { dlg = new KRPleaseWait(msg , _parentWindow, count, cancel); connect(dlg, &KRPleaseWait::canceled, this, &KRPleaseWaitHandler::killJob); } diff --git a/krusader/Dialogs/krspecialwidgets.h b/krusader/Dialogs/krspecialwidgets.h --- a/krusader/Dialogs/krspecialwidgets.h +++ b/krusader/Dialogs/krspecialwidgets.h @@ -35,14 +35,15 @@ #include #include +#include class KRPieSlice; class KRPie : public QWidget { Q_OBJECT public: - explicit KRPie(KIO::filesize_t _totalSize, QWidget *parent = 0); + explicit KRPie(KIO::filesize_t _totalSize, QWidget *parent = nullptr); void addSlice(KIO::filesize_t size, QString label); protected: @@ -72,10 +73,10 @@ freeSpace = t; } inline void setAlias(QString a) { - alias = a; + alias = std::move(a); } inline void setRealName(QString r) { - realName = r; + realName = std::move(r); } inline void setMounted(bool m) { mounted = m; @@ -100,7 +101,7 @@ { public: KRPieSlice(float _perct, QColor _color, QString _label) : - perct(_perct), color(_color), label(_label) {} + perct(_perct), color(std::move(_color)), label(std::move(_label)) {} inline QColor getColor() { return color; } @@ -114,7 +115,7 @@ perct = _perct; } inline void setLabel(QString _label) { - label = _label; + label = std::move(_label); } private: diff --git a/krusader/Dialogs/krspecialwidgets.cpp b/krusader/Dialogs/krspecialwidgets.cpp --- a/krusader/Dialogs/krspecialwidgets.cpp +++ b/krusader/Dialogs/krspecialwidgets.cpp @@ -30,6 +30,7 @@ #include #include +#include ///////////////////////////////////////////////////////////////////////////// /////////////////////// Pie related widgets ///////////////////////////////// @@ -57,7 +58,7 @@ // This is the full constructor: use it for a mounted filesystem KRFSDisplay::KRFSDisplay(QWidget *parent, QString _alias, QString _realName, KIO::filesize_t _total, KIO::filesize_t _free) : QWidget(parent), totalSpace(_total), - freeSpace(_free), alias(_alias), realName(_realName), mounted(true), + freeSpace(_free), alias(std::move(_alias)), realName(std::move(_realName)), mounted(true), empty(false), supermount(false) { @@ -70,7 +71,7 @@ // Use this one for an unmounted filesystem KRFSDisplay::KRFSDisplay(QWidget *parent, QString _alias, QString _realName, bool sm) : - QWidget(parent), alias(_alias), realName(_realName), mounted(false), + QWidget(parent), alias(std::move(_alias)), realName(std::move(_realName)), mounted(false), empty(false), supermount(sm) { @@ -212,7 +213,7 @@ { int i = (slices.count() % 12); slices.removeLast(); - slices.push_back(KRPieSlice(size * 100 / totalSize, colors[ i ], label)); + slices.push_back(KRPieSlice(size * 100 / totalSize, colors[ i ], std::move(label))); sizeLeft -= size; slices.push_back(KRPieSlice(sizeLeft * 100 / totalSize, Qt::yellow, "DEFAULT")); } diff --git a/krusader/Dialogs/krspwidgets.h b/krusader/Dialogs/krspwidgets.h --- a/krusader/Dialogs/krspwidgets.h +++ b/krusader/Dialogs/krspwidgets.h @@ -42,7 +42,7 @@ public: KRSpWidgets(); - static KRQuery getMask(QString caption, bool nameOnly = false, QWidget * parent = 0); // get file-mask for (un)selecting files + static KRQuery getMask(const QString& caption, bool nameOnly = false, QWidget * parent = 0); // get file-mask for (un)selecting files static QUrl newFTP(); private: diff --git a/krusader/Dialogs/krspwidgets.cpp b/krusader/Dialogs/krspwidgets.cpp --- a/krusader/Dialogs/krspwidgets.cpp +++ b/krusader/Dialogs/krspwidgets.cpp @@ -49,10 +49,9 @@ /////////////////////////////////////////////////////////////////////////////// KRSpWidgets::KRSpWidgets() -{ -} += default; -KRQuery KRSpWidgets::getMask(QString caption, bool nameOnly, QWidget * parent) +KRQuery KRSpWidgets::getMask(const QString& caption, bool nameOnly, QWidget * parent) { if (!nameOnly) { return FilterTabs::getQuery(parent); @@ -135,7 +134,7 @@ return url; } -newFTPSub::newFTPSub() : newFTPGUI(0) +newFTPSub::newFTPSub() : newFTPGUI(nullptr) { url->setFocus(); setGeometry(krMainWindow->x() + krMainWindow->width() / 2 - width() / 2, diff --git a/krusader/Dialogs/krsqueezedtextlabel.h b/krusader/Dialogs/krsqueezedtextlabel.h --- a/krusader/Dialogs/krsqueezedtextlabel.h +++ b/krusader/Dialogs/krsqueezedtextlabel.h @@ -44,8 +44,8 @@ { Q_OBJECT public: - explicit KrSqueezedTextLabel(QWidget *parent = 0); - ~KrSqueezedTextLabel(); + explicit KrSqueezedTextLabel(QWidget *parent = nullptr); + ~KrSqueezedTextLabel() override; public slots: void setText(const QString &text, int index = -1, int length = -1); @@ -57,8 +57,8 @@ void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE { squeezeTextToLabel(_index, _length); } - virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; - virtual void paintEvent(QPaintEvent * e) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent * e) Q_DECL_OVERRIDE; void squeezeTextToLabel(int index = -1, int length = -1); QString fullText; diff --git a/krusader/Dialogs/krsqueezedtextlabel.cpp b/krusader/Dialogs/krsqueezedtextlabel.cpp --- a/krusader/Dialogs/krsqueezedtextlabel.cpp +++ b/krusader/Dialogs/krsqueezedtextlabel.cpp @@ -39,8 +39,7 @@ KrSqueezedTextLabel::~KrSqueezedTextLabel() -{ -} += default; void KrSqueezedTextLabel::mousePressEvent(QMouseEvent *e) { diff --git a/krusader/Dialogs/kurllistrequester.h b/krusader/Dialogs/kurllistrequester.h --- a/krusader/Dialogs/kurllistrequester.h +++ b/krusader/Dialogs/kurllistrequester.h @@ -42,7 +42,7 @@ public: enum Mode { RequestFiles, RequestDirs }; - explicit KURLListRequester(Mode requestMode, QWidget *parent = 0); + explicit KURLListRequester(Mode requestMode, QWidget *parent = nullptr); QList urlList(); void setUrlList(const QList &); @@ -62,7 +62,7 @@ void slotRightClicked(QListWidgetItem *, const QPoint &); protected: - virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; void deleteSelectedItems(); Mode mode; diff --git a/krusader/Dialogs/kurllistrequester.cpp b/krusader/Dialogs/kurllistrequester.cpp --- a/krusader/Dialogs/kurllistrequester.cpp +++ b/krusader/Dialogs/kurllistrequester.cpp @@ -42,7 +42,7 @@ { // Creating the widget - QGridLayout *urlListRequesterGrid = new QGridLayout(this); + auto *urlListRequesterGrid = new QGridLayout(this); urlListRequesterGrid->setSpacing(0); urlListRequesterGrid->setContentsMargins(0, 0, 0, 0); @@ -132,7 +132,7 @@ void KURLListRequester::slotRightClicked(QListWidgetItem *item, const QPoint &pos) { - if (item == 0) + if (item == nullptr) return; QMenu popupMenu(this); @@ -178,7 +178,7 @@ urlLineEdit->clear(); urlListBox->clear(); - for (const QUrl url : urlList) { + for (const QUrl& url : urlList) { urlListBox->addItem(url.toDisplayString(QUrl::PreferLocalFile)); } diff --git a/krusader/Dialogs/newftpgui.h b/krusader/Dialogs/newftpgui.h --- a/krusader/Dialogs/newftpgui.h +++ b/krusader/Dialogs/newftpgui.h @@ -40,8 +40,8 @@ Q_OBJECT public: - explicit newFTPGUI(QWidget *parent = 0); - ~newFTPGUI(); + explicit newFTPGUI(QWidget *parent = nullptr); + ~newFTPGUI() override; KComboBox* prefix; KHistoryComboBox* url; diff --git a/krusader/Dialogs/newftpgui.cpp b/krusader/Dialogs/newftpgui.cpp --- a/krusader/Dialogs/newftpgui.cpp +++ b/krusader/Dialogs/newftpgui.cpp @@ -63,7 +63,7 @@ setWindowTitle(i18n("New Network Connection")); resize(500, 240); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Preferred); @@ -92,7 +92,7 @@ url->setMinimumContentsLength(10); const QStringList availableProtocols = KProtocolInfo::protocols(); - for (const QString protocol : sProtocols) { + for (const QString& protocol : sProtocols) { if (availableProtocols.contains(protocol)) prefix->addItem(protocol + QStringLiteral("://")); } @@ -121,11 +121,11 @@ password = new KLineEdit(this); password->setEchoMode(QLineEdit::Password); - QHBoxLayout *horizontalLayout = new QHBoxLayout(); + auto *horizontalLayout = new QHBoxLayout(); horizontalLayout->addWidget(iconLabel); horizontalLayout->addWidget(aboutLabel); - QGridLayout *gridLayout = new QGridLayout(); + auto *gridLayout = new QGridLayout(); gridLayout->addWidget(protocolLabel, 0, 0, 1, 1); gridLayout->addWidget(hostLabel, 0, 1, 1, 1); gridLayout->addWidget(portLabel, 0, 2, 1, 1); @@ -137,7 +137,7 @@ gridLayout->addWidget(passwordLabel, 4, 0, 1, 1); gridLayout->addWidget(password, 5, 0, 1, 3); - QGridLayout *widgetLayout = new QGridLayout(); + auto *widgetLayout = new QGridLayout(); widgetLayout->addLayout(horizontalLayout, 0, 0, 1, 1); widgetLayout->addLayout(gridLayout, 1, 0, 1, 1); mainLayout->addLayout(widgetLayout); diff --git a/krusader/Dialogs/packgui.h b/krusader/Dialogs/packgui.h --- a/krusader/Dialogs/packgui.h +++ b/krusader/Dialogs/packgui.h @@ -28,7 +28,7 @@ { Q_OBJECT public: - PackGUI(QString defaultName, QString defaultPath, int noOfFiles, QString filename = ""); + PackGUI(const QString& defaultName, const QString& defaultPath, int noOfFiles, const QString& filename = ""); public slots: void browse() Q_DECL_OVERRIDE; diff --git a/krusader/Dialogs/packgui.cpp b/krusader/Dialogs/packgui.cpp --- a/krusader/Dialogs/packgui.cpp +++ b/krusader/Dialogs/packgui.cpp @@ -40,13 +40,13 @@ #define PS(x) lst.contains(x)>0 // clear the statics first -QString PackGUI::filename = 0; -QString PackGUI::destination = 0; -QString PackGUI::type = 0; +QString PackGUI::filename = nullptr; +QString PackGUI::destination = nullptr; +QString PackGUI::type = nullptr; QMap PackGUI::extraProps; -PackGUI::PackGUI(QString defaultName, QString defaultPath, int noOfFiles, QString filename) : - PackGUIBase(0) +PackGUI::PackGUI(const QString& defaultName, const QString& defaultPath, int noOfFiles, const QString& filename) : + PackGUIBase(nullptr) { // first, fill the WhatToPack textfield with information if (noOfFiles == 1) @@ -97,7 +97,7 @@ void PackGUI::browse() { - QString temp = QFileDialog::getExistingDirectory(0, i18n("Please select a folder"), dirData->text()); + QString temp = QFileDialog::getExistingDirectory(nullptr, i18n("Please select a folder"), dirData->text()); if (!temp.isEmpty()) { dirData->setText(temp); } diff --git a/krusader/Dialogs/packguibase.h b/krusader/Dialogs/packguibase.h --- a/krusader/Dialogs/packguibase.h +++ b/krusader/Dialogs/packguibase.h @@ -47,8 +47,8 @@ Q_OBJECT public: - explicit PackGUIBase(QWidget* parent = 0); - ~PackGUIBase(); + explicit PackGUIBase(QWidget* parent = nullptr); + ~PackGUIBase() override; QLabel* TextLabel3; QLineEdit* nameData; diff --git a/krusader/Dialogs/packguibase.cpp b/krusader/Dialogs/packguibase.cpp --- a/krusader/Dialogs/packguibase.cpp +++ b/krusader/Dialogs/packguibase.cpp @@ -107,7 +107,7 @@ browseButton = new QToolButton(this); browseButton->setIcon(Icon("document-open")); hbox_2->addWidget(browseButton); - QSpacerItem* spacer = new QSpacerItem(48, 20, QSizePolicy::Fixed, QSizePolicy::Fixed); + auto* spacer = new QSpacerItem(48, 20, QSizePolicy::Fixed, QSizePolicy::Fixed); hbox_2->addItem(spacer); grid->addLayout(hbox_2, 2, 0); @@ -133,7 +133,7 @@ hbox_4->setSpacing(6); hbox_4->setContentsMargins(0, 0, 0, 0); - QSpacerItem* spacer_3 = new QSpacerItem(20, 26, QSizePolicy::Fixed, QSizePolicy::Expanding); + auto* spacer_3 = new QSpacerItem(20, 26, QSizePolicy::Fixed, QSizePolicy::Expanding); hbox_4->addItem(spacer_3); grid->addLayout(hbox_4, 3, 0); @@ -144,17 +144,17 @@ hbox_5->setContentsMargins(0, 0, 0, 0); - QVBoxLayout *compressLayout = new QVBoxLayout; + auto *compressLayout = new QVBoxLayout; compressLayout->setSpacing(6); compressLayout->setContentsMargins(0, 0, 0, 0); multipleVolume = new QCheckBox(i18n("Multiple volume archive"), advancedWidget); connect(multipleVolume, &QCheckBox::toggled, this, &PackGUIBase::checkConsistency); - compressLayout->addWidget(multipleVolume, 0, 0); + compressLayout->addWidget(multipleVolume, 0, nullptr); - QHBoxLayout * volumeHbox = new QHBoxLayout; + auto * volumeHbox = new QHBoxLayout; - QSpacerItem* spacer_5 = new QSpacerItem(20, 26, QSizePolicy::Fixed, QSizePolicy::Fixed); + auto* spacer_5 = new QSpacerItem(20, 26, QSizePolicy::Fixed, QSizePolicy::Fixed); volumeHbox->addItem(spacer_5); TextLabel7 = new QLabel(i18n("Size:"), advancedWidget); @@ -180,15 +180,15 @@ if (level != _defaultCompressionLevel) setCompressionLevel->setChecked(true); connect(setCompressionLevel, &QCheckBox::toggled, this, &PackGUIBase::checkConsistency); - compressLayout->addWidget(setCompressionLevel, 0, 0); + compressLayout->addWidget(setCompressionLevel, 0, nullptr); - QHBoxLayout * sliderHbox = new QHBoxLayout; + auto * sliderHbox = new QHBoxLayout; - QSpacerItem* spacer_6 = new QSpacerItem(20, 26, QSizePolicy::Fixed, QSizePolicy::Fixed); + auto* spacer_6 = new QSpacerItem(20, 26, QSizePolicy::Fixed, QSizePolicy::Fixed); sliderHbox->addItem(spacer_6); QWidget * sliderVBoxWidget = new QWidget(advancedWidget); - QVBoxLayout *sliderVBox = new QVBoxLayout(sliderVBoxWidget); + auto *sliderVBox = new QVBoxLayout(sliderVBoxWidget); compressionSlider = new QSlider(Qt::Horizontal, sliderVBoxWidget); compressionSlider->setMinimum(1); @@ -201,7 +201,7 @@ QWidget * minmaxWidget = new QWidget(sliderVBoxWidget); sliderVBox->addWidget(minmaxWidget); - QHBoxLayout * minmaxHbox = new QHBoxLayout(minmaxWidget); + auto * minmaxHbox = new QHBoxLayout(minmaxWidget); minLabel = new QLabel(i18n("MIN"), minmaxWidget); maxLabel = new QLabel(i18n("MAX"), minmaxWidget); @@ -223,7 +223,7 @@ hbox_5->addWidget(vline, 0, 1); - QGridLayout * passwordGrid = new QGridLayout; + auto * passwordGrid = new QGridLayout; passwordGrid->setSpacing(6); passwordGrid->setContentsMargins(0, 0, 0, 0); @@ -247,9 +247,9 @@ passwordGrid->addWidget(passwordAgain, 1, 1); - QHBoxLayout *consistencyHbox = new QHBoxLayout; + auto *consistencyHbox = new QHBoxLayout; - QSpacerItem* spacer_cons = new QSpacerItem(48, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); + auto* spacer_cons = new QSpacerItem(48, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); consistencyHbox->addItem(spacer_cons); passwordConsistencyLabel = new QLabel(advancedWidget); @@ -259,7 +259,7 @@ encryptHeaders = new QCheckBox(i18n("Encrypt headers"), advancedWidget); passwordGrid->addWidget(encryptHeaders, 3, 0, 1, 2); - QSpacerItem* spacer_psw = new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Expanding); + auto* spacer_psw = new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Expanding); passwordGrid->addItem(spacer_psw, 4, 0); hbox_5->addLayout(passwordGrid, 0, 2); @@ -298,7 +298,7 @@ advancedButton->setText(i18n("&Advanced >>")); hbox_6->addWidget(advancedButton); - QSpacerItem* spacer_2 = new QSpacerItem(140, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); + auto* spacer_2 = new QSpacerItem(140, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); hbox_6->addItem(spacer_2); okButton = new QPushButton(this); diff --git a/krusader/Dialogs/percentalsplitter.h b/krusader/Dialogs/percentalsplitter.h --- a/krusader/Dialogs/percentalsplitter.h +++ b/krusader/Dialogs/percentalsplitter.h @@ -30,13 +30,13 @@ Q_OBJECT public: - explicit PercentalSplitter(QWidget * parent = 0); - virtual ~PercentalSplitter(); + explicit PercentalSplitter(QWidget * parent = nullptr); + ~PercentalSplitter() override; QString toolTipString(int p); protected: - virtual void showEvent(QShowEvent * event) Q_DECL_OVERRIDE; + void showEvent(QShowEvent * event) Q_DECL_OVERRIDE; protected slots: void slotSplitterMoved(int pos, int index); diff --git a/krusader/Dialogs/percentalsplitter.cpp b/krusader/Dialogs/percentalsplitter.cpp --- a/krusader/Dialogs/percentalsplitter.cpp +++ b/krusader/Dialogs/percentalsplitter.cpp @@ -31,14 +31,13 @@ #include #include -PercentalSplitter::PercentalSplitter(QWidget * parent) : QSplitter(parent), label(0), opaqueOldPos(-1) +PercentalSplitter::PercentalSplitter(QWidget * parent) : QSplitter(parent), label(nullptr), opaqueOldPos(-1) { connect(this, &PercentalSplitter::splitterMoved, this, &PercentalSplitter::slotSplitterMoved); } PercentalSplitter::~PercentalSplitter() -{ -} += default; QString PercentalSplitter::toolTipString(int p) { @@ -53,7 +52,7 @@ if (sum == 0) sum++; - int percent = (int)(((double)p / (double)(sum)) * 10000. + 0.5); + auto percent = (int)(((double)p / (double)(sum)) * 10000. + 0.5); return QString("%1.%2%3").arg(percent / 100).arg((percent / 10) % 10).arg(percent % 10) + '%'; } return QString(); diff --git a/krusader/Dialogs/popularurls.h b/krusader/Dialogs/popularurls.h --- a/krusader/Dialogs/popularurls.h +++ b/krusader/Dialogs/popularurls.h @@ -53,8 +53,8 @@ { Q_OBJECT public: - explicit PopularUrls(QObject *parent = 0); - ~PopularUrls(); + explicit PopularUrls(QObject *parent = nullptr); + ~PopularUrls() override; void save(); void load(); void addUrl(const QUrl& url); @@ -91,7 +91,7 @@ Q_OBJECT public: PopularUrlsDlg(); - ~PopularUrlsDlg(); + ~PopularUrlsDlg() override; void run(QList list); // use this to open the dialog inline int result() const { return selection; diff --git a/krusader/Dialogs/popularurls.cpp b/krusader/Dialogs/popularurls.cpp --- a/krusader/Dialogs/popularurls.cpp +++ b/krusader/Dialogs/popularurls.cpp @@ -49,7 +49,7 @@ #define DECREASE 1 PopularUrls::PopularUrls(QObject *parent) : QObject(parent), - head(0), tail(0), count(0) + head(nullptr), tail(nullptr), count(0) { dlg = new PopularUrlsDlg(); } @@ -71,7 +71,7 @@ } } ranks.clear(); - head = tail = 0; + head = tail = nullptr; } void PopularUrls::save() @@ -105,7 +105,7 @@ QStringList::Iterator uit; QList::Iterator rit; for (uit = urlList.begin(), rit = rankList.begin(); uit != urlList.end() && rit != rankList.end(); ++uit, ++rit) { - UrlNodeP node = new UrlNode; + auto node = new UrlNode; node->url = QUrl(*uit); node->rank = *rit; appendNode(node); @@ -223,7 +223,7 @@ { if (!after) { // make node head node->next = head; - node->prev = 0; + node->prev = nullptr; head->prev = node; head = node; } else { @@ -243,9 +243,9 @@ { if (!tail) { // creating the first element head = tail = node; - node->prev = node->next = 0; + node->prev = node->next = nullptr; } else { - node->next = 0; + node->next = nullptr; node->prev = tail; tail->next = node; tail = node; @@ -280,10 +280,10 @@ setWindowTitle(i18n("Popular URLs")); setWindowModality(Qt::WindowModal); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); - QGridLayout *layout = new QGridLayout; + auto *layout = new QGridLayout; layout->setContentsMargins(0, 0, 0, 0); // listview to contain the urls @@ -328,7 +328,7 @@ return; urls->clearSelection(); - urls->setCurrentItem(0); + urls->setCurrentItem(nullptr); QTreeWidgetItemIterator it(urls); while (*it) { @@ -353,10 +353,10 @@ urls->clear(); QList::Iterator it; - QTreeWidgetItem * lastItem = 0; + QTreeWidgetItem * lastItem = nullptr; for (it = list.begin(); it != list.end(); ++it) { - QTreeWidgetItem *item = new QTreeWidgetItem(urls, lastItem); + auto *item = new QTreeWidgetItem(urls, lastItem); lastItem = item; item->setText(0, (*it).isLocalFile() ? (*it).path() : (*it).toDisplayString()); item->setIcon(0, (*it).isLocalFile() ? Icon("folder") : Icon("folder-html")); diff --git a/krusader/DiskUsage/diskusage.h b/krusader/DiskUsage/diskusage.h --- a/krusader/DiskUsage/diskusage.h +++ b/krusader/DiskUsage/diskusage.h @@ -77,31 +77,31 @@ } Directory* getDirectory(QString path); - File * getFile(QString path); + File * getFile(const QString& path); QString getConfigGroup() { return configGroup; } - void * getProperty(File *, QString); - void addProperty(File *, QString, void *); - void removeProperty(File *, QString); + void * getProperty(File *, const QString&); + void addProperty(File *, const QString&, void *); + void removeProperty(File *, const QString&); int exclude(File *file, bool calcPercents = true, int depth = 0); void includeAll(); int del(File *file, bool calcPercents = true, int depth = 0); QString getToolTip(File *); - void rightClickMenu(const QPoint &, File *, QMenu * = 0, QString = QString()); + void rightClickMenu(const QPoint &, File *, QMenu * = 0, const QString& = QString()); void changeDirectory(Directory *dir); Directory* getCurrentDir(); File* getCurrentFile(); - QPixmap getIcon(QString mime); + QPixmap getIcon(const QString& mime); QUrl getBaseURL() { return baseURL; diff --git a/krusader/DiskUsage/diskusage.cpp b/krusader/DiskUsage/diskusage.cpp --- a/krusader/DiskUsage/diskusage.cpp +++ b/krusader/DiskUsage/diskusage.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include "dufilelight.h" #include "dulines.h" @@ -89,7 +90,7 @@ widget = new QWidget(parent); - QGridLayout *loaderLayout = new QGridLayout(widget); + auto *loaderLayout = new QGridLayout(widget); loaderLayout->setSpacing(0); loaderLayout->setContentsMargins(0, 0, 0, 0); @@ -100,7 +101,7 @@ loaderBox->setFrameStyle(QFrame::Panel + QFrame::Raised); loaderBox->setLineWidth(2); - QGridLayout *synchGrid = new QGridLayout(loaderBox); + auto *synchGrid = new QGridLayout(loaderBox); synchGrid->setSpacing(6); synchGrid->setContentsMargins(11, 11, 11, 11); @@ -154,11 +155,11 @@ synchGrid->addWidget(line, 5, 0, 1, 2); QWidget *hboxWidget = new QWidget(loaderBox); - QHBoxLayout * hbox = new QHBoxLayout(hboxWidget); + auto * hbox = new QHBoxLayout(hboxWidget); - QSpacerItem* spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + auto* spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); hbox->addItem(spacer); - QPushButton *cancelButton = new QPushButton(hboxWidget); + auto *cancelButton = new QPushButton(hboxWidget); KStandardGuiItem::assign(cancelButton, KStandardGuiItem::Cancel); hbox->addWidget(cancelButton); @@ -195,8 +196,8 @@ } DiskUsage::DiskUsage(QString confGroup, QWidget *parent) : QStackedWidget(parent), - currentDirectory(0), root(0), configGroup(confGroup), loading(false), - abortLoading(false), clearAfterAbort(false), deleting(false), searchFileSystem(0) + currentDirectory(nullptr), root(nullptr), configGroup(std::move(confGroup)), loading(false), + abortLoading(false), clearAfterAbort(false), deleting(false), searchFileSystem(nullptr) { listView = new DUListView(this); lineView = new DULines(this); @@ -254,17 +255,17 @@ if (searchFileSystem) { delete searchFileSystem; - searchFileSystem = 0; + searchFileSystem = nullptr; } searchFileSystem = FileSystemProvider::instance().getFilesystem(baseDir); - if (searchFileSystem == 0) { + if (searchFileSystem == nullptr) { qWarning() << "could not get filesystem for directory=" << baseDir; loading = abortLoading = clearAfterAbort = false; emit loadFinished(false); return; } - currentFileItem = 0; + currentFileItem = nullptr; if (!loading) { viewBeforeLoad = activeView; @@ -283,12 +284,12 @@ void DiskUsage::slotLoadDirectory() { - if ((currentFileItem == 0 && directoryStack.isEmpty()) || loaderView->wasCancelled() || abortLoading) { + if ((currentFileItem == nullptr && directoryStack.isEmpty()) || loaderView->wasCancelled() || abortLoading) { if (searchFileSystem) delete searchFileSystem; - searchFileSystem = 0; - currentFileItem = 0; + searchFileSystem = nullptr; + currentFileItem = nullptr; setView(viewBeforeLoad); @@ -304,7 +305,7 @@ loading = abortLoading = clearAfterAbort = false; } else if (loading) { for (int counter = 0; counter != MAX_FILENUM; counter ++) { - if (currentFileItem == 0) { + if (currentFileItem == nullptr) { if (directoryStack.isEmpty()) break; @@ -339,7 +340,7 @@ currentFileItem = fileItems.isEmpty() ? 0 : fileItems.takeFirst(); } else { fileNum++; - File *newItem = 0; + File *newItem = nullptr; QString mime = currentFileItem->getMime(); // fast == not using mimetype magic @@ -384,8 +385,8 @@ void DiskUsage::dirUp() { - if (currentDirectory != 0) { - if (currentDirectory->parent() != 0) + if (currentDirectory != nullptr) { + if (currentDirectory->parent() != nullptr) changeDirectory((Directory *)(currentDirectory->parent())); else { QUrl up = KIO::upUrl(baseURL); @@ -410,11 +411,11 @@ return root; if (contentMap.find(dir) == contentMap.end()) - return 0; + return nullptr; return contentMap[ dir ]; } -File * DiskUsage::getFile(QString path) +File * DiskUsage::getFile(const QString& path) { if (path.isEmpty()) return root; @@ -430,14 +431,14 @@ dir.truncate(ndx); Directory *dirEntry = getDirectory(dir); - if (dirEntry == 0) - return 0; + if (dirEntry == nullptr) + return nullptr; for (Iterator it = dirEntry->iterator(); it != dirEntry->end(); ++it) if ((*it)->name() == file) return *it; - return 0; + return nullptr; } void DiskUsage::clear() @@ -453,14 +454,14 @@ contentMap.clear(); if (root) delete root; - root = currentDirectory = 0; + root = currentDirectory = nullptr; } int DiskUsage::calculateSizes(Directory *dirEntry, bool emitSig, int depth) { int changeNr = 0; - if (dirEntry == 0) + if (dirEntry == nullptr) dirEntry = root; KIO::filesize_t own = 0, total = 0; @@ -504,7 +505,7 @@ changeNr++; if (file->isDir()) { - Directory *dir = dynamic_cast(file); + auto *dir = dynamic_cast(file); for (Iterator it = dir->iterator(); it != dir->end(); ++it) changeNr += exclude(*it, false, depth + 1); } @@ -526,7 +527,7 @@ { int changeNr = 0; - if (dir == 0) + if (dir == nullptr) return 0; for (Iterator it = dir->iterator(); it != dir->end(); ++it) { @@ -596,14 +597,14 @@ dirUp(); if (file->isDir()) { - Directory *dir = dynamic_cast(file); + auto *dir = dynamic_cast(file); Iterator it; while ((it = dir->iterator()) != dir->end()) deleteNr += del(*it, false, depth + 1); QString path; - for (const Directory *d = (Directory*)file; d != root && d && d->parent() != 0; d = d->parent()) { + for (const Directory *d = (Directory*)file; d != root && d && d->parent() != nullptr; d = d->parent()) { if (!path.isEmpty()) path = '/' + path; @@ -654,20 +655,20 @@ return deleteNr; } -void * DiskUsage::getProperty(File *item, QString key) +void * DiskUsage::getProperty(File *item, const QString& key) { QHash< File *, Properties *>::iterator itr = propertyMap.find(item); if (itr == propertyMap.end()) - return 0; + return nullptr; QHash::iterator it = (*itr)->find(key); if (it == (*itr)->end()) - return 0; + return nullptr; return it.value(); } -void DiskUsage::addProperty(File *item, QString key, void * prop) +void DiskUsage::addProperty(File *item, const QString& key, void * prop) { Properties *props; QHash< File *, Properties *>::iterator itr = propertyMap.find(item); @@ -680,7 +681,7 @@ props->insert(key, prop); } -void DiskUsage::removeProperty(File *item, QString key) +void DiskUsage::removeProperty(File *item, const QString& key) { QHash< File *, Properties *>::iterator itr = propertyMap.find(item); if (itr == propertyMap.end()) @@ -694,7 +695,7 @@ { Directory *dirEntry = currentDirectory; - if (dirEntry == 0) + if (dirEntry == nullptr) return; QUrl url = baseURL; @@ -725,15 +726,15 @@ return currentDirectory; } -void DiskUsage::rightClickMenu(const QPoint & pos, File *fileItem, QMenu *addPopup, QString addPopupName) +void DiskUsage::rightClickMenu(const QPoint & pos, File *fileItem, QMenu *addPopup, const QString& addPopupName) { QMenu popup(this); popup.setTitle(i18n("Disk Usage")); QHash actionHash; - if (fileItem != 0) { + if (fileItem != nullptr) { QAction * actDelete = popup.addAction(i18n("Delete")); actionHash[ actDelete ] = DELETE_ID; actDelete->setShortcut(Qt::Key_Delete); @@ -766,7 +767,7 @@ popup.addSeparator(); - if (addPopup != 0) { + if (addPopup != nullptr) { QAction * menu = popup.addMenu(addPopup); menu->setText(addPopupName); } @@ -949,7 +950,7 @@ QStackedWidget::keyPressEvent(e); } -QPixmap DiskUsage::getIcon(QString mime) +QPixmap DiskUsage::getIcon(const QString& mime) { QPixmap icon; @@ -976,7 +977,7 @@ { int changeNr = 0; - if (dirEntry == 0) + if (dirEntry == nullptr) dirEntry = root; for (Iterator it = dirEntry->iterator(); it != dirEntry->end(); ++it) { @@ -1061,7 +1062,7 @@ File * DiskUsage::getCurrentFile() { - File * file = 0; + File * file = nullptr; switch (activeView) { case VIEW_LINES: @@ -1095,7 +1096,7 @@ } if (e->type() == QEvent::ShortcutOverride) { - QKeyEvent* ke = (QKeyEvent*) e; + auto* ke = (QKeyEvent*) e; if (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::KeypadModifier) { switch (ke->key()) { diff --git a/krusader/DiskUsage/diskusagegui.h b/krusader/DiskUsage/diskusagegui.h --- a/krusader/DiskUsage/diskusagegui.h +++ b/krusader/DiskUsage/diskusagegui.h @@ -40,19 +40,19 @@ public: explicit DiskUsageGUI(const QUrl &openDir); - ~DiskUsageGUI() {} + ~DiskUsageGUI() override = default; void askDirAndShow(); protected slots: - virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; protected: - virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; private slots: bool askDir(); void slotLoadUsageInfo(); - void slotStatus(QString); + void slotStatus(const QString&); void slotSelectLinesView() { diskUsage->setView(VIEW_LINES); } void slotSelectListView() { diskUsage->setView(VIEW_DETAILED); } diff --git a/krusader/DiskUsage/diskusagegui.cpp b/krusader/DiskUsage/diskusagegui.cpp --- a/krusader/DiskUsage/diskusagegui.cpp +++ b/krusader/DiskUsage/diskusagegui.cpp @@ -46,15 +46,15 @@ baseDirectory = openDir; - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); - QGridLayout *duGrid = new QGridLayout(); + auto *duGrid = new QGridLayout(); duGrid->setSpacing(6); duGrid->setContentsMargins(11, 11, 11, 11); QWidget *duTools = new QWidget(this); - QHBoxLayout *duHBox = new QHBoxLayout(duTools); + auto *duHBox = new QHBoxLayout(duTools); duHBox->setContentsMargins(0, 0, 0, 0); duTools->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); @@ -97,8 +97,8 @@ QWidget *spacerWidget = new QWidget(duTools); duHBox->addWidget(spacerWidget); - QHBoxLayout *hboxlayout = new QHBoxLayout(spacerWidget); - QSpacerItem* spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed); + auto *hboxlayout = new QHBoxLayout(spacerWidget); + auto* spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed); hboxlayout->addItem(spacer); duGrid->addWidget(duTools, 0, 0); @@ -194,7 +194,7 @@ diskUsage->load(baseDirectory); } -void DiskUsageGUI::slotStatus(QString stat) +void DiskUsageGUI::slotStatus(const QString& stat) { status->setText(stat); } diff --git a/krusader/DiskUsage/dufilelight.h b/krusader/DiskUsage/dufilelight.h --- a/krusader/DiskUsage/dufilelight.h +++ b/krusader/DiskUsage/dufilelight.h @@ -64,7 +64,7 @@ void minFontSize(); protected: - virtual void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE; void setScheme(Filelight::MapScheme); diff --git a/krusader/DiskUsage/dufilelight.cpp b/krusader/DiskUsage/dufilelight.cpp --- a/krusader/DiskUsage/dufilelight.cpp +++ b/krusader/DiskUsage/dufilelight.cpp @@ -33,7 +33,7 @@ #define SCHEME_POPUP_ID 6730 DUFilelight::DUFilelight(DiskUsage *usage) - : RadialMap::Widget(usage), diskUsage(usage), currentDir(0), refreshNeeded(true) + : RadialMap::Widget(usage), diskUsage(usage), currentDir(nullptr), refreshNeeded(true) { // setFocusPolicy(Qt::StrongFocus); @@ -63,23 +63,23 @@ void DUFilelight::clear() { invalidate(false); - currentDir = 0; + currentDir = nullptr; } File * DUFilelight::getCurrentFile() { const RadialMap::Segment * focus = focusSegment(); if (!focus || focus->isFake() || focus->file() == currentDir) - return 0; + return nullptr; return (File *)focus->file(); } void DUFilelight::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::RightButton) { - File * file = 0; + File * file = nullptr; const RadialMap::Segment * focus = focusSegment(); @@ -198,7 +198,7 @@ QWidget *widget = diskUsage->widget(ndx); if (widget == this && (diskUsage->getCurrentDir() != currentDir || refreshNeeded)) { refreshNeeded = false; - if ((currentDir = diskUsage->getCurrentDir()) != 0) { + if ((currentDir = diskUsage->getCurrentDir()) != nullptr) { invalidate(false); create(currentDir); } diff --git a/krusader/DiskUsage/dulines.h b/krusader/DiskUsage/dulines.h --- a/krusader/DiskUsage/dulines.h +++ b/krusader/DiskUsage/dulines.h @@ -39,7 +39,7 @@ public: explicit DULines(DiskUsage *usage); - ~DULines(); + ~DULines() override; File * getCurrentFile(); @@ -55,10 +55,10 @@ protected: DiskUsage *diskUsage; - virtual bool event(QEvent * event) Q_DECL_OVERRIDE; - virtual void mouseDoubleClickEvent(QMouseEvent * e) Q_DECL_OVERRIDE; - virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; - virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + bool event(QEvent * event) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent * e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; private: QPixmap createPixmap(int percent, int maxPercent, int maxWidth); diff --git a/krusader/DiskUsage/dulines.cpp b/krusader/DiskUsage/dulines.cpp --- a/krusader/DiskUsage/dulines.cpp +++ b/krusader/DiskUsage/dulines.cpp @@ -48,9 +48,9 @@ { public: - explicit DULinesItemDelegate(QObject *parent = 0) : QItemDelegate(parent) {} + explicit DULinesItemDelegate(QObject *parent = nullptr) : QItemDelegate(parent) {} - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE { + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE { QItemDelegate::paint(painter, option, index); QVariant value = index.data(Qt::UserRole); @@ -124,33 +124,33 @@ class DULinesItem : public QTreeWidgetItem { public: - DULinesItem(DiskUsage *diskUsageIn, File *fileItem, QTreeWidget * parent, QString label1, - QString label2, QString label3) : QTreeWidgetItem(parent), + DULinesItem(DiskUsage *diskUsageIn, File *fileItem, QTreeWidget * parent, const QString& label1, + const QString& label2, const QString& label3) : QTreeWidgetItem(parent), diskUsage(diskUsageIn), file(fileItem) { setText(0, label1); setText(1, label2); setText(2, label3); setTextAlignment(1, Qt::AlignRight); } DULinesItem(DiskUsage *diskUsageIn, File *fileItem, QTreeWidget * parent, QTreeWidgetItem * after, - QString label1, QString label2, QString label3) : QTreeWidgetItem(parent, after), + const QString& label1, const QString& label2, const QString& label3) : QTreeWidgetItem(parent, after), diskUsage(diskUsageIn), file(fileItem) { setText(0, label1); setText(1, label2); setText(2, label3); setTextAlignment(1, Qt::AlignRight); } - virtual bool operator<(const QTreeWidgetItem &other) const Q_DECL_OVERRIDE { + bool operator<(const QTreeWidgetItem &other) const Q_DECL_OVERRIDE { int column = treeWidget() ? treeWidget()->sortColumn() : 0; if (text(0) == "..") return true; - const DULinesItem *compWith = dynamic_cast< const DULinesItem * >(&other); - if (compWith == 0) + const auto *compWith = dynamic_cast< const DULinesItem * >(&other); + if (compWith == nullptr) return false; switch (column) { @@ -234,7 +234,7 @@ { switch (event->type()) { case QEvent::ToolTip: { - QHelpEvent *he = static_cast(event); + auto *he = dynamic_cast(event); if (viewport()) { QPoint pos = viewport()->mapFromGlobal(he->globalPos()); @@ -261,9 +261,9 @@ { clear(); - QTreeWidgetItem * lastItem = 0; + QTreeWidgetItem * lastItem = nullptr; - if (!(dirEntry->parent() == 0)) { + if (!(dirEntry->parent() == nullptr)) { lastItem = new QTreeWidgetItem(this); lastItem->setText(0, ".."); lastItem->setIcon(0, Icon("go-up")); @@ -282,7 +282,7 @@ QString fileName = item->name(); - if (lastItem == 0) + if (lastItem == nullptr) lastItem = new DULinesItem(diskUsage, item, this, "", item->percent() + " ", fileName); else lastItem = new DULinesItem(diskUsage, item, this, lastItem, "", item->percent() + " ", fileName); @@ -368,7 +368,7 @@ return; Directory * currentDir = diskUsage->getCurrentDir(); - if (currentDir == 0) + if (currentDir == nullptr) return; int maxPercent = -1; @@ -383,7 +383,7 @@ while (*it2) { QTreeWidgetItem *lvitem = *it2; if (lvitem->text(0) != "..") { - DULinesItem *duItem = dynamic_cast< DULinesItem *>(lvitem); + auto *duItem = dynamic_cast< DULinesItem *>(lvitem); if (duItem) { int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1; duItem->setData(0, Qt::DecorationRole, createPixmap(duItem->getFile()->intPercent(), maxPercent, header()->sectionSize(0) - 2 * textMargin)); @@ -405,7 +405,7 @@ diskUsage->changeDirectory(dynamic_cast(fileItem)); return true; } else { - Directory *upDir = (Directory *)diskUsage->getCurrentDir()->parent(); + auto *upDir = (Directory *)diskUsage->getCurrentDir()->parent(); if (upDir) diskUsage->changeDirectory(upDir); @@ -455,7 +455,7 @@ void DULines::slotRightClicked(QTreeWidgetItem *item, const QPoint &pos) { - File * file = 0; + File * file = nullptr; if (item && item->text(0) != "..") file = ((DULinesItem *)item)->getFile(); @@ -477,8 +477,8 @@ { QTreeWidgetItem *item = currentItem(); - if (item == 0 || item->text(0) == "..") - return 0; + if (item == nullptr || item->text(0) == "..") + return nullptr; return ((DULinesItem *)item)->getFile(); } @@ -491,7 +491,7 @@ it++; if (lvitem->text(0) != "..") { - DULinesItem *duItem = (DULinesItem *)(lvitem); + auto *duItem = (DULinesItem *)(lvitem); if (duItem->getFile() == item) { setSortingEnabled(false); duItem->setHidden(item->isExcluded()); @@ -514,7 +514,7 @@ it++; if (lvitem->text(0) != "..") { - DULinesItem *duItem = (DULinesItem *)(lvitem); + auto *duItem = (DULinesItem *)(lvitem); if (duItem->getFile() == item) { delete duItem; break; diff --git a/krusader/DiskUsage/dulistview.h b/krusader/DiskUsage/dulistview.h --- a/krusader/DiskUsage/dulistview.h +++ b/krusader/DiskUsage/dulistview.h @@ -31,9 +31,9 @@ class DUListViewItem : public QTreeWidgetItem { public: - DUListViewItem(DiskUsage *diskUsageIn, File *fileIn, QTreeWidget * parent, QString label1, - QString label2, QString label3, QString label4, QString label5, QString label6, - QString label7, QString label8, QString label9) + DUListViewItem(DiskUsage *diskUsageIn, File *fileIn, QTreeWidget * parent, const QString& label1, + const QString& label2, const QString& label3, const QString& label4, const QString& label5, const QString& label6, + const QString& label7, const QString& label8, const QString& label9) : QTreeWidgetItem(parent), diskUsage(diskUsageIn), file(fileIn) { setText(0, label1); setText(1, label2); @@ -52,9 +52,9 @@ setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); diskUsage->addProperty(file, "ListView-Ref", this); } - DUListViewItem(DiskUsage *diskUsageIn, File *fileIn, QTreeWidgetItem * parent, QString label1, - QString label2, QString label3, QString label4, QString label5, QString label6, - QString label7, QString label8, QString label9) + DUListViewItem(DiskUsage *diskUsageIn, File *fileIn, QTreeWidgetItem * parent, const QString& label1, + const QString& label2, const QString& label3, const QString& label4, const QString& label5, const QString& label6, + const QString& label7, const QString& label8, const QString& label9) : QTreeWidgetItem(parent), diskUsage(diskUsageIn), file(fileIn) { setText(0, label1); setText(1, label2); @@ -74,8 +74,8 @@ diskUsage->addProperty(file, "ListView-Ref", this); } DUListViewItem(DiskUsage *diskUsageIn, File *fileIn, QTreeWidget * parent, QTreeWidgetItem * after, - QString label1, QString label2, QString label3, QString label4, QString label5, - QString label6, QString label7, QString label8, QString label9) + const QString& label1, const QString& label2, const QString& label3, const QString& label4, const QString& label5, + const QString& label6, const QString& label7, const QString& label8, const QString& label9) : QTreeWidgetItem(parent, after), diskUsage(diskUsageIn), file(fileIn) { setText(0, label1); setText(1, label2); @@ -95,8 +95,8 @@ diskUsage->addProperty(file, "ListView-Ref", this); } DUListViewItem(DiskUsage *diskUsageIn, File *fileIn, QTreeWidgetItem * parent, QTreeWidgetItem * after, - QString label1, QString label2, QString label3, QString label4, QString label5, - QString label6, QString label7, QString label8, QString label9) + const QString& label1, const QString& label2, const QString& label3, const QString& label4, const QString& label5, + const QString& label6, const QString& label7, const QString& label8, const QString& label9) : QTreeWidgetItem(parent, after), diskUsage(diskUsageIn), file(fileIn) { setText(0, label1); @@ -116,18 +116,18 @@ setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); diskUsage->addProperty(file, "ListView-Ref", this); } - ~DUListViewItem() { + ~DUListViewItem() override { diskUsage->removeProperty(file, "ListView-Ref"); } - virtual bool operator<(const QTreeWidgetItem &other) const Q_DECL_OVERRIDE { + bool operator<(const QTreeWidgetItem &other) const Q_DECL_OVERRIDE { int column = treeWidget() ? treeWidget()->sortColumn() : 0; if (text(0) == "..") return true; - const DUListViewItem *compWith = dynamic_cast< const DUListViewItem * >(&other); - if (compWith == 0) + const auto *compWith = dynamic_cast< const DUListViewItem * >(&other); + if (compWith == nullptr) return false; switch (column) { @@ -158,7 +158,7 @@ public: explicit DUListView(DiskUsage *usage); - ~DUListView(); + ~DUListView() override; File * getCurrentFile(); @@ -172,8 +172,8 @@ protected: DiskUsage *diskUsage; - virtual void mouseDoubleClickEvent(QMouseEvent * e) Q_DECL_OVERRIDE; - virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent * e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; private: void addDirectory(Directory *dirEntry, QTreeWidgetItem *parent); diff --git a/krusader/DiskUsage/dulistview.cpp b/krusader/DiskUsage/dulistview.cpp --- a/krusader/DiskUsage/dulistview.cpp +++ b/krusader/DiskUsage/dulistview.cpp @@ -98,9 +98,9 @@ void DUListView::addDirectory(Directory *dirEntry, QTreeWidgetItem *parent) { - QTreeWidgetItem * lastItem = 0; + QTreeWidgetItem * lastItem = nullptr; - if (parent == 0 && !(dirEntry->parent() == 0)) { + if (parent == nullptr && !(dirEntry->parent() == nullptr)) { lastItem = new QTreeWidgetItem(this); lastItem->setText(0, ".."); lastItem->setIcon(0, Icon("go-up")); @@ -125,13 +125,13 @@ QString ownSize = KRpermHandler::parseSize(item->ownSize()) + ' '; QString percent = item->percent(); - if (lastItem == 0 && parent == 0) + if (lastItem == nullptr && parent == nullptr) lastItem = new DUListViewItem(diskUsage, item, this, item->name(), percent, totalSize, ownSize, mime, date, item->perm(), item->owner(), item->group()); - else if (lastItem == 0) + else if (lastItem == nullptr) lastItem = new DUListViewItem(diskUsage, item, parent, item->name(), percent, totalSize, ownSize, mime, date, item->perm(), item->owner(), item->group()); - else if (parent == 0) + else if (parent == nullptr) lastItem = new DUListViewItem(diskUsage, item, this, lastItem, item->name(), percent, totalSize, ownSize, mime, date, item->perm(), item->owner(), item->group()); else @@ -155,26 +155,26 @@ void DUListView::slotDirChanged(Directory *dirEntry) { clear(); - addDirectory(dirEntry, 0); + addDirectory(dirEntry, nullptr); } File * DUListView::getCurrentFile() { QTreeWidgetItem *item = currentItem(); - if (item == 0 || item->text(0) == "..") - return 0; + if (item == nullptr || item->text(0) == "..") + return nullptr; return ((DUListViewItem *)item)->getFile(); } void DUListView::slotChanged(File * item) { void * itemPtr = diskUsage->getProperty(item, "ListView-Ref"); - if (itemPtr == 0) + if (itemPtr == nullptr) return; - DUListViewItem *duItem = (DUListViewItem *)itemPtr; + auto *duItem = (DUListViewItem *)itemPtr; duItem->setHidden(item->isExcluded()); duItem->setText(1, item->percent()); duItem->setText(2, KRpermHandler::parseSize(item->size()) + ' '); @@ -184,16 +184,16 @@ void DUListView::slotDeleted(File * item) { void * itemPtr = diskUsage->getProperty(item, "ListView-Ref"); - if (itemPtr == 0) + if (itemPtr == nullptr) return; - DUListViewItem *duItem = (DUListViewItem *)itemPtr; + auto *duItem = (DUListViewItem *)itemPtr; delete duItem; } void DUListView::slotRightClicked(QTreeWidgetItem *item, const QPoint & pos) { - File * file = 0; + File * file = nullptr; if (item && item->text(0) != "..") file = ((DUListViewItem *)item)->getFile(); @@ -210,7 +210,7 @@ diskUsage->changeDirectory(dynamic_cast(fileItem)); return true; } else { - Directory *upDir = (Directory *)diskUsage->getCurrentDir()->parent(); + auto *upDir = (Directory *)diskUsage->getCurrentDir()->parent(); if (upDir) diskUsage->changeDirectory(upDir); @@ -259,7 +259,7 @@ void DUListView::slotExpanded(QTreeWidgetItem * item) { - if (item == 0 || item->text(0) == "..") + if (item == nullptr || item->text(0) == "..") return; if (item->childCount() == 0) { diff --git a/krusader/DiskUsage/filelightParts/fileTree.cpp b/krusader/DiskUsage/filelightParts/fileTree.cpp --- a/krusader/DiskUsage/filelightParts/fileTree.cpp +++ b/krusader/DiskUsage/filelightParts/fileTree.cpp @@ -33,11 +33,11 @@ { QString path; - if (root == this) root = 0; //prevent returning empty string when there is something we could return + if (root == this) root = nullptr; //prevent returning empty string when there is something we could return const File *d; - for (d = this; d != root && d && d->parent() != 0; d = d->parent()) { + for (d = this; d != root && d && d->parent() != nullptr; d = d->parent()) { if (!path.isEmpty()) path = '/' + path; diff --git a/krusader/DiskUsage/radialMap/builder.cpp b/krusader/DiskUsage/radialMap/builder.cpp --- a/krusader/DiskUsage/radialMap/builder.cpp +++ b/krusader/DiskUsage/radialMap/builder.cpp @@ -108,9 +108,9 @@ for (ConstIterator it = dir->constIterator(); it != dir->end(); ++it) { if ((*it)->size() > m_limits[depth]) { - unsigned int a_len = (unsigned int)(5760 * ((double)(*it)->size() / (double)m_root->size())); + auto a_len = (unsigned int)(5760 * ((double)(*it)->size() / (double)m_root->size())); - Segment *s = new Segment(*it, a_start, a_len); + auto *s = new Segment(*it, a_start, a_len); (m_signature + depth)->append(s); @@ -128,7 +128,7 @@ hiddenSize += (*it)->size(); if ((*it)->isDir()) //**** considered virtual, but dir wouldn't count itself! - hiddenFileCount += static_cast(*it)->fileCount(); //need to add one to count the dir as well + hiddenFileCount += dynamic_cast(*it)->fileCount(); //need to add one to count the dir as well ++hiddenFileCount; } diff --git a/krusader/DiskUsage/radialMap/labels.cpp b/krusader/DiskUsage/radialMap/labels.cpp --- a/krusader/DiskUsage/radialMap/labels.cpp +++ b/krusader/DiskUsage/radialMap/labels.cpp @@ -105,12 +105,12 @@ //1. Create list of labels sorted in the order they will be rendered - if (m_focus != NULL && m_focus->file() != m_tree) { //separate behavior for selected vs unselected segments + if (m_focus != nullptr && m_focus->file() != m_tree) { //separate behavior for selected vs unselected segments //don't bother with files - if (m_focus->file() == 0 || !m_focus->file()->isDir()) return; + if (m_focus->file() == nullptr || !m_focus->file()->isDir()) return; //find the range of levels we will be potentially drawing labels for - for (const Directory *p = (const Directory *)m_focus->file(); + for (const auto *p = (const Directory *)m_focus->file(); p != m_tree; ++startLevel) { //startLevel is the level above whatever m_focus is in p = p->parent(); @@ -184,7 +184,7 @@ //used in next two steps bool varySizes; //**** should perhaps use doubles - int *sizes = new int [ m_map.m_visibleDepth + 1 ]; //**** make sizes an array of floats I think instead (or doubles) + auto *sizes = new int [ m_map.m_visibleDepth + 1 ]; //**** make sizes an array of floats I think instead (or doubles) do { //3. Calculate font sizes diff --git a/krusader/DiskUsage/radialMap/map.cpp b/krusader/DiskUsage/radialMap/map.cpp --- a/krusader/DiskUsage/radialMap/map.cpp +++ b/krusader/DiskUsage/radialMap/map.cpp @@ -40,7 +40,7 @@ #define COLOR_GREY QColor::fromHsv( 0, 0, 140 ) RadialMap::Map::Map() - : m_signature(0) + : m_signature(nullptr) , m_ringBreadth(MIN_RING_BREADTH) , m_innerRadius(0) , m_visibleDepth(DEFAULT_RING_DEPTH) @@ -60,7 +60,7 @@ RadialMap::Map::invalidate(const bool desaturateTheImage) { delete [] m_signature; - m_signature = 0; + m_signature = nullptr; if (desaturateTheImage) { QImage img = this->toImage(); @@ -149,7 +149,7 @@ size += MAP_2MARGIN; this->QPixmap::operator=(QPixmap(size, size)); - if (m_signature != NULL) { + if (m_signature != nullptr) { setRingBreadth(); paint(); } else fill(); //FIXME I don't like having to do this.. @@ -293,7 +293,7 @@ for (int x = m_visibleDepth; x >= 0; --x) { int width = rect.width() / 2; //clever geometric trick to find largest angle that will give biggest arrow head - int a_max = int(acos((double)width / double((width + 5) * scaleFactor)) * (180 * 16 / M_PI)); + auto a_max = int(acos((double)width / double((width + 5) * scaleFactor)) * (180 * 16 / M_PI)); for (ConstIterator it = m_signature[x].constIterator(); it != m_signature[x].end(); ++it) { //draw the pie segments, most of this code is concerned with drawing the little diff --git a/krusader/DiskUsage/radialMap/segmentTip.cpp b/krusader/DiskUsage/radialMap/segmentTip.cpp --- a/krusader/DiskUsage/radialMap/segmentTip.cpp +++ b/krusader/DiskUsage/radialMap/segmentTip.cpp @@ -37,7 +37,7 @@ { SegmentTip::SegmentTip(uint h) - : QWidget(0, Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint) + : QWidget(nullptr, Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint) , m_cursorHeight(-h) { setAttribute(Qt::WA_NoSystemBackground, true); @@ -125,8 +125,8 @@ m_text += s2; if (file->isDir()) { - double files = static_cast(file)->fileCount(); - const uint pc = uint((100 * files) / (double)root->fileCount()); + double files = dynamic_cast(file)->fileCount(); + const auto pc = uint((100 * files) / (double)root->fileCount()); QString s3 = i18n("Files: %1", loc.toString(files, 'f', 0)); if (pc > 0) s3 += QString(" (%1%)").arg(loc.toString(pc)); diff --git a/krusader/DiskUsage/radialMap/widget.h b/krusader/DiskUsage/radialMap/widget.h --- a/krusader/DiskUsage/radialMap/widget.h +++ b/krusader/DiskUsage/radialMap/widget.h @@ -44,13 +44,13 @@ { public: Map(); - ~Map(); + ~Map() override; void make(const Directory *, bool = false); bool resize(const QRect&); bool isNull() const { - return (m_signature == 0); + return (m_signature == nullptr); } void invalidate(const bool); @@ -79,16 +79,16 @@ Q_OBJECT public: - explicit Widget(QWidget* = 0); + explicit Widget(QWidget* = nullptr); QString path() const; - QUrl url(File const * const = 0) const; + QUrl url(File const * const = nullptr) const; bool isValid() const { - return m_tree != 0; + return m_tree != nullptr; } - friend class Label; //FIXME badness + friend struct Label; //FIXME badness public slots: void zoomIn(); @@ -110,10 +110,10 @@ void mouseHover(const QString&); protected: - virtual void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; - virtual void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE; - virtual void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE; - virtual void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE; protected: const Segment *segmentAt(QPoint&) const; //FIXME const reference for a library others can use diff --git a/krusader/DiskUsage/radialMap/widget.cpp b/krusader/DiskUsage/radialMap/widget.cpp --- a/krusader/DiskUsage/radialMap/widget.cpp +++ b/krusader/DiskUsage/radialMap/widget.cpp @@ -40,10 +40,10 @@ RadialMap::Widget::Widget(QWidget *parent) : QWidget(parent) - , m_tree(0) - , m_focus(0) + , m_tree(nullptr) + , m_focus(nullptr) , m_tip(QFontMetrics(font()).height()) //needs to know cursor height - , m_rootSegment(0) //TODO we don't delete it, *shrug* + , m_rootSegment(nullptr) //TODO we don't delete it, *shrug* { QPalette pal = palette(); pal.setColor(backgroundRole(), Qt::white); @@ -57,15 +57,15 @@ QString RadialMap::Widget::path() const { - if (m_tree == 0) + if (m_tree == nullptr) return QString(); return m_tree->fullPath(); } QUrl RadialMap::Widget::url(File const * const file) const { - if (file == 0 && m_tree == 0) + if (file == nullptr && m_tree == nullptr) return QUrl(); return QUrl::fromLocalFile(file ? file->fullPath() : m_tree->fullPath()); @@ -84,11 +84,11 @@ QUrl urlInv = url(); //ensure this class won't think we have a map still - m_tree = 0; - m_focus = 0; + m_tree = nullptr; + m_focus = nullptr; delete m_rootSegment; - m_rootSegment = 0; + m_rootSegment = nullptr; //FIXME move this disablement thing no? // it is confusing in other areas, like the whole createFromCache() thing @@ -110,7 +110,7 @@ //FIXME make it the responsibility of create to invalidate first if (tree) { - m_focus = 0; + m_focus = nullptr; //generate the filemap image m_map.make(tree); @@ -146,7 +146,7 @@ { // the segments are about to erased! // this was a horrid bug, and proves the OO programming should be obeyed always! - m_focus = 0; + m_focus = nullptr; if (m_tree) m_map.make(m_tree, true); update(); @@ -160,7 +160,7 @@ if (!m_map.isNull()) { switch (filth) { case 1: - m_focus = 0; + m_focus = nullptr; if (m_tree) m_map.make(m_tree, true); //true means refresh only break; @@ -186,7 +186,7 @@ RadialMap::Widget::zoomIn() //slot { if (m_map.m_visibleDepth > MIN_RING_DEPTH) { - m_focus = 0; + m_focus = nullptr; --m_map.m_visibleDepth; if (m_tree) m_map.make(m_tree); @@ -198,7 +198,7 @@ void RadialMap::Widget::zoomOut() //slot { - m_focus = 0; + m_focus = nullptr; ++m_map.m_visibleDepth; if (m_tree) m_map.make(m_tree); diff --git a/krusader/DiskUsage/radialMap/widgetEvents.cpp b/krusader/DiskUsage/radialMap/widgetEvents.cpp --- a/krusader/DiskUsage/radialMap/widgetEvents.cpp +++ b/krusader/DiskUsage/radialMap/widgetEvents.cpp @@ -108,7 +108,7 @@ //ai = x, bi=1, aj=y, bj=0 //cos angle = x / (length) - uint a = (uint)(acos((double)e.x() / length) * 916.736); //916.7324722 = #radians in circle * 16 + auto a = (uint)(acos((double)e.x() / length) * 916.736); //916.7324722 = #radians in circle * 16 //acos only understands 0-180 degrees if (e.y() < 0) a = 5760 - a; @@ -122,7 +122,7 @@ } else return m_rootSegment; //hovering over inner circle } - return 0; + return nullptr; } void @@ -170,7 +170,7 @@ QMenu popup; popup.setTitle(m_focus->file()->fullPath(m_tree)); - QAction * actKonq = 0, * actKonsole = 0, *actViewMag = 0, * actFileOpen = 0, * actEditDel = 0; + QAction * actKonq = nullptr, * actKonsole = nullptr, *actViewMag = nullptr, * actFileOpen = nullptr, * actEditDel = nullptr; if (isDir) { actKonq = popup.addAction(Icon("system-file-manager"), i18n("Open File Manager Here")); @@ -188,7 +188,7 @@ actEditDel = popup.addAction(Icon("edit-delete"), i18n("&Delete")); QAction * result = popup.exec(e->globalPos()); - if (result == 0) + if (result == nullptr) result = (QAction *) - 1; // sanity if (result == actKonq) @@ -207,7 +207,7 @@ if (userIntention == KMessageBox::Continue) { KIO::Job *job = KIO::del(url); - KIO::JobUiDelegate *ui = static_cast(job->uiDelegate()); + auto *ui = dynamic_cast(job->uiDelegate()); ui->setWindow(this); connect(job, &KIO::Job::result, this, &Widget::deleteJobFinished); QApplication::setOverrideCursor(Qt::BusyCursor); diff --git a/krusader/FileSystem/defaultfilesystem.cpp b/krusader/FileSystem/defaultfilesystem.cpp --- a/krusader/FileSystem/defaultfilesystem.cpp +++ b/krusader/FileSystem/defaultfilesystem.cpp @@ -45,7 +45,7 @@ #include "../krservices.h" #include "../JobMan/krjob.h" -DefaultFileSystem::DefaultFileSystem(): FileSystem(), _watcher() +DefaultFileSystem::DefaultFileSystem() { _type = FS_DEFAULT; } @@ -213,7 +213,7 @@ // ensure connection credentials are asked only once if(!parentWindow.isNull()) { - KIO::JobUiDelegate *ui = static_cast(job->uiDelegate()); + auto *ui = dynamic_cast(job->uiDelegate()); ui->setWindow(parentWindow); } @@ -243,7 +243,7 @@ void DefaultFileSystem::slotAddFiles(KIO::Job *, const KIO::UDSEntryList& entries) { - for (const KIO::UDSEntry entry : entries) { + for (const KIO::UDSEntry& entry : entries) { FileItem *fileItem = FileSystem::createFileItemFromKIO(entry, _currentDirectory); if (fileItem) { addFileItem(fileItem); @@ -362,7 +362,7 @@ QT_DIRENT* dirEnt; QString name; const bool showHidden = showHiddenFiles(); - while ((dirEnt = QT_READDIR(dir)) != NULL) { + while ((dirEnt = QT_READDIR(dir)) != nullptr) { name = QString::fromLocal8Bit(dirEnt->d_name); // show hidden files? diff --git a/krusader/FileSystem/dirlisterinterface.h b/krusader/FileSystem/dirlisterinterface.h --- a/krusader/FileSystem/dirlisterinterface.h +++ b/krusader/FileSystem/dirlisterinterface.h @@ -35,7 +35,7 @@ Q_OBJECT public: explicit DirListerInterface(QObject *parent) : QObject(parent) {} - virtual ~DirListerInterface() {} + ~DirListerInterface() override = default; /** * Return the file items of all files and directories. Without current (".") and parent ("..") diff --git a/krusader/FileSystem/fileitem.cpp b/krusader/FileSystem/fileitem.cpp --- a/krusader/FileSystem/fileitem.cpp +++ b/krusader/FileSystem/fileitem.cpp @@ -92,7 +92,7 @@ { return new FileItem(name, url, true, 0, 0700, - time(0), time(0), time(0), + time(nullptr), time(nullptr), time(nullptr), getuid(), getgid()); } diff --git a/krusader/FileSystem/filesystem.h b/krusader/FileSystem/filesystem.h --- a/krusader/FileSystem/filesystem.h +++ b/krusader/FileSystem/filesystem.h @@ -64,7 +64,7 @@ }; FileSystem(); - virtual ~FileSystem(); + ~FileSystem() override; // DirListerInterface implementation inline QList fileItems() const Q_DECL_OVERRIDE { return _fileItems.values(); } @@ -189,7 +189,7 @@ virtual bool refreshInternal(const QUrl &origin, bool stayInDir) = 0; /// Connect the result signal of a file operation job - source URLs. - void connectJobToSources(KJob *job, const QList urls); + void connectJobToSources(KJob *job, const QList& urls); /// Connect the result signal of a file operation job - destination URL. void connectJobToDestination(KJob *job, const QUrl &destination); /// Returns true if showing hidden files is set in config. diff --git a/krusader/FileSystem/filesystem.cpp b/krusader/FileSystem/filesystem.cpp --- a/krusader/FileSystem/filesystem.cpp +++ b/krusader/FileSystem/filesystem.cpp @@ -41,7 +41,7 @@ #include "../JobMan/jobman.h" #include "../JobMan/krjob.h" -FileSystem::FileSystem() : DirListerInterface(0), _isRefreshing(false) {} +FileSystem::FileSystem() : DirListerInterface(nullptr), _isRefreshing(false) {} FileSystem::~FileSystem() { @@ -53,7 +53,7 @@ QList FileSystem::getUrls(const QStringList &names) const { QList urls; - for (const QString name : names) { + for (const QString& name : names) { urls.append(getUrl(name)); } return urls; @@ -167,7 +167,7 @@ krJobMan->manageJob(krJob); } -void FileSystem::connectJobToSources(KJob *job, const QList urls) +void FileSystem::connectJobToSources(KJob *job, const QList& urls) { if (!urls.isEmpty()) { // TODO we assume that all files were in the same directory and only emit one signal for @@ -287,7 +287,7 @@ const QString name = kfi.text(); // ignore un-needed entries if (name.isEmpty() || name == "." || name == "..") { - return 0; + return nullptr; } const QString localPath = kfi.localPath(); diff --git a/krusader/FileSystem/filesystemprovider.h b/krusader/FileSystem/filesystemprovider.h --- a/krusader/FileSystem/filesystemprovider.h +++ b/krusader/FileSystem/filesystemprovider.h @@ -46,7 +46,7 @@ * The filesystem instances returned by this method are already connected with this handler and will * notify each other about filesystem changes. */ - FileSystem *getFilesystem(const QUrl &url, FileSystem *oldFilesystem = 0); + FileSystem *getFilesystem(const QUrl &url, FileSystem *oldFilesystem = nullptr); /** * Start a copy job for copying, moving or linking files to a destination directory. diff --git a/krusader/FileSystem/filesystemprovider.cpp b/krusader/FileSystem/filesystemprovider.cpp --- a/krusader/FileSystem/filesystemprovider.cpp +++ b/krusader/FileSystem/filesystemprovider.cpp @@ -41,7 +41,7 @@ #include "../JobMan/jobman.h" -FileSystemProvider::FileSystemProvider() : _defaultFileSystem(0), _virtFileSystem(0) {} +FileSystemProvider::FileSystemProvider() : _defaultFileSystem(nullptr), _virtFileSystem(nullptr) {} FileSystem *FileSystemProvider::getFilesystem(const QUrl &url, FileSystem *oldFilesystem) { @@ -91,7 +91,7 @@ mountPoint = kMountPoint->mountPoint(); } - for(QPointer fileSystemPointer: _fileSystems) { + for(const QPointer& fileSystemPointer: _fileSystems) { FileSystem *fs = fileSystemPointer.data(); // refresh all filesystems currently showing this directory // and always refresh filesystems showing a virtual directory; it can contain files from @@ -176,9 +176,9 @@ Q_UNUSED(path); Q_UNUSED(type); #ifdef HAVE_POSIX_ACL - acl_t acl = 0; + acl_t acl = nullptr; // do we have an acl for the file, and/or a default acl for the dir, if it is one? - if ((acl = acl_get_file(path.toLocal8Bit(), type)) != 0) { + if ((acl = acl_get_file(path.toLocal8Bit(), type)) != nullptr) { bool aclExtended = false; #ifdef HAVE_NON_POSIX_ACL_EXTENSIONS @@ -201,14 +201,14 @@ if (!aclExtended) { acl_free(acl); - acl = 0; + acl = nullptr; } } - if (acl == 0) + if (acl == nullptr) return QString(); - char *aclString = acl_to_text(acl, 0); + char *aclString = acl_to_text(acl, nullptr); QString ret = QString::fromLatin1(aclString); acl_free((void*)aclString); acl_free(acl); diff --git a/krusader/FileSystem/krpermhandler.cpp b/krusader/FileSystem/krpermhandler.cpp --- a/krusader/FileSystem/krpermhandler.cpp +++ b/krusader/FileSystem/krpermhandler.cpp @@ -74,15 +74,15 @@ #ifndef Q_WS_WIN // fill the UID cache struct passwd *pass; - while ((pass = getpwent()) != 0L) { + while ((pass = getpwent()) != nullptr) { uidCache.insert(pass->pw_uid, pass->pw_name); } delete pass; endpwent(); // fill the GID cache struct group *gr; - while ((gr = getgrent()) != 0L) { + while ((gr = getgrent()) != nullptr) { gidCache.insert(gr->gr_gid, QString(gr->gr_name)); } delete gr; diff --git a/krusader/FileSystem/krquery.h b/krusader/FileSystem/krquery.h --- a/krusader/FileSystem/krquery.h +++ b/krusader/FileSystem/krquery.h @@ -52,10 +52,10 @@ // let operator KRQuery &operator=(const KRQuery &); // destructor - virtual ~KRQuery(); + ~KRQuery() override; // load parameters from config - void load(KConfigGroup cfg); + void load(const KConfigGroup& cfg); // save parameters to config void save(KConfigGroup cfg); @@ -78,7 +78,7 @@ // sets the content part of the query void setContent(const QString &content, bool cs = true, bool wholeWord = false, - QString encoding = QString(), bool regExp = false); + const QString& encoding = QString(), bool regExp = false); const QString content() { return contain; } // sets the minimum file size limit @@ -146,9 +146,9 @@ protected: // important to know whether the event processor is connected - virtual void connectNotify(const QMetaMethod &signal) Q_DECL_OVERRIDE; + void connectNotify(const QMetaMethod &signal) Q_DECL_OVERRIDE; // important to know whether the event processor is connected - virtual void disconnectNotify(const QMetaMethod &signal) Q_DECL_OVERRIDE; + void disconnectNotify(const QMetaMethod &signal) Q_DECL_OVERRIDE; protected: QStringList matches; // what to search @@ -192,9 +192,9 @@ private: bool matchCommon(const QString &, const QStringList &, const QStringList &) const; bool checkPerm(QString perm) const; - bool checkType(QString mime) const; - bool containsContent(QString file) const; - bool containsContent(QUrl url) const; + bool checkType(const QString& mime) const; + bool containsContent(const QString& file) const; + bool containsContent(const QUrl& url) const; bool checkBuffer(const char *data, int len) const; bool checkTimer() const; QStringList split(QString); diff --git a/krusader/FileSystem/krquery.cpp b/krusader/FileSystem/krquery.cpp --- a/krusader/FileSystem/krquery.cpp +++ b/krusader/FileSystem/krquery.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "../Archive/krarchandler.h" #include "fileitem.h" @@ -42,10 +43,10 @@ // set the defaults KRQuery::KRQuery() - : QObject(), matchesCaseSensitive(true), bNull(true), contain(QString()), + : matchesCaseSensitive(true), bNull(true), contain(QString()), containCaseSensetive(true), containWholeWord(false), containRegExp(false), minSize(0), maxSize(0), newerThen(0), olderThen(0), owner(QString()), group(QString()), perm(QString()), - type(QString()), inArchive(false), recurse(true), followLinksP(true), receivedBuffer(0), + type(QString()), inArchive(false), recurse(true), followLinksP(true), receivedBuffer(nullptr), receivedBufferLen(0), processEventsConnected(0), codec(QTextCodec::codecForLocale()) { QChar ch = '\n'; @@ -57,10 +58,10 @@ // set the defaults KRQuery::KRQuery(const QString &name, bool matchCase) - : QObject(), bNull(true), contain(QString()), containCaseSensetive(true), + : bNull(true), contain(QString()), containCaseSensetive(true), containWholeWord(false), containRegExp(false), minSize(0), maxSize(0), newerThen(0), olderThen(0), owner(QString()), group(QString()), perm(QString()), type(QString()), - inArchive(false), recurse(true), followLinksP(true), receivedBuffer(0), receivedBufferLen(0), + inArchive(false), recurse(true), followLinksP(true), receivedBuffer(nullptr), receivedBufferLen(0), processEventsConnected(0), codec(QTextCodec::codecForLocale()) { QChar ch = '\n'; @@ -73,16 +74,16 @@ } KRQuery::KRQuery(const KRQuery &that) - : QObject(), receivedBuffer(0), receivedBufferLen(0), processEventsConnected(0) + : QObject(), receivedBuffer(nullptr), receivedBufferLen(0), processEventsConnected(0) { *this = that; } KRQuery::~KRQuery() { if (receivedBuffer) delete[] receivedBuffer; - receivedBuffer = 0; + receivedBuffer = nullptr; } KRQuery &KRQuery::operator=(const KRQuery &old) @@ -123,7 +124,7 @@ return *this; } -void KRQuery::load(KConfigGroup cfg) +void KRQuery::load(const KConfigGroup& cfg) { *this = KRQuery(); // reset parameters first @@ -232,7 +233,7 @@ return true; } -bool KRQuery::checkType(QString mime) const +bool KRQuery::checkType(const QString& mime) const { if (type == mime) return true; @@ -328,7 +329,7 @@ receivedBytes = 0; if (receivedBuffer) delete receivedBuffer; - receivedBuffer = 0; + receivedBuffer = nullptr; receivedBufferLen = 0; fileName = item->getName(); timer.start(); @@ -375,7 +376,7 @@ { bool result = false; - char *mergedBuffer = new char[len + receivedBufferLen]; + auto *mergedBuffer = new char[len + receivedBufferLen]; if (receivedBufferLen) memcpy(mergedBuffer, receivedBuffer, receivedBufferLen); if (len) @@ -406,7 +407,7 @@ } delete[] receivedBuffer; - receivedBuffer = 0; + receivedBuffer = nullptr; receivedBufferLen = maxLen - lastLinePosition; if (receivedBufferLen) { @@ -479,7 +480,7 @@ return false; } -bool KRQuery::containsContent(QString file) const +bool KRQuery::containsContent(const QString& file) const { QFile qf(file); if (!qf.open(QIODevice::ReadOnly)) @@ -511,7 +512,7 @@ return false; } -bool KRQuery::containsContent(QUrl url) const +bool KRQuery::containsContent(const QUrl& url) const { KIO::TransferJob *contentReader = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo); connect(contentReader, &KIO::TransferJob::data, this, &KRQuery::containsContentData); @@ -551,7 +552,7 @@ bool KRQuery::checkTimer() const { if (timer.elapsed() >= STATUS_SEND_DELAY) { - int pcnt = (int)(100. * (double)receivedBytes / (double)totalBytes + .5); + auto pcnt = (int)(100. * (double)receivedBytes / (double)totalBytes + .5); QString message = i18nc("%1=filename, %2=percentage", "Searching content of '%1' (%2%)", fileName, pcnt); timer.start(); @@ -658,7 +659,7 @@ } } -void KRQuery::setContent(const QString &content, bool cs, bool wholeWord, QString encoding, +void KRQuery::setContent(const QString &content, bool cs, bool wholeWord, const QString& encoding, bool regExp) { bNull = false; @@ -671,7 +672,7 @@ codec = QTextCodec::codecForLocale(); else { codec = QTextCodec::codecForName(encoding.toLatin1()); - if (codec == 0) + if (codec == nullptr) codec = QTextCodec::codecForLocale(); } @@ -728,7 +729,7 @@ { bNull = false; type = typeIn; - customType = customList; + customType = std::move(customList); } bool KRQuery::isExcluded(const QUrl &url) diff --git a/krusader/FileSystem/krtrashhandler.h b/krusader/FileSystem/krtrashhandler.h --- a/krusader/FileSystem/krtrashhandler.h +++ b/krusader/FileSystem/krtrashhandler.h @@ -51,7 +51,7 @@ public: KrTrashWatcher(); - virtual ~KrTrashWatcher(); + ~KrTrashWatcher() override; public slots: void slotTrashChanged(); diff --git a/krusader/FileSystem/krtrashhandler.cpp b/krusader/FileSystem/krtrashhandler.cpp --- a/krusader/FileSystem/krtrashhandler.cpp +++ b/krusader/FileSystem/krtrashhandler.cpp @@ -38,7 +38,7 @@ #include "../icon.h" -KrTrashWatcher * KrTrashHandler::_trashWatcher = 0; +KrTrashWatcher * KrTrashHandler::_trashWatcher = nullptr; bool KrTrashHandler::isTrashEmpty() { @@ -90,7 +90,7 @@ void KrTrashHandler::stopWatcher() { delete _trashWatcher; - _trashWatcher = 0; + _trashWatcher = nullptr; } @@ -108,7 +108,7 @@ KrTrashWatcher::~KrTrashWatcher() { delete _watcher; - _watcher = 0; + _watcher = nullptr; } void KrTrashWatcher::slotTrashChanged() diff --git a/krusader/FileSystem/sizecalculator.h b/krusader/FileSystem/sizecalculator.h --- a/krusader/FileSystem/sizecalculator.h +++ b/krusader/FileSystem/sizecalculator.h @@ -43,7 +43,7 @@ * The calculation is automatically started (like KJob). */ explicit SizeCalculator(const QList &urls); - ~SizeCalculator(); + ~SizeCalculator() override; /** Return all URLs (queued and progressed). */ QList urls() const { return m_urls; } diff --git a/krusader/FileSystem/sizecalculator.cpp b/krusader/FileSystem/sizecalculator.cpp --- a/krusader/FileSystem/sizecalculator.cpp +++ b/krusader/FileSystem/sizecalculator.cpp @@ -97,7 +97,7 @@ if (m_currentUrl.scheme() == "virt") { // calculate size of all files/directories in this virtual directory - VirtualFileSystem *fs = new VirtualFileSystem(); + auto *fs = new VirtualFileSystem(); if (!fs->scanDir(m_currentUrl)) { qWarning() << "cannot scan virtual FS, URL=" << m_currentUrl.toDisplayString(); nextUrl(); @@ -139,8 +139,8 @@ return; } - const KIO::StatJob *statJob = static_cast(job); - const QUrl url = statJob->url(); + const KIO::StatJob *statJob = dynamic_cast(job); + const QUrl& url = statJob->url(); const KFileItem kfi(statJob->statResult(), url, true); if (kfi.isFile() || kfi.isLink()) { @@ -168,7 +168,7 @@ m_totalFiles += m_directorySizeJob->totalFiles(); m_totalDirs += m_directorySizeJob->totalSubdirs(); } - m_directorySizeJob = 0; + m_directorySizeJob = nullptr; nextSubUrl(); } diff --git a/krusader/FileSystem/virtualfilesystem.cpp b/krusader/FileSystem/virtualfilesystem.cpp --- a/krusader/FileSystem/virtualfilesystem.cpp +++ b/krusader/FileSystem/virtualfilesystem.cpp @@ -47,7 +47,7 @@ QHash *> VirtualFileSystem::_virtFilesystemDict; QHash VirtualFileSystem::_metaInfoDict; -VirtualFileSystem::VirtualFileSystem() : FileSystem() +VirtualFileSystem::VirtualFileSystem() { if (_virtFilesystemDict.isEmpty()) { restore(); @@ -111,7 +111,7 @@ } } else { // remove the URLs from the collection - for (const QString name : fileNames) { + for (const QString& name : fileNames) { if (_virtFilesystemDict.find(parentDir) != _virtFilesystemDict.end()) { QList *urlList = _virtFilesystemDict[parentDir]; urlList->removeAll(getUrl(name)); @@ -178,7 +178,7 @@ if (isRoot()) return false; - for (const QString fileName : fileNames) { + for (const QString& fileName : fileNames) { if (!getUrl(fileName).isLocalFile()) { return false; } @@ -313,7 +313,7 @@ if (url.isLocalFile()) { QFileInfo file(url.path()); - return file.exists() ? FileSystem::createLocalFileItem(url.fileName(), directory.path(), true) : 0; + return file.exists() ? FileSystem::createLocalFileItem(url.fileName(), directory.path(), true) : nullptr; } KIO::StatJob *statJob = KIO::stat(url, KIO::HideProgressInfo); @@ -325,12 +325,12 @@ eventLoop.exec(); // blocking until quit() if (_fileEntry.count() == 0) { - return 0; // stat job failed + return nullptr; // stat job failed } if (!_fileEntry.contains(KIO::UDSEntry::UDS_MODIFICATION_TIME)) { // TODO this also happens for FTP directories - return 0; // file not found + return nullptr; // file not found } return FileSystem::createFileItemFromKIO(_fileEntry, directory, true); @@ -345,7 +345,7 @@ void VirtualFileSystem::slotStatResult(KJob *job) { - _fileEntry = job->error() ? KIO::UDSEntry() : static_cast(job)->statResult(); + _fileEntry = job->error() ? KIO::UDSEntry() : dynamic_cast(job)->statResult(); } void VirtualFileSystem::showError(const QString &error) diff --git a/krusader/Filter/advancedfilter.h b/krusader/Filter/advancedfilter.h --- a/krusader/Filter/advancedfilter.h +++ b/krusader/Filter/advancedfilter.h @@ -41,17 +41,17 @@ Q_OBJECT public: - explicit AdvancedFilter(FilterTabs *tabs, QWidget *parent = 0); + explicit AdvancedFilter(FilterTabs *tabs, QWidget *parent = nullptr); - virtual void queryAccepted() Q_DECL_OVERRIDE {} - virtual QString name() Q_DECL_OVERRIDE { + void queryAccepted() Q_DECL_OVERRIDE {} + QString name() Q_DECL_OVERRIDE { return "AdvancedFilter"; } - virtual FilterTabs * filterTabs() Q_DECL_OVERRIDE { + FilterTabs * filterTabs() Q_DECL_OVERRIDE { return fltTabs; } - virtual bool getSettings(FilterSettings&) Q_DECL_OVERRIDE; - virtual void applySettings(const FilterSettings&) Q_DECL_OVERRIDE; + bool getSettings(FilterSettings&) Q_DECL_OVERRIDE; + void applySettings(const FilterSettings&) Q_DECL_OVERRIDE; public slots: void modifiedBetweenSetDate1(); @@ -106,7 +106,7 @@ private: void changeDate(KLineEdit *p); - void fillList(KComboBox *list, QString filename); + void fillList(KComboBox *list, const QString& filename); void invalidDateMessage(KLineEdit *p); static QDate stringToDate(const QString& text) { // 30.12.16 is interpreted as 1916-12-30 diff --git a/krusader/Filter/advancedfilter.cpp b/krusader/Filter/advancedfilter.cpp --- a/krusader/Filter/advancedfilter.cpp +++ b/krusader/Filter/advancedfilter.cpp @@ -49,18 +49,18 @@ AdvancedFilter::AdvancedFilter(FilterTabs *tabs, QWidget *parent) : QWidget(parent), fltTabs(tabs) { - QGridLayout *filterLayout = new QGridLayout(this); + auto *filterLayout = new QGridLayout(this); filterLayout->setSpacing(6); filterLayout->setContentsMargins(11, 11, 11, 11); // Options for size - QGroupBox *sizeGroup = new QGroupBox(this); + auto *sizeGroup = new QGroupBox(this); QSizePolicy sizeGroupPolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); sizeGroupPolicy.setHeightForWidth(sizeGroup->sizePolicy().hasHeightForWidth()); sizeGroup->setSizePolicy(sizeGroupPolicy); sizeGroup->setTitle(i18n("Size")); - QGridLayout *sizeLayout = new QGridLayout(sizeGroup); + auto *sizeLayout = new QGridLayout(sizeGroup); sizeLayout->setAlignment(Qt::AlignTop); sizeLayout->setSpacing(6); sizeLayout->setContentsMargins(11, 11, 11, 11); @@ -115,11 +115,11 @@ Icon iconDate("view-calendar"); - QGroupBox *dateGroup = new QGroupBox(this); - QButtonGroup *btnGroup = new QButtonGroup(dateGroup); + auto *dateGroup = new QGroupBox(this); + auto *btnGroup = new QButtonGroup(dateGroup); dateGroup->setTitle(i18n("Date")); btnGroup->setExclusive(true); - QGridLayout *dateLayout = new QGridLayout(dateGroup); + auto *dateLayout = new QGridLayout(dateGroup); dateLayout->setAlignment(Qt::AlignTop); dateLayout->setSpacing(6); dateLayout->setContentsMargins(11, 11, 11, 11); @@ -214,7 +214,7 @@ dateLayout->addWidget(notModifiedAfterBtn, 2, 2); dateLayout->addWidget(modifiedInTheLastEnabled, 3, 0); - QHBoxLayout *modifiedInTheLastLayout = new QHBoxLayout(); + auto *modifiedInTheLastLayout = new QHBoxLayout(); modifiedInTheLastLayout->addWidget(modifiedInTheLastData); modifiedInTheLastLayout->addWidget(modifiedInTheLastType); dateLayout->addLayout(modifiedInTheLastLayout, 3, 1); @@ -229,14 +229,14 @@ // Options for ownership - QGroupBox *ownershipGroup = new QGroupBox(this); + auto *ownershipGroup = new QGroupBox(this); ownershipGroup->setTitle(i18n("Ownership")); - QGridLayout *ownershipLayout = new QGridLayout(ownershipGroup); + auto *ownershipLayout = new QGridLayout(ownershipGroup); ownershipLayout->setAlignment(Qt::AlignTop); ownershipLayout->setSpacing(6); ownershipLayout->setContentsMargins(11, 11, 11, 11); - QHBoxLayout *hboxLayout = new QHBoxLayout(); + auto *hboxLayout = new QHBoxLayout(); hboxLayout->setSpacing(6); hboxLayout->setContentsMargins(0, 0, 0, 0); @@ -264,8 +264,8 @@ permissionsEnabled->setText(i18n("P&ermissions")); ownershipLayout->addWidget(permissionsEnabled, 1, 0); - QGroupBox *ownerGroup = new QGroupBox(ownershipGroup); - QHBoxLayout *ownerHBox = new QHBoxLayout(ownerGroup); + auto *ownerGroup = new QGroupBox(ownershipGroup); + auto *ownerHBox = new QHBoxLayout(ownerGroup); ownerGroup->setTitle(i18n("O&wner")); ownerR = new KComboBox(ownerGroup); @@ -291,8 +291,8 @@ ownershipLayout->addWidget(ownerGroup, 1, 1); - QGroupBox *groupGroup = new QGroupBox(ownershipGroup); - QHBoxLayout *groupHBox = new QHBoxLayout(groupGroup); + auto *groupGroup = new QGroupBox(ownershipGroup); + auto *groupHBox = new QHBoxLayout(groupGroup); groupGroup->setTitle(i18n("Grou&p")); groupR = new KComboBox(groupGroup); @@ -318,8 +318,8 @@ ownershipLayout->addWidget(groupGroup, 1, 2); - QGroupBox *allGroup = new QGroupBox(ownershipGroup); - QHBoxLayout *allHBox = new QHBoxLayout(allGroup); + auto *allGroup = new QGroupBox(ownershipGroup); + auto *allHBox = new QHBoxLayout(allGroup); allGroup->setTitle(i18n("A&ll")); allR = new KComboBox(allGroup); @@ -445,15 +445,15 @@ QDate d = stringToDate(p->text()); if (!d.isValid()) d = QDate::currentDate(); - KRGetDate *gd = new KRGetDate(d, this); + auto *gd = new KRGetDate(d, this); d = gd->getDate(); // if a user pressed ESC or closed the dialog, we'll return an invalid date if (d.isValid()) p->setText(dateToString(d)); delete gd; } -void AdvancedFilter::fillList(KComboBox *list, QString filename) +void AdvancedFilter::fillList(KComboBox *list, const QString& filename) { QFile data(filename); if (!data.open(QIODevice::ReadOnly)) { diff --git a/krusader/Filter/filterdialog.h b/krusader/Filter/filterdialog.h --- a/krusader/Filter/filterdialog.h +++ b/krusader/Filter/filterdialog.h @@ -35,7 +35,7 @@ Q_OBJECT public: - explicit FilterDialog(QWidget *parent = 0, QString caption = QString(), + explicit FilterDialog(QWidget *parent = nullptr, const QString& caption = QString(), QStringList extraOptions = QStringList(), bool modal = true); KRQuery getQuery(); const FilterSettings& getSettings() { diff --git a/krusader/Filter/filterdialog.cpp b/krusader/Filter/filterdialog.cpp --- a/krusader/Filter/filterdialog.cpp +++ b/krusader/Filter/filterdialog.cpp @@ -28,20 +28,21 @@ #include #include +#include -FilterDialog::FilterDialog(QWidget *parent, QString caption, QStringList extraOptions, bool modal) +FilterDialog::FilterDialog(QWidget *parent, const QString& caption, QStringList extraOptions, bool modal) : QDialog(parent) { setWindowTitle(caption.isNull() ? i18n("Krusader::Choose Files") : caption); setModal(modal); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); - QTabWidget *filterWidget = new QTabWidget; + auto *filterWidget = new QTabWidget; - filterTabs = FilterTabs::addTo(filterWidget, FilterTabs::HasProfileHandler, extraOptions); - generalFilter = static_cast (filterTabs->get("GeneralFilter")); + filterTabs = FilterTabs::addTo(filterWidget, FilterTabs::HasProfileHandler, std::move(extraOptions)); + generalFilter = dynamic_cast (filterTabs->get("GeneralFilter")); mainLayout->addWidget(filterWidget); @@ -74,12 +75,12 @@ bool FilterDialog::isExtraOptionChecked(QString name) { - return filterTabs->isExtraOptionChecked(name); + return filterTabs->isExtraOptionChecked(std::move(name)); } void FilterDialog::checkExtraOption(QString name, bool check) { - filterTabs->checkExtraOption(name, check); + filterTabs->checkExtraOption(std::move(name), check); } void FilterDialog::slotCloseRequest(bool doAccept) diff --git a/krusader/Filter/filtersettings.h b/krusader/Filter/filtersettings.h --- a/krusader/Filter/filtersettings.h +++ b/krusader/Filter/filtersettings.h @@ -39,7 +39,7 @@ bool isValid() const { return valid; } - void load(KConfigGroup cfg); + void load(const KConfigGroup& cfg); void save(KConfigGroup cfg) const; KRQuery toQuery() const; @@ -76,7 +76,7 @@ TimeUnit unit; }; - static void saveDate(QString key, const QDate &date, KConfigGroup &cfg); + static void saveDate(const QString& key, const QDate &date, KConfigGroup &cfg); static time_t qdate2time_t(QDate d, bool start); bool valid; diff --git a/krusader/Filter/filtersettings.cpp b/krusader/Filter/filtersettings.cpp --- a/krusader/Filter/filtersettings.cpp +++ b/krusader/Filter/filtersettings.cpp @@ -30,11 +30,7 @@ #include FilterSettings::FileSize& FilterSettings::FileSize::operator=(const FileSize &other) -{ - amount = other.amount; - unit = other.unit; - return *this; -} += default; KIO::filesize_t FilterSettings::FileSize::size() const { @@ -55,11 +51,7 @@ FilterSettings::TimeSpan& FilterSettings::TimeSpan::operator=(const TimeSpan &other) -{ - amount = other.amount; - unit = other.unit; - return *this; -} += default; int FilterSettings::TimeSpan::days() const { @@ -140,7 +132,7 @@ return *this; } -void FilterSettings::load(KConfigGroup cfg) { +void FilterSettings::load(const KConfigGroup& cfg) { *this = FilterSettings(); #define LOAD(key, var) { var = cfg.readEntry(key, var); } LOAD("IsValid", valid); @@ -186,7 +178,7 @@ #undef LOAD } -void FilterSettings::saveDate(QString key, const QDate &date, KConfigGroup &cfg) +void FilterSettings::saveDate(const QString& key, const QDate &date, KConfigGroup &cfg) { if(date.isValid()) cfg.writeEntry(key, date); diff --git a/krusader/Filter/filtertabs.h b/krusader/Filter/filtertabs.h --- a/krusader/Filter/filtertabs.h +++ b/krusader/Filter/filtertabs.h @@ -45,18 +45,18 @@ static FilterTabs * addTo(QTabWidget *tabWidget, int props = FilterTabs::Default, QStringList extraOptions = QStringList()); - static KRQuery getQuery(QWidget *parent = 0); + static KRQuery getQuery(QWidget *parent = nullptr); - FilterBase *get(QString name); + FilterBase *get(const QString& name); bool isExtraOptionChecked(QString name); void checkExtraOption(QString name, bool check); FilterSettings getSettings(); void applySettings(const FilterSettings &s); void reset(); public slots: - void loadFromProfile(QString); - void saveToProfile(QString); + void loadFromProfile(const QString&); + void saveToProfile(const QString&); bool fillQuery(KRQuery *query); void close(bool accept = true) { emit closeRequest(accept); diff --git a/krusader/Filter/filtertabs.cpp b/krusader/Filter/filtertabs.cpp --- a/krusader/Filter/filtertabs.cpp +++ b/krusader/Filter/filtertabs.cpp @@ -30,20 +30,21 @@ #include #include #include +#include FilterTabs::FilterTabs(int properties, QTabWidget *tabWidget, QObject *parent, QStringList extraOptions) : QObject(parent) { this->tabWidget = tabWidget; - GeneralFilter *generalFilter = new GeneralFilter(this, properties, tabWidget, extraOptions); + GeneralFilter *generalFilter = new GeneralFilter(this, properties, tabWidget, std::move(extraOptions)); tabWidget->addTab(generalFilter, i18n("&General")); filterList.append(generalFilter); pageNumbers.append(tabWidget->indexOf(generalFilter)); - AdvancedFilter *advancedFilter = new AdvancedFilter(this, tabWidget); + auto *advancedFilter = new AdvancedFilter(this, tabWidget); tabWidget->addTab(advancedFilter, i18n("&Advanced")); filterList.append(advancedFilter); pageNumbers.append(tabWidget->indexOf(advancedFilter)); @@ -53,17 +54,17 @@ bool FilterTabs::isExtraOptionChecked(QString name) { - return static_cast(get("GeneralFilter"))->isExtraOptionChecked(name); + return dynamic_cast(get("GeneralFilter"))->isExtraOptionChecked(std::move(name)); } void FilterTabs::checkExtraOption(QString name, bool check) { - static_cast(get("GeneralFilter"))->checkExtraOption(name, check); + dynamic_cast(get("GeneralFilter"))->checkExtraOption(std::move(name), check); } FilterTabs * FilterTabs::addTo(QTabWidget *tabWidget, int props, QStringList extraOptions) { - return new FilterTabs(props, tabWidget, tabWidget, extraOptions); + return new FilterTabs(props, tabWidget, tabWidget, std::move(extraOptions)); } FilterSettings FilterTabs::getSettings() @@ -99,15 +100,15 @@ applySettings(s); } -void FilterTabs::saveToProfile(QString name) +void FilterTabs::saveToProfile(const QString& name) { FilterSettings s(getSettings()); if(s.isValid()) s.save(KConfigGroup(krConfig, name)); krConfig->sync(); } -void FilterTabs::loadFromProfile(QString name) +void FilterTabs::loadFromProfile(const QString& name) { FilterSettings s; s.load(KConfigGroup(krConfig, name)); @@ -134,7 +135,7 @@ return !query->isNull(); } -FilterBase * FilterTabs::get(QString name) +FilterBase * FilterTabs::get(const QString& name) { QListIterator it(filterList); while (it.hasNext()) { @@ -144,7 +145,7 @@ return filter; } - return 0; + return nullptr; } KRQuery FilterTabs::getQuery(QWidget *parent) diff --git a/krusader/Filter/generalfilter.h b/krusader/Filter/generalfilter.h --- a/krusader/Filter/generalfilter.h +++ b/krusader/Filter/generalfilter.h @@ -43,22 +43,22 @@ Q_OBJECT public: - GeneralFilter(FilterTabs *tabs, int properties, QWidget *parent = 0, + GeneralFilter(FilterTabs *tabs, int properties, QWidget *parent = nullptr, QStringList extraOptions = QStringList()); - ~GeneralFilter(); + ~GeneralFilter() override; - virtual void queryAccepted() Q_DECL_OVERRIDE; - virtual QString name() Q_DECL_OVERRIDE { + void queryAccepted() Q_DECL_OVERRIDE; + QString name() Q_DECL_OVERRIDE { return "GeneralFilter"; } - virtual FilterTabs * filterTabs() Q_DECL_OVERRIDE { + FilterTabs * filterTabs() Q_DECL_OVERRIDE { return fltTabs; } - virtual bool getSettings(FilterSettings&) Q_DECL_OVERRIDE; - virtual void applySettings(const FilterSettings&) Q_DECL_OVERRIDE; + bool getSettings(FilterSettings&) Q_DECL_OVERRIDE; + void applySettings(const FilterSettings&) Q_DECL_OVERRIDE; - bool isExtraOptionChecked(QString name); - void checkExtraOption(QString name, bool check); + bool isExtraOptionChecked(const QString& name); + void checkExtraOption(const QString& name, bool check); public slots: void slotAddBtnClicked(); diff --git a/krusader/Filter/generalfilter.cpp b/krusader/Filter/generalfilter.cpp --- a/krusader/Filter/generalfilter.cpp +++ b/krusader/Filter/generalfilter.cpp @@ -87,19 +87,19 @@ GeneralFilter::GeneralFilter(FilterTabs *tabs, int properties, QWidget *parent, QStringList extraOptions) : QWidget(parent), - profileManager(0), fltTabs(tabs) + profileManager(nullptr), fltTabs(tabs) { - QGridLayout *filterLayout = new QGridLayout(this); + auto *filterLayout = new QGridLayout(this); filterLayout->setSpacing(6); filterLayout->setContentsMargins(11, 11, 11, 11); this->properties = properties; // Options for name filtering - QGroupBox *nameGroup = new QGroupBox(this); + auto *nameGroup = new QGroupBox(this); nameGroup->setTitle(i18n("File Name")); - QGridLayout *nameGroupLayout = new QGridLayout(nameGroup); + auto *nameGroupLayout = new QGridLayout(nameGroup); nameGroupLayout->setAlignment(Qt::AlignTop); nameGroupLayout->setSpacing(6); nameGroupLayout->setContentsMargins(11, 11, 11, 11); @@ -180,9 +180,9 @@ if (properties & FilterTabs::HasProfileHandler) { // The profile handler - QGroupBox *profileHandler = new QGroupBox(this); + auto *profileHandler = new QGroupBox(this); profileHandler->setTitle(i18n("&Profile handler")); - QGridLayout *profileLayout = new QGridLayout(profileHandler); + auto *profileLayout = new QGridLayout(profileHandler); profileLayout->setAlignment(Qt::AlignTop); profileLayout->setSpacing(6); profileLayout->setContentsMargins(11, 11, 11, 11); @@ -219,7 +219,7 @@ if (properties & FilterTabs::HasSearchIn) { // Options for search in QGroupBox *searchGroupBox = new QGroupBox(i18n("Searc&h in"), this); - QGridLayout *searchLayout = new QGridLayout(searchGroupBox); + auto *searchLayout = new QGridLayout(searchGroupBox); searchLayout->setAlignment(Qt::AlignTop); searchLayout->setSpacing(6); searchLayout->setContentsMargins(11, 11, 11, 11); @@ -234,7 +234,7 @@ if (properties & FilterTabs::HasDontSearchIn) { // Options for don't search in QGroupBox *searchGroupBox = new QGroupBox(i18n("&Do not search in"), this); - QGridLayout *searchLayout = new QGridLayout(searchGroupBox); + auto *searchLayout = new QGridLayout(searchGroupBox); searchLayout->setAlignment(Qt::AlignTop); searchLayout->setSpacing(6); searchLayout->setContentsMargins(11, 11, 11, 11); @@ -265,14 +265,14 @@ // Options for containing text - QGroupBox *containsGroup = new QGroupBox(this); + auto *containsGroup = new QGroupBox(this); containsGroup->setTitle(i18n("Containing text")); - QGridLayout *containsLayout = new QGridLayout(containsGroup); + auto *containsLayout = new QGridLayout(containsGroup); containsLayout->setAlignment(Qt::AlignTop); containsLayout->setSpacing(6); containsLayout->setContentsMargins(11, 11, 11, 11); - QHBoxLayout *containsTextLayout = new QHBoxLayout(); + auto *containsTextLayout = new QHBoxLayout(); containsTextLayout->setSpacing(6); containsTextLayout->setContentsMargins(0, 0, 0, 0); @@ -298,7 +298,7 @@ containsRegExp->setCheckable(true); containsRegExp->setText(i18n("RegExp")); // Populate the popup menu. - QMenu *patterns = new QMenu(containsRegExp); + auto *patterns = new QMenu(containsRegExp); for (int i = 0; (unsigned)i < sizeof(items) / sizeof(items[0]); i++) { patterns->addAction(new RegExpAction(patterns, i18n(items[i].description), items[i].regExp, items[i].cursorAdjustment)); @@ -312,7 +312,7 @@ containsLayout->addLayout(containsTextLayout, 0, 0); - QHBoxLayout *containsCbsLayout = new QHBoxLayout(); + auto *containsCbsLayout = new QHBoxLayout(); containsCbsLayout->setSpacing(6); containsCbsLayout->setContentsMargins(0, 0, 0, 0); @@ -324,7 +324,7 @@ contentEncoding->addItems(KCharsets::charsets()->descriptiveEncodingNames()); containsCbsLayout->addWidget(contentEncoding); - QSpacerItem* cbSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + auto* cbSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); containsCbsLayout->addItem(cbSpacer); containsWholeWord = new QCheckBox(containsGroup); @@ -347,10 +347,10 @@ filterLayout->addWidget(containsGroup, 2, 0); - QHBoxLayout *recurseLayout = new QHBoxLayout(); + auto *recurseLayout = new QHBoxLayout(); recurseLayout->setSpacing(6); recurseLayout->setContentsMargins(0, 0, 0, 0); - QSpacerItem* recurseSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + auto* recurseSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); recurseLayout->addItem(recurseSpacer); if (properties & FilterTabs::HasRecurseOptions) { @@ -372,7 +372,7 @@ filterLayout->addLayout(recurseLayout, 3, 0); for(int i = 0; i < extraOptions.length(); i++) { - QCheckBox *option = new QCheckBox(this); + auto *option = new QCheckBox(this); option->setText(extraOptions[i]); recurseLayout->addWidget(option); this->extraOptions.insert(extraOptions[i], option); @@ -435,13 +435,13 @@ krConfig->sync(); } -bool GeneralFilter::isExtraOptionChecked(QString name) +bool GeneralFilter::isExtraOptionChecked(const QString& name) { QCheckBox *option = extraOptions[name]; return option ? option->isChecked() : false; } -void GeneralFilter::checkExtraOption(QString name, bool check) +void GeneralFilter::checkExtraOption(const QString& name, bool check) { QCheckBox *option = extraOptions[name]; if (option) @@ -475,16 +475,16 @@ QCheckBox *GeneralFilter::createExcludeCheckBox(const KConfigGroup &group) { - QCheckBox *excludeCheckBox = new QCheckBox(this); + auto *excludeCheckBox = new QCheckBox(this); excludeCheckBox->setText(i18n("Exclude Folder Names")); excludeCheckBox->setToolTip(i18n("Filters out specified directory names from the results.")); excludeCheckBox->setChecked(static_cast(group.readEntry("ExcludeFolderNamesUse", 0))); return excludeCheckBox; } KHistoryComboBox *GeneralFilter::createExcludeComboBox(const KConfigGroup &group) { - KHistoryComboBox *excludeComboBox = new KHistoryComboBox(false, this); + auto *excludeComboBox = new KHistoryComboBox(false, this); QSizePolicy excludeFolderNamesPolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); excludeFolderNamesPolicy.setHeightForWidth(excludeComboBox->sizePolicy().hasHeightForWidth()); excludeComboBox->setSizePolicy(excludeFolderNamesPolicy); @@ -510,22 +510,22 @@ void GeneralFilter::slotOverwriteBtnClicked() { QListWidgetItem *item = profileListBox->currentItem(); - if (item != 0) + if (item != nullptr) profileManager->overwriteProfile(item->text()); } void GeneralFilter::slotRemoveBtnClicked() { QListWidgetItem *item = profileListBox->currentItem(); - if (item != 0) { + if (item != nullptr) { profileManager->deleteProfile(item->text()); refreshProfileListBox(); } } void GeneralFilter::slotProfileDoubleClicked(QListWidgetItem *item) { - if (item != 0) { + if (item != nullptr) { QString profileName = item->text(); profileManager->loadProfile(profileName); fltTabs->close(true); @@ -535,7 +535,7 @@ void GeneralFilter::slotLoadBtnClicked() { QListWidgetItem *item = profileListBox->currentItem(); - if (item != 0) + if (item != nullptr) profileManager->loadProfile(item->text()); } @@ -566,10 +566,10 @@ void GeneralFilter::slotRegExpTriggered(QAction * act) { - if (act == 0) + if (act == nullptr) return; - RegExpAction *regAct = dynamic_cast(act); - if (regAct == 0) + auto *regAct = dynamic_cast(act); + if (regAct == nullptr) return; containsText->lineEdit()->insert(regAct->regExp()); containsText->lineEdit()->setCursorPosition(containsText->lineEdit()->cursorPosition() + regAct->cursor()); diff --git a/krusader/GUI/dirhistorybutton.h b/krusader/GUI/dirhistorybutton.h --- a/krusader/GUI/dirhistorybutton.h +++ b/krusader/GUI/dirhistorybutton.h @@ -34,8 +34,8 @@ { Q_OBJECT public: - explicit DirHistoryButton(DirHistoryQueue* hQ, QWidget *parent = 0); - ~DirHistoryButton(); + explicit DirHistoryButton(DirHistoryQueue* hQ, QWidget *parent = nullptr); + ~DirHistoryButton() override; void showMenu(); diff --git a/krusader/GUI/dirhistorybutton.cpp b/krusader/GUI/dirhistorybutton.cpp --- a/krusader/GUI/dirhistorybutton.cpp +++ b/krusader/GUI/dirhistorybutton.cpp @@ -55,7 +55,7 @@ connect(popupMenu, &QMenu::triggered, this, &DirHistoryButton::slotPopupActivated); } -DirHistoryButton::~DirHistoryButton() {} +DirHistoryButton::~DirHistoryButton() = default; void DirHistoryButton::showMenu() { diff --git a/krusader/GUI/kcmdline.h b/krusader/GUI/kcmdline.h --- a/krusader/GUI/kcmdline.h +++ b/krusader/GUI/kcmdline.h @@ -45,7 +45,7 @@ public: explicit CmdLineCombo(QWidget *parent); - virtual bool eventFilter(QObject *watched, QEvent *e) Q_DECL_OVERRIDE; + bool eventFilter(QObject *watched, QEvent *e) Q_DECL_OVERRIDE; QString path() { return _path; @@ -59,8 +59,8 @@ void doLayout(); protected: - virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; - virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; void updateLineEditGeometry(); @@ -74,11 +74,11 @@ { Q_OBJECT public: - explicit KCMDLine(QWidget *parent = 0); - ~KCMDLine(); + explicit KCMDLine(QWidget *parent = nullptr); + ~KCMDLine() override; void setCurrent(const QString &path); //virtual methods from KrActionBase - void setText(QString text); + void setText(const QString& text); QString command() const Q_DECL_OVERRIDE; ExecType execType() const Q_DECL_OVERRIDE; QString startpath() const Q_DECL_OVERRIDE; @@ -95,15 +95,15 @@ void slotReturnFocus(); // returns keyboard focus to panel void slotRun(); void addPlaceholder(); - void addText(QString text) { + void addText(const QString& text) { cmdLine->lineEdit()->setText(cmdLine->lineEdit()->text() + text); } void popup() { cmdLine->showPopup(); } protected: - virtual void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE { + void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE { cmdLine->setFocus(); } diff --git a/krusader/GUI/kcmdline.cpp b/krusader/GUI/kcmdline.cpp --- a/krusader/GUI/kcmdline.cpp +++ b/krusader/GUI/kcmdline.cpp @@ -39,6 +39,7 @@ #include #include +#include #include "../krglobal.h" #include "../icon.h" @@ -72,7 +73,7 @@ void CmdLineCombo::setPath(QString path) { - _path = path; + _path = std::move(path); doLayout(); } @@ -157,7 +158,7 @@ KCMDLine::KCMDLine(QWidget *parent) : QWidget(parent) { - QGridLayout * layout = new QGridLayout(this); + auto * layout = new QGridLayout(this); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); @@ -309,7 +310,7 @@ return true; } -void KCMDLine::setText(QString text) +void KCMDLine::setText(const QString& text) { cmdLine->lineEdit()->setText(text); } diff --git a/krusader/GUI/kcmdmodebutton.h b/krusader/GUI/kcmdmodebutton.h --- a/krusader/GUI/kcmdmodebutton.h +++ b/krusader/GUI/kcmdmodebutton.h @@ -36,8 +36,8 @@ Q_OBJECT public: /** Constructor. Sets up the menu, and the icon */ - explicit KCMDModeButton(QWidget *parent = 0); - ~KCMDModeButton(); + explicit KCMDModeButton(QWidget *parent = nullptr); + ~KCMDModeButton() override; /** Shows the popup menu. Called when clicked to the button */ void showMenu(); diff --git a/krusader/GUI/kcmdmodebutton.cpp b/krusader/GUI/kcmdmodebutton.cpp --- a/krusader/GUI/kcmdmodebutton.cpp +++ b/krusader/GUI/kcmdmodebutton.cpp @@ -48,7 +48,7 @@ adjustSize(); action = new KActionMenu(i18n("Execution mode"), this); Q_CHECK_PTR(action); - for (int i = 0; KrActions::execTypeArray[i] != 0; i++) { + for (int i = 0; KrActions::execTypeArray[i] != nullptr; i++) { action->addAction(*KrActions::execTypeArray[i]); } QMenu *pP = action->menu(); diff --git a/krusader/GUI/kfnkeys.cpp b/krusader/GUI/kfnkeys.cpp --- a/krusader/GUI/kfnkeys.cpp +++ b/krusader/GUI/kfnkeys.cpp @@ -32,7 +32,7 @@ #include "../Panel/listpanelactions.h" KFnKeys::KFnKeys(QWidget *parent, KrMainWindow *mainWindow) : - QWidget(parent), mainWindow(mainWindow), buttonList() + QWidget(parent), mainWindow(mainWindow) { buttonList << setup(mainWindow->listPanelActions()->actRenameF2, i18n("Rename")) << setup(mainWindow->listPanelActions()->actViewFileF3, i18n("View")) @@ -46,7 +46,7 @@ updateShortcuts(); - QGridLayout *layout = new QGridLayout(this); + auto *layout = new QGridLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); @@ -66,7 +66,7 @@ KFnKeys::ButtonEntry KFnKeys::setup(QAction *action, const QString &text) { - QPushButton *button = new QPushButton(this); + auto *button = new QPushButton(this); button->setMinimumWidth(45); button->setToolTip(action->toolTip()); connect(button, &QPushButton::clicked, action, &QAction::trigger); diff --git a/krusader/GUI/krlistwidget.h b/krusader/GUI/krlistwidget.h --- a/krusader/GUI/krlistwidget.h +++ b/krusader/GUI/krlistwidget.h @@ -29,7 +29,7 @@ Q_OBJECT public: - explicit KrListWidget(QWidget * parent = 0); + explicit KrListWidget(QWidget * parent = nullptr); signals: void itemRightClicked(QListWidgetItem * it, const QPoint & pos); diff --git a/krusader/GUI/krlistwidget.cpp b/krusader/GUI/krlistwidget.cpp --- a/krusader/GUI/krlistwidget.cpp +++ b/krusader/GUI/krlistwidget.cpp @@ -26,7 +26,7 @@ KrListWidget::KrListWidget(QWidget *parent) : QListWidget(parent) { - KrStyleProxy *style = new KrStyleProxy(); + auto *style = new KrStyleProxy(); style->setParent(this); setStyle(style); diff --git a/krusader/GUI/krremoteencodingmenu.h b/krusader/GUI/krremoteencodingmenu.h --- a/krusader/GUI/krremoteencodingmenu.h +++ b/krusader/GUI/krremoteencodingmenu.h @@ -36,7 +36,7 @@ { Q_OBJECT public: - KrRemoteEncodingMenu(const QString &text, const QString &iconName, KActionCollection *parent = 0); + KrRemoteEncodingMenu(const QString &text, const QString &iconName, KActionCollection *parent = nullptr); protected slots: diff --git a/krusader/GUI/krremoteencodingmenu.cpp b/krusader/GUI/krremoteencodingmenu.cpp --- a/krusader/GUI/krremoteencodingmenu.cpp +++ b/krusader/GUI/krremoteencodingmenu.cpp @@ -202,12 +202,12 @@ partList.erase(partList.begin()); } - for (QStringList::Iterator it = domains.begin(); it != domains.end(); ++it) { + for (auto & domain : domains) { //qDebug() << "Domain to remove: " << *it; - if (config.hasGroup(*it)) - config.deleteGroup(*it); - else if (config.group("").hasKey(*it)) - config.group("").deleteEntry(*it); //don't know what group name is supposed to be XXX + if (config.hasGroup(domain)) + config.deleteGroup(domain); + else if (config.group("").hasKey(domain)) + config.group("").deleteEntry(domain); //don't know what group name is supposed to be XXX } } config.sync(); diff --git a/krusader/GUI/krstyleproxy.cpp b/krusader/GUI/krstyleproxy.cpp --- a/krusader/GUI/krstyleproxy.cpp +++ b/krusader/GUI/krstyleproxy.cpp @@ -34,7 +34,7 @@ QPainter *painter, const QWidget *widget) const { if (element == QStyle::PE_FrameFocusRect) { - if (const QStyleOptionFocusRect *fropt = qstyleoption_cast(option)) { + if (const auto *fropt = qstyleoption_cast(option)) { QColor bg = fropt->backgroundColor; QPen oldPen = painter->pen(); QPen newPen; diff --git a/krusader/GUI/krtreewidget.h b/krusader/GUI/krtreewidget.h --- a/krusader/GUI/krtreewidget.h +++ b/krusader/GUI/krtreewidget.h @@ -46,7 +46,7 @@ void itemRightClicked(QTreeWidgetItem * it, const QPoint & pos, int column); protected: - virtual bool event(QEvent * event) Q_DECL_OVERRIDE; + bool event(QEvent * event) Q_DECL_OVERRIDE; private: int _stretchingColumn; diff --git a/krusader/GUI/krtreewidget.cpp b/krusader/GUI/krtreewidget.cpp --- a/krusader/GUI/krtreewidget.cpp +++ b/krusader/GUI/krtreewidget.cpp @@ -37,7 +37,7 @@ _stretchingColumn = -1; - KrStyleProxy *krstyle = new KrStyleProxy(); + auto *krstyle = new KrStyleProxy(); krstyle->setParent(this); setStyle(krstyle); } @@ -47,7 +47,7 @@ switch (event->type()) { // HACK: QT 4 Context menu key isn't handled properly case QEvent::ContextMenu: { - QContextMenuEvent* ce = (QContextMenuEvent*) event; + auto* ce = (QContextMenuEvent*) event; if (ce->reason() == QContextMenuEvent::Mouse) { QPoint pos = viewport()->mapFromGlobal(ce->globalPos()); @@ -71,7 +71,7 @@ case QEvent::KeyPress: { // HACK: QT 4 Ctrl+A bug fix: Ctrl+A doesn't work if QTreeWidget contains parent / child items // Insert doesn't change the selections for multi selection modes - QKeyEvent* ke = (QKeyEvent*) event; + auto* ke = (QKeyEvent*) event; switch (ke->key()) { case Qt::Key_Insert: { if (ke->modifiers() != 0) @@ -85,7 +85,7 @@ ke->accept(); - if (currentItem() == 0) + if (currentItem() == nullptr) return true; currentItem()->setSelected(!currentItem()->isSelected()); @@ -109,7 +109,7 @@ } break; case QEvent::Resize: { - QResizeEvent * re = (QResizeEvent *)event; + auto * re = (QResizeEvent *)event; if (!_inResize && re->oldSize() != re->size()) { if (_stretchingColumn != -1 && columnCount()) { QList< int > columnsSizes; @@ -146,7 +146,7 @@ break; } case QEvent::ToolTip: { - QHelpEvent *he = static_cast(event); + auto *he = dynamic_cast(event); if (viewport()) { QPoint pos = viewport()->mapFromGlobal(he->globalPos()); @@ -184,7 +184,7 @@ QSize iconSize = icon.actualSize(opts.decorationSize); requiredWidth += iconSize.width(); - int pixmapMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, this) + 1; + int pixmapMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, this) + 1; requiredWidth += 2 * pixmapMargin; } diff --git a/krusader/GUI/krusaderstatus.h b/krusader/GUI/krusaderstatus.h --- a/krusader/GUI/krusaderstatus.h +++ b/krusader/GUI/krusaderstatus.h @@ -32,8 +32,8 @@ { Q_OBJECT public: - explicit KrusaderStatus(QWidget *parent = 0); - ~KrusaderStatus(); + explicit KrusaderStatus(QWidget *parent = nullptr); + ~KrusaderStatus() override; private: QLabel *mess; diff --git a/krusader/GUI/krusaderstatus.cpp b/krusader/GUI/krusaderstatus.cpp --- a/krusader/GUI/krusaderstatus.cpp +++ b/krusader/GUI/krusaderstatus.cpp @@ -34,6 +34,5 @@ } KrusaderStatus::~KrusaderStatus() -{ -} += default; diff --git a/krusader/GUI/mediabutton.h b/krusader/GUI/mediabutton.h --- a/krusader/GUI/mediabutton.h +++ b/krusader/GUI/mediabutton.h @@ -41,8 +41,8 @@ { Q_OBJECT public: - explicit MediaButton(QWidget *parent = 0); - ~MediaButton(); + explicit MediaButton(QWidget *parent = nullptr); + ~MediaButton() override; public slots: void slotAboutToShow(); @@ -66,17 +66,17 @@ private: void createMediaList(); - void toggleMount(QString udi); - void getStatus(QString udi, bool &mounted, QString *mountPointOut = 0, bool *ejectableOut = 0); - void mount(QString, bool open = false, bool newtab = false); - void umount(QString); + void toggleMount(const QString& udi); + void getStatus(const QString& udi, bool &mounted, QString *mountPointOut = nullptr, bool *ejectableOut = nullptr); + void mount(const QString&, bool open = false, bool newtab = false); + void umount(const QString&); void eject(QString); - void rightClickMenu(QString udi, QPoint pos); + void rightClickMenu(const QString& udi, QPoint pos); QList storageDevices; private slots: - void slotSetupDone(Solid::ErrorType error, QVariant errorData, const QString &udi); + void slotSetupDone(Solid::ErrorType error, const QVariant& errorData, const QString &udi); private: static QString remotePrefix; diff --git a/krusader/GUI/mediabutton.cpp b/krusader/GUI/mediabutton.cpp --- a/krusader/GUI/mediabutton.cpp +++ b/krusader/GUI/mediabutton.cpp @@ -43,12 +43,13 @@ #include #include #include +#include QString MediaButton::remotePrefix = QLatin1String("remote:"); MediaButton::MediaButton(QWidget *parent) : QToolButton(parent), - popupMenu(0), rightMenu(0), openInNewTab(false) + popupMenu(nullptr), rightMenu(nullptr), openInNewTab(false) { setAutoRaise(true); setIcon(Icon("system-file-manager")); @@ -75,8 +76,7 @@ } MediaButton::~MediaButton() -{ -} += default; void MediaButton::updateIcon(const QString &mountPoint) { @@ -90,7 +90,7 @@ if(!mountPoint.isEmpty()) { Solid::Device device(krMtMan.findUdiForPath(mountPoint, Solid::DeviceInterface::StorageAccess));; - Solid::StorageVolume *vol = device.as (); + auto *vol = device.as (); if(device.isValid()) iconName = device.icon(); @@ -142,25 +142,25 @@ KMountPoint::List possibleMountList = KMountPoint::possibleMountPoints(); KMountPoint::List currentMountList = KMountPoint::currentMountPoints(); - for (KMountPoint::List::iterator it = possibleMountList.begin(); it != possibleMountList.end(); ++it) { - if (krMtMan.networkFilesystem((*it)->mountType())) { - QString path = (*it)->mountPoint(); + for (auto & it : possibleMountList) { + if (krMtMan.networkFilesystem(it->mountType())) { + QString path = it->mountPoint(); bool mounted = false; - for (KMountPoint::List::iterator it2 = currentMountList.begin(); it2 != currentMountList.end(); ++it2) { - if (krMtMan.networkFilesystem((*it2)->mountType()) && - (*it)->mountPoint() == (*it2)->mountPoint()) { + for (auto & it2 : currentMountList) { + if (krMtMan.networkFilesystem(it2->mountType()) && + it->mountPoint() == it2->mountPoint()) { mounted = true; break; } } - QString name = i18nc("%1 is the mount point of the remote share", "Remote Share [%1]", (*it)->mountPoint()); + QString name = i18nc("%1 is the mount point of the remote share", "Remote Share [%1]", it->mountPoint()); QStringList overlays; if (mounted) overlays << "emblem-mounted"; QAction * act = popupMenu->addAction(Icon("network-wired", overlays), name); - QString udi = remotePrefix + (*it)->mountPoint(); + QString udi = remotePrefix + it->mountPoint(); act->setData(QVariant(udi)); } } @@ -171,8 +171,8 @@ bool MediaButton::getNameAndIcon(Solid::Device & device, QString &name, QIcon &iconOut) { - Solid::StorageAccess *access = device.as(); - if (access == 0) + auto *access = device.as(); + if (access == nullptr) return false; QString udi = device.udi(); @@ -184,7 +184,7 @@ QString fstype; QString size; - Solid::StorageVolume * vol = device.as (); + auto * vol = device.as (); if (vol) { label = vol->label(); fstype = vol->fsType(); @@ -289,7 +289,7 @@ } } } else if (e->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast(e); + auto *ke = dynamic_cast(e); if (ke->key() == Qt::Key_Return && ke->modifiers() == Qt::ControlModifier) { if (QAction *act = popupMenu->activeAction()) { QString id = act->data().toString(); @@ -300,7 +300,7 @@ } } } else if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease) { - QMouseEvent *m = static_cast(e); + auto *m = dynamic_cast(e); if (m->button() == Qt::RightButton) { if (e->type() == QEvent::MouseButtonPress) { QAction * act = popupMenu->actionAt(m->pos()); @@ -318,7 +318,7 @@ return false; } -void MediaButton::rightClickMenu(QString udi, QPoint pos) +void MediaButton::rightClickMenu(const QString& udi, QPoint pos) { if (rightMenu) rightMenu->close(); @@ -352,12 +352,12 @@ QAction *act = myMenu->exec(pos); int result = -1; - if (act != 0 && act->data().canConvert()) + if (act != nullptr && act->data().canConvert()) result = act->data().toInt(); delete myMenu; if (rightMenu == myMenu) - rightMenu = 0; + rightMenu = nullptr; else return; @@ -388,7 +388,7 @@ } } -void MediaButton::toggleMount(QString udi) +void MediaButton::toggleMount(const QString& udi) { bool mounted = false; getStatus(udi, mounted); @@ -399,7 +399,7 @@ mount(udi); } -void MediaButton::getStatus(QString udi, bool &mounted, QString *mountPointOut, bool *ejectableOut) +void MediaButton::getStatus(const QString& udi, bool &mounted, QString *mountPointOut, bool *ejectableOut) { mounted = false; bool network = udi.startsWith(remotePrefix); @@ -410,18 +410,18 @@ mountPoint = udi.mid(remotePrefix.length()); KMountPoint::List currentMountList = KMountPoint::currentMountPoints(); - for (KMountPoint::List::iterator it = currentMountList.begin(); it != currentMountList.end(); ++it) { - if (krMtMan.networkFilesystem((*it)->mountType()) && - (*it)->mountPoint() == mountPoint) { + for (auto & it : currentMountList) { + if (krMtMan.networkFilesystem(it->mountType()) && + it->mountPoint() == mountPoint) { mounted = true; break; } } } else { Solid::Device device(udi); - Solid::StorageAccess *access = device.as(); - Solid::OpticalDisc *optdisc = device.as(); + auto *access = device.as(); + auto *optdisc = device.as(); if (access) mountPoint = access->filePath(); if (access && access->isAccessible()) @@ -436,7 +436,7 @@ *ejectableOut = ejectable; } -void MediaButton::mount(QString udi, bool open, bool newtab) +void MediaButton::mount(const QString& udi, bool open, bool newtab) { if (udi.startsWith(remotePrefix)) { QString mp = udi.mid(remotePrefix.length()); @@ -448,20 +448,20 @@ return; } Solid::Device device(udi); - Solid::StorageAccess *access = device.as(); + auto *access = device.as(); if (access && !access->isAccessible()) { if (open) udiToOpen = device.udi(), openInNewTab = newtab; connect(access, &Solid::StorageAccess::setupDone, this, &MediaButton::slotSetupDone); access->setup(); } } -void MediaButton::slotSetupDone(Solid::ErrorType error, QVariant errorData, const QString &udi) +void MediaButton::slotSetupDone(Solid::ErrorType error, const QVariant& errorData, const QString &udi) { if (error == Solid::NoError) { if (udi == udiToOpen) { - Solid::StorageAccess *access = Solid::Device(udi).as(); + auto *access = Solid::Device(udi).as(); if (access && access->isAccessible()) { if (openInNewTab) emit newTab(QUrl::fromLocalFile(access->filePath())); @@ -486,7 +486,7 @@ } } -void MediaButton::umount(QString udi) +void MediaButton::umount(const QString& udi) { if (udi.startsWith(remotePrefix)) { krMtMan.unmount(udi.mid(remotePrefix.length()), false); @@ -497,7 +497,7 @@ void MediaButton::eject(QString udi) { - krMtMan.eject(krMtMan.pathForUdi(udi)); + krMtMan.eject(krMtMan.pathForUdi(std::move(udi))); } void MediaButton::slotAccessibilityChanged(bool /*accessible*/, const QString & udi) @@ -524,8 +524,8 @@ return; Solid::Device device(udi); - Solid::StorageAccess *access = device.as(); - if (access == 0) + auto *access = device.as(); + if (access == nullptr) return; QString name; @@ -572,9 +572,9 @@ QString mountPoint = act->data().toString().mid(remotePrefix.length()); bool available = false; - for (KMountPoint::List::iterator it = possibleMountList.begin(); it != possibleMountList.end(); ++it) { - if (krMtMan.networkFilesystem((*it)->mountType()) && - (*it)->mountPoint() == mountPoint) { + for (auto & it : possibleMountList) { + if (krMtMan.networkFilesystem(it->mountType()) && + it->mountPoint() == mountPoint) { available = true; break; } @@ -587,28 +587,28 @@ } } - for (KMountPoint::List::iterator it = possibleMountList.begin(); it != possibleMountList.end(); ++it) { - if (krMtMan.networkFilesystem((*it)->mountType())) { - QString path = (*it)->mountPoint(); + for (auto & it : possibleMountList) { + if (krMtMan.networkFilesystem(it->mountType())) { + QString path = it->mountPoint(); bool mounted = false; QString udi = remotePrefix + path; - QAction * correspondingAct = 0; + QAction * correspondingAct = nullptr; foreach(QAction * act, actionList) { if (act && act->data().canConvert() && act->data().toString() == udi) { correspondingAct = act; break; } } - for (KMountPoint::List::iterator it2 = currentMountList.begin(); it2 != currentMountList.end(); ++it2) { - if (krMtMan.networkFilesystem((*it2)->mountType()) && - path == (*it2)->mountPoint()) { + for (auto & it2 : currentMountList) { + if (krMtMan.networkFilesystem(it2->mountType()) && + path == it2->mountPoint()) { mounted = true; break; } } - QString name = i18nc("%1 is the mount point of the remote share", "Remote Share [%1]", (*it)->mountPoint()); + QString name = i18nc("%1 is the mount point of the remote share", "Remote Share [%1]", it->mountPoint()); QStringList overlays; if (mounted) overlays << "emblem-mounted"; diff --git a/krusader/GUI/profilemanager.h b/krusader/GUI/profilemanager.h --- a/krusader/GUI/profilemanager.h +++ b/krusader/GUI/profilemanager.h @@ -47,23 +47,23 @@ Q_OBJECT public: - explicit ProfileManager(QString profileType, QWidget * parent = 0); + explicit ProfileManager(const QString& profileType, QWidget * parent = nullptr); /** * @param profileType Type of the profile (sync, search, ...) * @return A list of all available profile-names */ - static QStringList availableProfiles(QString profileType); + static QStringList availableProfiles(const QString& profileType); QStringList getNames(); public slots: void profilePopup(); - void newProfile(QString defaultName = QString()); - void deleteProfile(QString name); - void overwriteProfile(QString name); - bool loadProfile(QString name); + void newProfile(const QString& defaultName = QString()); + void deleteProfile(const QString& name); + void overwriteProfile(const QString& name); + bool loadProfile(const QString& name); signals: void saveToProfile(QString profileName); diff --git a/krusader/GUI/profilemanager.cpp b/krusader/GUI/profilemanager.cpp --- a/krusader/GUI/profilemanager.cpp +++ b/krusader/GUI/profilemanager.cpp @@ -32,7 +32,7 @@ #include "../krglobal.h" #include "../icon.h" -ProfileManager::ProfileManager(QString profileType, QWidget * parent) +ProfileManager::ProfileManager(const QString& profileType, QWidget * parent) : QPushButton(parent) { setText(""); @@ -100,7 +100,7 @@ } } -void ProfileManager::newProfile(QString defaultName) +void ProfileManager::newProfile(const QString& defaultName) { QString profile = QInputDialog::getText(this, i18n("Krusader::ProfileManager"), i18n("Enter the profile name:"), QLineEdit::Normal, defaultName); @@ -123,7 +123,7 @@ } } -void ProfileManager::deleteProfile(QString name) +void ProfileManager::deleteProfile(const QString& name) { for (int i = 0; i != profileList.count() ; i++) { KConfigGroup group(krConfig, profileType + " - " + profileList[ i ]); @@ -141,7 +141,7 @@ } } -void ProfileManager::overwriteProfile(QString name) +void ProfileManager::overwriteProfile(const QString& name) { for (int i = 0; i != profileList.count() ; i++) { KConfigGroup group(krConfig, profileType + " - " + profileList[ i ]); @@ -154,7 +154,7 @@ } } -bool ProfileManager::loadProfile(QString name) +bool ProfileManager::loadProfile(const QString& name) { for (int i = 0; i != profileList.count() ; i++) { KConfigGroup group(krConfig, profileType + " - " + profileList[i]); @@ -168,7 +168,7 @@ return false; } -QStringList ProfileManager::availableProfiles(QString profileType) +QStringList ProfileManager::availableProfiles(const QString& profileType) { KConfigGroup group(krConfig, "Private"); QStringList profiles = group.readEntry(profileType, QStringList()); diff --git a/krusader/GUI/terminaldock.h b/krusader/GUI/terminaldock.h --- a/krusader/GUI/terminaldock.h +++ b/krusader/GUI/terminaldock.h @@ -46,15 +46,15 @@ Q_OBJECT public: TerminalDock(QWidget* parent, KrMainWindow *mainWindow); - virtual ~TerminalDock(); + ~TerminalDock() override; void sendInput(const QString& input, bool clearCommand=true); void sendCd(const QString& path); - virtual bool eventFilter(QObject * watched, QEvent * e) Q_DECL_OVERRIDE; + bool eventFilter(QObject * watched, QEvent * e) Q_DECL_OVERRIDE; bool isTerminalVisible() const; bool isInitialised() const; bool initialise(); - virtual void hideEvent(QHideEvent * e) Q_DECL_OVERRIDE; - virtual void showEvent(QShowEvent * e) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent * e) Q_DECL_OVERRIDE; + void showEvent(QShowEvent * e) Q_DECL_OVERRIDE; inline KParts::Part* part() { return konsole_part; } diff --git a/krusader/GUI/terminaldock.cpp b/krusader/GUI/terminaldock.cpp --- a/krusader/GUI/terminaldock.cpp +++ b/krusader/GUI/terminaldock.cpp @@ -59,14 +59,13 @@ * A widget containing the konsolepart for the Embedded terminal emulator */ TerminalDock::TerminalDock(QWidget* parent, KrMainWindow *mainWindow) : QWidget(parent), - _mainWindow(mainWindow), konsole_part(0), t(0), initialised(false), firstInput(true) + _mainWindow(mainWindow), konsole_part(nullptr), t(nullptr), initialised(false), firstInput(true) { terminal_hbox = new QHBoxLayout(this); } TerminalDock::~TerminalDock() -{ -} += default; bool TerminalDock::initialise() { @@ -96,7 +95,7 @@ initialised = true; firstInput = true; } else - KMessageBox::error(0, i18n("Cannot create embedded terminal.
" + KMessageBox::error(nullptr, i18n("Cannot create embedded terminal.
" "The reported error was: %1", error)); // the Terminal Emulator may be hidden (if we are creating it only // to send command there and see the results later) @@ -106,12 +105,12 @@ ACTIVE_PANEL->gui->slotFocusOnMe(); } } else - KMessageBox::sorry(0, i18nc("missing program - arg1 is a URL", + KMessageBox::sorry(nullptr, i18nc("missing program - arg1 is a URL", "Cannot create embedded terminal.
" "You can fix this by installing Konsole:
%1", QString("%1").arg( "https://www.kde.org/applications/system/konsole")), - 0, KMessageBox::AllowLink); + nullptr, KMessageBox::AllowLink); } return isInitialised(); } @@ -121,8 +120,8 @@ qDebug() << "killed"; initialised = false; - konsole_part = NULL; - t = NULL; + konsole_part = nullptr; + t = nullptr; qApp->removeEventFilter(this); MAIN_VIEW->setTerminalEmulator(false); } @@ -213,23 +212,23 @@ bool TerminalDock::eventFilter(QObject * watched, QEvent * e) { - if (konsole_part == NULL || konsole_part->widget() == NULL) + if (konsole_part == nullptr || konsole_part->widget() == nullptr) return false; // we must watch for child widgets as well, // otherwise some shortcuts are "eaten" by them before // being processed in konsole_part->widget() context // examples are Ctrl+F, Ctrl+Enter QObject *w; - for (w = watched; w != NULL; w = w->parent()) + for (w = watched; w != nullptr; w = w->parent()) if (w == konsole_part->widget()) break; - if (w == NULL) // is not a child of konsole_part + if (w == nullptr) // is not a child of konsole_part return false; switch (e->type()) { case QEvent::ShortcutOverride: { - QKeyEvent *ke = (QKeyEvent *)e; + auto *ke = (QKeyEvent *)e; // If not present, some keys would be considered a shortcut, for example "a" if ((ke->key() == Qt::Key_Insert) && (ke->modifiers() == Qt::ShiftModifier)) { ke->accept(); @@ -243,7 +242,7 @@ break; } case QEvent::KeyPress: { - QKeyEvent *ke = (QKeyEvent *)e; + auto *ke = (QKeyEvent *)e; if (applyShortcuts(ke)) { ke->accept(); return true; @@ -258,13 +257,13 @@ bool TerminalDock::isTerminalVisible() const { - return isVisible() && konsole_part != NULL && konsole_part->widget() != NULL + return isVisible() && konsole_part != nullptr && konsole_part->widget() != nullptr && konsole_part->widget()->isVisible(); } bool TerminalDock::isInitialised() const { - return konsole_part != NULL && konsole_part->widget() != NULL; + return konsole_part != nullptr && konsole_part->widget() != nullptr; } void TerminalDock::hideEvent(QHideEvent * /*e*/) diff --git a/krusader/JobMan/jobman.h b/krusader/JobMan/jobman.h --- a/krusader/JobMan/jobman.h +++ b/krusader/JobMan/jobman.h @@ -72,7 +72,7 @@ Delay }; - explicit JobMan(QObject *parent = 0); + explicit JobMan(QObject *parent = nullptr); /** Toolbar action icon for pausing/starting all jobs with drop down menu showing all jobs.*/ QAction *controlAction() const { return m_controlAction; } /** Toolbar action progress bar showing the average job progress percentage of all jobs.*/ diff --git a/krusader/JobMan/jobman.cpp b/krusader/JobMan/jobman.cpp --- a/krusader/JobMan/jobman.cpp +++ b/krusader/JobMan/jobman.cpp @@ -49,7 +49,7 @@ : QWidgetAction(parent), m_krJob(krJob) { QWidget *container = new QWidget(); - QGridLayout *layout = new QGridLayout(container); + auto *layout = new QGridLayout(container); m_description = new QLabel(krJob->description()); m_progressBar = new QProgressBar(); layout->addWidget(m_description, 0, 0, 1, 3); @@ -179,15 +179,15 @@ const QString JobMan::sDefaultToolTip = i18n("No jobs"); -JobMan::JobMan(QObject *parent) : QObject(parent), m_messageBox(0) +JobMan::JobMan(QObject *parent) : QObject(parent), m_messageBox(nullptr) { // job control action m_controlAction = new KToolBarPopupAction(Icon("media-playback-pause"), i18n("Play/Pause &Job"), this); m_controlAction->setEnabled(false); connect(m_controlAction, &QAction::triggered, this, &JobMan::slotControlActionTriggered); - QMenu *menu = new QMenu(krMainWindow); + auto *menu = new QMenu(krMainWindow); menu->setMinimumWidth(300); // make scrollable if menu is too long menu->setStyleSheet("QMenu { menu-scrollable: 1; }"); @@ -200,7 +200,7 @@ // listen to clicks on progress bar m_progressBar->installEventFilter(this); - QWidgetAction *progressAction = new QWidgetAction(krMainWindow); + auto *progressAction = new QWidgetAction(krMainWindow); progressAction->setText(i18n("Job Progress Bar")); progressAction->setDefaultWidget(m_progressBar); m_progressAction = progressAction; @@ -254,7 +254,7 @@ int result = m_messageBox->exec(); // blocking m_messageBox->deleteLater(); - m_messageBox = 0; + m_messageBox = nullptr; // accepted -> cancel all jobs if (result == QMessageBox::Abort) { @@ -398,7 +398,7 @@ void JobMan::managePrivate(KrJob *job, KJob *kJob) { - JobMenuAction *menuAction = new JobMenuAction(job, m_controlAction, kJob); + auto *menuAction = new JobMenuAction(job, m_controlAction, kJob); connect(menuAction, &QObject::destroyed, this, &JobMan::slotUpdateControlAction); m_controlAction->menu()->addAction(menuAction); cleanupMenu(); @@ -415,7 +415,7 @@ for (QAction *action : actions) { if (m_controlAction->menu()->actions().count() <= MAX_OLD_MENU_ACTIONS) break; - JobMenuAction *jobAction = static_cast(action); + auto *jobAction = dynamic_cast(action); if (jobAction->isDone()) { m_controlAction->menu()->removeAction(action); action->deleteLater(); diff --git a/krusader/KViewer/diskusageviewer.h b/krusader/KViewer/diskusageviewer.h --- a/krusader/KViewer/diskusageviewer.h +++ b/krusader/KViewer/diskusageviewer.h @@ -35,8 +35,8 @@ Q_OBJECT public: - explicit DiskUsageViewer(QWidget *parent = 0); - ~DiskUsageViewer(); + explicit DiskUsageViewer(QWidget *parent = nullptr); + ~DiskUsageViewer() override; void openUrl(QUrl url); void closeUrl(); diff --git a/krusader/KViewer/diskusageviewer.cpp b/krusader/KViewer/diskusageviewer.cpp --- a/krusader/KViewer/diskusageviewer.cpp +++ b/krusader/KViewer/diskusageviewer.cpp @@ -25,14 +25,15 @@ #include #include +#include #include "../FileSystem/filesystem.h" #include "../Panel/krpanel.h" #include "../Panel/panelfunc.h" #include "../krglobal.h" DiskUsageViewer::DiskUsageViewer(QWidget *parent) - : QWidget(parent), diskUsage(0), statusLabel(0) + : QWidget(parent), diskUsage(nullptr), statusLabel(nullptr) { layout = new QGridLayout(this); layout->setContentsMargins(0, 0, 0, 0); @@ -49,7 +50,7 @@ void DiskUsageViewer::openUrl(QUrl url) { - if (diskUsage == 0) { + if (diskUsage == nullptr) { diskUsage = new DiskUsage("DiskUsageViewer", this); connect(diskUsage, &DiskUsage::enteringDirectory, this, [=]() { slotUpdateStatus(); }); @@ -99,7 +100,7 @@ void DiskUsageViewer::setStatusLabel(QLabel *statLabel, QString pref) { statusLabel = statLabel; - prefix = pref; + prefix = std::move(pref); } void DiskUsageViewer::slotUpdateStatus(QString status) diff --git a/krusader/KViewer/krviewer.h b/krusader/KViewer/krviewer.h --- a/krusader/KViewer/krviewer.h +++ b/krusader/KViewer/krviewer.h @@ -54,7 +54,7 @@ static void view(QUrl url, QWidget * parent = krMainWindow); static void view(QUrl url, Mode mode, bool new_window, QWidget * parent = krMainWindow); static void edit(QUrl url, QWidget * parent); - static void edit(QUrl url, Mode mode = Text, int new_window = -1, QWidget * parent = krMainWindow); + static void edit(const QUrl& url, Mode mode = Text, int new_window = -1, QWidget * parent = krMainWindow); static void configureDeps(); virtual bool eventFilter(QObject * watched, QEvent * e) Q_DECL_OVERRIDE; diff --git a/krusader/KViewer/krviewer.cpp b/krusader/KViewer/krviewer.cpp --- a/krusader/KViewer/krviewer.cpp +++ b/krusader/KViewer/krviewer.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include "../defaults.h" #include "../icon.h" @@ -62,9 +63,9 @@ QList KrViewer::viewers; -KrViewer::KrViewer(QWidget *parent) : - KParts::MainWindow(parent, (Qt::WindowFlags)KDE_DEFAULT_WINDOWFLAGS), manager(this, this), tabBar(this), - reservedKeys(), reservedKeyActions(), sizeX(-1), sizeY(-1) +KrViewer::KrViewer(QWidget *parent) + : KParts::MainWindow(parent, (Qt::WindowFlags)KDE_DEFAULT_WINDOWFLAGS), manager(this, this), + tabBar(this), sizeX(-1), sizeY(-1) { //setWFlags(Qt::WType_TopLevel | WDestructiveClose); setXMLFile("krviewer.rc"); // kpart-related xml file @@ -78,8 +79,8 @@ tabBar.setMovable(true); setCentralWidget(&tabBar); - printAction = KStandardAction::print(this, SLOT(print()), 0); - copyAction = KStandardAction::copy(this, SLOT(copy()), 0); + printAction = KStandardAction::print(this, SLOT(print()), nullptr); + copyAction = KStandardAction::copy(this, SLOT(copy()), nullptr); viewerMenu = new QMenu(this); QAction *tempAction; @@ -241,12 +242,12 @@ // Should look into if there is any way to fix it. Currently if a KPart has same shortcut as KrViewer then // it causes a conflict, messagebox shown to user and no action triggered. if (e->type() == QEvent::ShortcutOverride) { - QKeyEvent* ke = (QKeyEvent*) e; + auto* ke = (QKeyEvent*) e; if (reservedKeys.contains(ke->key())) { ke->accept(); QAction *act = reservedKeyActions[ reservedKeys.indexOf(ke->key())]; - if (act != 0) { + if (act != nullptr) { // don't activate the close functions immediately! // it can cause crash if (act == tabCloseAction || act == quitAction) { @@ -258,7 +259,7 @@ return true; } } else if (e->type() == QEvent::KeyPress) { - QKeyEvent* ke = (QKeyEvent*) e; + auto* ke = (QKeyEvent*) e; if (reservedKeys.contains(ke->key())) { ke->accept(); return true; @@ -282,7 +283,7 @@ } return viewers.first(); } else { - KrViewer *newViewer = new KrViewer(); + auto *newViewer = new KrViewer(); viewers.prepend(newViewer); return newViewer; } @@ -293,22 +294,22 @@ KConfigGroup group(krConfig, "General"); bool defaultWindow = group.readEntry("View In Separate Window", _ViewInSeparateWindow); - view(url, Default, defaultWindow, parent); + view(std::move(url), Default, defaultWindow, parent); } void KrViewer::view(QUrl url, Mode mode, bool new_window, QWidget * parent) { KrViewer* viewer = getViewer(new_window); - viewer->viewInternal(url, mode, parent); + viewer->viewInternal(std::move(url), mode, parent); viewer->show(); } void KrViewer::edit(QUrl url, QWidget * parent) { - edit(url, Text, -1, parent); + edit(std::move(url), Text, -1, parent); } -void KrViewer::edit(QUrl url, Mode mode, int new_window, QWidget * parent) +void KrViewer::edit(const QUrl& url, Mode mode, int new_window, QWidget * parent) { KConfigGroup group(krConfig, "General"); QString editor = group.readEntry("Editor", _Editor); @@ -386,13 +387,13 @@ { QWidget *w = tabBar.widget(index); if(!w) return; - KParts::ReadOnlyPart *part = static_cast(w)->part(); + KParts::ReadOnlyPart *part = dynamic_cast(w)->part(); if (part && isPartAdded(part)) { manager.setActivePart(part); if (part->widget()) part->widget()->setFocus(); } else - manager.setActivePart(0); + manager.setActivePart(nullptr); // set this viewer to be the main viewer @@ -404,7 +405,7 @@ // important to save as returnFocusTo will be cleared at removePart QWidget *returnFocusToThisWidget = returnFocusTo; - PanelViewerBase *pvb = static_cast(tabBar.widget(index)); + auto *pvb = dynamic_cast(tabBar.widget(index)); if (!pvb) return; @@ -414,14 +415,14 @@ if (pvb->part() && isPartAdded(pvb->part())) removePart(pvb->part()); - disconnect(pvb, 0, this, 0); + disconnect(pvb, nullptr, this, nullptr); pvb->closeUrl(); tabBar.removeTab(index); delete pvb; - pvb = 0; + pvb = nullptr; if (tabBar.count() <= 0) { if (returnFocusToThisWidget) { @@ -453,7 +454,7 @@ group.writeEntry("Window Maximized", isMaximized()); for (int i = 0; i != tabBar.count(); i++) { - PanelViewerBase* pvb = static_cast(tabBar.widget(i)); + auto* pvb = dynamic_cast(tabBar.widget(i)); if (!pvb) continue; @@ -467,44 +468,44 @@ void KrViewer::viewGeneric() { - PanelViewerBase* pvb = static_cast(tabBar.currentWidget()); + auto* pvb = dynamic_cast(tabBar.currentWidget()); if (pvb) viewInternal(pvb->url(), Generic); } void KrViewer::viewText() { - PanelViewerBase* pvb = static_cast(tabBar.currentWidget()); + auto* pvb = dynamic_cast(tabBar.currentWidget()); if (pvb) viewInternal(pvb->url(), Text); } void KrViewer::viewLister() { - PanelViewerBase* pvb = static_cast(tabBar.currentWidget()); + auto* pvb = dynamic_cast(tabBar.currentWidget()); if (pvb) viewInternal(pvb->url(), Lister); } void KrViewer::viewHex() { - PanelViewerBase* pvb = static_cast(tabBar.currentWidget()); + auto* pvb = dynamic_cast(tabBar.currentWidget()); if (pvb) viewInternal(pvb->url(), Hex); } void KrViewer::editText() { - PanelViewerBase* pvb = static_cast(tabBar.currentWidget()); + auto* pvb = dynamic_cast(tabBar.currentWidget()); if (pvb) editInternal(pvb->url(), Text); } void KrViewer::checkModified() { QTimer::singleShot(CHECK_MODFIED_INTERVAL, this, &KrViewer::checkModified); - PanelViewerBase* pvb = static_cast(tabBar.currentWidget()); + auto* pvb = dynamic_cast(tabBar.currentWidget()); if (pvb) refreshTab(pvb); } @@ -532,7 +533,7 @@ void KrViewer::detachTab() { - PanelViewerBase* pvb = static_cast(tabBar.currentWidget()); + auto* pvb = dynamic_cast(tabBar.currentWidget()); if (!pvb) return; KrViewer* viewer = getViewer(true); @@ -545,7 +546,7 @@ removePart(part); } - disconnect(pvb, 0, this, 0); + disconnect(pvb, nullptr, this, nullptr); tabBar.removeTab(tabBar.indexOf(pvb)); @@ -576,7 +577,7 @@ void KrViewer::print() { - PanelViewerBase* pvb = static_cast(tabBar.currentWidget()); + auto* pvb = dynamic_cast(tabBar.currentWidget()); if (!pvb || !pvb->part() || !isPartAdded(pvb->part())) return; @@ -587,7 +588,7 @@ void KrViewer::copy() { - PanelViewerBase* pvb = static_cast(tabBar.currentWidget()); + auto* pvb = dynamic_cast(tabBar.currentWidget()); if (!pvb || !pvb->part() || !isPartAdded(pvb->part())) return; @@ -683,7 +684,7 @@ Q_ASSERT(isPartAdded(part)); if (isPartAdded(part)) { - disconnect(part, 0, this, 0); + disconnect(part, nullptr, this, nullptr); part->removeEventFilter(this); manager.removePart(part); } else @@ -697,7 +698,7 @@ PanelViewerBase* viewWidget = new PanelViewer(&tabBar, mode); addTab(viewWidget); - viewWidget->openUrl(url); + viewWidget->openUrl(std::move(url)); } void KrViewer::editInternal(QUrl url, Mode mode, QWidget * parent) @@ -707,5 +708,5 @@ PanelViewerBase* editWidget = new PanelEditor(&tabBar, mode); addTab(editWidget); - editWidget->openUrl(url); + editWidget->openUrl(std::move(url)); } diff --git a/krusader/KViewer/lister.h b/krusader/KViewer/lister.h --- a/krusader/KViewer/lister.h +++ b/krusader/KViewer/lister.h @@ -91,14 +91,14 @@ void sizeChanged(); protected: - virtual void resizeEvent(QResizeEvent * event) Q_DECL_OVERRIDE; - virtual void keyPressEvent(QKeyEvent * e) Q_DECL_OVERRIDE; - virtual void mousePressEvent(QMouseEvent * e) Q_DECL_OVERRIDE; - virtual void mouseDoubleClickEvent(QMouseEvent * e) Q_DECL_OVERRIDE; - virtual void mouseMoveEvent(QMouseEvent * e) Q_DECL_OVERRIDE; - virtual void wheelEvent(QWheelEvent * event) Q_DECL_OVERRIDE; - - QStringList readLines(const qint64 filePos, qint64 &endPos, const int lines, QList * locs = 0); + void resizeEvent(QResizeEvent * event) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent * e) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent * e) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent * e) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent * e) Q_DECL_OVERRIDE; + void wheelEvent(QWheelEvent * event) Q_DECL_OVERRIDE; + + QStringList readLines(const qint64 filePos, qint64 &endPos, const int lines, QList * locs = nullptr); QString readSection(qint64 p1, qint64 p2); void setUpScrollBar(); void setCursorPositionOnScreen(const int x, const int y, const int anchorX = -1, const int anchorY = -1); @@ -174,7 +174,7 @@ ListerPane(Lister *lister, QWidget *parent); protected: - virtual bool event(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; protected: bool handleCloseEvent(QEvent *e); @@ -207,7 +207,7 @@ QString characterSet() { return _characterSet; } QTextCodec *codec() { return _codec; } - void setCharacterSet(const QString set); + void setCharacterSet(const QString& set); void setHexMode(const bool); QStringList readHexLines(qint64 &filePos, const qint64 endPos, const int columns, const int lines); @@ -242,14 +242,14 @@ void slotSendFinished(KJob *); protected: - virtual bool openUrl(const QUrl &url) Q_DECL_OVERRIDE; - virtual bool closeUrl() Q_DECL_OVERRIDE { + bool openUrl(const QUrl &url) Q_DECL_OVERRIDE; + bool closeUrl() Q_DECL_OVERRIDE { return true; } - virtual bool openFile() Q_DECL_OVERRIDE { + bool openFile() Q_DECL_OVERRIDE { return true; } - virtual void guiActivateEvent(KParts::GUIActivateEvent * event) Q_DECL_OVERRIDE; + void guiActivateEvent(KParts::GUIActivateEvent * event) Q_DECL_OVERRIDE; void setColor(const bool match, const bool restore); void hideProgressBar(); void updateProgressBar(); @@ -307,7 +307,7 @@ QString _characterSet; QTextCodec *_codec = QTextCodec::codecForLocale(); - QTemporaryFile *_tempFile = 0; + QTemporaryFile *_tempFile = nullptr; bool _downloading = false; bool _restartFromBeginning = false; diff --git a/krusader/KViewer/lister.cpp b/krusader/KViewer/lister.cpp --- a/krusader/KViewer/lister.cpp +++ b/krusader/KViewer/lister.cpp @@ -1139,7 +1139,7 @@ bool ListerPane::handleCloseEvent(QEvent *e) { if (e->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast(e); + auto *ke = dynamic_cast(e); if (ke->key() == Qt::Key_Escape) { if (_lister->isSearchEnabled()) { _lister->searchDelete(); @@ -1183,15 +1183,15 @@ } protected: - virtual QString currentCharacterSet() Q_DECL_OVERRIDE { + QString currentCharacterSet() Q_DECL_OVERRIDE { return _lister->characterSet(); } - virtual void chooseDefault() Q_DECL_OVERRIDE { + void chooseDefault() Q_DECL_OVERRIDE { _lister->setCharacterSet(QString()); } - virtual void chooseEncoding(QString encodingName) Q_DECL_OVERRIDE { + void chooseEncoding(QString encodingName) Q_DECL_OVERRIDE { QString charset = KCharsets::charsets()->encodingForName(encodingName); _lister->setCharacterSet(charset); } @@ -1245,7 +1245,7 @@ QWidget * widget = new ListerPane(this, parent); widget->setFocusPolicy(Qt::StrongFocus); - QGridLayout *grid = new QGridLayout(widget); + auto *grid = new QGridLayout(widget); _textArea = new ListerTextArea(this, widget); _textArea->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); _textArea->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); @@ -1258,7 +1258,7 @@ _scrollBar->hide(); QWidget * statusWidget = new QWidget(widget); - QHBoxLayout *hbox = new QHBoxLayout(statusWidget); + auto *hbox = new QHBoxLayout(statusWidget); _listerLabel = new QLabel(i18n("Lister:"), statusWidget); hbox->addWidget(_listerLabel); @@ -1296,7 +1296,7 @@ hbox->addWidget(_searchPrevButton); _searchOptions = new QPushButton(i18n("Options"), statusWidget); _searchOptions->setToolTip(i18n("Modify search behavior")); - QMenu * menu = new QMenu(); + auto * menu = new QMenu(); _fromCursorAction = menu->addAction(i18n("From cursor")); _fromCursorAction->setCheckable(true); _fromCursorAction->setChecked(true); @@ -1359,7 +1359,7 @@ connect(downloadJob, &KIO::TransferJob::result, this, [=](KJob *job) { _tempFile->flush(); if (job->error()) { /* any error occurred? */ - KIO::TransferJob *kioJob = (KIO::TransferJob *)job; + auto *kioJob = (KIO::TransferJob *)job; KMessageBox::error(_textArea, i18n("Error reading file %1.", kioJob->url().toDisplayString(QUrl::PreferLocalFile))); } _downloading = false; @@ -1377,7 +1377,7 @@ _cache.clear(); _textArea->reset(); - emit started(0); + emit started(nullptr); emit setWindowCaption(listerUrl.toDisplayString()); emit completed(); return true; @@ -1846,7 +1846,7 @@ } const qint64 pcnt = (_fileSize == 0) ? 1000 : (2001 * _searchPosition) / _fileSize / 2; - const int pctInt = (int) pcnt; + const auto pctInt = (int) pcnt; if (_searchProgressBar->value() != pctInt) _searchProgressBar->setValue(pctInt); } @@ -1960,7 +1960,7 @@ _actionSaveSelected->setEnabled(true); } -void Lister::setCharacterSet(const QString set) +void Lister::setCharacterSet(const QString& set) { _characterSet = set; if (_characterSet.isEmpty()) { @@ -2208,7 +2208,7 @@ charData += QString(" "); } else { char c = chunk.at(cnt); - int charCode = (int)c; + auto charCode = (int)c; if (charCode < 0) charCode += 256; QString hex; diff --git a/krusader/KViewer/panelviewer.h b/krusader/KViewer/panelviewer.h --- a/krusader/KViewer/panelviewer.h +++ b/krusader/KViewer/panelviewer.h @@ -41,7 +41,7 @@ public: explicit PanelViewerBase(QWidget *parent, KrViewer::Mode mode = KrViewer::Default); - virtual ~PanelViewerBase(); + ~PanelViewerBase() override; inline QUrl url() const { return curl; } @@ -61,7 +61,7 @@ return true; } - void openUrl(QUrl url); + void openUrl(const QUrl& url); signals: void openUrlRequest(const QUrl &url); @@ -78,7 +78,7 @@ protected: virtual void openFile(KFileItem fi) = 0; virtual KParts::ReadOnlyPart* createPart(QString mimetype) = 0; - KParts::ReadOnlyPart* getPart(QString mimetype); + KParts::ReadOnlyPart* getPart(const QString& mimetype); QHash > *mimes; @@ -93,20 +93,20 @@ { Q_OBJECT public slots: - virtual bool closeUrl() Q_DECL_OVERRIDE; + bool closeUrl() Q_DECL_OVERRIDE; public: explicit PanelViewer(QWidget *parent, KrViewer::Mode mode = KrViewer::Default); - ~PanelViewer(); + ~PanelViewer() override; - virtual bool isEditor() Q_DECL_OVERRIDE { + bool isEditor() Q_DECL_OVERRIDE { return false; } protected: - virtual void openFile(KFileItem fi) Q_DECL_OVERRIDE; - virtual KParts::ReadOnlyPart* createPart(QString mimetype) Q_DECL_OVERRIDE; - KParts::ReadOnlyPart* getDefaultPart(KFileItem fi); + void openFile(KFileItem fi) Q_DECL_OVERRIDE; + KParts::ReadOnlyPart* createPart(QString mimetype) Q_DECL_OVERRIDE; + KParts::ReadOnlyPart* getDefaultPart(const KFileItem& fi); KParts::ReadOnlyPart* getHexPart(); KParts::ReadOnlyPart* getListerPart(bool hexMode = false); KParts::ReadOnlyPart* getTextPart(); @@ -116,24 +116,24 @@ { Q_OBJECT public: - virtual bool isModified() Q_DECL_OVERRIDE; - virtual bool isEditor() Q_DECL_OVERRIDE { + bool isModified() Q_DECL_OVERRIDE; + bool isEditor() Q_DECL_OVERRIDE { return true; } static void configureDeps(); public slots: - virtual bool closeUrl() Q_DECL_OVERRIDE; - virtual bool queryClose() Q_DECL_OVERRIDE; + bool closeUrl() Q_DECL_OVERRIDE; + bool queryClose() Q_DECL_OVERRIDE; public: explicit PanelEditor(QWidget *parent, KrViewer::Mode mode = KrViewer::Default); - ~PanelEditor(); + ~PanelEditor() override; protected: - virtual void openFile(KFileItem fi) Q_DECL_OVERRIDE; - virtual KParts::ReadOnlyPart* createPart(QString mimetype) Q_DECL_OVERRIDE; + void openFile(KFileItem fi) Q_DECL_OVERRIDE; + KParts::ReadOnlyPart* createPart(QString mimetype) Q_DECL_OVERRIDE; static QString missingKPartMsg(); }; diff --git a/krusader/KViewer/panelviewer.cpp b/krusader/KViewer/panelviewer.cpp --- a/krusader/KViewer/panelviewer.cpp +++ b/krusader/KViewer/panelviewer.cpp @@ -41,12 +41,12 @@ #define DICTSIZE 211 PanelViewerBase::PanelViewerBase(QWidget *parent, KrViewer::Mode mode) : - QStackedWidget(parent), mimes(0), cpart(0), mode(mode) + QStackedWidget(parent), mimes(nullptr), cpart(nullptr), mode(mode) { setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored)); mimes = new QHash >(); - cpart = 0; + cpart = nullptr; // NOTE: the fallback should be never visible. The viewer is not opened without a file and the // tab is closed if a file cannot be opened. fallback = new QLabel(i18n("No file selected or selected file cannot be displayed."), this); @@ -77,14 +77,14 @@ KMessageBox::error(this, job->errorString()); emit openUrlFinished(this, false); } else { - KIO::UDSEntry entry = static_cast(job)->statResult(); + KIO::UDSEntry entry = dynamic_cast(job)->statResult(); openFile(KFileItem(entry, curl)); } } -KParts::ReadOnlyPart* PanelViewerBase::getPart(QString mimetype) +KParts::ReadOnlyPart* PanelViewerBase::getPart(const QString& mimetype) { - KParts::ReadOnlyPart* part = 0; + KParts::ReadOnlyPart* part = nullptr; if (mimes->find(mimetype) == mimes->end()) { part = createPart(mimetype); @@ -96,7 +96,7 @@ return part; } -void PanelViewerBase::openUrl(QUrl url) +void PanelViewerBase::openUrl(const QUrl& url) { closeUrl(); curl = url; @@ -119,30 +119,29 @@ } PanelViewer::~PanelViewer() -{ -} += default; KParts::ReadOnlyPart* PanelViewer::getListerPart(bool hexMode) { - KParts::ReadOnlyPart* part = 0; + KParts::ReadOnlyPart* part = nullptr; if (mimes->find(QLatin1String("krusader_lister")) == mimes->end()) { part = new Lister(this); mimes->insert(QLatin1String("krusader_lister"), part); } else part = (*mimes)[ QLatin1String("krusader_lister")]; if (part) { - Lister *lister = qobject_cast((KParts::ReadOnlyPart *)part); + auto *lister = qobject_cast((KParts::ReadOnlyPart *)part); if (lister) lister->setHexMode(hexMode); } return part; } KParts::ReadOnlyPart* PanelViewer::getHexPart() { - KParts::ReadOnlyPart* part = 0; + KParts::ReadOnlyPart* part = nullptr; if (KConfigGroup(krConfig, "General").readEntry("UseOktetaViewer", _UseOktetaViewer)) { if (mimes->find("oktetapart") == mimes->end()) { @@ -174,7 +173,7 @@ return part ? part : getListerPart(); } -KParts::ReadOnlyPart* PanelViewer::getDefaultPart(KFileItem fi) +KParts::ReadOnlyPart* PanelViewer::getDefaultPart(const KFileItem& fi) { KConfigGroup group(krConfig, "General"); QString modeString = group.readEntry("Default Viewer Mode", QString("generic")); @@ -197,7 +196,7 @@ QString mimetype = fi.mimetype(); - KParts::ReadOnlyPart* part = 0; + KParts::ReadOnlyPart* part = nullptr; switch(mode) { case KrViewer::Generic: @@ -255,7 +254,7 @@ setCurrentWidget(cpart->widget()); if (cpart->inherits("KParts::ReadWritePart")) - static_cast(cpart.data())->setReadWrite(false); + dynamic_cast(cpart.data())->setReadWrite(false); KParts::OpenUrlArguments args; args.setReload(true); cpart->setArguments(args); @@ -274,15 +273,15 @@ { setCurrentWidget(fallback); if (cpart && cpart->closeUrl()) { - cpart = 0; + cpart = nullptr; return true; } return false; } KParts::ReadOnlyPart* PanelViewer::createPart(QString mimetype) { - KParts::ReadOnlyPart * part = 0; + KParts::ReadOnlyPart * part = nullptr; KService::Ptr ptr = KMimeTypeTrader::self()->preferredService(mimetype, "KParts/ReadOnlyPart"); if (ptr) { QVariantList args; @@ -312,16 +311,15 @@ } PanelEditor::~PanelEditor() -{ -} += default; void PanelEditor::configureDeps() { KService::Ptr ptr = KMimeTypeTrader::self()->preferredService("text/plain", "KParts/ReadWritePart"); if (!ptr) ptr = KMimeTypeTrader::self()->preferredService("all/allfiles", "KParts/ReadWritePart"); if (!ptr) - KMessageBox::sorry(0, missingKPartMsg(), i18n("Missing Plugin"), KMessageBox::AllowLink); + KMessageBox::sorry(nullptr, missingKPartMsg(), i18n("Missing Plugin"), KMessageBox::AllowLink); } @@ -385,23 +383,23 @@ bool PanelEditor::queryClose() { if (!cpart) return true; - return static_cast((KParts::ReadOnlyPart *)cpart)->queryClose(); + return dynamic_cast((KParts::ReadOnlyPart *)cpart)->queryClose(); } bool PanelEditor::closeUrl() { if (!cpart) return false; - static_cast((KParts::ReadOnlyPart *)cpart)->closeUrl(false); + dynamic_cast((KParts::ReadOnlyPart *)cpart)->closeUrl(false); setCurrentWidget(fallback); - cpart = 0; + cpart = nullptr; return true; } KParts::ReadOnlyPart* PanelEditor::createPart(QString mimetype) { - KParts::ReadWritePart * part = 0L; + KParts::ReadWritePart * part = nullptr; KService::Ptr ptr = KMimeTypeTrader::self()->preferredService(mimetype, "KParts/ReadWritePart"); if (ptr) { QVariantList args; @@ -425,7 +423,7 @@ bool PanelEditor::isModified() { if (cpart) - return static_cast((KParts::ReadOnlyPart *)cpart)->isModified(); + return dynamic_cast((KParts::ReadOnlyPart *)cpart)->isModified(); else return false; } diff --git a/krusader/Konfigurator/kgadvanced.h b/krusader/Konfigurator/kgadvanced.h --- a/krusader/Konfigurator/kgadvanced.h +++ b/krusader/Konfigurator/kgadvanced.h @@ -28,7 +28,7 @@ Q_OBJECT public: - explicit KgAdvanced(bool first, QWidget* parent = 0); + explicit KgAdvanced(bool first, QWidget* parent = nullptr); }; #endif /* __KGADVANCED_H__ */ diff --git a/krusader/Konfigurator/kgadvanced.cpp b/krusader/Konfigurator/kgadvanced.cpp --- a/krusader/Konfigurator/kgadvanced.cpp +++ b/krusader/Konfigurator/kgadvanced.cpp @@ -34,7 +34,7 @@ QWidget *innerWidget = new QFrame(this); setWidget(innerWidget); setWidgetResizable(true); - QGridLayout *kgAdvancedLayout = new QGridLayout(innerWidget); + auto *kgAdvancedLayout = new QGridLayout(innerWidget); kgAdvancedLayout->setSpacing(6); // -------------------------- GENERAL GROUPBOX ---------------------------------- diff --git a/krusader/Konfigurator/kgarchives.h b/krusader/Konfigurator/kgarchives.h --- a/krusader/Konfigurator/kgarchives.h +++ b/krusader/Konfigurator/kgarchives.h @@ -28,7 +28,7 @@ Q_OBJECT public: - explicit KgArchives(bool first, QWidget* parent = 0); + explicit KgArchives(bool first, QWidget* parent = nullptr); public slots: void slotAutoConfigure(); diff --git a/krusader/Konfigurator/kgarchives.cpp b/krusader/Konfigurator/kgarchives.cpp --- a/krusader/Konfigurator/kgarchives.cpp +++ b/krusader/Konfigurator/kgarchives.cpp @@ -42,7 +42,7 @@ QWidget *innerWidget = new QFrame(this); setWidget(innerWidget); setWidgetResizable(true); - QGridLayout *kgArchivesLayout = new QGridLayout(innerWidget); + auto *kgArchivesLayout = new QGridLayout(innerWidget); kgArchivesLayout->setSpacing(6); // ------------------------ KRARC GROUPBOX -------------------------------- diff --git a/krusader/Konfigurator/kgcolors.h b/krusader/Konfigurator/kgcolors.h --- a/krusader/Konfigurator/kgcolors.h +++ b/krusader/Konfigurator/kgcolors.h @@ -37,9 +37,9 @@ Q_OBJECT public: - explicit KgColors(bool first, QWidget* parent = 0); + explicit KgColors(bool first, QWidget* parent = nullptr); - virtual bool apply() Q_DECL_OVERRIDE; + bool apply() Q_DECL_OVERRIDE; public slots: void slotDisable(); @@ -61,10 +61,10 @@ private: class PreviewItem; - int addColorSelector(QString cfgName, QString name, QColor defaultValue, QString dfltName = QString(), - ADDITIONAL_COLOR *addColor = 0, int addColNum = 0); - KonfiguratorColorChooser *getColorSelector(QString name); - QLabel *getSelectorLabel(QString name); + int addColorSelector(const QString& cfgName, QString name, QColor defaultValue, const QString& dfltName = QString(), + ADDITIONAL_COLOR *addColor = nullptr, int addColNum = 0); + KonfiguratorColorChooser *getColorSelector(const QString& name); + QLabel *getSelectorLabel(const QString& name); void serialize(class QDataStream &); void deserialize(class QDataStream &); void serializeItem(class QDataStream &, const char * name); @@ -108,15 +108,16 @@ QString label; public: - PreviewItem(QTreeWidget * parent, QString name) : QTreeWidgetItem() { + PreviewItem(QTreeWidget * parent, const QString& name) + { setText(0, name); defaultBackground = QColor(255, 255, 255); defaultForeground = QColor(0, 0, 0); label = name; parent->insertTopLevelItem(0, this); } - void setColor(QColor foregnd, QColor backgnd) { + void setColor(const QColor& foregnd, const QColor& backgnd) { defaultForeground = foregnd; defaultBackground = backgnd; diff --git a/krusader/Konfigurator/kgcolors.cpp b/krusader/Konfigurator/kgcolors.cpp --- a/krusader/Konfigurator/kgcolors.cpp +++ b/krusader/Konfigurator/kgcolors.cpp @@ -37,6 +37,7 @@ #include #include +#include KgColors::KgColors(bool first, QWidget* parent) : KonfiguratorPage(first, parent), offset(0), @@ -49,7 +50,7 @@ QWidget *innerWidget = new QFrame(this); setWidget(innerWidget); setWidgetResizable(true); - QGridLayout *kgColorsLayout = new QGridLayout(innerWidget); + auto *kgColorsLayout = new QGridLayout(innerWidget); kgColorsLayout->setSpacing(6); // -------------------------- GENERAL GROUPBOX ---------------------------------- @@ -79,7 +80,7 @@ kgColorsLayout->addWidget(generalGrp, 0 , 0, 1, 3); QWidget *hboxWidget = new QWidget(innerWidget); - QHBoxLayout *hbox = new QHBoxLayout(hboxWidget); + auto *hbox = new QHBoxLayout(hboxWidget); // -------------------------- COLORS GROUPBOX ---------------------------------- @@ -279,13 +280,13 @@ slotDisable(); } -int KgColors::addColorSelector(QString cfgName, QString name, QColor defaultValue, QString dfltName, +int KgColors::addColorSelector(const QString& cfgName, QString name, QColor defaultValue, const QString& dfltName, ADDITIONAL_COLOR *addColor, int addColNum) { int index = itemList.count() - offset; - labelList.append(addLabel(colorsGrid, index, 0, name, colorsGrp)); - KonfiguratorColorChooser *chooser = createColorChooser("Colors", cfgName, defaultValue, colorsGrp, false, addColor, addColNum); + labelList.append(addLabel(colorsGrid, index, 0, std::move(name), colorsGrp)); + KonfiguratorColorChooser *chooser = createColorChooser("Colors", cfgName, std::move(defaultValue), colorsGrp, false, addColor, addColNum); chooser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); if (!dfltName.isEmpty()) @@ -303,28 +304,28 @@ return index; } -KonfiguratorColorChooser *KgColors::getColorSelector(QString name) +KonfiguratorColorChooser *KgColors::getColorSelector(const QString& name) { QList::iterator it; int position = 0; for (it = itemNames.begin(); it != itemNames.end(); it++, position++) if (*it == name) return itemList.at(position); - return 0; + return nullptr; } -QLabel *KgColors::getSelectorLabel(QString name) +QLabel *KgColors::getSelectorLabel(const QString& name) { QList::iterator it; int position = 0; for (it = itemNames.begin(); it != itemNames.end(); it++, position++) if (*it == name) return labelList.at(position); - return 0; + return nullptr; } void KgColors::slotDisable() @@ -469,15 +470,15 @@ // copy over local settings to color settings instance, which does not affect the persisted krConfig settings QList names = KrColorSettings::getColorNames(); - for (QList::Iterator it = names.begin(); it != names.end(); ++it) { - KonfiguratorColorChooser * chooser = getColorSelector(*it); + for (auto & name : names) { + KonfiguratorColorChooser * chooser = getColorSelector(name); if (!chooser) continue; - colorSettings.setColorTextValue(*it, chooser->getValue()); + colorSettings.setColorTextValue(name, chooser->getValue()); if (chooser->isValueRGB()) - colorSettings.setColorValue(*it, chooser->getColor()); + colorSettings.setColorValue(name, chooser->getColor()); else - colorSettings.setColorValue(*it, QColor()); + colorSettings.setColorValue(name, QColor()); } colorSettings.setBoolValue("KDE Default", generals->find("KDE Default")->isChecked()); @@ -566,7 +567,7 @@ QString basedir= QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("total_commander.keymap")); basedir = QFileInfo(basedir).absolutePath(); // let the user select a file to load - QString file = QFileDialog::getOpenFileName(0, i18n("Select a color-scheme file"), basedir, QStringLiteral("*.color")); + QString file = QFileDialog::getOpenFileName(nullptr, i18n("Select a color-scheme file"), basedir, QStringLiteral("*.color")); if (file.isEmpty()) { return; } @@ -583,7 +584,7 @@ void KgColors::slotExportColors() { - QString file = QFileDialog::getSaveFileName(0, i18n("Select a color scheme file"), QString(), QStringLiteral("*")); + QString file = QFileDialog::getSaveFileName(nullptr, i18n("Select a color scheme file"), QString(), QStringLiteral("*")); if (file.isEmpty()) { return; } @@ -682,7 +683,7 @@ } KonfiguratorColorChooser *selector = getColorSelector(name); - if (selector == 0) + if (selector == nullptr) break; selector->setValue(value); } diff --git a/krusader/Konfigurator/kgdependencies.h b/krusader/Konfigurator/kgdependencies.h --- a/krusader/Konfigurator/kgdependencies.h +++ b/krusader/Konfigurator/kgdependencies.h @@ -34,15 +34,15 @@ Q_OBJECT public: - explicit KgDependencies(bool first, QWidget* parent = 0); + explicit KgDependencies(bool first, QWidget* parent = nullptr); - virtual int activeSubPage() Q_DECL_OVERRIDE; + int activeSubPage() Q_DECL_OVERRIDE; private: - void addApplication(QString name, QGridLayout *grid, int row, QWidget *parent, int page, QString additionalList = QString()); + void addApplication(const QString& name, QGridLayout *grid, int row, QWidget *parent, int page, const QString& additionalList = QString()); public slots: - void slotApply(QObject *obj, QString configGroup, QString name); + void slotApply(QObject *obj, const QString& configGroup, const QString& name); private: QTabWidget *tabWidget; diff --git a/krusader/Konfigurator/kgdependencies.cpp b/krusader/Konfigurator/kgdependencies.cpp --- a/krusader/Konfigurator/kgdependencies.cpp +++ b/krusader/Konfigurator/kgdependencies.cpp @@ -40,20 +40,20 @@ KgDependencies::KgDependencies(bool first, QWidget* parent) : KonfiguratorPage(first, parent) { - QGridLayout *kgDependenciesLayout = new QGridLayout(this); + auto *kgDependenciesLayout = new QGridLayout(this); kgDependenciesLayout->setSpacing(6); // ---------------------------- GENERAL TAB ------------------------------------- tabWidget = new QTabWidget(this); QWidget *general_tab = new QWidget(tabWidget); - QScrollArea* general_scroll = new QScrollArea(tabWidget); + auto* general_scroll = new QScrollArea(tabWidget); general_scroll->setFrameStyle(QFrame::NoFrame); general_scroll->setWidget(general_tab); // this also sets scrollacrea as the new parent for widget general_scroll->setWidgetResizable(true); // let the widget use every space available tabWidget->addTab(general_scroll, i18n("General")); - QGridLayout *pathsGrid = new QGridLayout(general_tab); + auto *pathsGrid = new QGridLayout(general_tab); pathsGrid->setSpacing(6); pathsGrid->setContentsMargins(11, 11, 11, 11); pathsGrid->setAlignment(Qt::AlignTop); @@ -69,13 +69,13 @@ // ---------------------------- PACKERS TAB ------------------------------------- QWidget *packers_tab = new QWidget(tabWidget); - QScrollArea* packers_scroll = new QScrollArea(tabWidget); + auto* packers_scroll = new QScrollArea(tabWidget); packers_scroll->setFrameStyle(QFrame::NoFrame); packers_scroll->setWidget(packers_tab); // this also sets scrollacrea as the new parent for widget packers_scroll->setWidgetResizable(true); // let the widget use every space available tabWidget->addTab(packers_scroll, i18n("Packers")); - QGridLayout *archGrid1 = new QGridLayout(packers_tab); + auto *archGrid1 = new QGridLayout(packers_tab); archGrid1->setSpacing(6); archGrid1->setContentsMargins(11, 11, 11, 11); archGrid1->setAlignment(Qt::AlignTop); @@ -99,13 +99,13 @@ // ---------------------------- CHECKSUM TAB ------------------------------------- QWidget *checksum_tab = new QWidget(tabWidget); - QScrollArea* checksum_scroll = new QScrollArea(tabWidget); + auto* checksum_scroll = new QScrollArea(tabWidget); checksum_scroll->setFrameStyle(QFrame::NoFrame); checksum_scroll->setWidget(checksum_tab); // this also sets scrollacrea as the new parent for widget checksum_scroll->setWidgetResizable(true); // let the widget use every space available tabWidget->addTab(checksum_scroll, i18n("Checksum Utilities")); - QGridLayout *archGrid2 = new QGridLayout(checksum_tab); + auto *archGrid2 = new QGridLayout(checksum_tab); archGrid2->setSpacing(6); archGrid2->setContentsMargins(11, 11, 11, 11); archGrid2->setAlignment(Qt::AlignTop); @@ -120,8 +120,8 @@ kgDependenciesLayout->addWidget(tabWidget, 0, 0); } -void KgDependencies::addApplication(QString name, QGridLayout *grid, int row, QWidget *parent, - int page, QString additionalList) +void KgDependencies::addApplication(const QString& name, QGridLayout *grid, int row, QWidget *parent, + int page, const QString& additionalList) { // try to autodetect the full path name QString defaultValue = KrServices::fullPathName(name); @@ -143,9 +143,9 @@ grid->addWidget(fullPath, row, 1); } -void KgDependencies::slotApply(QObject *obj, QString configGroup, QString name) +void KgDependencies::slotApply(QObject *obj, const QString& configGroup, const QString& name) { - KonfiguratorURLRequester *urlRequester = (KonfiguratorURLRequester *) obj; + auto *urlRequester = (KonfiguratorURLRequester *) obj; KConfigGroup group(krConfig, configGroup); group.writeEntry(name, urlRequester->url().toDisplayString(QUrl::PreferLocalFile)); diff --git a/krusader/Konfigurator/kggeneral.h b/krusader/Konfigurator/kggeneral.h --- a/krusader/Konfigurator/kggeneral.h +++ b/krusader/Konfigurator/kggeneral.h @@ -28,10 +28,10 @@ Q_OBJECT public: - explicit KgGeneral(bool first, QWidget* parent = 0); + explicit KgGeneral(bool first, QWidget* parent = nullptr); public slots: - void applyTempDir(QObject *, QString, QString); + void applyTempDir(QObject *, const QString&, const QString&); void slotFindTools(); void slotAddExtension(); @@ -41,7 +41,7 @@ void createGeneralTab(); void createViewerTab(); void createExtensionsTab(); - QWidget* createTab(QString name); + QWidget* createTab(const QString& name); QTabWidget *tabWidget; KonfiguratorListBox *listBox; diff --git a/krusader/Konfigurator/kggeneral.cpp b/krusader/Konfigurator/kggeneral.cpp --- a/krusader/Konfigurator/kggeneral.cpp +++ b/krusader/Konfigurator/kggeneral.cpp @@ -59,9 +59,9 @@ createExtensionsTab(); } -QWidget* KgGeneral::createTab(QString name) +QWidget* KgGeneral::createTab(const QString& name) { - QScrollArea *scrollArea = new QScrollArea(tabWidget); + auto *scrollArea = new QScrollArea(tabWidget); tabWidget->addTab(scrollArea, name); scrollArea->setFrameStyle(QFrame::NoFrame); scrollArea->setWidgetResizable(true); @@ -75,7 +75,7 @@ void KgGeneral::createViewerTab() { QWidget *tab = createTab(i18n("Viewer/Editor")); - QGridLayout *tabLayout = new QGridLayout(tab); + auto *tabLayout = new QGridLayout(tab); tabLayout->setSpacing(6); tabLayout->setContentsMargins(11, 11, 11, 11); @@ -91,10 +91,10 @@ QGridLayout *viewerGrid = createGridLayout(viewerGrp); QWidget * hboxWidget2 = new QWidget(viewerGrp); - QHBoxLayout * hbox2 = new QHBoxLayout(hboxWidget2); + auto * hbox2 = new QHBoxLayout(hboxWidget2); QWidget * vboxWidget = new QWidget(hboxWidget2); - QVBoxLayout * vbox = new QVBoxLayout(vboxWidget); + auto * vbox = new QVBoxLayout(vboxWidget); vbox->addWidget(new QLabel(i18n("Default viewer mode:"), vboxWidget)); @@ -116,7 +116,7 @@ ); QWidget * hboxWidget4 = new QWidget(vboxWidget); - QHBoxLayout * hbox4 = new QHBoxLayout(hboxWidget4); + auto * hbox4 = new QHBoxLayout(hboxWidget4); QLabel *label5 = new QLabel(i18n("Use lister if the text file is bigger than:"), hboxWidget4); hbox4->addWidget(label5); @@ -154,34 +154,34 @@ // ------------------------- atomic extensions ---------------------------------- QWidget *tab = createTab(i18n("Atomic extensions")); - QGridLayout *tabLayout = new QGridLayout(tab); + auto *tabLayout = new QGridLayout(tab); tabLayout->setSpacing(6); tabLayout->setContentsMargins(11, 11, 11, 11); QWidget * vboxWidget2 = new QWidget(tab); tabLayout->addWidget(vboxWidget2); - QVBoxLayout * vbox2 = new QVBoxLayout(vboxWidget2); + auto * vbox2 = new QVBoxLayout(vboxWidget2); QWidget * hboxWidget3 = new QWidget(vboxWidget2); vbox2->addWidget(hboxWidget3); - QHBoxLayout * hbox3 = new QHBoxLayout(hboxWidget3); + auto * hbox3 = new QHBoxLayout(hboxWidget3); QLabel * atomLabel = new QLabel(i18n("Atomic extensions:"), hboxWidget3); hbox3->addWidget(atomLabel); int size = QFontMetrics(atomLabel->font()).height(); - QToolButton *addButton = new QToolButton(hboxWidget3); + auto *addButton = new QToolButton(hboxWidget3); hbox3->addWidget(addButton); QPixmap iconPixmap = Icon("list-add").pixmap(size); addButton->setFixedSize(iconPixmap.width() + 4, iconPixmap.height() + 4); addButton->setIcon(QIcon(iconPixmap)); connect(addButton, &QToolButton::clicked, this, &KgGeneral::slotAddExtension); - QToolButton *removeButton = new QToolButton(hboxWidget3); + auto *removeButton = new QToolButton(hboxWidget3); hbox3->addWidget(removeButton); iconPixmap = Icon("list-remove").pixmap(size); @@ -205,7 +205,7 @@ void KgGeneral::createGeneralTab() { QWidget *tab = createTab(i18n("General")); - QGridLayout *kgGeneralLayout = new QGridLayout(tab); + auto *kgGeneralLayout = new QGridLayout(tab); kgGeneralLayout->setSpacing(6); kgGeneralLayout->setContentsMargins(11, 11, 11, 11); @@ -226,7 +226,7 @@ // temp dir - QHBoxLayout *hbox = new QHBoxLayout(); + auto *hbox = new QHBoxLayout(); hbox->addWidget(new QLabel(i18n("Temp Folder:"), generalGrp)); KonfiguratorURLRequester *urlReq3 = createURLRequester("General", "Temp Directory", _TempDirectory, @@ -285,9 +285,9 @@ kgGeneralLayout->addWidget(terminalGrp, 2 , 0); } -void KgGeneral::applyTempDir(QObject *obj, QString configGroup, QString name) +void KgGeneral::applyTempDir(QObject *obj, const QString& configGroup, const QString& name) { - KonfiguratorURLRequester *urlReq = (KonfiguratorURLRequester *)obj; + auto *urlReq = (KonfiguratorURLRequester *)obj; QString value = urlReq->url().toDisplayString(QUrl::PreferLocalFile); KConfigGroup(krConfig, configGroup).writeEntry(name, value); diff --git a/krusader/Konfigurator/kgpanel.h b/krusader/Konfigurator/kgpanel.h --- a/krusader/Konfigurator/kgpanel.h +++ b/krusader/Konfigurator/kgpanel.h @@ -31,9 +31,9 @@ Q_OBJECT public: - explicit KgPanel(bool first, QWidget* parent = 0); + explicit KgPanel(bool first, QWidget* parent = nullptr); - virtual int activeSubPage() Q_DECL_OVERRIDE; + int activeSubPage() Q_DECL_OVERRIDE; protected: KonfiguratorCheckBoxGroup *panelToolbarButtonsCheckboxes; diff --git a/krusader/Konfigurator/kgpanel.cpp b/krusader/Konfigurator/kgpanel.cpp --- a/krusader/Konfigurator/kgpanel.cpp +++ b/krusader/Konfigurator/kgpanel.cpp @@ -71,14 +71,14 @@ // --------------------------------------------------------------------------------------- void KgPanel::setupGeneralTab() { - QScrollArea *scrollArea = new QScrollArea(tabWidget); + auto *scrollArea = new QScrollArea(tabWidget); QWidget *tab = new QWidget(scrollArea); scrollArea->setFrameStyle(QFrame::NoFrame); scrollArea->setWidget(tab); scrollArea->setWidgetResizable(true); tabWidget->addTab(scrollArea, i18n("General")); - QVBoxLayout *layout = new QVBoxLayout(tab); + auto *layout = new QVBoxLayout(tab); layout->setSpacing(6); layout->setContentsMargins(11, 11, 11, 11); @@ -129,7 +129,7 @@ gridLayout->addWidget(cbs, 0, 0, 1, 2); // ----------------- Tab Bar position ---------------------------------- - QHBoxLayout *hbox = new QHBoxLayout(); + auto *hbox = new QHBoxLayout(); hbox->addWidget(new QLabel(i18n("Tab Bar position:"), groupBox)); @@ -235,7 +235,7 @@ // -------------------------------------------------------------------------------------------- void KgPanel::setupLayoutTab() { - QScrollArea *scrollArea = new QScrollArea(tabWidget); + auto *scrollArea = new QScrollArea(tabWidget); QWidget *tab = new QWidget(scrollArea); scrollArea->setFrameStyle(QFrame::NoFrame); scrollArea->setWidget(tab); @@ -252,7 +252,7 @@ QLabel *l = new QLabel(i18n("Layout:"), tab); l->setAlignment(Qt::AlignRight | Qt::AlignVCenter); grid->addWidget(l, 0, 0); - KONFIGURATOR_NAME_VALUE_PAIR *layouts = new KONFIGURATOR_NAME_VALUE_PAIR[numLayouts]; + auto *layouts = new KONFIGURATOR_NAME_VALUE_PAIR[numLayouts]; for (int i = 0; i != numLayouts; i++) { layouts[ i ].text = KrLayoutFactory::layoutDescription(layoutNames[i]); layouts[ i ].value = layoutNames[i]; @@ -308,11 +308,11 @@ QGridLayout *grid = createGridLayout(parent); // -------------------- Filelist icon size ---------------------------------- - QHBoxLayout *hbox = new QHBoxLayout(); + auto *hbox = new QHBoxLayout(); hbox->addWidget(new QLabel(i18n("Default icon size:"), parent)); - KONFIGURATOR_NAME_VALUE_PAIR *iconSizes = new KONFIGURATOR_NAME_VALUE_PAIR[KrView::iconSizes.count()]; + auto *iconSizes = new KONFIGURATOR_NAME_VALUE_PAIR[KrView::iconSizes.count()]; for(int i = 0; i < KrView::iconSizes.count(); i++) iconSizes[i].text = iconSizes[i].value = QString::number(KrView::iconSizes[i]); KonfiguratorComboBox *cmb = createComboBox(instance->name(), "IconSize", _FilelistIconSize, iconSizes, KrView::iconSizes.count(), parent, true, true, PAGE_VIEW); @@ -342,14 +342,14 @@ // ---------------------------------------------------------------------------------- void KgPanel::setupPanelTab() { - QScrollArea *scrollArea = new QScrollArea(tabWidget); + auto *scrollArea = new QScrollArea(tabWidget); QWidget *tab_panel = new QWidget(scrollArea); scrollArea->setFrameStyle(QFrame::NoFrame); scrollArea->setWidget(tab_panel); scrollArea->setWidgetResizable(true); tabWidget->addTab(scrollArea, i18n("View")); - QGridLayout *panelLayout = new QGridLayout(tab_panel); + auto *panelLayout = new QGridLayout(tab_panel); panelLayout->setSpacing(6); panelLayout->setContentsMargins(11, 11, 11, 11); QGroupBox *panelGrp = createFrame(i18n("General"), tab_panel); @@ -361,18 +361,18 @@ // ---------------------------------------------------------------------------------- // -------------------- Panel Font ---------------------------------- - QHBoxLayout *hbox = new QHBoxLayout(); + auto *hbox = new QHBoxLayout(); - QHBoxLayout *fontLayout = new QHBoxLayout(); + auto *fontLayout = new QHBoxLayout(); fontLayout->addWidget(new QLabel(i18n("View font:"), panelGrp)); KonfiguratorFontChooser *chsr = createFontChooser("Look&Feel", "Filelist Font", _FilelistFont, panelGrp, true, PAGE_VIEW); fontLayout->addWidget(chsr); fontLayout->addStretch(1); hbox->addLayout(fontLayout, 1); // -------------------- Panel Tooltip ---------------------------------- - QHBoxLayout *tooltipLayout = new QHBoxLayout(); + auto *tooltipLayout = new QHBoxLayout(); QLabel *tooltipLabel = new QLabel(i18n("Tooltip delay (msec):")); tooltipLabel->setWhatsThis(i18n("The duration after a tooltip is shown for a file item, in " "milliseconds. Set a negative value to disable tooltips.")); @@ -430,7 +430,7 @@ { {"Look&Feel", "Case Sensative Sort", _CaseSensativeSort, i18n("Case sensitive sorting"), true, i18n("All files beginning with capital letters appear before files beginning with non-capital letters (UNIX default).") }, - {"Look&Feel", "Show Directories First", true, i18n("Show folders first"), true, 0 }, + {"Look&Feel", "Show Directories First", true, i18n("Show folders first"), true, nullptr }, {"Look&Feel", "Always sort dirs by name", false, i18n("Always sort dirs by name"), true, i18n("Folders are sorted by name, regardless of the sort column.") }, {"Look&Feel", "Locale Aware Sort", true, i18n("Locale aware sorting"), true, @@ -459,7 +459,7 @@ QList views = KrViewFactory::registeredViews(); const int viewsSize = views.size(); - KONFIGURATOR_NAME_VALUE_PAIR *panelTypes = new KONFIGURATOR_NAME_VALUE_PAIR[ viewsSize ]; + auto *panelTypes = new KONFIGURATOR_NAME_VALUE_PAIR[ viewsSize ]; QString defType = QString('0'); @@ -481,7 +481,7 @@ panelGrid->addLayout(hbox, 0, 0); // ----- Individual Settings Per View Type ------------------------ - QTabWidget *tabs_view = new QTabWidget(panelGrp); + auto *tabs_view = new QTabWidget(panelGrp); panelGrid->addWidget(tabs_view, 11, 0); for(int i = 0; i < views.count(); i++) { @@ -496,7 +496,7 @@ // ----------------------------------------------------------------------------------- void KgPanel::setupButtonsTab() { - QScrollArea *scrollArea = new QScrollArea(tabWidget); + auto *scrollArea = new QScrollArea(tabWidget); QWidget *tab = new QWidget(scrollArea); scrollArea->setFrameStyle(QFrame::NoFrame); scrollArea->setWidget(tab); @@ -520,7 +520,7 @@ }; buttonsCheckboxes = createCheckBoxGroup(1, 0, buttonsParams, 7/*count*/, tab, PAGE_PANELTOOLBAR); connect(buttonsCheckboxes->find("Panel Toolbar visible"), &KonfiguratorCheckBox::stateChanged, this, &KgPanel::slotEnablePanelToolbar); - tabLayout->addWidget(buttonsCheckboxes, 0, 0); + tabLayout->addWidget(buttonsCheckboxes, 0, nullptr); QGroupBox * panelToolbarGrp = createFrame(i18n("Visible Panel Toolbar buttons"), tab); QGridLayout * panelToolbarGrid = createGridLayout(panelToolbarGrp); @@ -536,7 +536,7 @@ sizeof(panelToolbarButtonsParams) / sizeof(*panelToolbarButtonsParams), panelToolbarGrp, PAGE_PANELTOOLBAR); panelToolbarGrid->addWidget(panelToolbarButtonsCheckboxes, 0, 0); - tabLayout->addWidget(panelToolbarGrp, 1, 0); + tabLayout->addWidget(panelToolbarGrp, 1, nullptr); // Enable panel toolbar checkboxes slotEnablePanelToolbar(); @@ -547,13 +547,13 @@ // --------------------------------------------------------------------------- void KgPanel::setupMouseModeTab() { - QScrollArea *scrollArea = new QScrollArea(tabWidget); + auto *scrollArea = new QScrollArea(tabWidget); QWidget *tab_mouse = new QWidget(scrollArea); scrollArea->setFrameStyle(QFrame::NoFrame); scrollArea->setWidget(tab_mouse); scrollArea->setWidgetResizable(true); tabWidget->addTab(scrollArea, i18n("Selection Mode")); - QGridLayout *mouseLayout = new QGridLayout(tab_mouse); + auto *mouseLayout = new QGridLayout(tab_mouse); mouseLayout->setSpacing(6); mouseLayout->setContentsMargins(11, 11, 11, 11); @@ -662,7 +662,7 @@ // --------------------------------------------------------------------------- void KgPanel::setupMediaMenuTab() { - QScrollArea *scrollArea = new QScrollArea(tabWidget); + auto *scrollArea = new QScrollArea(tabWidget); QWidget *tab = new QWidget(scrollArea); scrollArea->setFrameStyle(QFrame::NoFrame); scrollArea->setWidget(tab); @@ -676,16 +676,16 @@ KONFIGURATOR_CHECKBOX_PARAM mediaMenuParams[] = { // cfg_class cfg_name default text restart tooltip - {"MediaMenu", "ShowPath", true, i18n("Show Mount Path"), false, 0 }, - {"MediaMenu", "ShowFSType", true, i18n("Show File System Type"), false, 0 }, + {"MediaMenu", "ShowPath", true, i18n("Show Mount Path"), false, nullptr }, + {"MediaMenu", "ShowFSType", true, i18n("Show File System Type"), false, nullptr }, }; KonfiguratorCheckBoxGroup *mediaMenuCheckBoxes = createCheckBoxGroup(1, 0, mediaMenuParams, sizeof(mediaMenuParams) / sizeof(*mediaMenuParams), tab, PAGE_MEDIA_MENU); - tabLayout->addWidget(mediaMenuCheckBoxes, 0, 0); + tabLayout->addWidget(mediaMenuCheckBoxes, 0, nullptr); - QHBoxLayout *showSizeHBox = new QHBoxLayout(); + auto *showSizeHBox = new QHBoxLayout(); showSizeHBox->addWidget(new QLabel(i18n("Show Size:"), tab)); KONFIGURATOR_NAME_VALUE_PAIR showSizeValues[] = { { i18nc("setting 'show size'", "Always"), "Always" }, @@ -718,7 +718,7 @@ { KrSelectionMode *selectionMode = KrSelectionMode::getSelectionHandlerForMode(mouseRadio->selectedValue()); - if (selectionMode == NULL) //User mode + if (selectionMode == nullptr) //User mode return; selectionMode->init(); mouseCheckboxes->find("QT Selection")->setChecked(selectionMode->useQTSelection()); diff --git a/krusader/Konfigurator/kgprotocols.h b/krusader/Konfigurator/kgprotocols.h --- a/krusader/Konfigurator/kgprotocols.h +++ b/krusader/Konfigurator/kgprotocols.h @@ -33,12 +33,12 @@ Q_OBJECT public: - explicit KgProtocols(bool first, QWidget* parent = 0); + explicit KgProtocols(bool first, QWidget* parent = nullptr); - virtual void loadInitialValues() Q_DECL_OVERRIDE; - virtual void setDefaults() Q_DECL_OVERRIDE; - virtual bool apply() Q_DECL_OVERRIDE; - virtual bool isChanged() Q_DECL_OVERRIDE; + void loadInitialValues() Q_DECL_OVERRIDE; + void setDefaults() Q_DECL_OVERRIDE; + bool apply() Q_DECL_OVERRIDE; + bool isChanged() Q_DECL_OVERRIDE; static void init(); @@ -54,10 +54,10 @@ void loadMimes(); void addSpacer(QBoxLayout *parent); - void addProtocol(QString name, bool changeCurrent = false); - void removeProtocol(QString name); - void addMime(QString name, QString protocol); - void removeMime(QString name); + void addProtocol(const QString& name, bool changeCurrent = false); + void removeProtocol(const QString& name); + void addMime(QString name, const QString& protocol); + void removeMime(const QString& name); KrTreeWidget *linkList; diff --git a/krusader/Konfigurator/kgprotocols.cpp b/krusader/Konfigurator/kgprotocols.cpp --- a/krusader/Konfigurator/kgprotocols.cpp +++ b/krusader/Konfigurator/kgprotocols.cpp @@ -39,7 +39,7 @@ KgProtocols::KgProtocols(bool first, QWidget* parent) : KonfiguratorPage(first, parent) { - QGridLayout *KgProtocolsLayout = new QGridLayout(this); + auto *KgProtocolsLayout = new QGridLayout(this); KgProtocolsLayout->setSpacing(6); // -------------------------- LINK VIEW ---------------------------------- @@ -60,7 +60,7 @@ // -------------------------- BUTTONS ---------------------------------- QWidget *vbox1Widget = new QWidget(this); - QVBoxLayout *vbox1 = new QVBoxLayout(vbox1Widget); + auto *vbox1 = new QVBoxLayout(vbox1Widget); addSpacer(vbox1); btnAddProtocol = new QPushButton(vbox1Widget); @@ -77,7 +77,7 @@ KgProtocolsLayout->addWidget(vbox1Widget, 0 , 1); QWidget *vbox2Widget = new QWidget(this); - QVBoxLayout *vbox2 = new QVBoxLayout(vbox2Widget); + auto *vbox2 = new QVBoxLayout(vbox2Widget); addSpacer(vbox2); btnAddMime = new QPushButton(vbox2Widget); @@ -164,16 +164,16 @@ { btnAddProtocol->setEnabled(protocolList->selectedItems().count() != 0); QTreeWidgetItem *listViewItem = linkList->currentItem(); - bool isProtocolSelected = (listViewItem == 0 ? false : listViewItem->parent() == 0); + bool isProtocolSelected = (listViewItem == nullptr ? false : listViewItem->parent() == nullptr); btnRemoveProtocol->setEnabled(isProtocolSelected); - btnAddMime->setEnabled(listViewItem != 0 && mimeList->selectedItems().count() != 0); - btnRemoveMime->setEnabled(listViewItem == 0 ? false : listViewItem->parent() != 0); + btnAddMime->setEnabled(listViewItem != nullptr && mimeList->selectedItems().count() != 0); + btnRemoveMime->setEnabled(listViewItem == nullptr ? false : listViewItem->parent() != nullptr); - if (linkList->currentItem() == 0 && linkList->topLevelItemCount() != 0) + if (linkList->currentItem() == nullptr && linkList->topLevelItemCount() != 0) linkList->setCurrentItem(linkList->topLevelItem(0)); QList list = linkList->selectedItems(); - if (list.count() == 0 && linkList->currentItem() != 0) + if (list.count() == 0 && linkList->currentItem() != nullptr) linkList->currentItem()->setSelected(true); } @@ -188,12 +188,12 @@ } } -void KgProtocols::addProtocol(QString name, bool changeCurrent) +void KgProtocols::addProtocol(const QString& name, bool changeCurrent) { QList list = protocolList->findItems(name, Qt::MatchExactly); if (list.count() > 0) { delete list[ 0 ]; - QTreeWidgetItem *listViewItem = new QTreeWidgetItem(linkList); + auto *listViewItem = new QTreeWidgetItem(linkList); listViewItem->setText(0, name); QString iconName = KProtocolInfo::icon(name); if (iconName.isEmpty()) @@ -215,7 +215,7 @@ } } -void KgProtocols::removeProtocol(QString name) +void KgProtocols::removeProtocol(const QString& name) { QList itemList = linkList->findItems(name, Qt::MatchExactly, 0); @@ -234,7 +234,7 @@ void KgProtocols::slotAddMime() { QList list = mimeList->selectedItems(); - if (list.count() > 0 && linkList->currentItem() != 0) { + if (list.count() > 0 && linkList->currentItem() != nullptr) { QTreeWidgetItem *itemToAdd = linkList->currentItem(); if (itemToAdd->parent()) itemToAdd = itemToAdd->parent(); @@ -245,19 +245,19 @@ } } -void KgProtocols::addMime(QString name, QString protocol) +void KgProtocols::addMime(QString name, const QString& protocol) { QList list = mimeList->findItems(name, Qt::MatchExactly); QList itemList = linkList->findItems(protocol, Qt::MatchExactly | Qt::MatchRecursive, 0); - QTreeWidgetItem *currentListItem = 0; + QTreeWidgetItem *currentListItem = nullptr; if (itemList.count() != 0) currentListItem = itemList[ 0 ]; - if (list.count() > 0 && currentListItem && currentListItem->parent() == 0) { + if (list.count() > 0 && currentListItem && currentListItem->parent() == nullptr) { delete list[ 0 ]; - QTreeWidgetItem *listViewItem = new QTreeWidgetItem(currentListItem); + auto *listViewItem = new QTreeWidgetItem(currentListItem); listViewItem->setText(0, name); listViewItem->setIcon(0, Icon(name.replace(QLatin1Char('/'), QLatin1Char('-')), Icon("unknown"))); linkList->expandItem( currentListItem ); @@ -274,15 +274,15 @@ } } -void KgProtocols::removeMime(QString name) +void KgProtocols::removeMime(const QString& name) { QList itemList = linkList->findItems(name, Qt::MatchExactly | Qt::MatchRecursive, 0); - QTreeWidgetItem *currentMimeItem = 0; + QTreeWidgetItem *currentMimeItem = nullptr; if (itemList.count() != 0) currentMimeItem = itemList[ 0 ]; - if (currentMimeItem && currentMimeItem->parent() != 0) { + if (currentMimeItem && currentMimeItem->parent() != nullptr) { mimeList->addItem(currentMimeItem->text(0)); mimeList->sortItems(); currentMimeItem->parent()->removeChild(currentMimeItem); @@ -298,13 +298,13 @@ KConfigGroup group(krConfig, "Protocols"); QStringList protList = group.readEntry("Handled Protocols", QStringList()); - for (QStringList::Iterator it = protList.begin(); it != protList.end(); ++it) { - addProtocol(*it); + for (auto & it : protList) { + addProtocol(it); - QStringList mimes = group.readEntry(QString("Mimes For %1").arg(*it), QStringList()); + QStringList mimes = group.readEntry(QString("Mimes For %1").arg(it), QStringList()); - for (QStringList::Iterator it2 = mimes.begin(); it2 != mimes.end(); ++it2) - addMime(*it2, *it); + for (auto & mime : mimes) + addMime(mime, it); } if (linkList->topLevelItemCount() != 0) diff --git a/krusader/Konfigurator/kgstartup.h b/krusader/Konfigurator/kgstartup.h --- a/krusader/Konfigurator/kgstartup.h +++ b/krusader/Konfigurator/kgstartup.h @@ -28,7 +28,7 @@ Q_OBJECT public: - explicit KgStartup(bool first, QWidget* parent = 0); + explicit KgStartup(bool first, QWidget* parent = nullptr); public slots: void slotDisable(); diff --git a/krusader/Konfigurator/kgstartup.cpp b/krusader/Konfigurator/kgstartup.cpp --- a/krusader/Konfigurator/kgstartup.cpp +++ b/krusader/Konfigurator/kgstartup.cpp @@ -30,12 +30,12 @@ #include KgStartup::KgStartup(bool first, QWidget* parent) : - KonfiguratorPage(first, parent), profileCombo(0) + KonfiguratorPage(first, parent), profileCombo(nullptr) { QWidget *innerWidget = new QFrame(this); setWidget(innerWidget); setWidgetResizable(true); - QGridLayout *kgStartupLayout = new QGridLayout(innerWidget); + auto *kgStartupLayout = new QGridLayout(innerWidget); kgStartupLayout->setSpacing(6); // --------------------------- PANELS GROUPBOX ---------------------------------- @@ -52,7 +52,7 @@ profileList.push_front(i18n("")); const int profileListSize = profileList.size(); - KONFIGURATOR_NAME_VALUE_PAIR *comboItems = new KONFIGURATOR_NAME_VALUE_PAIR[ profileListSize ]; + auto *comboItems = new KONFIGURATOR_NAME_VALUE_PAIR[ profileListSize ]; for (int i = 0; i != profileListSize; i++) comboItems[ i ].text = comboItems[ i ].value = profileList [ i ]; comboItems[ 0 ].value = ""; @@ -74,7 +74,7 @@ KonfiguratorCheckBoxGroup* cbs = createCheckBoxGroup(2, 0, settings, 2 /* settings count */, panelsGrp); panelsGrid->addWidget(cbs, 2, 0, 1, 2); - QHBoxLayout *iconThemeLayout = new QHBoxLayout(); + auto *iconThemeLayout = new QHBoxLayout(); QLabel *iconThemeLabel = new QLabel(i18n("Fallback Icon Theme:")); iconThemeLabel->setWhatsThis(i18n("Whenever icon is not found in system icon theme, " "this theme will be used as a fallback. " diff --git a/krusader/Konfigurator/kguseractions.h b/krusader/Konfigurator/kguseractions.h --- a/krusader/Konfigurator/kguseractions.h +++ b/krusader/Konfigurator/kguseractions.h @@ -29,7 +29,7 @@ Q_OBJECT public: - explicit KgUserActions(bool first, QWidget* parent = 0); + explicit KgUserActions(bool first, QWidget* parent = nullptr); public slots: void startActionMan(); diff --git a/krusader/Konfigurator/kguseractions.cpp b/krusader/Konfigurator/kguseractions.cpp --- a/krusader/Konfigurator/kguseractions.cpp +++ b/krusader/Konfigurator/kguseractions.cpp @@ -35,7 +35,7 @@ QWidget *innerWidget = new QFrame(this); setWidget(innerWidget); setWidgetResizable(true); - QGridLayout *kgUserActionLayout = new QGridLayout(innerWidget); + auto *kgUserActionLayout = new QGridLayout(innerWidget); // ============= Info Group ============= QGroupBox *InfoGroup = createFrame(i18n("Information"), innerWidget); @@ -75,7 +75,7 @@ QGridLayout *outputGrid = createGridLayout(outputGroup); QWidget *hboxWidget = new QWidget(outputGroup); - QHBoxLayout *hbox = new QHBoxLayout(hboxWidget); + auto *hbox = new QHBoxLayout(hboxWidget); QLabel *lbel = new QLabel(i18n("Normal font:"), hboxWidget); hbox->addWidget(lbel); diff --git a/krusader/Konfigurator/konfigurator.cpp b/krusader/Konfigurator/konfigurator.cpp --- a/krusader/Konfigurator/konfigurator.cpp +++ b/krusader/Konfigurator/konfigurator.cpp @@ -50,7 +50,7 @@ #include "kguseractions.h" #include "kgprotocols.h" -Konfigurator::Konfigurator(bool f, int startPage) : KPageDialog((QWidget *)0), +Konfigurator::Konfigurator(bool f, int startPage) : KPageDialog((QWidget *)nullptr), firstTime(f), internalCall(false), sizeX(-1), sizeY(-1) { setWindowTitle(i18n("Konfigurator - Creating Your Own Krusader")); @@ -112,7 +112,7 @@ void Konfigurator::newPage(KonfiguratorPage *page, const QString &name, const QString &desc, const QIcon &icon) { - KPageWidgetItem *item = new KPageWidgetItem(page, name); + auto *item = new KPageWidgetItem(page, name); item->setIcon(icon); item->setHeader(desc); addPage(item); @@ -170,18 +170,18 @@ bool Konfigurator::slotPageSwitch(KPageWidgetItem *current, KPageWidgetItem *before) { - if (before == 0) + if (before == nullptr) return true; - KonfiguratorPage *currentPg = (KonfiguratorPage *)(before->widget()); + auto *currentPg = (KonfiguratorPage *)(before->widget()); if (internalCall) { internalCall = false; return true; } if (currentPg->isChanged()) { - int result = KMessageBox::questionYesNoCancel(0, i18n("The current page has been changed. Do you want to apply changes?")); + int result = KMessageBox::questionYesNoCancel(nullptr, i18n("The current page has been changed. Do you want to apply changes?")); switch (result) { case KMessageBox::No: diff --git a/krusader/Konfigurator/konfiguratoritems.h b/krusader/Konfigurator/konfiguratoritems.h --- a/krusader/Konfigurator/konfiguratoritems.h +++ b/krusader/Konfigurator/konfiguratoritems.h @@ -93,7 +93,7 @@ QString configGroup; QString configName; - virtual void connectNotify(const QMetaMethod &signal) Q_DECL_OVERRIDE; + void connectNotify(const QMetaMethod &signal) Q_DECL_OVERRIDE; }; @@ -105,9 +105,9 @@ Q_OBJECT public: - KonfiguratorCheckBox(QString configGroup, QString name, bool defaultValue, QString text, - QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE); - ~KonfiguratorCheckBox(); + KonfiguratorCheckBox(QString configGroup, QString name, bool defaultValue, const QString& text, + QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); + ~KonfiguratorCheckBox() override; inline KonfiguratorExtension *extension() { return ext; } @@ -117,12 +117,12 @@ public slots: virtual void loadInitialValue(); - void slotApply(QObject *, QString, QString); + void slotApply(QObject *, const QString&, const QString&); void slotSetDefaults(QObject *); protected: - virtual void checkStateSet() Q_DECL_OVERRIDE; - virtual void nextCheckState() Q_DECL_OVERRIDE; + void checkStateSet() Q_DECL_OVERRIDE; + void nextCheckState() Q_DECL_OVERRIDE; void updateDeps(); bool defaultValue; @@ -139,14 +139,14 @@ public: KonfiguratorSpinBox(QString configGroup, QString configName, int defaultValue, int min, int max, - QWidget *parent = 0, bool restartNeeded = false, int page = FIRST_PAGE); - ~KonfiguratorSpinBox(); + QWidget *parent = nullptr, bool restartNeeded = false, int page = FIRST_PAGE); + ~KonfiguratorSpinBox() override; inline KonfiguratorExtension *extension() { return ext; } public slots: virtual void loadInitialValue(); - void slotApply(QObject *, QString, QString); + void slotApply(QObject *, const QString&, const QString&); void slotSetDefaults(QObject *); protected: @@ -160,14 +160,14 @@ class KonfiguratorCheckBoxGroup : public QWidget { public: - explicit KonfiguratorCheckBoxGroup(QWidget *parent = 0) : QWidget(parent){} + explicit KonfiguratorCheckBoxGroup(QWidget *parent = nullptr) : QWidget(parent){} void add(KonfiguratorCheckBox *); int count() { return checkBoxList.count(); }; KonfiguratorCheckBox * find(int index); - KonfiguratorCheckBox * find(QString name); + KonfiguratorCheckBox * find(const QString& name); private: QList checkBoxList; @@ -182,23 +182,23 @@ public: KonfiguratorRadioButtons(QString configGroup, QString name, QString defaultValue, - QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE); - ~KonfiguratorRadioButtons(); + QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); + ~KonfiguratorRadioButtons() override; inline KonfiguratorExtension *extension() { return ext; } - void addRadioButton(QRadioButton *radioWidget, QString name, QString value); + void addRadioButton(QRadioButton *radioWidget, const QString& name, const QString& value); - void selectButton(QString value); + void selectButton(const QString& value); int count() { return radioButtons.count(); } QString selectedValue(); QRadioButton *find(int index); - QRadioButton *find(QString name); + QRadioButton *find(const QString& name); public slots: virtual void loadInitialValue(); - void slotApply(QObject *, QString, QString); + void slotApply(QObject *, const QString&, const QString&); void slotSetDefaults(QObject *); protected: @@ -220,14 +220,14 @@ public: KonfiguratorEditBox(QString configGroup, QString name, QString defaultValue, - QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE); - ~KonfiguratorEditBox(); + QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); + ~KonfiguratorEditBox() override; inline KonfiguratorExtension *extension() { return ext; } public slots: virtual void loadInitialValue(); - void slotApply(QObject *, QString, QString); + void slotApply(QObject *, const QString&, const QString&); void slotSetDefaults(QObject *); protected: @@ -245,15 +245,15 @@ public: KonfiguratorURLRequester(QString configGroup, QString name, QString defaultValue, - QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE, + QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE, bool expansion = true); - ~KonfiguratorURLRequester(); + ~KonfiguratorURLRequester() override; inline KonfiguratorExtension *extension() { return ext; } public slots: virtual void loadInitialValue(); - void slotApply(QObject *, QString, QString); + void slotApply(QObject *, const QString&, const QString&); void slotSetDefaults(QObject *); protected: @@ -270,15 +270,15 @@ Q_OBJECT public: - KonfiguratorFontChooser(QString configGroup, QString name, QFont defaultValue, - QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE); - ~KonfiguratorFontChooser(); + KonfiguratorFontChooser(QString configGroup, QString name, const QFont& defaultValue, + QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); + ~KonfiguratorFontChooser() override; inline KonfiguratorExtension *extension() { return ext; } public slots: virtual void loadInitialValue(); - void slotApply(QObject *, QString, QString); + void slotApply(QObject *, const QString&, const QString&); void slotSetDefaults(QObject *); void slotBrowseFont(); @@ -319,24 +319,24 @@ public: KonfiguratorComboBox(QString configGroup, QString name, QString defaultValue, - KONFIGURATOR_NAME_VALUE_PAIR *listIn, int listInLen, QWidget *parent = 0, + KONFIGURATOR_NAME_VALUE_PAIR *listIn, int listInLen, QWidget *parent = nullptr, bool restart = false, bool editable = false, int page = FIRST_PAGE); - ~KonfiguratorComboBox(); + ~KonfiguratorComboBox() override; inline KonfiguratorExtension *extension() { return ext; } public slots: virtual void loadInitialValue(); - void slotApply(QObject *, QString, QString); + void slotApply(QObject *, const QString&, const QString&); void slotSetDefaults(QObject *); protected: QString defaultValue; KONFIGURATOR_NAME_VALUE_PAIR *list; int listLen; KonfiguratorExtension *ext; - void selectEntry(QString entry); + void selectEntry(const QString& entry); }; @@ -354,35 +354,35 @@ Q_OBJECT public: - KonfiguratorColorChooser(QString configGroup, QString name, QColor defaultValue, - QWidget *parent = 0, bool restart = false, - ADDITIONAL_COLOR *addColPtr = 0, int addColNum = 0, int page = FIRST_PAGE); - ~KonfiguratorColorChooser(); + KonfiguratorColorChooser(QString configGroup, QString name, const QColor& defaultValue, + QWidget *parent = nullptr, bool restart = false, + ADDITIONAL_COLOR *addColPtr = nullptr, int addColNum = 0, int page = FIRST_PAGE); + ~KonfiguratorColorChooser() override; inline KonfiguratorExtension *extension() { return ext; } void setDefaultColor(QColor dflt); - void setDefaultText(QString text); + void setDefaultText(const QString& text); QColor getColor(); - void changeAdditionalColor(int num, QColor color); + void changeAdditionalColor(int num, const QColor& color); QString getValue(); bool isValueRGB(); - void setValue(QString value); + void setValue(const QString& value); public slots: virtual void loadInitialValue(); - void slotApply(QObject *, QString, QString); + void slotApply(QObject *, const QString&, const QString&); void slotSetDefaults(QObject *); void slotCurrentChanged(int number); signals: void colorChanged(); private: - void addColor(QString text, QColor color); - QPixmap createPixmap(QColor color); + void addColor(const QString& text, const QColor& color); + QPixmap createPixmap(const QColor& color); protected: QColor defaultValue; @@ -402,22 +402,22 @@ public: KonfiguratorListBox(QString configGroup, QString name, QStringList defaultValue, - QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE); - ~KonfiguratorListBox(); + QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); + ~KonfiguratorListBox() override; inline KonfiguratorExtension *extension() { return ext; } void addItem(const QString &); void removeItem(const QString &); public slots: virtual void loadInitialValue(); - void slotApply(QObject *, QString, QString); + void slotApply(QObject *, const QString&, const QString&); void slotSetDefaults(QObject *); protected: QStringList list(); - void setList(QStringList); + void setList(const QStringList&); QStringList defaultValue; KonfiguratorExtension *ext; diff --git a/krusader/Konfigurator/konfiguratoritems.cpp b/krusader/Konfigurator/konfiguratoritems.cpp --- a/krusader/Konfigurator/konfiguratoritems.cpp +++ b/krusader/Konfigurator/konfiguratoritems.cpp @@ -37,12 +37,13 @@ #include #include #include +#include KonfiguratorExtension::KonfiguratorExtension(QObject *obj, QString cfgGroup, QString cfgName, bool restartNeeded, int page) - : QObject(), objectPtr(obj), applyConnected(false), setDefaultsConnected(false), changed(false), - restartNeeded(restartNeeded), subpage(page), configGroup(cfgGroup), configName(cfgName) + : objectPtr(obj), applyConnected(false), setDefaultsConnected(false), changed(false), + restartNeeded(restartNeeded), subpage(page), configGroup(std::move(cfgGroup)), configName(std::move(cfgName)) { } @@ -91,11 +92,11 @@ // KonfiguratorCheckBox class /////////////////////////////// -KonfiguratorCheckBox::KonfiguratorCheckBox(QString configGroup, QString name, bool defaultValue, QString text, +KonfiguratorCheckBox::KonfiguratorCheckBox(QString configGroup, QString name, bool defaultValue, const QString& text, QWidget *parent, bool restart, int page) : QCheckBox(text, parent), defaultValue(defaultValue) { - ext = new KonfiguratorExtension(this, configGroup, name, restart, page); + ext = new KonfiguratorExtension(this, std::move(configGroup), std::move(name), restart, page); connect(ext, &KonfiguratorExtension::applyAuto, this, &KonfiguratorCheckBox::slotApply); connect(ext, &KonfiguratorExtension::setDefaultsAuto, this, &KonfiguratorCheckBox::slotSetDefaults); connect(ext, &KonfiguratorExtension::setInitialValue, this, &KonfiguratorCheckBox::loadInitialValue); @@ -140,7 +141,7 @@ dep->setEnabled(isChecked()); } -void KonfiguratorCheckBox::slotApply(QObject *, QString configGroup, QString name) +void KonfiguratorCheckBox::slotApply(QObject *, const QString& configGroup, const QString& name) { KConfigGroup(krConfig, configGroup).writeEntry(name, isChecked()); } @@ -160,7 +161,7 @@ int page) : QSpinBox(parent), defaultValue(defaultValue) { - ext = new KonfiguratorExtension(this, configGroup, configName, restartNeeded, page); + ext = new KonfiguratorExtension(this, std::move(configGroup), std::move(configName), restartNeeded, page); connect(ext, &KonfiguratorExtension::applyAuto, this, &KonfiguratorSpinBox::slotApply); connect(ext, &KonfiguratorExtension::setDefaultsAuto, this, &KonfiguratorSpinBox::slotSetDefaults); connect(ext, &KonfiguratorExtension::setInitialValue, this, &KonfiguratorSpinBox::loadInitialValue); @@ -185,7 +186,7 @@ ext->setChanged(false); } -void KonfiguratorSpinBox::slotApply(QObject *, QString configGroup, QString name) +void KonfiguratorSpinBox::slotApply(QObject *, const QString& configGroup, const QString& name) { KConfigGroup(krConfig, configGroup).writeEntry(name, value()); } @@ -207,11 +208,11 @@ KonfiguratorCheckBox * KonfiguratorCheckBoxGroup::find(int index) { if (index < 0 || index >= checkBoxList.count()) - return 0; + return nullptr; return checkBoxList.at(index); } -KonfiguratorCheckBox * KonfiguratorCheckBoxGroup::find(QString name) +KonfiguratorCheckBox * KonfiguratorCheckBoxGroup::find(const QString& name) { QListIterator it(checkBoxList); while (it.hasNext()) { @@ -221,18 +222,18 @@ return checkBox; } - return 0; + return nullptr; } // KonfiguratorRadioButtons class /////////////////////////////// KonfiguratorRadioButtons::KonfiguratorRadioButtons(QString configGroup, QString name, QString defaultValue, QWidget *parent, bool restart, int page) : - QWidget(parent), defaultValue(defaultValue) + QWidget(parent), defaultValue(std::move(defaultValue)) { - ext = new KonfiguratorExtension(this, configGroup, name, restart, page); + ext = new KonfiguratorExtension(this, std::move(configGroup), std::move(name), restart, page); connect(ext, &KonfiguratorExtension::applyAuto, this, &KonfiguratorRadioButtons::slotApply); connect(ext, &KonfiguratorExtension::setDefaultsAuto, this, &KonfiguratorRadioButtons::slotSetDefaults); connect(ext, &KonfiguratorExtension::setInitialValue, this, &KonfiguratorRadioButtons::loadInitialValue); @@ -243,7 +244,7 @@ delete ext; } -void KonfiguratorRadioButtons::addRadioButton(QRadioButton *radioWidget, QString name, QString value) +void KonfiguratorRadioButtons::addRadioButton(QRadioButton *radioWidget, const QString& name, const QString& value) { radioButtons.append(radioWidget); radioNames.push_back(name); @@ -255,21 +256,21 @@ QRadioButton * KonfiguratorRadioButtons::find(int index) { if (index < 0 || index >= radioButtons.count()) - return 0; + return nullptr; return radioButtons.at(index); } -QRadioButton * KonfiguratorRadioButtons::find(QString name) +QRadioButton * KonfiguratorRadioButtons::find(const QString& name) { int index = radioNames.indexOf(name); if (index == -1) - return 0; + return nullptr; return radioButtons.at(index); } -void KonfiguratorRadioButtons::selectButton(QString value) +void KonfiguratorRadioButtons::selectButton(const QString& value) { int cnt = 0; @@ -315,7 +316,7 @@ return QString(); } -void KonfiguratorRadioButtons::slotApply(QObject *, QString configGroup, QString name) +void KonfiguratorRadioButtons::slotApply(QObject *, const QString& configGroup, const QString& name) { QString value = selectedValue(); @@ -333,9 +334,9 @@ KonfiguratorEditBox::KonfiguratorEditBox(QString configGroup, QString name, QString defaultValue, QWidget *parent, bool restart, int page) : QLineEdit(parent), - defaultValue(defaultValue) + defaultValue(std::move(defaultValue)) { - ext = new KonfiguratorExtension(this, configGroup, name, restart, page); + ext = new KonfiguratorExtension(this, std::move(configGroup), std::move(name), restart, page); connect(ext, &KonfiguratorExtension::applyAuto, this, &KonfiguratorEditBox::slotApply); connect(ext, &KonfiguratorExtension::setDefaultsAuto, this, &KonfiguratorEditBox::slotSetDefaults); connect(ext, &KonfiguratorExtension::setInitialValue, this, &KonfiguratorEditBox::loadInitialValue); @@ -357,7 +358,7 @@ ext->setChanged(false); } -void KonfiguratorEditBox::slotApply(QObject *, QString configGroup, QString name) +void KonfiguratorEditBox::slotApply(QObject *, const QString& configGroup, const QString& name) { KConfigGroup(krConfig, configGroup).writeEntry(name, text()); } @@ -375,9 +376,9 @@ KonfiguratorURLRequester::KonfiguratorURLRequester(QString configGroup, QString name, QString defaultValue, QWidget *parent, bool restart, int page, bool expansion) - : KUrlRequester(parent), defaultValue(defaultValue), expansion(expansion) + : KUrlRequester(parent), defaultValue(std::move(defaultValue)), expansion(expansion) { - ext = new KonfiguratorExtension(this, configGroup, name, restart, page); + ext = new KonfiguratorExtension(this, std::move(configGroup), std::move(name), restart, page); connect(ext, &KonfiguratorExtension::applyAuto, this, &KonfiguratorURLRequester::slotApply); connect(ext, &KonfiguratorExtension::setDefaultsAuto, this, &KonfiguratorURLRequester::slotSetDefaults); connect(ext, &KonfiguratorExtension::setInitialValue, this, &KonfiguratorURLRequester::loadInitialValue); @@ -399,7 +400,7 @@ ext->setChanged(false); } -void KonfiguratorURLRequester::slotApply(QObject *, QString configGroup, QString name) +void KonfiguratorURLRequester::slotApply(QObject *, const QString& configGroup, const QString& name) { KConfigGroup(krConfig, configGroup) .writeEntry(name, expansion ? url().toDisplayString(QUrl::PreferLocalFile) : text()); @@ -414,13 +415,13 @@ // KonfiguratorFontChooser class /////////////////////////////// -KonfiguratorFontChooser::KonfiguratorFontChooser(QString configGroup, QString name, QFont defaultValue, +KonfiguratorFontChooser::KonfiguratorFontChooser(QString configGroup, QString name, const QFont& defaultValue, QWidget *parent, bool restart, int page) : QWidget(parent), defaultValue(defaultValue) { - QHBoxLayout *layout = new QHBoxLayout(this); + auto *layout = new QHBoxLayout(this); - ext = new KonfiguratorExtension(this, configGroup, name, restart, page); + ext = new KonfiguratorExtension(this, std::move(configGroup), std::move(name), restart, page); connect(ext, &KonfiguratorExtension::applyAuto, this, &KonfiguratorFontChooser::slotApply); connect(ext, &KonfiguratorExtension::setDefaultsAuto, this, &KonfiguratorFontChooser::slotSetDefaults); connect(ext, &KonfiguratorExtension::setInitialValue, this, &KonfiguratorFontChooser::loadInitialValue); @@ -458,7 +459,7 @@ pLabel->setText(font.family() + QString(", %1").arg(font.pointSize())); } -void KonfiguratorFontChooser::slotApply(QObject *, QString configGroup, QString name) +void KonfiguratorFontChooser::slotApply(QObject *, const QString& configGroup, const QString& name) { KConfigGroup(krConfig, configGroup).writeEntry(name, font); } @@ -485,16 +486,16 @@ KonfiguratorComboBox::KonfiguratorComboBox(QString configGroup, QString name, QString defaultValue, KONFIGURATOR_NAME_VALUE_PAIR *listIn, int listInLen, QWidget *parent, bool restart, bool editable, int page) : QComboBox(parent), - defaultValue(defaultValue), listLen(listInLen) + defaultValue(std::move(defaultValue)), listLen(listInLen) { list = new KONFIGURATOR_NAME_VALUE_PAIR[ listInLen ]; for (int i = 0; i != listLen; i++) { list[i] = listIn[i]; addItem(list[i].text); } - ext = new KonfiguratorExtension(this, configGroup, name, restart, page); + ext = new KonfiguratorExtension(this, std::move(configGroup), std::move(name), restart, page); connect(ext, &KonfiguratorExtension::applyAuto, this, &KonfiguratorComboBox::slotApply); connect(ext, &KonfiguratorExtension::setDefaultsAuto, this, &KonfiguratorComboBox::slotSetDefaults); connect(ext, &KonfiguratorExtension::setInitialValue, this, &KonfiguratorComboBox::loadInitialValue); @@ -521,7 +522,7 @@ ext->setChanged(false); } -void KonfiguratorComboBox::slotApply(QObject *, QString configGroup, QString name) +void KonfiguratorComboBox::slotApply(QObject *, const QString& configGroup, const QString& name) { QString text = isEditable() ? lineEdit()->text() : currentText(); QString value = text; @@ -535,7 +536,7 @@ KConfigGroup(krConfig, configGroup).writeEntry(name, value); } -void KonfiguratorComboBox::selectEntry(QString entry) +void KonfiguratorComboBox::selectEntry(const QString& entry) { for (int i = 0; i != listLen; i++) if (list[i].value == entry) { @@ -559,12 +560,12 @@ /////////////////////////////// KonfiguratorColorChooser::KonfiguratorColorChooser(QString configGroup, QString name, - QColor defaultValue, QWidget *parent, + const QColor& defaultValue, QWidget *parent, bool restart, ADDITIONAL_COLOR *addColPtr, int addColNum, int page) : QComboBox(parent), defaultValue(defaultValue), disableColorChooser(true) { - ext = new KonfiguratorExtension(this, configGroup, name, restart, page); + ext = new KonfiguratorExtension(this, std::move(configGroup), std::move(name), restart, page); connect(ext, &KonfiguratorExtension::applyAuto, this, &KonfiguratorColorChooser::slotApply); connect(ext, &KonfiguratorExtension::setDefaultsAuto, this, &KonfiguratorColorChooser::slotSetDefaults); @@ -606,7 +607,7 @@ delete ext; } -QPixmap KonfiguratorColorChooser::createPixmap(QColor color) +QPixmap KonfiguratorColorChooser::createPixmap(const QColor& color) { QPainter painter; QPen pen; @@ -627,7 +628,7 @@ return pixmap; } -void KonfiguratorColorChooser::addColor(QString text, QColor color) +void KonfiguratorColorChooser::addColor(const QString& text, const QColor& color) { addItem(createPixmap(color), text); palette.push_back(color); @@ -643,15 +644,15 @@ void KonfiguratorColorChooser::setDefaultColor(QColor dflt) { - defaultValue = dflt; + defaultValue = std::move(dflt); palette[1] = defaultValue; setItemIcon(1, createPixmap(defaultValue)); if (currentIndex() == 1) emit colorChanged(); } -void KonfiguratorColorChooser::changeAdditionalColor(int num, QColor color) +void KonfiguratorColorChooser::changeAdditionalColor(int num, const QColor& color) { if (num < additionalColors.size()) { palette[2+num] = color; @@ -663,18 +664,18 @@ } } -void KonfiguratorColorChooser::setDefaultText(QString text) +void KonfiguratorColorChooser::setDefaultText(const QString& text) { setItemIcon(1, createPixmap(defaultValue)); setItemText(1, text); } -void KonfiguratorColorChooser::slotApply(QObject *, QString configGroup, QString name) +void KonfiguratorColorChooser::slotApply(QObject *, const QString& configGroup, const QString& name) { KConfigGroup(krConfig, configGroup).writeEntry(name, getValue()); } -void KonfiguratorColorChooser::setValue(QString value) +void KonfiguratorColorChooser::setValue(const QString& value) { disableColorChooser = true; @@ -765,9 +766,9 @@ KonfiguratorListBox::KonfiguratorListBox(QString configGroup, QString name, QStringList defaultValue, QWidget *parent, bool restart, int page) : KrListWidget(parent), - defaultValue(defaultValue) + defaultValue(std::move(defaultValue)) { - ext = new KonfiguratorExtension(this, configGroup, name, restart, page); + ext = new KonfiguratorExtension(this, std::move(configGroup), std::move(name), restart, page); connect(ext, &KonfiguratorExtension::applyAuto, this, &KonfiguratorListBox::slotApply); connect(ext, &KonfiguratorExtension::setDefaultsAuto, this, &KonfiguratorListBox::slotSetDefaults); connect(ext, &KonfiguratorExtension::setInitialValue, this, &KonfiguratorListBox::loadInitialValue); @@ -787,7 +788,7 @@ ext->setChanged(false); } -void KonfiguratorListBox::slotApply(QObject *, QString configGroup, QString name) +void KonfiguratorListBox::slotApply(QObject *, const QString& configGroup, const QString& name) { KConfigGroup(krConfig, configGroup).writeEntry(name, list()); } @@ -800,7 +801,7 @@ } } -void KonfiguratorListBox::setList(QStringList list) +void KonfiguratorListBox::setList(const QStringList& list) { clear(); addItems(list); diff --git a/krusader/Konfigurator/konfiguratorpage.h b/krusader/Konfigurator/konfiguratorpage.h --- a/krusader/Konfigurator/konfiguratorpage.h +++ b/krusader/Konfigurator/konfiguratorpage.h @@ -123,8 +123,8 @@ * @return reference to the newly created checkbox */ KonfiguratorCheckBox *createCheckBox(QString configGroup, QString name, bool defaultValue, - QString text, QWidget *parent = 0, bool restart = false, - QString toolTip = QString(), int page = FIRST_PAGE); + QString text, QWidget *parent = nullptr, bool restart = false, + const QString& toolTip = QString(), int page = FIRST_PAGE); /** * Adds a new spinbox item to the page. @@ -146,7 +146,7 @@ * @return reference to the newly created spinbox */ KonfiguratorSpinBox *createSpinBox(QString configGroup, QString configName, int defaultValue, - int min, int max, QWidget *parent = 0, bool restart = false, + int min, int max, QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); /** @@ -167,7 +167,7 @@ * @return reference to the newly created editbox */ KonfiguratorEditBox *createEditBox(QString configGroup, QString name, QString defaultValue, - QWidget *parent = 0, bool restart = false, + QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); /** @@ -190,7 +190,7 @@ * @return reference to the newly created editbox */ KonfiguratorListBox *createListBox(QString configGroup, QString name, QStringList defaultValue, - QWidget *parent = 0, bool restart = false, + QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); /** @@ -234,7 +234,7 @@ * @return reference to the newly created font chooser */ KonfiguratorFontChooser *createFontChooser(QString configGroup, QString name, - QFont defaultValue, QWidget *parent = 0, + const QFont& defaultValue, QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); /** @@ -263,7 +263,7 @@ */ KonfiguratorComboBox *createComboBox(QString configGroup, QString name, QString defaultValue, KONFIGURATOR_NAME_VALUE_PAIR *params, int paramNum, - QWidget *parent = 0, bool restart = false, + QWidget *parent = nullptr, bool restart = false, bool editable = false, int page = FIRST_PAGE); /** @@ -278,7 +278,7 @@ * * @return reference to the newly created frame */ - QGroupBox *createFrame(QString text = QString(), QWidget *parent = 0); + QGroupBox *createFrame(const QString& text = QString(), QWidget *parent = nullptr); /** * Creates a new QGridLayout element and sets its margins. @@ -311,7 +311,7 @@ * * @return reference to the newly created label */ - QLabel *addLabel(QGridLayout *layout, int x, int y, QString label, QWidget *parent = 0); + QLabel *addLabel(QGridLayout *layout, int x, int y, const QString& label, QWidget *parent = nullptr); /** * Creates a spacer object (for justifying in QHBox). @@ -326,7 +326,7 @@ * * @return reference to the newly created spacer widget */ - QWidget *createSpacer(QWidget *parent = 0); + QWidget *createSpacer(QWidget *parent = nullptr); /** * Creates a separator line. @@ -340,7 +340,7 @@ * * @return reference to the newly created spacer widget */ - QFrame *createLine(QWidget *parent = 0, bool vertical = false); + QFrame *createLine(QWidget *parent = nullptr, bool vertical = false); /** * Creates a checkbox group. A checkbox group contains a lot of checkboxes. @@ -373,7 +373,7 @@ */ KonfiguratorCheckBoxGroup *createCheckBoxGroup(int sizex, int sizey, KONFIGURATOR_CHECKBOX_PARAM *params, - int paramNum, QWidget *parent = 0, + int paramNum, QWidget *parent = nullptr, int page = FIRST_PAGE); /** * Creates a radio button group. A radio button group contains a lot of radio buttons. @@ -412,7 +412,7 @@ KonfiguratorRadioButtons *createRadioButtonGroup(QString configGroup, QString name, QString defaultValue, int sizex, int sizey, KONFIGURATOR_NAME_VALUE_TIP *params, - int paramNum, QWidget *parent = 0, + int paramNum, QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); /** @@ -461,9 +461,9 @@ * @return reference to the newly created combobox */ KonfiguratorColorChooser *createColorChooser(QString configGroup, QString name, - QColor defaultValue, QWidget *parent = 0, + QColor defaultValue, QWidget *parent = nullptr, bool restart = false, - ADDITIONAL_COLOR *addColPtr = 0, int addColNum = 0, + ADDITIONAL_COLOR *addColPtr = nullptr, int addColNum = 0, int page = FIRST_PAGE); signals: /** diff --git a/krusader/Konfigurator/konfiguratorpage.cpp b/krusader/Konfigurator/konfiguratorpage.cpp --- a/krusader/Konfigurator/konfiguratorpage.cpp +++ b/krusader/Konfigurator/konfiguratorpage.cpp @@ -28,6 +28,7 @@ #include #include +#include #include "../krglobal.h" @@ -41,8 +42,8 @@ { bool restartNeeded = false; - for (QList::iterator item = itemList.begin(); item != itemList.end(); item ++) - restartNeeded = (*item)->apply() || restartNeeded; + for (auto & item : itemList) + restartNeeded = item->apply() || restartNeeded; krConfig->sync(); return restartNeeded; @@ -52,32 +53,32 @@ { int activePage = activeSubPage(); - for (QList::iterator item = itemList.begin(); item != itemList.end(); item ++) { - if ((*item)->subPage() == activePage) - (*item)->setDefaults(); + for (auto & item : itemList) { + if (item->subPage() == activePage) + item->setDefaults(); } } void KonfiguratorPage::loadInitialValues() { - for (QList::iterator item = itemList.begin(); item != itemList.end(); item ++) - (*item)->loadInitialValue(); + for (auto & item : itemList) + item->loadInitialValue(); } bool KonfiguratorPage::isChanged() { bool isChanged = false; - for (QList::iterator item = itemList.begin(); item != itemList.end(); item ++) - isChanged = isChanged || (*item)->isChanged(); + for (auto & item : itemList) + isChanged = isChanged || item->isChanged(); return isChanged; } KonfiguratorCheckBox* KonfiguratorPage::createCheckBox(QString configGroup, QString name, - bool defaultValue, QString text, QWidget *parent, bool restart, QString toolTip, int page) + bool defaultValue, QString text, QWidget *parent, bool restart, const QString& toolTip, int page) { - KonfiguratorCheckBox *checkBox = new KonfiguratorCheckBox(configGroup, name, defaultValue, text, + KonfiguratorCheckBox *checkBox = new KonfiguratorCheckBox(std::move(configGroup), std::move(name), defaultValue, std::move(text), parent, restart, page); if (!toolTip.isEmpty()) checkBox->setWhatsThis(toolTip); @@ -89,7 +90,7 @@ KonfiguratorSpinBox* KonfiguratorPage::createSpinBox(QString configGroup, QString configName, int defaultValue, int min, int max, QWidget *parent, bool restart, int page) { - KonfiguratorSpinBox *spinBox = new KonfiguratorSpinBox(configGroup, configName, defaultValue, + KonfiguratorSpinBox *spinBox = new KonfiguratorSpinBox(std::move(configGroup), std::move(configName), defaultValue, min, max, parent, restart, page); registerObject(spinBox->extension()); @@ -99,7 +100,7 @@ KonfiguratorEditBox* KonfiguratorPage::createEditBox(QString configGroup, QString name, QString defaultValue, QWidget *parent, bool restart, int page) { - KonfiguratorEditBox *editBox = new KonfiguratorEditBox(configGroup, name, defaultValue, parent, + KonfiguratorEditBox *editBox = new KonfiguratorEditBox(std::move(configGroup), std::move(name), std::move(defaultValue), parent, restart, page); registerObject(editBox->extension()); @@ -109,7 +110,7 @@ KonfiguratorListBox* KonfiguratorPage::createListBox(QString configGroup, QString name, QStringList defaultValue, QWidget *parent, bool restart, int page) { - KonfiguratorListBox *listBox = new KonfiguratorListBox(configGroup, name, defaultValue, parent, + KonfiguratorListBox *listBox = new KonfiguratorListBox(std::move(configGroup), std::move(name), std::move(defaultValue), parent, restart, page); registerObject(listBox->extension()); @@ -119,31 +120,31 @@ KonfiguratorURLRequester* KonfiguratorPage::createURLRequester(QString configGroup, QString name, QString defaultValue, QWidget *parent, bool restart, int page, bool expansion) { - KonfiguratorURLRequester *urlRequester = new KonfiguratorURLRequester(configGroup, name, defaultValue, + KonfiguratorURLRequester *urlRequester = new KonfiguratorURLRequester(std::move(configGroup), std::move(name), std::move(defaultValue), parent, restart, page, expansion); registerObject(urlRequester->extension()); return urlRequester; } -QGroupBox* KonfiguratorPage::createFrame(QString text, QWidget *parent) +QGroupBox* KonfiguratorPage::createFrame(const QString& text, QWidget *parent) { - QGroupBox *groupBox = new QGroupBox(parent); + auto *groupBox = new QGroupBox(parent); if (!text.isNull()) groupBox->setTitle(text); return groupBox; } QGridLayout* KonfiguratorPage::createGridLayout(QWidget *parent) { - QGridLayout *gridLayout = new QGridLayout(parent); + auto *gridLayout = new QGridLayout(parent); gridLayout->setAlignment(Qt::AlignTop); gridLayout->setSpacing(6); gridLayout->setContentsMargins(11, 11, 11, 11); return gridLayout; } -QLabel* KonfiguratorPage::addLabel(QGridLayout *layout, int x, int y, QString label, +QLabel* KonfiguratorPage::addLabel(QGridLayout *layout, int x, int y, const QString& label, QWidget *parent) { QLabel *lbl = new QLabel(label, parent); @@ -154,18 +155,18 @@ QWidget* KonfiguratorPage::createSpacer(QWidget *parent) { QWidget *widget = new QWidget(parent); - QHBoxLayout *hboxlayout = new QHBoxLayout(widget); - QSpacerItem* spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + auto *hboxlayout = new QHBoxLayout(widget); + auto* spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hboxlayout->addItem(spacer); return widget; } KonfiguratorCheckBoxGroup* KonfiguratorPage::createCheckBoxGroup(int sizex, int sizey, KONFIGURATOR_CHECKBOX_PARAM *params, int paramNum, QWidget *parent, int page) { - KonfiguratorCheckBoxGroup *groupWidget = new KonfiguratorCheckBoxGroup(parent); - QGridLayout *layout = new QGridLayout(groupWidget); + auto *groupWidget = new KonfiguratorCheckBoxGroup(parent); + auto *layout = new QGridLayout(groupWidget); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); @@ -195,17 +196,17 @@ QString name, QString defaultValue, int sizex, int sizey, KONFIGURATOR_NAME_VALUE_TIP *params, int paramNum, QWidget *parent, bool restart, int page) { - KonfiguratorRadioButtons *radioWidget = new KonfiguratorRadioButtons(configGroup, name, defaultValue, parent, restart, page); + KonfiguratorRadioButtons *radioWidget = new KonfiguratorRadioButtons(std::move(configGroup), std::move(name), std::move(defaultValue), parent, restart, page); - QGridLayout *layout = new QGridLayout(radioWidget); + auto *layout = new QGridLayout(radioWidget); layout->setAlignment(Qt::AlignTop); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); int x = 0, y = 0; for (int i = 0; i != paramNum; i++) { - QRadioButton *radBtn = new QRadioButton(params[i].text, radioWidget); + auto *radBtn = new QRadioButton(params[i].text, radioWidget); if (!params[i].tooltip.isEmpty()) radBtn->setWhatsThis(params[i].tooltip); @@ -229,9 +230,9 @@ } KonfiguratorFontChooser *KonfiguratorPage::createFontChooser(QString configGroup, QString name, - QFont defaultValue, QWidget *parent, bool restart, int page) + const QFont& defaultValue, QWidget *parent, bool restart, int page) { - KonfiguratorFontChooser *fontChooser = new KonfiguratorFontChooser(configGroup, name, defaultValue, parent, + KonfiguratorFontChooser *fontChooser = new KonfiguratorFontChooser(std::move(configGroup), std::move(name), defaultValue, parent, restart, page); registerObject(fontChooser->extension()); @@ -241,7 +242,7 @@ KonfiguratorComboBox *KonfiguratorPage::createComboBox(QString configGroup, QString name, QString defaultValue, KONFIGURATOR_NAME_VALUE_PAIR *params, int paramNum, QWidget *parent, bool restart, bool editable, int page) { - KonfiguratorComboBox *comboBox = new KonfiguratorComboBox(configGroup, name, defaultValue, params, + KonfiguratorComboBox *comboBox = new KonfiguratorComboBox(std::move(configGroup), std::move(name), std::move(defaultValue), params, paramNum, parent, restart, editable, page); registerObject(comboBox->extension()); @@ -275,7 +276,7 @@ QWidget *parent, bool restart, ADDITIONAL_COLOR *addColPtr, int addColNum, int page) { - KonfiguratorColorChooser *colorChooser = new KonfiguratorColorChooser(configGroup, name, defaultValue, parent, + KonfiguratorColorChooser *colorChooser = new KonfiguratorColorChooser(std::move(configGroup), std::move(name), std::move(defaultValue), parent, restart, addColPtr, addColNum, page); registerObject(colorChooser->extension()); diff --git a/krusader/Konfigurator/krresulttable.h b/krusader/Konfigurator/krresulttable.h --- a/krusader/Konfigurator/krresulttable.h +++ b/krusader/Konfigurator/krresulttable.h @@ -40,7 +40,7 @@ { public: explicit KrResultTable(QWidget* parent); - virtual ~KrResultTable(); + ~KrResultTable() override; /** * Adds a row of search results to the end of a QGridLayout @@ -86,7 +86,7 @@ Q_OBJECT public: explicit KrArchiverResultTable(QWidget* parent); - virtual ~KrArchiverResultTable(); + ~KrArchiverResultTable() override; bool addRow(SearchObject* search, QGridLayout* grid) Q_DECL_OVERRIDE; @@ -105,7 +105,7 @@ Q_OBJECT public: explicit KrToolResultTable(QWidget* parent); - virtual ~KrToolResultTable(); + ~KrToolResultTable() override; bool addRow(SearchObject* search, QGridLayout* grid) Q_DECL_OVERRIDE; diff --git a/krusader/Konfigurator/krresulttable.cpp b/krusader/Konfigurator/krresulttable.cpp --- a/krusader/Konfigurator/krresulttable.cpp +++ b/krusader/Konfigurator/krresulttable.cpp @@ -47,8 +47,7 @@ } KrResultTable::~KrResultTable() -{ -} += default; QGridLayout* KrResultTable::initTable() @@ -60,8 +59,8 @@ // +++ Build and add table header +++ int column = 0; - for (QStringList::Iterator it = _tableHeaders.begin(); it != _tableHeaders.end(); ++it) { - _label = new QLabel(*it, this); + for (auto & _tableHeader : _tableHeaders) { + _label = new QLabel(_tableHeader, this); _label->setContentsMargins(5, 5, 5, 5); _grid->addWidget(_label, 0, column); @@ -84,7 +83,7 @@ QLayoutItem *child; int col = 0; - while ((child = grid->itemAt(i)) != 0) { + while ((child = grid->itemAt(i)) != nullptr) { // Add some space between columns child->widget()->setMinimumWidth(child->widget()->sizeHint().width() + 15); @@ -184,13 +183,12 @@ } KrArchiverResultTable::~KrArchiverResultTable() -{ -} += default; bool KrArchiverResultTable::addRow(SearchObject* search, QGridLayout* grid) { - Archiver* arch = dynamic_cast(search); + auto* arch = dynamic_cast(search); // Name column KUrlLabel *urlLabel = new KUrlLabel(arch->getWebsite(), arch->getSearchName(), this); @@ -323,13 +321,12 @@ } KrToolResultTable::~KrToolResultTable() -{ -} += default; bool KrToolResultTable::addRow(SearchObject* search, QGridLayout* grid) { - ApplicationGroup* appGroup = dynamic_cast(search); + auto* appGroup = dynamic_cast(search); QList _apps = appGroup->getAppVec(); // Name column @@ -340,10 +337,10 @@ // Tool column QWidget* toolBoxWidget = new QWidget(this); - QVBoxLayout * toolBox = new QVBoxLayout(toolBoxWidget); + auto * toolBox = new QVBoxLayout(toolBoxWidget); - for (QList::Iterator it = _apps.begin(); it != _apps.end(); ++it) { - KUrlLabel* l = new KUrlLabel((*it)->getWebsite(), (*it)->getAppName(), toolBoxWidget); + for (auto & _app : _apps) { + auto* l = new KUrlLabel(_app->getWebsite(), _app->getAppName(), toolBoxWidget); toolBox->addWidget(l); l->setAlignment(Qt::AlignLeft | Qt::AlignTop); @@ -354,10 +351,10 @@ // Found column QWidget* vboxWidget = new QWidget(this); - QVBoxLayout * vbox = new QVBoxLayout(vboxWidget); + auto * vbox = new QVBoxLayout(vboxWidget); - for (QList::Iterator it = _apps.begin(); it != _apps.end(); ++it) { - _label = new QLabel((*it)->getPath(), vboxWidget); + for (auto & _app : _apps) { + _label = new QLabel(_app->getPath(), vboxWidget); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); vbox->addWidget(_label); diff --git a/krusader/Konfigurator/krresulttabledialog.cpp b/krusader/Konfigurator/krresulttabledialog.cpp --- a/krusader/Konfigurator/krresulttabledialog.cpp +++ b/krusader/Konfigurator/krresulttabledialog.cpp @@ -37,22 +37,22 @@ KrResultTableDialog::KrResultTableDialog(QWidget *parent, DialogType type, const QString& caption, const QString& heading, const QString& headerIcon, const QString& hint) - : QDialog(parent, 0) + : QDialog(parent, nullptr) { setWindowTitle(caption); setWindowModality(Qt::WindowModal); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); - QVBoxLayout *_topLayout = new QVBoxLayout(); + auto *_topLayout = new QVBoxLayout(); _topLayout->setAlignment(Qt::AlignTop); // +++ Heading +++ // prepare the icon QWidget *_iconWidget = new QWidget(this); - QHBoxLayout * _iconBox = new QHBoxLayout(_iconWidget); + auto * _iconBox = new QHBoxLayout(_iconWidget); QLabel *_iconLabel = new QLabel(_iconWidget); _iconLabel->setPixmap(Icon(headerIcon).pixmap(32)); _iconLabel->setMinimumWidth(fontMetrics().maxWidth()*20); @@ -68,7 +68,7 @@ _topLayout->addWidget(_iconWidget); // +++ Add some space between heading and table +++ - QSpacerItem* hSpacer1 = new QSpacerItem(0, 5); + auto* hSpacer1 = new QSpacerItem(0, 5); _topLayout->addItem(hSpacer1); // +++ Table +++ @@ -113,8 +113,7 @@ } KrResultTableDialog::~KrResultTableDialog() -{ -} += default; void KrResultTableDialog::showHelp() { diff --git a/krusader/Konfigurator/searchobject.cpp b/krusader/Konfigurator/searchobject.cpp --- a/krusader/Konfigurator/searchobject.cpp +++ b/krusader/Konfigurator/searchobject.cpp @@ -23,8 +23,7 @@ #include "../krservices.h" SearchObject::SearchObject() -{ -} += default; SearchObject::SearchObject(const QString& searchName, bool found, const QString& note) : _searchName(searchName), @@ -34,15 +33,13 @@ } SearchObject::~SearchObject() -{ -} += default; // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- Application::Application() -{ -} += default; Application::Application(const QString& searchName, bool found, const QString& appName, const QString& website, const QString& note) : SearchObject(searchName, found, note), @@ -61,8 +58,7 @@ } Application::~Application() -{ -} += default; // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- @@ -80,8 +76,7 @@ } Archiver::~Archiver() -{ -} += default; // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- @@ -94,5 +89,4 @@ } ApplicationGroup::~ApplicationGroup() -{ -} += default; diff --git a/krusader/Locate/locate.cpp b/krusader/Locate/locate.cpp --- a/krusader/Locate/locate.cpp +++ b/krusader/Locate/locate.cpp @@ -102,32 +102,32 @@ return; - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; + auto *drag = new QDrag(this); + auto *mimeData = new QMimeData; mimeData->setImageData(FileListIcon("file").pixmap()); mimeData->setUrls(urls); drag->setMimeData(mimeData); drag->start(); } }; -KProcess * LocateDlg::updateProcess = 0; -LocateDlg * LocateDlg::LocateDialog = 0; +KProcess * LocateDlg::updateProcess = nullptr; +LocateDlg * LocateDlg::LocateDialog = nullptr; LocateDlg::LocateDlg(QWidget *parent) : QDialog(parent), isFeedToListBox(false) { setWindowTitle(i18n("Krusader::Locate")); setWindowModality(Qt::NonModal); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); - QGridLayout *grid = new QGridLayout(); + auto *grid = new QGridLayout(); grid->setSpacing(6); grid->setContentsMargins(11, 11, 11, 11); QWidget *hboxWidget = new QWidget(this); - QHBoxLayout *hbox = new QHBoxLayout(hboxWidget); + auto *hbox = new QHBoxLayout(hboxWidget); hbox->setContentsMargins(0, 0, 0, 0); QLabel *label = new QLabel(i18n("Search for:"), hboxWidget); @@ -150,10 +150,10 @@ grid->addWidget(hboxWidget, 0, 0); QWidget *hboxWidget2 = new QWidget(this); - QHBoxLayout * hbox2 = new QHBoxLayout(hboxWidget2); + auto * hbox2 = new QHBoxLayout(hboxWidget2); hbox2->setContentsMargins(0, 0, 0, 0); - QSpacerItem* spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + auto* spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hbox2->addItem(spacer); dontSearchInPath = new QCheckBox(i18n("Do not search in path"), hboxWidget2); @@ -263,7 +263,7 @@ void LocateDlg::updateFinished() { delete updateProcess; - updateProcess = 0; + updateProcess = nullptr; updateDbButton->setEnabled(true); } @@ -278,13 +278,13 @@ group.writeEntry("Case Sensitive", isCs = caseSensitive->isChecked()); if (!KrServices::cmdExist("locate")) { - KMessageBox::error(0, + KMessageBox::error(nullptr, i18n("Cannot start 'locate'. Check the 'Dependencies' page in konfigurator.")); return; } resultList->clear(); - lastItem = 0; + lastItem = nullptr; remaining = ""; updateButtons(true); @@ -345,13 +345,13 @@ QStringList list = remaining.split('\n'); int items = list.size(); - for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) { + for (auto & it : list) { if (--items == 0 && !remaining.endsWith('\n')) - remaining = *it; + remaining = it; else { if (dontSearchPath) { QRegExp regExp(pattern, isCs ? Qt::CaseSensitive : Qt::CaseInsensitive, QRegExp::Wildcard); - QString fileName = (*it).trimmed(); + QString fileName = it.trimmed(); if (fileName.endsWith(QLatin1String("/")) && fileName != "/") { fileName.truncate(fileName.length() - 1); } @@ -361,7 +361,7 @@ continue; } if (onlyExist) { - KFileItem file(QUrl::fromLocalFile((*it).trimmed())); + KFileItem file(QUrl::fromLocalFile(it.trimmed())); if (!file.isReadable()) continue; } @@ -371,7 +371,7 @@ else lastItem = new QTreeWidgetItem(resultList); - lastItem->setText(0, *it); + lastItem->setText(0, it); } } } @@ -448,7 +448,7 @@ void LocateDlg::keyPressEvent(QKeyEvent *e) { if (KrGlobal::copyShortcut == QKeySequence(e->key() | e->modifiers())) { - operate(0, COPY_SELECTED_TO_CLIPBOARD); + operate(nullptr, COPY_SELECTED_TO_CLIPBOARD); e->accept(); return; } @@ -469,7 +469,7 @@ operate(resultList->currentItem(), EDIT_ID); break; case Qt::Key_F10 : - operate(0, COMPARE_ID); + operate(nullptr, COMPARE_ID); break; case Qt::Key_N : if (e->modifiers() == Qt::ControlModifier) @@ -491,7 +491,7 @@ void LocateDlg::operate(QTreeWidgetItem *item, int task) { QUrl name; - if (item != 0) + if (item != nullptr) name = QUrl::fromLocalFile(item->text(0)); switch (task) { @@ -586,7 +586,7 @@ if (urls.count() == 0) return; - QMimeData *mimeData = new QMimeData; + auto *mimeData = new QMimeData; mimeData->setImageData(FileListIcon("file").pixmap()); mimeData->setUrls(urls); @@ -633,7 +633,7 @@ QString queryName; do { queryName = i18n("Locate results") + QString(" %1").arg(listBoxNum++); - } while (virtFilesystem.getFileItem(queryName) != 0); + } while (virtFilesystem.getFileItem(queryName) != nullptr); group.writeEntry("Feed To Listbox Counter", listBoxNum); KConfigGroup ga(krConfig, "Advanced"); diff --git a/krusader/MountMan/kmountman.h b/krusader/MountMan/kmountman.h --- a/krusader/MountMan/kmountman.h +++ b/krusader/MountMan/kmountman.h @@ -53,42 +53,42 @@ return _operational; } // check this 1st - void mount(QString mntPoint, bool blocking = true); // this is probably what you need for mount - void unmount(QString mntPoint, bool blocking = true); // this is probably what you need for unmount - mntStatus getStatus(QString mntPoint); // return the status of a mntPoint (if any) - void eject(QString mntPoint); + void mount(const QString& mntPoint, bool blocking = true); // this is probably what you need for mount + void unmount(const QString& mntPoint, bool blocking = true); // this is probably what you need for unmount + mntStatus getStatus(const QString& mntPoint); // return the status of a mntPoint (if any) + void eject(const QString& mntPoint); bool ejectable(QString path); bool removable(QString path); bool removable(Solid::Device d); - bool invalidFilesystem(QString type); - bool networkFilesystem(QString type); - bool nonmountFilesystem(QString type, QString mntPoint); + bool invalidFilesystem(const QString& type); + bool networkFilesystem(const QString& type); + bool nonmountFilesystem(const QString& type, const QString& mntPoint); QAction *action() { return (QAction *) _action; } explicit KMountMan(QWidget *parent); ~KMountMan(); // NOTE: this function needs some time (~50msec) - QString findUdiForPath(QString path, const Solid::DeviceInterface::Type &expType = Solid::DeviceInterface::Unknown); - QString pathForUdi(QString udi); + QString findUdiForPath(const QString& path, const Solid::DeviceInterface::Type &expType = Solid::DeviceInterface::Unknown); + QString pathForUdi(const QString& udi); public slots: void mainWindow(); // opens up the GUI - void autoMount(QString path); // just call it before refreshing into a dir + void autoMount(const QString& path); // just call it before refreshing into a dir void delayedPerformAction(const QAction *action); void quickList(); protected slots: void jobResult(KJob *job); - void slotTeardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi); - void slotSetupDone(Solid::ErrorType error, QVariant errorData, const QString &udi); + void slotTeardownDone(Solid::ErrorType error, const QVariant& errorData, const QString &udi); + void slotSetupDone(Solid::ErrorType error, const QVariant& errorData, const QString &udi); protected: // used internally static QExplicitlySharedDataPointer findInListByMntPoint(KMountPoint::List &lst, QString value); - void toggleMount(QString mntPoint); + void toggleMount(const QString& mntPoint); void emitRefreshPanel(const QUrl &url) { emit refreshPanel(url); } diff --git a/krusader/MountMan/kmountman.cpp b/krusader/MountMan/kmountman.cpp --- a/krusader/MountMan/kmountman.cpp +++ b/krusader/MountMan/kmountman.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include "../krglobal.h" #include "../icon.h" @@ -56,7 +57,7 @@ #define FSTAB "/etc/fstab" #endif -KMountMan::KMountMan(QWidget *parent) : QObject(), _operational(false), waiting(false), mountManGui(0), parentWindow(parent) +KMountMan::KMountMan(QWidget *parent) : _operational(false), waiting(false), mountManGui(nullptr), parentWindow(parent) { _action = new KToolBarPopupAction(Icon("kr_mountman"), i18n("&MountMan..."), this); connect(_action, &QAction::triggered, this, &KMountMan::mainWindow); @@ -85,36 +86,36 @@ QStringList nonmount = group.readEntry("Nonmount Points", _NonMountPoints).split(','); nonmount_fs_mntpoint += nonmount; // simplify the white space - for (QStringList::Iterator it = nonmount_fs_mntpoint.begin(); it != nonmount_fs_mntpoint.end(); ++it) { - *it = (*it).simplified(); + for (auto & it : nonmount_fs_mntpoint) { + it = it.simplified(); } } } -KMountMan::~KMountMan() {} +KMountMan::~KMountMan() = default; -bool KMountMan::invalidFilesystem(QString type) +bool KMountMan::invalidFilesystem(const QString& type) { return (invalid_fs.contains(type) > 0); } // this is an ugly hack, but type can actually be a mountpoint. oh well... -bool KMountMan::nonmountFilesystem(QString type, QString mntPoint) +bool KMountMan::nonmountFilesystem(const QString& type, const QString& mntPoint) { return((nonmount_fs.contains(type) > 0) || (nonmount_fs_mntpoint.contains(mntPoint) > 0)); } -bool KMountMan::networkFilesystem(QString type) +bool KMountMan::networkFilesystem(const QString& type) { return (network_fs.contains(type) > 0); } void KMountMan::mainWindow() { // left as a precaution, although we use kde's services now if (!KrServices::cmdExist("mount")) { - KMessageBox::error(0, i18n("Cannot start 'mount'. Check the 'Dependencies' page in konfigurator.")); + KMessageBox::error(nullptr, i18n("Cannot start 'mount'. Check the 'Dependencies' page in konfigurator.")); return; } @@ -129,8 +130,8 @@ value = value.left(value.length() - 1); QExplicitlySharedDataPointer m; - for (KMountPoint::List::iterator it = lst.begin(); it != lst.end(); ++it) { - m = it->data(); + for (auto & it : lst) { + m = it.data(); QString mntPnt = m->mountPoint(); if (mntPnt.length() > 1 && mntPnt.endsWith('/')) mntPnt = mntPnt.left(mntPnt.length() - 1); @@ -148,12 +149,12 @@ job->uiDelegate()->showErrorMessage(); } -void KMountMan::mount(QString mntPoint, bool blocking) +void KMountMan::mount(const QString& mntPoint, bool blocking) { QString udi = findUdiForPath(mntPoint, Solid::DeviceInterface::StorageAccess); if (!udi.isNull()) { Solid::Device device(udi); - Solid::StorageAccess *access = device.as(); + auto *access = device.as(); if (access && !access->isAccessible()) { connect(access, &Solid::StorageAccess::setupDone, this, &KMountMan::slotSetupDone, Qt::UniqueConnection); if (blocking) @@ -191,16 +192,16 @@ } } -void KMountMan::unmount(QString mntPoint, bool blocking) +void KMountMan::unmount(const QString& mntPoint, bool blocking) { //if working dir is below mountpoint cd to ~ first if(QUrl::fromLocalFile(QDir(mntPoint).canonicalPath()).isParentOf(QUrl::fromLocalFile(QDir::current().canonicalPath()))) QDir::setCurrent(QDir::homePath()); QString udi = findUdiForPath(mntPoint, Solid::DeviceInterface::StorageAccess); if (!udi.isNull()) { Solid::Device device(udi); - Solid::StorageAccess *access = device.as(); + auto *access = device.as(); if (access && access->isAccessible()) { connect(access, &Solid::StorageAccess::teardownDone, this, &KMountMan::slotTeardownDone, Qt::UniqueConnection); access->teardown(); @@ -233,7 +234,7 @@ } } -KMountMan::mntStatus KMountMan::getStatus(QString mntPoint) +KMountMan::mntStatus KMountMan::getStatus(const QString& mntPoint) { QExplicitlySharedDataPointer mountPoint; @@ -254,7 +255,7 @@ } -void KMountMan::toggleMount(QString mntPoint) +void KMountMan::toggleMount(const QString& mntPoint) { mntStatus status = getStatus(mntPoint); switch (status) { @@ -270,7 +271,7 @@ } } -void KMountMan::autoMount(QString path) +void KMountMan::autoMount(const QString& path) { KConfigGroup group(krConfig, "Advanced"); if (!group.readEntry("AutoMount", _AutoMount)) @@ -280,15 +281,15 @@ mount(path); } -void KMountMan::eject(QString mntPoint) +void KMountMan::eject(const QString& mntPoint) { QString udi = findUdiForPath(mntPoint, Solid::DeviceInterface::OpticalDrive); if (udi.isNull()) return; Solid::Device dev(udi); - Solid::OpticalDrive *drive = dev.as(); - if (drive == 0) + auto *drive = dev.as(); + if (drive == nullptr) return; //if working dir is below mountpoint cd to ~ first @@ -304,17 +305,17 @@ // returns true if the path is an ejectable mount point (at the moment CDROM and DVD) bool KMountMan::ejectable(QString path) { - QString udi = findUdiForPath(path, Solid::DeviceInterface::OpticalDisc); + QString udi = findUdiForPath(std::move(path), Solid::DeviceInterface::OpticalDisc); if (udi.isNull()) return false; Solid::Device dev(udi); - return dev.as() != 0; + return dev.as() != nullptr; } bool KMountMan::removable(QString path) { - QString udi = findUdiForPath(path, Solid::DeviceInterface::StorageAccess); + QString udi = findUdiForPath(std::move(path), Solid::DeviceInterface::StorageAccess); if (udi.isNull()) return false; @@ -325,7 +326,7 @@ { if(!d.isValid()) return false; - Solid::StorageDrive *drive = d.as(); + auto *drive = d.as(); if(drive) return drive->isRemovable(); else @@ -337,7 +338,7 @@ void KMountMan::quickList() { if (!_operational) { - KMessageBox::error(0, i18n("MountMan is not operational. Sorry")); + KMessageBox::error(nullptr, i18n("MountMan is not operational. Sorry")); return; } @@ -390,7 +391,7 @@ return; } - disconnect(_action->menu(), &QMenu::triggered, 0, 0); + disconnect(_action->menu(), &QMenu::triggered, nullptr, nullptr); const QList actData = action->data().toList(); const int actionType = actData[0].toInt(); @@ -406,7 +407,7 @@ }); } -QString KMountMan::findUdiForPath(QString path, const Solid::DeviceInterface::Type &expType) +QString KMountMan::findUdiForPath(const QString& path, const Solid::DeviceInterface::Type &expType) { KMountPoint::List current = KMountPoint::currentMountPoints(); KMountPoint::List possible = KMountPoint::possibleMountPoints(); @@ -423,7 +424,7 @@ Solid::Device device = storageDevices[ p ]; QString udi = device.udi(); - Solid::Block * sb = device.as(); + auto * sb = device.as(); if (sb) { QString devb = QDir(sb->device()).canonicalPath(); if (expType != Solid::DeviceInterface::Unknown && !device.isDeviceInterface(expType)) @@ -436,25 +437,25 @@ return QString(); } -QString KMountMan::pathForUdi(QString udi) +QString KMountMan::pathForUdi(const QString& udi) { Solid::Device device(udi); - Solid::StorageAccess *access = device.as(); + auto *access = device.as(); if(access) return access->filePath(); else return QString(); } -void KMountMan::slotTeardownDone(Solid::ErrorType error, QVariant errorData, const QString& /*udi*/) +void KMountMan::slotTeardownDone(Solid::ErrorType error, const QVariant& errorData, const QString& /*udi*/) { waiting = false; if (error != Solid::NoError && errorData.isValid()) { KMessageBox::sorry(parentWindow, errorData.toString()); } } -void KMountMan::slotSetupDone(Solid::ErrorType error, QVariant errorData, const QString& /*udi*/) +void KMountMan::slotSetupDone(Solid::ErrorType error, const QVariant& errorData, const QString& /*udi*/) { waiting = false; if (error != Solid::NoError && errorData.isValid()) { diff --git a/krusader/MountMan/kmountmangui.h b/krusader/MountMan/kmountmangui.h --- a/krusader/MountMan/kmountmangui.h +++ b/krusader/MountMan/kmountmangui.h @@ -32,6 +32,7 @@ #include #include +#include #include "../GUI/krtreewidget.h" #include "kmountman.h" @@ -54,10 +55,10 @@ public: explicit KMountManGUI(KMountMan *mntMan); - ~KMountManGUI(); + ~KMountManGUI() override; protected: - virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; protected slots: void doubleClicked(QTreeWidgetItem *); @@ -145,13 +146,13 @@ // set information inline void setName(QString n_) { - Name = n_; + Name = std::move(n_); } inline void setType(QString t_) { - Type = t_; + Type = std::move(t_); } inline void setMntPoint(QString m_) { - MntPoint = m_; + MntPoint = std::move(m_); } inline void setTotalBlks(long t_) { TotalBlks = t_; diff --git a/krusader/MountMan/kmountmangui.cpp b/krusader/MountMan/kmountmangui.cpp --- a/krusader/MountMan/kmountmangui.cpp +++ b/krusader/MountMan/kmountmangui.cpp @@ -60,17 +60,17 @@ KMountManGUI::KMountManGUI(KMountMan *mntMan) : QDialog(mntMan->parentWindow), mountMan(mntMan), - info(0), - mountList(0), - cbShowOnlyRemovable(0), - watcher(0), + info(nullptr), + mountList(nullptr), + cbShowOnlyRemovable(nullptr), + watcher(nullptr), sizeX(-1), sizeY(-1) { setWindowTitle(i18n("MountMan - Your Mount-Manager")); setWindowModality(Qt::WindowModal); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); watcher = new QTimer(this); @@ -145,7 +145,7 @@ QLayout *KMountManGUI::createMainPage() { - QGridLayout *layout = new QGridLayout(); + auto *layout = new QGridLayout(); layout->setSpacing(10); mountList = new KrTreeWidget(this); // create the main container KConfigGroup grp(krConfig, "Look&Feel"); @@ -191,7 +191,7 @@ QGroupBox *box = new QGroupBox(i18n("MountMan.Info"), this); box->setAlignment(Qt::AlignHCenter); - QVBoxLayout *vboxl = new QVBoxLayout(box); + auto *vboxl = new QVBoxLayout(box); info = new KRFSDisplay(box); vboxl->addWidget(info); info->resize(info->width(), height()); @@ -220,22 +220,22 @@ return; } - for (KMountPoint::List::iterator it = mounted.begin(); it != mounted.end(); ++it) { + for (auto & it : mounted) { // don't bother with invalid file systems - if (mountMan->invalidFilesystem((*it)->mountType())) { + if (mountMan->invalidFilesystem(it->mountType())) { continue; } - KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo((*it) ->mountPoint()); + KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(it ->mountPoint()); if(!info.isValid()) { continue; } fsData data; - data.setMntPoint((*it) ->mountPoint()); + data.setMntPoint(it ->mountPoint()); data.setMounted(true); data.setTotalBlks(info.size() / 1024); data.setFreeBlks(info.available() / 1024); - data.setName((*it)->mountedFrom()); - data.setType((*it)->mountType()); + data.setName(it->mountedFrom()); + data.setType(it->mountType()); fileSystems.append(data); } addNonMounted(); @@ -245,16 +245,16 @@ void KMountManGUI::addNonMounted() { // handle the non-mounted ones - for (KMountPoint::List::iterator it = possible.begin(); it != possible.end(); ++it) { + for (auto & it : possible) { // make sure we don't add things we've already added - if (KMountMan::findInListByMntPoint(mounted, (*it)->mountPoint())) { + if (KMountMan::findInListByMntPoint(mounted, it->mountPoint())) { continue; } else { fsData data; - data.setMntPoint((*it)->mountPoint()); + data.setMntPoint(it->mountPoint()); data.setMounted(false); - data.setType((*it)->mountType()); - data.setName((*it)->mountedFrom()); + data.setType(it->mountType()); + data.setName(it->mountedFrom()); if (mountMan->invalidFilesystem(data.type())) continue; @@ -276,15 +276,15 @@ QString tSize = QString("%1").arg(KIO::convertSizeFromKiB(fs.totalBlks())); QString fSize = QString("%1").arg(KIO::convertSizeFromKiB(fs.freeBlks())); QString sPrct = QString("%1%").arg(100 - (fs.usedPerct())); - QTreeWidgetItem *item = new QTreeWidgetItem(lst); + auto *item = new QTreeWidgetItem(lst); item->setText(0, fs.name()); item->setText(1, fs.type()); item->setText(2, fs.mntPoint()); item->setText(3, (mtd ? tSize : QString("N/A"))); item->setText(4, (mtd ? fSize : QString("N/A"))); item->setText(5, (mtd ? sPrct : QString("N/A"))); - Solid::StorageVolume *vol = device.as (); + auto *vol = device.as (); QString iconName; if(device.isValid()) @@ -316,8 +316,8 @@ mountList->clearSelection(); mountList->clear(); - for (QList::iterator it = fileSystems.begin(); it != fileSystems.end() ; ++it) - addItemToMountList(mountList, *it); + for (auto & fileSystem : fileSystems) + addItemToMountList(mountList, fileSystem); currentItem = mountList->topLevelItem(currentIdx); for(int i = 0; i < mountList->topLevelItemCount(); i++) { @@ -469,15 +469,15 @@ fsData* KMountManGUI::getFsData(QTreeWidgetItem *item) { - for (QList::Iterator it = fileSystems.begin(); it != fileSystems.end(); ++it) { + for (auto & fileSystem : fileSystems) { // the only thing which is unique is the mount point - if ((*it).mntPoint() == getMntPoint(item)) { - return & (*it); + if (fileSystem.mntPoint() == getMntPoint(item)) { + return & fileSystem; } } //this point shouldn't be reached abort(); - return 0; + return nullptr; } QString KMountManGUI::getMntPoint(QTreeWidgetItem *item) @@ -500,11 +500,11 @@ #endif KMountPoint::List mountPoints = KMountPoint::currentMountPoints(KMountPoint::NeedRealDeviceName); QCryptographicHash md5(QCryptographicHash::Md5); - for (KMountPoint::List::iterator i = mountPoints.begin(); i != mountPoints.end(); ++i) { - md5.addData((*i)->mountedFrom().toUtf8()); - md5.addData((*i)->realDeviceName().toUtf8()); - md5.addData((*i)->mountPoint().toUtf8()); - md5.addData((*i)->mountType().toUtf8()); + for (auto & mountPoint : mountPoints) { + md5.addData(mountPoint->mountedFrom().toUtf8()); + md5.addData(mountPoint->realDeviceName().toUtf8()); + md5.addData(mountPoint->mountPoint().toUtf8()); + md5.addData(mountPoint->mountType().toUtf8()); } QString s = md5.result(); result = s != checksum; diff --git a/krusader/Panel/PanelView/krinterbriefview.h b/krusader/Panel/PanelView/krinterbriefview.h --- a/krusader/Panel/PanelView/krinterbriefview.h +++ b/krusader/Panel/PanelView/krinterbriefview.h @@ -40,7 +40,7 @@ Q_OBJECT public: KrInterBriefView(QWidget *parent, KrViewInstance &instance, KConfig *cfg); - virtual ~KrInterBriefView(); + ~KrInterBriefView() override; // ---- reimplemented from QAbstractItemView ---- QRect visualRect(const QModelIndex&) const Q_DECL_OVERRIDE; diff --git a/krusader/Panel/PanelView/krinterbriefview.cpp b/krusader/Panel/PanelView/krinterbriefview.cpp --- a/krusader/Panel/PanelView/krinterbriefview.cpp +++ b/krusader/Panel/PanelView/krinterbriefview.cpp @@ -54,7 +54,7 @@ KrInterBriefView::KrInterBriefView(QWidget *parent, KrViewInstance &instance, KConfig *cfg) : QAbstractItemView(parent), KrInterView(instance, cfg, this), - _header(0) + _header(nullptr) { setWidget(this); setModel(_model); @@ -65,7 +65,7 @@ KConfigGroup grpSvr(_config, "Look&Feel"); _viewFont = grpSvr.readEntry("Filelist Font", _FilelistFont); - KrStyleProxy *style = new KrStyleProxy(); + auto *style = new KrStyleProxy(); style->setParent(this); setStyle(style); viewport()->setStyle(style); // for custom tooltip delay @@ -84,10 +84,10 @@ KrInterBriefView::~KrInterBriefView() { delete _properties; - _properties = 0; + _properties = nullptr; delete _operator; - _operator = 0; + _operator = nullptr; } void KrInterBriefView::doRestoreSettings(KConfigGroup group) @@ -244,7 +244,7 @@ { if (object == _header) { if (event->type() == QEvent::ContextMenu) { - QContextMenuEvent *me = (QContextMenuEvent *)event; + auto *me = (QContextMenuEvent *)event; showContextMenu(me->globalPos()); return true; } @@ -601,7 +601,7 @@ void KrInterBriefView::copySettingsFrom(KrView *other) { if(other->instance() == instance()) { // the other view is of the same type - KrInterBriefView *v = static_cast(other); + auto *v = dynamic_cast(other); int column = v->_model->lastSortOrder(); Qt::SortOrder sortDir = v->_model->lastSortDir(); _header->setSortIndicator(column, sortDir); diff --git a/krusader/Panel/PanelView/krinterdetailedview.h b/krusader/Panel/PanelView/krinterdetailedview.h --- a/krusader/Panel/PanelView/krinterdetailedview.h +++ b/krusader/Panel/PanelView/krinterdetailedview.h @@ -41,7 +41,7 @@ public: KrInterDetailedView(QWidget *parent, KrViewInstance &instance, KConfig *cfg); - virtual ~KrInterDetailedView(); + ~KrInterDetailedView() override; void updateView() Q_DECL_OVERRIDE; diff --git a/krusader/Panel/PanelView/krinterdetailedview.cpp b/krusader/Panel/PanelView/krinterdetailedview.cpp --- a/krusader/Panel/PanelView/krinterdetailedview.cpp +++ b/krusader/Panel/PanelView/krinterdetailedview.cpp @@ -75,7 +75,7 @@ header()->setSectionResizeMode(QHeaderView::Interactive); header()->setStretchLastSection(false); - KrStyleProxy *style = new KrStyleProxy(); + auto *style = new KrStyleProxy(); style->setParent(this); setStyle(style); viewport()->setStyle(style); // for custom tooltip delay @@ -89,9 +89,9 @@ KrInterDetailedView::~KrInterDetailedView() { delete _properties; - _properties = 0; + _properties = nullptr; delete _operator; - _operator = 0; + _operator = nullptr; } void KrInterDetailedView::currentChanged(const QModelIndex & current, const QModelIndex & previous) @@ -271,7 +271,7 @@ { if (object == header()) { if (event->type() == QEvent::ContextMenu) { - QContextMenuEvent *me = (QContextMenuEvent *)event; + auto *me = (QContextMenuEvent *)event; showContextMenu(me->globalPos()); return true; } else if (event->type() == QEvent::Resize) { @@ -304,7 +304,7 @@ actAutoResize->setChecked(_autoResizeColumns); QAction *res = popup.exec(p); - if (res == 0) + if (res == nullptr) return; if(res == actAutoResize) { @@ -372,7 +372,7 @@ // only show tooltip if column is not wide enough to show all text. In this case the column // data text is abbreviated and the full text is shown as tooltip, see ListModel::data(). - QHelpEvent *he = static_cast(event); + auto *he = dynamic_cast(event); const QModelIndex index = indexAt(he->pos()); // name column has a detailed tooltip if (index.isValid() && index.column() != KrViewProperties::Name) { @@ -440,7 +440,7 @@ void KrInterDetailedView::copySettingsFrom(KrView *other) { if(other->instance() == instance()) { // the other view is of the same type - KrInterDetailedView *v = static_cast(other); + auto *v = dynamic_cast(other); _autoResizeColumns = v->_autoResizeColumns; header()->restoreState(v->header()->saveState()); _model->setExtensionEnabled(!isColumnHidden(KrViewProperties::Ext)); diff --git a/krusader/Panel/PanelView/krinterview.cpp b/krusader/Panel/PanelView/krinterview.cpp --- a/krusader/Panel/PanelView/krinterview.cpp +++ b/krusader/Panel/PanelView/krinterview.cpp @@ -34,7 +34,7 @@ KrInterView::KrInterView(KrViewInstance &instance, KConfig *cfg, QAbstractItemView *itemView) : - KrView(instance, cfg), _itemView(itemView), _mouseHandler(0) + KrView(instance, cfg), _itemView(itemView), _mouseHandler(nullptr) { _model = new ListModel(this); @@ -51,20 +51,20 @@ // so schedule _model for later deletion _model->clear(false); _model->deleteLater(); - _model = 0; + _model = nullptr; delete _mouseHandler; - _mouseHandler = 0; + _mouseHandler = nullptr; QHashIterator< FileItem *, KrViewItem *> it(_itemHash); while (it.hasNext()) delete it.next().value(); _itemHash.clear(); } void KrInterView::selectRegion(KrViewItem *i1, KrViewItem *i2, bool select) { - FileItem* file1 = (FileItem *)i1->getFileItem(); + auto* file1 = (FileItem *)i1->getFileItem(); QModelIndex mi1 = _model->fileItemIndex(file1); - FileItem* file2 = (FileItem *)i2->getFileItem(); + auto* file2 = (FileItem *)i2->getFileItem(); QModelIndex mi2 = _model->fileItemIndex(file2); if (mi1.isValid() && mi2.isValid()) { @@ -106,22 +106,22 @@ KrViewItem* KrInterView::findItemByName(const QString &name) { if (!_model->ready()) - return 0; + return nullptr; QModelIndex ndx = _model->nameIndex(name); if (!ndx.isValid()) - return 0; + return nullptr; return getKrViewItem(ndx); } KrViewItem *KrInterView::findItemByUrl(const QUrl &url) { if (!_model->ready()) - return 0; + return nullptr; const QModelIndex ndx = _model->indexFromUrl(url); if (!ndx.isValid()) - return 0; + return nullptr; return getKrViewItem(ndx); } @@ -138,58 +138,58 @@ KrViewItem* KrInterView::getCurrentKrViewItem() { if (!_model->ready()) - return 0; + return nullptr; return getKrViewItem(_itemView->currentIndex()); } KrViewItem* KrInterView::getFirst() { if (!_model->ready()) - return 0; + return nullptr; return getKrViewItem(_model->index(0, 0, QModelIndex())); } KrViewItem* KrInterView::getLast() { if (!_model->ready()) - return 0; + return nullptr; return getKrViewItem(_model->index(_model->rowCount() - 1, 0, QModelIndex())); } KrViewItem* KrInterView::getNext(KrViewItem *current) { - FileItem* fileItem = (FileItem *)current->getFileItem(); + auto* fileItem = (FileItem *)current->getFileItem(); QModelIndex ndx = _model->fileItemIndex(fileItem); if (ndx.row() >= _model->rowCount() - 1) - return 0; + return nullptr; return getKrViewItem(_model->index(ndx.row() + 1, 0, QModelIndex())); } KrViewItem* KrInterView::getPrev(KrViewItem *current) { - FileItem* fileItem = (FileItem *)current->getFileItem(); + auto* fileItem = (FileItem *)current->getFileItem(); QModelIndex ndx = _model->fileItemIndex(fileItem); if (ndx.row() <= 0) - return 0; + return nullptr; return getKrViewItem(_model->index(ndx.row() - 1, 0, QModelIndex())); } KrViewItem* KrInterView::getKrViewItemAt(const QPoint &vp) { if (!_model->ready()) - return 0; + return nullptr; return getKrViewItem(_itemView->indexAt(vp)); } KrViewItem * KrInterView::getKrViewItem(FileItem *fileItem) { QHash::iterator it = _itemHash.find(fileItem); if (it == _itemHash.end()) { - KrViewItem * newItem = new KrViewItem(fileItem, this); + auto * newItem = new KrViewItem(fileItem, this); _itemHash[ fileItem ] = newItem; return newItem; } @@ -199,10 +199,10 @@ KrViewItem * KrInterView::getKrViewItem(const QModelIndex & ndx) { if (!ndx.isValid()) - return 0; + return nullptr; FileItem * fileitem = _model->fileItemAt(ndx); - if (fileitem == 0) - return 0; + if (fileitem == nullptr) + return nullptr; else return getKrViewItem(fileitem); } @@ -214,10 +214,10 @@ void KrInterView::makeItemVisible(const KrViewItem *item) { - if (item == 0) + if (item == nullptr) return; - FileItem* fileitem = (FileItem *)item->getFileItem(); + auto* fileitem = (FileItem *)item->getFileItem(); const QModelIndex index = _model->fileItemIndex(fileitem); qDebug() << "scroll to item; name=" << fileitem->getName() << " index=" << index; if (index.isValid()) @@ -256,7 +256,7 @@ return; } - FileItem* fileitem = (FileItem *)item->getFileItem(); + auto* fileitem = (FileItem *)item->getFileItem(); const QModelIndex index = _model->fileItemIndex(fileitem); if (index.isValid() && index.row() != _itemView->currentIndex().row()) { setCurrent(index, scrollToCurrent); @@ -314,7 +314,7 @@ // if the next item is current, current selection is lost on remove; preserve manually KrViewItem *currentItem = getCurrentKrViewItem(); - KrViewItem *nextCurrentItem = currentItem && currentItem == getNext(item) ? currentItem : 0; + KrViewItem *nextCurrentItem = currentItem && currentItem == getNext(item) ? currentItem : nullptr; _model->removeItem((FileItem *)item->getFileItem()); diff --git a/krusader/Panel/PanelView/krmousehandler.cpp b/krusader/Panel/PanelView/krmousehandler.cpp --- a/krusader/Panel/PanelView/krmousehandler.cpp +++ b/krusader/Panel/PanelView/krmousehandler.cpp @@ -36,9 +36,9 @@ #define CANCEL_TWO_CLICK_RENAME {_singleClicked = false;_renameTimer.stop();} -KrMouseHandler::KrMouseHandler(KrView * view, int contextMenuShift) : _view(view), _rightClickedItem(0), - _contextMenuTimer(), _contextMenuShift(contextMenuShift), _singleClicked(false), _singleClickTime(), - _renameTimer(), _dragStartPos(-1, -1), _emptyContextMenu(false), _selectedItemNames() +KrMouseHandler::KrMouseHandler(KrView *view, int contextMenuShift) + : _view(view), _rightClickedItem(nullptr), _contextMenuShift(contextMenuShift), + _singleClicked(false), _dragStartPos(-1, -1), _emptyContextMenu(false) { KConfigGroup grpSvr(krConfig, "Look&Feel"); // decide on single click/double click selection @@ -50,7 +50,7 @@ bool KrMouseHandler::mousePressEvent(QMouseEvent *e) { - _rightClickedItem = _clickedItem = 0; + _rightClickedItem = _clickedItem = nullptr; KrViewItem * item = _view->getKrViewItemAt(e->pos()); if (!_view->isFocused()) _view->op()->emitNeedFocus(); @@ -109,7 +109,7 @@ if (item && (KrSelectionMode::getSelectionHandler()->shiftCtrlLeftButtonSelects() || KrSelectionMode::getSelectionHandler()->leftButtonSelects())) { KrViewItem * current = _view->getCurrentKrViewItem(); - if (current != 0) + if (current != nullptr) _view->selectRegion(item, current, true); } if (item) @@ -157,7 +157,7 @@ if (item && (KrSelectionMode::getSelectionHandler()->shiftCtrlRightButtonSelects() || KrSelectionMode::getSelectionHandler()->rightButtonSelects())) { KrViewItem * current = _view->getCurrentKrViewItem(); - if (current != 0) + if (current != nullptr) _view->selectRegion(item, current, true); } if (item) @@ -197,13 +197,13 @@ } if (e->button() == Qt::RightButton) { - _rightClickedItem = 0; + _rightClickedItem = nullptr; _contextMenuTimer.stop(); } if (_singleClick && e->button() == Qt::LeftButton && e->modifiers() == Qt::NoModifier) { CANCEL_TWO_CLICK_RENAME; e->accept(); - if (item == 0) + if (item == nullptr) return true; QString tmp = item->name(); _view->op()->emitExecuted(tmp); @@ -236,9 +236,9 @@ CANCEL_TWO_CLICK_RENAME; - if (e->button() == Qt::MidButton && item != 0) { + if (e->button() == Qt::MidButton && item != nullptr) { e->accept(); - if (item == 0) + if (item == nullptr) return true; _view->op()->emitMiddleButtonClicked(item); return true; @@ -253,9 +253,9 @@ KrViewItem * item = _view->getKrViewItemAt(e->pos()); if (_singleClick) return false; - if (e->button() == Qt::LeftButton && item != 0) { + if (e->button() == Qt::LeftButton && item != nullptr) { e->accept(); - QString tmp = item->name(); + const QString& tmp = item->name(); _view->op()->emitExecuted(tmp); return true; } diff --git a/krusader/Panel/PanelView/krselectionmode.cpp b/krusader/Panel/PanelView/krselectionmode.cpp --- a/krusader/Panel/PanelView/krselectionmode.cpp +++ b/krusader/Panel/PanelView/krselectionmode.cpp @@ -25,7 +25,7 @@ #include -static KrSelectionMode *__currentSelectionMode = 0; // uninitiated, at first +static KrSelectionMode *__currentSelectionMode = nullptr; // uninitiated, at first KonqSelectionMode konqSelectionMode; @@ -36,7 +36,7 @@ KrSelectionMode* KrSelectionMode::getSelectionHandlerForMode(const QString &mode) { - KrSelectionMode *res = NULL; + KrSelectionMode *res = nullptr; bool isNum; int modenum = mode.toInt(&isNum); switch (modenum) { @@ -69,7 +69,7 @@ KConfigGroup group(krConfig, "Look&Feel"); QString mode = group.readEntry("Mouse Selection", QString("")); __currentSelectionMode = getSelectionHandlerForMode(mode); - if (__currentSelectionMode == NULL) { + if (__currentSelectionMode == nullptr) { __currentSelectionMode = &userSelectionMode; } // init and return @@ -80,7 +80,7 @@ void KrSelectionMode::resetSelectionHandler() { - __currentSelectionMode = 0; + __currentSelectionMode = nullptr; } void UserSelectionMode::init() diff --git a/krusader/Panel/PanelView/krsort.cpp b/krusader/Panel/PanelView/krsort.cpp --- a/krusader/Panel/PanelView/krsort.cpp +++ b/krusader/Panel/PanelView/krsort.cpp @@ -21,6 +21,8 @@ #include "krsort.h" +#include + #include "krview.h" #include "../FileSystem/fileitem.h" @@ -34,7 +36,7 @@ _fileItem = fileitem; _index = origNdx; _name = fileitem->getName(); - _customData = customData; + _customData = std::move(customData); if(_prop->sortOptions & KrViewProperties::IgnoreCase) _name = _name.toLower(); @@ -49,9 +51,9 @@ int loc = fileitemName.lastIndexOf('.'); if (loc > 0) { // avoid mishandling of .bashrc and friend // check if it has one of the predefined 'atomic extensions' - for (QStringList::const_iterator i = props->atomicExtensions.begin(); i != props->atomicExtensions.end(); ++i) { - if (fileitemName.endsWith(*i) && fileitemName != *i) { - loc = fileitemName.length() - (*i).length(); + for (const auto & atomicExtension : props->atomicExtensions) { + if (fileitemName.endsWith(atomicExtension) && fileitemName != atomicExtension) { + loc = fileitemName.length() - atomicExtension.length(); break; } } @@ -302,7 +304,7 @@ void Sorter::addItem(FileItem *fileitem, bool isDummy, int idx, QVariant customData) { - _itemStore << SortProps(fileitem, _viewProperties->sortColumn, _viewProperties, isDummy, !descending(), idx, customData); + _itemStore << SortProps(fileitem, _viewProperties->sortColumn, _viewProperties, isDummy, !descending(), idx, std::move(customData)); _items << &_itemStore.last(); } @@ -314,7 +316,7 @@ int Sorter::insertIndex(FileItem *fileitem, bool isDummy, QVariant customData) { - SortProps props(fileitem, _viewProperties->sortColumn, _viewProperties, isDummy, !descending(), -1, customData); + SortProps props(fileitem, _viewProperties->sortColumn, _viewProperties, isDummy, !descending(), -1, std::move(customData)); const QVector::iterator it = qLowerBound(_items.begin(), _items.end(), &props, descending() ? _greaterThanFunc : _lessThanFunc); diff --git a/krusader/Panel/PanelView/krview.h b/krusader/Panel/PanelView/krview.h --- a/krusader/Panel/PanelView/krview.h +++ b/krusader/Panel/PanelView/krview.h @@ -32,6 +32,7 @@ // QtGui #include #include +#include #include "krviewproperties.h" @@ -53,14 +54,14 @@ Q_OBJECT public: KrViewOperator(KrView *view, QWidget *widget); - ~KrViewOperator(); + ~KrViewOperator() override; KrView *view() const { return _view; } QWidget *widget() const { return _widget; } void startDrag(); void emitGotDrop(QDropEvent *e) { emit gotDrop(e); } - void emitLetsDrag(QStringList items, QPixmap icon) { emit letsDrag(items, icon); } + void emitLetsDrag(QStringList items, const QPixmap& icon) { emit letsDrag(std::move(items), icon); } void emitItemDescription(const QString &desc) { emit itemDescription(desc); } void emitContextMenu(const QPoint &point) { emit contextMenu(point); } void emitEmptyContextMenu(const QPoint &point) { emit emptyContextMenu(point); } @@ -176,7 +177,7 @@ class IconSizes : public QVector { public: - IconSizes() : QVector() { *this << 12 << 16 << 22 << 32 << 48 << 64 << 128 << 256; } + IconSizes() { *this << 12 << 16 << 22 << 32 << 48 << 64 << 128 << 256; } }; // instantiating a new view @@ -253,21 +254,21 @@ uint numDirs() const { return _numDirs; } uint count() const { return _count; } void getSelectedItems(QStringList *names, bool fallbackToFocused = true); - void getItemsByMask(QString mask, QStringList *names, bool dirs = true, bool files = true); + void getItemsByMask(const QString& mask, QStringList *names, bool dirs = true, bool files = true); void getSelectedKrViewItems(KrViewItemList *items); void selectAllIncludingDirs() { changeSelection(KRQuery("*"), true, true); } void select(const KRQuery &filter = KRQuery("*")) { changeSelection(filter, true); } void unselect(const KRQuery &filter = KRQuery("*")) { changeSelection(filter, false); } void unselectAll() { changeSelection(KRQuery("*"), false, true); } void invertSelection(); QString nameToMakeCurrent() const { return _nameToMakeCurrent; } - void setNameToMakeCurrent(const QString name) { _nameToMakeCurrent = name; } + void setNameToMakeCurrent(const QString& name) { _nameToMakeCurrent = name; } QString firstUnmarkedBelowCurrent(const bool skipCurrent); QString statistics(); const KrViewProperties *properties() const { return _properties; } KrViewOperator *op() const { return _operator; } void showPreviews(bool show); - bool previewsShown() { return _previews != 0; } + bool previewsShown() { return _previews != nullptr; } void applySettingsToOthers(); void setFiles(DirListerInterface *files); @@ -295,7 +296,7 @@ const KRQuery &filterMask() const { return _properties->filterMask; } KrViewProperties::FilterSpec filter() const { return _properties->filter; } void setFilter(KrViewProperties::FilterSpec filter); - void setFilter(KrViewProperties::FilterSpec filter, FilterSettings customFilter, + void setFilter(KrViewProperties::FilterSpec filter, const FilterSettings& customFilter, bool applyToDirs); void customSelection(bool select); int defaultFileIconSize(); @@ -323,7 +324,7 @@ // restore the default settings for this view type void restoreDefaultSettings(); // call this to restore this view's settings after restart - void restoreSettings(KConfigGroup grp); + void restoreSettings(const KConfigGroup& grp); void saveSelection(); void restoreSelection(); diff --git a/krusader/Panel/PanelView/krview.cpp b/krusader/Panel/PanelView/krview.cpp --- a/krusader/Panel/PanelView/krview.cpp +++ b/krusader/Panel/PanelView/krview.cpp @@ -56,7 +56,7 @@ #define FILEITEM getFileItem() -KrView *KrViewOperator::_changedView = 0; +KrView *KrViewOperator::_changedView = nullptr; KrViewProperties::PropertyType KrViewOperator::_changedProperties = KrViewProperties::NoProperty; @@ -101,7 +101,7 @@ if (items.empty()) return ; // don't drag an empty thing QPixmap px; - if (items.count() > 1 || _view->getCurrentKrViewItem() == 0) + if (items.count() > 1 || _view->getCurrentKrViewItem() == nullptr) px = FileListIcon("document-multiple").pixmap(); // we are dragging multiple items else px = _view->getCurrentKrViewItem()->icon(); @@ -174,28 +174,28 @@ if(_changedView) _changedView->saveDefaultSettings(_changedProperties); _changedProperties = KrViewProperties::NoProperty; - _changedView = 0; + _changedView = nullptr; } // ----------------------------- krview const KrView::IconSizes KrView::iconSizes; KrView::KrView(KrViewInstance &instance, KConfig *cfg) - : _config(cfg), _properties(0), _focused(false), _fileIconSize(0), - _instance(instance), _files(0), _mainWindow(0), _widget(0), _nameToMakeCurrent(QString()), - _previews(0), _updateDefaultSettings(false), _ignoreSettingsChange(false), _count(0), - _numDirs(0), _dummyFileItem(0) + : _config(cfg), _properties(nullptr), _focused(false), _fileIconSize(0), + _instance(instance), _files(nullptr), _mainWindow(nullptr), _widget(nullptr), _nameToMakeCurrent(QString()), + _previews(nullptr), _updateDefaultSettings(false), _ignoreSettingsChange(false), _count(0), + _numDirs(0), _dummyFileItem(nullptr) { } KrView::~KrView() { _instance.m_objects.removeOne(this); delete _previews; - _previews = 0; + _previews = nullptr; delete _dummyFileItem; - _dummyFileItem = 0; + _dummyFileItem = nullptr; if (_properties) qFatal("A class inheriting KrView didn't delete _properties!"); if (_operator) @@ -236,7 +236,7 @@ sortOps |= KrViewProperties::IgnoreCase; if (grpSvr.readEntry("Locale Aware Sort", true)) sortOps |= KrViewProperties::LocaleAwareSort; - KrViewProperties::SortOptions sortOptions = static_cast(sortOps); + auto sortOptions = static_cast(sortOps); KrViewProperties::SortMethod sortMethod = static_cast( grpSvr.readEntry("Sort method", (int)_DefaultSortMethod)); @@ -278,7 +278,7 @@ } } else { delete _previews; - _previews = 0; + _previews = nullptr; } redraw(); // op()->settingsChanged(KrViewProperties::PropShowPreviews); @@ -368,9 +368,9 @@ * this function ADDs a list of selected item names into 'names'. * it assumes the list is ready and doesn't initialize it, or clears it */ -void KrView::getItemsByMask(QString mask, QStringList* names, bool dirs, bool files) +void KrView::getItemsByMask(const QString& mask, QStringList* names, bool dirs, bool files) { - for (KrViewItem * it = getFirst(); it != 0; it = getNext(it)) { + for (KrViewItem * it = getFirst(); it != nullptr; it = getNext(it)) { if ((it->name() == "..") || !QDir::match(mask, it->name())) continue; // if we got here, than the item fits the mask if (it->getFileItem()->isDir() && !dirs) continue; // do we need to skip folders? @@ -385,7 +385,7 @@ */ void KrView::getSelectedItems(QStringList *names, bool fallbackToFocused) { - for (KrViewItem *it = getFirst(); it != 0; it = getNext(it)) + for (KrViewItem *it = getFirst(); it != nullptr; it = getNext(it)) if (it->isSelected() && (it->name() != "..")) names->append(it->name()); @@ -400,15 +400,15 @@ void KrView::getSelectedKrViewItems(KrViewItemList *items) { - for (KrViewItem * it = getFirst(); it != 0; it = getNext(it)) + for (KrViewItem * it = getFirst(); it != nullptr; it = getNext(it)) if (it->isSelected() && (it->name() != "..")) items->append(it); // if all else fails, take the current item QString item = getCurrentItem(); if (items->empty() && !item.isEmpty() && item != ".." && - getCurrentKrViewItem() != 0) { + getCurrentKrViewItem() != nullptr) { items->append(getCurrentKrViewItem()); } } @@ -453,15 +453,15 @@ if (op()) op()->setMassSelectionUpdate(true); KrViewItem *temp = getCurrentKrViewItem(); - KrViewItem *firstMatch = 0; - for (KrViewItem * it = getFirst(); it != 0; it = getNext(it)) { + KrViewItem *firstMatch = nullptr; + for (KrViewItem * it = getFirst(); it != nullptr; it = getNext(it)) { if (it->name() == "..") continue; if (it->getFileItem()->isDir() && !includeDirs) continue; FileItem * file = it->getMutableFileItem(); // filter::match calls getMimetype which isn't const - if (file == 0) + if (file == nullptr) continue; if (filter.match(file)) { @@ -472,9 +472,9 @@ if (op()) op()->setMassSelectionUpdate(false); updateView(); - if (ensureVisibilityAfterSelect() && temp != 0) { + if (ensureVisibilityAfterSelect() && temp != nullptr) { makeItemVisible(temp); - } else if (makeVisible && firstMatch != 0) { + } else if (makeVisible && firstMatch != nullptr) { // if no selected item is visible... KrViewItemList selectedItems; getSelectedKrViewItems(&selectedItems); @@ -492,7 +492,7 @@ } redraw(); - return firstMatch != 0; // return if any file was selected + return firstMatch != nullptr; // return if any file was selected } void KrView::invertSelection() @@ -502,22 +502,22 @@ bool markDirs = grpSvr.readEntry("Mark Dirs", _MarkDirs); KrViewItem *temp = getCurrentKrViewItem(); - for (KrViewItem * it = getFirst(); it != 0; it = getNext(it)) { + for (KrViewItem * it = getFirst(); it != nullptr; it = getNext(it)) { if (it->name() == "..") continue; if (it->getFileItem()->isDir() && !markDirs && !it->isSelected()) continue; it->setSelected(!it->isSelected()); } if (op()) op()->setMassSelectionUpdate(false); updateView(); - if (ensureVisibilityAfterSelect() && temp != 0) + if (ensureVisibilityAfterSelect() && temp != nullptr) makeItemVisible(temp); } QString KrView::firstUnmarkedBelowCurrent(const bool skipCurrent) { - if (getCurrentKrViewItem() == 0) + if (getCurrentKrViewItem() == nullptr) return QString(); KrViewItem *iterator = getCurrentKrViewItem(); @@ -610,7 +610,7 @@ _previews->clear(); _count = _numDirs = 0; delete _dummyFileItem; - _dummyFileItem = 0; + _dummyFileItem = nullptr; redraw(); } @@ -625,7 +625,7 @@ e->ignore(); else { KrViewItem * i = getCurrentKrViewItem(); - if (i == 0) + if (i == nullptr) return true; QString tmp = i->name(); op()->emitExecuted(tmp); @@ -667,7 +667,7 @@ } case Qt::Key_Space: { KrViewItem * viewItem = getCurrentKrViewItem(); - if (viewItem != 0) { + if (viewItem != nullptr) { viewItem->setSelected(!viewItem->isSelected()); if (viewItem->getFileItem()->isDir() && @@ -752,7 +752,7 @@ if (e->modifiers() & Qt::ShiftModifier) { bool select = true; KrViewItem *pos = getCurrentKrViewItem(); - if (pos == 0) + if (pos == nullptr) pos = getLast(); KrViewItem *item = getFirst(); op()->setMassSelectionUpdate(true); @@ -775,7 +775,7 @@ if (e->modifiers() & Qt::ShiftModifier) { bool select = false; KrViewItem *pos = getCurrentKrViewItem(); - if (pos == 0) + if (pos == nullptr) pos = getFirst(); op()->setMassSelectionUpdate(true); KrViewItem *item = getFirst(); @@ -799,7 +799,7 @@ int downStep = itemsPerPage(); while (downStep != 0 && current) { KrViewItem * newCurrent = getNext(current); - if (newCurrent == 0) + if (newCurrent == nullptr) break; current = newCurrent; downStep--; @@ -815,7 +815,7 @@ int upStep = itemsPerPage(); while (upStep != 0 && current) { KrViewItem * newCurrent = getPrev(current); - if (newCurrent == 0) + if (newCurrent == nullptr) break; current = newCurrent; upStep--; @@ -905,7 +905,7 @@ } } -void KrView::restoreSettings(KConfigGroup group) +void KrView::restoreSettings(const KConfigGroup& group) { _ignoreSettingsChange = true; doRestoreSettings(group); @@ -927,8 +927,7 @@ void KrView::applySettingsToOthers() { - for(int i = 0; i < _instance.m_objects.length(); i++) { - KrView *view = _instance.m_objects[i]; + for(auto view : _instance.m_objects) { if(this != view) { view->_ignoreSettingsChange = true; view->copySettingsFrom(this); @@ -1048,21 +1047,21 @@ if(files != _files) { clear(); if(_files) - QObject::disconnect(_files, 0, op(), 0); + QObject::disconnect(_files, nullptr, op(), nullptr); _files = files; } if(!_files) return; - QObject::disconnect(_files, 0, op(), 0); + QObject::disconnect(_files, nullptr, op(), nullptr); QObject::connect(_files, &DirListerInterface::scanDone, op(), &KrViewOperator::startUpdate); QObject::connect(_files, &DirListerInterface::cleared, op(), &KrViewOperator::cleared); QObject::connect(_files, &DirListerInterface::addedFileItem, op(), &KrViewOperator::fileAdded); QObject::connect(_files, &DirListerInterface::updatedFileItem, op(), &KrViewOperator::fileUpdated); } -void KrView::setFilter(KrViewProperties::FilterSpec filter, FilterSettings customFilter, bool applyToDirs) +void KrView::setFilter(KrViewProperties::FilterSpec filter, const FilterSettings& customFilter, bool applyToDirs) { _properties->filter = filter; _properties->filterSettings = customFilter; @@ -1108,7 +1107,7 @@ KConfigGroup grpSvr(_config, "Look&Feel"); bool includeDirs = grpSvr.readEntry("Mark Dirs", _MarkDirs); - FilterDialog dialog(0, i18n("Select Files"), QStringList(i18n("Apply selection to folders")), false); + FilterDialog dialog(nullptr, i18n("Select Files"), QStringList(i18n("Apply selection to folders")), false); dialog.checkExtraOption(i18n("Apply selection to folders"), includeDirs); dialog.exec(); KRQuery query = dialog.getQuery(); diff --git a/krusader/Panel/PanelView/krviewfactory.cpp b/krusader/Panel/PanelView/krviewfactory.cpp --- a/krusader/Panel/PanelView/krviewfactory.cpp +++ b/krusader/Panel/PanelView/krviewfactory.cpp @@ -43,7 +43,7 @@ const QKeySequence &shortcut) : KrViewInstance(id, name, desc, icon, shortcut) {} - virtual KrView *create(QWidget *w, KConfig *cfg) Q_DECL_OVERRIDE { + KrView *create(QWidget *w, KConfig *cfg) Q_DECL_OVERRIDE { return new T(w, *this, cfg); } }; @@ -53,7 +53,7 @@ // static initialization, on first use idiom KrViewFactory &KrViewFactory::self() { - static KrViewFactory *factory = 0; + static KrViewFactory *factory = nullptr; if (!factory) { factory = new KrViewFactory(); factory->init(); diff --git a/krusader/Panel/PanelView/krviewitem.cpp b/krusader/Panel/PanelView/krviewitem.cpp --- a/krusader/Panel/PanelView/krviewitem.cpp +++ b/krusader/Panel/PanelView/krviewitem.cpp @@ -47,11 +47,9 @@ int loc = fileitemName.lastIndexOf('.'); if (loc > 0) { // avoid mishandling of .bashrc and friend // check if it has one of the predefined 'atomic extensions' - for (QStringList::const_iterator i = _viewProperties->atomicExtensions.begin(); - i != _viewProperties->atomicExtensions.end(); - ++i) { - if (fileitemName.endsWith(*i)) { - loc = fileitemName.length() - (*i).length(); + for (const auto & atomicExtension : _viewProperties->atomicExtensions) { + if (fileitemName.endsWith(atomicExtension)) { + loc = fileitemName.length() - atomicExtension.length(); break; } } diff --git a/krusader/Panel/PanelView/krviewitemdelegate.cpp b/krusader/Panel/PanelView/krviewitemdelegate.cpp --- a/krusader/Panel/PanelView/krviewitemdelegate.cpp +++ b/krusader/Panel/PanelView/krviewitemdelegate.cpp @@ -60,7 +60,7 @@ void KrViewItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QItemDelegate::setEditorData(editor, index); - QLineEdit *lineEdit = qobject_cast (editor); + auto *lineEdit = qobject_cast (editor); if (lineEdit) { KConfigGroup gl(krConfig, "Look&Feel"); QFont font = index.data(Qt::FontRole).value(); @@ -91,15 +91,15 @@ if (!editor) return false; if (event->type() == QEvent::KeyPress) { - switch (static_cast(event)->key()) { + switch (dynamic_cast(event)->key()) { case Qt::Key_Tab: case Qt::Key_Backtab: _currentlyEdited = -1; emit closeEditor(editor, QAbstractItemDelegate::RevertModelCache); return true; case Qt::Key_Enter: case Qt::Key_Return: - if (QLineEdit *e = qobject_cast(editor)) { + if (auto *e = qobject_cast(editor)) { if (!e->hasAcceptableInput()) return true; event->accept(); @@ -142,7 +142,7 @@ emit closeEditor(editor, RevertModelCache); } } else if (event->type() == QEvent::ShortcutOverride) { - const QKeyEvent *ke = static_cast(event); + const QKeyEvent *ke = dynamic_cast(event); if (ke->key() == Qt::Key_Escape || (ke->key() == Qt::Key_Backspace && ke->modifiers() == Qt::ControlModifier)) { event->accept(); diff --git a/krusader/Panel/PanelView/krviewproperties.cpp b/krusader/Panel/PanelView/krviewproperties.cpp --- a/krusader/Panel/PanelView/krviewproperties.cpp +++ b/krusader/Panel/PanelView/krviewproperties.cpp @@ -19,6 +19,8 @@ #include "krviewproperties.h" +#include + KrViewProperties::KrViewProperties(bool displayIcons, bool numericPermissions, KrViewProperties::SortOptions sortOptions, KrViewProperties::SortMethod sortMethod, bool humanReadableSize, @@ -28,6 +30,6 @@ sortOptions(sortOptions), sortMethod(sortMethod), filter(KrViewProperties::All), filterMask(KRQuery("*")), filterApplysToDirs(false), localeAwareCompareIsCaseSensitive(localeAwareCompareIsCaseSensitive), - humanReadableSize(humanReadableSize), atomicExtensions(atomicExtensions), numberOfColumns(1) + humanReadableSize(humanReadableSize), atomicExtensions(std::move(atomicExtensions)), numberOfColumns(1) { } diff --git a/krusader/Panel/PanelView/listmodel.h b/krusader/Panel/PanelView/listmodel.h --- a/krusader/Panel/PanelView/listmodel.h +++ b/krusader/Panel/PanelView/listmodel.h @@ -42,7 +42,7 @@ public: explicit ListModel(KrInterView *); - virtual ~ListModel(); + ~ListModel() override; inline bool ready() const { return _ready; @@ -74,7 +74,7 @@ const QModelIndex & fileItemIndex(const FileItem *); const QModelIndex & nameIndex(const QString &); const QModelIndex & indexFromUrl(const QUrl &url); - virtual Qt::ItemFlags flags(const QModelIndex & index) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags(const QModelIndex & index) const Q_DECL_OVERRIDE; void emitChanged() { emit layoutChanged(); } @@ -85,7 +85,7 @@ } public slots: - virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) Q_DECL_OVERRIDE; + void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) Q_DECL_OVERRIDE; protected: KrSort::LessThanFunc lessThanFunc() { diff --git a/krusader/Panel/PanelView/listmodel.cpp b/krusader/Panel/PanelView/listmodel.cpp --- a/krusader/Panel/PanelView/listmodel.cpp +++ b/krusader/Panel/PanelView/listmodel.cpp @@ -33,7 +33,7 @@ #include ListModel::ListModel(KrInterView *view) - : QAbstractListModel(0), _extensionEnabled(true), _view(view), _dummyFileItem(0), _ready(false), + : QAbstractListModel(nullptr), _extensionEnabled(true), _view(view), _dummyFileItem(nullptr), _ready(false), _justForSizeHint(false), _alternatingTable(false) { KConfigGroup grpSvr(krConfig, "Look&Feel"); @@ -58,8 +58,7 @@ } ListModel::~ListModel() -{ -} += default; void ListModel::clear(bool emitLayoutChanged) { @@ -79,7 +78,7 @@ _fileItemNdx.clear(); _nameNdx.clear(); _urlNdx.clear(); - _dummyFileItem = 0; + _dummyFileItem = nullptr; if (emitLayoutChanged) emit layoutChanged(); @@ -101,7 +100,7 @@ if (!index.isValid() || index.row() >= rowCount()) return QVariant(); FileItem *fileitem = _fileItems.at(index.row()); - if (fileitem == 0) + if (fileitem == nullptr) return QVariant(); switch (role) { @@ -260,7 +259,7 @@ if (role == Qt::EditRole && index.isValid()) { if (index.row() < rowCount() && index.row() >= 0) { FileItem *fileitem = _fileItems.at(index.row()); - if (fileitem == 0) + if (fileitem == nullptr) return false; _view->op()->emitRenameItem(fileitem->getName(), value.toString()); } @@ -416,7 +415,7 @@ FileItem *ListModel::fileItemAt(const QModelIndex &index) { if (!index.isValid() || index.row() < 0 || index.row() >= _fileItems.count()) - return 0; + return nullptr; return _fileItems[ index.row()]; } @@ -469,9 +468,9 @@ // and virtfs / search result names like "/dir/.file" which would become "/dir/" if (loc > 0 && fileItemName.lastIndexOf('/') < loc) { // check if it has one of the predefined 'atomic extensions' - for (QStringList::const_iterator i = properties()->atomicExtensions.begin(); i != properties()->atomicExtensions.end(); ++i) { - if (fileItemName.endsWith(*i) && fileItemName != *i) { - loc = fileItemName.length() - (*i).length(); + for (const auto & atomicExtension : properties()->atomicExtensions) { + if (fileItemName.endsWith(atomicExtension) && fileItemName != atomicExtension) { + loc = fileItemName.length() - atomicExtension.length(); break; } } diff --git a/krusader/Panel/dirhistoryqueue.h b/krusader/Panel/dirhistoryqueue.h --- a/krusader/Panel/dirhistoryqueue.h +++ b/krusader/Panel/dirhistoryqueue.h @@ -37,7 +37,7 @@ Q_OBJECT public: explicit DirHistoryQueue(KrPanel *panel); - ~DirHistoryQueue(); + ~DirHistoryQueue() override; void clear(); int currentPos() { @@ -51,7 +51,7 @@ const QUrl &get(int pos) { return _urlQueue[pos]; } - void add(QUrl url, QString currentItem); + void add(QUrl url, const QString& currentItem); bool gotoPos(int pos); bool goBack(); bool goForward(); @@ -64,7 +64,7 @@ QString currentItem(); // current item of the view void save(KConfigGroup cfg); - bool restore(KConfigGroup cfg); + bool restore(const KConfigGroup& cfg); public slots: void saveCurrentItem(); diff --git a/krusader/Panel/dirhistoryqueue.cpp b/krusader/Panel/dirhistoryqueue.cpp --- a/krusader/Panel/dirhistoryqueue.cpp +++ b/krusader/Panel/dirhistoryqueue.cpp @@ -35,7 +35,7 @@ { } -DirHistoryQueue::~DirHistoryQueue() {} +DirHistoryQueue::~DirHistoryQueue() = default; void DirHistoryQueue::clear() { @@ -74,7 +74,7 @@ _currentItems[_currentPos] = _panel->view->getCurrentItem(); } -void DirHistoryQueue::add(QUrl url, QString currentItem) +void DirHistoryQueue::add(QUrl url, const QString& currentItem) { url.setPath(QDir::cleanPath(url.path())); @@ -145,7 +145,7 @@ cfg.writeEntry("CurrentIndex", _currentPos); } -bool DirHistoryQueue::restore(KConfigGroup cfg) +bool DirHistoryQueue::restore(const KConfigGroup& cfg) { clear(); _urlQueue = KrServices::toUrlList(cfg.readEntry("Entrys", QStringList())); // krazy:exclude=spelling diff --git a/krusader/Panel/krcalcspacedialog.cpp b/krusader/Panel/krcalcspacedialog.cpp --- a/krusader/Panel/krcalcspacedialog.cpp +++ b/krusader/Panel/krcalcspacedialog.cpp @@ -41,7 +41,7 @@ { setWindowTitle(i18n("Calculate Occupied Space")); - QVBoxLayout *layout = new QVBoxLayout; + auto *layout = new QVBoxLayout; setLayout(layout); layout->setSizeConstraint(QLayout::SetFixedSize); @@ -86,7 +86,7 @@ void KrCalcSpaceDialog::showDialog(QWidget *parent, SizeCalculator *calculator) { - KrCalcSpaceDialog *dialog = new KrCalcSpaceDialog(parent, calculator); + auto *dialog = new KrCalcSpaceDialog(parent, calculator); dialog->show(); } diff --git a/krusader/Panel/krcolorcache.h b/krusader/Panel/krcolorcache.h --- a/krusader/Panel/krcolorcache.h +++ b/krusader/Panel/krcolorcache.h @@ -158,7 +158,7 @@ const KrColorCache & operator= (const KrColorCache &); public: KrColorCache(); - ~KrColorCache(); + ~KrColorCache() override; static KrColorCache & getColorCache(); void getColors(KrColorGroup & result, const KrColorItemType & type) const; bool getDimSettings(QColor & dimColor, int & dimFactor); diff --git a/krusader/Panel/krcolorcache.cpp b/krusader/Panel/krcolorcache.cpp --- a/krusader/Panel/krcolorcache.cpp +++ b/krusader/Panel/krcolorcache.cpp @@ -153,23 +153,23 @@ { KConfigGroup group(krConfig, "Colors"); QStringList names = KrColorSettingNames::getColorNames(); - for (QStringList::Iterator it = names.begin(); it != names.end(); ++it) { - m_colorTextValues[*it] = group.readEntry(*it, QString()); - if (m_colorTextValues[*it].count(',') == 2) - m_colorValues[*it] = group.readEntry(*it, QColor()); + for (auto & name : names) { + m_colorTextValues[name] = group.readEntry(name, QString()); + if (m_colorTextValues[name].count(',') == 2) + m_colorValues[name] = group.readEntry(name, QColor()); else - m_colorValues[*it] = QColor(); + m_colorValues[name] = QColor(); } names = KrColorSettingNames::getNumNames(); - for (QStringList::Iterator it = names.begin(); it != names.end(); ++it) { - if (!group.readEntry(*it, QString()).isEmpty()) { - m_numValues[*it] = group.readEntry(*it, (long long)0); + for (auto & name : names) { + if (!group.readEntry(name, QString()).isEmpty()) { + m_numValues[name] = group.readEntry(name, (long long)0); } } names = KrColorSettingNames::getBoolNames(); - for (QStringList::Iterator it = names.begin(); it != names.end(); ++it) { - if (!group.readEntry(*it, QString()).isEmpty()) { - m_boolValues[*it] = group.readEntry(*it, false); + for (auto & name : names) { + if (!group.readEntry(name, QString()).isEmpty()) { + m_boolValues[name] = group.readEntry(name, false); } } } @@ -196,9 +196,9 @@ if (this == & src) return * this; QStringList names = KrColorSettingNames::getColorNames(); - for (QStringList::Iterator it = names.begin(); it != names.end(); ++it) { - m_impl->m_colorTextValues[*it] = src.m_impl->m_colorTextValues[*it]; - m_impl->m_colorValues[*it] = src.m_impl->m_colorValues[*it]; + for (auto & name : names) { + m_impl->m_colorTextValues[name] = src.m_impl->m_colorTextValues[name]; + m_impl->m_colorValues[name] = src.m_impl->m_colorValues[name]; } for (QMap::Iterator it = src.m_impl->m_numValues.begin(); it != src.m_impl->m_numValues.end(); ++it) { m_impl->m_numValues[it.key()] = it.value(); @@ -659,7 +659,7 @@ -KrColorCache * KrColorCache::m_instance = 0; +KrColorCache * KrColorCache::m_instance = nullptr; KrColorCache::KrColorCache() { diff --git a/krusader/Panel/krerrordisplay.h b/krusader/Panel/krerrordisplay.h --- a/krusader/Panel/krerrordisplay.h +++ b/krusader/Panel/krerrordisplay.h @@ -35,7 +35,7 @@ public: explicit KrErrorDisplay(QWidget *parent); - void setText(QString text); + void setText(const QString& text); private slots: void slotTimeout(); diff --git a/krusader/Panel/krerrordisplay.cpp b/krusader/Panel/krerrordisplay.cpp --- a/krusader/Panel/krerrordisplay.cpp +++ b/krusader/Panel/krerrordisplay.cpp @@ -39,7 +39,7 @@ connect(&_dimTimer, &QTimer::timeout, this, &KrErrorDisplay::slotTimeout); } -void KrErrorDisplay::setText(QString text) +void KrErrorDisplay::setText(const QString& text) { QLabel::setText(text); _currentDim = 100; diff --git a/krusader/Panel/krfiletreeview.h b/krusader/Panel/krfiletreeview.h --- a/krusader/Panel/krfiletreeview.h +++ b/krusader/Panel/krfiletreeview.h @@ -45,8 +45,8 @@ Q_OBJECT public: - explicit KrFileTreeView(QWidget *parent = 0); - virtual ~KrFileTreeView() {} + explicit KrFileTreeView(QWidget *parent = nullptr); + ~KrFileTreeView() override = default; void setCurrentUrl(const QUrl &url); diff --git a/krusader/Panel/krfiletreeview.cpp b/krusader/Panel/krfiletreeview.cpp --- a/krusader/Panel/krfiletreeview.cpp +++ b/krusader/Panel/krfiletreeview.cpp @@ -56,7 +56,7 @@ KrDirModel(QWidget *parent, KrFileTreeView *ftv) : KDirModel(parent), fileTreeView(ftv) {} protected: - virtual Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE + Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE { Qt::ItemFlags itflags = KDirModel::flags(index); if (index.column() != KDirModel::Name) @@ -85,8 +85,7 @@ }; KrFileTreeView::KrFileTreeView(QWidget *parent) - : QTreeView(parent), mCurrentUrl(), - mCurrentTreeBase(), mStartTreeFromCurrent(false), mStartTreeFromPlace(true) + : QTreeView(parent), mStartTreeFromCurrent(false), mStartTreeFromPlace(true) { mSourceModel = new KrDirModel(this, this); mSourceModel->dirLister()->setDirOnlyMode(true); @@ -199,7 +198,7 @@ showHiddenAction->setToolTip(i18n("Show folders starting with a dot")); popup.addSeparator(); - QActionGroup *rootActionGroup = new QActionGroup(this); + auto *rootActionGroup = new QActionGroup(this); QAction *startFromRootAction = popup.addAction(i18n("Start From Root")); startFromRootAction->setCheckable(true); @@ -241,7 +240,7 @@ const KFileItem fileItem = mSourceModel->itemForIndex(mProxyModel->mapToSource(index)); const KFileItemListProperties capabilities(KFileItemList() << fileItem); - QMenu* popup = new QMenu(this); + auto* popup = new QMenu(this); // TODO nice to have: "open with" @@ -314,7 +313,7 @@ void KrFileTreeView::copyToClipBoard(const KFileItem &fileItem, bool cut) const { - QMimeData* mimeData = new QMimeData(); + auto* mimeData = new QMimeData(); QList kdeUrls; kdeUrls.append(fileItem.url()); diff --git a/krusader/Panel/krlayoutfactory.h b/krusader/Panel/krlayoutfactory.h --- a/krusader/Panel/krlayoutfactory.h +++ b/krusader/Panel/krlayoutfactory.h @@ -44,18 +44,18 @@ QLayout *createLayout(QString layoutName = QString()); static QStringList layoutNames(); - static QString layoutDescription(QString layoutName); + static QString layoutDescription(const QString& layoutName); private: - QBoxLayout *createLayout(QDomElement e, QWidget *parent); - QWidget *createFrame(QDomElement e, QWidget *parent); + QBoxLayout *createLayout(const QDomElement& e, QWidget *parent); + QWidget *createFrame(const QDomElement& e, QWidget *parent); static bool parseFiles(); - static bool parseFile(QString path, QDomDocument &doc); - static bool parseResource(QString path, QDomDocument &doc); - static bool parseContent(QByteArray content, QString fileName, QDomDocument &doc); - static void getLayoutNames(QDomDocument doc, QStringList &names); - static QDomElement findLayout(QDomDocument doc, QString layoutName); + static bool parseFile(const QString& path, QDomDocument &doc); + static bool parseResource(const QString& path, QDomDocument &doc); + static bool parseContent(const QByteArray& content, const QString& fileName, QDomDocument &doc); + static void getLayoutNames(const QDomDocument& doc, QStringList &names); + static QDomElement findLayout(const QDomDocument& doc, const QString& layoutName); ListPanel *panel; QHash &widgets; diff --git a/krusader/Panel/krlayoutfactory.cpp b/krusader/Panel/krlayoutfactory.cpp --- a/krusader/Panel/krlayoutfactory.cpp +++ b/krusader/Panel/krlayoutfactory.cpp @@ -51,7 +51,7 @@ QList KrLayoutFactory::_extraDocs; -QString KrLayoutFactory::layoutDescription(QString layoutName) +QString KrLayoutFactory::layoutDescription(const QString& layoutName) { if(layoutName == DEFAULT_LAYOUT) return i18nc("Default layout", "Default"); @@ -85,7 +85,7 @@ return true; } -bool KrLayoutFactory::parseFile(QString path, QDomDocument &doc) +bool KrLayoutFactory::parseFile(const QString& path, QDomDocument &doc) { bool success = false; @@ -99,7 +99,7 @@ return success; } -bool KrLayoutFactory::parseResource(QString path, QDomDocument &doc) +bool KrLayoutFactory::parseResource(const QString& path, QDomDocument &doc) { QResource res(path); if (res.isValid()) { @@ -115,7 +115,7 @@ } } -bool KrLayoutFactory::parseContent(QByteArray content, QString fileName, QDomDocument &doc) +bool KrLayoutFactory::parseContent(const QByteArray& content, const QString& fileName, QDomDocument &doc) { bool success = false; @@ -136,7 +136,7 @@ return success; } -void KrLayoutFactory::getLayoutNames(QDomDocument doc, QStringList &names) +void KrLayoutFactory::getLayoutNames(const QDomDocument& doc, QStringList &names) { QDomElement root = doc.documentElement(); @@ -164,7 +164,7 @@ return names; } -QDomElement KrLayoutFactory::findLayout(QDomDocument doc, QString layoutName) +QDomElement KrLayoutFactory::findLayout(const QDomDocument& doc, const QString& layoutName) { QDomElement root = doc.documentElement(); @@ -182,7 +182,7 @@ KConfigGroup cg(krConfig, "PanelLayout"); layoutName = cg.readEntry("Layout", DEFAULT_LAYOUT); } - QLayout *layout = 0; + QLayout *layout = nullptr; if (parseFiles()) { QDomElement layoutRoot; @@ -216,9 +216,9 @@ return layout; } -QBoxLayout *KrLayoutFactory::createLayout(QDomElement e, QWidget *parent) +QBoxLayout *KrLayoutFactory::createLayout(const QDomElement& e, QWidget *parent) { - QBoxLayout *l = 0; + QBoxLayout *l = nullptr; bool horizontal = false; if(e.attribute("type") == "horizontal") { @@ -229,7 +229,7 @@ l = new QVBoxLayout(); else { qWarning() << "unknown layout type:" << e.attribute("type"); - return 0; + return nullptr; } l->setSpacing(0); @@ -263,7 +263,7 @@ return l; } -QWidget *KrLayoutFactory::createFrame(QDomElement e, QWidget *parent) +QWidget *KrLayoutFactory::createFrame(const QDomElement& e, QWidget *parent) { KConfigGroup cg(krConfig, "PanelLayout"); diff --git a/krusader/Panel/krpreviewjob.h b/krusader/Panel/krpreviewjob.h --- a/krusader/Panel/krpreviewjob.h +++ b/krusader/Panel/krpreviewjob.h @@ -39,7 +39,7 @@ friend class KrPreviews; Q_OBJECT public: - virtual void start() Q_DECL_OVERRIDE {} + void start() Q_DECL_OVERRIDE {} protected slots: void slotStartJob(); @@ -55,12 +55,12 @@ KrPreviews *_parent; explicit KrPreviewJob(KrPreviews *parent); - ~KrPreviewJob(); + ~KrPreviewJob() override; void scheduleItem(KrViewItem *item); void removeItem(KrViewItem *item); void sort(); - virtual bool doKill() Q_DECL_OVERRIDE; + bool doKill() Q_DECL_OVERRIDE; }; #endif // __krpreviewjob__ diff --git a/krusader/Panel/krpreviewjob.cpp b/krusader/Panel/krpreviewjob.cpp --- a/krusader/Panel/krpreviewjob.cpp +++ b/krusader/Panel/krpreviewjob.cpp @@ -38,7 +38,7 @@ #define MAX_CHUNK_SIZE 50 -KrPreviewJob::KrPreviewJob(KrPreviews *parent) : _job(0), _parent(parent) +KrPreviewJob::KrPreviewJob(KrPreviews *parent) : _job(nullptr), _parent(parent) { _timer.setSingleShot(true); _timer.setInterval(0); @@ -104,7 +104,7 @@ KFileItemList list; for(int i = 0; i < _scheduled.count() && i < MAX_CHUNK_SIZE; i++) { - KFileItem fi(_scheduled[i]->getFileItem()->getUrl(), 0, 0); + KFileItem fi(_scheduled[i]->getFileItem()->getUrl(), nullptr, 0); list.append(fi); _hash.insert(fi, _scheduled[i]); } @@ -122,10 +122,10 @@ { (void) job; - if(!disconnect(_job, 0, this, 0)) + if(!disconnect(_job, nullptr, this, nullptr)) abort(); - _job = 0; + _job = nullptr; _hash.clear(); if(_scheduled.isEmpty()) @@ -151,11 +151,11 @@ { _timer.stop(); if(_job) { - if(!disconnect(_job, 0, this, 0)) + if(!disconnect(_job, nullptr, this, nullptr)) abort(); if(!_job->kill()) abort(); - _job = 0; + _job = nullptr; } _hash.clear(); return true; diff --git a/krusader/Panel/krpreviewpopup.h b/krusader/Panel/krpreviewpopup.h --- a/krusader/Panel/krpreviewpopup.h +++ b/krusader/Panel/krpreviewpopup.h @@ -44,7 +44,7 @@ void view(QAction *); protected: - virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; QAction * prevNotAvailAction; QList files; diff --git a/krusader/Panel/krpreviewpopup.cpp b/krusader/Panel/krpreviewpopup.cpp --- a/krusader/Panel/krpreviewpopup.cpp +++ b/krusader/Panel/krpreviewpopup.cpp @@ -41,11 +41,11 @@ public: ProxyStyle() : QProxyStyle(QApplication::style()) {} - virtual QSize sizeFromContents(ContentsType type, const QStyleOption *option, - const QSize &contentsSize, const QWidget *widget = 0) const Q_DECL_OVERRIDE + QSize sizeFromContents(ContentsType type, const QStyleOption *option, + const QSize &contentsSize, const QWidget *widget = nullptr) const Q_DECL_OVERRIDE { if(type == QStyle::CT_MenuItem) { - const QStyleOptionMenuItem *menuItem = + const auto *menuItem = qstyleoption_cast(option); QFontMetrics fontMetrics(menuItem->font); @@ -59,13 +59,13 @@ return QProxyStyle::sizeFromContents(type, option, contentsSize, widget); } - virtual void drawControl(ControlElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget = 0 ) const Q_DECL_OVERRIDE + void drawControl(ControlElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget = nullptr ) const Q_DECL_OVERRIDE { if(element == QStyle::CE_MenuItem) { painter->save(); - const QStyleOptionMenuItem *menuItem = + const auto *menuItem = qstyleoption_cast(option); bool active = menuItem->state & State_Selected; @@ -135,7 +135,7 @@ if (prevNotAvailAction) { removeAction(prevNotAvailAction); delete prevNotAvailAction; - prevNotAvailAction = 0; + prevNotAvailAction = nullptr; } QAction *act = addAction(file.text()); diff --git a/krusader/Panel/krpreviews.h b/krusader/Panel/krpreviews.h --- a/krusader/Panel/krpreviews.h +++ b/krusader/Panel/krpreviews.h @@ -40,7 +40,7 @@ Q_OBJECT public: explicit KrPreviews(KrView *view); - ~KrPreviews(); + ~KrPreviews() override; bool getPreview(const FileItem* file, QPixmap &pixmap, bool active); void updatePreview(KrViewItem *item); diff --git a/krusader/Panel/krpreviews.cpp b/krusader/Panel/krpreviews.cpp --- a/krusader/Panel/krpreviews.cpp +++ b/krusader/Panel/krpreviews.cpp @@ -32,7 +32,7 @@ #define ASSERT(what) if(!what) abort(); -KrPreviews::KrPreviews(KrView *view) : _job(0), _view(view) +KrPreviews::KrPreviews(KrView *view) : _job(nullptr), _view(view) { _dim = KrColorCache::getColorCache().getDimSettings(_dimColor, _dimFactor); connect(&KrColorCache::getColorCache(), &KrColorCache::colorsRefreshed, this, &KrPreviews::slotRefreshColors); @@ -47,7 +47,7 @@ { if(_job) { _job->kill(KJob::EmitResult); - _job = 0; + _job = nullptr; } _previews.clear(); _previewsInactive.clear(); @@ -57,7 +57,7 @@ { if(_job) return; - for (KrViewItem *it = _view->getFirst(); it != 0; it = _view->getNext(it)) { + for (KrViewItem *it = _view->getFirst(); it != nullptr; it = _view->getNext(it)) { if(!_previews.contains(it->getFileItem())) updatePreview(it); } @@ -94,7 +94,7 @@ void KrPreviews::slotJobResult(KJob *job) { (void) job; - _job = 0; + _job = nullptr; } void KrPreviews::slotRefreshColors() diff --git a/krusader/Panel/krsearchbar.cpp b/krusader/Panel/krsearchbar.cpp --- a/krusader/Panel/krsearchbar.cpp +++ b/krusader/Panel/krsearchbar.cpp @@ -40,10 +40,10 @@ KrSearchBar::KrSearchBar(KrView *view, QWidget *parent) - : QWidget(parent), _view(0), _rightArrowEntersDirFlag(true) + : QWidget(parent), _view(nullptr), _rightArrowEntersDirFlag(true) { // close button - QToolButton *closeButton = new QToolButton(this); + auto *closeButton = new QToolButton(this); closeButton->setAutoRaise(true); closeButton->setIcon(Icon(QStringLiteral("dialog-close"))); closeButton->setToolTip(i18n("Close the search bar")); @@ -69,7 +69,7 @@ _textBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); connect(_textBox, &KComboBox::currentTextChanged, this, &KrSearchBar::onSearchChange); - QToolButton *saveSearchBtn = new QToolButton(this); + auto *saveSearchBtn = new QToolButton(this); saveSearchBtn->setIcon(Icon("document-save")); saveSearchBtn->setFixedSize(20, 20); saveSearchBtn->setToolTip(i18n("Save the current search string")); @@ -80,7 +80,7 @@ _openSelectDialogBtn->setFixedSize(20, 20); _openSelectDialogBtn->setToolTip(i18n("Open selection dialog")); - QHBoxLayout *layout = new QHBoxLayout(this); + auto *layout = new QHBoxLayout(this); layout->setMargin(0); layout->addWidget(closeButton); layout->addWidget(_modeBox); @@ -97,7 +97,7 @@ { if (_view) { _view->widget()->removeEventFilter(this); - disconnect(_openSelectDialogBtn, 0, 0, 0); + disconnect(_openSelectDialogBtn, nullptr, nullptr, nullptr); } _view = view; @@ -215,24 +215,16 @@ bool KrSearchBar::eventFilter(QObject *watched, QEvent *event) { - if (event->type() != QEvent::ShortcutOverride && watched == _view->widget()) { - QKeyEvent *ke = static_cast(event); - // overwrite "escape" shortcut if bar is shown - if ((ke->key() == Qt::Key_Escape) && (ke->modifiers() == Qt::NoModifier) && !isHidden()) { - ke->accept(); - handleKeyPressEvent(ke); - return true; - } - } - + // only handle KeyPress events in this method if (event->type() != QEvent::KeyPress) { return false; } qDebug() << "key press event=" << event; - QKeyEvent *ke = static_cast(event); + auto *ke = static_cast(event); auto modifiers = ke->modifiers(); + if (watched == _view->widget()) { KConfigGroup grpSv(krConfig, "Look&Feel"); const bool autoShow = grpSv.readEntry("New Style Quicksearch", _NewStyleQuicksearch); diff --git a/krusader/Panel/listpanel.h b/krusader/Panel/listpanel.h --- a/krusader/Panel/listpanel.h +++ b/krusader/Panel/listpanel.h @@ -86,10 +86,10 @@ }; // constructor create the panel, but DOESN'T fill it with data, use start() - ListPanel(QWidget *parent, AbstractPanelManager *manager, KConfigGroup cfg = KConfigGroup()); - ~ListPanel(); + ListPanel(QWidget *parent, AbstractPanelManager *manager, const KConfigGroup& cfg = KConfigGroup()); + ~ListPanel() override; - virtual void otherPanelChanged() Q_DECL_OVERRIDE; + void otherPanelChanged() Q_DECL_OVERRIDE; void start(const QUrl &url = QUrl()); @@ -164,13 +164,13 @@ void prepareToDelete(); // internal use only protected: - virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; - virtual void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE { + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE { slotFocusOnMe(); } - virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE; - virtual void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; - virtual bool eventFilter(QObject * watched, QEvent * e) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; + bool eventFilter(QObject * watched, QEvent * e) Q_DECL_OVERRIDE; void showButtonMenu(QToolButton *b); void createView(); @@ -181,16 +181,16 @@ protected slots: void slotCurrentChanged(KrViewItem *item); - void startDragging(QStringList, QPixmap); + void startDragging(const QStringList&, const QPixmap&); void slotPreviewJobStarted(KJob *job); void slotPreviewJobPercent(KJob *job, unsigned long percent); void slotPreviewJobResult(KJob *job); // those handle the in-panel refresh notifications void slotRefreshJobStarted(KIO::Job* job); void inlineRefreshInfoMessage(KJob* job, const QString &msg); void inlineRefreshListResult(KJob* job); void inlineRefreshPercent(KJob*, unsigned long); - void slotFilesystemError(QString msg); + void slotFilesystemError(const QString& msg); void newTab(KrViewItem *item); void newTab(const QUrl &url, bool nextToThis = false); void slotNavigatorUrlChanged(const QUrl &url); diff --git a/krusader/Panel/listpanel.cpp b/krusader/Panel/listpanel.cpp --- a/krusader/Panel/listpanel.cpp +++ b/krusader/Panel/listpanel.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include "dirhistoryqueue.h" #include "krcolorcache.h" @@ -96,7 +97,7 @@ class ActionButton : public QToolButton { public: - ActionButton(QWidget *parent, ListPanel *panel, QAction *action, QString text = QString()) : + ActionButton(QWidget *parent, ListPanel *panel, QAction *action, const QString& text = QString()) : QToolButton(parent), panel(panel), action(action) { setText(text); setAutoRaise(true); @@ -106,7 +107,7 @@ } protected: - virtual void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE { + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE { panel->slotFocusOnMe(); action->trigger(); } @@ -119,11 +120,11 @@ ///////////////////////////////////////////////////// // The list panel constructor // ///////////////////////////////////////////////////// -ListPanel::ListPanel(QWidget *parent, AbstractPanelManager *manager, KConfigGroup cfg) : - QWidget(parent), KrPanel(manager, this, new ListPanelFunc(this)), - panelType(-1), colorMask(255), compareMode(false), - previewJob(0), inlineRefreshJob(0), searchBar(0), cdRootButton(0), cdUpButton(0), - sidebarButton(0), sidebar(0), fileSystemError(0), _navigatorUrl(), _tabState(TabState::DEFAULT) +ListPanel::ListPanel(QWidget *parent, AbstractPanelManager *manager, const KConfigGroup &cfg) + : QWidget(parent), KrPanel(manager, this, new ListPanelFunc(this)), panelType(-1), + colorMask(255), compareMode(false), previewJob(nullptr), inlineRefreshJob(nullptr), + searchBar(nullptr), cdRootButton(nullptr), cdUpButton(nullptr), sidebarButton(nullptr), + sidebar(nullptr), fileSystemError(nullptr), _tabState(TabState::DEFAULT) { if(cfg.isValid()) panelType = cfg.readEntry("Type", -1); @@ -198,7 +199,7 @@ // toolbar QWidget * toolbar = new QWidget(this); - QHBoxLayout * toolbarLayout = new QHBoxLayout(toolbar); + auto * toolbarLayout = new QHBoxLayout(toolbar); toolbarLayout->setContentsMargins(0, 0, 0, 0); toolbarLayout->setSpacing(0); ADD_WIDGET(toolbar); @@ -210,7 +211,7 @@ // client area clientArea = new QWidget(this); - QVBoxLayout *clientLayout = new QVBoxLayout(clientArea); + auto *clientLayout = new QVBoxLayout(clientArea); clientLayout->setSpacing(0); clientLayout->setContentsMargins(0, 0, 0, 0); ADD_WIDGET(clientArea); @@ -330,11 +331,11 @@ QLayout *layout = fact.createLayout(); if(!layout) { // fallback: create a layout by ourself - QVBoxLayout *v = new QVBoxLayout; + auto *v = new QVBoxLayout; v->setContentsMargins(0, 0, 0, 0); v->setSpacing(0); - QHBoxLayout *h = new QHBoxLayout; + auto *h = new QHBoxLayout; h->setContentsMargins(0, 0, 0, 0); h->setSpacing(0); h->addWidget(urlNavigator); @@ -381,7 +382,7 @@ { cancelProgress(); delete view; - view = 0; + view = nullptr; delete func; delete status; delete bookmarksButton; @@ -514,7 +515,7 @@ if(e->type() == QEvent::FocusIn && this != ACTIVE_PANEL && !isHidden()) slotFocusOnMe(); else if(e->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast(e); + auto *ke = dynamic_cast(e); if(ke->key() == Qt::Key_Escape && ke->modifiers() == Qt::NoModifier) { // if the cancel refresh action has no shortcut assigned, // we need this event ourselves to cancel refresh @@ -529,13 +530,13 @@ else if(watched == urlNavigator->editor()) { // override default shortcut for panel focus if(e->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast(e); + auto *ke = dynamic_cast(e); if ((ke->key() == Qt::Key_Escape) && (ke->modifiers() == Qt::NoModifier)) { e->accept(); // we will get the key press event now return true; } } else if(e->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast(e); + auto *ke = dynamic_cast(e); if ((ke->key() == Qt::Key_Down) && (ke->modifiers() == Qt::ControlModifier)) { slotFocusOnMe(); return true; @@ -648,14 +649,14 @@ KrViewItem *item, *otherItem; - for (item = view->getFirst(); item != 0; item = view->getNext(item)) { + for (item = view->getFirst(); item != nullptr; item = view->getNext(item)) { if (item->name() == "..") continue; - for (otherItem = otherPanel()->view->getFirst(); otherItem != 0 && otherItem->name() != item->name(); + for (otherItem = otherPanel()->view->getFirst(); otherItem != nullptr && otherItem->name() != item->name(); otherItem = otherPanel()->view->getNext(otherItem)); - bool isSingle = (otherItem == 0), isDifferent = false, isNewer = false; + bool isSingle = (otherItem == nullptr), isDifferent = false, isNewer = false; if (func->getFileItem(item)->isDir() && !selectDirs) { item->setSelected(false); @@ -748,7 +749,7 @@ void ListPanel::slotStartUpdate(bool directoryChange) { if (inlineRefreshJob) - inlineRefreshListResult(0); + inlineRefreshListResult(nullptr); setCursor(Qt::BusyCursor); @@ -816,7 +817,7 @@ // find dropping destination QString destinationDir = ""; const bool dragFromThisPanel = event->source() == this; - const KrViewItem *item = onView ? view->getKrViewItemAt(event->pos()) : 0; + const KrViewItem *item = onView ? view->getKrViewItemAt(event->pos()) : nullptr; if (item) { const FileItem *file = item->getFileItem(); if (file && !file->isDir() && dragFromThisPanel) { @@ -848,16 +849,16 @@ func->files()->dropFiles(destination, event); } -void ListPanel::startDragging(QStringList names, QPixmap px) +void ListPanel::startDragging(const QStringList& names, const QPixmap& px) { if (names.isEmpty()) { // avoid dragging empty urls return; } QList urls = func->files()->getUrls(names); - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; + auto *drag = new QDrag(this); + auto *mimeData = new QMimeData; drag->setPixmap(px); mimeData->setUrls(urls); drag->setMimeData(mimeData); @@ -1028,7 +1029,7 @@ void ListPanel::slotPreviewJobResult(KJob* /*job*/) { - previewJob = 0; + previewJob = nullptr; previewProgress->hide(); if(!inlineRefreshJob) cancelProgressButton->hide(); @@ -1065,14 +1066,14 @@ void ListPanel::cancelProgress() { if (inlineRefreshJob) { - disconnect(inlineRefreshJob, 0, this, 0); + disconnect(inlineRefreshJob, nullptr, this, nullptr); inlineRefreshJob->kill(KJob::EmitResult); - inlineRefreshListResult(0); + inlineRefreshListResult(nullptr); } if(previewJob) { - disconnect(previewJob, 0, this, 0); + disconnect(previewJob, nullptr, this, nullptr); previewJob->kill(KJob::EmitResult); - slotPreviewJobResult(0); + slotPreviewJobResult(nullptr); } } @@ -1096,8 +1097,8 @@ void ListPanel::inlineRefreshListResult(KJob*) { if(inlineRefreshJob) - disconnect(inlineRefreshJob, 0, this, 0); - inlineRefreshJob = 0; + disconnect(inlineRefreshJob, nullptr, this, nullptr); + inlineRefreshJob = nullptr; // reenable everything status->setEnabled(true); urlNavigator->setEnabled(true); @@ -1123,10 +1124,10 @@ void ListPanel::setJumpBack(QUrl url) { - _jumpBackURL = url; + _jumpBackURL = std::move(url); } -void ListPanel::slotFilesystemError(QString msg) +void ListPanel::slotFilesystemError(const QString& msg) { slotRefreshColors(); fileSystemError->setText(i18n("Error: %1", msg)); @@ -1320,7 +1321,7 @@ void ListPanel::newTab(const QUrl &url, bool nextToThis) { - _manager->newTab(url, nextToThis ? this : 0); + _manager->newTab(url, nextToThis ? this : nullptr); } void ListPanel::slotNavigatorUrlChanged(const QUrl &url) diff --git a/krusader/Panel/listpanelactions.cpp b/krusader/Panel/listpanelactions.cpp --- a/krusader/Panel/listpanelactions.cpp +++ b/krusader/Panel/listpanelactions.cpp @@ -41,9 +41,9 @@ ActionsBase(parent, mainWindow) { // set view type - QSignalMapper *mapper = new QSignalMapper(this); + auto *mapper = new QSignalMapper(this); connect(mapper, QOverload::of(&QSignalMapper::mapped), this, &ListPanelActions::setView); - QActionGroup *group = new QActionGroup(this); + auto *group = new QActionGroup(this); group->setExclusive(true); QList views = KrViewFactory::registeredViews(); for(int i = 0; i < views.count(); i++) { @@ -79,58 +79,58 @@ // Fn keys actRenameF2 = action(i18n("Rename"), "edit-rename", Qt::Key_F2, _func, SLOT(rename()) , "F2_Rename"); - actViewFileF3 = action(i18n("View File"), 0, Qt::Key_F3, _func, SLOT(view()), "F3_View"); - actEditFileF4 = action(i18n("Edit File"), 0, Qt::Key_F4, _func, SLOT(edit()) , "F4_Edit"); - actCopyF5 = action(i18n("Copy to other panel"), 0, Qt::Key_F5, _func, SLOT(copyFiles()) , "F5_Copy"); - actMoveF6 = action(i18n("Move to other panel"), 0, Qt::Key_F6, _func, SLOT(moveFiles()) , "F6_Move"); - actCopyDelayedF5 = action(i18n("Copy delayed..."), 0, Qt::SHIFT + Qt::Key_F5, _func, SLOT(copyFilesDelayed()) , "F5_Copy_Queue"); - actMoveDelayedShiftF6 = action(i18n("Move delayed..."), 0, Qt::SHIFT + Qt::Key_F6, _func, SLOT(moveFilesDelayed()) , "F6_Move_Queue"); + actViewFileF3 = action(i18n("View File"), nullptr, Qt::Key_F3, _func, SLOT(view()), "F3_View"); + actEditFileF4 = action(i18n("Edit File"), nullptr, Qt::Key_F4, _func, SLOT(edit()) , "F4_Edit"); + actCopyF5 = action(i18n("Copy to other panel"), nullptr, Qt::Key_F5, _func, SLOT(copyFiles()) , "F5_Copy"); + actMoveF6 = action(i18n("Move to other panel"), nullptr, Qt::Key_F6, _func, SLOT(moveFiles()) , "F6_Move"); + actCopyDelayedF5 = action(i18n("Copy delayed..."), nullptr, Qt::SHIFT + Qt::Key_F5, _func, SLOT(copyFilesDelayed()) , "F5_Copy_Queue"); + actMoveDelayedShiftF6 = action(i18n("Move delayed..."), nullptr, Qt::SHIFT + Qt::Key_F6, _func, SLOT(moveFilesDelayed()) , "F6_Move_Queue"); actNewFolderF7 = action(i18n("New Folder..."), "folder-new", Qt::Key_F7, _func, SLOT(mkdir()) , "F7_Mkdir"); actDeleteF8 = action(i18n("Delete"), "edit-delete", Qt::Key_F8, _func, SLOT(defaultDeleteFiles()) , "F8_Delete"); actTerminalF9 = action(i18n("Start Terminal Here"), "utilities-terminal", Qt::Key_F9, _func, SLOT(terminal()) , "F9_Terminal"); action(i18n("&New Text File..."), "document-new", Qt::SHIFT + Qt::Key_F4, _func, SLOT(editNew()), "edit_new_file"); - action(i18n("F3 View Dialog"), 0, Qt::SHIFT + Qt::Key_F3, _func, SLOT(viewDlg()), "F3_ViewDlg"); + action(i18n("F3 View Dialog"), nullptr, Qt::SHIFT + Qt::Key_F3, _func, SLOT(viewDlg()), "F3_ViewDlg"); // file operations - action(i18n("Right-click Menu"), 0, Qt::Key_Menu, _gui, SLOT(rightclickMenu()), "rightclick menu"); + action(i18n("Right-click Menu"), nullptr, Qt::Key_Menu, _gui, SLOT(rightclickMenu()), "rightclick menu"); actProperties = action(i18n("&Properties..."), "document-properties", Qt::ALT + Qt::Key_Return, _func, SLOT(properties()), "properties"); actCompDirs = action(i18n("&Compare Folders"), "kr_comparedirs", Qt::ALT + Qt::SHIFT + Qt::Key_C, _gui, SLOT(compareDirs()), "compare dirs"); actCalculate = action(i18n("Calculate &Occupied Space"), "accessories-calculator", 0, _func, SLOT(calcSpace()), "calculate"); actPack = action(i18n("Pac&k..."), "archive-insert", Qt::ALT + Qt::SHIFT + Qt::Key_P, _func, SLOT(pack()), "pack"); actUnpack = action(i18n("&Unpack..."), "archive-extract", Qt::ALT + Qt::SHIFT + Qt::Key_U, _func, SLOT(unpack()), "unpack"); actCreateChecksum = action(i18n("Create Checksum..."), "document-edit-sign", 0, _func, SLOT(createChecksum()), "create checksum"); actMatchChecksum = action(i18n("Verify Checksum..."), "document-edit-decrypt-verify", 0, _func, SLOT(matchChecksum()), "match checksum"); - action(i18n("New Symlink..."), 0, Qt::CTRL + Qt::ALT + Qt::Key_S, _func, SLOT(krlink()), "new symlink"); + action(i18n("New Symlink..."), nullptr, Qt::CTRL + Qt::ALT + Qt::Key_S, _func, SLOT(krlink()), "new symlink"); actTest = action(i18n("T&est Archive"), "archive-extract", Qt::ALT + Qt::SHIFT + Qt::Key_E, _func, SLOT(testArchive()), "test archives"); action(i18n("Alternative Delete"), "edit-delete", Qt::Key_Delete + Qt::CTRL, _func, SLOT(alternativeDeleteFiles()), "alternative delete"); // navigation actRoot = action(i18n("Root"), "folder-red", Qt::CTRL + Qt::Key_Backspace, _func, SLOT(root()), "root"); - actCdToOther = action(i18n("Go to Other Panel's Folder"), 0, Qt::CTRL + Qt::Key_Equal, _func, SLOT(cdToOtherPanel()), "cd to other panel"); + actCdToOther = action(i18n("Go to Other Panel's Folder"), nullptr, Qt::CTRL + Qt::Key_Equal, _func, SLOT(cdToOtherPanel()), "cd to other panel"); action(i18n("&Reload"), "view-refresh", Qt::CTRL + Qt::Key_R, _func, SLOT(refresh()), "std_redisplay"); actCancelRefresh = action(i18n("Cancel Refresh of View"), "dialog-cancel", 0, _gui, SLOT(cancelProgress()), "cancel refresh"); actFTPNewConnect = action(i18n("New Net &Connection..."), "network-connect", Qt::CTRL + Qt::Key_N, _func, SLOT(newFTPconnection()), "ftp new connection"); actFTPDisconnect = action(i18n("Disconnect &from Net"), "network-disconnect", Qt::SHIFT + Qt::CTRL + Qt::Key_D, _func, SLOT(FTPDisconnect()), "ftp disconnect"); - action(i18n("Sync Panels"), 0, Qt::ALT + Qt::SHIFT + Qt::Key_O, _func, SLOT(syncOtherPanel()), "sync panels"); + action(i18n("Sync Panels"), nullptr, Qt::ALT + Qt::SHIFT + Qt::Key_O, _func, SLOT(syncOtherPanel()), "sync panels"); actJumpBack = action(i18n("Jump Back"), "go-jump", Qt::CTRL + Qt::Key_J, _gui, SLOT(jumpBack()), "jump_back"); actSetJumpBack = action(i18n("Set Jump Back Point"), "go-jump-definition", Qt::CTRL + Qt::SHIFT + Qt::Key_J, _gui, SLOT(setJumpBack()), "set_jump_back"); actSyncBrowse = action(i18n("S&ynchron Folder Changes"), "kr_syncbrowse_off", Qt::ALT + Qt::SHIFT + Qt::Key_Y, _gui, SLOT(toggleSyncBrowse()), "sync browse"); - actLocationBar = action(i18n("Go to Location Bar"), 0, Qt::CTRL + Qt::Key_L, _gui, SLOT(editLocation()), "location_bar"); - toggleAction(i18n("Toggle Sidebar"), 0, Qt::ALT + Qt::Key_Down, _gui, SLOT(toggleSidebar()), "toggle sidebar"); - action(i18n("Bookmarks"), 0, Qt::CTRL + Qt::Key_D, _gui, SLOT(openBookmarks()), "bookmarks"); - action(i18n("Left Bookmarks"), 0, 0, this, SLOT(openLeftBookmarks()), "left bookmarks"); - action(i18n("Right Bookmarks"), 0, 0, this, SLOT(openRightBookmarks()), "right bookmarks"); - action(i18n("History"), 0, Qt::CTRL + Qt::Key_H, _gui, SLOT(openHistory()), "history"); - action(i18n("Left History"), 0, Qt::ALT + Qt::CTRL + Qt::Key_Left, this, SLOT(openLeftHistory()), "left history"); - action(i18n("Right History"), 0, Qt::ALT + Qt::CTRL + Qt::Key_Right, this, SLOT(openRightHistory()), "right history"); - action(i18n("Media"), 0, Qt::CTRL + Qt::Key_M, _gui, SLOT(openMedia()), "media"); - action(i18n("Left Media"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Left, this, SLOT(openLeftMedia()), "left media"); - action(i18n("Right Media"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Right, this, SLOT(openRightMedia()), "right media"); + actLocationBar = action(i18n("Go to Location Bar"), nullptr, Qt::CTRL + Qt::Key_L, _gui, SLOT(editLocation()), "location_bar"); + toggleAction(i18n("Toggle Sidebar"), nullptr, Qt::ALT + Qt::Key_Down, _gui, SLOT(toggleSidebar()), "toggle sidebar"); + action(i18n("Bookmarks"), nullptr, Qt::CTRL + Qt::Key_D, _gui, SLOT(openBookmarks()), "bookmarks"); + action(i18n("Left Bookmarks"), nullptr, 0, this, SLOT(openLeftBookmarks()), "left bookmarks"); + action(i18n("Right Bookmarks"), nullptr, 0, this, SLOT(openRightBookmarks()), "right bookmarks"); + action(i18n("History"), nullptr, Qt::CTRL + Qt::Key_H, _gui, SLOT(openHistory()), "history"); + action(i18n("Left History"), nullptr, Qt::ALT + Qt::CTRL + Qt::Key_Left, this, SLOT(openLeftHistory()), "left history"); + action(i18n("Right History"), nullptr, Qt::ALT + Qt::CTRL + Qt::Key_Right, this, SLOT(openRightHistory()), "right history"); + action(i18n("Media"), nullptr, Qt::CTRL + Qt::Key_M, _gui, SLOT(openMedia()), "media"); + action(i18n("Left Media"), nullptr, Qt::CTRL + Qt::SHIFT + Qt::Key_Left, this, SLOT(openLeftMedia()), "left media"); + action(i18n("Right Media"), nullptr, Qt::CTRL + Qt::SHIFT + Qt::Key_Right, this, SLOT(openRightMedia()), "right media"); // quick search bar - action(i18n("Find in folder..."), 0, Qt::CTRL + Qt::Key_F, _gui, SLOT(showSearchBar()), "search bar"); - action(i18n("Select in folder..."), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_S, _gui, SLOT(showSearchBarSelection()), "search bar selection"); - action(i18n("Filter in folder..."), 0, Qt::CTRL + Qt::Key_I, _gui, SLOT(showSearchBarFilter()), "search bar filter"); + action(i18n("Find in folder..."), nullptr, Qt::CTRL + Qt::Key_F, _gui, SLOT(showSearchBar()), "search bar"); + action(i18n("Select in folder..."), nullptr, Qt::CTRL + Qt::SHIFT + Qt::Key_S, _gui, SLOT(showSearchBarSelection()), "search bar selection"); + action(i18n("Filter in folder..."), nullptr, Qt::CTRL + Qt::Key_I, _gui, SLOT(showSearchBarFilter()), "search bar filter"); // and at last we can set the tool-tips actRoot->setToolTip(i18n("ROOT (/)")); diff --git a/krusader/Panel/listpanelframe.h b/krusader/Panel/listpanelframe.h --- a/krusader/Panel/listpanelframe.h +++ b/krusader/Panel/listpanelframe.h @@ -34,7 +34,7 @@ { Q_OBJECT public: - ListPanelFrame(QWidget *parent, QString color); + ListPanelFrame(QWidget *parent, const QString& color); signals: void dropped(QDropEvent*, QWidget*); /**< emitted when someone drops URL onto the frame */ @@ -46,12 +46,12 @@ void refreshColors(bool active); protected: - QColor getColor(KConfigGroup &cg, QString name, const QColor &def, const QColor &kdedef); + QColor getColor(KConfigGroup &cg, const QString& name, const QColor &def, const QColor &kdedef); - virtual void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE { + void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE { emit dropped(e, this); } - virtual void dragEnterEvent(QDragEnterEvent*) Q_DECL_OVERRIDE; + void dragEnterEvent(QDragEnterEvent*) Q_DECL_OVERRIDE; QString color; QPalette palActive, palInactive; diff --git a/krusader/Panel/listpanelframe.cpp b/krusader/Panel/listpanelframe.cpp --- a/krusader/Panel/listpanelframe.cpp +++ b/krusader/Panel/listpanelframe.cpp @@ -32,7 +32,7 @@ #include #include -ListPanelFrame::ListPanelFrame(QWidget *parent, QString color) : QFrame(parent), color(color) +ListPanelFrame::ListPanelFrame(QWidget *parent, const QString& color) : QFrame(parent), color(color) { if(!color.isEmpty()) { colorsChanged(); @@ -54,8 +54,8 @@ void ListPanelFrame::colorsChanged() { QPalette p = QGuiApplication::palette(); - QColor windowForeground = p.color(QPalette::Active, QPalette::WindowText); - QColor windowBackground = p.color(QPalette::Active, QPalette::Window); + const QColor& windowForeground = p.color(QPalette::Active, QPalette::WindowText); + const QColor& windowBackground = p.color(QPalette::Active, QPalette::Window); KConfigGroup gc(krConfig, "Colors"); QColor fgAct = getColor(gc, color + " Foreground Active", @@ -97,7 +97,7 @@ setPalette(active ? palActive : palInactive); } -QColor ListPanelFrame::getColor(KConfigGroup &cg, QString name, const QColor &def, const QColor &kdedef) +QColor ListPanelFrame::getColor(KConfigGroup &cg, const QString& name, const QColor &def, const QColor &kdedef) { if (cg.readEntry(name, QString()) == "KDE default") return kdedef; diff --git a/krusader/Panel/panelcontextmenu.h b/krusader/Panel/panelcontextmenu.h --- a/krusader/Panel/panelcontextmenu.h +++ b/krusader/Panel/panelcontextmenu.h @@ -43,7 +43,7 @@ static void run(const QPoint &pos, KrPanel *panel); private: - explicit PanelContextMenu(KrPanel *thePanel, QWidget *parent = 0); + explicit PanelContextMenu(KrPanel *thePanel, QWidget *parent = nullptr); void performAction(int id); void addEmptyMenuEntries(); // adds the choices for a menu without selected items void addCreateNewMenu(); // adds a "create new" submenu diff --git a/krusader/Panel/panelcontextmenu.cpp b/krusader/Panel/panelcontextmenu.cpp --- a/krusader/Panel/panelcontextmenu.cpp +++ b/krusader/Panel/panelcontextmenu.cpp @@ -78,7 +78,7 @@ }); foreach (const KPluginMetaData &jsonMetadata, jsonPlugins) { - KAbstractFileItemActionPlugin* abstractPlugin = KPluginLoader(jsonMetadata.fileName()) + auto* abstractPlugin = KPluginLoader(jsonMetadata.fileName()) .factory()->create(); if (abstractPlugin) { abstractPlugin->setParent(this); @@ -95,7 +95,7 @@ // file items QList files; - for (const QString fileName : fileNames) { + for (const QString& fileName : fileNames) { files.append(panel->func->files()->getFileItem(fileName)); } @@ -177,7 +177,7 @@ KFileItemActions::associatedApplications(mimeTypes, QString()); if (!offers.isEmpty()) { - QMenu *openWithMenu = new QMenu(this); + auto *openWithMenu = new QMenu(this); for (int i = 0; i < offers.count(); ++i) { QExplicitlySharedDataPointer service = offers[i]; if (service->isValid() && service->isApplication()) { @@ -211,7 +211,7 @@ // NOTE: design and usability problem here. Services disabled in kservicemenurc settings won't // be added to the menu. But Krusader does not provide a way do change these settings (only // Dolphin does). - KFileItemActions *fileItemActions = new KFileItemActions(this); + auto *fileItemActions = new KFileItemActions(this); fileItemActions->setItemListProperties(KFileItemListProperties(_items)); fileItemActions->setParentWidget(MAIN_VIEW); fileItemActions->addServiceActionsTo(this); @@ -249,7 +249,7 @@ // create new shortcut or redirect links - only on local directories: if (panel->func->files()->isLocal()) { addSeparator(); - QMenu *linkMenu = new QMenu(this); + auto *linkMenu = new QMenu(this); linkMenu->addAction(i18n("New Symlink..."))->setData(QVariant(NEW_SYMLINK_ID)); linkMenu->addAction(i18n("New Hardlink..."))->setData(QVariant(NEW_LINK_ID)); if (file->isSymLink()) { @@ -313,7 +313,7 @@ void PanelContextMenu::addCreateNewMenu() { - QMenu *createNewMenu = new QMenu(this); + auto *createNewMenu = new QMenu(this); createNewMenu->addAction(Icon("folder"), i18n("Folder..."))->setData(QVariant(MKDIR_ID)); @@ -404,13 +404,13 @@ #ifdef SYNCHRONIZER_ENABLED case SYNC_SELECTED_ID : { QStringList selectedNames; - for (const KFileItem item : _items) { + for (const KFileItem& item : _items) { selectedNames.append(item.name()); } KrViewItemList otherItems; panel->otherPanel()->view->getSelectedKrViewItems(&otherItems); for (KrViewItem *otherItem : otherItems) { - const QString name = otherItem->name(); + const QString& name = otherItem->name(); if (!selectedNames.contains(name)) { selectedNames.append(name); } diff --git a/krusader/Panel/panelfunc.h b/krusader/Panel/panelfunc.h --- a/krusader/Panel/panelfunc.h +++ b/krusader/Panel/panelfunc.h @@ -105,7 +105,7 @@ public: explicit ListPanelFunc(ListPanel *parent); - ~ListPanelFunc(); + ~ListPanelFunc() override; FileSystem* files(); // return a pointer to the filesystem QUrl virtualDirectory(); // return the current URL (simulated when panel is paused) @@ -115,8 +115,8 @@ void refreshActions(); void redirectLink(); - void runService(const KService &service, QList urls); - void displayOpenWithDialog(QList urls); + void runService(const KService &service, const QList& urls); + void displayOpenWithDialog(const QList& urls); QUrl browsableArchivePath(const QString &); void deleteFiles(bool moveToTrash); @@ -144,7 +144,7 @@ void immediateOpenUrl(const QUrl &url); void openUrlInternal(const QUrl &url, const QString& makeCurrent, bool immediately, bool manuallyEntered); - void runCommand(QString cmd); + void runCommand(const QString& cmd); ListPanel* panel; // our ListPanel DirHistoryQueue* history; diff --git a/krusader/Panel/panelfunc.cpp b/krusader/Panel/panelfunc.cpp --- a/krusader/Panel/panelfunc.cpp +++ b/krusader/Panel/panelfunc.cpp @@ -85,8 +85,8 @@ QPointer ListPanelFunc::copyToClipboardOrigin; ListPanelFunc::ListPanelFunc(ListPanel *parent) : QObject(parent), - panel(parent), fileSystemP(0), urlManuallyEntered(false), - _isPaused(true), _refreshAfterPaused(true), _quickSizeCalculator(0) + panel(parent), fileSystemP(nullptr), urlManuallyEntered(false), + _isPaused(true), _refreshAfterPaused(true), _quickSizeCalculator(nullptr) { history = new DirHistoryQueue(panel); delayTimer.setSingleShot(true); @@ -122,7 +122,7 @@ } FileItem *fileitem = files()->getFileItem(name); - if (fileitem == 0) + if (fileitem == nullptr) return; QUrl url = files()->getUrl(name); @@ -275,10 +275,10 @@ fileSystem->setParentWindow(krMainWindow); connect(fileSystem, &FileSystem::aboutToOpenDir, &krMtMan, &KMountMan::autoMount, Qt::DirectConnection); if (fileSystem != fileSystemP) { - panel->view->setFiles(0); + panel->view->setFiles(nullptr); // disconnect older signals - disconnect(fileSystemP, 0, panel, 0); + disconnect(fileSystemP, nullptr, panel, nullptr); fileSystemP->deleteLater(); fileSystemP = fileSystem; // v != 0 so this is safe @@ -290,7 +290,7 @@ } } // (re)connect filesystem signals - disconnect(files(), 0, panel, 0); + disconnect(files(), nullptr, panel, nullptr); connect(files(), &DirListerInterface::scanDone, panel, &ListPanel::slotStartUpdate); connect(files(), &FileSystem::fileSystemInfoChanged, panel, &ListPanel::updateFilesystemStats); connect(files(), &FileSystem::refreshJobStarted, panel, &ListPanel::slotRefreshJobStarted); @@ -413,7 +413,7 @@ return; // if the name is already taken - quit - if (files()->getFileItem(linkName) != 0) { + if (files()->getFileItem(linkName) != nullptr) { KMessageBox::sorry(krMainWindow, i18n("A folder or a file with this name already exists.")); return; } @@ -447,7 +447,7 @@ if (!fileitem || fileitem->isDir()) return; if (!fileitem->isReadable()) { - KMessageBox::sorry(0, i18n("No permissions to view this file.")); + KMessageBox::sorry(nullptr, i18n("No permissions to view this file.")); return; } // call KViewer. @@ -491,7 +491,7 @@ } if (!tmp.isReadable()) { - KMessageBox::sorry(0, i18n("No permissions to edit this file.")); + KMessageBox::sorry(nullptr, i18n("No permissions to edit this file.")); fileToCreate = QUrl(); return; } @@ -516,11 +516,11 @@ if(f.exists()) { edit(); } else { - QTemporaryFile *tempFile = new QTemporaryFile; + auto *tempFile = new QTemporaryFile; tempFile->open(); KIO::CopyJob *job = KIO::copy(QUrl::fromLocalFile(tempFile->fileName()), fileToCreate); - job->setUiDelegate(0); + job->setUiDelegate(nullptr); job->setDefaultPermissions(true); connect(job, &KIO::CopyJob::result, this, &ListPanelFunc::slotFileCreated); connect(job, &KIO::CopyJob::result, tempFile, &QTemporaryFile::deleteLater); @@ -716,7 +716,7 @@ bool virtualFS, bool showPath) { QStringList files; - for (QUrl fileUrl : urls) { + for (const QUrl& fileUrl : urls) { files.append(showPath ? fileUrl.toDisplayString(QUrl::PreferLocalFile) : fileUrl.fileName()); } @@ -756,7 +756,7 @@ QList toDelete; if (emptyDirVerify) { QSet confirmedFiles = urls.toSet(); - for (QUrl fileUrl : urls) { + for (const QUrl& fileUrl : urls) { if (!fileUrl.isLocalFile()) { continue; // TODO only local fs supported } @@ -816,36 +816,36 @@ KStandardGuiItem::remove()) != KMessageBox::Continue) return; - VirtualFileSystem *fileSystem = static_cast(files()); + auto *fileSystem = dynamic_cast(files()); fileSystem->remove(fileNames); } void ListPanelFunc::goInside(const QString& name) { openFileNameInternal(name, false); } -void ListPanelFunc::runCommand(QString cmd) +void ListPanelFunc::runCommand(const QString& cmd) { qDebug() << "command=" << cmd; const QString workdir = panel->virtualPath().isLocalFile() ? panel->virtualPath().path() : QDir::homePath(); if(!KRun::runCommand(cmd, krMainWindow, workdir)) - KMessageBox::error(0, i18n("Could not start %1", cmd)); + KMessageBox::error(nullptr, i18n("Could not start %1", cmd)); } -void ListPanelFunc::runService(const KService &service, QList urls) +void ListPanelFunc::runService(const KService &service, const QList& urls) { qDebug() << "service name=" << service.name(); KIO::DesktopExecParser parser(service, urls); QStringList args = parser.resultingArguments(); if (!args.isEmpty()) runCommand(KShell::joinArgs(args)); else - KMessageBox::error(0, i18n("%1 cannot open %2", service.name(), KrServices::toStringList(urls).join(", "))); + KMessageBox::error(nullptr, i18n("%1 cannot open %2", service.name(), KrServices::toStringList(urls).join(", "))); } -void ListPanelFunc::displayOpenWithDialog(QList urls) +void ListPanelFunc::displayOpenWithDialog(const QList& urls) { // NOTE: we are not using KRun::displayOpenWithDialog() because we want the commands working // directory to be the panel directory @@ -1044,7 +1044,7 @@ SizeCalculator *ListPanelFunc::createAndConnectSizeCalculator(const QList &urls) { - SizeCalculator *sizeCalculator = new SizeCalculator(urls); + auto *sizeCalculator = new SizeCalculator(urls); connect(sizeCalculator, &SizeCalculator::calculated, this, &ListPanelFunc::slotSizeCalculated); connect(sizeCalculator, &SizeCalculator::finished, panel, &ListPanel::slotUpdateTotals); connect(this, &ListPanelFunc::destroyed, sizeCalculator, &SizeCalculator::deleteLater); @@ -1094,7 +1094,7 @@ KFileItemList fileItems; - for (const QString name : names) { + for (const QString& name : names) { FileItem *fileitem = files()->getFileItem(name); if (!fileitem) { continue; @@ -1107,7 +1107,7 @@ return; // Show the properties dialog - KPropertiesDialog *dialog = new KPropertiesDialog(fileItems, krMainWindow); + auto *dialog = new KPropertiesDialog(fileItems, krMainWindow); connect(dialog, &KPropertiesDialog::applied, this, &ListPanelFunc::refresh); dialog->show(); } @@ -1177,8 +1177,8 @@ void ListPanelFunc::clipboardChanged(QClipboard::Mode mode) { if (mode == QClipboard::Clipboard && this == copyToClipboardOrigin) { - disconnect(QApplication::clipboard(), 0, this, 0); - copyToClipboardOrigin = 0; + disconnect(QApplication::clipboard(), nullptr, this, nullptr); + copyToClipboardOrigin = nullptr; } } @@ -1189,12 +1189,12 @@ return ; // safety QList fileUrls = files()->getUrls(fileNames); - QMimeData *mimeData = new QMimeData; + auto *mimeData = new QMimeData; mimeData->setData("application/x-kde-cutselection", move ? "1" : "0"); mimeData->setUrls(fileUrls); if (copyToClipboardOrigin) - disconnect(QApplication::clipboard(), 0, copyToClipboardOrigin, 0); + disconnect(QApplication::clipboard(), nullptr, copyToClipboardOrigin, nullptr); copyToClipboardOrigin = this; QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); @@ -1206,12 +1206,12 @@ { QClipboard * cb = QApplication::clipboard(); - ListPanelFunc *origin = 0; + ListPanelFunc *origin = nullptr; if (copyToClipboardOrigin) { - disconnect(QApplication::clipboard(), 0, copyToClipboardOrigin, 0); + disconnect(QApplication::clipboard(), nullptr, copyToClipboardOrigin, nullptr); origin = copyToClipboardOrigin; - copyToClipboardOrigin = 0; + copyToClipboardOrigin = nullptr; } bool move = false; @@ -1228,7 +1228,7 @@ if(origin && KConfigGroup(krConfig, "Look&Feel").readEntry("UnselectBeforeOperation", _UnselectBeforeOperation)) { origin->panel->view->saveSelection(); - for(KrViewItem *item = origin->panel->view->getFirst(); item != 0; item = origin->panel->view->getNext(item)) { + for(KrViewItem *item = origin->panel->view->getFirst(); item != nullptr; item = origin->panel->view->getNext(item)) { if (urls.contains(item->getFileItem()->getUrl())) item->setSelected(false); } diff --git a/krusader/Panel/sidebar.h b/krusader/Panel/sidebar.h --- a/krusader/Panel/sidebar.h +++ b/krusader/Panel/sidebar.h @@ -62,11 +62,11 @@ public: explicit Sidebar(QWidget *parent); - ~Sidebar(); + ~Sidebar() override; inline int currentPage() const { return stack->currentWidget()->property("KrusaderWidgetId").toInt(); } - void saveSettings(KConfigGroup cfg) const; + void saveSettings(const KConfigGroup& cfg) const; void restoreSettings(const KConfigGroup &cfg); void setCurrentPage(int); @@ -85,7 +85,7 @@ void handleOpenUrlRequest(const QUrl &url); protected: - virtual void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE; bool _hidden; QStackedWidget *stack; diff --git a/krusader/Panel/sidebar.cpp b/krusader/Panel/sidebar.cpp --- a/krusader/Panel/sidebar.cpp +++ b/krusader/Panel/sidebar.cpp @@ -46,9 +46,9 @@ #include -Sidebar::Sidebar(QWidget *parent) : QWidget(parent), stack(0), imageFilePreview(0), pjob(0) +Sidebar::Sidebar(QWidget *parent) : QWidget(parent), stack(nullptr), imageFilePreview(nullptr), pjob(nullptr) { - QGridLayout * layout = new QGridLayout(this); + auto * layout = new QGridLayout(this); layout->setContentsMargins(0, 0, 0, 0); // create the label+buttons setup @@ -139,9 +139,9 @@ setCurrentPage(0); } -Sidebar::~Sidebar() {} +Sidebar::~Sidebar() = default; -void Sidebar::saveSettings(KConfigGroup cfg) const +void Sidebar::saveSettings(const KConfigGroup& cfg) const { tree->saveSettings(cfg); } @@ -204,7 +204,7 @@ void Sidebar::tabSelected(int id) { QUrl url; - const FileItem *fileitem = 0; + const FileItem *fileitem = nullptr; if (ACTIVE_PANEL && ACTIVE_PANEL->view) fileitem = ACTIVE_PANEL->func->files()->getFileItem(ACTIVE_PANEL->view->getCurrentItem()); if(fileitem) diff --git a/krusader/Panel/viewactions.cpp b/krusader/Panel/viewactions.cpp --- a/krusader/Panel/viewactions.cpp +++ b/krusader/Panel/viewactions.cpp @@ -35,27 +35,27 @@ actDefaultZoom = action(i18n("Default Zoom"), "zoom-original", 0, SLOT(defaultZoom()), "default_zoom"); // filter - action(i18n("&All Files"), 0, Qt::SHIFT + Qt::Key_F10, SLOT(allFilter()), "all files"); + action(i18n("&All Files"), nullptr, Qt::SHIFT + Qt::Key_F10, SLOT(allFilter()), "all files"); //actExecFilter = new QAction( i18n( "&Executables" ), SHIFT + Qt::Key_F11, // SLOTS, SLOT(execFilter()), actionCollection(), "exec files" ); - action(i18n("&Custom"), 0, Qt::SHIFT + Qt::Key_F12, SLOT(customFilter()), "custom files"); + action(i18n("&Custom"), nullptr, Qt::SHIFT + Qt::Key_F12, SLOT(customFilter()), "custom files"); // selection actSelect = action(i18n("Select &Group..."), "edit-select", Qt::CTRL + Qt::Key_Plus, SLOT(markGroup()), "select group"); actSelectAll = action(i18n("&Select All"), "edit-select-all", Qt::ALT + Qt::Key_Plus, SLOT(markAll()), "select all"); actUnselect = action(i18n("&Unselect Group..."), "kr_unselect", Qt::CTRL + Qt::Key_Minus, SLOT(unmarkGroup()), "unselect group"); actUnselectAll = action(i18n("U&nselect All"), "edit-select-none", Qt::ALT + Qt::Key_Minus, SLOT(unmarkAll()), "unselect all"); actInvert = action(i18n("&Invert Selection"), "edit-select-invert", Qt::ALT + Qt::Key_Asterisk, SLOT(invertSelection()), "invert"); - actRestoreSelection = action(i18n("Restore Selection"), 0, 0, SLOT(restoreSelection()), "restore_selection"); - actMarkSameBaseName = action(i18n("Select Files with the Same Name"), 0, 0, SLOT(markSameBaseName()), "select_same_base_name"); - actMarkSameExtension = action(i18n("Select Files with the Same Extension"), 0, 0, SLOT(markSameExtension()), "select_same_extension"); + actRestoreSelection = action(i18n("Restore Selection"), nullptr, 0, SLOT(restoreSelection()), "restore_selection"); + actMarkSameBaseName = action(i18n("Select Files with the Same Name"), nullptr, 0, SLOT(markSameBaseName()), "select_same_base_name"); + actMarkSameExtension = action(i18n("Select Files with the Same Extension"), nullptr, 0, SLOT(markSameExtension()), "select_same_extension"); // other stuff - action(i18n("Show View Options Menu"), 0, 0, SLOT(showOptionsMenu()), "show_view_options_menu"); - action(i18n("Set Focus to the Panel"), 0, 0, SLOT(focusPanel()), "focus_panel"); - action(i18n("Apply settings to other tabs"), 0, 0, SLOT(applySettingsToOthers()), "view_apply_settings_to_others"); - actTogglePreviews = toggleAction(i18n("Show Previews"), 0, 0, SLOT(togglePreviews(bool)), "toggle previews"); - QAction *actSaveaveDefaultSettings = action(i18n("Save settings as default"), 0, 0, SLOT(saveDefaultSettings()), "view_save_default_settings"); + action(i18n("Show View Options Menu"), nullptr, 0, SLOT(showOptionsMenu()), "show_view_options_menu"); + action(i18n("Set Focus to the Panel"), nullptr, 0, SLOT(focusPanel()), "focus_panel"); + action(i18n("Apply settings to other tabs"), nullptr, 0, SLOT(applySettingsToOthers()), "view_apply_settings_to_others"); + actTogglePreviews = toggleAction(i18n("Show Previews"), nullptr, 0, SLOT(togglePreviews(bool)), "toggle previews"); + QAction *actSaveaveDefaultSettings = action(i18n("Save settings as default"), nullptr, 0, SLOT(saveDefaultSettings()), "view_save_default_settings"); // tooltips actSelect->setToolTip(i18n("Select group")); diff --git a/krusader/Search/krsearchdialog.h b/krusader/Search/krsearchdialog.h --- a/krusader/Search/krsearchdialog.h +++ b/krusader/Search/krsearchdialog.h @@ -48,8 +48,8 @@ { Q_OBJECT public: - explicit KrSearchDialog(QString profile = QString(), QWidget* parent = 0); - ~KrSearchDialog(); + explicit KrSearchDialog(const QString& profile = QString(), QWidget* parent = nullptr); + ~KrSearchDialog() override; void prepareGUI(); @@ -66,9 +66,9 @@ void currentChanged(KrViewItem *item); void contextMenu(const QPoint &); - virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; - virtual void closeEvent(QCloseEvent *e) Q_DECL_OVERRIDE; - virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent *e) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; protected slots: void reject() Q_DECL_OVERRIDE; diff --git a/krusader/Search/krsearchdialog.cpp b/krusader/Search/krsearchdialog.cpp --- a/krusader/Search/krsearchdialog.cpp +++ b/krusader/Search/krsearchdialog.cpp @@ -73,17 +73,17 @@ { public: explicit SearchResultContainer(QObject *parent) : DirListerInterface(parent) {} - virtual ~SearchResultContainer() { + ~SearchResultContainer() override { clear(); } - virtual QList fileItems() const Q_DECL_OVERRIDE { + QList fileItems() const Q_DECL_OVERRIDE { return _fileItems; } - virtual unsigned long numFileItems() const Q_DECL_OVERRIDE { + unsigned long numFileItems() const Q_DECL_OVERRIDE { return _fileItems.count(); } - virtual bool isRoot() const Q_DECL_OVERRIDE { + bool isRoot() const Q_DECL_OVERRIDE { return true; } @@ -115,7 +115,7 @@ }; -KrSearchDialog *KrSearchDialog::SearchDialog = 0; +KrSearchDialog *KrSearchDialog::SearchDialog = nullptr; QString KrSearchDialog::lastSearchText = QString('*'); int KrSearchDialog::lastSearchType = 0; @@ -129,21 +129,21 @@ // class starts here ///////////////////////////////////////// -KrSearchDialog::KrSearchDialog(QString profile, QWidget* parent) - : QDialog(parent), query(0), searcher(0), isBusy(false), closed(false) +KrSearchDialog::KrSearchDialog(const QString& profile, QWidget* parent) + : QDialog(parent), query(nullptr), searcher(nullptr), isBusy(false), closed(false) { KConfigGroup group(krConfig, "Search"); setWindowTitle(i18n("Krusader::Search")); setWindowIcon(Icon("system-search")); - QGridLayout* searchBaseLayout = new QGridLayout(this); + auto* searchBaseLayout = new QGridLayout(this); searchBaseLayout->setSpacing(6); searchBaseLayout->setContentsMargins(11, 11, 11, 11); // creating the dialog buttons ( Search, Stop, Close ) - QHBoxLayout* buttonsLayout = new QHBoxLayout(); + auto* buttonsLayout = new QHBoxLayout(); buttonsLayout->setSpacing(6); buttonsLayout->setContentsMargins(0, 0, 0, 0); @@ -160,7 +160,7 @@ }); buttonsLayout->addWidget(searchTextToClipboard); - QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + auto* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); buttonsLayout->addItem(spacer); mainSearchBtn = new QPushButton(this); @@ -190,7 +190,7 @@ generalFilter = (GeneralFilter *)filterTabs->get("GeneralFilter"); QWidget* resultTab = new QWidget(searcherTabs); - QGridLayout* resultLayout = new QGridLayout(resultTab); + auto* resultLayout = new QGridLayout(resultTab); resultLayout->setSpacing(6); resultLayout->setContentsMargins(6, 6, 6, 6); @@ -218,7 +218,7 @@ foundTextFrame->setFrameShape(QLabel::StyledPanel); foundTextFrame->setFrameShadow(QLabel::Sunken); - QHBoxLayout* foundTextLayout = new QHBoxLayout(); + auto* foundTextLayout = new QHBoxLayout(); foundTextLayout->setSpacing(6); QLabel *textFoundLabel = new QLabel(i18n("Text found:"), resultTab); @@ -232,7 +232,7 @@ resultLayout->addWidget(foundTextFrame, 2, 0); // result info row - QHBoxLayout* resultLabelLayout = new QHBoxLayout(); + auto* resultLabelLayout = new QHBoxLayout(); resultLabelLayout->setSpacing(6); resultLabelLayout->setContentsMargins(0, 0, 0, 0); @@ -309,9 +309,9 @@ KrSearchDialog::~KrSearchDialog() { delete query; - query = 0; + query = nullptr; delete resultView; - resultView = 0; + resultView = nullptr; } void KrSearchDialog::closeDialog(bool isAccept) @@ -322,9 +322,9 @@ } // stop the search if it's on-going - if (searcher != 0) { + if (searcher != nullptr) { delete searcher; - searcher = 0; + searcher = nullptr; } // saving the searcher state @@ -348,7 +348,7 @@ lastFollowSymLinks = generalFilter->followLinks->isChecked(); hide(); - SearchDialog = 0; + SearchDialog = nullptr; if (isAccept) QDialog::accept(); else @@ -380,8 +380,8 @@ { // prepare the query ... /////////////////// names, locations and greps - if (query != 0) { - delete query; query = 0; + if (query != nullptr) { + delete query; query = nullptr; } query = new KRQuery(); @@ -401,7 +401,7 @@ KMessageBox::information(this, i18n("Since you chose to also search in archives, " "note the following limitations:\n" "You cannot search for text (grep) while doing" - " a search that includes archives."), 0, "searchInArchives"); + " a search that includes archives."), nullptr, "searchInArchives"); } // prepare the gui /////////////////////////////////////////////// @@ -426,7 +426,7 @@ qApp->processEvents(); // start the search. - if (searcher != 0) + if (searcher != nullptr) abort(); searcher = new KRSearchMod(query); connect(searcher, &KRSearchMod::searching, searchingLabel, &KSqueezedTextLabel::setText); @@ -438,7 +438,7 @@ isBusy = false; delete searcher; - searcher = 0; + searcher = nullptr; // gui stuff mainSearchBtn->setEnabled(true); @@ -454,9 +454,9 @@ void KrSearchDialog::stopSearch() { - if (searcher != 0) { + if (searcher != nullptr) { searcher->stop(); - disconnect(searcher, 0, 0, 0); + disconnect(searcher, nullptr, nullptr, nullptr); } } @@ -601,7 +601,7 @@ QString fileSystemName; do { fileSystemName = i18n("Search results") + QString(" %1").arg(listBoxNum++); - } while (virtFilesystem.getFileItem(fileSystemName) != 0); + } while (virtFilesystem.getFileItem(fileSystemName) != nullptr); group.writeEntry("Feed To Listbox Counter", listBoxNum); KConfigGroup ga(krConfig, "Advanced"); @@ -644,7 +644,7 @@ if (urls.count() == 0) return; - QMimeData *mimeData = new QMimeData; + auto *mimeData = new QMimeData; mimeData->setImageData(FileListIcon("file").pixmap()); mimeData->setUrls(urls); diff --git a/krusader/Search/krsearchmod.h b/krusader/Search/krsearchmod.h --- a/krusader/Search/krsearchmod.h +++ b/krusader/Search/krsearchmod.h @@ -47,7 +47,7 @@ Q_OBJECT public: explicit KRSearchMod(const KRQuery *query); - ~KRSearchMod(); + ~KRSearchMod() override; void start(); void stop(); diff --git a/krusader/Splitter/combiner.h b/krusader/Splitter/combiner.h --- a/krusader/Splitter/combiner.h +++ b/krusader/Splitter/combiner.h @@ -37,7 +37,7 @@ public: Combiner(QWidget* parent, QUrl baseURLIn, QUrl destinationURLIn, bool unixNamingIn = false); - ~Combiner(); + ~Combiner() override; void combine(); diff --git a/krusader/Splitter/combiner.cpp b/krusader/Splitter/combiner.cpp --- a/krusader/Splitter/combiner.cpp +++ b/krusader/Splitter/combiner.cpp @@ -29,14 +29,15 @@ #include #include #include +#include //TODO: delete destination file on error //TODO: cache more than one byte array of data Combiner::Combiner(QWidget* parent, QUrl baseURLIn, QUrl destinationURLIn, bool unixNamingIn) : - QProgressDialog(parent, 0), baseURL(baseURLIn), destinationURL(destinationURLIn), + QProgressDialog(parent, nullptr), baseURL(std::move(baseURLIn)), destinationURL(std::move(destinationURLIn)), hasValidSplitFile(false), fileCounter(0), permissions(-1), receivedSize(0), - statJob(0), combineReadJob(0), combineWriteJob(0), unixNaming(unixNamingIn) + statJob(nullptr), combineReadJob(nullptr), combineWriteJob(nullptr), unixNaming(unixNamingIn) { crcContext = new CRC32(); @@ -70,7 +71,7 @@ file.refresh(); if (!file.isReadable()) { - int ret = KMessageBox::questionYesNo(0, i18n("The CRC information file (%1) is missing.\n" + int ret = KMessageBox::questionYesNo(nullptr, i18n("The CRC information file (%1) is missing.\n" "Validity checking is impossible without it. Continue combining?", splURL.toDisplayString(QUrl::PreferLocalFile))); @@ -99,7 +100,7 @@ void Combiner::combineSplitFileFinished(KJob *job) { - combineReadJob = 0; + combineReadJob = nullptr; QString error; if (job->error()) @@ -138,7 +139,7 @@ } if (!error.isEmpty()) { - int ret = KMessageBox::questionYesNo(0, + int ret = KMessageBox::questionYesNo(nullptr, error + i18n("\nValidity checking is impossible without a good CRC file. Continue combining?")); if (ret == KMessageBox::No) { emit reject(); @@ -167,17 +168,17 @@ void Combiner::statDestResult(KJob* job) { - statJob = 0; + statJob = nullptr; if (job->error()) { if (job->error() == KIO::ERR_DOES_NOT_EXIST) { openNextFile(); } else { - static_cast(job)->uiDelegate()->showErrorMessage(); + dynamic_cast(job)->uiDelegate()->showErrorMessage(); emit reject(); } } else { // destination already exists - KIO::RenameDialog_Options mode = static_cast(job)->statResult().isDir() ? + KIO::RenameDialog_Options mode = dynamic_cast(job)->statResult().isDir() ? KIO::RenameDialog_IsDirectory : KIO::RenameDialog_Overwrite; KIO::RenameDialog dlg(this, i18n("File Already Exists"), QUrl(), writeURL, mode); switch (dlg.exec()) { @@ -245,7 +246,7 @@ receivedSize += byteArray.size(); - if (combineWriteJob == 0) { + if (combineWriteJob == nullptr) { combineWriteJob = KIO::put(writeURL, permissions, KIO::HideProgressInfo | KIO::Overwrite); connect(combineWriteJob, &KIO::TransferJob::dataReq, this, &Combiner::combineDataSend); @@ -259,16 +260,16 @@ void Combiner::combineReceiveFinished(KJob *job) { - combineReadJob = 0; /* KIO automatically deletes the object after Finished signal */ + combineReadJob = nullptr; /* KIO automatically deletes the object after Finished signal */ if (job->error()) { if (job->error() == KIO::ERR_DOES_NOT_EXIST) { if (fileCounter == 1) { // .000 file doesn't exist but .001 is still a valid first file firstFileIs000 = false; openNextFile(); } else if (!firstFileIs000 && fileCounter == 2) { // neither .000 nor .001 exist combineAbortJobs(); - KMessageBox::error(0, i18n("Cannot open the first split file of %1.", + KMessageBox::error(nullptr, i18n("Cannot open the first split file of %1.", baseURL.toDisplayString(QUrl::PreferLocalFile))); emit reject(); } else { // we've received the last file @@ -287,7 +288,7 @@ } } else { combineAbortJobs(); - static_cast(job)->uiDelegate()->showErrorMessage(); + dynamic_cast(job)->uiDelegate()->showErrorMessage(); emit reject(); } } else @@ -308,15 +309,15 @@ void Combiner::combineSendFinished(KJob *job) { - combineWriteJob = 0; /* KIO automatically deletes the object after Finished signal */ + combineWriteJob = nullptr; /* KIO automatically deletes the object after Finished signal */ if (job->error()) { /* any error occurred? */ combineAbortJobs(); - static_cast(job)->uiDelegate()->showErrorMessage(); + dynamic_cast(job)->uiDelegate()->showErrorMessage(); emit reject(); } else if (!error.isEmpty()) { /* was any error message at reading ? */ combineAbortJobs(); /* we cannot write out it in combineReceiveFinished */ - KMessageBox::error(0, error); /* because emit accept closes it in this function */ + KMessageBox::error(nullptr, error); /* because emit accept closes it in this function */ emit reject(); } else emit accept(); @@ -331,12 +332,12 @@ if (combineWriteJob) combineWriteJob->kill(KJob::Quietly); - statJob = combineReadJob = combineWriteJob = 0; + statJob = combineReadJob = combineWriteJob = nullptr; } void Combiner::combineWritePercent(KJob *, unsigned long) { - int percent = (int)((((double)receivedSize / expectedSize) * 100.) + 0.5); + auto percent = (int)((((double)receivedSize / expectedSize) * 100.) + 0.5); setValue(percent); } diff --git a/krusader/Splitter/splitter.h b/krusader/Splitter/splitter.h --- a/krusader/Splitter/splitter.h +++ b/krusader/Splitter/splitter.h @@ -37,7 +37,7 @@ public: Splitter(QWidget* parent, QUrl fileNameIn, QUrl destinationDirIn, bool overWriteIn); - ~Splitter(); + ~Splitter() override; void split(KIO::filesize_t splitSizeIn); diff --git a/krusader/Splitter/splitter.cpp b/krusader/Splitter/splitter.cpp --- a/krusader/Splitter/splitter.cpp +++ b/krusader/Splitter/splitter.cpp @@ -31,21 +31,22 @@ #include #include #include +#include Splitter::Splitter(QWidget* parent, QUrl fileNameIn, QUrl destinationDirIn, bool overWriteIn) : - QProgressDialog(parent, 0), - fileName(fileNameIn), - destinationDir(destinationDirIn), + QProgressDialog(parent, nullptr), + fileName(std::move(fileNameIn)), + destinationDir(std::move(destinationDirIn)), splitSize(0), permissions(0), overwrite(overWriteIn), fileNumber(0), outputFileRemaining(0), receivedSize(0), crcContext(new CRC32()), - statJob(0), - splitReadJob(0), - splitWriteJob(0) + statJob(nullptr), + splitReadJob(nullptr), + splitWriteJob(nullptr) { setMaximum(100); @@ -69,7 +70,7 @@ Q_ASSERT(!receivedSize); Q_ASSERT(!outputFileRemaining); - splitReadJob = splitWriteJob = 0; + splitReadJob = splitWriteJob = nullptr; fileNumber = receivedSize = outputFileRemaining = 0; splitSize = splitSizeIn; @@ -83,7 +84,7 @@ setLabelText(i18n("Splitting the file %1...", fileName.toDisplayString(QUrl::PreferLocalFile))); if (file.isDir()) { - KMessageBox::error(0, i18n("Cannot split a folder.")); + KMessageBox::error(nullptr, i18n("Cannot split a folder.")); return; } @@ -121,14 +122,14 @@ void Splitter::splitReceiveFinished(KJob *job) { - splitReadJob = 0; /* KIO automatically deletes the object after Finished signal */ + splitReadJob = nullptr; /* KIO automatically deletes the object after Finished signal */ if (splitWriteJob) splitWriteJob->resume(); // finish writing the output if (job->error()) { /* any error occurred? */ splitAbortJobs(); - KMessageBox::error(0, i18n("Error reading file %1: %2", fileName.toDisplayString(QUrl::PreferLocalFile), + KMessageBox::error(nullptr, i18n("Error reading file %1: %2", fileName.toDisplayString(QUrl::PreferLocalFile), job->errorString())); emit reject(); return; @@ -173,13 +174,13 @@ void Splitter::statOutputFileResult(KJob* job) { - statJob = 0; + statJob = nullptr; if (job->error()) { if (job->error() == KIO::ERR_DOES_NOT_EXIST) openOutputFile(); else { - static_cast(job)->uiDelegate()->showErrorMessage(); + dynamic_cast(job)->uiDelegate()->showErrorMessage(); emit reject(); } } else { // destination already exists @@ -235,11 +236,11 @@ void Splitter::splitSendFinished(KJob *job) { - splitWriteJob = 0; /* KIO automatically deletes the object after Finished signal */ + splitWriteJob = nullptr; /* KIO automatically deletes the object after Finished signal */ if (job->error()) { /* any error occurred? */ splitAbortJobs(); - KMessageBox::error(0, i18n("Error writing file %1: %2", writeURL.toDisplayString(QUrl::PreferLocalFile), + KMessageBox::error(nullptr, i18n("Error writing file %1: %2", writeURL.toDisplayString(QUrl::PreferLocalFile), job->errorString())); emit reject(); return; @@ -270,7 +271,7 @@ if (splitWriteJob) splitWriteJob->kill(KJob::Quietly); - splitReadJob = splitWriteJob = 0; + splitReadJob = splitWriteJob = nullptr; } void Splitter::splitFileSend(KIO::Job *, QByteArray &byteArray) @@ -281,10 +282,10 @@ void Splitter::splitFileFinished(KJob *job) { - splitWriteJob = 0; /* KIO automatically deletes the object after Finished signal */ + splitWriteJob = nullptr; /* KIO automatically deletes the object after Finished signal */ if (job->error()) { /* any error occurred? */ - KMessageBox::error(0, i18n("Error writing file %1: %2", writeURL.toDisplayString(QUrl::PreferLocalFile), + KMessageBox::error(nullptr, i18n("Error writing file %1: %2", writeURL.toDisplayString(QUrl::PreferLocalFile), job->errorString())); emit reject(); return; diff --git a/krusader/Splitter/splittergui.h b/krusader/Splitter/splittergui.h --- a/krusader/Splitter/splittergui.h +++ b/krusader/Splitter/splittergui.h @@ -53,8 +53,8 @@ KUrlRequester *urlReq; public: - SplitterGUI(QWidget* parent, QUrl fileURL, QUrl defaultDir); - ~SplitterGUI(); + SplitterGUI(QWidget* parent, const QUrl& fileURL, const QUrl& defaultDir); + ~SplitterGUI() override; QUrl getDestinationDir() { return urlReq->url(); @@ -68,7 +68,7 @@ virtual void splitPressed(); protected: - virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; }; #endif /* __SPLITTERGUI_H__ */ diff --git a/krusader/Splitter/splittergui.cpp b/krusader/Splitter/splittergui.cpp --- a/krusader/Splitter/splittergui.cpp +++ b/krusader/Splitter/splittergui.cpp @@ -43,11 +43,12 @@ #include #include #include +#include struct SplitterGUI::PredefinedDevice { PredefinedDevice(QString name, KIO::filesize_t capacity) : - name(name), capacity(capacity) {} + name(std::move(name)), capacity(capacity) {} PredefinedDevice(const PredefinedDevice &other) : name(other.name), capacity(other.capacity) {} PredefinedDevice &operator=(const PredefinedDevice &other); @@ -73,14 +74,14 @@ return list; }; -SplitterGUI::SplitterGUI(QWidget* parent, QUrl fileURL, QUrl defaultDir) : +SplitterGUI::SplitterGUI(QWidget* parent, const QUrl& fileURL, const QUrl& defaultDir) : QDialog(parent), userDefinedSize(0x100000), lastSelectedDevice(-1), division(1) { setModal(true); - QGridLayout *grid = new QGridLayout(this); + auto *grid = new QGridLayout(this); grid->setSpacing(6); grid->setContentsMargins(11, 11, 11, 11); @@ -95,7 +96,7 @@ grid->addWidget(urlReq, 1 , 0); QWidget *splitSizeLine = new QWidget(this); - QHBoxLayout * splitSizeLineLayout = new QHBoxLayout; + auto * splitSizeLineLayout = new QHBoxLayout; splitSizeLineLayout->setContentsMargins(0, 0, 0, 0); splitSizeLine->setLayout(splitSizeLineLayout); diff --git a/krusader/Synchronizer/feedtolistboxdialog.h b/krusader/Synchronizer/feedtolistboxdialog.h --- a/krusader/Synchronizer/feedtolistboxdialog.h +++ b/krusader/Synchronizer/feedtolistboxdialog.h @@ -36,7 +36,7 @@ public: FeedToListBoxDialog(QWidget*, Synchronizer *, QTreeWidget *, bool); - virtual ~FeedToListBoxDialog() {} + ~FeedToListBoxDialog() override = default; bool isAccepted() { return accepted; diff --git a/krusader/Synchronizer/feedtolistboxdialog.cpp b/krusader/Synchronizer/feedtolistboxdialog.cpp --- a/krusader/Synchronizer/feedtolistboxdialog.cpp +++ b/krusader/Synchronizer/feedtolistboxdialog.cpp @@ -51,7 +51,7 @@ setWindowTitle(i18n("Krusader::Feed to listbox")); setWindowModality(Qt::WindowModal); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); // autodetecting the parameters @@ -63,7 +63,7 @@ QTreeWidgetItemIterator it(syncList); while (*it) { - SynchronizerGUI::SyncViewItem *item = (SynchronizerGUI::SyncViewItem *) * it; + auto *item = (SynchronizerGUI::SyncViewItem *) * it; SynchronizerFileItem *syncItem = item->synchronizerItemRef(); if (syncItem && syncItem->isMarked()) { @@ -98,7 +98,7 @@ QString queryName; do { queryName = i18n("Synchronize results") + QString(" %1").arg(listBoxNum++); - } while (virtFilesystem.getFileItem(queryName) != 0); + } while (virtFilesystem.getFileItem(queryName) != nullptr); group.writeEntry("Feed To Listbox Counter", listBoxNum); // creating the widget @@ -112,7 +112,7 @@ lineEdit->selectAll(); mainLayout->addWidget(lineEdit); - QHBoxLayout * hbox = new QHBoxLayout; + auto * hbox = new QHBoxLayout; QLabel *label2 = new QLabel(i18n("Side to feed:"), this); label2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); @@ -169,7 +169,7 @@ QTreeWidgetItemIterator it(syncList); for (;*it; it++) { - SynchronizerGUI::SyncViewItem *item = (SynchronizerGUI::SyncViewItem *) * it; + auto *item = (SynchronizerGUI::SyncViewItem *) * it; SynchronizerFileItem *syncItem = item->synchronizerItemRef(); if (!syncItem || !syncItem->isMarked()) diff --git a/krusader/Synchronizer/synchronizedialog.h b/krusader/Synchronizer/synchronizedialog.h --- a/krusader/Synchronizer/synchronizedialog.h +++ b/krusader/Synchronizer/synchronizedialog.h @@ -37,7 +37,7 @@ public: SynchronizeDialog(QWidget*, Synchronizer *sync, int, KIO::filesize_t, int, KIO::filesize_t, int, KIO::filesize_t, int); - ~SynchronizeDialog(); + ~SynchronizeDialog() override; inline bool wasSyncronizationStarted() { return syncStarted; diff --git a/krusader/Synchronizer/synchronizedialog.cpp b/krusader/Synchronizer/synchronizedialog.cpp --- a/krusader/Synchronizer/synchronizedialog.cpp +++ b/krusader/Synchronizer/synchronizedialog.cpp @@ -45,7 +45,7 @@ setWindowTitle(i18n("Krusader::Synchronize")); setModal(true); - QVBoxLayout *layout = new QVBoxLayout(this); + auto *layout = new QVBoxLayout(this); layout->setContentsMargins(11, 11, 11, 11); layout->setSpacing(6); @@ -96,16 +96,16 @@ layout->addWidget(progress); QWidget *hboxWidget = new QWidget(this); - QHBoxLayout * hbox = new QHBoxLayout(hboxWidget); + auto * hbox = new QHBoxLayout(hboxWidget); hbox->setSpacing(6); cbOverwrite = new QCheckBox(i18n("Confirm overwrites"), this); KConfigGroup group(krConfig, "Synchronize"); cbOverwrite->setChecked(group.readEntry("Confirm overwrites", _ConfirmOverWrites)); layout->addWidget(cbOverwrite); - QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + auto* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hbox->addItem(spacer); btnStart = new QPushButton(hboxWidget); @@ -119,7 +119,7 @@ btnPause->setIcon(Icon("media-playback-pause")); hbox->addWidget(btnPause); - QPushButton *btnClose = new QPushButton(hboxWidget); + auto *btnClose = new QPushButton(hboxWidget); btnClose->setText(i18n("&Close")); btnClose->setIcon(Icon("dialog-close")); hbox->addWidget(btnClose); diff --git a/krusader/Synchronizer/synchronizer.h b/krusader/Synchronizer/synchronizer.h --- a/krusader/Synchronizer/synchronizer.h +++ b/krusader/Synchronizer/synchronizer.h @@ -47,7 +47,7 @@ public: Synchronizer(); - ~Synchronizer(); + ~Synchronizer() override; int compare(QString leftURL, QString rightURL, KRQuery *query, bool subDirs, bool symLinks, bool igDate, bool asymm, bool cmpByCnt, bool igCase, bool autoSc, QStringList &selFiles, int equThres, int timeOffs, int parThreads, bool hiddenFiles); @@ -77,7 +77,7 @@ QString leftBaseDirectory(); QString rightBaseDirectory(); static QString getTaskTypeName(TaskType taskType); - static QUrl fsUrl(QString strUrl); + static QUrl fsUrl(const QString& strUrl); SynchronizerFileItem *getItemAt(unsigned ndx); @@ -205,7 +205,7 @@ Q_OBJECT public: - explicit KgetProgressDialog(QWidget *parent = 0, const QString &caption = QString(), + explicit KgetProgressDialog(QWidget *parent = nullptr, const QString &caption = QString(), const QString &text = QString(), bool modal = false); QProgressBar *progressBar() { diff --git a/krusader/Synchronizer/synchronizer.cpp b/krusader/Synchronizer/synchronizer.cpp --- a/krusader/Synchronizer/synchronizer.cpp +++ b/krusader/Synchronizer/synchronizer.cpp @@ -64,18 +64,18 @@ #define DISPLAY_UPDATE_PERIOD 2 -Synchronizer::Synchronizer() : displayUpdateCount(0), markEquals(true), - markDiffers(true), markCopyToLeft(true), markCopyToRight(true), markDeletable(true), - stack(), jobMap(), receivedMap(), parentWidget(0), resultListIt(resultList) +Synchronizer::Synchronizer() + : displayUpdateCount(0), markEquals(true), markDiffers(true), markCopyToLeft(true), + markCopyToRight(true), markDeletable(true), parentWidget(nullptr), resultListIt(resultList) { } Synchronizer::~Synchronizer() { clearLists(); } -QUrl Synchronizer::fsUrl(QString strUrl) +QUrl Synchronizer::fsUrl(const QString& strUrl) { QUrl result = QUrl::fromUserInput(strUrl, QString(), QUrl::AssumeLocalFile); return KrServices::escapeFileUrl(result); @@ -148,7 +148,7 @@ comparedDirs = fileCount = 0; - stack.append(new CompareTask(0, leftBaseDir = leftURL, rightBaseDir = rightURL, "", "", ignoreHidden)); + stack.append(new CompareTask(nullptr, leftBaseDir = leftURL, rightBaseDir = rightURL, "", "", ignoreHidden)); compareLoop(); QListIterator it(temporaryList); @@ -179,7 +179,7 @@ if (entry->inherits("CompareTask")) { if (entry->state() == ST_STATE_READY) { - CompareTask *ctentry = (CompareTask *) entry; + auto *ctentry = (CompareTask *) entry; if (ctentry->isDuplicate()) compareDirectory(ctentry->parent(), ctentry->leftDirList(), ctentry->rightDirList(), ctentry->leftDir(), ctentry->rightDir()); @@ -230,7 +230,7 @@ checkIfSelected = true; /* walking through in the left directory */ - for (left_file = left_directory->first(); left_file != 0 && !stopped; + for (left_file = left_directory->first(); left_file != nullptr && !stopped; left_file = left_directory->next()) { if (isDir(left_file)) continue; @@ -243,7 +243,7 @@ if (!query->match(left_file)) continue; - if ((right_file = right_directory->search(file_name, ignoreCase)) == 0) + if ((right_file = right_directory->search(file_name, ignoreCase)) == nullptr) addLeftOnlyItem(parent, file_name, leftDir, left_file->getSize(), left_file->getTime_t(), readLink(left_file), left_file->getOwner(), left_file->getGroup(), left_file->getMode(), left_file->getACL()); @@ -261,7 +261,7 @@ } /* walking through in the right directory */ - for (right_file = right_directory->first(); right_file != 0 && !stopped; + for (right_file = right_directory->first(); right_file != nullptr && !stopped; right_file = right_directory->next()) { if (isDir(right_file)) continue; @@ -274,15 +274,15 @@ if (!query->match(right_file)) continue; - if (left_directory->search(file_name, ignoreCase) == 0) + if (left_directory->search(file_name, ignoreCase) == nullptr) addRightOnlyItem(parent, file_name, rightDir, right_file->getSize(), right_file->getTime_t(), readLink(right_file), right_file->getOwner(), right_file->getGroup(), right_file->getMode(), right_file->getACL()); } /* walking through the subdirectories */ if (recurseSubDirs) { - for (left_file = left_directory->first(); left_file != 0 && !stopped; + for (left_file = left_directory->first(); left_file != nullptr && !stopped; left_file = left_directory->next()) { if (left_file->isDir() && (followSymLinks || !left_file->isSymLink())) { QString left_file_name = left_file->getName(); @@ -296,7 +296,7 @@ if (!query->matchDirName(left_file_name)) continue; - if ((right_file = right_directory->search(left_file_name, ignoreCase)) == 0) { + if ((right_file = right_directory->search(left_file_name, ignoreCase)) == nullptr) { SynchronizerFileItem *me = addLeftOnlyItem(parent, left_file_name, leftDir, 0, left_file->getTime_t(), readLink(left_file), left_file->getOwner(), left_file->getGroup(), @@ -323,7 +323,7 @@ } /* walking through the right side subdirectories */ - for (right_file = right_directory->first(); right_file != 0 && !stopped; + for (right_file = right_directory->first(); right_file != nullptr && !stopped; right_file = right_directory->next()) { if (right_file->isDir() && (followSymLinks || !right_file->isSymLink())) { file_name = right_file->getName(); @@ -337,7 +337,7 @@ if (!query->matchDirName(file_name)) continue; - if (left_directory->search(file_name, ignoreCase) == 0) { + if (left_directory->search(file_name, ignoreCase) == nullptr) { SynchronizerFileItem *me = addRightOnlyItem(parent, file_name, rightDir, 0, right_file->getTime_t(), readLink(right_file), right_file->getOwner(), right_file->getGroup(), @@ -370,7 +370,7 @@ bool isDir, bool isTemp) { bool marked = autoScroll ? !isTemp && isMarked(tsk, existsLeft && existsRight) : false; - SynchronizerFileItem *item = new SynchronizerFileItem(leftFile, rightFile, leftDir, rightDir, marked, + auto *item = new SynchronizerFileItem(leftFile, rightFile, leftDir, rightDir, marked, existsLeft, existsRight, leftSize, rightSize, leftDate, rightDate, leftLink, rightLink, leftOwner, rightOwner, leftGroup, rightGroup, leftMode, rightMode, leftACL, rightACL, tsk, isDir, isTemp, parent); @@ -523,7 +523,7 @@ QString file_name; /* walking through the directory files */ - for (file = directory->first(); file != 0 && !stopped; file = directory->next()) { + for (file = directory->first(); file != nullptr && !stopped; file = directory->next()) { if (isDir(file)) continue; @@ -541,7 +541,7 @@ } /* walking through the subdirectories */ - for (file = directory->first(); file != 0 && !stopped; file = directory->next()) { + for (file = directory->first(); file != nullptr && !stopped; file = directory->next()) { if (file->isDir() && (followSymLinks || !file->isSymLink())) { file_name = file->getName(); @@ -602,7 +602,7 @@ bool Synchronizer::markParentDirectories(SynchronizerFileItem *item) { - if (item->parent() == 0 || item->parent()->isMarked()) + if (item->parent() == nullptr || item->parent()->isMarked()) return false; markParentDirectories(item->parent()); @@ -685,7 +685,7 @@ { operate(item, restoreOperation); - while ((item = item->parent()) != 0) /* in case of restore, the parent directories */ + while ((item = item->parent()) != nullptr) /* in case of restore, the parent directories */ { /* must be changed for being consistent */ if (item->task() != TT_DIFFERS) break; @@ -741,7 +741,7 @@ { operate(item, copyToLeftOperation); - while ((item = item->parent()) != 0) { + while ((item = item->parent()) != nullptr) { if (item->task() != TT_DIFFERS) break; @@ -770,7 +770,7 @@ { operate(item, copyToRightOperation); - while ((item = item->parent()) != 0) { + while ((item = item->parent()) != nullptr) { if (item->task() != TT_DIFFERS && item->task() != TT_DELETE) break; @@ -859,7 +859,7 @@ leftCopySize = rightCopySize = deleteSize = 0; inTaskFinished = 0; - lastTask = 0; + lastTask = nullptr; jobMap.clear(); receivedMap.clear(); @@ -878,7 +878,7 @@ while ((int)jobMap.count() < parallelThreads) { SynchronizerFileItem *task = getNextTask(); - if (task == 0) { + if (task == nullptr) { if (jobMap.count() == 0) emit synchronizationFinished(); return; @@ -896,7 +896,7 @@ do { if (!resultListIt.hasNext()) - return 0; + return nullptr; currentTask = resultListIt.next(); @@ -1021,21 +1021,21 @@ if (leftURL.isLocalFile()) { struct utimbuf timestamp; - timestamp.actime = time(0); + timestamp.actime = time(nullptr); timestamp.modtime = item->rightDate() - timeOffset; utime((const char *)(leftURL.adjusted(QUrl::StripTrailingSlash).path().toLocal8Bit()), ×tamp); - uid_t newOwnerID = (uid_t) - 1; // chown(2) : -1 means no change + auto newOwnerID = (uid_t) - 1; // chown(2) : -1 means no change if (!item->rightOwner().isEmpty()) { struct passwd* pw = getpwnam(QFile::encodeName(item->rightOwner())); - if (pw != 0L) + if (pw != nullptr) newOwnerID = pw->pw_uid; } - gid_t newGroupID = (gid_t) - 1; // chown(2) : -1 means no change + auto newGroupID = (gid_t) - 1; // chown(2) : -1 means no change if (!item->rightGroup().isEmpty()) { struct group* g = getgrnam(QFile::encodeName(item->rightGroup())); - if (g != 0L) + if (g != nullptr) newGroupID = g->gr_gid; } int status1 = chown((const char *)(leftURL.adjusted(QUrl::StripTrailingSlash).path().toLocal8Bit()), newOwnerID, (gid_t) - 1); @@ -1061,21 +1061,21 @@ if (rightURL.isLocalFile()) { struct utimbuf timestamp; - timestamp.actime = time(0); + timestamp.actime = time(nullptr); timestamp.modtime = item->leftDate() + timeOffset; utime((const char *)(rightURL.adjusted(QUrl::StripTrailingSlash).path().toLocal8Bit()), ×tamp); - uid_t newOwnerID = (uid_t) - 1; // chown(2) : -1 means no change + auto newOwnerID = (uid_t) - 1; // chown(2) : -1 means no change if (!item->leftOwner().isEmpty()) { struct passwd* pw = getpwnam(QFile::encodeName(item->leftOwner())); - if (pw != 0L) + if (pw != nullptr) newOwnerID = pw->pw_uid; } - gid_t newGroupID = (gid_t) - 1; // chown(2) : -1 means no change + auto newGroupID = (gid_t) - 1; // chown(2) : -1 means no change if (!item->leftGroup().isEmpty()) { struct group* g = getgrnam(QFile::encodeName(item->leftGroup())); - if (g != 0L) + if (g != nullptr) newGroupID = g->gr_gid; } int status1 = chown((const char *)(rightURL.adjusted(QUrl::StripTrailingSlash).path().toLocal8Bit()), newOwnerID, (uid_t) - 1); @@ -1108,7 +1108,7 @@ if (autoSkip) break; - KIO::JobUiDelegate *ui = static_cast(job->uiDelegate()); + auto *ui = dynamic_cast(job->uiDelegate()); ui->setWindow(syncDlgWidget); if (item->task() == TT_COPY_TO_LEFT) { @@ -1178,7 +1178,7 @@ break; } - KIO::JobUiDelegate *ui = static_cast(job->uiDelegate()); + auto *ui = dynamic_cast(job->uiDelegate()); ui->setWindow(syncDlgWidget); KIO::SkipDialog_Result result = ui->askSkip(job, KIO::SkipDialog_MultipleItems, error); @@ -1280,7 +1280,7 @@ setWindowTitle(caption); setModal(modal); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); mainLayout->addWidget(new QLabel(text)); @@ -1319,7 +1319,7 @@ void Synchronizer::synchronizeWithKGet() { bool isLeftLocal = QUrl::fromUserInput(leftBaseDirectory(), QString(), QUrl::AssumeLocalFile).isLocalFile(); - KgetProgressDialog *progDlg = 0; + KgetProgressDialog *progDlg = nullptr; int processedCount = 0, totalCount = 0; QListIterator it(resultList); @@ -1338,7 +1338,7 @@ QString leftDirName = item->leftDirectory().isEmpty() ? "" : item->leftDirectory() + '/'; QString rightDirName = item->rightDirectory().isEmpty() ? "" : item->rightDirectory() + '/'; - if (progDlg == 0) { + if (progDlg == nullptr) { progDlg = new KgetProgressDialog(krMainWindow, i18n("Krusader::Synchronizer"), i18n("Feeding the URLs to KGet"), true); progDlg->progressBar()->setMaximum(totalCount); @@ -1438,6 +1438,6 @@ if (ndx < (unsigned)resultList.count()) return resultList.at(ndx); else - return 0; + return nullptr; } diff --git a/krusader/Synchronizer/synchronizerdirlist.h b/krusader/Synchronizer/synchronizerdirlist.h --- a/krusader/Synchronizer/synchronizerdirlist.h +++ b/krusader/Synchronizer/synchronizerdirlist.h @@ -35,7 +35,7 @@ public: SynchronizerDirList(QWidget *w, bool ignoreHidden); - ~SynchronizerDirList(); + ~SynchronizerDirList() override; FileItem *search(const QString &name, bool ignoreCase = false); FileItem *first(); diff --git a/krusader/Synchronizer/synchronizerdirlist.cpp b/krusader/Synchronizer/synchronizerdirlist.cpp --- a/krusader/Synchronizer/synchronizerdirlist.cpp +++ b/krusader/Synchronizer/synchronizerdirlist.cpp @@ -42,7 +42,7 @@ #include "../FileSystem/krpermhandler.h" #include "../krservices.h" -SynchronizerDirList::SynchronizerDirList(QWidget *w, bool hidden) : QObject(), QHash(), fileIterator(0), +SynchronizerDirList::SynchronizerDirList(QWidget *w, bool hidden) : fileIterator(nullptr), parentWidget(w), busy(false), result(false), ignoreHidden(hidden), currentUrl() { } @@ -61,7 +61,7 @@ { if (!ignoreCase) { if (!contains(name)) - return 0; + return nullptr; return (*this)[ name ]; } @@ -75,28 +75,28 @@ if (file == item->getName().toLower()) return item; } - return 0; + return nullptr; } FileItem *SynchronizerDirList::first() { - if (fileIterator == 0) + if (fileIterator == nullptr) fileIterator = new QHashIterator (*this); fileIterator->toFront(); if (fileIterator->hasNext()) return fileIterator->next().value(); - return 0; + return nullptr; } FileItem *SynchronizerDirList::next() { - if (fileIterator == 0) + if (fileIterator == nullptr) fileIterator = new QHashIterator (*this); if (fileIterator->hasNext()) return fileIterator->next().value(); - return 0; + return nullptr; } bool SynchronizerDirList::load(const QString &urlIn, bool wait) @@ -113,7 +113,7 @@ clear(); if (fileIterator) { delete fileIterator; - fileIterator = 0; + fileIterator = nullptr; } if (url.isLocalFile()) { @@ -128,7 +128,7 @@ QT_DIRENT* dirEnt; - while ((dirEnt = QT_READDIR(qdir)) != NULL) { + while ((dirEnt = QT_READDIR(qdir)) != nullptr) { const QString name = QString::fromLocal8Bit(dirEnt->d_name); if (name == "." || name == "..") continue; @@ -159,8 +159,8 @@ void SynchronizerDirList::slotEntries(KIO::Job *job, const KIO::UDSEntryList& entries) { - KIO::ListJob *listJob = static_cast(job); - for (const KIO::UDSEntry entry : entries) { + auto *listJob = dynamic_cast(job); + for (const KIO::UDSEntry& entry : entries) { FileItem *item = FileSystem::createFileItemFromKIO(entry, listJob->url()); if (item) { insert(item->getName(), item); diff --git a/krusader/Synchronizer/synchronizergui.h b/krusader/Synchronizer/synchronizergui.h --- a/krusader/Synchronizer/synchronizergui.h +++ b/krusader/Synchronizer/synchronizergui.h @@ -34,6 +34,7 @@ #include #include +#include #include "synchronizer.h" #include "../GUI/profilemanager.h" @@ -55,11 +56,11 @@ SyncViewItem *lastItemRef; public: - SyncViewItem(SynchronizerFileItem *item, QColor txt, QColor base, QTreeWidget * parent, QTreeWidgetItem *after, QString label1, - QString label2 = QString(), QString label3 = QString(), QString label4 = QString(), - QString label5 = QString(), QString label6 = QString(), - QString label7 = QString(), QString label8 = QString()) : - QTreeWidgetItem(parent, after), syncItemRef(item), lastItemRef(0) { + SyncViewItem(SynchronizerFileItem *item, QColor txt, QColor base, QTreeWidget * parent, QTreeWidgetItem *after, const QString& label1, + const QString& label2 = QString(), const QString& label3 = QString(), const QString& label4 = QString(), + const QString& label5 = QString(), const QString& label6 = QString(), + const QString& label7 = QString(), const QString& label8 = QString()) : + QTreeWidgetItem(parent, after), syncItemRef(item), lastItemRef(nullptr) { setText(0, label1); setText(1, label2); setText(2, label3); @@ -74,14 +75,14 @@ setTextAlignment(5, Qt::AlignRight); item->setUserData((void *)this); - setColors(txt, base); + setColors(std::move(txt), std::move(base)); } - SyncViewItem(SynchronizerFileItem *item, QColor txt, QColor base, QTreeWidgetItem * parent, QTreeWidgetItem *after, QString label1, - QString label2 = QString(), QString label3 = QString(), QString label4 = QString(), - QString label5 = QString(), QString label6 = QString(), - QString label7 = QString(), QString label8 = QString()) : - QTreeWidgetItem(parent, after), syncItemRef(item), lastItemRef(0) { + SyncViewItem(SynchronizerFileItem *item, QColor txt, QColor base, QTreeWidgetItem * parent, QTreeWidgetItem *after, const QString& label1, + const QString& label2 = QString(), const QString& label3 = QString(), const QString& label4 = QString(), + const QString& label5 = QString(), const QString& label6 = QString(), + const QString& label7 = QString(), const QString& label8 = QString()) : + QTreeWidgetItem(parent, after), syncItemRef(item), lastItemRef(nullptr) { setText(0, label1); setText(1, label2); setText(2, label3); @@ -96,11 +97,11 @@ setTextAlignment(5, Qt::AlignRight); item->setUserData((void *)this); - setColors(txt, base); + setColors(std::move(txt), std::move(base)); } - ~SyncViewItem() { - syncItemRef->setUserData(0); + ~SyncViewItem() override { + syncItemRef->setUserData(nullptr); } inline SynchronizerFileItem * synchronizerItemRef() { @@ -113,7 +114,7 @@ lastItemRef = s; } - void setColors(QColor fore, QColor back) { + void setColors(const QColor& fore, const QColor& back) { QBrush textColor(fore); QBrush baseColor(back); @@ -130,7 +131,7 @@ // if rightDirectory is null, leftDirectory is actually the profile name to load SynchronizerGUI(QWidget* parent, QUrl leftDirectory, QUrl rightDirectory = QUrl(), QStringList selList = QStringList()); SynchronizerGUI(QWidget* parent, QString profile); - ~SynchronizerGUI(); + ~SynchronizerGUI() override; inline bool wasSynchronization() { return wasSync; @@ -146,23 +147,23 @@ void closeDialog(); void refresh(); void swapSides(); - void loadFromProfile(QString); - void saveToProfile(QString); + void loadFromProfile(const QString&); + void saveToProfile(const QString&); protected slots: void reject() Q_DECL_OVERRIDE; void addFile(SynchronizerFileItem *); void markChanged(SynchronizerFileItem *, bool); void setScrolling(bool); - void statusInfo(QString); + void statusInfo(const QString&); void subdirsChecked(bool); void setPanelLabels(); void setCompletion(); void checkExcludeURLValidity(QString &text, QString &error); void connectFilters(const QString &); private: - void initGUI(QString profile, QUrl leftURL, QUrl rightURL, QStringList selList); + void initGUI(const QString& profile, QUrl leftURL, QUrl rightURL, QStringList selList); QString convertTime(time_t time) const; void setMarkFlags(); @@ -178,9 +179,9 @@ const QString &text = QString(), bool textAndIcon = false); protected: - virtual void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; - virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; - virtual bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; void executeOperation(SynchronizerFileItem *item, int op); diff --git a/krusader/Synchronizer/synchronizergui.cpp b/krusader/Synchronizer/synchronizergui.cpp --- a/krusader/Synchronizer/synchronizergui.cpp +++ b/krusader/Synchronizer/synchronizergui.cpp @@ -65,6 +65,7 @@ #include #include #include +#include class SynchronizerListView : public KrTreeWidget @@ -88,8 +89,8 @@ unsigned ndx = 0; SynchronizerFileItem *currentItem; - while ((currentItem = synchronizer->getItemAt(ndx++)) != 0) { - SynchronizerGUI::SyncViewItem *viewItem = (SynchronizerGUI::SyncViewItem *)currentItem->userData(); + while ((currentItem = synchronizer->getItemAt(ndx++)) != nullptr) { + auto *viewItem = (SynchronizerGUI::SyncViewItem *)currentItem->userData(); if (!viewItem || !viewItem->isSelected() || viewItem->isHidden()) continue; @@ -111,8 +112,8 @@ if (urls.count() == 0) return; - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; + auto *drag = new QDrag(this); + auto *mimeData = new QMimeData; mimeData->setImageData(FileListIcon(isLeft ? "arrow-left-double" : "arrow-right-double").pixmap()); mimeData->setUrls(urls); drag->setMimeData(mimeData); @@ -124,20 +125,20 @@ SynchronizerGUI::SynchronizerGUI(QWidget* parent, QUrl leftURL, QUrl rightURL, QStringList selList) : QDialog(parent) { - initGUI(QString(), leftURL, rightURL, selList); + initGUI(QString(), std::move(leftURL), std::move(rightURL), std::move(selList)); } SynchronizerGUI::SynchronizerGUI(QWidget* parent, QString profile) : QDialog(parent) { - initGUI(profile, QUrl(), QUrl(), QStringList()); + initGUI(std::move(profile), QUrl(), QUrl(), QStringList()); } -void SynchronizerGUI::initGUI(QString profileName, QUrl leftURL, QUrl rightURL, QStringList selList) +void SynchronizerGUI::initGUI(const QString& profileName, QUrl leftURL, QUrl rightURL, QStringList selList) { setAttribute(Qt::WA_DeleteOnClose); - selectedFiles = selList; + selectedFiles = std::move(selList); isComparing = wasClosed = wasSync = false; firstResize = true; sizeX = sizeY = -1; @@ -152,24 +153,24 @@ rightURL = QUrl::fromLocalFile(ROOT_DIR); setWindowTitle(i18n("Krusader::Synchronize Folders")); - QGridLayout *synchGrid = new QGridLayout(this); + auto *synchGrid = new QGridLayout(this); synchGrid->setSpacing(6); synchGrid->setContentsMargins(11, 11, 11, 11); synchronizerTabs = new QTabWidget(this); /* ============================== Compare groupbox ============================== */ QWidget *synchronizerTab = new QWidget(this); - QGridLayout *synchronizerGrid = new QGridLayout(synchronizerTab); + auto *synchronizerGrid = new QGridLayout(synchronizerTab); synchronizerGrid->setSpacing(6); synchronizerGrid->setContentsMargins(11, 11, 11, 11); - QGroupBox *compareDirs = new QGroupBox(synchronizerTab); + auto *compareDirs = new QGroupBox(synchronizerTab); compareDirs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); compareDirs->setTitle(i18n("Folder Comparison")); - QGridLayout *grid = new QGridLayout(compareDirs); + auto *grid = new QGridLayout(compareDirs); grid->setSpacing(6); grid->setContentsMargins(11, 11, 11, 11); @@ -195,7 +196,7 @@ leftLocation->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); QStringList list = group.readEntry("Left Folder History", QStringList()); leftLocation->setHistoryItems(list); - KUrlRequester *leftUrlReq = new KUrlRequester(leftLocation, compareDirs); + auto *leftUrlReq = new KUrlRequester(leftLocation, compareDirs); leftUrlReq->setUrl(leftURL); leftUrlReq->setMode(KFile::Directory); leftUrlReq->setMinimumWidth(250); @@ -228,7 +229,7 @@ rightLocation->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); list = group.readEntry("Right Folder History", QStringList()); rightLocation->setHistoryItems(list); - KUrlRequester *rightUrlReq = new KUrlRequester(rightLocation, compareDirs); + auto *rightUrlReq = new KUrlRequester(rightLocation, compareDirs); rightUrlReq->setUrl(rightURL); rightUrlReq->setMode(KFile::Directory); rightUrlReq->setMinimumWidth(250); @@ -239,11 +240,11 @@ rightDirLabel->setBuddy(rightLocation); QWidget *optionWidget = new QWidget(compareDirs); - QHBoxLayout *optionBox = new QHBoxLayout(optionWidget); + auto *optionBox = new QHBoxLayout(optionWidget); optionBox->setContentsMargins(0, 0, 0, 0); QWidget *optionGridWidget = new QWidget(optionWidget); - QGridLayout *optionGrid = new QGridLayout(optionGridWidget); + auto *optionGrid = new QGridLayout(optionGridWidget); optionBox->addWidget(optionGridWidget); @@ -275,13 +276,13 @@ /* =========================== Show options groupbox ============================= */ - QGroupBox *showOptions = new QGroupBox(optionWidget); + auto *showOptions = new QGroupBox(optionWidget); optionBox->addWidget(showOptions); showOptions->setTitle(i18n("S&how options")); showOptions->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - QGridLayout *showOptionsLayout = new QGridLayout(showOptions); + auto *showOptionsLayout = new QGridLayout(showOptions); showOptionsLayout->setSpacing(4); showOptionsLayout->setContentsMargins(11, 11, 11, 11); @@ -400,10 +401,10 @@ // creating the time shift, equality threshold, hidden files options - QGroupBox *optionsGroup = new QGroupBox(generalFilter); + auto *optionsGroup = new QGroupBox(generalFilter); optionsGroup->setTitle(i18n("&Options")); - QGridLayout *optionsLayout = new QGridLayout(optionsGroup); + auto *optionsLayout = new QGridLayout(optionsGroup); optionsLayout->setAlignment(Qt::AlignTop); optionsLayout->setSpacing(6); optionsLayout->setContentsMargins(11, 11, 11, 11); @@ -459,7 +460,7 @@ /* ================================== Buttons =================================== */ - QHBoxLayout *buttons = new QHBoxLayout; + auto *buttons = new QHBoxLayout; buttons->setSpacing(6); buttons->setContentsMargins(0, 0, 0, 0); @@ -477,7 +478,7 @@ statusLabel = new QLabel(this); buttons->addWidget(statusLabel); - QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + auto* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); buttons->addItem(spacer); btnCompareDirs = new QPushButton(this); @@ -515,7 +516,7 @@ btnSynchronize->setEnabled(false); buttons->addWidget(btnSynchronize); - QPushButton *btnCloseSync = new QPushButton(this); + auto *btnCloseSync = new QPushButton(this); btnCloseSync->setText(i18n("Close")); btnCloseSync->setIcon(Icon("dialog-close")); buttons->addWidget(btnCloseSync); @@ -688,7 +689,7 @@ if (!itemIn) return; - SyncViewItem *syncItem = (SyncViewItem *)itemIn; + auto *syncItem = (SyncViewItem *)itemIn; SynchronizerFileItem *item = syncItem->synchronizerItemRef(); if (item && item->existsInLeft() && item->existsInRight() && !item->isDir()) { QString leftDirName = item->leftDirectory().isEmpty() ? "" : item->leftDirectory() + '/'; @@ -724,8 +725,8 @@ if (!itemIn) return; - SyncViewItem *syncItem = (SyncViewItem *)itemIn; - if (syncItem == 0) + auto *syncItem = (SyncViewItem *)itemIn; + if (syncItem == nullptr) return; SynchronizerFileItem *item = syncItem->synchronizerItemRef(); @@ -821,8 +822,8 @@ unsigned ndx = 0; SynchronizerFileItem *currentItem; - while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { - SyncViewItem *viewItem = (SyncViewItem *)currentItem->userData(); + while ((currentItem = synchronizer.getItemAt(ndx++)) != nullptr) { + auto *viewItem = (SyncViewItem *)currentItem->userData(); if (!viewItem || !viewItem->isSelected() || viewItem->isHidden()) continue; @@ -871,8 +872,8 @@ unsigned ndx = 0; SynchronizerFileItem *currentItem; - while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { - SyncViewItem *viewItem = (SyncViewItem *)currentItem->userData(); + while ((currentItem = synchronizer.getItemAt(ndx++)) != nullptr) { + auto *viewItem = (SyncViewItem *)currentItem->userData(); if (!viewItem || viewItem->isHidden()) continue; @@ -887,8 +888,8 @@ unsigned ndx = 0; SynchronizerFileItem *currentItem; - while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { - SyncViewItem *viewItem = (SyncViewItem *)currentItem->userData(); + while ((currentItem = synchronizer.getItemAt(ndx++)) != nullptr) { + auto *viewItem = (SyncViewItem *)currentItem->userData(); if (!viewItem || viewItem->isHidden()) continue; @@ -1009,7 +1010,7 @@ synchronizerTabs->setCurrentIndex(0); syncList->clear(); - lastItem = 0; + lastItem = nullptr; leftLocation->addToHistory(leftLocation->currentText()); rightLocation->addToHistory(rightLocation->currentText()); @@ -1093,10 +1094,10 @@ rightDate = SynchronizerGUI::convertTime(item->rightDate()); } - SyncViewItem *listItem = 0; + SyncViewItem *listItem = nullptr; SyncViewItem *dirItem; - if (item->parent() == 0) { + if (item->parent() == nullptr) { listItem = new SyncViewItem(item, textColor, baseColor, syncList, lastItem, leftName, leftSize, leftDate, Synchronizer::getTaskTypeName(item->task()), rightDate, rightSize, rightName); @@ -1124,7 +1125,7 @@ void SynchronizerGUI::markChanged(SynchronizerFileItem *item, bool ensureVisible) { - SyncViewItem *listItem = (SyncViewItem *)item->userData(); + auto *listItem = (SyncViewItem *)item->userData(); if (listItem) { if (!item->isMarked()) { listItem->setHidden(true); @@ -1237,7 +1238,7 @@ return; } - SynchronizeDialog *sd = new SynchronizeDialog(this, &synchronizer, + auto *sd = new SynchronizeDialog(this, &synchronizer, copyToLeftNr, copyToLeftSize, copyToRightNr, copyToRightSize, deleteNr, deleteSize, parallelThreadsSpinBox->value()); @@ -1267,7 +1268,7 @@ QDialog::resizeEvent(e); } -void SynchronizerGUI::statusInfo(QString info) +void SynchronizerGUI::statusInfo(const QString& info) { statusLabel->setText(info); qApp->processEvents(); @@ -1299,7 +1300,7 @@ e->accept(); syncList->setFocus(); QTreeWidgetItem *listItem = syncList->currentItem(); - if (listItem == 0) + if (listItem == nullptr) break; bool isedit = e->key() == Qt::Key_F4; @@ -1358,7 +1359,7 @@ bool SynchronizerGUI::eventFilter(QObject * /* watched */, QEvent * e) { if (e->type() == QEvent::KeyPress) { - QKeyEvent* ke = (QKeyEvent*) e; + auto* ke = (QKeyEvent*) e; switch (ke->key()) { case Qt::Key_Down: case Qt::Key_Left: @@ -1397,7 +1398,7 @@ ke->accept(); QTreeWidgetItem *listItem = syncList->currentItem(); - if (listItem == 0) + if (listItem == nullptr) return true; SynchronizerFileItem *item = ((SyncViewItem *)listItem)->synchronizerItemRef(); @@ -1418,7 +1419,7 @@ return false; } -void SynchronizerGUI::loadFromProfile(QString profile) +void SynchronizerGUI::loadFromProfile(const QString& profile) { syncList->clear(); synchronizer.reset(); @@ -1472,7 +1473,7 @@ refresh(); } -void SynchronizerGUI::saveToProfile(QString profile) +void SynchronizerGUI::saveToProfile(const QString& profile) { KConfigGroup group(krConfig, profile); @@ -1558,7 +1559,7 @@ const QKeySequence &shortCut, const QString &description, const QString &text, bool textAndIcon) { - QPushButton *button = new QPushButton(parent); + auto *button = new QPushButton(parent); bool iconExists = Icon::exists(iconName); if (!text.isEmpty() && (textAndIcon || !iconExists)) { button->setText(text); @@ -1583,8 +1584,8 @@ unsigned ndx = 0; SynchronizerFileItem *currentItem; - while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { - SynchronizerGUI::SyncViewItem *viewItem = (SynchronizerGUI::SyncViewItem *)currentItem->userData(); + while ((currentItem = synchronizer.getItemAt(ndx++)) != nullptr) { + auto *viewItem = (SynchronizerGUI::SyncViewItem *)currentItem->userData(); if (!viewItem || !viewItem->isSelected() || viewItem->isHidden()) continue; @@ -1606,7 +1607,7 @@ if (urls.count() == 0) return; - QMimeData *mimeData = new QMimeData; + auto *mimeData = new QMimeData; mimeData->setImageData(FileListIcon(isLeft ? "arrow-left-double" : "arrow-right-double").pixmap()); mimeData->setUrls(urls); diff --git a/krusader/Synchronizer/synchronizertask.h b/krusader/Synchronizer/synchronizertask.h --- a/krusader/Synchronizer/synchronizertask.h +++ b/krusader/Synchronizer/synchronizertask.h @@ -43,8 +43,8 @@ Q_OBJECT public: - SynchronizerTask() : QObject(), m_state(ST_STATE_NEW), m_statusMessage(QString()) {} - virtual ~SynchronizerTask() {} + SynchronizerTask() : m_state(ST_STATE_NEW), m_statusMessage(QString()) {} + ~SynchronizerTask() override = default; inline int start(QWidget *parentWidget) { this->parentWidget = parentWidget; start(); return state(); @@ -86,7 +86,7 @@ const QString &rightDir, bool ignoreHidden); CompareTask(SynchronizerFileItem *parentIn, const QString &urlIn, const QString &dirIn, bool isLeftIn, bool ignoreHidden); - virtual ~CompareTask(); + ~CompareTask() override; inline bool isDuplicate() { return m_duplicate; @@ -126,7 +126,7 @@ } protected slots: - virtual void start() Q_DECL_OVERRIDE; + void start() Q_DECL_OVERRIDE; void slotFinished(bool result); void slotOtherFinished(bool result); @@ -152,15 +152,15 @@ public: CompareContentTask(Synchronizer *, SynchronizerFileItem *, const QUrl &, const QUrl &, KIO::filesize_t); - virtual ~CompareContentTask(); + ~CompareContentTask() override; public slots: void slotDataReceived(KIO::Job *job, const QByteArray &data); void slotFinished(KJob *job); void sendStatusMessage(); protected: - virtual void start() Q_DECL_OVERRIDE; + void start() Q_DECL_OVERRIDE; protected slots: void localFileCompareCycle(); diff --git a/krusader/Synchronizer/synchronizertask.cpp b/krusader/Synchronizer/synchronizertask.cpp --- a/krusader/Synchronizer/synchronizertask.cpp +++ b/krusader/Synchronizer/synchronizertask.cpp @@ -34,32 +34,32 @@ CompareTask::CompareTask(SynchronizerFileItem *parentIn, const QString &leftURL, const QString &rightURL, const QString &leftDir, - const QString &rightDir, bool hidden) : SynchronizerTask(), m_parent(parentIn), + const QString &rightDir, bool hidden) : m_parent(parentIn), m_url(leftURL), m_dir(leftDir), m_otherUrl(rightURL), m_otherDir(rightDir), m_duplicate(true), - m_dirList(0), m_otherDirList(0) + m_dirList(nullptr), m_otherDirList(nullptr) { ignoreHidden = hidden; } CompareTask::CompareTask(SynchronizerFileItem *parentIn, const QString &urlIn, - const QString &dirIn, bool isLeftIn, bool hidden) : SynchronizerTask(), + const QString &dirIn, bool isLeftIn, bool hidden) : m_parent(parentIn), m_url(urlIn), m_dir(dirIn), m_isLeft(isLeftIn), m_duplicate(false), - m_dirList(0), m_otherDirList(0) + m_dirList(nullptr), m_otherDirList(nullptr) { ignoreHidden = hidden; } CompareTask::~CompareTask() { if (m_dirList) { delete m_dirList; - m_dirList = 0; + m_dirList = nullptr; } if (m_otherDirList) { delete m_otherDirList; - m_otherDirList = 0; + m_otherDirList = nullptr; } } @@ -107,11 +107,11 @@ } CompareContentTask::CompareContentTask(Synchronizer *syn, SynchronizerFileItem *itemIn, const QUrl &leftURLIn, - const QUrl &rightURLIn, KIO::filesize_t sizeIn) : SynchronizerTask(), + const QUrl &rightURLIn, KIO::filesize_t sizeIn) : leftURL(leftURLIn), rightURL(rightURLIn), - size(sizeIn), errorPrinted(false), leftReadJob(0), - rightReadJob(0), compareArray(), owner(-1), item(itemIn), timer(0), - leftFile(0), rightFile(0), received(0), sync(syn) + size(sizeIn), errorPrinted(false), leftReadJob(nullptr), + rightReadJob(nullptr), compareArray(), owner(-1), item(itemIn), timer(nullptr), + leftFile(nullptr), rightFile(nullptr), received(0), sync(syn) { } @@ -268,7 +268,7 @@ KIO::TransferJob *otherJob = (job == leftReadJob) ? rightReadJob : leftReadJob; - if (otherJob == 0) { + if (otherJob == nullptr) { if (compareArray.size()) abortContentComparing(); } else { @@ -284,9 +284,9 @@ KIO::TransferJob *otherJob = (job == leftReadJob) ? rightReadJob : leftReadJob; if (job == leftReadJob) - leftReadJob = 0; + leftReadJob = nullptr; else - rightReadJob = 0; + rightReadJob = nullptr; if (otherJob) otherJob->resume(); @@ -303,7 +303,7 @@ rightURL.toDisplayString(QUrl::PreferLocalFile))); } - if (leftReadJob == 0 && rightReadJob == 0) { + if (leftReadJob == nullptr && rightReadJob == nullptr) { if (!compareArray.size()) sync->compareContentResult(item, true); else @@ -332,7 +332,7 @@ void CompareContentTask::sendStatusMessage() { double perc = (size == 0) ? 1. : (double)received / (double)size; - int percent = (int)(perc * 10000. + 0.5); + auto percent = (int)(perc * 10000. + 0.5); QString statstr = QString("%1.%2%3").arg(percent / 100).arg((percent / 10) % 10).arg(percent % 10) + '%'; setStatusMessage(i18n("Comparing file %1 (%2)...", leftURL.fileName(), statstr)); timer->setSingleShot(true); diff --git a/krusader/UserAction/expander.cpp b/krusader/UserAction/expander.cpp --- a/krusader/UserAction/expander.cpp +++ b/krusader/UserAction/expander.cpp @@ -72,8 +72,7 @@ return Expander::splitEach(s); } inline exp_placeholder::exp_placeholder() -{ -} += default; void exp_placeholder::panelMissingError(const QString &s, Expander& exp) { @@ -262,8 +261,8 @@ static const QString evilstuff = "\\\"'`()[]{}!?;$&<>| \t\r\n"; // stuff that should get escaped - for (int i = 0; i < evilstuff.length(); ++i) - s.replace(evilstuff[ i ], ('\\' + evilstuff[ i ])); + for (auto i : evilstuff) + s.replace(i, ('\\' + i)); return s; } @@ -627,7 +626,7 @@ // basically the parameter can already be used as URL, but since QUrl has problems with ftp-proxy-urls (like ftp://username@proxyusername@url...) this is necessary: const QStringList sourceList = splitEach(parameter[0]); QList sourceURLs; - for (const QString source : sourceList) { + for (const QString& source : sourceList) { sourceURLs.append(QUrl::fromUserInput(source, QString(), QUrl::AssumeLocalFile)); } @@ -986,9 +985,9 @@ TagString exp_simpleplaceholder::expFunc(const KrPanel* p, const TagStringList& parameter, const bool& useUrl, Expander& exp) const { QStringList lst; - for (TagStringList::const_iterator it = parameter.begin(), end = parameter.end();it != end;++it) - if ((*it).isSimple()) - lst.push_back((*it).string()); + for (const auto & it : parameter) + if (it.isSimple()) + lst.push_back(it.string()); else { setError(exp, Error(Error::exp_S_FATAL, Error::exp_C_SYNTAX, i18n("%Each% is not allowed in parameter to %1", description()))); return QString(); @@ -1010,10 +1009,10 @@ case 'r': return RIGHT_PANEL; case '_': - return 0; + return nullptr; default: exp.setError(Error(Error::exp_S_FATAL, Error::exp_C_SYNTAX, i18n("Expander: Bad panel specifier %1 in placeholder %2", panelIndicator, pl->description()))); - return 0; + return nullptr; } } @@ -1138,11 +1137,11 @@ } parameter1.append(result.mid(begin, idx - begin)); //don't forget the last one - for (QStringList::Iterator it = parameter1.begin(); it != parameter1.end(); ++it) { - *it = (*it).trimmed(); - if ((*it).left(1) == "\"") - *it = (*it).mid(1, (*it).length() - 2); - parameter.push_back(expandCurrent(*it, useUrl)); + for (auto & it : parameter1) { + it = it.trimmed(); + if (it.left(1) == "\"") + it = it.mid(1, it.length() - 2); + parameter.push_back(expandCurrent(it, useUrl)); if (error()) return TagStringList(); } diff --git a/krusader/UserAction/kraction.h b/krusader/UserAction/kraction.h --- a/krusader/UserAction/kraction.h +++ b/krusader/UserAction/kraction.h @@ -50,8 +50,8 @@ { Q_OBJECT public: - explicit KrAction(KActionCollection *parent, QString name = QString()); - ~KrAction(); + explicit KrAction(KActionCollection *parent, const QString& name = QString()); + ~KrAction() override; /** * This chekcs if the KrAction is for a specific file / location available @@ -190,7 +190,7 @@ { Q_OBJECT public: - explicit KrActionProcDlg(QString caption, bool enableStderr = false, QWidget *parent = 0); + explicit KrActionProcDlg(const QString& caption, bool enableStderr = false, QWidget *parent = nullptr); public slots: void addStderr(const QString& str); @@ -227,8 +227,8 @@ public: explicit KrActionProc(KrActionBase* action); - virtual ~KrActionProc(); - void start(QString cmdLine); + ~KrActionProc() override; + void start(const QString& cmdLine); void start(QStringList cmdLineList); protected slots: diff --git a/krusader/UserAction/kraction.cpp b/krusader/UserAction/kraction.cpp --- a/krusader/UserAction/kraction.cpp +++ b/krusader/UserAction/kraction.cpp @@ -62,30 +62,30 @@ #include "../defaults.h" // KrActionProcDlg -KrActionProcDlg::KrActionProcDlg(QString caption, bool enableStderr, QWidget *parent) : - QDialog(parent), _stdout(0), _stderr(0), _currentTextEdit(0) +KrActionProcDlg::KrActionProcDlg(const QString& caption, bool enableStderr, QWidget *parent) : + QDialog(parent), _stdout(nullptr), _stderr(nullptr), _currentTextEdit(nullptr) { setWindowTitle(caption); setWindowModality(Qt::NonModal); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; setLayout(mainLayout); // do we need to separate stderr and stdout? if (enableStderr) { - QSplitter *splitt = new QSplitter(Qt::Horizontal, this); + auto *splitt = new QSplitter(Qt::Horizontal, this); mainLayout->addWidget(splitt); // create stdout QWidget *stdoutWidget = new QWidget(splitt); - QVBoxLayout *stdoutBox = new QVBoxLayout(stdoutWidget); + auto *stdoutBox = new QVBoxLayout(stdoutWidget); stdoutBox->addWidget(new QLabel(i18n("Standard Output (stdout)"), stdoutWidget)); _stdout = new KTextEdit(stdoutWidget); _stdout->setReadOnly(true); stdoutBox->addWidget(_stdout); // create stderr QWidget *stderrWidget = new QWidget(splitt); - QVBoxLayout *stderrBox = new QVBoxLayout(stderrWidget); + auto *stderrBox = new QVBoxLayout(stderrWidget); stderrBox->addWidget(new QLabel(i18n("Standard Error (stderr)"), stderrWidget)); _stderr = new KTextEdit(stderrWidget); @@ -110,7 +110,7 @@ bool startupState = group.readEntry("Use Fixed Font", _UserActions_UseFixedFont); toggleFixedFont(startupState); - QHBoxLayout *hbox = new QHBoxLayout; + auto *hbox = new QHBoxLayout; QCheckBox* useFixedFont = new QCheckBox(i18n("Use font with fixed width")); useFixedFont->setChecked(startupState); hbox->addWidget(useFixedFont); @@ -123,7 +123,7 @@ closeButton = buttonBox->button(QDialogButtonBox::Close); closeButton->setEnabled(false); - QPushButton *saveAsButton = new QPushButton; + auto *saveAsButton = new QPushButton; KGuiItem::assign(saveAsButton, KStandardGuiItem::saveAs()); buttonBox->addButton(saveAsButton, QDialogButtonBox::ActionRole); @@ -219,16 +219,16 @@ } // KrActionProc -KrActionProc::KrActionProc(KrActionBase* action) : QObject(), _action(action), _proc(0), _output(0) +KrActionProc::KrActionProc(KrActionBase* action) : _action(action), _proc(nullptr), _output(nullptr) { } KrActionProc::~KrActionProc() { delete _proc; } -void KrActionProc::start(QString cmdLine) +void KrActionProc::start(const QString& cmdLine) { QStringList list; list << cmdLine; @@ -246,16 +246,16 @@ if (!_action->user().isEmpty()) { if (!KrServices::isExecutable(KDESU_PATH)) { - KMessageBox::sorry(0, + KMessageBox::sorry(nullptr, i18n("Cannot run user action, %1 not found or not executable. " "Please verify that kde-cli-tools are installed.", QString(KDESU_PATH))); return; } } if (_action->execType() == KrAction::RunInTE && (! MAIN_VIEW->terminalDock()->initialise())) { - KMessageBox::sorry(0, i18n("Embedded terminal emulator does not work, using output collection instead.")); + KMessageBox::sorry(nullptr, i18n("Embedded terminal emulator does not work, using output collection instead.")); } for (QStringList::Iterator it = cmdLineList.begin(); it != cmdLineList.end(); ++it) { @@ -292,7 +292,7 @@ QString term = group.readEntry("Terminal", _UserActions_Terminal); QStringList termArgs = KShell::splitArgs(term, KShell::TildeExpand); if (termArgs.isEmpty()) { - KMessageBox::error(0, i18nc("Arg is a string containing the bad quoting.", + KMessageBox::error(nullptr, i18nc("Arg is a string containing the bad quoting.", "Bad quoting in terminal command:\n%1", term)); deleteLater(); return; @@ -362,7 +362,7 @@ // KrAction -KrAction::KrAction(KActionCollection *parent, QString name) : QAction((QObject *)parent) +KrAction::KrAction(KActionCollection *parent, const QString& name) : QAction((QObject *)parent) { _actionCollection = parent; setObjectName(name); @@ -385,9 +385,9 @@ //check protocol if (! _showonlyProtocol.empty()) { available = false; - for (QStringList::Iterator it = _showonlyProtocol.begin(); it != _showonlyProtocol.end(); ++it) { + for (auto & it : _showonlyProtocol) { //qDebug() << "KrAction::isAvailable currentProtocol: " << currentURL.scheme() << " =?= " << *it; - if (currentURL.scheme() == *it) { // FIXME remove trailing slashes at the xml-parsing (faster because done only once) + if (currentURL.scheme() == it) { // FIXME remove trailing slashes at the xml-parsing (faster because done only once) available = true; break; } @@ -397,14 +397,14 @@ //check the Path-list: if (available && ! _showonlyPath.empty()) { available = false; - for (QStringList::Iterator it = _showonlyPath.begin(); it != _showonlyPath.end(); ++it) { - if ((*it).right(1) == "*") { - if (currentURL.path().indexOf((*it).left((*it).length() - 1)) == 0) { + for (auto & it : _showonlyPath) { + if (it.right(1) == "*") { + if (currentURL.path().indexOf(it.left(it.length() - 1)) == 0) { available = true; break; } } else - if (currentURL.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path() == *it) { // FIXME remove trailing slashes at the xml-parsing (faster because done only once) + if (currentURL.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path() == it) { // FIXME remove trailing slashes at the xml-parsing (faster because done only once) available = true; break; } @@ -417,14 +417,14 @@ QMimeDatabase db; QMimeType mime = db.mimeTypeForUrl(currentURL); if (mime.isValid()) { - for (QStringList::Iterator it = _showonlyMime.begin(); it != _showonlyMime.end(); ++it) { - if ((*it).contains("/")) { - if (mime.inherits(*it)) { // don't use ==; use 'inherits()' instead, which is aware of inheritance (ie: text/x-makefile is also text/plain) + for (auto & it : _showonlyMime) { + if (it.contains("/")) { + if (mime.inherits(it)) { // don't use ==; use 'inherits()' instead, which is aware of inheritance (ie: text/x-makefile is also text/plain) available = true; break; } } else { - if (mime.name().indexOf(*it) == 0) { // 0 is the beginning, -1 is not found + if (mime.name().indexOf(it) == 0) { // 0 is the beginning, -1 is not found available = true; break; } @@ -436,8 +436,8 @@ //check filename if (available && ! _showonlyFile.empty()) { available = false; - for (QStringList::Iterator it = _showonlyFile.begin(); it != _showonlyFile.end(); ++it) { - QRegExp regex = QRegExp(*it, Qt::CaseInsensitive, QRegExp::Wildcard); // case-sensitive = false; wildcards = true + for (auto & it : _showonlyFile) { + QRegExp regex = QRegExp(it, Qt::CaseInsensitive, QRegExp::Wildcard); // case-sensitive = false; wildcards = true if (regex.exactMatch(currentURL.fileName())) { available = true; break; @@ -639,7 +639,7 @@ if (e.isNull()) continue; // this should skip nodes which are not elements ( i.e. comments, , or text nodes) - QStringList* showlist = 0; + QStringList* showlist = nullptr; if (e.tagName() == "protocol") showlist = &_showonlyProtocol; @@ -654,7 +654,7 @@ showlist = & _showonlyFile; else { qWarning() << "KrAction::readAvailability() - unrecognized element found: <" << e.tagName() << ">"; - showlist = 0; + showlist = nullptr; } if (showlist) { diff --git a/krusader/UserAction/kractionbase.cpp b/krusader/UserAction/kractionbase.cpp --- a/krusader/UserAction/kractionbase.cpp +++ b/krusader/UserAction/kractionbase.cpp @@ -31,12 +31,11 @@ #include "../krglobal.h" KrActionBase::~KrActionBase() -{ -} += default; void KrActionBase::exec() { - KrActionProc *proc = 0; + KrActionProc *proc = nullptr; // replace %% and prepare string QStringList commandList; @@ -57,13 +56,13 @@ return; if (confirmExecution()) { - for (QStringList::iterator it = commandList.begin(); it != commandList.end(); ++it) { + for (auto & it : commandList) { bool exec = true; - *it = QInputDialog::getText(krMainWindow, i18n("Confirm Execution"), i18n("Command being executed:"), - QLineEdit::Normal, *it, &exec); + it = QInputDialog::getText(krMainWindow, i18n("Confirm Execution"), i18n("Command being executed:"), + QLineEdit::Normal, it, &exec); if (exec) { proc = actionProcFactoryMethod(); - proc->start(*it); + proc->start(it); } } //for } // if ( _properties->confirmExecution() ) @@ -78,7 +77,7 @@ { // once qtHandler is instantiated, it keeps on showing all qDebug() messages //QErrorMessage::qtHandler()->showMessage(err.what()); - const QString errorMessage = err.description(); + const QString& errorMessage = err.description(); if (!errorMessage.isEmpty()) { KMessageBox::error(krMainWindow, errorMessage); } diff --git a/krusader/UserAction/useraction.cpp b/krusader/UserAction/useraction.cpp --- a/krusader/UserAction/useraction.cpp +++ b/krusader/UserAction/useraction.cpp @@ -90,13 +90,13 @@ const QString category = action->category(); if (! action->isEnabled()) continue; - if (currentURL != NULL && ! action->isAvailable(*currentURL)) + if (currentURL != nullptr && ! action->isAvailable(*currentURL)) continue; if (category.isEmpty()) { uncategorised.append(action); } else { if (! categoryMap.contains(category)) { - KActionMenu *categoryMenu = new KActionMenu(category, menu); + auto *categoryMenu = new KActionMenu(category, menu); categoryMenu->setObjectName(category); categoryMap.insert(category, categoryMenu); } @@ -165,7 +165,7 @@ // if the file doesn't exist till now, the content CAN be set but is empty. // if the content can't be set, the file exists and is NOT an xml-file. file.close(); - delete doc; doc = 0; + delete doc; doc = nullptr; KMessageBox::error(MAIN_VIEW, i18n("The file %1 does not contain valid UserActions.\n", filename), // text i18n("UserActions - cannot read from file") // caption @@ -183,7 +183,7 @@ i18n("The actionfile's root element is not called %1, using %2", QString::fromLatin1(ACTION_ROOT), filename), i18n("UserActions - cannot read from file") ); - delete doc; doc = 0; + delete doc; doc = nullptr; } readFromElement(root, mode, list); delete doc; diff --git a/krusader/actionsbase.h b/krusader/actionsbase.h --- a/krusader/actionsbase.h +++ b/krusader/actionsbase.h @@ -47,26 +47,26 @@ void addAction(QAction *action, const char *slot); }; - QAction *createAction(QString text, QString icon, bool isToggleAction); + QAction *createAction(const QString& text, const QString& icon, bool isToggleAction); - QAction *action(QString text, QString icon, QKeySequence shortcut, - QObject *recv, const char *slot, QString name, bool isToggleAction = false); + QAction *action(QString text, QString icon, const QKeySequence& shortcut, + QObject *recv, const char *slot, const QString& name, bool isToggleAction = false); QAction *action(QString text, QString icon, QKeySequence shortcut, const char *slot, QString name) { return action(text, icon, shortcut, this, slot, name); } QAction *action(QString text, QString icon, const QList &shortcuts, - QObject *recv, const char *slot, QString name, bool isToggleAction = false); - QAction *action(QString text, QString icon, QKeySequence shortcut, - ActionGroup &group, const char *slot, QString name, bool isToggleAction = false); + QObject *recv, const char *slot, const QString& name, bool isToggleAction = false); + QAction *action(QString text, QString icon, const QKeySequence& shortcut, + ActionGroup &group, const char *slot, const QString& name, bool isToggleAction = false); - KToggleAction *toggleAction(QString text, QString icon, QKeySequence shortcut, + KToggleAction *toggleAction(QString text, QString icon, const QKeySequence& shortcut, QObject *recv, const char *slot, QString name); KToggleAction *toggleAction(QString text, QString icon, QKeySequence shortcut, const char *slot, QString name) { return toggleAction(text, icon, shortcut, this, slot, name); } - KToggleAction *toggleAction(QString text, QString icon, QKeySequence shortcut, + KToggleAction *toggleAction(QString text, QString icon, const QKeySequence& shortcut, ActionGroup &group, const char *slot, QString name); QAction *stdAction(KStandardAction::StandardAction id, QObject *recv, const char *slot); diff --git a/krusader/actionsbase.cpp b/krusader/actionsbase.cpp --- a/krusader/actionsbase.cpp +++ b/krusader/actionsbase.cpp @@ -28,11 +28,12 @@ #include #include +#include void ActionsBase::ActionGroup::reconnect(QObject *recv) { foreach(QAction *action, _slots.keys()) { - disconnect(action, 0, 0, 0); + disconnect(action, nullptr, nullptr, nullptr); connect(action, SIGNAL(triggered(bool)), recv, _slots[action]); } } @@ -43,25 +44,25 @@ } -QAction *ActionsBase::createAction(QString text, QString icon, bool isToggleAction) +QAction *ActionsBase::createAction(const QString& text, const QString& icon, bool isToggleAction) { if(isToggleAction) { - if (icon == 0) + if (icon == nullptr) return (QAction *)(new KToggleAction(text, this)); else return (QAction *)(new KToggleAction(Icon(icon), text, this)); } else { - if (icon == 0) + if (icon == nullptr) return new QAction(text, this); else return new QAction(Icon(icon), text, this); } } -QAction *ActionsBase::action(QString text, QString icon, QKeySequence shortcut, - QObject *recv, const char *slot, QString name, bool isToggleAction) +QAction *ActionsBase::action(QString text, QString icon, const QKeySequence& shortcut, + QObject *recv, const char *slot, const QString& name, bool isToggleAction) { - QAction *a = createAction(text, icon, isToggleAction); + QAction *a = createAction(std::move(text), std::move(icon), isToggleAction); connect(a, SIGNAL(triggered(bool)), recv, slot); _mainWindow->actions()->addAction(name, a); @@ -71,39 +72,39 @@ } QAction *ActionsBase::action(QString text, QString icon, const QList &shortcuts, - QObject *recv, const char *slot, QString name, bool isToggleAction) + QObject *recv, const char *slot, const QString& name, bool isToggleAction) { - QAction *a = createAction(text, icon, isToggleAction); + QAction *a = createAction(std::move(text), std::move(icon), isToggleAction); connect(a, SIGNAL(triggered(bool)), recv, slot); _mainWindow->actions()->addAction(name, a); _mainWindow->actions()->setDefaultShortcuts(a, shortcuts); return a; } -QAction *ActionsBase::action(QString text, QString icon, QKeySequence shortcut, - ActionGroup &group, const char *slot, QString name, bool isToggleAction) +QAction *ActionsBase::action(QString text, QString icon, const QKeySequence& shortcut, + ActionGroup &group, const char *slot, const QString& name, bool isToggleAction) { - QAction *action = createAction(text, icon, isToggleAction); + QAction *action = createAction(std::move(text), std::move(icon), isToggleAction); group.addAction(action, slot); _mainWindow->actions()->addAction(name, action); _mainWindow->actions()->setDefaultShortcut(action, shortcut); return action; } -KToggleAction *ActionsBase::toggleAction(QString text, QString icon, QKeySequence shortcut, +KToggleAction *ActionsBase::toggleAction(QString text, QString icon, const QKeySequence& shortcut, QObject *recv, const char *slot, QString name) { - return (KToggleAction *)(action(text, icon, shortcut, recv, slot, name, true)); + return (KToggleAction *)(action(std::move(text), std::move(icon), shortcut, recv, slot, std::move(name), true)); } -KToggleAction *ActionsBase::toggleAction(QString text, QString icon, QKeySequence shortcut, +KToggleAction *ActionsBase::toggleAction(QString text, QString icon, const QKeySequence& shortcut, ActionGroup &group, const char *slot, QString name) { - return (KToggleAction *)(action(text, icon, shortcut, group, slot, name, true)); + return (KToggleAction *)(action(std::move(text), std::move(icon), shortcut, group, slot, std::move(name), true)); } QAction *ActionsBase::stdAction(KStandardAction::StandardAction id, QObject *recv, const char *slot) @@ -113,7 +114,7 @@ QAction *ActionsBase::stdAction(KStandardAction::StandardAction id, ActionGroup &group, const char *slot) { - QAction *action = KStandardAction::create(id, 0, 0, _mainWindow->actions()); + QAction *action = KStandardAction::create(id, nullptr, nullptr, _mainWindow->actions()); group.addAction(action, slot); return action; } diff --git a/krusader/icon.h b/krusader/icon.h --- a/krusader/icon.h +++ b/krusader/icon.h @@ -43,7 +43,7 @@ explicit Icon(QString name, QIcon fallbackIcon, QStringList overlays = QStringList()); /// Check if icon exists in any configured theme - static bool exists(QString iconName); + static bool exists(const QString& iconName); /// Apply overlays to the pixmap with fallbacks to standard emblems static void applyOverlays(QPixmap *pixmap, QStringList overlays); diff --git a/krusader/icon.cpp b/krusader/icon.cpp --- a/krusader/icon.cpp +++ b/krusader/icon.cpp @@ -34,6 +34,7 @@ #include #include +#include static const int cacheSize = 500; @@ -66,15 +67,15 @@ { public: IconEngine(QString iconName, QIcon fallbackIcon, QStringList overlays = QStringList()) : - _iconName(iconName), _fallbackIcon(fallbackIcon), _overlays(overlays) + _iconName(std::move(iconName)), _fallbackIcon(std::move(fallbackIcon)), _overlays(std::move(overlays)) { _themeFallbackList = getThemeFallbackList(); } - virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; - virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override; + void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override; - virtual IconEngine *clone() const override + IconEngine *clone() const override { return new IconEngine(*this); } @@ -86,17 +87,17 @@ QStringList _overlays; }; -Icon::Icon() : QIcon() +Icon::Icon() { } Icon::Icon(QString name, QStringList overlays) : - QIcon(new IconEngine(name, QIcon(missingIconPath), overlays)) + QIcon(new IconEngine(std::move(name), QIcon(missingIconPath), std::move(overlays))) { } Icon::Icon(QString name, QIcon fallbackIcon, QStringList overlays) : - QIcon(new IconEngine(name, fallbackIcon, overlays)) + QIcon(new IconEngine(std::move(name), std::move(fallbackIcon), std::move(overlays))) { } @@ -106,12 +107,12 @@ QString originalThemeName; ///< original theme name if theme is modified by search IconSearchResult(QIcon icon, QString originalThemeName) : - icon(icon), originalThemeName(originalThemeName) {} + icon(std::move(icon)), originalThemeName(std::move(originalThemeName)) {} }; // Search icon in the configured themes. // If this call modifies active theme, the original theme name will be specified in the result. -static inline IconSearchResult searchIcon(QString iconName, QStringList themeFallbackList) +static inline IconSearchResult searchIcon(const QString& iconName, QStringList themeFallbackList) { if (QDir::isAbsolutePath(iconName)) { // a path is used - directly load the icon @@ -125,7 +126,7 @@ } else { // search the icon in fallback themes auto currentTheme = QIcon::themeName(); - for (auto fallbackThemeName : themeFallbackList) { + for (const auto& fallbackThemeName : themeFallbackList) { QIcon::setThemeName(fallbackThemeName); if (QIcon::hasThemeIcon(iconName)) { return IconSearchResult(QIcon::fromTheme(iconName), currentTheme); @@ -138,7 +139,7 @@ } } -bool Icon::exists(QString iconName) +bool Icon::exists(const QString& iconName) { static QCache cache(cacheSize); static QString cachedTheme; @@ -159,7 +160,7 @@ QIcon::setThemeName(searchResult.originalThemeName); } - bool *result = new bool(!searchResult.icon.isNull()); + auto *result = new bool(!searchResult.icon.isNull()); // update the cache; the cache takes ownership over the result cache.insert(iconName, result); @@ -178,7 +179,7 @@ // per freedesktop icon name specification: // https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html QStringList fixedOverlays; - for (auto overlay : overlays) { + for (const auto& overlay : overlays) { if (overlay.isEmpty() || iconLoader->hasIcon(overlay)) { fixedOverlays << overlay; } else { @@ -199,7 +200,7 @@ class IconCacheKey { public: - IconCacheKey(const QString &name, QStringList overlays, + IconCacheKey(const QString &name, const QStringList& overlays, const QSize &size, QIcon::Mode mode, QIcon::State state) : name(name), overlays(overlays), size(size), mode(mode), state(state) { diff --git a/krusader/kractions.cpp b/krusader/kractions.cpp --- a/krusader/kractions.cpp +++ b/krusader/kractions.cpp @@ -45,75 +45,75 @@ #include "Panel/PanelView/krviewfactory.h" #include "UserAction/useraction.h" -QAction *KrActions::actCompare = 0; -QAction *KrActions::actDiskUsage = 0; -QAction *KrActions::actHomeTerminal = 0; -QAction *KrActions::actRemoteEncoding = 0; -QAction *KrActions::actProfiles = 0; -QAction *KrActions::actMultiRename = 0; -QAction *KrActions::actMountMan = 0; -QAction *KrActions::actNewTool = 0; -QAction *KrActions::actKonfigurator = 0; -QAction *KrActions::actToolsSetup = 0; -QAction *KrActions::actSwapPanels = 0; -QAction *KrActions::actSwapSides = 0; -QAction *KrActions::actFind = 0; -QAction *KrActions::actLocate = 0; -QAction *KrActions::actSwitchFullScreenTE = 0; -QAction *KrActions::actAddBookmark = 0; -QAction *KrActions::actSavePosition = 0; -QAction *KrActions::actSelectColorMask = 0; -QAction *KrActions::actOpenLeftBm = 0; -QAction *KrActions::actOpenRightBm = 0; -QAction *KrActions::actCmdlinePopup = 0; -QAction *KrActions::actSplit = 0; -QAction *KrActions::actCombine = 0; -QAction *KrActions::actUserMenu = 0; -QAction *KrActions::actManageUseractions = 0; +QAction *KrActions::actCompare = nullptr; +QAction *KrActions::actDiskUsage = nullptr; +QAction *KrActions::actHomeTerminal = nullptr; +QAction *KrActions::actRemoteEncoding = nullptr; +QAction *KrActions::actProfiles = nullptr; +QAction *KrActions::actMultiRename = nullptr; +QAction *KrActions::actMountMan = nullptr; +QAction *KrActions::actNewTool = nullptr; +QAction *KrActions::actKonfigurator = nullptr; +QAction *KrActions::actToolsSetup = nullptr; +QAction *KrActions::actSwapPanels = nullptr; +QAction *KrActions::actSwapSides = nullptr; +QAction *KrActions::actFind = nullptr; +QAction *KrActions::actLocate = nullptr; +QAction *KrActions::actSwitchFullScreenTE = nullptr; +QAction *KrActions::actAddBookmark = nullptr; +QAction *KrActions::actSavePosition = nullptr; +QAction *KrActions::actSelectColorMask = nullptr; +QAction *KrActions::actOpenLeftBm = nullptr; +QAction *KrActions::actOpenRightBm = nullptr; +QAction *KrActions::actCmdlinePopup = nullptr; +QAction *KrActions::actSplit = nullptr; +QAction *KrActions::actCombine = nullptr; +QAction *KrActions::actUserMenu = nullptr; +QAction *KrActions::actManageUseractions = nullptr; #ifdef SYNCHRONIZER_ENABLED -QAction *KrActions::actSyncDirs = 0; +QAction *KrActions::actSyncDirs = nullptr; #endif -QAction *KrActions::actF10Quit = 0; -QAction *KrActions::actEmptyTrash = 0; -QAction *KrActions::actTrashBin = 0; -QAction *KrActions::actPopularUrls = 0; - -KToggleAction *KrActions::actToggleTerminal = 0; -QAction *KrActions::actVerticalMode = 0; -QAction *KrActions::actSelectNewerAndSingle = 0; -QAction *KrActions::actSelectSingle = 0; -QAction *KrActions::actSelectNewer = 0; -QAction *KrActions::actSelectDifferentAndSingle = 0; -QAction *KrActions::actSelectDifferent = 0; +QAction *KrActions::actF10Quit = nullptr; +QAction *KrActions::actEmptyTrash = nullptr; +QAction *KrActions::actTrashBin = nullptr; +QAction *KrActions::actPopularUrls = nullptr; + +KToggleAction *KrActions::actToggleTerminal = nullptr; +QAction *KrActions::actVerticalMode = nullptr; +QAction *KrActions::actSelectNewerAndSingle = nullptr; +QAction *KrActions::actSelectSingle = nullptr; +QAction *KrActions::actSelectNewer = nullptr; +QAction *KrActions::actSelectDifferentAndSingle = nullptr; +QAction *KrActions::actSelectDifferent = nullptr; QAction **KrActions::compareArray[] = {&actSelectNewerAndSingle, &actSelectNewer, &actSelectSingle, - &actSelectDifferentAndSingle, &actSelectDifferent, 0 + &actSelectDifferentAndSingle, &actSelectDifferent, nullptr }; -QAction *KrActions::actExecStartAndForget = 0; -QAction *KrActions::actExecCollectSeparate = 0; -QAction *KrActions::actExecCollectTogether = 0; -QAction *KrActions::actExecTerminalExternal = 0; -QAction *KrActions::actExecTerminalEmbedded = 0; +QAction *KrActions::actExecStartAndForget = nullptr; +QAction *KrActions::actExecCollectSeparate = nullptr; +QAction *KrActions::actExecCollectTogether = nullptr; +QAction *KrActions::actExecTerminalExternal = nullptr; +QAction *KrActions::actExecTerminalEmbedded = nullptr; QAction **KrActions::execTypeArray[] = {&actExecStartAndForget, &actExecCollectSeparate, &actExecCollectTogether, - &actExecTerminalExternal, &actExecTerminalEmbedded, 0 + &actExecTerminalExternal, &actExecTerminalEmbedded, nullptr }; -KToggleAction *KrActions::actToggleFnkeys = 0; -KToggleAction *KrActions::actToggleCmdline = 0; -KToggleAction *KrActions::actShowStatusBar = 0; -KToggleAction *KrActions::actToggleHidden = 0; -KToggleAction *KrActions::actCompareDirs = 0; +KToggleAction *KrActions::actToggleFnkeys = nullptr; +KToggleAction *KrActions::actToggleCmdline = nullptr; +KToggleAction *KrActions::actShowStatusBar = nullptr; +KToggleAction *KrActions::actToggleHidden = nullptr; +KToggleAction *KrActions::actCompareDirs = nullptr; -QAction *KrActions::actJobProgress = 0; -QAction *KrActions::actJobControl = 0; -QAction *KrActions::actJobMode = 0; -QAction *KrActions::actJobUndo = 0; +QAction *KrActions::actJobProgress = nullptr; +QAction *KrActions::actJobControl = nullptr; +QAction *KrActions::actJobMode = nullptr; +QAction *KrActions::actJobUndo = nullptr; #ifdef __KJSEMBED__ static QAction *actShowJSConsole; #endif -QAction *createAction(QString text, QString iconName, QKeySequence shortcut, - QObject *recv, const char *slot, QString name, Krusader *krusaderApp) +QAction *createAction(const QString& text, const QString& iconName, const QKeySequence& shortcut, + QObject *recv, const char *slot, const QString& name, Krusader *krusaderApp) { QAction *a; if (iconName.isEmpty()) @@ -126,8 +126,8 @@ return a; } -QAction *createAction(QString text, QString iconName, QList shortcuts, - QObject *recv, const char *slot, QString name, Krusader *krusaderApp) +QAction *createAction(const QString& text, const QString& iconName, const QList& shortcuts, + QObject *recv, const char *slot, const QString& name, Krusader *krusaderApp) { QAction *a; if (iconName.isEmpty()) @@ -141,11 +141,11 @@ } -KToggleAction *createToggleAction(QString text, QString iconName, QKeySequence shortcut, - QObject *recv, const char *slot, QString name, Krusader *krusaderApp) +KToggleAction *createToggleAction(const QString& text, const QString& iconName, const QKeySequence& shortcut, + QObject *recv, const char *slot, const QString& name, Krusader *krusaderApp) { KToggleAction *a; - if (iconName == 0) + if (iconName == nullptr) a = new KToggleAction(text, krusaderApp); else a = new KToggleAction(Icon(iconName), text, krusaderApp); @@ -180,7 +180,7 @@ QAction *tmp; Q_UNUSED(tmp); - NEW_KACTION(tmp, i18n("Tab-Switch panel"), 0, Qt::Key_Tab, MAIN_VIEW, SLOT(panelSwitch()), "tab"); + NEW_KACTION(tmp, i18n("Tab-Switch panel"), nullptr, Qt::Key_Tab, MAIN_VIEW, SLOT(panelSwitch()), "tab"); KToggleToolBarAction *actShowToolBar = new KToggleToolBarAction(krusaderApp->toolBar(), i18n("Show Main Toolbar"), krusaderApp); krusaderApp->actionCollection()->addAction(KStandardAction::name(KStandardAction::ShowToolbar), actShowToolBar); @@ -197,62 +197,62 @@ KStandardAction::keyBindings(krusaderApp->guiFactory(), SLOT(configureShortcuts()), krusaderApp->actionCollection()); // the toggle actions - NEW_KTOGGLEACTION(actToggleFnkeys, i18n("Show &FN Keys Bar"), 0, 0, SLOTS, SLOT(toggleFnkeys()), "toggle fn bar"); + NEW_KTOGGLEACTION(actToggleFnkeys, i18n("Show &FN Keys Bar"), nullptr, 0, SLOTS, SLOT(toggleFnkeys()), "toggle fn bar"); - NEW_KTOGGLEACTION(actToggleCmdline, i18n("Show &Command Line"), 0, 0, SLOTS, SLOT(toggleCmdline()), "toggle command line"); + NEW_KTOGGLEACTION(actToggleCmdline, i18n("Show &Command Line"), nullptr, 0, SLOTS, SLOT(toggleCmdline()), "toggle command line"); - NEW_KTOGGLEACTION(actToggleTerminal, i18n("Show &Embedded Terminal"), 0, Qt::ALT + Qt::CTRL + Qt::Key_T, SLOTS, SLOT(toggleTerminal()), "toggle terminal emulator"); + NEW_KTOGGLEACTION(actToggleTerminal, i18n("Show &Embedded Terminal"), nullptr, Qt::ALT + Qt::CTRL + Qt::Key_T, SLOTS, SLOT(toggleTerminal()), "toggle terminal emulator"); - NEW_KTOGGLEACTION(actToggleHidden, i18n("Show &Hidden Files"), 0, Qt::ALT + Qt::Key_Period, SLOTS, SLOT(showHiddenFiles(bool)), "toggle hidden files"); + NEW_KTOGGLEACTION(actToggleHidden, i18n("Show &Hidden Files"), nullptr, Qt::ALT + Qt::Key_Period, SLOTS, SLOT(showHiddenFiles(bool)), "toggle hidden files"); - NEW_KACTION(actSwapPanels, i18n("S&wap Panels"), 0, Qt::CTRL + Qt::Key_U, SLOTS, SLOT(swapPanels()), "swap panels"); + NEW_KACTION(actSwapPanels, i18n("S&wap Panels"), nullptr, Qt::CTRL + Qt::Key_U, SLOTS, SLOT(swapPanels()), "swap panels"); NEW_KACTION(actEmptyTrash, i18n("Empty Trash"), "trash-empty", 0, SLOTS, SLOT(emptyTrash()), "emptytrash"); NEW_KACTION(actTrashBin, i18n("Trash Popup Menu"), KrTrashHandler::trashIconName(), 0, SLOTS, SLOT(trashPopupMenu()), "trashbin"); - NEW_KACTION(actSwapSides, i18n("Sw&ap Sides"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_U, SLOTS, SLOT(toggleSwapSides()), "toggle swap sides"); + NEW_KACTION(actSwapSides, i18n("Sw&ap Sides"), nullptr, Qt::CTRL + Qt::SHIFT + Qt::Key_U, SLOTS, SLOT(toggleSwapSides()), "toggle swap sides"); actToggleHidden->setChecked(KConfigGroup(krConfig, "Look&Feel").readEntry("Show Hidden", _ShowHidden)); // and then the DONE actions - NEW_KACTION(actCmdlinePopup, i18n("popup cmdline"), 0, Qt::CTRL + Qt::Key_Slash, SLOTS, SLOT(cmdlinePopup()), "cmdline popup"); + NEW_KACTION(actCmdlinePopup, i18n("popup cmdline"), nullptr, Qt::CTRL + Qt::Key_Slash, SLOTS, SLOT(cmdlinePopup()), "cmdline popup"); NEW_KACTION(tmp, i18n("Start &Root Mode Krusader"), "krusader_root", Qt::ALT + Qt::SHIFT + Qt::Key_K, SLOTS, SLOT(rootKrusader()), "root krusader"); NEW_KACTION(actProfiles, i18n("Pro&files"), "user-identity", Qt::ALT + Qt::SHIFT + Qt::Key_L, MAIN_VIEW, SLOT(profiles()), "profile"); NEW_KACTION(actSplit, i18n("Sp&lit File..."), "split", Qt::CTRL + Qt::Key_P, SLOTS, SLOT(slotSplit()), "split"); NEW_KACTION(actCombine, i18n("Com&bine Files..."), "kr_combine", 0, SLOTS, SLOT(slotCombine()), "combine"); - NEW_KACTION(actSelectNewerAndSingle, i18n("&Select Newer and Single"), 0, 0, SLOTS, SLOT(compareSetup()), "select_newer_and_single"); - NEW_KACTION(actSelectNewer, i18n("Select &Newer"), 0, 0, SLOTS, SLOT(compareSetup()), "select_newer"); - NEW_KACTION(actSelectSingle, i18n("Select &Single"), 0, 0, SLOTS, SLOT(compareSetup()), "select_single"); - NEW_KACTION(actSelectDifferentAndSingle, i18n("Select Different &and Single"), 0, 0, SLOTS, SLOT(compareSetup()), "select_different_and_single"); - NEW_KACTION(actSelectDifferent, i18n("Select &Different"), 0, 0, SLOTS, SLOT(compareSetup()), "select_different"); + NEW_KACTION(actSelectNewerAndSingle, i18n("&Select Newer and Single"), nullptr, 0, SLOTS, SLOT(compareSetup()), "select_newer_and_single"); + NEW_KACTION(actSelectNewer, i18n("Select &Newer"), nullptr, 0, SLOTS, SLOT(compareSetup()), "select_newer"); + NEW_KACTION(actSelectSingle, i18n("Select &Single"), nullptr, 0, SLOTS, SLOT(compareSetup()), "select_single"); + NEW_KACTION(actSelectDifferentAndSingle, i18n("Select Different &and Single"), nullptr, 0, SLOTS, SLOT(compareSetup()), "select_different_and_single"); + NEW_KACTION(actSelectDifferent, i18n("Select &Different"), nullptr, 0, SLOTS, SLOT(compareSetup()), "select_different"); actSelectNewerAndSingle->setCheckable(true); actSelectNewer->setCheckable(true); actSelectSingle->setCheckable(true); actSelectDifferentAndSingle->setCheckable(true); actSelectDifferent->setCheckable(true); - QActionGroup *selectGroup = new QActionGroup(krusaderApp); + auto *selectGroup = new QActionGroup(krusaderApp); selectGroup->setExclusive(true); selectGroup->addAction(actSelectNewerAndSingle); selectGroup->addAction(actSelectNewer); selectGroup->addAction(actSelectSingle); selectGroup->addAction(actSelectDifferentAndSingle); selectGroup->addAction(actSelectDifferent); if (compareMode < (int)(sizeof(compareArray) / sizeof(QAction **)) - 1) (*compareArray[ compareMode ])->setChecked(true); - NEW_KACTION(actExecStartAndForget, i18n("Start and &Forget"), 0, 0, SLOTS, SLOT(execTypeSetup()), "exec_start_and_forget"); - NEW_KACTION(actExecCollectSeparate, i18n("Display &Separated Standard and Error Output"), 0, 0, SLOTS, SLOT(execTypeSetup()), "exec_collect_separate"); - NEW_KACTION(actExecCollectTogether, i18n("Display &Mixed Standard and Error Output"), 0, 0, SLOTS, SLOT(execTypeSetup()), "exec_collect_together"); - NEW_KACTION(actExecTerminalExternal, i18n("Start in &New Terminal"), 0, 0, SLOTS, SLOT(execTypeSetup()), "exec_terminal_external"); - NEW_KACTION(actExecTerminalEmbedded, i18n("Send to &Embedded Terminal Emulator"), 0, 0, SLOTS, SLOT(execTypeSetup()), "exec_terminal_embedded"); + NEW_KACTION(actExecStartAndForget, i18n("Start and &Forget"), nullptr, 0, SLOTS, SLOT(execTypeSetup()), "exec_start_and_forget"); + NEW_KACTION(actExecCollectSeparate, i18n("Display &Separated Standard and Error Output"), nullptr, 0, SLOTS, SLOT(execTypeSetup()), "exec_collect_separate"); + NEW_KACTION(actExecCollectTogether, i18n("Display &Mixed Standard and Error Output"), nullptr, 0, SLOTS, SLOT(execTypeSetup()), "exec_collect_together"); + NEW_KACTION(actExecTerminalExternal, i18n("Start in &New Terminal"), nullptr, 0, SLOTS, SLOT(execTypeSetup()), "exec_terminal_external"); + NEW_KACTION(actExecTerminalEmbedded, i18n("Send to &Embedded Terminal Emulator"), nullptr, 0, SLOTS, SLOT(execTypeSetup()), "exec_terminal_embedded"); actExecStartAndForget->setCheckable(true); actExecCollectSeparate->setCheckable(true); actExecCollectTogether->setCheckable(true); actExecTerminalExternal->setCheckable(true); actExecTerminalEmbedded->setCheckable(true); - QActionGroup *actionGroup = new QActionGroup(krusaderApp); + auto *actionGroup = new QActionGroup(krusaderApp); actionGroup->setExclusive(true); actionGroup->addAction(actExecStartAndForget); actionGroup->addAction(actExecCollectSeparate); @@ -276,28 +276,28 @@ #endif NEW_KACTION(actDiskUsage, i18n("D&isk Usage..."), "kr_diskusage", Qt::ALT + Qt::SHIFT + Qt::Key_S, SLOTS, SLOT(slotDiskUsage()), "disk usage"); NEW_KACTION(actKonfigurator, i18n("Configure &Krusader..."), "configure", 0, SLOTS, SLOT(startKonfigurator()), "konfigurator"); - NEW_KACTION(actSavePosition, i18n("Save &Position"), 0, 0, krusaderApp, SLOT(savePosition()), "save position"); + NEW_KACTION(actSavePosition, i18n("Save &Position"), nullptr, 0, krusaderApp, SLOT(savePosition()), "save position"); NEW_KACTION(actCompare, i18n("Compare b&y Content..."), "kr_comparedirs", 0, SLOTS, SLOT(compareContent()), "compare"); NEW_KACTION(actMultiRename, i18n("Multi &Rename..."), "edit-rename", Qt::SHIFT + Qt::Key_F2, SLOTS, SLOT(multiRename()), "multirename"); NEW_KACTION(actAddBookmark, i18n("Add Bookmark"), "bookmark-new", KStandardShortcut::addBookmark(), SLOTS, SLOT(addBookmark()), "add bookmark"); NEW_KACTION(actVerticalMode, i18n("Vertical Mode"), "view-split-top-bottom", Qt::ALT + Qt::CTRL + Qt::Key_R, MAIN_VIEW, SLOT(toggleVerticalMode()), "toggle vertical mode"); actUserMenu = new KActionMenu(i18n("User&actions"), krusaderApp); krusaderApp->actionCollection()->addAction("useractionmenu", actUserMenu); - NEW_KACTION(actManageUseractions, i18n("Manage User Actions..."), 0, 0, SLOTS, SLOT(manageUseractions()), "manage useractions"); + NEW_KACTION(actManageUseractions, i18n("Manage User Actions..."), nullptr, 0, SLOTS, SLOT(manageUseractions()), "manage useractions"); actRemoteEncoding = new KrRemoteEncodingMenu(i18n("Select Remote Charset"), "character-set", krusaderApp->actionCollection()); - NEW_KACTION(actF10Quit, i18n("Quit"), 0, Qt::Key_F10, krusaderApp, SLOT(quit()) , "F10_Quit"); + NEW_KACTION(actF10Quit, i18n("Quit"), nullptr, Qt::Key_F10, krusaderApp, SLOT(quit()) , "F10_Quit"); actF10Quit->setToolTip(i18n("Quit Krusader.")); - NEW_KACTION(actPopularUrls, i18n("Popular URLs..."), 0, Qt::CTRL + Qt::Key_Z, krusaderApp->popularUrls(), SLOT(showDialog()), "Popular_Urls"); - NEW_KACTION(actSwitchFullScreenTE, i18n("Toggle Fullscreen Embedded Terminal"), 0, + NEW_KACTION(actPopularUrls, i18n("Popular URLs..."), nullptr, Qt::CTRL + Qt::Key_Z, krusaderApp->popularUrls(), SLOT(showDialog()), "Popular_Urls"); + NEW_KACTION(actSwitchFullScreenTE, i18n("Toggle Fullscreen Embedded Terminal"), nullptr, Qt::CTRL + Qt::ALT + Qt::Key_F, MAIN_VIEW, SLOT(toggleFullScreenTerminalEmulator()), "switch_fullscreen_te"); - NEW_KACTION(tmp, i18n("Move Focus Up"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Up, MAIN_VIEW, SLOT(focusUp()), "move_focus_up"); - NEW_KACTION(tmp, i18n("Move Focus Down"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Down, MAIN_VIEW, SLOT(focusDown()), "move_focus_down"); + NEW_KACTION(tmp, i18n("Move Focus Up"), nullptr, Qt::CTRL + Qt::SHIFT + Qt::Key_Up, MAIN_VIEW, SLOT(focusUp()), "move_focus_up"); + NEW_KACTION(tmp, i18n("Move Focus Down"), nullptr, Qt::CTRL + Qt::SHIFT + Qt::Key_Down, MAIN_VIEW, SLOT(focusDown()), "move_focus_down"); // job manager actions actJobControl = krJobMan->controlAction(); diff --git a/krusader/krglobal.cpp b/krusader/krglobal.cpp --- a/krusader/krglobal.cpp +++ b/krusader/krglobal.cpp @@ -29,14 +29,14 @@ #include -KConfig *KrGlobal::config = 0; -KMountMan *KrGlobal::mountMan = 0; -KrBookmarkHandler *KrGlobal::bookman = 0; -KRslots* KrGlobal::slot = 0; -KrusaderView *KrGlobal::mainView = 0; -QWidget *KrGlobal::mainWindow = 0; -UserAction *KrGlobal::userAction = 0; -JobMan *KrGlobal::jobMan = 0; +KConfig *KrGlobal::config = nullptr; +KMountMan *KrGlobal::mountMan = nullptr; +KrBookmarkHandler *KrGlobal::bookman = nullptr; +KRslots* KrGlobal::slot = nullptr; +KrusaderView *KrGlobal::mainView = nullptr; +QWidget *KrGlobal::mainWindow = nullptr; +UserAction *KrGlobal::userAction = nullptr; +JobMan *KrGlobal::jobMan = nullptr; // ListPanel *KrGlobal::activePanel = 0; QKeySequence KrGlobal::copyShortcut; diff --git a/krusader/krservices.h b/krusader/krservices.h --- a/krusader/krservices.h +++ b/krusader/krservices.h @@ -37,17 +37,17 @@ class KrServices { public: - static bool cmdExist(QString cmdName); - static QString chooseFullPathName(QStringList names, QString confName); - static QString fullPathName(QString name, QString confName = QString()); + static bool cmdExist(const QString& cmdName); + static QString chooseFullPathName(QStringList names, const QString& confName); + static QString fullPathName(const QString& name, QString confName = QString()); static bool isExecutable(const QString &path); - static QString registeredProtocol(QString mimetype); - static bool isoSupported(QString mimetype); + static QString registeredProtocol(const QString& mimetype); + static bool isoSupported(const QString& mimetype); static QString urlToLocalPath(const QUrl &url); static void clearProtocolCache(); static bool fileToStringList(QTextStream *stream, QStringList& target, bool keepEmptyLines = false); static bool fileToStringList(QFile *file, QStringList& target, bool keepEmptyLines = false); - static QString quote(QString name); + static QString quote(const QString& name); static QStringList quote(const QStringList& names); static QList toUrlList(const QStringList &list); static QStringList toStringList(const QList &list); diff --git a/krusader/krservices.cpp b/krusader/krservices.cpp --- a/krusader/krservices.cpp +++ b/krusader/krservices.cpp @@ -29,11 +29,12 @@ #include #include +#include #include "krglobal.h" #include "defaults.h" -QMap* KrServices::slaveMap = 0; +QMap* KrServices::slaveMap = nullptr; QSet KrServices::krarcArchiveMimetypes = KrServices::generateKrarcArchiveMimetypes(); #ifdef KRARC_QUERY_ENABLED QSet KrServices::isoArchiveMimetypes = QSet::fromList(KProtocolInfo::archiveMimetypes("iso")); @@ -79,16 +80,16 @@ return mimes; } -bool KrServices::cmdExist(QString cmdName) +bool KrServices::cmdExist(const QString& cmdName) { KConfigGroup group(krConfig, "Dependencies"); if (QFile(group.readEntry(cmdName, QString())).exists()) return true; return !QStandardPaths::findExecutable(cmdName).isEmpty(); } -QString KrServices::fullPathName(QString name, QString confName) +QString KrServices::fullPathName(const QString& name, QString confName) { QString supposedName; @@ -106,7 +107,7 @@ return supposedName; } -QString KrServices::chooseFullPathName(QStringList names, QString confName) +QString KrServices::chooseFullPathName(QStringList names, const QString& confName) { foreach(const QString &name, names) { QString foundTool = KrServices::fullPathName(name, confName); @@ -124,17 +125,17 @@ return info.isFile() && info.isExecutable(); } -QString KrServices::registeredProtocol(QString mimetype) +QString KrServices::registeredProtocol(const QString& mimetype) { - if (slaveMap == 0) { + if (slaveMap == nullptr) { slaveMap = new QMap(); KConfigGroup group(krConfig, "Protocols"); QStringList protList = group.readEntry("Handled Protocols", QStringList()); - for (QStringList::Iterator it = protList.begin(); it != protList.end(); ++it) { - QStringList mimes = group.readEntry(QString("Mimes For %1").arg(*it), QStringList()); - for (QStringList::Iterator it2 = mimes.begin(); it2 != mimes.end(); ++it2) - (*slaveMap)[*it2] = *it; + for (auto & it : protList) { + QStringList mimes = group.readEntry(QString("Mimes For %1").arg(it), QStringList()); + for (auto & mime : mimes) + (*slaveMap)[mime] = it; } } QString protocol = (*slaveMap)[mimetype]; @@ -147,16 +148,16 @@ return protocol; } -bool KrServices::isoSupported(QString mimetype) +bool KrServices::isoSupported(const QString& mimetype) { return isoArchiveMimetypes.contains(mimetype); } void KrServices::clearProtocolCache() { if (slaveMap) delete slaveMap; - slaveMap = 0; + slaveMap = nullptr; } bool KrServices::fileToStringList(QTextStream *stream, QStringList& target, bool keepEmptyLines) @@ -176,7 +177,7 @@ return fileToStringList(&stream, target, keepEmptyLines); } -QString KrServices::quote(QString name) +QString KrServices::quote(const QString& name) { if (!name.contains('\'')) return '\'' + name + '\''; @@ -212,9 +213,9 @@ } // Adds one tool to the list in the supportedTools method -void supportedTool(QStringList &tools, QString toolType, +void supportedTool(QStringList &tools, const QString& toolType, QStringList names, QString confName) { - QString foundTool = KrServices::chooseFullPathName(names, confName); + QString foundTool = KrServices::chooseFullPathName(std::move(names), std::move(confName)); if (! foundTool.isEmpty()) { tools.append(toolType); tools.append(foundTool); @@ -260,8 +261,8 @@ { const QString evilstuff = "\\\"'`()[]{}!?;$&<>| \t\r\n"; // stuff that should get escaped - for (int i = 0; i < evilstuff.length(); ++i) - name.replace(evilstuff[ i ], ('\\' + evilstuff[ i ])); + for (auto i : evilstuff) + name.replace(i, ('\\' + i)); return name; } @@ -306,7 +307,7 @@ void KrServices::setGlobalKrMessageHandler(bool withDebugMessages) { s_withDebugMessages = withDebugMessages; - s_defaultMessageHandler = qInstallMessageHandler(0); + s_defaultMessageHandler = qInstallMessageHandler(nullptr); qInstallMessageHandler(&krMessageHandler); } diff --git a/krusader/krslots.h b/krusader/krslots.h --- a/krusader/krslots.h +++ b/krusader/krslots.h @@ -30,6 +30,7 @@ #include #include +#include class KrMainWindow; class QUrl; @@ -42,8 +43,8 @@ public: KrProcess(QString in1, QString in2) { - tmp1 = in1; - tmp2 = in2; + tmp1 = std::move(in1); + tmp2 = std::move(in2); connect(this, QOverload::of(&KrProcess::finished), this, &KrProcess::processHasExited); } @@ -65,12 +66,12 @@ enum compareMode { full }; explicit KRslots(QObject *parent); - ~KRslots() {} + ~KRslots() override = default; public slots: void sendFileByEmail(const QList &filename); void compareContent(); - void compareContent(QUrl, QUrl); + void compareContent(const QUrl&, const QUrl&); void insertFileName(bool fullPath); void rootKrusader(); void swapPanels(); diff --git a/krusader/krslots.cpp b/krusader/krslots.cpp --- a/krusader/krslots.cpp +++ b/krusader/krslots.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #ifdef __KJSEMBED__ #include @@ -102,15 +103,15 @@ void KRslots::sendFileByEmail(const QList &urls) { if (urls.count() == 0) { - KMessageBox::error(0, i18n("No selected files to send.")); + KMessageBox::error(nullptr, i18n("No selected files to send.")); return; } QString mailProg; QStringList lst = KrServices::supportedTools(); if (lst.contains("MAIL")) mailProg = lst[lst.indexOf("MAIL") + 1]; else { - KMessageBox::error(0, i18n("Krusader cannot find a supported mail client. Please install one to your path. Hint: Krusader supports KMail.")); + KMessageBox::error(nullptr, i18n("Krusader cannot find a supported mail client. Please install one to your path. Hint: Krusader supports KMail.")); return; } @@ -149,7 +150,7 @@ } if (!proc.startDetached()) - KMessageBox::error(0, i18n("Error executing %1.", mailProg)); + KMessageBox::error(nullptr, i18n("Error executing %1.", mailProg)); } void KRslots::compareContent() @@ -173,7 +174,7 @@ name2 = ACTIVE_PANEL->otherPanel()->func->files()->getUrl(ACTIVE_VIEW->getCurrentItem()); } else { // if we got here, then we can't be sure what file to diff - KMessageBox::sorry(0, "" + i18n("Do not know which files to compare.") + "

" + i18n("To compare two files by content, you can either:
  • Select one file in the left panel, and one in the right panel.
  • Select exactly two files in the active panel.
  • Make sure there is a file in the other panel, with the same name as the current file in the active panel.
") + "
"); + KMessageBox::sorry(nullptr, "" + i18n("Do not know which files to compare.") + "

" + i18n("To compare two files by content, you can either:
  • Select one file in the left panel, and one in the right panel.
  • Select exactly two files in the active panel.
  • Make sure there is a file in the other panel, with the same name as the current file in the active panel.
") + "
"); return; } @@ -199,13 +200,13 @@ return false; } -void KRslots::compareContent(QUrl url1, QUrl url2) +void KRslots::compareContent(const QUrl& url1, const QUrl& url2) { QString diffProg; QStringList lst = KrServices::supportedTools(); if (lst.contains("DIFF")) diffProg = lst[lst.indexOf("DIFF") + 1]; else { - KMessageBox::error(0, i18n("Krusader cannot find any of the supported diff-frontends. Please install one to your path. Hint: Krusader supports Kompare, KDiff3 and Xxdiff.")); + KMessageBox::error(nullptr, i18n("Krusader cannot find any of the supported diff-frontends. Please install one to your path. Hint: Krusader supports Kompare, KDiff3 and Xxdiff.")); return; } @@ -236,7 +237,7 @@ *p << diffProg << tmp1 << tmp2; p->start(); if (!p->waitForStarted()) - KMessageBox::error(0, i18n("Error executing %1.", diffProg)); + KMessageBox::error(nullptr, i18n("Error executing %1.", diffProg)); } // GUI toggle slots @@ -298,7 +299,7 @@ void KRslots::runKonfigurator(bool firstTime) { - Konfigurator *konfigurator = new Konfigurator(firstTime); + auto *konfigurator = new Konfigurator(firstTime); connect(konfigurator, &Konfigurator::configChanged, this, &KRslots::configChanged); //FIXME - no need to exec @@ -368,7 +369,7 @@ void KRslots::search() { - if (KrSearchDialog::SearchDialog != 0) { + if (KrSearchDialog::SearchDialog != nullptr) { KConfigGroup group(krConfig, "Search"); if (group.readEntry("Window Maximized", false)) KrSearchDialog::SearchDialog->showMaximized(); @@ -445,7 +446,7 @@ KProcess proc; proc << pathToRename; - for (const QString name: names) { + for (const QString& name: names) { FileItem *file = ACTIVE_FUNC->files()->getFileItem(name); if (!file) continue; @@ -459,7 +460,7 @@ } if (!proc.startDetached()) - KMessageBox::error(0, i18n("Error executing '%1'.", proc.program().join(" "))); + KMessageBox::error(nullptr, i18n("Error executing '%1'.", proc.program().join(" "))); } void KRslots::rootKrusader() @@ -485,7 +486,7 @@ + " --right=" + KrServices::quote(RIGHT_PANEL->virtualPath().toDisplayString(QUrl::PreferLocalFile)); if (!proc.startDetached()) - KMessageBox::error(0, i18n("Error executing %1.", proc.program()[0])); + KMessageBox::error(nullptr, i18n("Error executing %1.", proc.program()[0])); } void KRslots::slotSplit() @@ -498,7 +499,7 @@ if (name.isEmpty()) { // if we got here, then one of the panel can't be sure what file to diff - KMessageBox::error(0, i18n("Do not know which file to split.")); + KMessageBox::error(nullptr, i18n("Do not know which file to split.")); return; } @@ -531,7 +532,7 @@ { const QStringList list = ACTIVE_PANEL->gui->getSelectedNames(); if (list.isEmpty()) { - KMessageBox::error(0, i18n("Do not know which files to combine.")); + KMessageBox::error(nullptr, i18n("Do not know which files to combine.")); return; } @@ -542,12 +543,12 @@ int commonLength = 0; /* checking splitter names */ - for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { - QUrl url = ACTIVE_FUNC->files()->getUrl(*it); + for (const auto & it : list) { + QUrl url = ACTIVE_FUNC->files()->getUrl(it); if (url.isEmpty()) return; - if (ACTIVE_FUNC->files()->getFileItem(*it)->isDir()) { + if (ACTIVE_FUNC->files()->getFileItem(it)->isDir()) { KMessageBox::sorry(krApp, i18n("You cannot combine a folder.")); return; } @@ -565,7 +566,7 @@ if (extPos < 1 || ext.isEmpty() || (ext != "crc" && !isExtInt)) { if (windowsStyle) { - KMessageBox::error(0, i18n("Not a split file: %1.", url.toDisplayString(QUrl::PreferLocalFile))); + KMessageBox::error(nullptr, i18n("Not a split file: %1.", url.toDisplayString(QUrl::PreferLocalFile))); return; } unixStyle = true; @@ -577,7 +578,7 @@ if (baseURL.isEmpty()) baseURL = url; else if (baseURL != url) { - KMessageBox::error(0, i18n("Select only one split file.")); + KMessageBox::error(nullptr, i18n("Select only one split file.")); return; } } @@ -587,7 +588,7 @@ bool error = true; do { - QString shortName = *it; + const QString& shortName = it; QChar lastChar = shortName.at(shortName.length() - 1); if (lastChar.isLetter()) { @@ -601,7 +602,7 @@ QString shorter = commonName.left(commonName.length() - 1); QString testFile = shorter.leftJustified(commonLength, fillLetter); - if (ACTIVE_FUNC->files()->getFileItem(testFile) == 0) + if (ACTIVE_FUNC->files()->getFileItem(testFile) == nullptr) break; else { commonName = shorter; @@ -617,7 +618,7 @@ } while (false); if (error) { - KMessageBox::error(0, i18n("Not a split file: %1.", url.toDisplayString(QUrl::PreferLocalFile))); + KMessageBox::error(nullptr, i18n("Not a split file: %1.", url.toDisplayString(QUrl::PreferLocalFile))); return; } } @@ -646,14 +647,14 @@ void KRslots::slotSynchronizeDirs(QStringList selected) { SynchronizerGUI *synchronizerDialog = new SynchronizerGUI(MAIN_VIEW, LEFT_PANEL->virtualPath(), - RIGHT_PANEL->virtualPath(), selected); + RIGHT_PANEL->virtualPath(), std::move(selected)); synchronizerDialog->show(); // destroyed on close } #endif void KRslots::compareSetup() { - for (int i = 0; KrActions::compareArray[i] != 0; i++) + for (int i = 0; KrActions::compareArray[i] != nullptr; i++) if ((*KrActions::compareArray[i])->isChecked()) { KConfigGroup group(krConfig, "Private"); group.writeEntry("Compare Mode", i); @@ -664,7 +665,7 @@ /** called by actions actExec* to choose the built-in command line mode */ void KRslots::execTypeSetup() { - for (int i = 0; KrActions::execTypeArray[i] != 0; i++) + for (int i = 0; KrActions::execTypeArray[i] != nullptr; i++) if ((*KrActions::execTypeArray[i])->isChecked()) { if (*KrActions::execTypeArray[i] == KrActions::actExecTerminalEmbedded) { // if commands are to be executed in the TE, it must be loaded @@ -684,7 +685,7 @@ void KRslots::applicationStateChanged() { - if (MAIN_VIEW == 0) { /* CRASH FIX: it's possible that the method is called after destroying the main view */ + if (MAIN_VIEW == nullptr) { /* CRASH FIX: it's possible that the method is called after destroying the main view */ return; } if(qApp->applicationState() == Qt::ApplicationActive || diff --git a/krusader/krusader.h b/krusader/krusader.h --- a/krusader/krusader.h +++ b/krusader/krusader.h @@ -73,37 +73,37 @@ public: explicit Krusader(const QCommandLineParser &parser); - virtual ~Krusader(); + ~Krusader() override; void setTray(bool forceCreation = false); // KrMainWindow implementation - virtual QWidget *widget() Q_DECL_OVERRIDE { + QWidget *widget() Q_DECL_OVERRIDE { return this; } - virtual KrView *activeView() Q_DECL_OVERRIDE; + KrView *activeView() Q_DECL_OVERRIDE; ViewActions *viewActions() Q_DECL_OVERRIDE { return _viewActions; } - virtual KActionCollection *actions() Q_DECL_OVERRIDE { + KActionCollection *actions() Q_DECL_OVERRIDE { return actionCollection(); } - virtual AbstractPanelManager *activeManager() Q_DECL_OVERRIDE; - virtual AbstractPanelManager *leftManager() Q_DECL_OVERRIDE; - virtual AbstractPanelManager *rightManager() Q_DECL_OVERRIDE; - virtual PopularUrls *popularUrls() Q_DECL_OVERRIDE { + AbstractPanelManager *activeManager() Q_DECL_OVERRIDE; + AbstractPanelManager *leftManager() Q_DECL_OVERRIDE; + AbstractPanelManager *rightManager() Q_DECL_OVERRIDE; + PopularUrls *popularUrls() Q_DECL_OVERRIDE { return _popularUrls; } - virtual KrActions *krActions() Q_DECL_OVERRIDE { + KrActions *krActions() Q_DECL_OVERRIDE { return _krActions; } - virtual ListPanelActions *listPanelActions() Q_DECL_OVERRIDE { + ListPanelActions *listPanelActions() Q_DECL_OVERRIDE { return _listPanelActions; } - virtual TabActions *tabActions() Q_DECL_OVERRIDE { + TabActions *tabActions() Q_DECL_OVERRIDE { return _tabActions; } - virtual void plugActionList(const char *name, QList &list) Q_DECL_OVERRIDE { + void plugActionList(const char *name, QList &list) Q_DECL_OVERRIDE { KParts::MainWindow::plugActionList(name, list); } diff --git a/krusader/krusader.cpp b/krusader/krusader.cpp --- a/krusader/krusader.cpp +++ b/krusader/krusader.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include "defaults.h" #include "kractions.h" @@ -94,7 +95,7 @@ // define the static members -Krusader *Krusader::App = 0; +Krusader *Krusader::App = nullptr; QString Krusader::AppName; // KrBookmarkHandler *Krusader::bookman = 0; //QTextOStream *Krusader::_krOut = QTextOStream(::stdout); @@ -105,9 +106,9 @@ #endif // construct the views, statusbar and menu bars and prepare Krusader to start -Krusader::Krusader(const QCommandLineParser &parser) : KParts::MainWindow(0, +Krusader::Krusader(const QCommandLineParser &parser) : KParts::MainWindow(nullptr, Qt::Window | Qt::WindowTitleHint | Qt::WindowContextHelpButtonHint), - _listPanelActions(0), isStarting(true), isExiting(false), _quit(false) + _listPanelActions(nullptr), isStarting(true), isExiting(false), _quit(false) { // create the "krusader" App = this; @@ -190,7 +191,7 @@ MAIN_VIEW->start(startupGroup, startProfile.isEmpty(), leftTabs, rightTabs); // create a status bar - KrusaderStatus *status = new KrusaderStatus(this); + auto *status = new KrusaderStatus(this); setStatusBar(status); status->setWhatsThis(i18n("Statusbar will show basic information " "about file below mouse pointer.")); @@ -276,7 +277,7 @@ _openUrlTimer.setSingleShot(true); connect(&_openUrlTimer, &QTimer::timeout, this, &Krusader::doOpenUrl); - KStartupInfo *startupInfo = new KStartupInfo(0, this); + auto *startupInfo = new KStartupInfo(0, this); connect(startupInfo, &KStartupInfo::gotNewStartup, this, &Krusader::slotGotNewStartup); connect(startupInfo, &KStartupInfo::gotRemoveStartup, @@ -290,8 +291,8 @@ saveSettings(); delete MAIN_VIEW; - MAIN_VIEW = 0; - App = 0; + MAIN_VIEW = nullptr; + App = nullptr; } void Krusader::setTray(bool forceCreation) @@ -496,7 +497,7 @@ } if (i == list.count()) - w = 0; + w = nullptr; } if (!w) break; @@ -530,7 +531,7 @@ // the please wait dialog functions void Krusader::startWaiting(QString msg, int count , bool cancel) { - plzWait->startWaiting(msg , count, cancel); + plzWait->startWaiting(std::move(msg) , count, cancel); } bool Krusader::wasWaitingCancelled() const { @@ -542,13 +543,13 @@ } void Krusader::updateUserActions() { - KActionMenu *userActionMenu = (KActionMenu *) KrActions::actUserMenu; + auto *userActionMenu = (KActionMenu *) KrActions::actUserMenu; if (userActionMenu) { userActionMenu->menu()->clear(); userActionMenu->addAction(KrActions::actManageUseractions); userActionMenu->addSeparator(); - krUserAction->populateMenu(userActionMenu, NULL); + krUserAction->populateMenu(userActionMenu, nullptr); } } @@ -583,7 +584,7 @@ bool Krusader::openUrl(QString url) { - _urlToOpen = url; + _urlToOpen = std::move(url); _openUrlTimer.start(0); return true; } diff --git a/krusader/krusaderview.h b/krusader/krusaderview.h --- a/krusader/krusaderview.h +++ b/krusader/krusaderview.h @@ -44,8 +44,8 @@ Q_OBJECT public: - explicit KrusaderView(QWidget *parent = 0); - virtual ~KrusaderView() {} + explicit KrusaderView(QWidget *parent = nullptr); + ~KrusaderView() override = default; void start(const KConfigGroup &cfg, bool restoreSettings, const QList &leftTabs, const QList &rightTabs); void updateGUI(const KConfigGroup &cfg); void saveSettings(KConfigGroup &cfg); @@ -67,7 +67,7 @@ KCMDLine *cmdLine() const { return _cmdLine; } TerminalDock *terminalDock() const { return _terminalDock; } bool isVertical() const { - return horiz_splitter != 0 ? horiz_splitter->orientation() == Qt::Vertical : false; + return horiz_splitter != nullptr ? horiz_splitter->orientation() == Qt::Vertical : false; } void swapSides(); void setPanelSize(bool leftPanel, int percent); @@ -87,9 +87,9 @@ void focusUp(); void focusDown(); - void profiles(QString profileName = QString()); - void loadPanelProfiles(QString group); - void savePanelProfiles(QString group); + void profiles(const QString& profileName = QString()); + void loadPanelProfiles(const QString& group); + void savePanelProfiles(const QString& group); void draggingTab(PanelManager *from, QMouseEvent *e); void draggingTabFinished(PanelManager *from, QMouseEvent *e); diff --git a/krusader/krusaderview.cpp b/krusader/krusaderview.cpp --- a/krusader/krusaderview.cpp +++ b/krusader/krusaderview.cpp @@ -54,7 +54,7 @@ #include "krservices.h" KrusaderView::KrusaderView(QWidget *parent) : QWidget(parent), - activeMng(0) + activeMng(nullptr) { } @@ -190,7 +190,7 @@ PanelManager *KrusaderView::createManager(bool left) { - PanelManager *panelManager = new PanelManager(horiz_splitter, krApp, left); + auto *panelManager = new PanelManager(horiz_splitter, krApp, left); connect(panelManager, &PanelManager::draggingTab, this, &KrusaderView::draggingTab); connect(panelManager, &PanelManager::draggingTabFinished, this, &KrusaderView::draggingTabFinished); connect(panelManager, &PanelManager::pathChanged, this, &KrusaderView::slotPathChanged); @@ -420,7 +420,7 @@ return leftMng->isHidden() && rightMng->isHidden(); } -void KrusaderView::profiles(QString profileName) +void KrusaderView::profiles(const QString& profileName) { ProfileManager profileManager("Panel", this); profileManager.hide(); @@ -432,7 +432,7 @@ profileManager.loadProfile(profileName); } -void KrusaderView::loadPanelProfiles(QString group) +void KrusaderView::loadPanelProfiles(const QString& group) { KConfigGroup ldg(krConfig, group); leftMng->loadSettings(KConfigGroup(&ldg, "Left Tabs")); @@ -443,7 +443,7 @@ rightPanel()->slotFocusOnMe(); } -void KrusaderView::savePanelProfiles(QString group) +void KrusaderView::savePanelProfiles(const QString& group) { KConfigGroup svr(krConfig, group); diff --git a/krusader/main.cpp b/krusader/main.cpp --- a/krusader/main.cpp +++ b/krusader/main.cpp @@ -68,7 +68,7 @@ QApplication::exit(- 15); } -void openTabsRemote(QStringList tabs, bool left, QString appName) +void openTabsRemote(QStringList tabs, bool left, const QString& appName) { // make sure left or right are not relative paths for (int i = 0; i != tabs.count(); i++) { @@ -126,80 +126,80 @@ aboutData.setOrganizationDomain(QByteArray("kde.org")); aboutData.setDesktopFileName(QStringLiteral("org.kde.krusader")); - aboutData.addAuthor(i18n("Davide Gianforte"), i18n("Developer"), QStringLiteral("davide@gengisdave.org"), 0); - aboutData.addAuthor(i18n("Toni Asensi Esteve"), i18n("Developer"), QStringLiteral("toni.asensi@kdemail.net"), 0); - aboutData.addAuthor(i18n("Alexander Bikadorov"), i18n("Developer"), QStringLiteral("alex.bikadorov@kdemail.net"), 0); - aboutData.addAuthor(i18n("Martin Kostolný"), i18n("Developer"), QStringLiteral("clearmartin@gmail.com"), 0); - aboutData.addAuthor(i18n("Nikita Melnichenko"), i18n("Developer"), QStringLiteral("nikita+kde@melnichenko.name"), 0); - aboutData.addAuthor(i18n("Yuri Chornoivan"), i18n("Documentation"), QStringLiteral("yurchor@ukr.net"), 0); + aboutData.addAuthor(i18n("Davide Gianforte"), i18n("Developer"), QStringLiteral("davide@gengisdave.org"), nullptr); + aboutData.addAuthor(i18n("Toni Asensi Esteve"), i18n("Developer"), QStringLiteral("toni.asensi@kdemail.net"), nullptr); + aboutData.addAuthor(i18n("Alexander Bikadorov"), i18n("Developer"), QStringLiteral("alex.bikadorov@kdemail.net"), nullptr); + aboutData.addAuthor(i18n("Martin Kostolný"), i18n("Developer"), QStringLiteral("clearmartin@gmail.com"), nullptr); + aboutData.addAuthor(i18n("Nikita Melnichenko"), i18n("Developer"), QStringLiteral("nikita+kde@melnichenko.name"), nullptr); + aboutData.addAuthor(i18n("Yuri Chornoivan"), i18n("Documentation"), QStringLiteral("yurchor@ukr.net"), nullptr); aboutData.addAuthor(i18n("Rafi Yanai"), i18n("Author (retired)"), QStringLiteral("yanai@users.sourceforge.net")); aboutData.addAuthor(i18n("Shie Erlich"), i18n("Author (retired)"), QStringLiteral("erlich@users.sourceforge.net")); - aboutData.addAuthor(i18n("Csaba Karai"), i18n("Developer (retired)"), QStringLiteral("ckarai@users.sourceforge.net"), 0); - aboutData.addAuthor(i18n("Heiner Eichmann"), i18n("Developer (retired)"), QStringLiteral("h.eichmann@gmx.de"), 0); - aboutData.addAuthor(i18n("Jonas Bähr"), i18n("Developer (retired)"), QStringLiteral("jonas.baehr@web.de"), 0); - aboutData.addAuthor(i18n("Václav Jůza"), i18n("Developer (retired)"), QStringLiteral("vaclavjuza@gmail.com"), 0); - aboutData.addAuthor(i18n("Jan Lepper"), i18n("Developer (retired)"), QStringLiteral("jan_lepper@gmx.de"), 0); - aboutData.addAuthor(i18n("Andrey Matveyakin"), i18n("Developer (retired)"), QStringLiteral("a.matveyakin@gmail.com"), 0); - aboutData.addAuthor(i18n("Simon Persson"), i18n("Developer (retired)"), QStringLiteral("simon.persson@mykolab.com"), 0); - aboutData.addAuthor(i18n("Dirk Eschler"), i18n("Webmaster (retired)"), QStringLiteral("deschler@users.sourceforge.net"), 0); - aboutData.addAuthor(i18n("Frank Schoolmeesters"), i18n("Documentation and marketing coordinator (retired)"), QStringLiteral("frank_schoolmeesters@yahoo.com"), 0); - aboutData.addAuthor(i18n("Richard Holt"), i18n("Documentation & Proofing (retired)"), QStringLiteral("richard.holt@gmail.com"), 0); - aboutData.addAuthor(i18n("Matej Urbancic"), i18n("Marketing & Product Research (retired)"), QStringLiteral("matej.urban@gmail.com"), 0); - aboutData.addCredit(i18n("kde.org"), i18n("Everyone involved in KDE"), 0, 0); - aboutData.addCredit(i18n("l10n.kde.org"), i18n("KDE Translation Teams"), 0, 0); - aboutData.addCredit(i18n("Jiří Paleček"), i18n("QA, bug-hunting, patches and general help"), QStringLiteral("jpalecek@web.de"), 0); - aboutData.addCredit(i18n("Jiří Klement"), i18n("Important help in KDE 4 porting"), 0, 0); - aboutData.addCredit(i18n("Andrew Neupokoev"), i18n("Killer Logo and Icons for Krusader (contest winner)"), QStringLiteral("doom-blue@yandex.ru"), 0); - aboutData.addCredit(i18n("The UsefulArts Organization"), i18n("Icon for Krusader"), QStringLiteral("mail@usefularts.org"), 0); - aboutData.addCredit(i18n("Gábor Lehel"), i18n("Viewer module for 3rd Hand"), QStringLiteral("illissius@gmail.com"), 0); - aboutData.addCredit(i18n("Mark Eatough"), i18n("Handbook Proof-Reader"), QStringLiteral("markeatough@yahoo.com"), 0); - aboutData.addCredit(i18n("Jan Halasa"), i18n("The old Bookmark Module"), QStringLiteral("xhalasa@fi.muni.cz"), 0); - aboutData.addCredit(i18n("Hans Löffler"), i18n("Dir history button"), 0, 0); - aboutData.addCredit(i18n("Szombathelyi György"), i18n("ISO KIO slave"), 0, 0); - aboutData.addCredit(i18n("Jan Willem van de Meent (Adios)"), i18n("Icons for Krusader"), QStringLiteral("janwillem@lorentz.leidenuniv.nl"), 0); - aboutData.addCredit(i18n("Mikolaj Machowski"), i18n("Usability and QA"), QStringLiteral(""), 0); - aboutData.addCredit(i18n("Cristi Dumitrescu"), i18n("QA, bug-hunting, patches and general help"), QStringLiteral("cristid@chip.ro"), 0); - aboutData.addCredit(i18n("Aurelien Gateau"), i18n("patch for KViewer"), QStringLiteral("aurelien.gateau@free.fr"), 0); - aboutData.addCredit(i18n("Milan Brabec"), i18n("the first patch ever!"), QStringLiteral("mbrabec@volny.cz"), 0); - aboutData.addCredit(i18n("Asim Husanovic"), i18n("Bosnian translation"), QStringLiteral("asim@megatel.ba"), 0); - aboutData.addCredit(i18n("Doutor Zero"), i18n("Brazilian Portuguese translation"), QStringLiteral("doutor.zero@gmail.com"), 0); - aboutData.addCredit(i18n("Milen Ivanov"), i18n("Bulgarian translation"), QStringLiteral("milen.ivanov@abv.bg"), 0); - aboutData.addCredit(i18n("Quim Perez"), i18n("Catalan translation"), QStringLiteral("noguer@osona.com"), 0); - aboutData.addCredit(i18n("Jinghua Luo"), i18n("Chinese Simplified translation"), QStringLiteral("luojinghua@msn.com"), 0); - aboutData.addCredit(i18n("Mitek"), i18n("Old Czech translation"), QStringLiteral("mitek@email.cz"), 0); - aboutData.addCredit(i18n("Martin Sixta"), i18n("Old Czech translation"), QStringLiteral("lukumo84@seznam.cz"), 0); - aboutData.addCredit(i18n("Vaclav Jůza"), i18n("Czech translation"), QStringLiteral("VaclavJuza@gmail.com"), 0); - aboutData.addCredit(i18n("Anders Bruun Olsen"), i18n("Old Danish translation"), QStringLiteral("anders@bruun-olsen.net"), 0); - aboutData.addCredit(i18n("Peter H. Sorensen"), i18n("Danish translation"), QStringLiteral("peters@skydebanen.net"), 0); - aboutData.addCredit(i18n("Frank Schoolmeesters"), i18n("Dutch translation"), QStringLiteral("frank_schoolmeesters@yahoo.com"), 0); - aboutData.addCredit(i18n("Rene-Pierre Lehmann"), i18n("Old French translation"), QStringLiteral("ripi@lepi.org"), 0); - aboutData.addCredit(i18n("David Guillerm"), i18n("French translation"), QStringLiteral("dguillerm@gmail.com"), 0); - aboutData.addCredit(i18n("Christoph Thielecke"), i18n("Old German translation"), QStringLiteral("crissi99@gmx.de"), 0); - aboutData.addCredit(i18n("Dirk Eschler"), i18n("German translation"), QStringLiteral("deschler@users.sourceforge.net"), 0); - aboutData.addCredit(i18n("Spiros Georgaras"), i18n("Greek translation"), QStringLiteral("sngeorgaras@gmail.com"), 0); - aboutData.addCredit(i18n("Kukk Zoltan"), i18n("Old Hungarian translation"), QStringLiteral("kukkzoli@freemail.hu"), 0); - aboutData.addCredit(i18n("Arpad Biro"), i18n("Hungarian translation"), QStringLiteral("biro_arpad@yahoo.com"), 0); - aboutData.addCredit(i18n("Giuseppe Bordoni"), i18n("Italian translation"), QStringLiteral("geppo@geppozone.com"), 0); - aboutData.addCredit(i18n("Hideki Kimura"), i18n("Japanese translation"), QStringLiteral("hangyo1973@gmail.com"), 0); - aboutData.addCredit(i18n("UTUMI Hirosi"), i18n("Old Japanese translation"), QStringLiteral("utuhiro@mx12.freecom.ne.jp"), 0); - aboutData.addCredit(i18n("Dovydas Sankauskas"), i18n("Lithuanian translation"), QStringLiteral("laisve@gmail.com"), 0); - aboutData.addCredit(i18n("Bruno Queiros"), i18n("Portuguese translation"), QStringLiteral("brunoqueiros@portugalmail.com"), 0); - aboutData.addCredit(i18n("Lukasz Janyst"), i18n("Old Polish translation"), QStringLiteral("ljan@wp.pl"), 0); - aboutData.addCredit(i18n("Pawel Salawa"), i18n("Polish translation"), QStringLiteral("boogie@myslenice.one.pl"), 0); - aboutData.addCredit(i18n("Tomek Grzejszczyk"), i18n("Polish translation"), QStringLiteral("tgrzej@onet.eu"), 0); - aboutData.addCredit(i18n("Dmitry A. Bugay"), i18n("Russian translation"), QStringLiteral("sam@vhnet.ru"), 0); - aboutData.addCredit(i18n("Dmitry Chernyak"), i18n("Old Russian translation"), QStringLiteral("chernyak@mail.ru"), 0); - aboutData.addCredit(i18n("Sasa Tomic"), i18n("Serbian translation"), QStringLiteral("stomic@gmx.net"), 0); - aboutData.addCredit(i18n("Zdenko Podobný and Ondrej Pačay (Yogi)"), i18n("Slovak translation"), QStringLiteral("zdenop@gmail.com"), 0); - aboutData.addCredit(i18n("Matej Urbancic"), i18n("Slovenian translation"), QStringLiteral("matej.urban@gmail.com"), 0); - aboutData.addCredit(i18n("Rafael Munoz"), i18n("Old Spanish translation"), QStringLiteral("muror@hotpop.com"), 0); - aboutData.addCredit(i18n("Alejandro Araiza Alvarado"), i18n("Spanish translation"), QStringLiteral("mebrelith@gmail.com"), 0); - aboutData.addCredit(i18n("Erik Johanssen"), i18n("Old Swedish translation"), QStringLiteral("erre@telia.com"), 0); - aboutData.addCredit(i18n("Anders Linden"), i18n("Old Swedish translation"), QStringLiteral("connyosis@gmx.net"), 0); - aboutData.addCredit(i18n("Peter Landgren"), i18n("Swedish translation"), QStringLiteral("peter.talken@telia.com"), 0); - aboutData.addCredit(i18n("Bekir Sonat"), i18n("Turkish translation"), QStringLiteral("bekirsonat@kde.org.tr"), 0); - aboutData.addCredit(i18n("Ivan Petrouchtchak"), i18n("Ukrainian translation"), QStringLiteral("connyosis@gmx.net"), 0); - aboutData.addCredit(i18n("Seongnam Jee"), i18n("Korean translation"), QStringLiteral("snjee@intellicam.com"), 0); + aboutData.addAuthor(i18n("Csaba Karai"), i18n("Developer (retired)"), QStringLiteral("ckarai@users.sourceforge.net"), nullptr); + aboutData.addAuthor(i18n("Heiner Eichmann"), i18n("Developer (retired)"), QStringLiteral("h.eichmann@gmx.de"), nullptr); + aboutData.addAuthor(i18n("Jonas Bähr"), i18n("Developer (retired)"), QStringLiteral("jonas.baehr@web.de"), nullptr); + aboutData.addAuthor(i18n("Václav Jůza"), i18n("Developer (retired)"), QStringLiteral("vaclavjuza@gmail.com"), nullptr); + aboutData.addAuthor(i18n("Jan Lepper"), i18n("Developer (retired)"), QStringLiteral("jan_lepper@gmx.de"), nullptr); + aboutData.addAuthor(i18n("Andrey Matveyakin"), i18n("Developer (retired)"), QStringLiteral("a.matveyakin@gmail.com"), nullptr); + aboutData.addAuthor(i18n("Simon Persson"), i18n("Developer (retired)"), QStringLiteral("simon.persson@mykolab.com"), nullptr); + aboutData.addAuthor(i18n("Dirk Eschler"), i18n("Webmaster (retired)"), QStringLiteral("deschler@users.sourceforge.net"), nullptr); + aboutData.addAuthor(i18n("Frank Schoolmeesters"), i18n("Documentation and marketing coordinator (retired)"), QStringLiteral("frank_schoolmeesters@yahoo.com"), nullptr); + aboutData.addAuthor(i18n("Richard Holt"), i18n("Documentation & Proofing (retired)"), QStringLiteral("richard.holt@gmail.com"), nullptr); + aboutData.addAuthor(i18n("Matej Urbancic"), i18n("Marketing & Product Research (retired)"), QStringLiteral("matej.urban@gmail.com"), nullptr); + aboutData.addCredit(i18n("kde.org"), i18n("Everyone involved in KDE"), nullptr, nullptr); + aboutData.addCredit(i18n("l10n.kde.org"), i18n("KDE Translation Teams"), nullptr, nullptr); + aboutData.addCredit(i18n("Jiří Paleček"), i18n("QA, bug-hunting, patches and general help"), QStringLiteral("jpalecek@web.de"), nullptr); + aboutData.addCredit(i18n("Jiří Klement"), i18n("Important help in KDE 4 porting"), nullptr, nullptr); + aboutData.addCredit(i18n("Andrew Neupokoev"), i18n("Killer Logo and Icons for Krusader (contest winner)"), QStringLiteral("doom-blue@yandex.ru"), nullptr); + aboutData.addCredit(i18n("The UsefulArts Organization"), i18n("Icon for Krusader"), QStringLiteral("mail@usefularts.org"), nullptr); + aboutData.addCredit(i18n("Gábor Lehel"), i18n("Viewer module for 3rd Hand"), QStringLiteral("illissius@gmail.com"), nullptr); + aboutData.addCredit(i18n("Mark Eatough"), i18n("Handbook Proof-Reader"), QStringLiteral("markeatough@yahoo.com"), nullptr); + aboutData.addCredit(i18n("Jan Halasa"), i18n("The old Bookmark Module"), QStringLiteral("xhalasa@fi.muni.cz"), nullptr); + aboutData.addCredit(i18n("Hans Löffler"), i18n("Dir history button"), nullptr, nullptr); + aboutData.addCredit(i18n("Szombathelyi György"), i18n("ISO KIO slave"), nullptr, nullptr); + aboutData.addCredit(i18n("Jan Willem van de Meent (Adios)"), i18n("Icons for Krusader"), QStringLiteral("janwillem@lorentz.leidenuniv.nl"), nullptr); + aboutData.addCredit(i18n("Mikolaj Machowski"), i18n("Usability and QA"), QStringLiteral(""), nullptr); + aboutData.addCredit(i18n("Cristi Dumitrescu"), i18n("QA, bug-hunting, patches and general help"), QStringLiteral("cristid@chip.ro"), nullptr); + aboutData.addCredit(i18n("Aurelien Gateau"), i18n("patch for KViewer"), QStringLiteral("aurelien.gateau@free.fr"), nullptr); + aboutData.addCredit(i18n("Milan Brabec"), i18n("the first patch ever!"), QStringLiteral("mbrabec@volny.cz"), nullptr); + aboutData.addCredit(i18n("Asim Husanovic"), i18n("Bosnian translation"), QStringLiteral("asim@megatel.ba"), nullptr); + aboutData.addCredit(i18n("Doutor Zero"), i18n("Brazilian Portuguese translation"), QStringLiteral("doutor.zero@gmail.com"), nullptr); + aboutData.addCredit(i18n("Milen Ivanov"), i18n("Bulgarian translation"), QStringLiteral("milen.ivanov@abv.bg"), nullptr); + aboutData.addCredit(i18n("Quim Perez"), i18n("Catalan translation"), QStringLiteral("noguer@osona.com"), nullptr); + aboutData.addCredit(i18n("Jinghua Luo"), i18n("Chinese Simplified translation"), QStringLiteral("luojinghua@msn.com"), nullptr); + aboutData.addCredit(i18n("Mitek"), i18n("Old Czech translation"), QStringLiteral("mitek@email.cz"), nullptr); + aboutData.addCredit(i18n("Martin Sixta"), i18n("Old Czech translation"), QStringLiteral("lukumo84@seznam.cz"), nullptr); + aboutData.addCredit(i18n("Vaclav Jůza"), i18n("Czech translation"), QStringLiteral("VaclavJuza@gmail.com"), nullptr); + aboutData.addCredit(i18n("Anders Bruun Olsen"), i18n("Old Danish translation"), QStringLiteral("anders@bruun-olsen.net"), nullptr); + aboutData.addCredit(i18n("Peter H. Sorensen"), i18n("Danish translation"), QStringLiteral("peters@skydebanen.net"), nullptr); + aboutData.addCredit(i18n("Frank Schoolmeesters"), i18n("Dutch translation"), QStringLiteral("frank_schoolmeesters@yahoo.com"), nullptr); + aboutData.addCredit(i18n("Rene-Pierre Lehmann"), i18n("Old French translation"), QStringLiteral("ripi@lepi.org"), nullptr); + aboutData.addCredit(i18n("David Guillerm"), i18n("French translation"), QStringLiteral("dguillerm@gmail.com"), nullptr); + aboutData.addCredit(i18n("Christoph Thielecke"), i18n("Old German translation"), QStringLiteral("crissi99@gmx.de"), nullptr); + aboutData.addCredit(i18n("Dirk Eschler"), i18n("German translation"), QStringLiteral("deschler@users.sourceforge.net"), nullptr); + aboutData.addCredit(i18n("Spiros Georgaras"), i18n("Greek translation"), QStringLiteral("sngeorgaras@gmail.com"), nullptr); + aboutData.addCredit(i18n("Kukk Zoltan"), i18n("Old Hungarian translation"), QStringLiteral("kukkzoli@freemail.hu"), nullptr); + aboutData.addCredit(i18n("Arpad Biro"), i18n("Hungarian translation"), QStringLiteral("biro_arpad@yahoo.com"), nullptr); + aboutData.addCredit(i18n("Giuseppe Bordoni"), i18n("Italian translation"), QStringLiteral("geppo@geppozone.com"), nullptr); + aboutData.addCredit(i18n("Hideki Kimura"), i18n("Japanese translation"), QStringLiteral("hangyo1973@gmail.com"), nullptr); + aboutData.addCredit(i18n("UTUMI Hirosi"), i18n("Old Japanese translation"), QStringLiteral("utuhiro@mx12.freecom.ne.jp"), nullptr); + aboutData.addCredit(i18n("Dovydas Sankauskas"), i18n("Lithuanian translation"), QStringLiteral("laisve@gmail.com"), nullptr); + aboutData.addCredit(i18n("Bruno Queiros"), i18n("Portuguese translation"), QStringLiteral("brunoqueiros@portugalmail.com"), nullptr); + aboutData.addCredit(i18n("Lukasz Janyst"), i18n("Old Polish translation"), QStringLiteral("ljan@wp.pl"), nullptr); + aboutData.addCredit(i18n("Pawel Salawa"), i18n("Polish translation"), QStringLiteral("boogie@myslenice.one.pl"), nullptr); + aboutData.addCredit(i18n("Tomek Grzejszczyk"), i18n("Polish translation"), QStringLiteral("tgrzej@onet.eu"), nullptr); + aboutData.addCredit(i18n("Dmitry A. Bugay"), i18n("Russian translation"), QStringLiteral("sam@vhnet.ru"), nullptr); + aboutData.addCredit(i18n("Dmitry Chernyak"), i18n("Old Russian translation"), QStringLiteral("chernyak@mail.ru"), nullptr); + aboutData.addCredit(i18n("Sasa Tomic"), i18n("Serbian translation"), QStringLiteral("stomic@gmx.net"), nullptr); + aboutData.addCredit(i18n("Zdenko Podobný and Ondrej Pačay (Yogi)"), i18n("Slovak translation"), QStringLiteral("zdenop@gmail.com"), nullptr); + aboutData.addCredit(i18n("Matej Urbancic"), i18n("Slovenian translation"), QStringLiteral("matej.urban@gmail.com"), nullptr); + aboutData.addCredit(i18n("Rafael Munoz"), i18n("Old Spanish translation"), QStringLiteral("muror@hotpop.com"), nullptr); + aboutData.addCredit(i18n("Alejandro Araiza Alvarado"), i18n("Spanish translation"), QStringLiteral("mebrelith@gmail.com"), nullptr); + aboutData.addCredit(i18n("Erik Johanssen"), i18n("Old Swedish translation"), QStringLiteral("erre@telia.com"), nullptr); + aboutData.addCredit(i18n("Anders Linden"), i18n("Old Swedish translation"), QStringLiteral("connyosis@gmx.net"), nullptr); + aboutData.addCredit(i18n("Peter Landgren"), i18n("Swedish translation"), QStringLiteral("peter.talken@telia.com"), nullptr); + aboutData.addCredit(i18n("Bekir Sonat"), i18n("Turkish translation"), QStringLiteral("bekirsonat@kde.org.tr"), nullptr); + aboutData.addCredit(i18n("Ivan Petrouchtchak"), i18n("Ukrainian translation"), QStringLiteral("connyosis@gmx.net"), nullptr); + aboutData.addCredit(i18n("Seongnam Jee"), i18n("Korean translation"), QStringLiteral("snjee@intellicam.com"), nullptr); // This will call QCoreApplication::setApplicationName, etc for us by using info in the KAboutData instance. // The only thing not called for us is setWindowIcon(), which is why we do it ourselves here. @@ -267,7 +267,7 @@ } // splash screen - if the user wants one - QSplashScreen *splash = 0; + QSplashScreen *splash = nullptr; { // don't remove bracket KConfigGroup cfg(KSharedConfig::openConfig(), QStringLiteral("Look&Feel")); if (cfg.readEntry("Show splashscreen", _ShowSplashScreen)) { @@ -281,7 +281,7 @@ } // don't remove bracket Krusader::AppName = appName; - Krusader *krusader = new Krusader(parser); + auto *krusader = new Krusader(parser); if(!url.isEmpty()) krusader->openUrl(url); diff --git a/krusader/panelmanager.h b/krusader/panelmanager.h --- a/krusader/panelmanager.h +++ b/krusader/panelmanager.h @@ -76,10 +76,10 @@ } // AbstractPanelManager implementation - virtual bool isLeft() const Q_DECL_OVERRIDE { return _left; } - virtual AbstractPanelManager *otherManager() const Q_DECL_OVERRIDE { return _otherManager; } - virtual KrPanel *currentPanel() const Q_DECL_OVERRIDE; - virtual void newTab(const QUrl &url, KrPanel *nextTo) Q_DECL_OVERRIDE { + bool isLeft() const Q_DECL_OVERRIDE { return _left; } + AbstractPanelManager *otherManager() const Q_DECL_OVERRIDE { return _otherManager; } + KrPanel *currentPanel() const Q_DECL_OVERRIDE; + void newTab(const QUrl &url, KrPanel *nextTo) Q_DECL_OVERRIDE { slotNewTab(url, true, nextTo); } @@ -100,7 +100,7 @@ } Q_SCRIPTABLE void newTabs(const QStringList& urls); - void slotNewTab(const QUrl &url, bool setCurrent = true, KrPanel *nextTo = 0); + void slotNewTab(const QUrl &url, bool setCurrent = true, KrPanel *nextTo = nullptr); void slotNewTab(); void slotLockTab(); void slotPinTab(); @@ -127,8 +127,8 @@ void deletePanel(ListPanel *p); void updateTabbarPos(); void tabsCountChanged(); - ListPanel* addPanel(bool setCurrent = true, KConfigGroup cfg = KConfigGroup(), KrPanel *nextTo = 0); - ListPanel* createPanel(KConfigGroup cfg); + ListPanel* addPanel(bool setCurrent = true, const KConfigGroup& cfg = KConfigGroup(), KrPanel *nextTo = nullptr); + ListPanel* createPanel(const KConfigGroup& cfg); void connectPanel(ListPanel *p); void disconnectPanel(ListPanel *p); diff --git a/krusader/panelmanager.cpp b/krusader/panelmanager.cpp --- a/krusader/panelmanager.cpp +++ b/krusader/panelmanager.cpp @@ -45,11 +45,11 @@ PanelManager::PanelManager(QWidget *parent, KrMainWindow* mainWindow, bool left) : QWidget(parent), - _otherManager(0), + _otherManager(nullptr), _actions(mainWindow->tabActions()), - _layout(0), + _layout(nullptr), _left(left), - _currentPanel(0) + _currentPanel(nullptr) { _layout = new QGridLayout(this); _layout->setContentsMargins(0, 0, 0, 0); @@ -74,7 +74,7 @@ connect(_tabbar, &PanelTabBar::draggingTab, this, &PanelManager::slotDraggingTab); connect(_tabbar, &PanelTabBar::draggingTabFinished, this, &PanelManager::slotDraggingTabFinished); - QHBoxLayout *tabbarLayout = new QHBoxLayout; + auto *tabbarLayout = new QHBoxLayout; tabbarLayout->setSpacing(0); tabbarLayout->setContentsMargins(0, 0, 0, 0); @@ -144,7 +144,7 @@ } } -ListPanel* PanelManager::createPanel(KConfigGroup cfg) +ListPanel* PanelManager::createPanel(const KConfigGroup& cfg) { ListPanel * p = new ListPanel(_stack, this, cfg); connectPanel(p); @@ -164,7 +164,7 @@ disconnect(p, &ListPanel::pathChanged, this, nullptr); } -ListPanel* PanelManager::addPanel(bool setCurrent, KConfigGroup cfg, KrPanel *nextTo) +ListPanel* PanelManager::addPanel(bool setCurrent, const KConfigGroup& cfg, KrPanel *nextTo) { // create the panel and add it into the widgetstack ListPanel * p = createPanel(cfg); @@ -403,10 +403,10 @@ int i = 0; while (i < _tabbar->count() - 1) { ListPanel * panel1 = _tabbar->getPanel(i); - if (panel1 != 0) { + if (panel1 != nullptr) { for (int j = i + 1; j < _tabbar->count(); j++) { ListPanel * panel2 = _tabbar->getPanel(j); - if (panel2 != 0 && panel1->virtualPath().matches(panel2->virtualPath(), QUrl::StripTrailingSlash)) { + if (panel2 != nullptr && panel1->virtualPath().matches(panel2->virtualPath(), QUrl::StripTrailingSlash)) { if (j == activeTab()) { slotCloseTab(i); i--; diff --git a/krusader/paneltabbar.h b/krusader/paneltabbar.h --- a/krusader/paneltabbar.h +++ b/krusader/paneltabbar.h @@ -55,7 +55,7 @@ /** * called by PanelManager with an already created panel, and creates the corresponding tab */ - int addPanel(ListPanel *panel, bool setCurrent = true, KrPanel *nextTo = 0); + int addPanel(ListPanel *panel, bool setCurrent = true, KrPanel *nextTo = nullptr); ListPanel* getPanel(int tabIdx); void changePanel(int tabIdx, ListPanel *panel); @@ -88,15 +88,15 @@ void draggingTabFinished(QMouseEvent*); protected: - virtual void mouseMoveEvent(QMouseEvent*e) Q_DECL_OVERRIDE; - virtual void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE; - virtual void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent*e) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE; void insertAction(QAction*); QString squeeze(const QUrl &url, int tabIndex = -1); - virtual void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE; - virtual void dragLeaveEvent(QDragLeaveEvent *) Q_DECL_OVERRIDE; - virtual void dragMoveEvent(QDragMoveEvent *) Q_DECL_OVERRIDE; - virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE; + void dragLeaveEvent(QDragLeaveEvent *) Q_DECL_OVERRIDE; + void dragMoveEvent(QDragMoveEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; protected slots: void duplicateTab(); diff --git a/krusader/paneltabbar.cpp b/krusader/paneltabbar.cpp --- a/krusader/paneltabbar.cpp +++ b/krusader/paneltabbar.cpp @@ -116,7 +116,7 @@ ListPanel* PanelTabBar::getPanel(int tabIdx) { QVariant v = tabData(tabIdx); - if (v.isNull()) return 0; + if (v.isNull()) return nullptr; return (ListPanel*)v.toLongLong(); } @@ -128,7 +128,7 @@ ListPanel* PanelTabBar::removePanel(int index, ListPanel* &panelToDelete) { panelToDelete = getPanel(index); // old panel to kill later - disconnect(panelToDelete, 0, this, 0); + disconnect(panelToDelete, nullptr, this, nullptr); removeTab(index); layoutTabs(); @@ -195,7 +195,7 @@ // set the real max length QFontMetrics fm(fontMetrics()); - _maxTabLength = (static_cast(parent())->width() - (6 * fm.width("W"))) / fm.width("W"); + _maxTabLength = (dynamic_cast(parent())->width() - (6 * fm.width("W"))) / fm.width("W"); // each tab gets a fair share of the max tab length const int effectiveTabLength = _maxTabLength / (count() == 0 ? 1 : count()); const int labelWidth = fm.width("W") * effectiveTabLength; diff --git a/krusader/tabactions.cpp b/krusader/tabactions.cpp --- a/krusader/tabactions.cpp +++ b/krusader/tabactions.cpp @@ -35,19 +35,19 @@ { actNewTab = action(i18n("New Tab"), "tab-new", QKeySequence::keyBindings(QKeySequence::AddTab), this, SLOT(newTab()), "new tab"); actDupTab = action(i18n("Duplicate Current Tab"), "tab-duplicate", Qt::ALT + Qt::CTRL + Qt::SHIFT + Qt::Key_N, SLOT(duplicateTab()), "duplicate tab"); - actMoveTabToOtherSide = action(i18n("Move Current Tab to Other Side"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_O, SLOT(moveTabToOtherSide()), "move_tab_to_other_side"); + actMoveTabToOtherSide = action(i18n("Move Current Tab to Other Side"), nullptr, Qt::CTRL + Qt::SHIFT + Qt::Key_O, SLOT(moveTabToOtherSide()), "move_tab_to_other_side"); actCloseTab = action(i18n("Close Current Tab"), "tab-close", KStandardShortcut::close(), this, SLOT(closeTab()), "close tab"); actNextTab = action(i18n("Next Tab"), QString(), KStandardShortcut::tabNext(), this, SLOT(nextTab()), "next tab"); actPreviousTab = action(i18n("Previous Tab"), QString(), KStandardShortcut::tabPrev(), this, SLOT(previousTab()), "previous tab"); - actCloseInactiveTabs = action(i18n("Close Inactive Tabs"), 0, 0, SLOT(closeInactiveTabs()), "close inactive tabs"); - actCloseDuplicatedTabs = action(i18n("Close Duplicated Tabs"), 0, 0, SLOT(closeDuplicatedTabs()), "close duplicated tabs"); + actCloseInactiveTabs = action(i18n("Close Inactive Tabs"), nullptr, 0, SLOT(closeInactiveTabs()), "close inactive tabs"); + actCloseDuplicatedTabs = action(i18n("Close Duplicated Tabs"), nullptr, 0, SLOT(closeDuplicatedTabs()), "close duplicated tabs"); actLockTab = action(i18n("Lock Tab"), "lock", 0, SLOT(lockTab()), "lock tab"); actPinTab = action(i18n("Pin Tab"), "pin", 0, SLOT(pinTab()), "pin tab"); } inline PanelManager *TabActions::activeManager() { - return static_cast( + return dynamic_cast( static_cast(_mainWindow)->activeManager()); }