diff --git a/src/kiosvn/kiosvn.cpp b/src/kiosvn/kiosvn.cpp --- a/src/kiosvn/kiosvn.cpp +++ b/src/kiosvn/kiosvn.cpp @@ -822,16 +822,16 @@ } catch (const svn::ClientException &e) { extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); } - for (long j = 0; j < urls.count(); ++j) { + for (const auto &url : urls) { QString userstring; if (nnum != svn::Revision::UNDEFINED) { userstring = i18n("Committed revision %1.", nnum.toString()); } else { userstring = i18n("Nothing to commit."); } const QString num(QString::number(m_pData->m_Listener.counter()).rightJustified(10, QLatin1Char('0'))); const QString zero(QStringLiteral("0")); - setMetaData(num + QLatin1String("path"), urls[j].path()); + setMetaData(num + QLatin1String("path"), url.path()); setMetaData(num + QLatin1String("action"), zero); setMetaData(num + QLatin1String("kind"), zero); setMetaData(num + QLatin1String("mime_t"), QString()); @@ -862,41 +862,39 @@ svn::LogParameter params; params.revisionRange(start, end).peg(svn::Revision::UNDEFINED).limit(0).discoverChangedPathes(true).strictNodeHistory(true); - for (long j = 0; j < urls.count(); ++j) { + for (const auto &url : urls) { svn::LogEntriesMap logs; try { - m_pData->m_Svnclient->log(params.targets(makeSvnPath(urls[j])), logs); + m_pData->m_Svnclient->log(params.targets(makeSvnPath(url)), logs); } catch (const svn::ClientException &e) { extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); break; } if (logs.isEmpty()) { const QString num(QString::number(m_pData->m_Listener.counter()).rightJustified(10, QLatin1Char('0'))); - setMetaData(num + QStringLiteral("path"), urls[j].path()); + setMetaData(num + QStringLiteral("path"), url.path()); setMetaData(num + QStringLiteral("string"), i18n("Empty logs")); m_pData->m_Listener.incCounter(); continue; } - svn::LogEntriesMap::const_iterator it = logs.constBegin(); - for (; it != logs.constEnd(); ++it) { + for (const svn::LogEntry &logEntry : qAsConst(logs)) { const QString num(QString::number(m_pData->m_Listener.counter()).rightJustified(10, QLatin1Char('0'))); - setMetaData(num + QStringLiteral("path"), urls[j].path()); - setMetaData(num + QStringLiteral("rev"), QString::number((*it).revision)); - setMetaData(num + QStringLiteral("author"), (*it).author); - setMetaData(num + QStringLiteral("logmessage"), (*it).message); + setMetaData(num + QStringLiteral("path"), url.path()); + setMetaData(num + QStringLiteral("rev"), QString::number(logEntry.revision)); + setMetaData(num + QStringLiteral("author"), logEntry.author); + setMetaData(num + QStringLiteral("logmessage"), logEntry.message); m_pData->m_Listener.incCounter(); - for (long z = 0; z < (*it).changedPaths.count(); ++z) { + for (const svn::LogChangePathEntry &logPathEntry : logEntry.changedPaths) { const QString num(QString::number(m_pData->m_Listener.counter()).rightJustified(10, QLatin1Char('0'))); - setMetaData(num + QStringLiteral("rev"), QString::number((*it).revision)); - setMetaData(num + QStringLiteral("path"), urls[j].path()); - setMetaData(num + QStringLiteral("loggedpath"), (*it).changedPaths[z].path); - setMetaData(num + QStringLiteral("loggedaction"), QString(QLatin1Char((*it).changedPaths[z].action))); - setMetaData(num + QStringLiteral("loggedcopyfrompath"), (*it).changedPaths[z].copyFromPath); - setMetaData(num + QStringLiteral("loggedcopyfromrevision"), QString::number((*it).changedPaths[z].copyFromRevision)); + setMetaData(num + QStringLiteral("rev"), QString::number(logEntry.revision)); + setMetaData(num + QStringLiteral("path"), url.path()); + setMetaData(num + QStringLiteral("loggedpath"), logPathEntry.path); + setMetaData(num + QStringLiteral("loggedaction"), QString(QLatin1Char(logPathEntry.action))); + setMetaData(num + QStringLiteral("loggedcopyfrompath"), logPathEntry.copyFromPath); + setMetaData(num + QStringLiteral("loggedcopyfromrevision"), QString::number(logPathEntry.copyFromRevision)); m_pData->m_Listener.incCounter(); - } } } diff --git a/src/ksvnwidgets/commitmsg_impl.cpp b/src/ksvnwidgets/commitmsg_impl.cpp --- a/src/ksvnwidgets/commitmsg_impl.cpp +++ b/src/ksvnwidgets/commitmsg_impl.cpp @@ -207,11 +207,11 @@ } } QStringList::const_iterator it; - for (it = sLogHistory.constBegin(); it != sLogHistory.constEnd(); ++it) { - if ((*it).length() <= 40) { - m_LogHistory->addItem((*it)); + for (const QString &historyEntry : qAsConst(sLogHistory)) { + if (historyEntry.length() <= 40) { + m_LogHistory->addItem(historyEntry); } else { - m_LogHistory->addItem((*it).left(37) + QStringLiteral("...")); + m_LogHistory->addItem(historyEntry.leftRef(37) + QStringLiteral("...")); } } if (!sLastMessage.isEmpty()) { diff --git a/src/ksvnwidgets/models/commitmodel.cpp b/src/ksvnwidgets/models/commitmodel.cpp --- a/src/ksvnwidgets/models/commitmodel.cpp +++ b/src/ksvnwidgets/models/commitmodel.cpp @@ -101,22 +101,21 @@ CommitActionEntries CommitModel::checkedEntries() const { CommitActionEntries res; - for (int i = 0; i < m_List.count(); ++i) { - if (m_List.at(i)->checked()) { - res.append(m_List.at(i)->actionEntry()); + for (const auto &entry : m_List) { + if (entry->checked()) { + res.append(entry->actionEntry()); } } return res; } void CommitModel::markItems(bool mark, CommitActionEntry::ACTION_TYPE _type) { - QVariant v = mark ? int(2) : int(0); + QVariant v = mark ? int(Qt::Checked) : int(Qt::Unchecked); for (int i = 0; i < m_List.count(); ++i) { if (m_List.at(i)->actionEntry().type() & _type) { QModelIndex _index = index(i, 0, QModelIndex()); setData(_index, v, Qt::CheckStateRole); - emit dataChanged(_index, _index, {Qt::CheckStateRole}); } } } diff --git a/src/ksvnwidgets/ssltrustprompt.cpp b/src/ksvnwidgets/ssltrustprompt.cpp --- a/src/ksvnwidgets/ssltrustprompt.cpp +++ b/src/ksvnwidgets/ssltrustprompt.cpp @@ -67,8 +67,8 @@ QString text = QStringLiteral(""); if (!reasons.isEmpty()) { text += QStringLiteral("

") + i18n("Failure reasons") + QStringLiteral("

"); - for (int i = 0; i < reasons.count(); ++i) { - text += reasons.at(i)+ QStringLiteral("
"); + for (const QString &reason : reasons) { + text += reason + QStringLiteral("
"); } text += QStringLiteral("

"); } diff --git a/src/svnfrontend/background/getinfothread.cpp b/src/svnfrontend/background/getinfothread.cpp --- a/src/svnfrontend/background/getinfothread.cpp +++ b/src/svnfrontend/background/getinfothread.cpp @@ -93,9 +93,8 @@ } QMutexLocker ml(&m_QueueLock); bool found = false; - QQueue::const_iterator it = m_NodeQueue.constBegin(); - for (; it != m_NodeQueue.constEnd(); ++it) { - if ((*it)->fullName() == node->fullName()) { + for (const SvnItemModelNode *qNode : qAsConst(m_NodeQueue)) { + if (qNode->fullName() == node->fullName()) { found = true; break; } diff --git a/src/svnfrontend/blamedisplay.h b/src/svnfrontend/blamedisplay.h --- a/src/svnfrontend/blamedisplay.h +++ b/src/svnfrontend/blamedisplay.h @@ -27,7 +27,7 @@ class BlameDisplay; } class BlameTreeItem; -class BlameDisplayData; +struct BlameDisplayData; class QTreeWidgetItem; class SimpleLogCb; diff --git a/src/svnfrontend/blamedisplay.cpp b/src/svnfrontend/blamedisplay.cpp --- a/src/svnfrontend/blamedisplay.cpp +++ b/src/svnfrontend/blamedisplay.cpp @@ -156,32 +156,22 @@ localeChanged(); } -class BlameDisplayData +struct BlameDisplayData { -public: - BlameDisplayData() - : max(-1) - , min(INT_MAX - 1) - , rev_count(0) - , up(false) - , m_cb(nullptr) - , m_pbGoToLine(nullptr) - , m_pbShowLog(nullptr) - {} - - svn_revnum_t max, min; - QMap m_shadingMap; - QMap m_logCache; + QHash m_shadingMap; + QHash m_logCache; QColor m_lastCalcColor; - unsigned int rev_count; - bool up; - SimpleLogCb *m_cb; + SimpleLogCb *m_cb = nullptr; QString m_File; QString reposRoot; - QPushButton *m_pbGoToLine; - QPushButton *m_pbShowLog; + QPushButton *m_pbGoToLine = nullptr; + QPushButton *m_pbShowLog = nullptr; + svn_revnum_t max = -1; + svn_revnum_t min = std::numeric_limits::max() - 1; + unsigned int rev_count = 0; + bool up = false; }; BlameDisplay::BlameDisplay(const QString &what, const svn::AnnotatedFile &blame, SimpleLogCb *cb, QWidget *parent) @@ -232,7 +222,6 @@ m_Data->m_File = what; m_Data->m_pbShowLog->setEnabled(false); - svn::AnnotatedFile::const_iterator bit; //m_BlameList->setSorting(COL_LINENR,false); m_Data->max = -1; svn_revnum_t lastRev(-1); @@ -249,26 +238,28 @@ bool _b_init = false, _bt_init = false; - for (bit = blame.begin(); bit != blame.end(); ++bit) { - bool disp = (*bit).revision() != lastRev || bit == blame.begin() ; + for (auto bit = blame.begin(); bit != blame.end(); ++bit) { + const svn::AnnotateLine &line = *bit; + bool disp = line.revision() != lastRev || bit == blame.begin(); - if ((*bit).revision() > m_Data->max) { - m_Data->max = (*bit).revision(); + if (line.revision() > m_Data->max) { + m_Data->max = line.revision(); ++(m_Data->rev_count); } - if ((*bit).revision() < m_Data->min) { - m_Data->min = (*bit).revision(); + if (line.revision() < m_Data->min) { + m_Data->min = line.revision(); } - BlameTreeItem *item = new BlameTreeItem((*bit), disp); + BlameTreeItem *item = new BlameTreeItem(line, disp); _list.append(item); if (disp) { - lastRev = (*bit).revision(); + lastRev = line.revision(); } if (Kdesvnsettings::self()->colored_blame()) { - if (m_Data->m_shadingMap.find((*bit).revision()) == m_Data->m_shadingMap.end()) { + auto it = m_Data->m_shadingMap.find(line.revision()); + if (it == m_Data->m_shadingMap.end()) { a.setRgb(a.red() + offset, a.green() + offset, a.blue() + offset); - m_Data->m_shadingMap[(*bit).revision()] = a; + m_Data->m_shadingMap.insert(line.revision(), a); if (a.red() > 245 || a.green() > 245 || a.blue() > 245) { if (colinc == 0) { ++colinc; @@ -309,13 +300,13 @@ _bt = item->background(COL_REV); _bt.setStyle(Qt::SolidPattern); } - _bt.setColor(m_Data->m_shadingMap.value((*bit).revision())); + _bt.setColor(m_Data->m_shadingMap.value(line.revision())); item->setBackground(COL_REV, _bt); item->setBackground(COL_DATE, _bt); item->setBackground(COL_AUT, _bt); item->setBackground(COL_LINE, _bt); } else { - m_Data->m_shadingMap[(*bit).revision()] = QColor(); + m_Data->m_shadingMap[line.revision()] = QColor(); } } m_ui->m_BlameTree->addTopLevelItems(_list); @@ -354,7 +345,7 @@ return; } QString text; - const QMap::const_iterator it = m_Data->m_logCache.constFind(bti->rev()); + const auto it = m_Data->m_logCache.constFind(bti->rev()); if (it != m_Data->m_logCache.constEnd()) { text = it.value().message; } else { diff --git a/src/svnfrontend/cacheentry.h b/src/svnfrontend/cacheentry.h --- a/src/svnfrontend/cacheentry.h +++ b/src/svnfrontend/cacheentry.h @@ -45,8 +45,6 @@ public: typedef cacheEntry cache_type; typedef typename std::map cache_map_type; - typedef typename cache_map_type::const_iterator citer; - typedef typename cache_map_type::iterator iter; protected: QString m_key; @@ -59,7 +57,7 @@ cacheEntry(const QString &key); cacheEntry(const cacheEntry &other); - virtual ~cacheEntry() {}; + virtual ~cacheEntry() = default; virtual bool find(QStringList &, QList &)const; //! Checks if cache contains a specific item @@ -122,8 +120,7 @@ { QString pre; pre.fill('-', level); - std::map::const_iterator it; - for (it = m_subMap.begin(); it != m_subMap.end(); ++it) { + for (auto it = m_subMap.begin(); it != m_subMap.end(); ++it) { std::cout << pre.latin1() << it->first.latin1() << " (" << it->second.m_key.latin1() << ")" << std::endl; it->second.dump_tree(level + 1); } @@ -158,12 +155,12 @@ return *this; } -template inline bool cacheEntry::find(QStringList &what, QList &t)const +template inline bool cacheEntry::find(QStringList &what, QList &t) const { if (what.empty()) { return false; } - citer it = m_subMap.find(what.at(0)); + const auto it = m_subMap.find(what.at(0)); if (it == m_subMap.end()) { return false; } @@ -178,12 +175,12 @@ return it->second.find(what, t); } -template inline bool cacheEntry::find(QStringList &what)const +template inline bool cacheEntry::find(QStringList &what) const { if (what.isEmpty()) { return false; } - citer it = m_subMap.find(what.at(0)); + const auto it = m_subMap.find(what.at(0)); if (it == m_subMap.end()) { return false; } @@ -194,12 +191,12 @@ return it->second.find(what); } -template inline bool cacheEntry::findSingleValid(QStringList &what, C &t)const +template inline bool cacheEntry::findSingleValid(QStringList &what, C &t) const { if (what.isEmpty()) { return false; } - citer it = m_subMap.find(what.at(0)); + const auto it = m_subMap.find(what.at(0)); if (it == m_subMap.end()) { return false; } @@ -211,12 +208,12 @@ return it->second.findSingleValid(what, t); } -template inline bool cacheEntry::findSingleValid(QStringList &what, bool check_valid_subs)const +template inline bool cacheEntry::findSingleValid(QStringList &what, bool check_valid_subs) const { if (what.isEmpty()) { return false; } - citer it = m_subMap.find(what.at(0)); + const auto it = m_subMap.find(what.at(0)); if (it == m_subMap.end()) { return false; } @@ -227,23 +224,22 @@ return it->second.findSingleValid(what, check_valid_subs); } -template inline void cacheEntry::appendValidSub(QList &t)const +template inline void cacheEntry::appendValidSub(QList &t) const { - citer it; - for (it = m_subMap.begin(); it != m_subMap.end(); ++it) { - if (it->second.isValid()) { - t.append(it->second.content()); + for (const auto &it : m_subMap) { + if (it.second.isValid()) { + t.append(it.second.content()); } - it->second.appendValidSub(t); + it.second.appendValidSub(t); } } template inline bool cacheEntry::deleteKey(QStringList &what, bool exact) { if (what.isEmpty()) { return true; } - iter it = m_subMap.find(what.at(0)); + const auto it = m_subMap.find(what.at(0)); if (it == m_subMap.end()) { return true; } @@ -268,11 +264,10 @@ return caller_must_check; } -template inline bool cacheEntry::hasValidSubs()const +template inline bool cacheEntry::hasValidSubs() const { - citer it; - for (it = m_subMap.begin(); it != m_subMap.end(); ++it) { - if (it->second.isValid() || it->second.hasValidSubs()) { + for (const auto &it : m_subMap) { + if (it.second.isValid() || it.second.hasValidSubs()) { return true; } } @@ -297,15 +292,15 @@ m_subMap[m].insertKey(what, st); } -template template inline void cacheEntry::listsubs_if(QStringList &what, T &oper)const +template template inline void cacheEntry::listsubs_if(QStringList &what, T &oper) const { if (what.isEmpty()) { /* we are the one to get the list for*/ oper = for_each(m_subMap.begin(), m_subMap.end(), oper); return; } /* otherwise find next */ - citer it = m_subMap.find(what.at(0)); + const auto it = m_subMap.find(what.at(0)); if (it == m_subMap.end()) { /* not found */ return; @@ -319,17 +314,15 @@ public: typedef cacheEntry cache_type; typedef typename std::map cache_map_type; - typedef typename cache_map_type::const_iterator citer; - typedef typename cache_map_type::iterator iter; protected: cache_map_type m_contentMap; mutable QReadWriteLock m_RWLock; public: - itemCache(): m_contentMap(), m_RWLock() {} - virtual ~itemCache() {} + itemCache() = default; + virtual ~itemCache() = default; void clear() { @@ -363,8 +356,8 @@ } QWriteLocker locker(&m_RWLock); - const QString m = _keys.at(0); - citer it = m_contentMap.find(m); + const QString &m = _keys.at(0); + const auto it = m_contentMap.find(m); if (it == m_contentMap.end()) { m_contentMap[m] = cache_type(m); @@ -388,7 +381,7 @@ if (_keys.isEmpty()) { return false; } - citer it = m_contentMap.find(_keys.at(0)); + const auto it = m_contentMap.find(_keys.at(0)); if (it == m_contentMap.end()) { return false; } @@ -410,7 +403,7 @@ if (what.isEmpty()) { return; } - iter it = m_contentMap.find(what.at(0)); + const auto it = m_contentMap.find(what.at(0)); if (it == m_contentMap.end()) { return; } @@ -437,8 +430,7 @@ template inline void itemCache::dump_tree() { QReadLocker locker(&m_RWLock); - citer it; - for (it = m_contentMap.begin(); it != m_contentMap.end(); ++it) { + for (auto it = m_contentMap.begin(); it != m_contentMap.end(); ++it) { // std::cout<first.latin1() << " (" << it->second.key().latin1() << ")"<second.dump_tree(1); } @@ -455,7 +447,7 @@ if (what.isEmpty()) { return false; } - citer it = m_contentMap.find(what.at(0)); + const auto it = m_contentMap.find(what.at(0)); if (it == m_contentMap.end()) { return false; } @@ -481,7 +473,7 @@ if (what.isEmpty()) { return false; } - citer it = m_contentMap.find(what.at(0)); + const auto it = m_contentMap.find(what.at(0)); if (it == m_contentMap.end()) { return false; } @@ -503,8 +495,7 @@ if (what.isEmpty()) { return; } - citer it = m_contentMap.find(what.at(0)); - + const auto it = m_contentMap.find(what.at(0)); if (it == m_contentMap.end()) { return; } diff --git a/src/svnfrontend/fronthelpers/propertylist.cpp b/src/svnfrontend/fronthelpers/propertylist.cpp --- a/src/svnfrontend/fronthelpers/propertylist.cpp +++ b/src/svnfrontend/fronthelpers/propertylist.cpp @@ -65,8 +65,7 @@ if (!propList->isEmpty()) { /* just want the first one */ const svn::PropertiesMap pmap = propList->at(0).second; - svn::PropertiesMap::const_iterator pit; - for (pit = pmap.constBegin(); pit != pmap.constEnd(); ++pit) { + for (auto pit = pmap.constBegin(); pit != pmap.constEnd(); ++pit) { PropertyListViewItem *ki = new PropertyListViewItem(this, pit.key(), pit.value()); diff --git a/src/svnfrontend/fronthelpers/watchedprocess.cpp b/src/svnfrontend/fronthelpers/watchedprocess.cpp --- a/src/svnfrontend/fronthelpers/watchedprocess.cpp +++ b/src/svnfrontend/fronthelpers/watchedprocess.cpp @@ -20,29 +20,26 @@ #include "watchedprocess.h" #include -#include -#include +#include class ProcessData { public: - ProcessData() - : _autoDelete(false) - {} + ProcessData() = default; ~ProcessData() { QStringList::iterator it2; - for (it2 = _tempFiles.begin(); it2 != _tempFiles.end(); ++it2) { - QFile::remove(*it2); + for (const QString &fn : qAsConst(_tempFiles)) { + QFile::remove(fn); } - for (it2 = _tempDirs.begin(); it2 != _tempDirs.end(); ++it2) { - QDir(*it2).removeRecursively(); + for (const QString &dir : qAsConst(_tempDirs)) { + QDir(dir).removeRecursively(); } } QStringList _tempFiles; QStringList _tempDirs; - bool _autoDelete; + bool _autoDelete = false; }; WatchedProcess::WatchedProcess(QObject *parent) diff --git a/src/svnfrontend/graphtree/revisiontree.cpp b/src/svnfrontend/graphtree/revisiontree.cpp --- a/src/svnfrontend/graphtree/revisiontree.cpp +++ b/src/svnfrontend/graphtree/revisiontree.cpp @@ -137,9 +137,8 @@ m_Data->progress->setAutoClose(false); m_Data->progress->setWindowModality(Qt::WindowModal); bool cancel = false; - svn::LogEntriesMap::Iterator it; - unsigned count = 0; - for (it = m_Data->m_OldHistory.begin(); it != m_Data->m_OldHistory.end(); ++it) { + int count = 0; + for (auto it = m_Data->m_OldHistory.begin(); it != m_Data->m_OldHistory.end(); ++it) { m_Data->progress->setValue(count); QCoreApplication::processEvents(); if (m_Data->progress->wasCanceled()) { diff --git a/src/svnfrontend/maintreewidget.cpp b/src/svnfrontend/maintreewidget.cpp --- a/src/svnfrontend/maintreewidget.cpp +++ b/src/svnfrontend/maintreewidget.cpp @@ -390,8 +390,8 @@ } return ret; } - for (int i = 0; i < _mi.count(); ++i) { - ret.push_back(m_Data->sourceNode(_mi[i], false)); + for (const QModelIndex &idx : _mi) { + ret.push_back(m_Data->sourceNode(idx, false)); } return ret; } @@ -401,8 +401,8 @@ SvnItemList ret; const QModelIndexList _mi = m_DirTreeView->selectionModel()->selectedRows(0); ret.reserve(_mi.size()); - for (int i = 0; i < _mi.count(); ++i) { - ret.push_back(m_Data->sourceNode(_mi[i], true)); + for (const QModelIndex &idx : _mi) { + ret.push_back(m_Data->sourceNode(idx, true)); } return ret; } @@ -1053,11 +1053,11 @@ if (!m_Data->m_Model->svnWrapper()->makeStatus(item->fullName(), res, start, _d, true /* all entries */, false, false)) { return; } - for (int i = 0; i < res.count(); ++i) { - if (!res[i]->isRealVersioned() || res[i]->entry().kind() != svn_node_dir) { + for (const svn::StatusPtr &ptr: qAsConst(res)) { + if (!ptr->isRealVersioned() || ptr->entry().kind() != svn_node_dir) { continue; } - m_Data->m_Model->svnWrapper()->makeIgnoreEntry(res[i]->path(), _pattern, unignore); + m_Data->m_Model->svnWrapper()->makeIgnoreEntry(ptr->path(), _pattern, unignore); } refreshCurrentTree(); delete dlg; @@ -1337,8 +1337,8 @@ ptr->saveHistory(false); QStringList displist; - for (int i = 0; i < lst.count(); ++i) { - displist.append(lst[i]->fullName()); + for (const SvnItem *item : lst) { + displist.append(item->fullName()); } m_Data->m_Model->svnWrapper()->makeLock(displist, logMessage, steal); refreshCurrentTree(); @@ -1366,8 +1366,8 @@ bool breakit = res == KMessageBox::Yes; QStringList displist; - for (int i = 0; i < lst.count(); ++i) { - displist.append(lst[i]->fullName()); + for (const SvnItem *item : lst) { + displist.append(item->fullName()); } m_Data->m_Model->svnWrapper()->makeUnlock(displist, breakit); refreshCurrentTree(); @@ -1698,11 +1698,10 @@ if (!isWorkingCopy()) { nProto = svn::Url::transformProtokoll(lst[0].scheme()); } - QList::iterator it = lst.begin(); - for (; it != lst.end(); ++it) { - (*it).setQuery(QUrlQuery()); + for (QUrl &url : lst) { + url.setQuery(QUrlQuery()); if (!nProto.isEmpty()) - (*it).setScheme(nProto); + url.setScheme(nProto); } if (index.isValid()) { diff --git a/src/svnfrontend/models/logitemmodel.h b/src/svnfrontend/models/logitemmodel.h --- a/src/svnfrontend/models/logitemmodel.h +++ b/src/svnfrontend/models/logitemmodel.h @@ -31,7 +31,7 @@ typedef QSharedPointer SvnLogModelNodePtr; -class SvnLogModel: public QAbstractListModel +class SvnLogModel final : public QAbstractListModel { Q_OBJECT public: @@ -51,10 +51,10 @@ Count }; - QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex &) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + int columnCount(const QModelIndex &idx = QModelIndex()) const override; SvnLogModelNodePtr indexNode(const QModelIndex &)const; int leftRow() const; diff --git a/src/svnfrontend/models/logitemmodel.cpp b/src/svnfrontend/models/logitemmodel.cpp --- a/src/svnfrontend/models/logitemmodel.cpp +++ b/src/svnfrontend/models/logitemmodel.cpp @@ -57,17 +57,16 @@ m_data.reserve(log->count()); beginInsertRows(QModelIndex(), 0, log->count() - 1); - svn::LogEntriesMap::const_iterator it = log->constBegin(); - for (; it != log->constEnd(); ++it) { - SvnLogModelNodePtr np(new SvnLogModelNode((*it))); + for (const svn::LogEntry &entry : qAsConst(*log)) { + SvnLogModelNodePtr np(new SvnLogModelNode(entry)); m_data.append(np); - if ((*it).revision > m_max) { - m_max = (*it).revision; + if (entry.revision > m_max) { + m_max = entry.revision; } - if ((*it).revision < m_min || m_min == -1) { - m_min = (*it).revision; + if (entry.revision < m_min || m_min == -1) { + m_min = entry.revision; } - itemMap[(*it).revision] = np; + itemMap[entry.revision] = np; } endInsertRows(); QString bef = m_name; @@ -97,8 +96,7 @@ int SvnLogModel::rowCount(const QModelIndex &parent) const { - Q_UNUSED(parent); - return m_data.count(); + return parent.isValid() ? 0 : m_data.count(); } QVariant SvnLogModel::data(const QModelIndex &index, int role) const @@ -160,9 +158,9 @@ return m_data[index.row()]->realName(); } -int SvnLogModel::columnCount(const QModelIndex &)const +int SvnLogModel::columnCount(const QModelIndex &idx) const { - return Count; + return idx.isValid() ? 0 : Count; } QVariant SvnLogModel::headerData(int section, Qt::Orientation orientation, int role) const @@ -203,8 +201,8 @@ return; } QList _list; - for (int i = 0; i < _l->changedPaths().count(); ++i) { - _list.append(new LogChangePathItem(_l->changedPaths()[i])); + for (const svn::LogChangePathEntry &entry : _l->changedPaths()) { + _list.append(new LogChangePathItem(entry)); } where->addTopLevelItems(_list); where->resizeColumnToContents(0); diff --git a/src/svnfrontend/models/logmodelhelper.cpp b/src/svnfrontend/models/logmodelhelper.cpp --- a/src/svnfrontend/models/logmodelhelper.cpp +++ b/src/svnfrontend/models/logmodelhelper.cpp @@ -64,8 +64,7 @@ bool SvnLogModelNode::copiedFrom(QString &_n, qlonglong &_rev)const { - for (int i = 0; i < _data.changedPaths.count(); ++i) { - const svn::LogChangePathEntry &entry =_data.changedPaths.at(i); + for (const svn::LogChangePathEntry &entry : _data.changedPaths) { if (entry.action == 'A' && !entry.copyFromPath.isEmpty() && isParent(entry.path, _realName)) { diff --git a/src/svnfrontend/models/svnitemmodel.cpp b/src/svnfrontend/models/svnitemmodel.cpp --- a/src/svnfrontend/models/svnitemmodel.cpp +++ b/src/svnfrontend/models/svnitemmodel.cpp @@ -386,19 +386,19 @@ svn::StatusEntries neweritems; svnWrapper()->getaddedItems(what, neweritems); dlist += neweritems; - svn::StatusEntries::iterator it = dlist.begin(); SvnItemModelNode *node = nullptr; - for (; it != dlist.end(); ++it) { - if ((*it)->path() == what || (*it)->entry().url().toString() == what) { + for (auto it = dlist.begin(); it != dlist.end(); ++it) { + const svn::StatusPtr &sp = *it; + if (sp->path() == what || sp->entry().url().toString() == what) { if (!_parent) { // toplevel item beginInsertRows(m_Data->indexForNode(m_Data->m_rootNode), 0, 0); - if ((*it)->entry().kind() == svn_node_dir) { + if (sp->entry().kind() == svn_node_dir) { node = new SvnItemModelNodeDir(m_Data->m_rootNode, svnWrapper(), m_Data->m_Display); } else { node = new SvnItemModelNode(m_Data->m_rootNode, svnWrapper(), m_Data->m_Display); } - node->setStat((*it)); + node->setStat(sp); m_Data->m_rootNode->m_Children.prepend(node); endInsertRows(); } @@ -430,21 +430,20 @@ } SvnItemModelNode *node = nullptr; beginInsertRows(ind, parent->childList().count(), parent->childList().count() + dlist.count() - 1); - svn::StatusEntries::iterator it = dlist.begin(); #ifdef DEBUG_TIMER QTime _counttime; _counttime.start(); #endif - for (; it != dlist.end(); ++it) { + for (const svn::StatusPtr &sp : dlist) { #ifdef DEBUG_TIMER _counttime.restart(); #endif - if (m_Data->MustCreateDir(*(*it))) { + if (m_Data->MustCreateDir(*sp)) { node = new SvnItemModelNodeDir(parent, svnWrapper(), m_Data->m_Display); } else { node = new SvnItemModelNode(parent, svnWrapper(), m_Data->m_Display); } - node->setStat((*it)); + node->setStat(sp); #ifdef DEBUG_TIMER // qCDebug(KDESVN_LOG)<<"Time creating item: "<<_counttime.elapsed(); _counttime.restart(); @@ -724,14 +723,11 @@ if (!svnWrapper()->makeStatus(what, dlist, m_Data->m_Display->baseRevision(), false, true, true)) { return; } - svn::StatusEntries::iterator it; - for (it = dlist.begin(); it != dlist.end();) { - if (n->contains((*it)->path()) || (*it)->path() == what) { - it = dlist.erase(it); - } else { - ++it; - } - } + const auto pred = [&](const svn::StatusPtr &sp) -> bool + { + return n->contains(sp->path()) || sp->path() == what; + }; + dlist.erase(std::remove_if(dlist.begin(), dlist.end(), pred), dlist.end()); if (!dlist.isEmpty()) { insertDirs(n, dlist); } @@ -829,39 +825,37 @@ dlist += neweritems; } - svn::StatusEntries::iterator it = dlist.begin(); - - for (it = dlist.begin(); it != dlist.end(); ++it) { + for (auto it = dlist.begin(); it != dlist.end(); ++it) { if ((*it)->path() == what) { dlist.erase(it); break; } } QModelIndex ind = m_Data->indexForNode(node); for (int i = 0; i < node->m_Children.size(); ++i) { + const SvnItemModelNode *n = node->m_Children[i]; bool found = false; - for (it = dlist.begin(); it != dlist.end(); ++it) { - if ((*it)->path() == node->m_Children[i]->fullName()) { + for (const auto &entry : qAsConst(dlist)) { + if (entry->path() == n->fullName()) { found = true; break; } } if (!found) { - SvnItemModelNode *n = node->m_Children[i]; beginRemoveRows(ind, i, i); node->m_Children.removeAt(i); delete n; endRemoveRows(); --i; } } - for (it = dlist.begin(); it != dlist.end();) { + for (auto it = dlist.begin(); it != dlist.end();) { int index = node->indexOf((*it)->path()); if (index != -1) { - node->m_Children[index]->setStat((*it)); - if (node->m_Children[index]->NodeIsDir() != node->m_Children[index]->isDir()) { - SvnItemModelNode *n = node->m_Children[index]; + SvnItemModelNode *n = node->m_Children[index]; + n->setStat((*it)); + if (n->NodeIsDir() != n->isDir()) { beginRemoveRows(ind, index, index); node->m_Children.removeAt(index); delete n; diff --git a/src/svnfrontend/svnactions.cpp b/src/svnfrontend/svnactions.cpp --- a/src/svnfrontend/svnactions.cpp +++ b/src/svnfrontend/svnactions.cpp @@ -603,8 +603,8 @@ QLatin1String("Type == 'Application'")); } KService::List::ConstIterator it = offers.constBegin(); - for (; it != offers.constEnd(); ++it) { - if ((*it)->noDisplay()) { + for (const auto &offer : qAsConst(offers)) { + if (offer->noDisplay()) { continue; } break; @@ -676,11 +676,11 @@ QString SvnActions::getInfo(const SvnItemList &lst, const svn::Revision &rev, const svn::Revision &peg, bool recursive, bool all) { QString res; - for (auto it = lst.cbegin(); it != lst.cend(); ++it) { + for (const SvnItem *item : lst) { if (all) { - res += QStringLiteral("

%1

").arg((*it)->fullName()); + res += QStringLiteral("

%1

").arg(item->fullName()); } - res += getInfo((*it)->fullName(), rev, peg, recursive, all); + res += getInfo(item->fullName(), rev, peg, recursive, all); } return res; } @@ -725,27 +725,27 @@ static QString re(QStringLiteral("\n")); static QString cs(QStringLiteral(":")); unsigned int val = 0; - for (auto it = entries.begin(); it != entries.end(); ++it) { + for (const svn::InfoEntry &entry : entries) { if (val > 0) { text += QStringLiteral(""); } ++val; text += QStringLiteral("

"); text += QStringLiteral(""); - if (!(*it).Name().isEmpty()) { - text += rb + i18n("Name") + cs + ((*it).Name()) + re; + if (!entry.Name().isEmpty()) { + text += rb + i18n("Name") + cs + (entry.Name()) + re; } if (all) { - text += rb + i18n("URL") + cs + ((*it).url().toDisplayString()) + re; - if (!(*it).reposRoot().toString().isEmpty()) { - text += rb + i18n("Canonical repository URL") + cs + ((*it).reposRoot().toDisplayString()) + re; + text += rb + i18n("URL") + cs + (entry.url().toDisplayString()) + re; + if (!entry.reposRoot().toString().isEmpty()) { + text += rb + i18n("Canonical repository URL") + cs + (entry.reposRoot().toDisplayString()) + re; } - if (!(*it).checksum().isEmpty()) { - text += rb + i18n("Checksum") + cs + ((*it).checksum()) + re; + if (!entry.checksum().isEmpty()) { + text += rb + i18n("Checksum") + cs + (entry.checksum()) + re; } } text += rb + i18n("Type") + cs; - switch ((*it).kind()) { + switch (entry.kind()) { case svn_node_none: text += i18n("Absent"); break; @@ -761,18 +761,18 @@ break; } text += re; - if ((*it).kind() == svn_node_file) { + if (entry.kind() == svn_node_file) { text += rb + i18n("Size") + cs; - if ((*it).size() != svn::InfoEntry::SVNQT_SIZE_UNKNOWN) { - text += helpers::ByteToString((*it).size()); - } else if ((*it).working_size() != svn::InfoEntry::SVNQT_SIZE_UNKNOWN) { - text += helpers::ByteToString((*it).working_size()); + if (entry.size() != svn::InfoEntry::SVNQT_SIZE_UNKNOWN) { + text += helpers::ByteToString(entry.size()); + } else if (entry.working_size() != svn::InfoEntry::SVNQT_SIZE_UNKNOWN) { + text += helpers::ByteToString(entry.working_size()); } text += re; } if (all) { text += rb + i18n("Schedule") + cs; - switch ((*it).Schedule()) { + switch (entry.Schedule()) { case svn_wc_schedule_normal: text += i18n("Normal"); break; @@ -790,39 +790,39 @@ break; } text += re; - text += rb + i18n("UUID") + cs + ((*it).uuid()) + re; + text += rb + i18n("UUID") + cs + (entry.uuid()) + re; } - text += rb + i18n("Last author") + cs + ((*it).cmtAuthor()) + re; - if ((*it).cmtDate().IsValid()) { - text += rb + i18n("Last committed") + cs + (*it).cmtDate().toString() + re; + text += rb + i18n("Last author") + cs + (entry.cmtAuthor()) + re; + if (entry.cmtDate().IsValid()) { + text += rb + i18n("Last committed") + cs + entry.cmtDate().toString() + re; } - text += rb + i18n("Last revision") + cs + (*it).cmtRev().toString() + re; - if ((*it).textTime().IsValid()) { - text += rb + i18n("Content last changed") + cs + (*it).textTime().toString() + re; + text += rb + i18n("Last revision") + cs + entry.cmtRev().toString() + re; + if (entry.textTime().IsValid()) { + text += rb + i18n("Content last changed") + cs + entry.textTime().toString() + re; } if (all) { - if ((*it).propTime().IsValid()) { - text += rb + i18n("Property last changed") + cs + (*it).propTime().toString() + re; + if (entry.propTime().IsValid()) { + text += rb + i18n("Property last changed") + cs + entry.propTime().toString() + re; } - for (const auto & _cfi : (*it).conflicts()) { + for (const auto & _cfi : entry.conflicts()) { text += rb + i18n("New version of conflicted file") + cs + (_cfi->theirFile()); } - if ((*it).prejfile().length()) { + if (entry.prejfile().length()) { text += rb + i18n("Property reject file") + - cs + ((*it).prejfile()) + re; + cs + (entry.prejfile()) + re; } - if (!(*it).copyfromUrl().isEmpty()) { - text += rb + i18n("Copy from URL") + cs + ((*it).copyfromUrl().toDisplayString()) + re; + if (!entry.copyfromUrl().isEmpty()) { + text += rb + i18n("Copy from URL") + cs + (entry.copyfromUrl().toDisplayString()) + re; } - if ((*it).lockEntry().Locked()) { - text += rb + i18n("Lock token") + cs + ((*it).lockEntry().Token()) + re; - text += rb + i18n("Owner") + cs + ((*it).lockEntry().Owner()) + re; + if (entry.lockEntry().Locked()) { + text += rb + i18n("Lock token") + cs + (entry.lockEntry().Token()) + re; + text += rb + i18n("Owner") + cs + (entry.lockEntry().Owner()) + re; text += rb + i18n("Locked on") + cs + - (*it).lockEntry().Date().toString() + + entry.lockEntry().Date().toString() + re; text += rb + i18n("Lock comment") + cs + - (*it).lockEntry().Comment() + re; + entry.lockEntry().Comment() + re; } else { svn::StatusPtr d; if (checkReposLockCache(_what, d) && d && d->lockEntry().Locked()) { @@ -858,8 +858,8 @@ { QStringList infoList; infoList.reserve(lst.size()); - for (int i = 0; i < lst.size(); ++i) { - const QString text = getInfo(lst.at(i), rev, peg, recursive, true); + for (const QString &l : lst) { + const QString text = getInfo(l, rev, peg, recursive, true); if (!text.isEmpty()) { infoList += text; } @@ -873,8 +873,8 @@ return; } QString text(QLatin1String("")); - for (int i = 0; i < infoList.count(); ++i) { - text += QLatin1String("

") + infoList.at(i) + QLatin1String("

"); + for (const QString &info : infoList) { + text += QLatin1String("

") + info + QLatin1String("

"); } text += QLatin1String(""); @@ -1184,13 +1184,13 @@ const QString edisp = Kdesvnsettings::external_diff_display(); const QVector wlist = edisp.splitRef(QLatin1Char(' ')); WatchedProcess *proc = new WatchedProcess(this); - for (auto it = wlist.begin(); it != wlist.end(); ++it) { - if (*it == QLatin1String("%1")) { + for (const QStringRef &str : wlist) { + if (str == QLatin1String("%1")) { *proc << first; - } else if (*it == QLatin1String("%2")) { + } else if (str == QLatin1String("%2")) { *proc << second; } else { - *proc << (*it).toString(); + *proc << str.toString(); } } proc->setAutoDelete(true); @@ -1340,8 +1340,8 @@ WatchedProcess *proc = new WatchedProcess(this); bool fname_used = false; - for (auto it = wlist.begin(); it != wlist.end(); ++it) { - if (*it == QLatin1String("%f")) { + for (const QStringRef &str : wlist) { + if (str == QLatin1String("%f")) { QTemporaryFile tfile; tfile.setAutoRemove(false); tfile.open(); @@ -1352,7 +1352,7 @@ proc->appendTempFile(tfile.fileName()); tfile.close(); } else { - *proc << (*it).toString(); + *proc << str.toString(); } } proc->setAutoDelete(true); @@ -1543,9 +1543,8 @@ bool SvnActions::addItems(const svn::Paths &items, svn::Depth depth) { try { - svn::Paths::const_iterator piter; - for (piter = items.begin(); piter != items.end(); ++piter) { - m_Data->m_Svnclient->add((*piter), depth); + for (const svn::Path &item : items) { + m_Data->m_Svnclient->add(item, depth); } } catch (const svn::Exception &e) { emit clientException(e.msg()); @@ -1945,17 +1944,17 @@ } WatchedProcess *proc = new WatchedProcess(this); - for (auto it = wlist.begin(); it != wlist.end(); ++it) { - if (*it == QLatin1String("%o") || *it == QLatin1String("%l")) { + for (const QStringRef &str : wlist) { + if (str == QLatin1String("%o") || str == QLatin1String("%l")) { *proc << i1.conflicts()[0]->baseFile(); - } else if (*it == QLatin1String("%m") || *it == QLatin1String("%w")) { + } else if (str == QLatin1String("%m") || str == QLatin1String("%w")) { *proc << i1.conflicts()[0]->myFile(); - } else if (*it == QLatin1String("%n") || *it == QLatin1String("%r")) { + } else if (str == QLatin1String("%n") || str == QLatin1String("%r")) { *proc << i1.conflicts()[0]->theirFile(); - } else if (*it == QLatin1String("%t")) { + } else if (str == QLatin1String("%t")) { *proc << p; } else { - *proc << (*it).toString(); + *proc << str.toString(); } } proc->setAutoDelete(true); @@ -2092,17 +2091,17 @@ const QString edisp = Kdesvnsettings::external_merge_program(); const QVector wlist = edisp.splitRef(QLatin1Char(' ')); WatchedProcess *proc = new WatchedProcess(this); - for (auto it = wlist.begin(); it != wlist.end(); ++it) { - if (*it == QLatin1String("%s1")) { + for (const QStringRef &str : wlist) { + if (str == QLatin1String("%s1")) { *proc << first; - } else if (*it == QLatin1String("%s2")) { + } else if (str == QLatin1String("%s2")) { if (!second.isEmpty()) { *proc << second; } - } else if (*it == QLatin1String("%t")) { + } else if (str == QLatin1String("%t")) { *proc << target; } else { - *proc << (*it).toString(); + *proc << str.toString(); } } tdir1.setAutoRemove(false); @@ -2375,9 +2374,9 @@ dlg->setWithCancelButton(); QTreeWidget *ptr(new QTreeWidget(dlg)); ptr->headerItem()->setText(0, i18n("Item")); - for (int j = 0; j < displist.size(); ++j) { + for (const QString &text : qAsConst(displist)) { QTreeWidgetItem *n = new QTreeWidgetItem(ptr); - n->setText(0, displist[j]); + n->setText(0, text); n->setCheckState(0, Qt::Checked); } ptr->resizeColumnToContents(0); @@ -2655,8 +2654,8 @@ void SvnActions::removeFromUpdateCache(const QStringList &what, bool exact_only) { - for (int i = 0; i < what.size(); ++i) { - m_Data->m_UpdateCache.deleteKey(what.at(i), exact_only); + for (const QString &key : what) { + m_Data->m_UpdateCache.deleteKey(key, exact_only); } } @@ -2696,16 +2695,16 @@ bool result = false; QStringList lst = data.split(QLatin1Char('\n'), QString::SkipEmptyParts); - for (int _current = 0; _current < ignorePattern.size(); ++_current) { - int it = lst.indexOf(ignorePattern[_current]); + for (const QString &ignore : ignorePattern) { + int it = lst.indexOf(ignore); if (it != -1) { if (unignore) { lst.removeAt(it); result = true; } } else { if (!unignore) { - lst.append(ignorePattern[_current]); + lst.append(ignore); result = true; } } @@ -2772,7 +2771,7 @@ QPair pmp; try { pmp = m_Data->m_Svnclient->propget(QStringLiteral("svn:needs-lock"), p, where, where); - } catch (const svn::Exception &e) { + } catch (const svn::Exception &) { /* no messagebox needed */ //emit clientException(e.msg()); return false; @@ -2883,10 +2882,7 @@ void SvnActions::setContextData(const QString &aKey, const QString &aValue) { if (aValue.isNull()) { - QMap::iterator it = m_Data->m_contextData.find(aKey); - if (it != m_Data->m_contextData.end()) { - m_Data->m_contextData.remove(aKey); - } + m_Data->m_contextData.remove(aKey); } else { m_Data->m_contextData[aKey] = aValue; } diff --git a/src/svnfrontend/svntreeview.h b/src/svnfrontend/svntreeview.h --- a/src/svnfrontend/svntreeview.h +++ b/src/svnfrontend/svntreeview.h @@ -22,12 +22,11 @@ #include -class SvnTreeView: public QTreeView +class SvnTreeView final : public QTreeView { Q_OBJECT public: - explicit SvnTreeView(QWidget *parent = nullptr); - ~SvnTreeView(); + using QTreeView::QTreeView; protected: void startDrag(Qt::DropActions supportedActions) override; diff --git a/src/svnfrontend/svntreeview.cpp b/src/svnfrontend/svntreeview.cpp --- a/src/svnfrontend/svntreeview.cpp +++ b/src/svnfrontend/svntreeview.cpp @@ -34,16 +34,6 @@ #include #include -SvnTreeView::SvnTreeView(QWidget *parent) - : QTreeView(parent) -{ - -} - -SvnTreeView::~SvnTreeView() -{ -} - void SvnTreeView::startDrag(Qt::DropActions supportedActions) { // only one dragging at time diff --git a/src/svnqt/cache/LogCache.cpp b/src/svnqt/cache/LogCache.cpp --- a/src/svnqt/cache/LogCache.cpp +++ b/src/svnqt/cache/LogCache.cpp @@ -62,30 +62,30 @@ m_DB.commit(); m_DB.close(); m_DB = QSqlDatabase(); - QMap::Iterator it; - for (it = reposCacheNames.begin(); it != reposCacheNames.end(); ++it) { - if (QSqlDatabase::database(it.value()).isOpen()) { - QSqlDatabase::database(it.value()).commit(); - QSqlDatabase::database(it.value()).close(); + for (const QString &dbName : reposCacheNames) { + if (QSqlDatabase::database(dbName).isOpen()) { + QSqlDatabase::database(dbName).commit(); + QSqlDatabase::database(dbName).close(); } - QSqlDatabase::removeDatabase(it.value()); + QSqlDatabase::removeDatabase(dbName); } QSqlDatabase::removeDatabase(key); } void deleteDb(const QString &path) { - QMap::Iterator it; - for (it = reposCacheNames.begin(); it != reposCacheNames.end(); ++it) { + for (auto it = reposCacheNames.begin(); it != reposCacheNames.end(); ++it) { QSqlDatabase _db = QSqlDatabase::database(it.value()); if (_db.databaseName() == path) { qDebug() << "Removing database " << _db.databaseName() << endl; if (_db.isOpen()) { _db.commit(); _db.close(); } + _db = QSqlDatabase(); QSqlDatabase::removeDatabase(it.value()); - it = reposCacheNames.begin(); + reposCacheNames.erase(it); + break; } } } @@ -106,7 +106,7 @@ { if (m_mainDB.hasLocalData()) { m_mainDB.localData()->m_DB.close(); - m_mainDB.setLocalData(0L); + m_mainDB.setLocalData(nullptr); } } @@ -563,7 +563,6 @@ cur.prepare(s_q); if (!cur.exec()) { throw svn::cache::DatabaseException(QLatin1String("Could not retrieve values: ") + cur.lastError().text()); - return _res; } while (cur.next()) { _res.append(cur.value(0).toString()); diff --git a/src/svnqt/cache/ReposLog.cpp b/src/svnqt/cache/ReposLog.cpp --- a/src/svnqt/cache/ReposLog.cpp +++ b/src/svnqt/cache/ReposLog.cpp @@ -100,7 +100,7 @@ } /// no catch - exception has go trough... //qDebug("Getting headrev"); - svn::InfoEntries e = m_Client->info(m_ReposRoot, svn::DepthEmpty, svn::Revision::HEAD, svn::Revision::HEAD); + const svn::InfoEntries e = m_Client->info(m_ReposRoot, svn::DepthEmpty, svn::Revision::HEAD, svn::Revision::HEAD); if (e.count() < 1 || e[0].reposRoot().isEmpty()) { return svn::Revision::UNDEFINED; } @@ -265,11 +265,10 @@ if (!m_Client->log(params.targets(m_ReposRoot).revisionRange(_rstart, _rend).peg(svn::Revision::UNDEFINED).discoverChangedPathes(true).strictNodeHistory(false), _internal)) { return false; } - LogEntriesMap::ConstIterator it = _internal.constBegin(); DatabaseLocker l(&m_Database); - for (; it != _internal.constEnd(); ++it) { - _insertLogEntry((*it)); + for (const LogEntry &le : qAsConst(_internal)) { + _insertLogEntry(le); if (cp && cp->getListener()) { //cp->getListener()->contextProgress(++icount,_internal.size()); if (cp->getListener()->contextCancel()) { @@ -325,7 +324,6 @@ if (!bcount.exec()) { //qDebug() << bcount.lastError().text(); throw svn::cache::DatabaseException(QLatin1String("Could not retrieve count: ") + bcount.lastError().text()); - return false; } if (!bcount.next() || bcount.value(0).toLongLong() < 1) { // we didn't found logs with this parameters @@ -340,12 +338,11 @@ if (!bcur.exec()) { throw svn::cache::DatabaseException(QLatin1String("Could not retrieve values: ") + bcur.lastError().text()); - return false; } QString sItems(QStringLiteral("select changeditem,action,copyfrom,copyfromrev from changeditems where revision=?")); - for (int i = 0; i < exclude.size(); ++i) { - sItems += QLatin1String(" and changeditem not like '") + exclude[i] + QLatin1String("%'"); + for (const QString &ex : exclude.data()) { + sItems += QLatin1String(" and changeditem not like '") + ex + QLatin1String("%'"); } QSqlQuery cur(m_Database); cur.setForwardOnly(true); @@ -360,7 +357,6 @@ throw svn::cache::DatabaseException(QStringLiteral("Could not retrieve revision values: %1, %2") .arg(cur.lastError().text(), cur.lastError().nativeErrorCode())); - return false; } target[revision].revision = revision; target[revision].author = bcur.value(1).toString(); @@ -378,7 +374,6 @@ if (cp && cp->getListener()) { if (cp->getListener()->contextCancel()) { throw svn::cache::DatabaseException(QStringLiteral("Could not retrieve values: User cancel.")); - return false; } } } @@ -408,7 +403,7 @@ } } if (must_remote) { - svn::InfoEntries e = (m_Client->info(m_ReposRoot, svn::DepthEmpty, aRev, aRev));; + const svn::InfoEntries e = (m_Client->info(m_ReposRoot, svn::DepthEmpty, aRev, aRev));; if (e.count() < 1 || e[0].reposRoot().isEmpty()) { return aRev; } @@ -423,7 +418,7 @@ if (noNetwork) { return svn::Revision::UNDEFINED; } - svn::InfoEntries e = (m_Client->info(m_ReposRoot, svn::DepthEmpty, svn::Revision::HEAD, svn::Revision::HEAD));; + const svn::InfoEntries e = (m_Client->info(m_ReposRoot, svn::DepthEmpty, svn::Revision::HEAD, svn::Revision::HEAD));; if (e.count() < 1 || e[0].reposRoot().isEmpty()) { return svn::Revision::UNDEFINED; } @@ -450,13 +445,12 @@ throw svn::cache::DatabaseException(QStringLiteral("_insertLogEntry_0: Could not insert values: %1, %2").arg(_q.lastError().text(), _q.lastError().nativeErrorCode())); } _q.prepare(qPathes); - svn::LogChangePathEntries::ConstIterator cpit = aEntry.changedPaths.begin(); - for (; cpit != aEntry.changedPaths.end(); ++cpit) { + for (const LogChangePathEntry &cp : aEntry.changedPaths) { _q.bindValue(0, j); - _q.bindValue(1, (*cpit).path); - _q.bindValue(2, QString(QLatin1Char((*cpit).action))); - _q.bindValue(3, (*cpit).copyFromPath); - _q.bindValue(4, Q_LLONG((*cpit).copyFromRevision)); + _q.bindValue(1, cp.path); + _q.bindValue(2, QString(QLatin1Char(cp.action))); + _q.bindValue(3, cp.copyFromPath); + _q.bindValue(4, Q_LLONG(cp.copyFromRevision)); if (!_q.exec()) { //qDebug("Could not insert values: %s",_q.lastError().text().toUtf8().data()); //qDebug() << _q.lastQuery(); diff --git a/src/svnqt/client_status.cpp b/src/svnqt/client_status.cpp --- a/src/svnqt/client_status.cpp +++ b/src/svnqt/client_status.cpp @@ -213,12 +213,10 @@ const StatusParameter ¶ms, const ContextP &) { - DirEntries dirEntries = client->list(params.path(), params.revision(), params.revision(), params.depth(), params.detailedRemote()); - DirEntries::const_iterator it; + const DirEntries dirEntries = client->list(params.path(), params.revision(), params.revision(), params.depth(), params.detailedRemote()); StatusEntries entries; - for (it = dirEntries.constBegin(); it != dirEntries.constEnd(); ++it) { - DirEntry dirEntry = *it; + for (const DirEntry &dirEntry : dirEntries) { if (dirEntry.name().isEmpty()) { continue; } diff --git a/src/svnqt/dirent.cpp b/src/svnqt/dirent.cpp --- a/src/svnqt/dirent.cpp +++ b/src/svnqt/dirent.cpp @@ -38,49 +38,26 @@ { public: QString name; - svn_node_kind_t kind; - qlonglong size; - bool hasProps; - svn_revnum_t createdRev; - DateTime time; QString lastAuthor; + DateTime time; LockEntry m_Lock; + qlonglong size = 0; + svn_revnum_t createdRev = 0; + svn_node_kind_t kind = svn_node_unknown; + bool hasProps = false; - DirEntry_Data() - : kind(svn_node_unknown), size(0), hasProps(false), - createdRev(0), time(0), m_Lock() - { - } - + DirEntry_Data() = default; DirEntry_Data(const QString &_name, const svn_dirent_t *dirEntry) - : name(_name), kind(dirEntry->kind), size(dirEntry->size), - hasProps(dirEntry->has_props != 0), - createdRev(dirEntry->created_rev), time(dirEntry->time), m_Lock() + : name(_name), time(dirEntry->time), size(dirEntry->size), + createdRev(dirEntry->created_rev), kind(dirEntry->kind), + hasProps(dirEntry->has_props != 0) { lastAuthor = dirEntry->last_author == nullptr ? QString() : QString::fromUtf8(dirEntry->last_author); } - - DirEntry_Data(const DirEntry &src) - { - init(src); - } - - void - init(const DirEntry &src) - { - name = src.name(); - kind = src.kind(); - size = src.size(); - hasProps = src.hasProps(); - createdRev = src.createdRev(); - time = src.time(); - lastAuthor = src.lastAuthor(); - m_Lock = src.lockEntry(); - } }; DirEntry::DirEntry() - : m(new DirEntry_Data()) + : m(new DirEntry_Data) { } @@ -102,7 +79,7 @@ } DirEntry::DirEntry(const DirEntry &src) - : m(new DirEntry_Data(src)) + : m(new DirEntry_Data(*src.m)) { } @@ -177,7 +154,7 @@ return *this; } - m->init(dirEntry); + *m = *dirEntry.m; return *this; } } diff --git a/src/svnqt/entry.cpp b/src/svnqt/entry.cpp --- a/src/svnqt/entry.cpp +++ b/src/svnqt/entry.cpp @@ -41,15 +41,15 @@ public: Entry_private(); - bool m_valid; LockEntry m_Lock; QUrl _url, _repos; + DateTime _cmt_date; QString _name, _uuid, _cmt_author; - bool _copied; svn_revnum_t _revision, _cmt_rev; svn_node_kind_t _kind; - DateTime _cmt_date; + bool m_valid; + bool _copied; /** * initializes the members @@ -78,7 +78,7 @@ } Entry_private::Entry_private() - : m_valid(false), m_Lock() + : m_valid(false) { init_clean(); } diff --git a/src/svnqt/helper.h b/src/svnqt/helper.h --- a/src/svnqt/helper.h +++ b/src/svnqt/helper.h @@ -69,7 +69,6 @@ _value = svn_depth_immediates; break; case DepthInfinity: - default: _value = svn_depth_infinity; break; } @@ -93,10 +92,10 @@ apr_array_header_t *ranges = apr_array_make(pool, m_ranges.size(), sizeof(svn_opt_revision_range_t *)); svn_opt_revision_range_t *range; - for (long j = 0; j < m_ranges.count(); ++j) { + for (const RevisionRange &rr : qAsConst(m_ranges)) { range = (svn_opt_revision_range_t *)apr_palloc(pool, sizeof(*range)); - range->start = *m_ranges[j].first.revision(); - range->end = *m_ranges[j].second.revision(); + range->start = *rr.first.revision(); + range->end = *rr.second.revision(); APR_ARRAY_PUSH(ranges, svn_opt_revision_range_t *) = range; } return ranges; @@ -115,15 +114,11 @@ return nullptr; } apr_hash_t *hash = apr_hash_make(pool); - PropertiesMap::ConstIterator it; - const char *propval; - const char *propname; - QByteArray s, n; - for (it = _map.begin(); it != _map.end(); ++it) { - s = it.value().toUtf8(); - n = it.key().toUtf8(); - propval = apr_pstrndup(pool, s, s.size()); - propname = apr_pstrndup(pool, n, n.size()); + for (auto it = _map.begin(); it != _map.end(); ++it) { + const QByteArray s = it.value().toUtf8(); + const QByteArray n = it.key().toUtf8(); + const char *propval = apr_pstrndup(pool, s, s.size()); + const char *propname = apr_pstrndup(pool, n, n.size()); apr_hash_set(hash, propname, APR_HASH_KEY_STRING, propval); } return hash; diff --git a/src/svnqt/log_entry.h b/src/svnqt/log_entry.h --- a/src/svnqt/log_entry.h +++ b/src/svnqt/log_entry.h @@ -58,20 +58,20 @@ const QString ©FromPath_, const svn_revnum_t copyFromRevision_) : path(path_) - , action(action_) , copyFromPath(copyFromPath_) , copyFromRevision(copyFromRevision_) + , action(action_) {} QString path; - char action = '\0'; QString copyFromPath; //! future use or useful in backends QString copyToPath; qlonglong copyFromRevision; //! future use or useful in backends qlonglong copyToRevision; + char action = '\0'; }; typedef QVector LogChangePathEntries; diff --git a/src/svnqt/log_entry.cpp b/src/svnqt/log_entry.cpp --- a/src/svnqt/log_entry.cpp +++ b/src/svnqt/log_entry.cpp @@ -78,8 +78,8 @@ svn_log_changed_path2_t *log_item = reinterpret_cast(val); const char *path = reinterpret_cast(pv); QString _p(QString::fromUtf8(path)); - for (int _exnr = 0; _exnr < excludeList.size(); ++_exnr) { - if (_p.startsWith(excludeList[_exnr])) { + for (const QString &exclude : excludeList.data()) { + if (_p.startsWith(exclude)) { blocked = true; break; } diff --git a/src/svnqt/path.h b/src/svnqt/path.h --- a/src/svnqt/path.h +++ b/src/svnqt/path.h @@ -65,11 +65,6 @@ ~Path() = default; - /** - * Assignment operator - */ - Path &operator=(const Path &); - /** * @return Path string */ diff --git a/src/svnqt/path.cpp b/src/svnqt/path.cpp --- a/src/svnqt/path.cpp +++ b/src/svnqt/path.cpp @@ -98,16 +98,6 @@ return m_path.toUtf8(); } -Path & -Path::operator=(const Path &path) -{ - if (this == &path) { - return *this; - } - m_path = path.path(); - return *this; -} - bool Path::isSet() const { diff --git a/src/svnqt/status.cpp b/src/svnqt/status.cpp --- a/src/svnqt/status.cpp +++ b/src/svnqt/status.cpp @@ -42,8 +42,6 @@ class SVNQT_NOEXPORT Status_private { public: - Status_private(); - virtual ~Status_private(); /** * Initialize structures * @@ -58,33 +56,19 @@ void setPath(const QString &); QString m_Path; - bool m_isVersioned; - bool m_hasReal; LockEntry m_Lock; Entry m_entry; - - svn_wc_status_kind m_node_status, m_text_status, m_prop_status, m_repos_text_status, m_repos_prop_status; - bool m_copied, m_switched; + svn_wc_status_kind m_node_status = svn_wc_status_none; + svn_wc_status_kind m_text_status = svn_wc_status_none; + svn_wc_status_kind m_prop_status = svn_wc_status_none; + svn_wc_status_kind m_repos_text_status = svn_wc_status_none; + svn_wc_status_kind m_repos_prop_status = svn_wc_status_none; + bool m_isVersioned = false; + bool m_hasReal = false; + bool m_copied = false; + bool m_switched = false; }; -Status_private::Status_private() - : m_Path() - , m_isVersioned(false) - , m_hasReal(false) - , m_node_status(svn_wc_status_none) - , m_text_status(svn_wc_status_none) - , m_prop_status(svn_wc_status_none) - , m_repos_text_status(svn_wc_status_none) - , m_repos_prop_status(svn_wc_status_none) - , m_copied(false) - , m_switched(false) -{ -} - -Status_private::~ Status_private() -{ -} - void Status_private::setPath(const QString &aPath) { Pool pool; @@ -136,13 +120,13 @@ setPath(path); m_Lock = src.m_Lock; m_entry = src.m_entry; - m_isVersioned = src.m_isVersioned; - m_hasReal = src.m_hasReal; m_node_status = src.m_node_status; m_text_status = src.m_text_status; m_prop_status = src.m_prop_status; m_repos_text_status = src.m_repos_text_status; m_repos_prop_status = src.m_repos_prop_status; + m_isVersioned = src.m_isVersioned; + m_hasReal = src.m_hasReal; m_copied = src.m_copied; m_switched = src.m_switched; } diff --git a/src/svnqt/stringarray.h b/src/svnqt/stringarray.h --- a/src/svnqt/stringarray.h +++ b/src/svnqt/stringarray.h @@ -50,8 +50,6 @@ explicit StringArray(const QStringList &); explicit StringArray(const apr_array_header_t *apr_targets); QStringList::size_type size()const; - const QString &operator[](QStringList::size_type which)const; - QString &operator[](QStringList::size_type which); /** * Returns an apr array containing char*. * diff --git a/src/svnqt/stringarray.cpp b/src/svnqt/stringarray.cpp --- a/src/svnqt/stringarray.cpp +++ b/src/svnqt/stringarray.cpp @@ -74,34 +74,21 @@ return m_content.size(); } -const QString &svn::StringArray::operator[](QStringList::size_type which)const -{ - return m_content[which]; -} - -QString &svn::StringArray::operator[](QStringList::size_type which) -{ - return m_content[which]; -} - /*! \fn svn::StringArray::array (const Pool & pool) const */ apr_array_header_t *svn::StringArray::array(const Pool &pool) const { if (isNull()) { return nullptr; } - QStringList::const_iterator it; - apr_pool_t *apr_pool = pool.pool(); apr_array_header_t *apr_targets = apr_array_make(apr_pool, m_content.size(), sizeof(const char *)); - for (it = m_content.begin(); it != m_content.end(); ++it) { - QByteArray s = (*it).toUtf8(); - char *t2 = apr_pstrndup(apr_pool, s, s.size()); - + for (const QString &content : m_content) { + const QByteArray s = content.toUtf8(); + char *t2 = apr_pstrndup(apr_pool, s.data(), s.size()); (*((const char **) apr_array_push(apr_targets))) = t2; } return apr_targets; diff --git a/src/svnqt/targets.cpp b/src/svnqt/targets.cpp --- a/src/svnqt/targets.cpp +++ b/src/svnqt/targets.cpp @@ -70,20 +70,15 @@ apr_array_header_t * Targets::array(const Pool &pool) const { - Paths::const_iterator it; - apr_pool_t *apr_pool = pool.pool(); apr_array_header_t *apr_targets = apr_array_make(apr_pool, m_targets.size(), sizeof(const char *)); - for (it = m_targets.begin(); it != m_targets.end(); ++it) { - QByteArray s = (*it).path().toUtf8(); - - char *t2 = - apr_pstrndup(apr_pool, s, s.size()); - + for (const svn::Path &tgt : m_targets) { + const QByteArray s = tgt.path().toUtf8(); + char *t2 = apr_pstrndup(apr_pool, s.data(), s.size()); (*((const char **) apr_array_push(apr_targets))) = t2; }