Commit eaef1920 authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Compile with QT_NO_FOREACH QT_NO_KEYWORDS

parent c67ff4dd
......@@ -42,7 +42,7 @@ include(ECMOptionalAddSubdirectory)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_NO_FOREACH -DQT_NO_KEYWORDS)
ecm_optional_add_subdirectory(svn)
ecm_optional_add_subdirectory(git)
......
......@@ -282,7 +282,7 @@ QList<QAction*> FileViewBazaarPlugin::outOfVersionControlActions(const KFileItem
QList<QAction*> FileViewBazaarPlugin::contextMenuFilesActions(const KFileItemList& items) const
{
Q_ASSERT(!items.isEmpty());
foreach (const KFileItem& item, items) {
for (const KFileItem& item : items) {
m_contextItems.append(item);
}
m_contextDir.clear();
......@@ -294,7 +294,7 @@ QList<QAction*> FileViewBazaarPlugin::contextMenuFilesActions(const KFileItemLis
const int itemsCount = items.count();
int versionedCount = 0;
int editingCount = 0;
foreach (const KFileItem& item, items) {
for (const KFileItem& item : items) {
const ItemVersion state = itemVersion(item);
if (state != UnversionedVersion) {
++versionedCount;
......@@ -436,10 +436,10 @@ void FileViewBazaarPlugin::slotOperationCompleted(int exitCode, QProcess::ExitSt
m_pendingOperation = false;
if ((exitStatus != QProcess::NormalExit) || (exitCode != 0)) {
emit errorMessage(m_errorMsg);
Q_EMIT errorMessage(m_errorMsg);
} else if (m_contextItems.isEmpty()) {
emit operationCompletedMessage(m_operationCompletedMsg);
emit itemVersionsChanged();
Q_EMIT operationCompletedMessage(m_operationCompletedMsg);
Q_EMIT itemVersionsChanged();
} else {
startBazaarCommandProcess();
}
......@@ -451,7 +451,7 @@ void FileViewBazaarPlugin::slotOperationError()
m_contextItems.clear();
m_pendingOperation = false;
emit errorMessage(m_errorMsg);
Q_EMIT errorMessage(m_errorMsg);
}
void FileViewBazaarPlugin::execBazaarCommand(const QString& command,
......@@ -460,7 +460,7 @@ void FileViewBazaarPlugin::execBazaarCommand(const QString& command,
const QString& errorMsg,
const QString& operationCompletedMsg)
{
emit infoMessage(infoMsg);
Q_EMIT infoMessage(infoMsg);
QProcess process;
process.start(QLatin1String("bzr plugins"));
......@@ -477,7 +477,7 @@ void FileViewBazaarPlugin::execBazaarCommand(const QString& command,
}
if (!foundQbzr) {
emit infoMessage("Please Install QBzr");
Q_EMIT infoMessage("Please Install QBzr");
return;
}
......
......@@ -49,7 +49,7 @@ public:
private slots:
private Q_SLOTS:
void updateFiles();
void pullFiles();
void pushFiles();
......
......@@ -78,7 +78,7 @@ FileViewDropboxPlugin::FileViewDropboxPlugin(QObject* parent, const QVariantList
// Find and watch aggregation.dbx file
QDir dir(dropboxDir);
QStringList nameFilter("instance*");
QStringList instanceDirs = dir.entryList(nameFilter);
const QStringList instanceDirs = dir.entryList(nameFilter);
QString aggregationDB = "";
for (const QString &instance : instanceDirs) {
aggregationDB = dropboxDir + '/' + instance + '/' + "aggregation.dbx";
......@@ -145,7 +145,7 @@ QList<QAction*> FileViewDropboxPlugin::versionControlActions(const KFileItemList
return QList<QAction*>();
}
foreach (const KFileItem& item, items) {
for (const KFileItem& item : items) {
d->contextFilePaths << QDir(item.localPath()).canonicalPath();
}
......@@ -156,7 +156,7 @@ QList<QAction*> FileViewDropboxPlugin::versionControlActions(const KFileItemList
}
// analyze item options and dynamically form a menu
foreach (const QString& replyLine, reply) {
for (const QString& replyLine : reply) {
const QStringList options = replyLine.split('~');
if (options.count() > 2) {
......
......@@ -66,7 +66,7 @@ public:
QList<QAction*> versionControlActions(const KFileItemList& items) const override;
QList<QAction*> outOfVersionControlActions(const KFileItemList& items) const override;
private slots:
private Q_SLOTS:
void handleContextAction(QAction* action);
private:
......
......@@ -120,7 +120,7 @@ CheckoutDialog::CheckoutDialog(QWidget* parent):
setDefaultNewBranchName(m_branchComboBox->currentText());
//keep local branches to prevent creating an equally named new branch
foreach (const QString& b, branches) {
for (const QString& b : branches) {
if (!b.startsWith(QLatin1String("remotes/"))) {
//you CAN create local branches called "remotes/...", but since no sane person
//would do that, we save the effort of another call to "git branch"
......
......@@ -55,7 +55,7 @@ public:
*/
QString newBranchName() const;
private slots:
private Q_SLOTS:
void branchRadioButtonToggled(bool checked);
void newBranchCheckBoxStateToggled(int state);
/**
......
......@@ -43,7 +43,7 @@ public:
* @returns True if the last commit is to be amended, false otherwise
*/
bool amend() const;
private slots:
private Q_SLOTS:
void signOffButtonClicked();
void amendCheckBoxStateChanged();
void saveDialogSize();
......
......@@ -308,7 +308,7 @@ QList<QAction*> FileViewGitPlugin::contextMenuFilesActions(const KFileItemList&
if (!m_pendingOperation){
m_contextDir = QFileInfo(items.first().localPath()).canonicalPath();
m_contextItems.clear();
foreach(const KFileItem& item, items){
for (const KFileItem& item : items){
m_contextItems.append(item);
}
......@@ -316,7 +316,7 @@ QList<QAction*> FileViewGitPlugin::contextMenuFilesActions(const KFileItemList&
int versionedCount = 0;
int addableCount = 0;
int revertCount = 0;
foreach(const KFileItem& item, items){
for (const KFileItem& item : items){
const ItemVersion state = itemVersion(item);
if (state != UnversionedVersion && state != RemovedVersion &&
state != IgnoredVersion) {
......@@ -473,7 +473,7 @@ void FileViewGitPlugin::log()
);
if (!process.waitForFinished() || process.exitCode() != 0) {
emit errorMessage(xi18nd("@info:status", "<application>Git</application> Log failed."));
Q_EMIT errorMessage(xi18nd("@info:status", "<application>Git</application> Log failed."));
return;
}
......@@ -571,12 +571,12 @@ void FileViewGitPlugin::checkout()
}
if (process.exitCode() == 0 && process.exitStatus() == QProcess::NormalExit) {
if (!completedMessage.isEmpty()) {
emit operationCompletedMessage(completedMessage);
emit itemVersionsChanged();
Q_EMIT operationCompletedMessage(completedMessage);
Q_EMIT itemVersionsChanged();
}
}
else {
emit errorMessage(xi18nd("@info:status", "<application>Git</application> Checkout failed."
Q_EMIT errorMessage(xi18nd("@info:status", "<application>Git</application> Checkout failed."
" Maybe your working directory is dirty."));
}
}
......@@ -610,8 +610,8 @@ void FileViewGitPlugin::commit()
}
}
if (!completedMessage.isEmpty()) {
emit operationCompletedMessage(completedMessage);
emit itemVersionsChanged();
Q_EMIT operationCompletedMessage(completedMessage);
Q_EMIT itemVersionsChanged();
}
}
}
......@@ -641,10 +641,10 @@ void FileViewGitPlugin::createTag()
}
if (process.exitCode() == 0 && process.exitStatus() == QProcess::NormalExit) {
completedMessage = xi18nd("@info:status","Successfully created tag '%1'", dialog.tagName());
emit operationCompletedMessage(completedMessage);
Q_EMIT operationCompletedMessage(completedMessage);
} else {
//I don't know any other error, but in case one occurs, the user doesn't get FALSE error messages
emit errorMessage(gotTagAlreadyExistsMessage ?
Q_EMIT errorMessage(gotTagAlreadyExistsMessage ?
xi18nd("@info:status", "<application>Git</application> tag creation failed."
" A tag with the name '%1' already exists.", dialog.tagName()) :
xi18nd("@info:status", "<application>Git</application> tag creation failed.")
......@@ -663,7 +663,7 @@ void FileViewGitPlugin::push()
dialog.localBranch(), dialog.destination(), dialog.remoteBranch());
m_operationCompletedMsg = xi18nd("@info:status", "Pushed branch %1 to %2:%3.",
dialog.localBranch(), dialog.destination(), dialog.remoteBranch());
emit infoMessage(xi18nd("@info:status", "Pushing branch %1 to %2:%3...",
Q_EMIT infoMessage(xi18nd("@info:status", "Pushing branch %1 to %2:%3...",
dialog.localBranch(), dialog.destination(), dialog.remoteBranch()));
m_command = "push";
......@@ -684,7 +684,7 @@ void FileViewGitPlugin::pull()
dialog.remoteBranch(), dialog.source());
m_operationCompletedMsg = xi18nd("@info:status", "Pulled branch %1 from %2 successfully.",
dialog.remoteBranch(), dialog.source());
emit infoMessage(xi18nd("@info:status", "Pulling branch %1 from %2...", dialog.remoteBranch(),
Q_EMIT infoMessage(xi18nd("@info:status", "Pulling branch %1 from %2...", dialog.remoteBranch(),
dialog.source()));
m_command = "pull";
......@@ -708,10 +708,10 @@ void FileViewGitPlugin::slotOperationCompleted(int exitCode, QProcess::ExitStatu
}
if ((exitStatus != QProcess::NormalExit) || (exitCode != 0)) {
emit errorMessage(message.isNull() ? m_errorMsg : message);
Q_EMIT errorMessage(message.isNull() ? m_errorMsg : message);
} else if (m_contextItems.isEmpty()) {
emit operationCompletedMessage(message.isNull() ? m_operationCompletedMsg : message);
emit itemVersionsChanged();
Q_EMIT operationCompletedMessage(message.isNull() ? m_operationCompletedMsg : message);
Q_EMIT itemVersionsChanged();
} else {
startGitCommandProcess();
}
......@@ -723,7 +723,7 @@ void FileViewGitPlugin::slotOperationError()
m_contextItems.clear();
m_pendingOperation = false;
emit errorMessage(m_errorMsg);
Q_EMIT errorMessage(m_errorMsg);
}
QString FileViewGitPlugin::parsePushOutput()
......@@ -752,7 +752,7 @@ QString FileViewGitPlugin::parsePullOutput()
return xi18nd("@info:status", "Branch is already up-to-date.");
}
if (line.contains("CONFLICT")) {
emit itemVersionsChanged();
Q_EMIT itemVersionsChanged();
return xi18nd("@info:status", "Merge conflicts occurred. Fix them and commit the result.");
}
}
......@@ -765,7 +765,7 @@ void FileViewGitPlugin::execGitCommand(const QString& gitCommand,
const QString& errorMsg,
const QString& operationCompletedMsg)
{
emit infoMessage(infoMsg);
Q_EMIT infoMessage(infoMsg);
m_command = gitCommand;
m_arguments = arguments;
......
......@@ -47,7 +47,7 @@ public:
QList<QAction*> versionControlActions(const KFileItemList& items) const override;
QList<QAction*> outOfVersionControlActions(const KFileItemList& items) const override;
private slots:
private Q_SLOTS:
void addFiles();
void revertFiles();
void showLocalChanges();
......
......@@ -78,9 +78,9 @@ PullDialog::PullDialog(QWidget* parent):
//get branch names
int currentBranchIndex;
QStringList branches = gitWrapper->branches(&currentBranchIndex);
const QStringList branches = gitWrapper->branches(&currentBranchIndex);
foreach (const QString& branch, branches) {
for (const QString& branch : branches) {
if (branch.startsWith(QLatin1String("remotes/"))) {
const QString remote = branch.section('/', 1, 1);
const QString name = branch.section('/', 2);
......
......@@ -38,7 +38,7 @@ private:
QComboBox * m_remoteComboBox;
QComboBox * m_remoteBranchComboBox;
QHash<QString, QStringList> m_remoteBranches;
private slots:
private Q_SLOTS:
void remoteSelectionChanged(const QString& newRemote);
};
......
......@@ -108,9 +108,9 @@ PushDialog::PushDialog (QWidget* parent ):
//get branch names
int currentBranchIndex;
QStringList branches = gitWrapper->branches(&currentBranchIndex);
const QStringList branches = gitWrapper->branches(&currentBranchIndex);
foreach (const QString& branch, branches) {
for (const QString& branch : branches) {
if (branch.startsWith(QLatin1String("remotes/"))) {
const QString remote = branch.section('/', 1, 1);
const QString name = branch.section('/', 2);
......
......@@ -36,7 +36,7 @@ public:
QString localBranch() const;
QString remoteBranch() const;
bool force() const;
private slots:
private Q_SLOTS:
void remoteSelectionChanged(const QString& newRemote);
void localBranchSelectionChanged(const QString& newLocalBranch);
private:
......
......@@ -52,7 +52,7 @@ public:
*/
QString baseBranch() const;
private slots:
private Q_SLOTS:
void setOkButtonState();
private:
inline void setLineEditErrorModeActive(bool active);
......
......@@ -37,10 +37,10 @@ class HgBackoutDialog : public DialogBase
public:
explicit HgBackoutDialog(QWidget *parent = 0);
public slots:
public Q_SLOTS:
void done(int r) override;
private slots:
private Q_SLOTS:
void saveGeometry();
void slotSelectBaseChangeset();
void slotSelectParentChangeset();
......
......@@ -37,7 +37,7 @@ class HgBranchDialog : public DialogBase
public:
explicit HgBranchDialog(QWidget *parent = 0);
public slots:
public Q_SLOTS:
void slotUpdateDialog(const QString &text);
void slotCreateBranch();
void slotSwitch();
......
......@@ -44,10 +44,10 @@ class HgBundleDialog : public DialogBase
public:
explicit HgBundleDialog(QWidget *parent=0);
public slots:
public Q_SLOTS:
void done(int r) override;
private slots:
private Q_SLOTS:
void saveGeometry();
/**
......
......@@ -44,7 +44,7 @@ public:
explicit HgCloneDialog(const QString &directory, QWidget *parent = 0);
void setWorkingDirectory(const QString &directory);
private slots:
private Q_SLOTS:
void saveGeometry();
/**
......
......@@ -366,8 +366,8 @@ void HgCommitDialog::createCopyMessageMenu()
QString output;
hgw->executeCommand(QLatin1String("log"), args, output);
QStringList messages = output.split('\n', QString::SkipEmptyParts);
foreach (QString msg, messages) {
const QStringList messages = output.split('\n', QString::SkipEmptyParts);
for (const QString &msg : messages) {
QAction *action = m_copyMessageMenu->addAction(msg.left(40)); // max 40 characters
action->setData(msg); // entire description into action data
actionGroup->addAction(action);
......
......@@ -53,7 +53,7 @@ class HgCommitDialog : public DialogBase
public:
explicit HgCommitDialog(QWidget *parent = 0);
private slots:
private Q_SLOTS:
/**
* Shows diff of selected file in a KTextEditor widget when user selects
* one of the entry in HgStatusList widget.
......@@ -122,7 +122,7 @@ class NewBranchDialog : public QDialog
explicit NewBranchDialog(QWidget *parent = 0);
QString getBranchName() const;
private slots:
private Q_SLOTS:
void slotTextChanged(const QString &text);
private:
......
......@@ -103,7 +103,7 @@ public:
*/
void clear() const;
private slots:
private Q_SLOTS:
/**
* Show selected changeset information when an entry is selected
*/
......
......@@ -40,7 +40,7 @@ public:
*/
explicit HgGeneralConfigWidget(HgConfig::ConfigType type, QWidget *parent = 0);
public slots:
public Q_SLOTS:
void saveConfig();
void loadConfig();
......
......@@ -80,8 +80,8 @@ void HgIgnoreWidget::setupUntrackedList()
QString output;
hgw->executeCommand(QLatin1String("status"), args, output);
QStringList result = output.split('\n', QString::SkipEmptyParts);
foreach (QString file, result) {
const QStringList result = output.split('\n', QString::SkipEmptyParts);
for (const QString &file : result) {
m_untrackedList->addItem(file.mid(2));
}
}
......@@ -125,8 +125,8 @@ void HgIgnoreWidget::saveConfig()
void HgIgnoreWidget::slotAddFiles()
{
QList<QListWidgetItem*> selectedItems = m_untrackedList->selectedItems();
foreach (QListWidgetItem *item, selectedItems) {
const QList<QListWidgetItem*> selectedItems = m_untrackedList->selectedItems();
for (QListWidgetItem *item : selectedItems) {
m_ignoreTable->addItem(item->text());
m_untrackedList->takeItem(m_untrackedList->row(item));
}
......@@ -148,8 +148,8 @@ void HgIgnoreWidget::slotAddPattern()
void HgIgnoreWidget::slotRemoveEntries()
{
QList<QListWidgetItem*> selectedItems = m_ignoreTable->selectedItems();
foreach (QListWidgetItem *item, selectedItems) {
const QList<QListWidgetItem*> selectedItems = m_ignoreTable->selectedItems();
for (QListWidgetItem *item : selectedItems) {
m_ignoreTable->takeItem(m_ignoreTable->row(item));
}
}
......
......@@ -39,7 +39,7 @@ public:
void loadConfig();
void saveConfig();
private slots:
private Q_SLOTS:
void slotAddFiles();
void slotAddPattern();
void slotRemoveEntries();
......
......@@ -149,7 +149,7 @@ void HgPathConfigWidget::saveConfig()
}
// first delete the alias in remove list from hgrc
foreach(QString alias, m_removeList) {
for (const QString &alias : qAsConst(m_removeList)) {
hgc.deleteRepoRemotePath(alias);
}
......
......@@ -41,7 +41,7 @@ class HgPathConfigWidget : public QWidget
public:
explicit HgPathConfigWidget(QWidget *parent = 0);
public slots:
public Q_SLOTS:
void saveConfig();
void loadConfig();
......@@ -53,7 +53,7 @@ private:
*/
void setupContextMenu();
private slots:
private Q_SLOTS:
/**
* Show context menu and changed enabled status of actions according
* to the position where menu is requested.
......
......@@ -39,11 +39,11 @@ public:
explicit HgPluginSettingsWidget(QWidget *parent = 0);
~HgPluginSettingsWidget() override;
public slots:
public Q_SLOTS:
void saveConfig();
void loadConfig();
private slots:
private Q_SLOTS:
void browse_diff();
private:
......
......@@ -45,7 +45,7 @@ private:
// user interface
void setupUI();
private slots:
private Q_SLOTS:
void saveSettings();
void saveGeometry();
void loadGeometry();
......
......@@ -134,7 +134,7 @@ void HgExportDialog::saveGeometry()
void HgExportDialog::done(int r)
{
if (r == QDialog::Accepted) {
QList<QListWidgetItem*> items = m_commitInfoWidget->selectedItems();
const QList<QListWidgetItem*> items = m_commitInfoWidget->selectedItems();
if (items.empty()) {
KMessageBox::error(this, i18nc("@message:error",
"Please select at least one changeset to be exported!"));
......@@ -153,7 +153,7 @@ void HgExportDialog::done(int r)
}
args << QLatin1String("-r");
foreach (QListWidgetItem *item, items) {
for (QListWidgetItem *item : items) {
args << item->data(Qt::DisplayRole).toString();
}
......
......@@ -40,10 +40,10 @@ class HgExportDialog : public DialogBase
public:
explicit HgExportDialog(QWidget *parent=0);
public slots:
public Q_SLOTS:
void done(int r) override;
private slots:
private Q_SLOTS:
void saveGeometry();
private:
......
......@@ -361,8 +361,8 @@ KVersionControlPlugin::ItemVersion FileViewHgPlugin::itemVersion(const KFileItem
// will disable the context menu there. Will enable recursive
// add however.
QDir dir(item.localPath());
QStringList filesInside = dir.entryList();
foreach (const QString &fileName, filesInside) {
const QStringList filesInside = dir.entryList();
for (const QString &fileName : filesInside) {
if (fileName == "." || fileName == ".." ) {
continue;
}
......@@ -419,7 +419,7 @@ QList<QAction*> FileViewHgPlugin::itemContextMenu(const KFileItemList &items) co
m_hgWrapper->setCurrentDir(m_currentDir);
if (!m_hgWrapper->isBusy()) {
m_contextItems.clear();
foreach (const KFileItem &item, items) {
for (const KFileItem &item : items) {
m_contextItems.append(item);
}
......@@ -427,7 +427,7 @@ QList<QAction*> FileViewHgPlugin::itemContextMenu(const KFileItemList &items) co
int versionedCount = 0;
int addableCount = 0;
int revertableCount = 0;
foreach (const KFileItem &item, items) {
for (const KFileItem &item : items) {
const ItemVersion state = itemVersion(item);
if (state != UnversionedVersion && state != RemovedVersion) {
++versionedCount;
......@@ -495,9 +495,9 @@ void FileViewHgPlugin::addFiles()
m_operationCompletedMsg = xi18nc("@info:status",
"Added files to <application>Hg</application> repository.");
emit infoMessage(infoMsg);
Q_EMIT infoMessage(infoMsg);
m_hgWrapper->addFiles(m_contextItems);
emit itemVersionsChanged();
Q_EMIT itemVersionsChanged();
}
void FileViewHgPlugin::removeFiles()
......@@ -518,7 +518,7 @@ void FileViewHgPlugin::removeFiles()
m_operationCompletedMsg = xi18nc("@info:status",
"Removed files from <application>Hg</application> repository.");
emit infoMessage(infoMsg);
Q_EMIT infoMessage(infoMsg);
m_hgWrapper->removeFiles(m_contextItems);
}
......@@ -531,7 +531,7 @@ void FileViewHgPlugin::renameFile()
"Renaming of file in <application>Hg</application> repository failed.");
m_operationCompletedMsg = xi18nc("@info:status",
"Renamed file in <application>Hg</application> repository successfully.");
emit infoMessage(xi18nc("@info:status",
Q_EMIT infoMessage(xi18nc("@info:status",
"Renaming file in <application>Hg</application> repository."));
HgRenameDialog dialog(m_contextItems.first());
......@@ -551,12 +551,12 @@ void FileViewHgPlugin::commit()
"Commit to <application>Hg</application> repository failed.");
m_operationCompletedMsg = xi18nc("@info:status",
"Committed to <application>Hg</application> repository.");
emit infoMessage(xi18nc("@info:status",
Q_EMIT infoMessage(xi18nc("@info:status",
"Commit <application>Hg</application> repository."));
HgCommitDialog dialog;
if (dialog.exec() == QDialog::Accepted) {
emit itemVersionsChanged();
Q_EMIT itemVersionsChanged();
};
}
......@@ -566,7 +566,7 @@ void FileViewHgPlugin::tag()
"Tag operation in <application>Hg</application> repository failed.");
m_operationCompletedMsg = xi18nc("@info:status",
"Tagging operation in <application>Hg</application> repository is successful."