🚨 Fixed some clang warnings
This commit is contained in:
parent
25b78bd8d8
commit
7503db9059
@ -123,7 +123,7 @@ void Settings::SetFossilValue(const QString &name, const QVariant &value)
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Settings::SupportsLang(const QString &langId) const
|
||||
{
|
||||
QString locale_path = QString(":intl/intl/%0.qm").arg(langId);
|
||||
QString locale_path = QString(":intl/%0.qm").arg(langId);
|
||||
QResource res(locale_path);
|
||||
return res.isValid();
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ bool CloneDialog::run(QWidget *parent, QUrl &url, QString &repository, QUrl &url
|
||||
QString urltext = dlg.ui->lineURL->text();
|
||||
|
||||
// Check if the url is a local file
|
||||
if (QFileInfo(urltext).exists())
|
||||
if (QFileInfo::exists(urltext))
|
||||
url = QUrl::fromLocalFile(urltext);
|
||||
else
|
||||
{
|
||||
|
@ -36,14 +36,14 @@ WorkspaceState Fossil::getWorkspaceState()
|
||||
bool run_ok = exit_code == EXIT_SUCCESS;
|
||||
|
||||
activeTags.clear();
|
||||
for (QStringList::iterator it = res.begin(); it != res.end(); ++it)
|
||||
for (auto &re : res)
|
||||
{
|
||||
int col_index = it->indexOf(':');
|
||||
int col_index = re.indexOf(':');
|
||||
if (col_index == -1)
|
||||
continue;
|
||||
|
||||
QString key = it->left(col_index).trimmed();
|
||||
QString value = it->mid(col_index + 1).trimmed();
|
||||
QString key = re.left(col_index).trimmed();
|
||||
QString value = re.mid(col_index + 1).trimmed();
|
||||
|
||||
if (key == "fossil")
|
||||
{
|
||||
@ -363,7 +363,7 @@ bool Fossil::revertFiles(const QStringList &fileList)
|
||||
bool Fossil::renameFile(const QString &beforePath, const QString &afterPath, bool renameLocal)
|
||||
{
|
||||
// Ensure we can rename the file
|
||||
if (!QFileInfo(beforePath).exists() || QFileInfo(afterPath).exists())
|
||||
if (!QFileInfo::exists(beforePath) || QFileInfo::exists(afterPath))
|
||||
return false;
|
||||
|
||||
// Do Rename
|
||||
@ -449,7 +449,7 @@ bool Fossil::setRemoteUrl(const QUrl &url)
|
||||
|
||||
// FIXME: Fossil ignores any password passed via the URL
|
||||
// Run as silent to avoid displaying credentials in the log
|
||||
bool ok = runFossil(QStringList() << "remote-url" << u, 0, RUNFLAGS_SILENT_INPUT);
|
||||
bool ok = runFossil(QStringList() << "remote-url" << u, nullptr, RUNFLAGS_SILENT_INPUT);
|
||||
|
||||
return ok;
|
||||
}
|
||||
@ -817,7 +817,7 @@ bool Fossil::runFossilRaw(const QStringList &args, QStringList *output, int *exi
|
||||
// Create fossil process
|
||||
// FIXME: when we are sure this works delete this
|
||||
// LoggedProcess process(parentWidget*/);
|
||||
LoggedProcess process(0);
|
||||
LoggedProcess process(nullptr);
|
||||
|
||||
process.setWorkingDirectory(wkdir);
|
||||
|
||||
@ -860,11 +860,7 @@ bool Fossil::runFossilRaw(const QStringList &args, QStringList *output, int *exi
|
||||
|
||||
if (uiCallback->processAborted())
|
||||
{
|
||||
#ifdef Q_OS_WIN // Verify this is still true on Qt5
|
||||
process.kill(); // QT on windows cannot terminate console processes with QProcess::terminate
|
||||
#else
|
||||
process.terminate();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1109,7 +1105,7 @@ bool Fossil::isWorkspace(const QString &path)
|
||||
QString checkout_file1 = wkspace + PATH_SEPARATOR + FOSSIL_CHECKOUT1;
|
||||
QString checkout_file2 = wkspace + PATH_SEPARATOR + FOSSIL_CHECKOUT2;
|
||||
|
||||
return (QFileInfo(checkout_file1).exists() || QFileInfo(checkout_file2).exists());
|
||||
return (QFileInfo::exists(checkout_file1) || QFileInfo::exists(checkout_file2));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -1204,11 +1200,7 @@ void Fossil::stopUI()
|
||||
{
|
||||
if (uiRunning())
|
||||
{
|
||||
#ifdef Q_WS_WIN
|
||||
fossilUI.kill(); // QT on windows cannot terminate console processes with QProcess::terminate
|
||||
#else
|
||||
fossilUI.terminate();
|
||||
#endif
|
||||
}
|
||||
fossilUI.close();
|
||||
fossilUIPort.clear();
|
||||
|
@ -199,12 +199,12 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
|
||||
}
|
||||
}
|
||||
Q_ASSERT(recent_sep);
|
||||
for (int i = 0; i < MAX_RECENT; ++i)
|
||||
for (auto &recentWorkspaceAct : recentWorkspaceActs)
|
||||
{
|
||||
recentWorkspaceActs[i] = new QAction(this);
|
||||
recentWorkspaceActs[i]->setVisible(false);
|
||||
connect(recentWorkspaceActs[i], SIGNAL(triggered()), this, SLOT(onOpenRecent()));
|
||||
ui->menuFile->insertAction(recent_sep, recentWorkspaceActs[i]);
|
||||
recentWorkspaceAct = new QAction(this);
|
||||
recentWorkspaceAct->setVisible(false);
|
||||
connect(recentWorkspaceAct, SIGNAL(triggered()), this, SLOT(onOpenRecent()));
|
||||
ui->menuFile->insertAction(recent_sep, recentWorkspaceAct);
|
||||
}
|
||||
|
||||
// Custom Actions
|
||||
@ -368,7 +368,7 @@ bool MainWindow::openWorkspace(const QString &path)
|
||||
QString checkout_file1 = wkspace + PATH_SEPARATOR + FOSSIL_CHECKOUT1;
|
||||
QString checkout_file2 = wkspace + PATH_SEPARATOR + FOSSIL_CHECKOUT2;
|
||||
|
||||
if (!(QFileInfo(checkout_file1).exists() || QFileInfo(checkout_file2).exists()))
|
||||
if (!(QFileInfo::exists(checkout_file1) || QFileInfo::exists(checkout_file2)))
|
||||
{
|
||||
if (QMessageBox::Yes != DialogQuery(this, tr("Open Workspace"), tr("A workspace does not exist in this folder.\nWould you like to create one here?")))
|
||||
{
|
||||
@ -569,8 +569,8 @@ void MainWindow::on_actionCloneRepository_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::rebuildRecent()
|
||||
{
|
||||
for (int i = 0; i < MAX_RECENT; ++i)
|
||||
recentWorkspaceActs[i]->setVisible(false);
|
||||
for (auto &recentWorkspaceAct : recentWorkspaceActs)
|
||||
recentWorkspaceAct->setVisible(false);
|
||||
|
||||
int enabled_acts = qMin<int>(MAX_RECENT, workspaceHistory.size());
|
||||
|
||||
@ -610,8 +610,8 @@ void MainWindow::enableActions(bool on)
|
||||
ui->actionViewIgnored, ui->actionViewModifedOnly, ui->actionViewModified, ui->actionViewUnchanged,
|
||||
ui->actionViewUnknown};
|
||||
|
||||
for (size_t i = 0; i < COUNTOF(actions); ++i)
|
||||
actions[i]->setEnabled(on);
|
||||
for (auto &action : actions)
|
||||
action->setEnabled(on);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -710,9 +710,8 @@ static void addPathToTree(QStandardItem &root, const QString &path, const QIcon
|
||||
QStandardItem *parent = &root;
|
||||
|
||||
QString fullpath;
|
||||
for (QStringList::iterator it = dirs.begin(); it != dirs.end(); ++it)
|
||||
for (auto &dir : dirs)
|
||||
{
|
||||
const QString &dir = *it;
|
||||
fullpath += dir;
|
||||
|
||||
// Find the child that matches this subdirectory
|
||||
@ -810,7 +809,7 @@ void MainWindow::updateWorkspaceView()
|
||||
if (viewMode == VIEWMODE_TREE)
|
||||
{
|
||||
// FIXME: Change paths to map to allow for automatic sorting
|
||||
QStringList paths = getWorkspace().getPaths().toList();
|
||||
QStringList paths = getWorkspace().getPaths().values();
|
||||
paths.sort();
|
||||
|
||||
foreach (const QString &dir, paths)
|
||||
@ -885,15 +884,15 @@ void MainWindow::updateWorkspaceView()
|
||||
remotes->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTES, ""), ROLE_WORKSPACE_ITEM);
|
||||
remotes->setEditable(false);
|
||||
getWorkspace().getTreeModel().appendRow(remotes);
|
||||
for (remote_map_t::const_iterator it = getWorkspace().getRemotes().begin(); it != getWorkspace().getRemotes().end(); ++it)
|
||||
for (const auto &it : getWorkspace().getRemotes())
|
||||
{
|
||||
QStandardItem *remote_item = new QStandardItem(getCachedIcon(":icons/icon-item-remote"), it->name);
|
||||
remote_item->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTE, it->url.toString()), ROLE_WORKSPACE_ITEM);
|
||||
QStandardItem *remote_item = new QStandardItem(getCachedIcon(":icons/icon-item-remote"), it.name);
|
||||
remote_item->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTE, it.url.toString()), ROLE_WORKSPACE_ITEM);
|
||||
|
||||
remote_item->setToolTip(UrlToStringDisplay(it->url));
|
||||
remote_item->setToolTip(UrlToStringDisplay(it.url));
|
||||
|
||||
// Mark the default url as bold
|
||||
if (it->isDefault)
|
||||
if (it.isDefault)
|
||||
{
|
||||
QFont font = remote_item->font();
|
||||
font.setBold(true);
|
||||
@ -972,12 +971,12 @@ void MainWindow::updateFileView()
|
||||
const QString *status_text = &status_unknown;
|
||||
const char *status_icon_path = ":icons/icon-item-unknown"; // Default icon
|
||||
|
||||
for (size_t t = 0; t < COUNTOF(stats); ++t)
|
||||
for (auto &stat : stats)
|
||||
{
|
||||
if (e.getType() == stats[t].type)
|
||||
if (e.getType() == stat.type)
|
||||
{
|
||||
status_text = &stats[t].text;
|
||||
status_icon_path = stats[t].icon;
|
||||
status_text = &stat.text;
|
||||
status_icon_path = stat.icon;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1188,9 +1187,8 @@ void MainWindow::updateSettings()
|
||||
Settings::custom_actions_t &actions = settings.GetCustomActions();
|
||||
store->beginWriteArray("CustomActions", actions.size());
|
||||
int active_actions = 0;
|
||||
for (int i = 0; i < actions.size(); ++i)
|
||||
for (auto &action : actions)
|
||||
{
|
||||
CustomAction &action = actions[i];
|
||||
if (!action.IsValid())
|
||||
continue;
|
||||
store->setArrayIndex(active_actions);
|
||||
|
@ -41,9 +41,8 @@ SettingsDialog::SettingsDialog(QWidget *parent, Settings &_settings) : QDialog(p
|
||||
|
||||
GetCustomAction(0);
|
||||
|
||||
for (int i = 0; i < currentCustomActions.size(); ++i)
|
||||
for (auto &a : currentCustomActions)
|
||||
{
|
||||
CustomAction &a = currentCustomActions[i];
|
||||
ui->cmbCustomAction->addItem(a.Id);
|
||||
}
|
||||
ui->cmbCustomAction->setCurrentIndex(0);
|
||||
@ -79,9 +78,8 @@ void SettingsDialog::on_buttonBox_accepted()
|
||||
if (curr_langid != new_langid)
|
||||
QMessageBox::information(this, tr("Restart required"), tr("The language change will take effect after restarting the application"), QMessageBox::Ok);
|
||||
|
||||
for (int i = 0; i < currentCustomActions.size(); ++i)
|
||||
for (auto &a : currentCustomActions)
|
||||
{
|
||||
CustomAction &a = currentCustomActions[i];
|
||||
a.Description = a.Description.trimmed();
|
||||
a.Command = a.Command.trimmed();
|
||||
}
|
||||
|
@ -39,15 +39,15 @@ void Workspace::storeWorkspace(QSettings &store)
|
||||
|
||||
store.beginWriteArray(workspace_hash);
|
||||
int index = 0;
|
||||
for (remote_map_t::iterator it = remotes.begin(); it != remotes.end(); ++it, ++index)
|
||||
for (auto &re : remotes)
|
||||
{
|
||||
store.setArrayIndex(index);
|
||||
store.setValue("Name", it->name);
|
||||
QUrl url = it->url;
|
||||
store.setValue("Name", re.name);
|
||||
QUrl url = re.url;
|
||||
url.setPassword("");
|
||||
store.setValue("Url", url);
|
||||
if (it->isDefault)
|
||||
store.setValue("Default", it->isDefault);
|
||||
if (re.isDefault)
|
||||
store.setValue("Default", re.isDefault);
|
||||
else
|
||||
store.remove("Default");
|
||||
}
|
||||
@ -77,10 +77,7 @@ bool Workspace::switchWorkspace(const QString &workspace, QSettings &store)
|
||||
// Load Remotes
|
||||
QString workspace_hash = HashString(QDir::toNativeSeparators(new_workspace));
|
||||
|
||||
QString gr = store.group();
|
||||
|
||||
store.beginGroup("Remotes");
|
||||
gr = store.group();
|
||||
int num_remotes = store.beginReadArray(workspace_hash);
|
||||
for (int i = 0; i < num_remotes; ++i)
|
||||
{
|
||||
@ -124,12 +121,11 @@ bool Workspace::scanDirectory(QFileInfoList &entries, const QString &dirPath, co
|
||||
uiCallback.updateProcess(dirPath);
|
||||
|
||||
QFileInfoList list = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot);
|
||||
for (int i = 0; i < list.count(); ++i)
|
||||
for (auto &info : list)
|
||||
{
|
||||
if (uiCallback.processAborted())
|
||||
return false;
|
||||
|
||||
QFileInfo info = list[i];
|
||||
QString filepath = info.filePath();
|
||||
QString rel_path = filepath;
|
||||
rel_path.remove(baseDir + PATH_SEPARATOR);
|
||||
@ -188,10 +184,10 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
||||
if (!scanDirectory(all_files, wkdir, wkdir, ignore, uiCallback))
|
||||
goto _done;
|
||||
|
||||
for (QFileInfoList::iterator it = all_files.begin(); it != all_files.end(); ++it)
|
||||
for (auto &all_file : all_files)
|
||||
{
|
||||
QString filename = it->fileName();
|
||||
QString fullpath = it->absoluteFilePath();
|
||||
QString filename = all_file.fileName();
|
||||
QString fullpath = all_file.absoluteFilePath();
|
||||
|
||||
// Skip fossil files
|
||||
if (filename == FOSSIL_CHECKOUT1 || filename == FOSSIL_CHECKOUT2 || (!fossil().getRepositoryFile().isEmpty() && QFileInfo(fullpath) == QFileInfo(fossil().getRepositoryFile())))
|
||||
@ -199,7 +195,7 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
||||
|
||||
WorkspaceFile::Type type = WorkspaceFile::TYPE_UNKNOWN;
|
||||
|
||||
WorkspaceFile *rf = new WorkspaceFile(*it, type, wkdir);
|
||||
WorkspaceFile *rf = new WorkspaceFile(all_file, type, wkdir);
|
||||
const QString &path = rf->getPath();
|
||||
getFiles().insert(rf->getFilePath(), rf);
|
||||
getPaths().insert(path);
|
||||
@ -220,9 +216,9 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
||||
uiCallback.beginProcess(QObject::tr("Updating..."));
|
||||
|
||||
// Update Files and Directories
|
||||
for (QStringList::iterator line_it = res.begin(); line_it != res.end(); ++line_it)
|
||||
for (auto &re : res)
|
||||
{
|
||||
QString line = (*line_it).trimmed();
|
||||
QString line = re.trimmed();
|
||||
if (line.length() == 0)
|
||||
continue;
|
||||
|
||||
@ -323,9 +319,9 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
||||
parent_path = "";
|
||||
|
||||
// Merge path of child to parent
|
||||
pathstate_map_t::iterator state_it = pathState.find(parent_path);
|
||||
if (state_it != pathState.end())
|
||||
state_it.value() = static_cast<WorkspaceFile::Type>(state_it.value() | state);
|
||||
pathstate_map_t::iterator state_it2 = pathState.find(parent_path);
|
||||
if (state_it2 != pathState.end())
|
||||
state_it2.value() = static_cast<WorkspaceFile::Type>(state_it2.value() | state);
|
||||
else
|
||||
pathState.insert(parent_path, state);
|
||||
}
|
||||
@ -386,15 +382,15 @@ bool Workspace::setRemoteDefault(const QUrl &url)
|
||||
const QString &url_str = url.toString();
|
||||
|
||||
bool found = false;
|
||||
for (remote_map_t::iterator it = remotes.begin(); it != remotes.end(); ++it)
|
||||
for (auto &remote : remotes)
|
||||
{
|
||||
if (it->url.toString() == url_str) // FIXME: Use strings as QUrl to QUrl comparisons sometime fail!?
|
||||
if (remote.url.toString() == url_str) // FIXME: Use strings as QUrl to QUrl comparisons sometime fail!?
|
||||
{
|
||||
it->isDefault = true;
|
||||
remote.isDefault = true;
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
it->isDefault = false;
|
||||
remote.isDefault = false;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
@ -402,10 +398,10 @@ bool Workspace::setRemoteDefault(const QUrl &url)
|
||||
//------------------------------------------------------------------------------
|
||||
QUrl Workspace::getRemoteDefault() const
|
||||
{
|
||||
for (remote_map_t::const_iterator it = remotes.begin(); it != remotes.end(); ++it)
|
||||
for (const auto &remote : remotes)
|
||||
{
|
||||
if (it->isDefault)
|
||||
return it->url;
|
||||
if (remote.isDefault)
|
||||
return remote.url;
|
||||
}
|
||||
|
||||
return QUrl();
|
||||
|
Loading…
x
Reference in New Issue
Block a user