Commit 3e2ce73f authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

debuggercommon: port foreach -> range-based for

parent 1234dd54
......@@ -51,11 +51,11 @@ void CommandQueue::enqueue(MICommand* command)
dumpQueue();
}
void CommandQueue::dumpQueue()
void CommandQueue::dumpQueue() const
{
qCDebug(DEBUGGERCOMMON) << "Pending commands" << m_commandList.count();
unsigned commandNum = 0;
foreach(const MICommand* command, m_commandList) {
for (const MICommand* command : m_commandList) {
qCDebug(DEBUGGERCOMMON) << "Command" << commandNum << command->initialString();
++commandNum;
}
......
......@@ -53,7 +53,7 @@ private:
void rationalizeQueue(MICommand* command);
void removeVariableUpdates();
void removeStackListUpdates();
void dumpQueue();
void dumpQueue() const;
QList<MICommand*> m_commandList;
int m_immediatelyCounter = 0;
......
......@@ -338,7 +338,7 @@ void MIVariable::formatChanged()
{
if(childCount())
{
foreach(TreeItem* item, childItems) {
for (TreeItem* item : qAsConst(childItems)) {
Q_ASSERT(dynamic_cast<MIVariable*>(item));
if (auto* var = qobject_cast<MIVariable*>(item)) {
var->setFormat(format());
......
......@@ -84,7 +84,8 @@ QString ModelsManager::addView(QAbstractItemView* view)
Q_ASSERT(m_controller);
QString name;
foreach (const GroupsName & group, m_controller->namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = m_controller->namesOfRegisterGroups();
for (const GroupsName& group : namesOfRegisterGroups) {
if (!m_models->contains(group.name())) {
QStandardItemModel* m = m_models->addModel(Model(group.name(), QSharedPointer<QStandardItemModel>(new QStandardItemModel()), view));
view->setModel(m);
......@@ -278,7 +279,8 @@ void ModelsManager::updateRegisters(const QString& group)
if (group.isEmpty()) {
m_controller->updateRegisters(GroupsName());
} else {
foreach (const GroupsName & g, m_controller->namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = m_controller->namesOfRegisterGroups();
for (const GroupsName& g : namesOfRegisterGroups) {
if (g.name() == group) {
m_controller->updateRegisters(g);
break;
......@@ -294,7 +296,8 @@ void Models::clear()
void ModelsManager::setFormat(const QString& group, Format format)
{
foreach (const GroupsName & g, m_controller->namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = m_controller->namesOfRegisterGroups();
for (const GroupsName& g : namesOfRegisterGroups) {
if (g.name() == group) {
m_controller->setFormat(format, g);
save(g);
......@@ -307,7 +310,8 @@ QVector<Format> ModelsManager::formats(const QString& group) const
{
QVector<Format> formats; formats << Raw;
foreach (const GroupsName & g, m_controller->namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = m_controller->namesOfRegisterGroups();
for (const GroupsName& g : namesOfRegisterGroups) {
if (g.name() == group) {
formats = m_controller->formats(g);
break;
......@@ -339,7 +343,8 @@ QVector< Mode > ModelsManager::modes(const QString& group) const
{
QVector<Mode> modes;
foreach (const GroupsName & g, m_controller->namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = m_controller->namesOfRegisterGroups();
for (const GroupsName& g : namesOfRegisterGroups) {
if (g.name() == group) {
modes = m_controller->modes(g);
break;
......@@ -351,7 +356,8 @@ QVector< Mode > ModelsManager::modes(const QString& group) const
void ModelsManager::setMode(const QString& group, Mode mode)
{
foreach (const GroupsName & g, m_controller->namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = m_controller->namesOfRegisterGroups();
for (const GroupsName& g : namesOfRegisterGroups) {
if (g.name() == group) {
m_controller->setMode(mode, g);
save(g);
......
......@@ -49,7 +49,8 @@ void IRegisterController::updateRegisters(const GroupsName& group)
}
if (group.name().isEmpty()) {
foreach (const GroupsName & g, namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = this->namesOfRegisterGroups();
for (const GroupsName& g : namesOfRegisterGroups) {
IRegisterController::updateRegisters(g);
}
return;
......@@ -93,7 +94,8 @@ void IRegisterController::updateRegisters(const GroupsName& group)
if (group.type() == flag) {
registers += numberForName(group.flagName());
} else {
foreach (const QString & name, registerNamesForGroup(group)) {
const auto names = registerNamesForGroup(group);
for (const QString& name : names) {
registers += numberForName(name) + QLatin1Char(' ');
}
}
......@@ -193,7 +195,8 @@ bool IRegisterController::initializeRegisters()
GroupsName IRegisterController::groupForRegisterName(const QString& name) const
{
foreach (const GroupsName & group, namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = this->namesOfRegisterGroups();
for (const GroupsName& group : namesOfRegisterGroups) {
const QStringList registersInGroup = registerNamesForGroup(group);
if (group.flagName() == name) {
return group;
......@@ -265,7 +268,8 @@ void IRegisterController::updateFlagValues(RegistersGroup* flagsGroup, const Fla
QVector<Format> IRegisterController::formats(const GroupsName& group)
{
int idx = -1;
foreach (const GroupsName & g, namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = this->namesOfRegisterGroups();
for (const GroupsName& g : namesOfRegisterGroups) {
if (g == group) {
idx = g.index();
}
......@@ -281,7 +285,8 @@ GroupsName IRegisterController::createGroupName(const QString& name, int idx, Re
void IRegisterController::setFormat(Format f, const GroupsName& group)
{
foreach (const GroupsName & g, namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = this->namesOfRegisterGroups();
for (const GroupsName& g : namesOfRegisterGroups) {
if (g == group) {
int i = m_formatsModes[g.index()].formats.indexOf(f);
if (i != -1) {
......@@ -387,7 +392,8 @@ void IRegisterController::structuredRegistersHandler(const ResultRecord& r)
QVector< Mode > IRegisterController::modes(const GroupsName& group)
{
int idx = -1;
foreach (const GroupsName & g, namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = this->namesOfRegisterGroups();
for (const GroupsName& g : namesOfRegisterGroups) {
if (g == group) {
idx = g.index();
}
......@@ -398,7 +404,8 @@ QVector< Mode > IRegisterController::modes(const GroupsName& group)
void IRegisterController::setMode(Mode m, const GroupsName& group)
{
foreach (const GroupsName & g, namesOfRegisterGroups()) {
const auto namesOfRegisterGroups = this->namesOfRegisterGroups();
for (const GroupsName& g : namesOfRegisterGroups) {
if (g == group) {
int i = m_formatsModes[g.index()].modes.indexOf(m);
if (i != -1) {
......
......@@ -37,7 +37,7 @@ void ArchitectureParser::parseArchitecture()
{
Architecture arch = other;
foreach (const QString & reg, m_registerNames) {
for (const QString& reg : qAsConst(m_registerNames)) {
if (reg == QLatin1String("rax")) {
arch = x86_64;
break;
......
......@@ -56,7 +56,7 @@ void RegistersView::contextMenuEvent(QContextMenuEvent* e)
QString group = activeViews().first();
foreach (QAction * act, m_actions) {
for (QAction* act : qAsConst(m_actions)) {
act->setChecked(false);
}
......@@ -85,7 +85,8 @@ void RegistersView::updateRegisters()
{
changeAvaliableActions();
foreach (const QString & v, activeViews()) {
const auto views = activeViews();
for (const QString& v : views) {
m_modelsManager->updateRegisters(v);
}
}
......@@ -112,7 +113,7 @@ void RegistersView::changeAvaliableActions()
const QVector<Format> formats = m_modelsManager->formats(view) ;
const QVector<Mode> modes = m_modelsManager->modes(view);
foreach (QAction * a, m_actions) {
for (QAction* a : qAsConst(m_actions)) {
bool enable = false;
for (Format f : formats) {
if (a->text() == Converters::formatToString(f)) {
......@@ -135,14 +136,12 @@ void RegistersView::changeAvaliableActions()
}
}
QAction* RegistersView::findAction(const QString& name)
QAction* RegistersView::findAction(const QString& name) const
{
foreach (QAction * a, m_actions) {
if (a->text() == name) {
return a;
}
}
return nullptr;
auto it = std::find_if(m_actions.begin(), m_actions.end(), [&](QAction* a) {
return (a->text() == name);
});
return (it != m_actions.end()) ? *it : nullptr;
}
void RegistersView::addView(QTableView* view, int idx)
......
......@@ -73,7 +73,7 @@ private:
///Adds new action into m_actions and to this widget's list of actions.
void insertAction(const QString& name, Qt::Key k);
///Returns action for given @p name.
QAction* findAction(const QString& name);
QAction* findAction(const QString& name) const;
private Q_SLOTS:
///Enables/disables actions based on current view.
void changeAvaliableActions();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment