_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;
}
|