Sat, 04 May 2013 19:14:16 +0300
Further tweaking
--- a/common.h Sat May 04 18:31:03 2013 +0300 +++ b/common.h Sat May 04 19:14:16 2013 +0300 @@ -33,9 +33,7 @@ #include "config.h" #include "types.h" -#define APPNAME "ldforge" -#define APPNAME_DISPLAY "LDForge" -#define APPNAME_CAPS "LDFORGE" +#define APPNAME "LDForge" #define VERSION_MAJOR 0 #define VERSION_MAJOR_STR "0" @@ -46,7 +44,7 @@ // #define RELEASE // Version string identifier -static const str versionString = format ("%d.%d", VERSION_MAJOR, VERSION_MINOR); +static const str versionString = fmt ("%d.%d", VERSION_MAJOR, VERSION_MINOR); #ifdef __GNUC__ # define FORMAT_PRINTF(M,N) __attribute__ ((format (printf, M, N))) @@ -77,6 +75,9 @@ static const short maincolor = 16; static const short edgecolor = 24; +static const bool yup = true; +static const bool nope = false; + class ForgeWindow; class LDObject; class bbox; @@ -143,6 +144,16 @@ // logf is defined in main.cpp void logf (const char* fmtstr, ...) FORMAT_PRINTF (1, 2); void logf (LogType type, const char* fmtstr, ...) FORMAT_PRINTF (2, 3); +void warnf (const char* fmtstr, ...) FORMAT_PRINTF (1, 2); +void infof (const char* fmtstr, ...) FORMAT_PRINTF (1, 2); +void succf (const char* fmtstr, ...) FORMAT_PRINTF (1, 2); +void errf (const char* fmtstr, ...) FORMAT_PRINTF (1, 2); + +#ifndef RELEASE +void devf (const char* fmtstr, ...); +#else +# define devf(...) +#endif // RELEASE // ----------------------------------------------------------------------------- // Vertex at (0, 0, 0)
--- a/config.cpp Sat May 04 18:31:03 2013 +0300 +++ b/config.cpp Sat May 04 19:14:16 2013 +0300 @@ -181,10 +181,10 @@ setlocale (LC_NUMERIC, "C"); // If the directory doesn't exist, create it now. - if (!QDir (dirpath().chars()).exists ()) { + if (QDir (dirpath ()).exists () == nope) { fprintf (stderr, "Creating config path %s...\n", dirpath().chars()); if (!QDir ().mkpath (dirpath().chars())) { - fprintf (stderr, "Failed to create the directory. Configuration cannot be saved!\n"); + logf (LOG_Warning, "Failed to create the directory. Configuration cannot be saved!\n"); return false; // Couldn't create directory } } @@ -264,14 +264,13 @@ // ============================================================================= str config::filepath () { str path; - path.format ("%s" CONFIGFILE, dirpath().chars()); + path.format ("%s%s.cfg", dirpath ().chars (), + str (APPNAME).tolower ().chars ()); return path; } // ============================================================================= str config::dirpath () { - str path = (QDir::homePath ().toStdString().c_str()); - path += "/." APPNAME "/"; - - return path; + return fmt ("%s/.%s/", qchars (QDir::homePath ()), + str (APPNAME).tolower ().chars ()); } \ No newline at end of file
--- a/config.h Sat May 04 18:31:03 2013 +0300 +++ b/config.h Sat May 04 19:14:16 2013 +0300 @@ -23,7 +23,6 @@ #include "str.h" // ============================================================================= -#define CONFIGFILE APPNAME ".cfg" #include <QString> #include <qkeysequence.h>
--- a/file.cpp Sat May 04 18:31:03 2013 +0300 +++ b/file.cpp Sat May 04 19:14:16 2013 +0300 @@ -76,7 +76,7 @@ if (~io_ldpath.value) { // Try with just the LDraw path first - zFilePath = format ("%s" DIRSLASH "%s", + zFilePath = fmt ("%s" DIRSLASH "%s", io_ldpath.value.chars(), zTruePath.chars()); logf ("Trying %s\n", zFilePath.chars()); @@ -91,7 +91,7 @@ }; for (char const* sSubdir : saSubdirectories) { - zFilePath = format ("%s" DIRSLASH "%s" DIRSLASH "%s", + zFilePath = fmt ("%s" DIRSLASH "%s" DIRSLASH "%s", io_ldpath.value.chars(), sSubdir, zTruePath.chars()); printf ("try %s\n", zFilePath.chars()); @@ -191,12 +191,12 @@ // If we have unsaved changes, warn and give the option of saving. if (!m_implicit && History::pos () != savePos) { switch (QMessageBox::question (g_win, "Unsaved Changes", - format ("There are unsaved changes to %s. Should it be saved?", m_filename.chars ()), + fmt ("There are unsaved changes to %s. Should it be saved?", m_filename.chars ()), (QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel), QMessageBox::Cancel)) { case QMessageBox::Yes: if (!save ()) { - str errormsg = format ("Failed to save %s: %s\nDo you still want to close?", + str errormsg = fmt ("Failed to save %s: %s\nDo you still want to close?", m_filename.chars (), strerror (lastError)); if (QMessageBox::critical (g_win, "Save Failure", errormsg, @@ -296,7 +296,7 @@ // Tell the user loading failed. setlocale (LC_ALL, "C"); QMessageBox::critical (g_win, "Load Failure", - format ("Failed to open %s\nReason: %s", zPath.chars(), strerror (errno)), + fmt ("Failed to open %s\nReason: %s", zPath.chars(), strerror (errno)), (QMessageBox::Close), QMessageBox::Close); return; @@ -333,7 +333,7 @@ // Write all entries now for (LDObject* obj : m_objs) { // LDraw requires lines to have DOS line endings - str zLine = format ("%s\r\n", obj->getContents ().chars ()); + str zLine = fmt ("%s\r\n", obj->getContents ().chars ()); fwrite (zLine.chars(), 1, ~zLine, fp); } @@ -355,7 +355,7 @@ #define CHECK_TOKEN_NUMBERS(MIN,MAX) \ for (ushort i = MIN; i <= MAX; ++i) \ if (!isNumber (tokens[i])) \ - return new LDGibberish (zLine, format ("Token #%u was `%s`, expected a number", \ + return new LDGibberish (zLine, fmt ("Token #%u was `%s`, expected a number", \ (i + 1), tokens[i].chars())); // ============================================================================= @@ -393,24 +393,24 @@ case 0: { // Comment - str zComment; + str comm; for (uint i = 1; i < tokens.size(); ++i) { - zComment += tokens[i]; + comm += tokens[i]; if (i != tokens.size() - 1) - zComment += ' '; + comm += ' '; } // Handle BFC statements if (tokens.size() > 2 && tokens[1] == "BFC") { for (short i = 0; i < LDBFC::NumStatements; ++i) - if (zComment == format ("BFC %s", LDBFC::saStatements [i])) + if (comm == fmt ("BFC %s", LDBFC::saStatements [i])) return new LDBFC ((LDBFC::Type) i); // MLCAD is notorious for stuffing these statements in parts it // creates. The above block only handles valid statements, so we // need to handle MLCAD-style invertnext separately. - if (zComment == "BFC CERTIFY INVERTNEXT") + if (comm == "BFC CERTIFY INVERTNEXT") return new LDBFC (LDBFC::InvertNext); } @@ -445,7 +445,7 @@ } if (eType == LDRadial::NumTypes) - return new LDGibberish (zLine, format ("Unknown radial type %s", tokens[3].chars ())); + return new LDGibberish (zLine, fmt ("Unknown radial type %s", tokens[3].chars ())); LDRadial* obj = new LDRadial; @@ -465,7 +465,7 @@ } LDComment* obj = new LDComment; - obj->zText = zComment; + obj->zText = comm; return obj; }
--- a/gui.cpp Sat May 04 18:31:03 2013 +0300 +++ b/gui.cpp Sat May 04 19:14:16 2013 +0300 @@ -469,7 +469,7 @@ else { QPushButton* qColorButton = new QPushButton; qColorButton->setAutoFillBackground (true); - qColorButton->setStyleSheet (format ("background-color: %s", entry.col->zColorString.chars())); + qColorButton->setStyleSheet (fmt ("background-color: %s", entry.col->zColorString.chars())); qColorButton->setToolTip (entry.col->zName); connect (qColorButton, SIGNAL (clicked ()), this, SLOT (slot_quickColor ())); @@ -497,19 +497,19 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void ForgeWindow::setTitle () { - str title = APPNAME_DISPLAY " v"; + str title = APPNAME " v"; title += versionString; // Append our current file if we have one if (g_curfile) { - title += format (": %s", basename (g_curfile->m_filename.chars())); + title += fmt (": %s", basename (g_curfile->m_filename.chars())); if (g_curfile->m_objs.size() > 0 && g_curfile->m_objs[0]->getType() == OBJ_Comment) { // Append title LDComment* comm = static_cast<LDComment*> (g_curfile->m_objs[0]); - title += format (": %s", comm->zText.chars()); + title += fmt (": %s", comm->zText.chars()); } if (History::pos () != g_curfile->savePos) @@ -948,7 +948,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= QPixmap getIcon (const char* sIconName) { - return (QPixmap (format (":/icons/%s.png", sIconName))); + return (QPixmap (fmt (":/icons/%s.png", sIconName))); } // ============================================================================= @@ -963,7 +963,7 @@ // ============================================================================= void critical (str msg) { - QMessageBox::critical (g_win, APPNAME_DISPLAY ": Critical Error", msg, + QMessageBox::critical (g_win, APPNAME ": Critical Error", msg, (QMessageBox::Close), QMessageBox::Close); }
--- a/gui.h Sat May 04 18:31:03 2013 +0300 +++ b/gui.h Sat May 04 19:14:16 2013 +0300 @@ -145,6 +145,11 @@ friend void logf (const char* fmt, ...); friend void logf (LogType eType, const char* fmt, ...); + friend void warnf (const char* fmt, ...); + friend void infof (const char* fmt, ...); + friend void succf (const char* fmt, ...); + friend void errf (const char* fmt, ...); + friend void devf (const char* fmt, ...); private: GLRenderer* m_renderer;
--- a/gui_actions.cpp Sat May 04 18:31:03 2013 +0300 +++ b/gui_actions.cpp Sat May 04 19:14:16 2013 +0300 @@ -73,7 +73,7 @@ // Tell the user the save failed, and give the option for saving as with it. QMessageBox dlg (QMessageBox::Critical, "Save Failure", - format ("Failed to save to %s\nReason: %s", path.chars(), strerror (g_curfile->lastError)), + fmt ("Failed to save to %s\nReason: %s", path.chars(), strerror (g_curfile->lastError)), QMessageBox::Close, g_win); QPushButton* saveAsBtn = new QPushButton ("Save As"); @@ -104,14 +104,14 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -MAKE_ACTION (settings, "Settin&gs", "settings", "Edit the settings of " APPNAME_DISPLAY ".", (0)) { +MAKE_ACTION (settings, "Settin&gs", "settings", "Edit the settings of " APPNAME ".", (0)) { ConfigDialog::staticDialog (); } // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".", CTRL (Q)) { +MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME ".", CTRL (Q)) { exit (0); } @@ -162,15 +162,15 @@ AddObjectDialog::staticDialog (obj->getType (), obj); } -MAKE_ACTION (help, "Help", "help", "Shows the " APPNAME_DISPLAY " help manual.", KEY (F1)) { +MAKE_ACTION (help, "Help", "help", "Shows the " APPNAME " help manual.", KEY (F1)) { } // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -MAKE_ACTION (about, "About " APPNAME_DISPLAY, "ldforge", - "Shows information about " APPNAME_DISPLAY ".", CTRL (F1)) +MAKE_ACTION (about, "About " APPNAME, "ldforge", + "Shows information about " APPNAME ".", CTRL (F1)) { AboutDialog dlg; dlg.exec (); @@ -285,7 +285,7 @@ FILE* fp = fopen (fname, "r"); if (!fp) { - critical (format ("Couldn't open %s\n%s", fname.chars(), strerror (errno))); + critical (fmt ("Couldn't open %s\n%s", fname.chars(), strerror (errno))); return; } @@ -327,7 +327,7 @@ layout->addWidget (te_edit); layout->addWidget (bbx_buttons); dlg->setLayout (layout); - dlg->setWindowTitle (APPNAME_DISPLAY ": Insert Raw"); + dlg->setWindowTitle (APPNAME ": Insert Raw"); dlg->connect (bbx_buttons, SIGNAL (accepted ()), dlg, SLOT (accept ())); dlg->connect (bbx_buttons, SIGNAL (rejected ()), dlg, SLOT (reject ())); @@ -369,12 +369,12 @@ if (root.substr (~root - 4, -1) == ".dat") root -= 4; - str defaultname = (~root > 0) ? format ("%s.png", root.chars ()) : ""; + str defaultname = (~root > 0) ? fmt ("%s.png", root.chars ()) : ""; str fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); if (~fname > 0 && !img.save (fname)) - critical (format ("Couldn't open %s for writing to save screencap: %s", fname.chars(), strerror (errno))); + critical (fmt ("Couldn't open %s for writing to save screencap: %s", fname.chars(), strerror (errno))); delete[] imagedata; }
--- a/gui_editactions.cpp Sat May 04 18:31:03 2013 +0300 +++ b/gui_editactions.cpp Sat May 04 19:14:16 2013 +0300 @@ -653,7 +653,7 @@ for (LDObject* obj : g_win->sel ()) for (short i = 0; i < obj->vertices (); ++i) for (const Axis ax : g_Axes) - obj->vaCoords[i][ax] = atof (format ("%.3f", obj->vaCoords[i][ax])); + obj->vaCoords[i][ax] = atof (fmt ("%.3f", obj->vaCoords[i][ax])); g_win->refresh (); }
--- a/ldtypes.cpp Sat May 04 18:31:03 2013 +0300 +++ b/ldtypes.cpp Sat May 04 19:14:16 2013 +0300 @@ -110,11 +110,11 @@ // ============================================================================= str LDComment::getContents () { - return format ("0 %s", zText.chars ()); + return fmt ("0 %s", zText.chars ()); } str LDSubfile::getContents () { - str val = format ("1 %d %s ", dColor, vPosition.stringRep (false).chars ()); + str val = fmt ("1 %d %s ", dColor, vPosition.stringRep (false).chars ()); val += mMatrix.stringRep (); val += ' '; val += zFileName; @@ -122,7 +122,7 @@ } str LDLine::getContents () { - str val = format ("2 %d", dColor); + str val = fmt ("2 %d", dColor); for (ushort i = 0; i < 2; ++i) val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); @@ -131,7 +131,7 @@ } str LDTriangle::getContents () { - str val = format ("3 %d", dColor); + str val = fmt ("3 %d", dColor); for (ushort i = 0; i < 3; ++i) val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); @@ -140,7 +140,7 @@ } str LDQuad::getContents () { - str val = format ("4 %d", dColor); + str val = fmt ("4 %d", dColor); for (ushort i = 0; i < 4; ++i) val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); @@ -149,7 +149,7 @@ } str LDCondLine::getContents () { - str val = format ("5 %d", dColor); + str val = fmt ("5 %d", dColor); // Add the coordinates for (ushort i = 0; i < 4; ++i) @@ -163,7 +163,7 @@ } str LDVertex::getContents () { - return format ("0 !LDFORGE VERTEX %d %s", dColor, vPosition.stringRep (false).chars()); + return fmt ("0 !LDFORGE VERTEX %d %s", dColor, vPosition.stringRep (false).chars()); } str LDEmpty::getContents () { @@ -183,7 +183,7 @@ }; str LDBFC::getContents () { - return format ("0 BFC %s", LDBFC::saStatements[eStatement]); + return fmt ("0 BFC %s", LDBFC::saStatements[eStatement]); } // ============================================================================= @@ -431,7 +431,7 @@ if (!firstDetails) text += ", "; - str noun = format ("%s%s", g_saObjTypeNames[objType], PLURAL (objCount)); + str noun = fmt ("%s%s", g_saObjTypeNames[objType], PLURAL (objCount)); // Plural of "vertex" is "vertices". Stupid English. if (objType == OBJ_Vertex && objCount != 1) @@ -660,7 +660,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= str LDRadial::getContents () { - return format ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", + return fmt ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", str (radialTypeName()).toupper ().strip (' ').chars (), dColor, dSegments, dDivisions, dRingNum, vPosition.stringRep (false).chars(), mMatrix.stringRep().chars()); @@ -694,10 +694,10 @@ } // Compose some general information: prefix, fraction, root, ring number - str zPrefix = (dDivisions == 16) ? "" : format ("%d/", dDivisions); - str zFrac = format ("%d-%d", dNumerator, dDenominator); + str zPrefix = (dDivisions == 16) ? "" : fmt ("%d/", dDivisions); + str zFrac = fmt ("%d-%d", dNumerator, dDenominator); str zRoot = g_saRadialNameRoots[eRadialType]; - str zRingNum = (eRadialType == Ring || eRadialType == Cone) ? format ("%d", dRingNum) : ""; + str zRingNum = (eRadialType == Ring || eRadialType == Cone) ? fmt ("%d", dRingNum) : ""; // Truncate the root if necessary (7-16rin4.dat for instance). // However, always keep the root at least 2 characters. @@ -705,7 +705,7 @@ zRoot -= min<short> (max<short> (dExtra, 0), 2); // Stick them all together and return the result. - return format ("%s%s%s%s", zPrefix.chars(), zFrac.chars (), zRoot.chars (), zRingNum.chars ()); + return fmt ("%s%s%s%s", zPrefix.chars(), zFrac.chars (), zRoot.chars (), zRingNum.chars ()); } // =============================================================================
--- a/main.cpp Sat May 04 18:31:03 2013 +0300 +++ b/main.cpp Sat May 04 19:14:16 2013 +0300 @@ -66,7 +66,6 @@ // ============================================================================= void logf (const char* fmtstr, ...) { va_list va; - va_start (va, fmtstr); g_win->logVA (LOG_Normal, fmtstr, va); va_end (va); @@ -74,8 +73,44 @@ void logf (LogType type, const char* fmtstr, ...) { va_list va; - va_start (va, fmtstr); g_win->logVA (type, fmtstr, va); va_end (va); } + +void warnf (const char* fmtstr, ...) { + va_list va; + va_start (va, fmtstr); + g_win->logVA (LOG_Warning, fmtstr, va); + va_end (va); +} + +void succf (const char* fmtstr, ...) { + va_list va; + va_start (va, fmtstr); + g_win->logVA (LOG_Success, fmtstr, va); + va_end (va); +} + +void errf (const char* fmtstr, ...) { + va_list va; + va_start (va, fmtstr); + g_win->logVA (LOG_Error, fmtstr, va); + va_end (va); +} + +void infof (const char* fmtstr, ...) { + va_list va; + va_start (va, fmtstr); + g_win->logVA (LOG_Info, fmtstr, va); + va_end (va); +} + +#ifndef RELEASE +void devf (const char* fmtstr, ...) { + va_list va; + va_start (va, fmtstr); + g_win->logVA (LOG_Dev, fmtstr, va); + va_end (va); +} +#endif // RELEASE \ No newline at end of file
--- a/misc.cpp Sat May 04 18:31:03 2013 +0300 +++ b/misc.cpp Sat May 04 19:14:16 2013 +0300 @@ -130,7 +130,7 @@ // turn into anything weird (like commas) setlocale (LC_NUMERIC, "C"); - str zRep = format ("%f", fCoord); + str zRep = fmt ("%f", fCoord); // Remove trailing zeroes while (zRep[~zRep - 1] == '0')
--- a/str.cpp Sat May 04 18:31:03 2013 +0300 +++ b/str.cpp Sat May 04 19:14:16 2013 +0300 @@ -157,19 +157,6 @@ delete[] buf; } -str str::format (...) { - va_list va; - char* buf; - - va_start (va, this); - buf = vdynformat (text, va, 256); - va_end (va); - - str val = buf; - delete[] buf; - return val; -} - // ============================================================================ char* str::chars () { return text; @@ -502,7 +489,7 @@ return *this; } -str format (const char* fmt, ...) { +str fmt (const char* fmt, ...) { va_list va; char* buf;
--- a/str.h Sat May 04 18:31:03 2013 +0300 +++ b/str.h Sat May 04 19:14:16 2013 +0300 @@ -78,7 +78,6 @@ // Formats text to the string. void format (const char* fmt, ...); - str format (...); // Appends formatted text to the string. void appendformat (const char* c, ...); @@ -267,6 +266,6 @@ } }; -str format (const char* fmt, ...); +str fmt (const char* fmt, ...); #endif // STR_H
--- a/types.cpp Sat May 04 18:31:03 2013 +0300 +++ b/types.cpp Sat May 04 19:14:16 2013 +0300 @@ -19,7 +19,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= str vertex::stringRep (const bool mangled) { - return format (mangled ? "(%s, %s, %s)" : "%s %s %s", + return fmt (mangled ? "(%s, %s, %s)" : "%s %s %s", ftoa (coord (X)).chars(), ftoa (coord (Y)).chars(), ftoa (coord (Z)).chars());
--- a/zz_aboutDialog.cpp Sat May 04 18:31:03 2013 +0300 +++ b/zz_aboutDialog.cpp Sat May 04 19:14:16 2013 +0300 @@ -37,7 +37,7 @@ icon->setPixmap (getIcon ("ldforge")); // Heading - application label and copyright information - QLabel* title = new QLabel (format ("<b>" APPNAME_DISPLAY " v%d.%d</b><br />" + QLabel* title = new QLabel (fmt ("<b>" APPNAME " v%d.%d</b><br />" "Copyright (C) 2013 Santeri Piippo", VERSION_MAJOR, VERSION_MINOR)); @@ -46,7 +46,7 @@ "<p>This software is intended for usage as a parts<br />" "authoring tool for the <a href=\"http://ldraw.org/\">LDraw</a> parts library.</p>" - "<p>" APPNAME_DISPLAY " is free software, and you are welcome<br />" + "<p>" APPNAME " is free software, and you are welcome<br />" "to redistribute it under the terms of GPL v3. See the LICENSE<br />" "text file or the license tab in this dialog for details. If the<br />" "license text is not available for some reason, see<br />" @@ -71,7 +71,7 @@ label->setAlignment (Qt::AlignCenter); mainTab->setLayout (layout); - tabs->addTab (mainTab, "About " APPNAME_DISPLAY); + tabs->addTab (mainTab, "About " APPNAME); } { @@ -96,10 +96,10 @@ if (fp == null) { // Failed; tell the user how to get the license text instead. setlocale (LC_ALL, "C"); - char const* fmt = "Couldn't open LICENSE: %s.<br />" + char const* text = "Couldn't open LICENSE: %s.<br />" "See <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a> for the GPLv3 text."; - license->setHtml (format (fmt, strerror (errno))); + license->setHtml (fmt (text, strerror (errno))); } else { // Figure out file size fseek (fp, 0, SEEK_END); @@ -148,7 +148,7 @@ layout->addWidget (tabs); layout->addWidget (buttons); setLayout (layout); - setWindowTitle ("About " APPNAME_DISPLAY); + setWindowTitle ("About " APPNAME); } void AboutDialog::slot_mail () {
--- a/zz_addObjectDialog.cpp Sat May 04 18:31:03 2013 +0300 +++ b/zz_addObjectDialog.cpp Sat May 04 19:14:16 2013 +0300 @@ -49,7 +49,7 @@ QDialog (parent) { short coordCount = 0; - QPixmap icon = getIcon (format ("add-%s", g_saObjTypeIcons[type])); + QPixmap icon = getIcon (fmt ("add-%s", g_saObjTypeIcons[type])); LDObject* defaults = LDObject::getDefault (type); lb_typeIcon = new QLabel; @@ -126,7 +126,7 @@ (i == Parts && !isSubpart && !isPrimitive && !isHiRes)) { SubfileListItem* item = new SubfileListItem (parentItem, j); - item->setText (0, format ("%s - %s", part.sName, part.sTitle)); + item->setText (0, fmt ("%s - %s", part.sName, part.sTitle)); subfileItems.append (item); } @@ -271,7 +271,7 @@ layout->addWidget (bbx_buttons, 5, 0, 1, 4); setLayout (layout); - setWindowTitle (format (APPNAME_DISPLAY ": New %s", + setWindowTitle (fmt (APPNAME ": New %s", g_saObjTypeNames[type]).chars()); setWindowIcon (icon); @@ -285,7 +285,7 @@ button->setIcon (getIcon ("palette")); button->setAutoFillBackground (true); button->setStyleSheet ( - format ("background-color: %s", getColor (color)->zColorString.chars()).chars() + fmt ("background-color: %s", getColor (color)->zColorString.chars()).chars() ); }
--- a/zz_colorSelectDialog.cpp Sat May 04 18:31:03 2013 +0300 +++ b/zz_colorSelectDialog.cpp Sat May 04 19:14:16 2013 +0300 @@ -87,7 +87,7 @@ setLayout (qLayout); setWindowIcon (getIcon ("palette")); - setWindowTitle (APPNAME_DISPLAY); + setWindowTitle (APPNAME); } // ============================================================================= @@ -119,7 +119,7 @@ bool dark = (luma (col) < 80); gs_scene->addRect (x, y, w, w, qPen, col); - QGraphicsTextItem* qText = gs_scene->addText (format ("%lu", i).chars()); + QGraphicsTextItem* qText = gs_scene->addText (fmt ("%lu", i).chars()); qText->setDefaultTextColor ((dark) ? Qt::white : Qt::black); qText->setPos (x, y); @@ -141,7 +141,7 @@ return; } - lb_colorInfo->setText (format ("%d - %s", + lb_colorInfo->setText (fmt ("%d - %s", selColor, col->zName.chars())); }
--- a/zz_configDialog.cpp Sat May 04 18:31:03 2013 +0300 +++ b/zz_configDialog.cpp Sat May 04 19:14:16 2013 +0300 @@ -69,7 +69,7 @@ layout->addWidget (bbx_buttons); setLayout (layout); - setWindowTitle (APPNAME_DISPLAY " - Settings"); + setWindowTitle (APPNAME " - Settings"); setWindowIcon (getIcon ("settings")); } @@ -286,10 +286,10 @@ for (int i = 0; i < g_NumGrids; ++i) { // Icon lb_gridIcons[i] = new QLabel; - lb_gridIcons[i]->setPixmap (getIcon (format ("grid-%s", str (g_GridInfo[i].name).tolower ().chars ()))); + lb_gridIcons[i]->setPixmap (getIcon (fmt ("grid-%s", str (g_GridInfo[i].name).tolower ().chars ()))); // Text label - lb_gridLabels[i] = new QLabel (format ("%s:", g_GridInfo[i].name)); + lb_gridLabels[i] = new QLabel (fmt ("%s:", g_GridInfo[i].name)); QHBoxLayout* labellayout = new QHBoxLayout; labellayout->addWidget (lb_gridIcons[i]); @@ -504,7 +504,7 @@ qButton->setIcon (getIcon ("colorselect")); qButton->setAutoFillBackground (true); qButton->setStyleSheet ( - format ("background-color: %s", zValue.chars()).chars() + fmt ("background-color: %s", zValue.chars()).chars() ); } @@ -587,7 +587,7 @@ str zLabel = qAct->iconText (); str zKeybind = qAct->shortcut ().toString (); - qItem->setText (format ("%s (%s)", zLabel.chars () ,zKeybind.chars ()).chars()); + qItem->setText (fmt ("%s (%s)", zLabel.chars () ,zKeybind.chars ()).chars()); } // ============================================================================= @@ -694,7 +694,7 @@ void KeySequenceDialog::updateOutput () { str zShortcut = seq.toString (); - str zText = format ("<center><b>%s</b></center>", zShortcut.chars ()); + str zText = fmt ("<center><b>%s</b></center>", zShortcut.chars ()); lb_output->setText (zText); }
--- a/zz_historyDialog.cpp Sat May 04 18:31:03 2013 +0300 +++ b/zz_historyDialog.cpp Sat May 04 19:14:16 2013 +0300 @@ -61,7 +61,7 @@ setLayout (qLayout); setWindowIcon (getIcon ("history")); - setWindowTitle (APPNAME_DISPLAY " - Edit history"); + setWindowTitle (APPNAME " - Edit history"); populateList (); updateButtons (); @@ -80,20 +80,20 @@ historyList->addItem (qItem); for (HistoryEntry* entry : History::entries ()) { - str zText; - QIcon qEntryIcon; + str text; + QIcon entryIcon; switch (entry->type ()) { case HISTORY_Add: { - AddHistory* addentry = static_cast<AddHistory*> (entry); - ulong ulCount = addentry->paObjs.size (); - str zVerb = "Added"; + AddHistory* subentry = static_cast<AddHistory*> (entry); + ulong count = subentry->paObjs.size (); + str verb = "Added"; - switch (addentry->eType) { + switch (subentry->eType) { case AddHistory::Paste: - zVerb = "Pasted"; - qEntryIcon = getIcon ("paste"); + verb = "Pasted"; + entryIcon = getIcon ("paste"); break; default: @@ -102,7 +102,7 @@ // type, we display its addition icon. Otherwise, we draw a subfile addition // one as a default. LDObjectType_e eCommonType = OBJ_Unidentified; - for (LDObject* obj : addentry->paObjs) { + for (LDObject* obj : subentry->paObjs) { if (eCommonType == OBJ_Unidentified or obj->getType() == eCommonType) eCommonType = obj->getType (); else { @@ -113,80 +113,80 @@ // Set the icon based on the common type decided above. if (eCommonType == OBJ_Unidentified) - qEntryIcon = getIcon ("add-subfile"); + entryIcon = getIcon ("add-subfile"); else - qEntryIcon = getIcon (format ("add-%s", g_saObjTypeIcons[eCommonType])); + entryIcon = getIcon (fmt ("add-%s", g_saObjTypeIcons[eCommonType])); } break; } - zText.format ("%s %lu objects\n%s", zVerb.chars(), ulCount, - LDObject::objectListContents (addentry->paObjs).chars()); + text.format ("%s %lu objects\n%s", verb.chars(), count, + LDObject::objectListContents (subentry->paObjs).chars()); } break; case HISTORY_QuadSplit: { - QuadSplitHistory* splitentry = static_cast<QuadSplitHistory*> (entry); - ulong ulCount = splitentry->paQuads.size (); - zText.format ("Split %lu quad%s to triangles", ulCount, PLURAL (ulCount)); + QuadSplitHistory* subentry = static_cast<QuadSplitHistory*> (entry); + ulong ulCount = subentry->paQuads.size (); + text.format ("Split %lu quad%s to triangles", ulCount, PLURAL (ulCount)); - qEntryIcon = getIcon ("quad-split"); + entryIcon = getIcon ("quad-split"); } break; case HISTORY_Del: { - DelHistory* delentry = static_cast<DelHistory*> (entry); - ulong ulCount = delentry->cache.size (); - str zVerb = "Deleted"; - qEntryIcon = getIcon ("delete"); + DelHistory* subentry = static_cast<DelHistory*> (entry); + ulong count = subentry->cache.size (); + str verb = "Deleted"; + entryIcon = getIcon ("delete"); - switch (delentry->eType) { + switch (subentry->eType) { case DelHistory::Cut: - qEntryIcon = getIcon ("cut"); - zVerb = "Cut"; + entryIcon = getIcon ("cut"); + verb = "Cut"; break; default: break; } - zText.format ("%s %lu objects:\n%s", zVerb.chars(), ulCount, - LDObject::objectListContents (delentry->cache).chars ()); + text.format ("%s %lu objects:\n%s", verb.chars(), count, + LDObject::objectListContents (subentry->cache).chars ()); } break; case HISTORY_SetColor: { - SetColorHistory* colentry = static_cast<SetColorHistory*> (entry); - ulong ulCount = colentry->ulaIndices.size (); - zText.format ("Set color of %lu objects to %d (%s)", ulCount, - colentry->dNewColor, getColor (colentry->dNewColor)->zName.chars()); + SetColorHistory* subentry = static_cast<SetColorHistory*> (entry); + ulong count = subentry->ulaIndices.size (); + text.format ("Set color of %lu objects to %d (%s)", count, + subentry->dNewColor, getColor (subentry->dNewColor)->zName.chars()); - qEntryIcon = getIcon ("palette"); + entryIcon = getIcon ("palette"); } break; case HISTORY_ListMove: { - ListMoveHistory* moveentry = static_cast<ListMoveHistory*> (entry); - ulong ulCount = moveentry->ulaIndices.size (); + ListMoveHistory* subentry = static_cast<ListMoveHistory*> (entry); + ulong ulCount = subentry->ulaIndices.size (); - zText.format ("Moved %lu objects %s", ulCount, - moveentry->bUp ? "up" : "down"); - qEntryIcon = getIcon (moveentry->bUp ? "arrow-up" : "arrow-down"); + text.format ("Moved %lu objects %s", ulCount, + subentry->bUp ? "up" : "down"); + entryIcon = getIcon (subentry->bUp ? "arrow-up" : "arrow-down"); } break; case HISTORY_Edit: { - EditHistory* pEntry = static_cast<EditHistory*> (entry); + EditHistory* subentry = static_cast<EditHistory*> (entry); - zText.format ("Edited %u objects\n%s", - pEntry->paNewObjs.size(), - LDObject::objectListContents (pEntry->paOldObjs).chars ()); - qEntryIcon = getIcon ("set-contents"); + text.format ("Edited %u objects\n%s", + subentry->paNewObjs.size(), + LDObject::objectListContents (subentry->paOldObjs).chars ()); + entryIcon = getIcon ("set-contents"); } break; @@ -194,24 +194,24 @@ { InlineHistory* subentry = static_cast<InlineHistory*> (entry); - zText.format ("%s %lu subfiles:\n%lu resultants", + text.format ("%s %lu subfiles:\n%lu resultants", (subentry->bDeep) ? "Deep-inlined" : "Inlined", (ulong) subentry->paRefs.size(), (ulong) subentry->ulaBitIndices.size()); - qEntryIcon = getIcon (subentry->bDeep ? "inline-deep" : "inline"); + entryIcon = getIcon (subentry->bDeep ? "inline-deep" : "inline"); } break; default: - zText = "???"; + text = "???"; break; } - QListWidgetItem* qItem = new QListWidgetItem; - qItem->setText (zText); - qItem->setIcon (qEntryIcon); - historyList->addItem (qItem); + QListWidgetItem* item = new QListWidgetItem; + item->setText (text); + item->setIcon (entryIcon); + historyList->addItem (item); } }
--- a/zz_newPartDialog.cpp Sat May 04 18:31:03 2013 +0300 +++ b/zz_newPartDialog.cpp Sat May 04 19:14:16 2013 +0300 @@ -77,7 +77,7 @@ setLayout (layout); setWindowIcon (getIcon ("brick")); - setWindowTitle (APPNAME_DISPLAY ": New Part"); + setWindowTitle (APPNAME ": New Part"); } // ============================================================================= @@ -106,11 +106,11 @@ objs.push_back (new LDComment (dlg.le_name->text ())); objs.push_back (new LDComment ("Name: <untitled>.dat")); - objs.push_back (new LDComment (format ("Author: %s", zAuthor.chars()))); - objs.push_back (new LDComment (format ("!LDRAW_ORG Unofficial_Part"))); + objs.push_back (new LDComment (fmt ("Author: %s", zAuthor.chars()))); + objs.push_back (new LDComment (fmt ("!LDRAW_ORG Unofficial_Part"))); if (sLicense != null) - objs.push_back (new LDComment (format ("!LICENSE %s", sLicense))); + objs.push_back (new LDComment (fmt ("!LICENSE %s", sLicense))); objs.push_back (new LDEmpty); objs.push_back (new LDBFC (eBFCType));
--- a/zz_setContentsDialog.cpp Sat May 04 18:31:03 2013 +0300 +++ b/zz_setContentsDialog.cpp Sat May 04 19:14:16 2013 +0300 @@ -27,7 +27,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= SetContentsDialog::SetContentsDialog (LDObject* obj, QWidget* parent) : QDialog(parent) { - setWindowTitle (APPNAME_DISPLAY ": Set Contents"); + setWindowTitle (APPNAME ": Set Contents"); lb_contents = new QLabel ("Set contents:", parent); @@ -42,7 +42,7 @@ if (obj->getType() == OBJ_Gibberish) { lb_error = new QLabel; - lb_error->setText (format ("<span style=\"color: #900\">%s</span>", + lb_error->setText (fmt ("<span style=\"color: #900\">%s</span>", static_cast<LDGibberish*> (obj)->zReason.chars())); QPixmap qErrorPixmap = getIcon ("error").scaledToHeight (16); @@ -68,7 +68,7 @@ layout->addLayout (layout2); setLayout (layout); - setWindowTitle (APPNAME_DISPLAY ": Set Contents"); + setWindowTitle (APPNAME ": Set Contents"); setWindowIcon (getIcon ("set-contents")); }