mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-27 21:39:57 +01:00
Replace foreach function by for, please try and report problem
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4900 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -137,7 +137,7 @@ void HelperCell::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||
if (actions_.isEmpty()) return;
|
||||
|
||||
QMenu context_menu;
|
||||
foreach (QAction *action, actions_) {
|
||||
for (QAction *action: actions_) {
|
||||
context_menu.addAction(action);
|
||||
}
|
||||
emit(contextMenuTriggered(this));
|
||||
|
||||
@@ -50,7 +50,7 @@ TitleBlockTemplateCellsSet::~TitleBlockTemplateCellsSet() {
|
||||
*/
|
||||
QPainterPath TitleBlockTemplateCellsSet::painterPath() const {
|
||||
QPainterPath cells_path;
|
||||
foreach (TitleBlockTemplateVisualCell *cell, *this) {
|
||||
for (TitleBlockTemplateVisualCell *cell: *this) {
|
||||
cells_path.addRect(cell -> geometry());
|
||||
}
|
||||
return(cells_path);
|
||||
@@ -74,7 +74,7 @@ bool TitleBlockTemplateCellsSet::isRectangle() const {
|
||||
@return true if all cells within this set are selected
|
||||
*/
|
||||
bool TitleBlockTemplateCellsSet::allCellsAreSelected() const {
|
||||
foreach (TitleBlockTemplateVisualCell *cell, *this) {
|
||||
for (TitleBlockTemplateVisualCell *cell: *this) {
|
||||
if (!cell -> isSelected()) {
|
||||
return(false);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ bool TitleBlockTemplateCellsSet::hasExternalSpan() const {
|
||||
QSet<TitleBlockCell *> all_cells = cells(true);
|
||||
|
||||
// look for cells spanned by cells that do not belong to this set
|
||||
foreach (TitleBlockCell *cell, all_cells) {
|
||||
for (TitleBlockCell *cell: all_cells) {
|
||||
if (cell -> spanner_cell && !all_cells.contains(cell -> spanner_cell)) {
|
||||
return(true);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ TitleBlockTemplateVisualCell *TitleBlockTemplateCellsSet::topLeftCell() const {
|
||||
|
||||
// look for cells at the top
|
||||
QMultiMap<int, TitleBlockTemplateVisualCell *> top_cells;
|
||||
foreach (TitleBlockTemplateVisualCell *cell_view, *this) {
|
||||
for (TitleBlockTemplateVisualCell *cell_view: *this) {
|
||||
if (TitleBlockCell *cell = cell_view -> cell()) {
|
||||
top_cells.insertMulti(cell -> num_row, cell_view);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ TitleBlockTemplateVisualCell *TitleBlockTemplateCellsSet::topLeftCell() const {
|
||||
// look for the cell at the left
|
||||
int lowest_num_col = 100000;
|
||||
TitleBlockTemplateVisualCell *candidate = 0;
|
||||
foreach (TitleBlockTemplateVisualCell *cell_view, candidates) {
|
||||
for (TitleBlockTemplateVisualCell *cell_view: candidates) {
|
||||
if (TitleBlockCell *cell = cell_view -> cell()) {
|
||||
if (cell -> num_col < lowest_num_col) {
|
||||
lowest_num_col = cell -> num_col;
|
||||
@@ -139,7 +139,7 @@ TitleBlockTemplateVisualCell *TitleBlockTemplateCellsSet::bottomRightCell() cons
|
||||
|
||||
// look for cells at the bottom
|
||||
QMultiMap<qreal, TitleBlockTemplateVisualCell *> bottom_cells;
|
||||
foreach (TitleBlockTemplateVisualCell *cell_view, *this) {
|
||||
for (TitleBlockTemplateVisualCell *cell_view: *this) {
|
||||
bottom_cells.insertMulti(cell_view -> geometry().bottom(), cell_view);
|
||||
}
|
||||
QList<TitleBlockTemplateVisualCell *> candidates = bottom_cells.values(bottom_cells.keys().last());
|
||||
@@ -148,7 +148,7 @@ TitleBlockTemplateVisualCell *TitleBlockTemplateCellsSet::bottomRightCell() cons
|
||||
// look for the cell at the right
|
||||
qreal highest_right = -100000;
|
||||
TitleBlockTemplateVisualCell *candidate = 0;
|
||||
foreach (TitleBlockTemplateVisualCell *cell_view, candidates) {
|
||||
for (TitleBlockTemplateVisualCell *cell_view: candidates) {
|
||||
qreal right = cell_view -> geometry().right();
|
||||
if (right > highest_right) {
|
||||
highest_right = right;
|
||||
@@ -197,10 +197,10 @@ TitleBlockTemplateCellsSet TitleBlockTemplateCellsSet::mergeArea(const QRectF &r
|
||||
*/
|
||||
QSet<TitleBlockCell *> TitleBlockTemplateCellsSet::cells(bool include_spanned) const {
|
||||
QSet<TitleBlockCell *> set;
|
||||
foreach (TitleBlockTemplateVisualCell *cell_view, *this) {
|
||||
for (TitleBlockTemplateVisualCell *cell_view: *this) {
|
||||
if (TitleBlockCell *cell = cell_view -> cell()) {
|
||||
if (include_spanned) {
|
||||
foreach (TitleBlockCell *cell, cell_view -> cells()) {
|
||||
for (TitleBlockCell *cell: cell_view -> cells()) {
|
||||
set << cell;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -308,7 +308,7 @@ void TitleBlockTemplateCellWidget::updateLogosComboBox(const TitleBlockTemplate
|
||||
logo_input_ -> setCurrentIndex(0);
|
||||
|
||||
if (!parent_template) return;
|
||||
foreach (QString logo, parent_template -> logos()) {
|
||||
for (QString logo: parent_template -> logos()) {
|
||||
logo_input_ -> addItem(logo, QVariant(logo));
|
||||
}
|
||||
int current_value_index = logo_input_ -> findData(current_value);
|
||||
|
||||
@@ -72,7 +72,7 @@ bool ModifyTitleBlockCellCommand::mergeWith(const QUndoCommand *command) {
|
||||
*/
|
||||
void ModifyTitleBlockCellCommand::undo() {
|
||||
if (!modified_cell_) return;
|
||||
foreach (QString attribute, old_values_.keys()) {
|
||||
for (QString attribute: old_values_.keys()) {
|
||||
modified_cell_ -> setAttribute(attribute, old_values_[attribute]);
|
||||
}
|
||||
if (view_) view_ -> refresh();
|
||||
@@ -83,7 +83,7 @@ void ModifyTitleBlockCellCommand::undo() {
|
||||
*/
|
||||
void ModifyTitleBlockCellCommand::redo() {
|
||||
if (!modified_cell_) return;
|
||||
foreach (QString attribute, new_values_.keys()) {
|
||||
for (QString attribute: new_values_.keys()) {
|
||||
modified_cell_ -> setAttribute(attribute, new_values_[attribute]);
|
||||
}
|
||||
if (view_) view_ -> refresh();
|
||||
@@ -601,7 +601,7 @@ MergeCellsCommand::MergeCellsCommand(const TitleBlockTemplateCellsSet &merged_ce
|
||||
if (!spanning_cell_) return;
|
||||
|
||||
// store the spanner_cell attribute of each cell implied in the merge
|
||||
foreach(TitleBlockCell *cell, merged_cells.cells()) {
|
||||
for (TitleBlockCell *cell: merged_cells.cells()) {
|
||||
spanner_cells_before_merge_.insert(cell, cell -> spanner_cell);
|
||||
}
|
||||
|
||||
@@ -670,7 +670,7 @@ void MergeCellsCommand::undo() {
|
||||
if (!isValid()) return;
|
||||
|
||||
// restore the original spanning_cell attribute of all impacted cells
|
||||
foreach (TitleBlockCell *cell, spanner_cells_before_merge_.keys()) {
|
||||
for (TitleBlockCell *cell: spanner_cells_before_merge_.keys()) {
|
||||
cell -> spanner_cell = spanner_cells_before_merge_[cell];
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ void MergeCellsCommand::redo() {
|
||||
if (!isValid()) return;
|
||||
|
||||
// set the spanning_cell attributes of spanned cells to the spanning cell
|
||||
foreach (TitleBlockCell *cell, spanner_cells_before_merge_.keys()) {
|
||||
for (TitleBlockCell *cell: spanner_cells_before_merge_.keys()) {
|
||||
if (cell == spanning_cell_) continue;
|
||||
cell -> spanner_cell = spanning_cell_;
|
||||
}
|
||||
@@ -723,7 +723,7 @@ TitleBlockCell *MergeCellsCommand::getBottomRightCell(const TitleBlockTemplateCe
|
||||
// we then look for the bottom right logical cell
|
||||
int max_num_row = -1, max_num_col = -1;
|
||||
TitleBlockCell *candidate = 0;
|
||||
foreach(TitleBlockCell *cell, logical_cells) {
|
||||
for (TitleBlockCell *cell: logical_cells) {
|
||||
if (cell -> num_row > max_num_row) max_num_row = cell -> num_row;
|
||||
if (cell -> num_col > max_num_col) max_num_col = cell -> num_col;
|
||||
if (cell -> num_row == max_num_row && cell -> num_col == max_num_col) {
|
||||
@@ -810,7 +810,7 @@ void SplitCellsCommand::undo() {
|
||||
if (!isValid()) return;
|
||||
|
||||
// the spanned cells are spanned again
|
||||
foreach(TitleBlockCell *cell, spanned_cells_) {
|
||||
for (TitleBlockCell *cell: spanned_cells_) {
|
||||
cell -> spanner_cell = spanning_cell_;
|
||||
}
|
||||
|
||||
@@ -831,7 +831,7 @@ void SplitCellsCommand::redo() {
|
||||
if (!isValid()) return;
|
||||
|
||||
// the spanned cells are not spanned anymore
|
||||
foreach(TitleBlockCell *cell, spanned_cells_) {
|
||||
for (TitleBlockCell *cell: spanned_cells_) {
|
||||
cell -> spanner_cell = 0;
|
||||
}
|
||||
|
||||
@@ -898,7 +898,7 @@ CutTemplateCellsCommand::~CutTemplateCellsCommand() {
|
||||
Undo a cut operation
|
||||
*/
|
||||
void CutTemplateCellsCommand::undo() {
|
||||
foreach (TitleBlockCell *cell, cut_cells_.keys()) {
|
||||
for (TitleBlockCell *cell: cut_cells_.keys()) {
|
||||
cell -> cell_type = cut_cells_.value(cell);
|
||||
}
|
||||
refreshView();
|
||||
@@ -908,14 +908,14 @@ void CutTemplateCellsCommand::undo() {
|
||||
Redo a cut operation
|
||||
*/
|
||||
void CutTemplateCellsCommand::redo() {
|
||||
foreach (TitleBlockCell *cell, cut_cells_.keys()) {
|
||||
for (TitleBlockCell *cell: cut_cells_.keys()) {
|
||||
cell -> cell_type = TitleBlockCell::EmptyCell;
|
||||
}
|
||||
refreshView();
|
||||
}
|
||||
|
||||
void CutTemplateCellsCommand::setCutCells(const QList<TitleBlockCell *> &cells) {
|
||||
foreach (TitleBlockCell *cell, cells) {
|
||||
for (TitleBlockCell *cell: cells) {
|
||||
cut_cells_.insert(cell, cell -> cell_type);
|
||||
}
|
||||
updateText();
|
||||
@@ -957,7 +957,7 @@ void PasteTemplateCellsCommand::updateText() {
|
||||
*/
|
||||
void PasteTemplateCellsCommand::undo() {
|
||||
bool span_management = erased_cells_.count() > 1;
|
||||
foreach (TitleBlockCell *cell, erased_cells_.keys()) {
|
||||
for (TitleBlockCell *cell: erased_cells_.keys()) {
|
||||
cell -> loadContentFromCell(erased_cells_.value(cell));
|
||||
}
|
||||
if (span_management) {
|
||||
@@ -987,7 +987,7 @@ void PasteTemplateCellsCommand::redo() {
|
||||
}
|
||||
|
||||
// copy data from each pasted cell into each erased cell
|
||||
foreach (TitleBlockCell *cell, erased_cells_.keys()) {
|
||||
for (TitleBlockCell *cell: erased_cells_.keys()) {
|
||||
if (span_management) {
|
||||
// the erased cell may be spanned by another cell
|
||||
if (TitleBlockCell *spanning_cell = cell -> spanner_cell) {
|
||||
@@ -1012,7 +1012,7 @@ void PasteTemplateCellsCommand::redo() {
|
||||
|
||||
if (cell -> row_span || cell -> col_span) {
|
||||
// browse newly spanned cells...
|
||||
foreach (TitleBlockCell *spanned_cell, tbtemplate_ -> spannedCells(cell, true)) {
|
||||
for (TitleBlockCell *spanned_cell: tbtemplate_ -> spannedCells(cell, true)) {
|
||||
// ... to ensure they are not already spanned by other cells
|
||||
if (spanned_cell -> spanner_cell && spanned_cell -> spanner_cell != cell) {
|
||||
// if so, simply cancel the whole spanning
|
||||
|
||||
@@ -116,7 +116,7 @@ void TitleBlockTemplateLocationChooser::updateCollections() {
|
||||
collections_index_.clear();
|
||||
|
||||
int index = 0;
|
||||
foreach(TitleBlockTemplatesCollection *collection, QETApp::availableTitleBlockTemplatesCollections()) {
|
||||
for (TitleBlockTemplatesCollection *collection: QETApp::availableTitleBlockTemplatesCollections()) {
|
||||
collections_ -> addItem(collection -> title());
|
||||
collections_index_.insert(index, collection);
|
||||
++ index;
|
||||
@@ -136,7 +136,7 @@ void TitleBlockTemplateLocationChooser::updateTemplates() {
|
||||
|
||||
QStringList available_templates = current_collection -> templates();
|
||||
if (available_templates.count()) {
|
||||
foreach (QString template_name, available_templates) {
|
||||
for (QString template_name: available_templates) {
|
||||
templates_ -> addItem(template_name, QVariant(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ void TitleBlockTemplateLogoManager::fillView() {
|
||||
if (!managed_template_) return;
|
||||
logos_view_ -> clear();
|
||||
|
||||
foreach (QString logo_name, managed_template_ -> logos()) {
|
||||
for (QString logo_name: managed_template_ -> logos()) {
|
||||
QIcon current_icon;
|
||||
QPixmap current_logo = managed_template_ -> bitmapLogo(logo_name);
|
||||
if (!current_logo.isNull()) {
|
||||
|
||||
@@ -98,7 +98,7 @@ QETProject *TitleBlockTemplatesCollection::parentProject() {
|
||||
*/
|
||||
QList<TitleBlockTemplateLocation> TitleBlockTemplatesCollection::templatesLocations() {
|
||||
QList<TitleBlockTemplateLocation> locations;
|
||||
foreach (QString template_name, templates()) {
|
||||
for (QString template_name: templates()) {
|
||||
locations << location(template_name);
|
||||
}
|
||||
return(locations);
|
||||
@@ -320,7 +320,7 @@ bool TitleBlockTemplatesProjectCollection::isReadOnly(const QString &template_na
|
||||
@param xml_element XML element to be parsed to load title block templates
|
||||
*/
|
||||
void TitleBlockTemplatesProjectCollection::fromXml(const QDomElement &xml_element) {
|
||||
foreach (QDomElement e, QET::findInDomElement(xml_element, "titleblocktemplates", "titleblocktemplate")) {
|
||||
for (QDomElement e: QET::findInDomElement(xml_element, "titleblocktemplates", "titleblocktemplate")) {
|
||||
// each titleblock template must have a name
|
||||
if (!e.hasAttribute("name")) continue;
|
||||
QString titleblock_template_name = e.attribute("name");
|
||||
@@ -340,7 +340,7 @@ void TitleBlockTemplatesProjectCollection::fromXml(const QDomElement &xml_elemen
|
||||
void TitleBlockTemplatesProjectCollection::deleteUnusedTitleBlocKTemplates() {
|
||||
if (!project_) return;
|
||||
|
||||
foreach (QString template_name, templates()) {
|
||||
for (QString template_name: templates()) {
|
||||
if (!project_ -> usesTitleBlockTemplate(location(template_name))) {
|
||||
removeTemplate(template_name);
|
||||
}
|
||||
@@ -390,7 +390,7 @@ QString TitleBlockTemplatesFilesCollection::path(const QString &template_name) c
|
||||
QStringList TitleBlockTemplatesFilesCollection::templates() {
|
||||
QStringList templates_names;
|
||||
QRegExp replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
|
||||
foreach(QString name, dir_.entryList()) {
|
||||
for (QString name: dir_.entryList()) {
|
||||
templates_names << name.replace(replace_regexp, "");
|
||||
}
|
||||
return(templates_names);
|
||||
|
||||
@@ -158,7 +158,7 @@ QList<TitleBlockCell *> TitleBlockTemplateView::copy() {
|
||||
QDomDocument xml_export;
|
||||
QDomElement tbtpartial = xml_export.createElement("titleblocktemplate-partial");
|
||||
xml_export.appendChild(tbtpartial);
|
||||
foreach (TitleBlockCell *cell, copied_cells) {
|
||||
for (TitleBlockCell *cell: copied_cells) {
|
||||
tbtemplate_ -> exportCellToXml(cell, tbtpartial);
|
||||
tbtpartial.setAttribute("row", cell -> num_row);
|
||||
tbtpartial.setAttribute("col", cell -> num_col);
|
||||
@@ -248,7 +248,7 @@ void TitleBlockTemplateView::paste() {
|
||||
normalizeCells(pasted_cells, erased_cell -> num_row, erased_cell -> num_col);
|
||||
|
||||
PasteTemplateCellsCommand *paste_command = new PasteTemplateCellsCommand(tbtemplate_);
|
||||
foreach (TitleBlockCell cell, pasted_cells) {
|
||||
for (TitleBlockCell cell: pasted_cells) {
|
||||
TitleBlockCell *erased_cell = tbtemplate_ -> cell(cell.num_row, cell.num_col);
|
||||
if (!erased_cell) continue;
|
||||
paste_command -> addCell(erased_cell, *erased_cell, cell);
|
||||
@@ -1056,7 +1056,7 @@ void TitleBlockTemplateView::removeItem(QGraphicsLayoutItem *item) {
|
||||
*/
|
||||
TitleBlockTemplateCellsSet TitleBlockTemplateView::makeCellsSetFromGraphicsItems(const QList<QGraphicsItem *> &items) const {
|
||||
TitleBlockTemplateCellsSet set(this);
|
||||
foreach (QGraphicsItem *item, items) {
|
||||
for (QGraphicsItem *item: items) {
|
||||
if (TitleBlockTemplateVisualCell *cell_view = dynamic_cast<TitleBlockTemplateVisualCell *>(item)) {
|
||||
if (cell_view -> cell() && cell_view -> cell() -> num_row != -1) {
|
||||
set << cell_view;
|
||||
|
||||
Reference in New Issue
Block a user