# HG changeset patch # User Santeri Piippo # Date 1369399103 -10800 # Node ID 3f9067022d74a7f7f3fb41b1e95bd0b47bdd2321 # Parent c4b96bc41298cd3828de8c9e1a067407d078600d Take the aforementioned operator<< into use diff -r c4b96bc41298 -r 3f9067022d74 src/configDialog.cpp --- a/src/configDialog.cpp Fri May 24 15:23:56 2013 +0300 +++ b/src/configDialog.cpp Fri May 24 15:38:23 2013 +0300 @@ -368,14 +368,14 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -void ConfigDialog::updateQuickColorList (quickColorMetaEntry* sel) { +void ConfigDialog::updateQuickColorList (quickColor* sel) { for (QListWidgetItem* item : quickColorItems) delete item; quickColorItems.clear (); // Init table items - for (quickColorMetaEntry& entry : quickColorMeta) { + for (quickColor& entry : quickColorMeta) { QListWidgetItem* item = new QListWidgetItem; if (entry.bSeparator) { @@ -394,7 +394,7 @@ } lw_quickColors->addItem (item); - quickColorItems.push_back (item); + quickColorItems << item; if (sel && &entry == sel) { lw_quickColors->setCurrentItem (item); @@ -407,7 +407,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void ConfigDialog::slot_setColor () { - quickColorMetaEntry* entry = null; + quickColor* entry = null; QListWidgetItem* item = null; const bool isNew = static_cast (sender ()) == pb_addColor; @@ -432,7 +432,7 @@ if (entry) entry->col = getColor (dValue); else { - quickColorMetaEntry entry = {getColor (dValue), null, false}; + quickColor entry = {getColor (dValue), null, false}; item = getSelectedQuickColor (); ulong idx; @@ -463,29 +463,29 @@ // ============================================================================= void ConfigDialog::slot_moveColor () { - const bool bUp = (static_cast (sender()) == pb_moveColorUp); + const bool up = (static_cast (sender()) == pb_moveColorUp); if (lw_quickColors->selectedItems().size() == 0) return; - QListWidgetItem* qItem = lw_quickColors->selectedItems ()[0]; - ulong ulIdx = getItemRow (qItem, quickColorItems); + QListWidgetItem* item = lw_quickColors->selectedItems ()[0]; + ulong idx = getItemRow (item, quickColorItems); - long lDest = bUp ? (ulIdx - 1) : (ulIdx + 1); + long dest = up ? (idx - 1) : (idx + 1); - if (lDest < 0 || (ulong)lDest >= quickColorItems.size ()) + if (dest < 0 || (ulong) dest >= quickColorItems.size ()) return; // destination out of bounds - quickColorMetaEntry tmp = quickColorMeta[lDest]; - quickColorMeta[lDest] = quickColorMeta[ulIdx]; - quickColorMeta[ulIdx] = tmp; + quickColor tmp = quickColorMeta[dest]; + quickColorMeta[dest] = quickColorMeta[idx]; + quickColorMeta[idx] = tmp; - updateQuickColorList (&quickColorMeta[lDest]); + updateQuickColorList (&quickColorMeta[dest]); } // ============================================================================= void ConfigDialog::slot_addColorSeparator() { - quickColorMeta.push_back ({null, null, true}); + quickColorMeta << quickColor ({null, null, true}); updateQuickColorList (&quickColorMeta[quickColorMeta.size () - 1]); } @@ -655,7 +655,7 @@ str ConfigDialog::makeColorToolBarString () { str val; - for (quickColorMetaEntry entry : quickColorMeta) { + for (quickColor entry : quickColorMeta) { if (~val > 0) val += ':'; diff -r c4b96bc41298 -r 3f9067022d74 src/configDialog.h --- a/src/configDialog.h Fri May 24 15:23:56 2013 +0300 +++ b/src/configDialog.h Fri May 24 15:38:23 2013 +0300 @@ -69,7 +69,7 @@ QPushButton* pb_addColor, *pb_delColor, *pb_changeColor, *pb_addColorSeparator, *pb_moveColorUp, *pb_moveColorDown, *pb_clearColors; vector quickColorItems; - vector quickColorMeta; + vector quickColorMeta; // ========================================================================= // Grid tab @@ -93,7 +93,7 @@ void makeSlider (QSlider*& slider, short min, short max, short defval); void setButtonBackground (QPushButton* qButton, str zValue); void pickColor (strconfig& cfg, QPushButton* qButton); - void updateQuickColorList (quickColorMetaEntry* pSel = null); + void updateQuickColorList (quickColor* pSel = null); void setShortcutText (QListWidgetItem* qItem, actionmeta meta); long getItemRow (QListWidgetItem* qItem, vector& haystack); str makeColorToolBarString (); diff -r c4b96bc41298 -r 3f9067022d74 src/extprogs.cpp --- a/src/extprogs.cpp Fri May 24 15:23:56 2013 +0300 +++ b/src/extprogs.cpp Fri May 24 15:38:23 2013 +0300 @@ -158,7 +158,7 @@ if (obj->isColored () == false || obj->color != colnum) continue; - objects.push_back (obj); + objects << obj; } writeObjects (objects, fname); @@ -237,9 +237,9 @@ } ulong idx = g_curfile->addObject (obj); - indices.push_back (idx); - copies.push_back (obj->clone ()); - g_win->sel ().push_back (obj); + indices << idx; + copies << obj->clone (); + g_win->sel () << obj; } if (indices.size() > 0) diff -r c4b96bc41298 -r 3f9067022d74 src/file.cpp --- a/src/file.cpp Fri May 24 15:23:56 2013 +0300 +++ b/src/file.cpp Fri May 24 15:38:23 2013 +0300 @@ -216,7 +216,7 @@ (*m_warningsPointer)++; } - m_objs.push_back (obj); + m_objs << obj; m_progress++; emit progressUpdate (m_progress); @@ -334,7 +334,7 @@ load->addObject (obj); fclose (fp); - g_loadedFiles.push_back (load); + g_loadedFiles << load; logf ("File %s parsed successfully (%lu warning%s).\n", path.chars(), numWarnings, plural (numWarnings)); @@ -419,7 +419,7 @@ LDOpenFile* f = new LDOpenFile; f->setName (""); f->setImplicit (false); - g_loadedFiles.push_back (f); + g_loadedFiles << f; g_curfile = f; History::clear (); @@ -791,7 +791,7 @@ delete file; g_loadedFiles.clear (); - g_loadedFiles.push_back (g_curfile); + g_loadedFiles << g_curfile; // Go through all objects in the current file and reload the subfiles for (LDObject* obj : g_curfile->objs ()) { @@ -819,7 +819,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= ulong LDOpenFile::addObject (LDObject* obj) { - m_objs.push_back (obj); + m_objs << obj; if (this == g_curfile) g_BBox.calcObject (obj); @@ -909,7 +909,7 @@ partListEntry entry; strcpy (entry.sName, sName); strcpy (entry.sTitle, sTitle); - g_PartList.push_back (entry); + g_PartList << entry; } } diff -r c4b96bc41298 -r 3f9067022d74 src/gldraw.cpp --- a/src/gldraw.cpp Fri May 24 15:23:56 2013 +0300 +++ b/src/gldraw.cpp Fri May 24 15:38:23 2013 +0300 @@ -285,7 +285,7 @@ return; printf ("%s: Unknown color %d!\n", __func__, obj->color); - g_warnedColors.push_back (obj->color); + g_warnedColors << obj->color; return; } } @@ -878,7 +878,7 @@ } } - m_drawedVerts.push_back (m_hoverpos); + m_drawedVerts << m_hoverpos; update (); break; @@ -1100,7 +1100,7 @@ break; } - g_win->sel ().push_back (obj); + g_win->sel () << obj; } delete[] pixeldata; diff -r c4b96bc41298 -r 3f9067022d74 src/gui.cpp --- a/src/gui.cpp Fri May 24 15:23:56 2013 +0300 +++ b/src/gui.cpp Fri May 24 15:38:23 2013 +0300 @@ -293,7 +293,7 @@ connect (recent, SIGNAL (triggered ()), this, SLOT (slot_recentFile ())); m_recentFilesMenu->addAction (recent); - m_recentFiles.push_back (recent); + m_recentFiles << recent; } } @@ -306,7 +306,7 @@ void ForgeWindow::initSingleToolBar (const char* name) { QToolBar* toolbar = new QToolBar (name); addToolBar (g_ToolBarArea, toolbar); - m_toolBars.push_back (toolbar); + m_toolBars << toolbar; g_CurrentToolBar = toolbar; } @@ -428,16 +428,16 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -vector parseQuickColorMeta () { - vector meta; +vector parseQuickColorMeta () { + vector meta; for (str colorname : gui_colortoolbar.value / ":") { if (colorname == "|") { - meta.push_back ({null, null, true}); + meta << quickColor ({null, null, true}); } else { color* col = getColor (atoi (colorname)); assert (col != null); - meta.push_back ({col, null, false}); + meta << quickColor ({col, null, false}); } } @@ -462,7 +462,7 @@ // Clear the toolbar to remove separators m_colorToolBar->clear (); - for (quickColorMetaEntry& entry : m_colorMeta) { + for (quickColor& entry : m_colorMeta) { if (entry.bSeparator) m_colorToolBar->addSeparator (); else { @@ -473,7 +473,7 @@ connect (colorButton, SIGNAL (clicked ()), this, SLOT (slot_quickColor ())); m_colorToolBar->addWidget (colorButton); - m_colorButtons.push_back (colorButton); + m_colorButtons << colorButton; entry.btn = colorButton; } @@ -552,7 +552,7 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -void ForgeWindow::deleteSelection (vector* ulapIndices, vector* papObjects) { +void ForgeWindow::deleteSelection (vector* indicesPtr, vector* objsPtr) { if (m_sel.size () == 0) return; @@ -560,9 +560,9 @@ // Delete the objects that were being selected for (LDObject* obj : selCopy) { - if (papObjects && ulapIndices) { - papObjects->push_back (obj->clone ()); - ulapIndices->push_back (obj->getIndex (g_curfile)); + if (objsPtr && indicesPtr) { + *objsPtr << obj->clone (); + *indicesPtr << obj->getIndex (g_curfile); } g_curfile->forgetObject (obj); @@ -735,7 +735,7 @@ for (LDObject* obj : g_curfile->objs ()) for (QListWidgetItem* item : items) { if (item == obj->qObjListEntry) { - m_sel.push_back (obj); + m_sel << obj; break; } } @@ -767,7 +767,7 @@ QToolButton* button = static_cast (sender ()); color* col = null; - for (quickColorMetaEntry entry : m_colorMeta) { + for (quickColor entry : m_colorMeta) { if (entry.btn == button) { col = entry.col; break; @@ -785,8 +785,8 @@ if (obj->color == -1) continue; // uncolored object - indices.push_back (obj->getIndex (g_curfile)); - colors.push_back (obj->color); + indices << obj->getIndex (g_curfile); + colors << obj->color; obj->color = newColor; } @@ -949,8 +949,8 @@ vector cache; for (LDObject* obj : objs) { - indices.push_back (obj->getIndex (g_curfile)); - cache.push_back (obj->clone ()); + indices << obj->getIndex (g_curfile); + cache << obj->clone (); g_curfile->forgetObject (obj); delete obj; @@ -974,7 +974,7 @@ if (!obj->isColored () || obj->color != colnum) continue; - objs.push_back (obj); + objs << obj; } return deleteObjVector (objs); diff -r c4b96bc41298 -r 3f9067022d74 src/gui.h --- a/src/gui.h Fri May 24 15:23:56 2013 +0300 +++ b/src/gui.h Fri May 24 15:38:23 2013 +0300 @@ -78,7 +78,7 @@ color* col; QToolButton* btn; bool bSeparator; -} quickColorMetaEntry; +} quickColor; // ============================================================================= // ObjectList @@ -125,7 +125,7 @@ DelHistory* deleteByColor (const short colnum); GLRenderer* R () { return m_renderer; } vector& sel () { return m_sel; } - void setQuickColorMeta (vector& quickColorMeta) { + void setQuickColorMeta (vector& quickColorMeta) { m_colorMeta = quickColorMeta; } void setStatusBarText (str text); @@ -147,7 +147,7 @@ QToolBar* m_colorToolBar; vector m_toolBars; vector m_sel; - vector m_colorMeta; + vector m_colorMeta; vector m_colorButtons; vector m_recentFiles; @@ -171,7 +171,7 @@ // ----------------------------------------------------------------------------- // Other GUI-related stuff not directly part of ForgeWindow: QPixmap getIcon (const char* sIconName); -vector parseQuickColorMeta (); +vector parseQuickColorMeta (); bool confirm (str title, str msg); bool confirm (str msg); void critical (str msg); diff -r c4b96bc41298 -r 3f9067022d74 src/gui_actions.cpp --- a/src/gui_actions.cpp Fri May 24 15:23:56 2013 +0300 +++ b/src/gui_actions.cpp Fri May 24 15:38:23 2013 +0300 @@ -208,7 +208,7 @@ g_win->sel ().clear (); for (LDObject* obj : g_curfile->objs ()) - g_win->sel ().push_back (obj); + g_win->sel () << obj; g_win->updateSelection (); } @@ -225,7 +225,7 @@ g_win->sel ().clear (); for (LDObject* obj : g_curfile->objs ()) if (obj->color == dColor) - g_win->sel ().push_back (obj); + g_win->sel () << obj; g_win->updateSelection (); } @@ -262,7 +262,7 @@ if (type == LDObject::Subfile && static_cast (obj)->fileName != refName) continue; - g_win->sel ().push_back (obj); + g_win->sel () << obj; } g_win->updateSelection (); @@ -317,10 +317,10 @@ g_win->sel ().clear (); for (LDObject* obj : objs) { - historyCopies.push_back (obj->clone ()); - historyIndices.push_back (idx); + historyCopies << obj->clone (); + historyIndices << idx; g_curfile->insertObj (idx, obj); - g_win->sel ().push_back (obj); + g_win->sel () << obj; idx++; } @@ -361,9 +361,9 @@ LDObject* obj = parseLine (line); g_curfile->insertObj (idx, obj); - historyIndices.push_back (idx); - historyCopies.push_back (obj->clone ()); - g_win->sel ().push_back (obj); + historyIndices << idx; + historyCopies << obj->clone (); + g_win->sel () << obj; idx++; } diff -r c4b96bc41298 -r 3f9067022d74 src/gui_editactions.cpp --- a/src/gui_editactions.cpp Fri May 24 15:23:56 2013 +0300 +++ b/src/gui_editactions.cpp Fri May 24 15:38:23 2013 +0300 @@ -57,7 +57,7 @@ // the clipboard. Thus, we add clones of the objects to the clipboard, not // the objects themselves. for (ulong i = 0; i < objs.size(); ++i) - g_Clipboard.push_back (objs[i]->clone ()); + g_Clipboard << objs[i]->clone (); return true; } @@ -94,12 +94,12 @@ g_win->sel ().clear (); for (LDObject* obj : g_Clipboard) { - historyIndices.push_back (idx); - historyCopies.push_back (obj->clone ()); + historyIndices << idx; + historyCopies << obj->clone (); LDObject* copy = obj->clone (); g_curfile->insertObj (idx++, copy); - g_win->sel ().push_back (copy); + g_win->sel () << copy; } History::addEntry (new AddHistory (historyIndices, historyCopies, AddHistory::Paste)); @@ -134,8 +134,8 @@ if (obj->getType() != LDObject::Subfile) continue; - refIndices.push_back (obj->getIndex (g_curfile)); - refs.push_back (static_cast (obj)->clone ()); + refIndices << obj->getIndex (g_curfile); + refs << static_cast (obj)->clone (); } for (LDObject* obj : sel) { @@ -156,7 +156,7 @@ // Merge in the inlined objects for (LDObject* inlineobj : objs) { - bitIndices.push_back (idx); + bitIndices << idx; // This object is now inlined so it has no parent anymore. inlineobj->parent = null; @@ -200,7 +200,7 @@ LDOpenFile* file = loadSubfile (name); if (file == null) { - fails.push_back (name); + fails << name; continue; } @@ -247,8 +247,8 @@ if (obj->getType() != LDObject::Quad) continue; - ulaIndices.push_back (obj->getIndex (g_curfile)); - paCopies.push_back (static_cast (obj)->clone ()); + ulaIndices << obj->getIndex (g_curfile); + paCopies << static_cast (obj)->clone (); } for (LDObject* obj : objs) { @@ -332,8 +332,8 @@ if (obj->isColored () == false) continue; - indices.push_back (obj->getIndex (g_curfile)); - colornums.push_back (obj->color); + indices << obj->getIndex (g_curfile); + colornums << obj->color; obj->color = colnum; g_win->R ()->compileObject (obj); @@ -382,8 +382,8 @@ lines[i]->color = edgecolor; g_curfile->insertObj (idx, lines[i]); - historyIndices.push_back (idx); - historyObjs.push_back (lines[i]->clone ()); + historyIndices << idx; + historyObjs << lines[i]->clone (); g_win->R ()->compileObject (lines[i]); } } @@ -412,8 +412,8 @@ vert->color = obj->color; g_curfile->insertObj (++idx, vert); - ulaIndices.push_back (idx); - paObjs.push_back (vert->clone ()); + ulaIndices << idx; + paObjs << vert->clone (); g_win->R ()->compileObject (vert); } } @@ -433,7 +433,7 @@ // Get the indices of the objects for history archival vector ulaIndices; for (LDObject* obj : objs) - ulaIndices.push_back (obj->getIndex (g_curfile)); + ulaIndices << obj->getIndex (g_curfile); LDObject::moveObjects (objs, bUp); History::addEntry (new ListMoveHistory (ulaIndices, bUp)); @@ -476,7 +476,7 @@ vVector[Z] *= currentGrid ().confs[Grid::Z]->value; for (LDObject* obj : g_win->sel ()) { - ulaIndices.push_back (obj->getIndex (g_curfile)); + ulaIndices << obj->getIndex (g_curfile); obj->move (vVector); g_win->R ()->compileObject (obj); } @@ -570,14 +570,14 @@ for (LDObject* obj : sel) { if (obj->vertices ()) for (short i = 0; i < obj->vertices (); ++i) - queue.push_back (&obj->coords[i]); + queue << &obj->coords[i]; else if (obj->hasMatrix ()) { LDMatrixObject* mobj = static_cast (obj); - queue.push_back (&mobj->pos); + queue << &mobj->pos; mobj->transform = mobj->transform * transform; } else if (obj->getType () == LDObject::Vertex) - queue.push_back (&static_cast (obj)->pos); + queue << &static_cast (obj)->pos; g_win->R ()->compileObject (obj); } @@ -645,11 +645,11 @@ if (obj->isColored () == false) continue; - indices.push_back (obj->getIndex (g_curfile)); - oldCopies.push_back (obj->clone ()); + indices << obj->getIndex (g_curfile); + oldCopies << obj->clone (); obj->color = (obj->getType () == LDObject::Line || obj->getType () == LDObject::CondLine) ? edgecolor : maincolor; - newCopies.push_back (obj->clone ()); + newCopies << obj->clone (); } if (indices.size () > 0) { @@ -811,8 +811,8 @@ if (obj->isColored () == false) continue; - indices.push_back (obj->getIndex (g_curfile)); - colors.push_back (obj->color); + indices << obj->getIndex (g_curfile); + colors << obj->color; obj->color = colnum; g_win->R ()->compileObject (obj); diff -r c4b96bc41298 -r 3f9067022d74 src/history.cpp --- a/src/history.cpp Fri May 24 15:23:56 2013 +0300 +++ b/src/history.cpp Fri May 24 15:38:23 2013 +0300 @@ -41,7 +41,7 @@ s_entries.erase (i); } - s_entries.push_back (entry); + s_entries << entry; s_pos++; updateActions (); @@ -175,9 +175,9 @@ } void EditHistory::addEntry (LDObject* const oldObj, LDObject* const newObj, const ulong idx) { - ulaIndices.push_back (idx); - paOldObjs.push_back (oldObj->clone ()); - paNewObjs.push_back (newObj->clone ()); + ulaIndices << idx; + paOldObjs << oldObj->clone (); + paNewObjs << newObj->clone (); } EditHistory::~EditHistory () { @@ -195,7 +195,7 @@ vector objs; for (ulong idx : ulaIndices) - objs.push_back (g_curfile->object (idx + ofs)); + objs << g_curfile->object (idx + ofs); return objs; } diff -r c4b96bc41298 -r 3f9067022d74 src/ldtypes.cpp --- a/src/ldtypes.cpp Fri May 24 15:23:56 2013 +0300 +++ b/src/ldtypes.cpp Fri May 24 15:38:23 2013 +0300 @@ -174,8 +174,8 @@ tri1->color = tri2->color = color; vector triangles; - triangles.push_back (tri1); - triangles.push_back (tri2); + triangles << tri1; + triangles << tri2; return triangles; } @@ -262,7 +262,7 @@ // If we have this cached, just clone that if (deep && fileInfo->cache ().size ()) { for (LDObject* obj : fileInfo->cache ()) - objs.push_back (obj->clone ()); + objs << obj->clone (); } else { if (!deep) cache = false; @@ -298,15 +298,15 @@ for (LDObject* otherobj : otherobjs) { // Cache this object, if desired if (cache) - objcache.push_back (otherobj->clone ()); + objcache << otherobj->clone (); - objs.push_back (otherobj); + objs << otherobj; } } else { if (cache) - objcache.push_back (obj->clone ()); + objcache << obj->clone (); - objs.push_back (obj->clone ()); + objs << obj->clone (); } } @@ -363,8 +363,8 @@ return; } - objsToCompile.push_back (obj); - objsToCompile.push_back (g_curfile->obj (target)); + objsToCompile << obj; + objsToCompile << g_curfile->obj (target); obj->swap (g_curfile->obj (target)); } @@ -538,7 +538,7 @@ pLine->color = edgecolor; pLine->parent = this; - paObjects.push_back (pLine); + paObjects << pLine; } break; @@ -596,7 +596,7 @@ pQuad->color = color; pQuad->parent = this; - paObjects.push_back (pQuad); + paObjects << pQuad; } break; @@ -629,7 +629,7 @@ pSeg->color = color; pSeg->parent = this; - paObjects.push_back (pSeg); + paObjects << pSeg; } break; diff -r c4b96bc41298 -r 3f9067022d74 src/widgets.cpp --- a/src/widgets.cpp Fri May 24 15:23:56 2013 +0300 +++ b/src/widgets.cpp Fri May 24 15:38:23 2013 +0300 @@ -66,7 +66,7 @@ void RadioBox::rowBreak () { QBoxLayout* newLayout = new QBoxLayout (m_vert ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight); m_currentLayout = newLayout; - m_layouts.push_back (newLayout); + m_layouts << newLayout; m_coreLayout->addLayout (newLayout); } @@ -79,7 +79,7 @@ void RadioBox::addButton (QRadioButton* button) { bool const selectThis = (m_curId == m_defId); - m_objects.push_back (button); + m_objects << button; m_buttonGroup->addButton (button, m_curId++); m_currentLayout->addWidget (button); @@ -159,7 +159,7 @@ for (const auto& kv : m_vals) if (kv.second->isChecked ()) - vals.push_back (kv.first); + vals << kv.first; return vals; }