# HG changeset patch # User Santeri Piippo # Date 1389090106 -7200 # Node ID 3dd6f343ec06eaa951a254dbb45c735709d025a8 # Parent 2983f7c7e7c9dcad8530ce0fd44fcca1d7b221f7 - removed the 'str' typedef, use QString directly diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/addObjectDialog.cc --- a/src/addObjectDialog.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/addObjectDialog.cc Tue Jan 07 12:21:46 2014 +0200 @@ -60,7 +60,7 @@ setlocale (LC_ALL, "C"); int coordCount = 0; - str typeName = LDObject::typeName (type); + QString typeName = LDObject::typeName (type); switch (type) { @@ -283,7 +283,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str AddObjectDialog::currentSubfileName() +QString AddObjectDialog::currentSubfileName() { SubfileListItem* item = static_cast (tw_subfileList->currentItem()); @@ -305,7 +305,7 @@ // ----------------------------------------------------------------------------- void AddObjectDialog::slot_subfileTypeChanged() { - str name = currentSubfileName(); + QString name = currentSubfileName(); if (name.length() > 0) le_subfileName->setText (name); @@ -352,7 +352,7 @@ double matrixvals[9]; int i = 0; - for (str val : matrixstrvals) + for (QString val : matrixstrvals) matrixvals[i++] = val.toFloat(); transform = Matrix (matrixvals); @@ -404,7 +404,7 @@ case LDObject::ESubfile: { - str name = dlg.le_subfileName->text(); + QString name = dlg.le_subfileName->text(); if (name.length() == 0) return; // no subfile filename diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/addObjectDialog.h --- a/src/addObjectDialog.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/addObjectDialog.h Tue Jan 07 12:21:46 2014 +0200 @@ -61,7 +61,7 @@ private: void setButtonBackground (QPushButton* button, int color); - str currentSubfileName(); + QString currentSubfileName(); int colnum; diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/colors.h --- a/src/colors.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/colors.h Tue Jan 07 12:21:46 2014 +0200 @@ -27,7 +27,7 @@ class LDColor { public: - str name, hexcode; + QString name, hexcode; QColor faceColor, edgeColor; int index; }; diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/config.cc --- a/src/config.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/config.cc Tue Jan 07 12:21:46 2014 +0200 @@ -40,7 +40,7 @@ Config* g_configPointers[MAX_CONFIG]; static int g_cfgPointerCursor = 0; -static QMap g_configsByName; +static QMap g_configsByName; static QList g_configs; // ============================================================================= @@ -51,7 +51,7 @@ return new QSettings (UNIXNAME EXTENSION, QSettings::IniFormat); } -Config::Config (str name) : +Config::Config (QString name) : m_Name (name) {} // ============================================================================= @@ -110,7 +110,7 @@ // ============================================================================= // Where is the configuration file located at? // ----------------------------------------------------------------------------- -str Config::filepath (str file) +QString Config::filepath (QString file) { return Config::dirpath() + DIRSLASH + file; } @@ -118,7 +118,7 @@ // ============================================================================= // Directory of the configuration file. // ----------------------------------------------------------------------------- -str Config::dirpath() +QString Config::dirpath() { QSettings* cfg = getSettingsObject(); return dirname (cfg->fileName()); @@ -140,7 +140,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -template T* getConfigByName (str name, Config::Type type) +template T* getConfigByName (QString name, Config::Type type) { auto it = g_configsByName.find (name); @@ -162,7 +162,7 @@ // ----------------------------------------------------------------------------- #undef IMPLEMENT_CONFIG #define IMPLEMENT_CONFIG(NAME) \ - NAME##Config* NAME##Config::getByName (str name) \ + NAME##Config* NAME##Config::getByName (QString name) \ { \ return getConfigByName (name, NAME); \ } diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/config.h --- a/src/config.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/config.h Tue Jan 07 12:21:46 2014 +0200 @@ -28,7 +28,7 @@ class QSettings; typedef QChar QChar; -typedef QString str; +typedef QString QString; #define MAX_INI_LINE 512 #define MAX_CONFIG 512 @@ -42,7 +42,7 @@ // ========================================================= class Config { - PROPERTY (private, str, Name, STR_OPS, STOCK_WRITE) + PROPERTY (private, QString, Name, STR_OPS, STOCK_WRITE) public: enum Type @@ -55,14 +55,14 @@ List, }; - using IntType = int; - using StringType = QString; - using FloatType = float; - using BoolType = bool; - using KeySequenceType = QKeySequence; - using ListType = QList; + using IntType = int; + using StringType = QString; + using FloatType = float; + using BoolType = bool; + using KeySequenceType = QKeySequence; + using ListType = QList; - Config (str name); + Config (QString name); virtual QVariant getDefaultAsVariant() const = 0; virtual Type getType() const = 0; @@ -75,8 +75,8 @@ static bool load(); static bool save(); static void reset(); - static str dirpath(); - static str filepath (str file); + static QString dirpath(); + static QString filepath (QString file); protected: static void addToArray (Config* ptr); @@ -87,7 +87,7 @@ public: \ using ValueType = Config::NAME##Type; \ \ - NAME##Config (ValueType* valueptr, str name, ValueType def) : \ + NAME##Config (ValueType* valueptr, QString name, ValueType def) : \ Config (name), \ m_valueptr (valueptr), \ m_default (def) \ @@ -141,7 +141,7 @@ return QVariant::fromValue (m_default); \ } \ \ - static NAME##Config* getByName (str name); \ + static NAME##Config* getByName (QString name); \ \ private: \ ValueType* m_valueptr; \ diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/configDialog.cc --- a/src/configDialog.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/configDialog.cc Tue Jan 07 12:21:46 2014 +0200 @@ -219,7 +219,7 @@ { // Icon lb_gridIcons[i] = new QLabel; - lb_gridIcons[i]->setPixmap (getIcon (fmt ("grid-%1", str (g_GridInfo[i].name).toLower()))); + lb_gridIcons[i]->setPixmap (getIcon (fmt ("grid-%1", QString (g_GridInfo[i].name).toLower()))); // Text label lb_gridLabels[i] = new QLabel (fmt ("%1:", g_GridInfo[i].name)); @@ -250,9 +250,9 @@ // ----------------------------------------------------------------------------- static struct LDExtProgInfo { - const str name, + const QString name, iconname; - str* const path; + QString* const path; QLineEdit* input; QPushButton* setPathButton; #ifndef _WIN32 @@ -540,7 +540,7 @@ // ============================================================================= // Pick a color and set the appropriate configuration option. // ----------------------------------------------------------------------------- -void ConfigDialog::pickColor (str& conf, QPushButton* button) +void ConfigDialog::pickColor (QString& conf, QPushButton* button) { QColor col = QColorDialog::getColor (QColor (conf)); @@ -550,7 +550,7 @@ g = col.green(), b = col.blue(); - str colname; + QString colname; colname.sprintf ("#%.2X%.2X%.2X", r, g, b); conf = colname; setButtonBackground (button, colname); @@ -581,7 +581,7 @@ // ============================================================================= // Sets background color of a given button. // ----------------------------------------------------------------------------- -void ConfigDialog::setButtonBackground (QPushButton* button, str value) +void ConfigDialog::setButtonBackground (QPushButton* button, QString value) { button->setIcon (getIcon ("colorselect")); button->setAutoFillBackground (true); @@ -691,7 +691,7 @@ } assert (info != null); - str fpath = QFileDialog::getOpenFileName (this, fmt ("Path to %1", info->name), *info->path, g_extProgPathFilter); + QString fpath = QFileDialog::getOpenFileName (this, fmt ("Path to %1", info->name), *info->path, g_extProgPathFilter); if (fpath.isEmpty()) return; @@ -704,7 +704,7 @@ // ----------------------------------------------------------------------------- void ConfigDialog::slot_findDownloadFolder() { - str dpath = QFileDialog::getExistingDirectory(); + QString dpath = QFileDialog::getExistingDirectory(); ui->downloadPath->setText (dpath); } @@ -714,17 +714,17 @@ void ConfigDialog::setShortcutText (ShortcutListItem* item) { QAction* act = item->getAction(); - str label = act->iconText(); - str keybind = item->getKeyConfig()->getValue().toString(); + QString label = act->iconText(); + QString keybind = item->getKeyConfig()->getValue().toString(); item->setText (fmt ("%1 (%2)", label, keybind)); } // ============================================================================= // Gets the configuration string of the quick color toolbar // ----------------------------------------------------------------------------- -str ConfigDialog::quickColorString() +QString ConfigDialog::quickColorString() { - str val; + QString val; for (const LDQuickColor& entry : quickColors) { @@ -782,12 +782,12 @@ // ----------------------------------------------------------------------------- void KeySequenceDialog::updateOutput() { - str shortcut = seq.toString(); + QString shortcut = seq.toString(); if (seq == QKeySequence()) shortcut = "<empty>"; - str text = fmt ("
%1
", shortcut); + QString text = fmt ("
%1
", shortcut); lb_output->setText (text); } diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/configDialog.h --- a/src/configDialog.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/configDialog.h Tue Jan 07 12:21:46 2014 +0200 @@ -69,12 +69,12 @@ void applySettings(); void addShortcut (KeySequenceConfig& cfg, QAction* act, int& i); - void setButtonBackground (QPushButton* button, str value); - void pickColor (str& conf, QPushButton* button); + void setButtonBackground (QPushButton* button, QString value); + void pickColor (QString& conf, QPushButton* button); void updateQuickColorList (LDQuickColor* sel = null); void setShortcutText (ShortcutListItem* item); int getItemRow (QListWidgetItem* item, QList& haystack); - str quickColorString(); + QString quickColorString(); QListWidgetItem* getSelectedQuickColor(); QList getShortcutSelection(); void initGrids(); diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/crashcatcher.cc --- a/src/crashcatcher.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/crashcatcher.cc Tue Jan 07 12:21:46 2014 +0200 @@ -33,7 +33,7 @@ static bool g_crashCatcherActive = false; // If an assertion failed, what was it? -static str g_assertionFailure; +static QString g_assertionFailure; // List of signals to catch and crash on static QList g_signalsToCatch ({ @@ -64,9 +64,9 @@ if (commandsFile.open()) { commandsFile.write (fmt ("attach %1\n", pid).toLocal8Bit()); - commandsFile.write (str ("backtrace full\n").toLocal8Bit()); - commandsFile.write (str ("detach\n").toLocal8Bit()); - commandsFile.write (str ("quit").toLocal8Bit()); + commandsFile.write (QString ("backtrace full\n").toLocal8Bit()); + commandsFile.write (QString ("detach\n").toLocal8Bit()); + commandsFile.write (QString ("quit").toLocal8Bit()); commandsFile.flush(); commandsFile.close(); } @@ -81,8 +81,8 @@ prctl (PR_SET_PTRACER, proc.pid(), 0, 0, 0); proc.waitForFinished (1000); - str output = QString (proc.readAllStandardOutput()); - str err = QString (proc.readAllStandardError()); + QString output = QString (proc.readAllStandardOutput()); + QString err = QString (proc.readAllStandardError()); bombBox (fmt ("

Program crashed with signal %1

\n\n" "%2" @@ -115,7 +115,7 @@ // ----------------------------------------------------------------------------- void assertionFailure (const char* file, int line, const char* funcname, const char* expr) { - str errmsg = fmt ( + QString errmsg = fmt ( "

File: %1
" "Line: %2
" "Function: %3

" diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/dialogs.cc --- a/src/dialogs.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/dialogs.cc Tue Jan 07 12:21:46 2014 +0200 @@ -113,7 +113,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str OverlayDialog::fpath() const +QString OverlayDialog::fpath() const { return ui->filename->text(); } @@ -207,12 +207,12 @@ return ui->buttonBox->button (QDialogButtonBox::Cancel); } -void LDrawPathDialog::setPath (str path) +void LDrawPathDialog::setPath (QString path) { ui->path->setText (path); } -str LDrawPathDialog::filename() const +QString LDrawPathDialog::filename() const { return ui->path->text(); } @@ -221,7 +221,7 @@ // ----------------------------------------------------------------------------- void LDrawPathDialog::slot_findPath() { - str newpath = QFileDialog::getExistingDirectory (this, "Find LDraw Path"); + QString newpath = QFileDialog::getExistingDirectory (this, "Find LDraw Path"); if (newpath.length() > 0 && newpath != filename()) { @@ -305,12 +305,12 @@ // ============================================================================= // ----------------------------------------------------------------------------- -ExtProgPathPrompt::ExtProgPathPrompt (str progName, QWidget* parent, Qt::WindowFlags f) : +ExtProgPathPrompt::ExtProgPathPrompt (QString progName, QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f), ui (new Ui_ExtProgPath) { ui->setupUi (this); - str labelText = ui->m_label->text(); + QString labelText = ui->m_label->text(); labelText.replace ("", progName); ui->m_label->setText (labelText); connect (ui->m_findPath, SIGNAL (clicked (bool)), this, SLOT (findPath())); @@ -327,7 +327,7 @@ // ----------------------------------------------------------------------------- void ExtProgPathPrompt::findPath() { - str path = QFileDialog::getOpenFileName (null, "", "", g_extProgPathFilter); + QString path = QFileDialog::getOpenFileName (null, "", "", g_extProgPathFilter); if (!path.isEmpty()) ui->m_path->setText (path); @@ -335,7 +335,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str ExtProgPathPrompt::getPath() const +QString ExtProgPathPrompt::getPath() const { return ui->m_path->text(); } @@ -367,7 +367,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void bombBox (const str& message) +void bombBox (const QString& message) { QDialog dlg (g_win); Ui_BombBox ui; diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/dialogs.h --- a/src/dialogs.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/dialogs.h Tue Jan 07 12:21:46 2014 +0200 @@ -48,7 +48,7 @@ explicit OverlayDialog (QWidget* parent = null, Qt::WindowFlags f = 0); virtual ~OverlayDialog(); - str fpath() const; + QString fpath() const; int ofsx() const; int ofsy() const; double lwidth() const; @@ -74,8 +74,8 @@ public: explicit LDrawPathDialog (const bool validDefault, QWidget* parent = null, Qt::WindowFlags f = 0); virtual ~LDrawPathDialog(); - str filename() const; - void setPath (str path); + QString filename() const; + void setPath (QString path); private: Q_DISABLE_COPY (LDrawPathDialog) @@ -117,9 +117,9 @@ Q_OBJECT public: - explicit ExtProgPathPrompt (str progName, QWidget* parent = 0, Qt::WindowFlags f = 0); + explicit ExtProgPathPrompt (QString progName, QWidget* parent = 0, Qt::WindowFlags f = 0); virtual ~ExtProgPathPrompt(); - str getPath() const; + QString getPath() const; public slots: void findPath(); @@ -140,6 +140,6 @@ void slot_mail(); }; -void bombBox (const str& message); +void bombBox (const QString& message); #endif // LDFORGE_DIALOGS_H diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/document.cc --- a/src/document.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/document.cc Tue Jan 07 12:21:46 2014 +0200 @@ -49,12 +49,12 @@ // ----------------------------------------------------------------------------- namespace LDPaths { - static str pathError; + static QString pathError; struct { - str LDConfigPath; - str partsPath, primsPath; + QString LDConfigPath; + QString partsPath, primsPath; } pathInfo; void initPaths() @@ -70,7 +70,7 @@ } } - bool tryConfigure (str path) + bool tryConfigure (QString path) { QDir dir; @@ -97,22 +97,22 @@ } // Accessors - str getError() + QString getError() { return pathError; } - str ldconfig() + QString ldconfig() { return pathInfo.LDConfigPath; } - str prims() + QString prims() { return pathInfo.primsPath; } - str parts() + QString parts() { return pathInfo.partsPath; } @@ -182,7 +182,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -LDDocument* findDocument (str name) +LDDocument* findDocument (QString name) { for (LDDocument * file : g_loadedFiles) if (!file->getName().isEmpty() && file->getName() == name) @@ -193,7 +193,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str dirname (str path) +QString dirname (QString path) { long lastpos = path.lastIndexOf (DIRSLASH); @@ -210,7 +210,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str basename (str path) +QString basename (QString path) { long lastpos = path.lastIndexOf (DIRSLASH); @@ -222,11 +222,11 @@ // ============================================================================= // ----------------------------------------------------------------------------- -File* openLDrawFile (str relpath, bool subdirs) +File* openLDrawFile (QString relpath, bool subdirs) { log ("Opening %1...\n", relpath); File* f = new File; - str fullPath; + QString fullPath; // LDraw models use Windows-style path separators. If we're not on Windows, // replace the path separator now before opening any files. Qt expects @@ -237,22 +237,22 @@ // Try find it relative to other currently open documents. We want a file // in the immediate vicinity of a current model to override stock LDraw stuff. - str reltop = basename (dirname (relpath)); + QString reltop = basename (dirname (relpath)); for (LDDocument* doc : g_loadedFiles) { if (doc->getFullPath().isEmpty()) continue; - str partpath = fmt ("%1/%2", dirname (doc->getFullPath()), relpath); + QString partpath = fmt ("%1/%2", dirname (doc->getFullPath()), relpath); if (f->open (partpath, File::Read)) { // ensure we don't mix subfiles and 48-primitives with non-subfiles and non-48 - str proptop = basename (dirname (partpath)); + QString proptop = basename (dirname (partpath)); bool bogus = false; - for (str s : g_specialSubdirectories) + for (QString s : g_specialSubdirectories) { if ((proptop == s && reltop != s) || (reltop == s && proptop != s)) { @@ -279,9 +279,9 @@ { // Look in sub-directories: parts and p. Also look in net_downloadpath, since that's // where we download parts from the PT to. - for (const str& topdir : initlist ({ io_ldpath, net_downloadpath })) + for (const QString& topdir : initlist ({ io_ldpath, net_downloadpath })) { - for (const str& subdir : initlist ({ "parts", "p" })) + for (const QString& subdir : initlist ({ "parts", "p" })) { fullPath = fmt ("%1" DIRSLASH "%2" DIRSLASH "%3", topdir, subdir, relpath); @@ -349,7 +349,7 @@ for (; i < max && i < (int) getLines().size(); ++i) { - str line = getLines()[i]; + QString line = getLines()[i]; // Trim the trailing newline QChar c; @@ -418,14 +418,14 @@ // ----------------------------------------------------------------------------- QList loadFileContents (File* f, int* numWarnings, bool* ok) { - QList lines; + QList lines; QList objs; if (numWarnings) *numWarnings = 0; // Read in the lines - for (str line : *f) + for (QString line : *f) lines << line; LDFileLoader* loader = new LDFileLoader; @@ -451,7 +451,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -LDDocument* openDocument (str path, bool search) +LDDocument* openDocument (QString path, bool search) { // Convert the file name to lowercase since some parts contain uppercase // file names. I'll assume here that the library will always use lowercase @@ -518,7 +518,7 @@ // If we have unsaved changes, warn and give the option of saving. if (hasUnsavedChanges()) { - str message = fmt (tr ("There are unsaved changes to %1. Should it be saved?"), + QString message = fmt (tr ("There are unsaved changes to %1. Should it be saved?"), (getName().length() > 0) ? getName() : tr ("")); int button = msgbox::question (g_win, tr ("Unsaved Changes"), message, @@ -531,7 +531,7 @@ // If we don't have a file path yet, we have to ask the user for one. if (getName().length() == 0) { - str newpath = QFileDialog::getSaveFileName (g_win, tr ("Save As"), + QString newpath = QFileDialog::getSaveFileName (g_win, tr ("Save As"), getCurrentDocument()->getName(), tr ("LDraw files (*.dat *.ldr)")); if (newpath.length() == 0) @@ -594,7 +594,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void addRecentFile (str path) +void addRecentFile (QString path) { auto& rfiles = io_recentfiles; int idx = rfiles.indexOf (path); @@ -623,7 +623,7 @@ // ============================================================================= // Open an LDraw file and set it as the main model // ----------------------------------------------------------------------------- -void openMainFile (str path) +void openMainFile (QString path) { g_loadingMainFile = true; LDDocument* file = openDocument (path, false); @@ -662,7 +662,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -bool LDDocument::save (str savepath) +bool LDDocument::save (QString savepath) { if (!savepath.length()) savepath = getName(); @@ -683,7 +683,7 @@ if (fpathComment->text.left (6) == "Name: ") { - str newname = shortenName (savepath); + QString newname = shortenName (savepath); fpathComment->text = fmt ("Name: %1", newname); g_win->buildObjList(); } @@ -711,11 +711,11 @@ // ----------------------------------------------------------------------------- class LDParseError : public std::exception { - PROPERTY (private, str, Error, STR_OPS, STOCK_WRITE) - PROPERTY (private, str, Line, STR_OPS, STOCK_WRITE) + PROPERTY (private, QString, Error, STR_OPS, STOCK_WRITE) + PROPERTY (private, QString, Line, STR_OPS, STOCK_WRITE) public: - LDParseError (str line, str a) : m_Error (a), m_Line (line) {} + LDParseError (QString line, QString a) : m_Error (a), m_Line (line) {} const char* what() const throw() { @@ -725,7 +725,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void checkTokenCount (str line, const QStringList& tokens, int num) +void checkTokenCount (QString line, const QStringList& tokens, int num) { if (tokens.size() != num) throw LDParseError (line, fmt ("Bad amount of tokens, expected %1, got %2", num, tokens.size())); @@ -733,7 +733,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void checkTokenNumbers (str line, const QStringList& tokens, int min, int max) +void checkTokenNumbers (QString line, const QStringList& tokens, int min, int max) { bool ok; @@ -766,11 +766,11 @@ // code and returns the object parsed from it. parseLine never returns null, // the object will be LDError if it could not be parsed properly. // ----------------------------------------------------------------------------- -LDObject* parseLine (str line) +LDObject* parseLine (QString line) { try { - QStringList tokens = line.split (" ", str::SkipEmptyParts); + QStringList tokens = line.split (" ", QString::SkipEmptyParts); if (tokens.size() <= 0) { @@ -788,7 +788,7 @@ case 0: { // Comment - str comm = line.mid (line.indexOf ("0") + 1).simplified(); + QString comm = line.mid (line.indexOf ("0") + 1).simplified(); // Handle BFC statements if (tokens.size() > 2 && tokens[1] == "BFC") @@ -802,7 +802,7 @@ // need to handle MLCAD-style invertnext, clip and noclip separately. struct { - str a; + QString a; LDBFC::Type b; } BFCData[] = { @@ -954,7 +954,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -LDDocument* getDocument (str filename) +LDDocument* getDocument (QString filename) { // Try find the file in the list of loaded files LDDocument* doc = findDocument (filename); @@ -1074,8 +1074,8 @@ // Mark this change to history if (!m_History->isIgnoring()) { - str oldcode = getObject (idx)->raw(); - str newcode = obj->raw(); + QString oldcode = getObject (idx)->raw(); + QString newcode = obj->raw(); *m_History << new EditHistory (idx, oldcode, newcode); } @@ -1121,7 +1121,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDDocument::getDisplayName() +QString LDDocument::getDisplayName() { if (!getName().isEmpty()) return getName(); @@ -1342,10 +1342,10 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDDocument::shortenName (str a) // [static] +QString LDDocument::shortenName (QString a) // [static] { - str shortname = basename (a); - str topdirname = basename (dirname (a)); + QString shortname = basename (a); + QString topdirname = basename (dirname (a)); if (g_specialSubdirectories.contains (topdirname)) shortname.prepend (topdirname + "\\"); diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/document.h --- a/src/document.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/document.h Tue Jan 07 12:21:46 2014 +0200 @@ -31,12 +31,12 @@ namespace LDPaths { void initPaths(); - bool tryConfigure (str path); + bool tryConfigure (QString path); - str ldconfig(); - str prims(); - str parts(); - str getError(); + QString ldconfig(); + QString prims(); + QString parts(); + QString getError(); } // ============================================================================= @@ -59,9 +59,9 @@ PROPERTY (private, QList, Objects, NO_OPS, STOCK_WRITE) PROPERTY (private, History*, History, NO_OPS, STOCK_WRITE) PROPERTY (private, QList, Vertices, NO_OPS, STOCK_WRITE) - PROPERTY (public, str, Name, STR_OPS, STOCK_WRITE) - PROPERTY (public, str, FullPath, STR_OPS, STOCK_WRITE) - PROPERTY (public, str, DefaultName, STR_OPS, STOCK_WRITE) + PROPERTY (public, QString, Name, STR_OPS, STOCK_WRITE) + PROPERTY (public, QString, FullPath, STR_OPS, STOCK_WRITE) + PROPERTY (public, QString, DefaultName, STR_OPS, STOCK_WRITE) PROPERTY (public, bool, Implicit, BOOL_OPS, STOCK_WRITE) PROPERTY (public, QList, Cache, NO_OPS, STOCK_WRITE) PROPERTY (public, long, SavePosition, NUM_OPS, STOCK_WRITE) @@ -75,14 +75,14 @@ void addObjects (const QList objs); void clearSelection(); void forgetObject (LDObject* obj); // Deletes the given object from the object chain. - str getDisplayName(); + QString getDisplayName(); const QList& getSelection() const; bool hasUnsavedChanges() const; // Does this document.have unsaved changes? QList inlineContents (LDSubfile::InlineFlags flags); void insertObj (int pos, LDObject* obj); int getObjectCount() const; LDObject* getObject (int pos) const; - bool save (str path = ""); // Saves this file to disk. + bool save (QString path = ""); // Saves this file to disk. void swapObjects (LDObject* one, LDObject* other); bool isSafeToClose(); // Perform safety checks. Do this before closing any files! void setObject (int idx, LDObject* obj); @@ -128,7 +128,7 @@ static int countExplicitFiles(); // Turns a full path into a relative path - static str shortenName (str a); + static QString shortenName (QString a); protected: void addToSelection (LDObject* obj); @@ -151,27 +151,27 @@ void newFile(); // Opens the given file as the main file. Everything is closed first. -void openMainFile (str path); +void openMainFile (QString path); // Finds an OpenFile by name or null if not open -LDDocument* findDocument (str name); +LDDocument* findDocument (QString name); // Opens the given file and parses the LDraw code within. Returns a pointer // to the opened file or null on error. -LDDocument* openDocument (str path, bool search); +LDDocument* openDocument (QString path, bool search); // Opens the given file and returns a pointer to it, potentially looking in /parts and /p -File* openLDrawFile (str relpath, bool subdirs); +File* openLDrawFile (QString relpath, bool subdirs); // Close all open files, whether user-opened or subfile caches. void closeAll(); // Parses a string line containing an LDraw object and returns the object parsed. -LDObject* parseLine (str line); +LDObject* parseLine (QString line); // Retrieves the pointer to the given document by file name. Document is loaded // from file if necessary. Can return null if neither succeeds. -LDDocument* getDocument (str filename); +LDDocument* getDocument (QString filename); // Re-caches all subfiles. void reloadAllSubfiles(); @@ -188,10 +188,10 @@ return getCurrentDocument()->getSelection(); } -void addRecentFile (str path); +void addRecentFile (QString path); void loadLogoedStuds(); -str basename (str path); -str dirname (str path); +QString basename (QString path); +QString dirname (QString path); extern QList g_loadedFiles; // Vector of all currently opened files. diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/download.cc --- a/src/download.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/download.cc Tue Jan 07 12:21:46 2014 +0200 @@ -35,13 +35,13 @@ cfg (Bool, net_guesspaths, true); cfg (Bool, net_autoclose, true); -const str g_unofficialLibraryURL ("http://ldraw.org/library/unofficial/"); +const QString g_unofficialLibraryURL ("http://ldraw.org/library/unofficial/"); // ============================================================================= // ----------------------------------------------------------------------------- void PartDownloader::staticBegin() { - str path = getDownloadPath(); + QString path = getDownloadPath(); if (path == "" || QDir (path).exists() == false) { @@ -58,9 +58,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str PartDownloader::getDownloadPath() +QString PartDownloader::getDownloadPath() { - str path = net_downloadpath; + QString path = net_downloadpath; #if DIRSLASH_CHAR != '/' path.replace (DIRSLASH, "/"); @@ -97,10 +97,10 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str PartDownloader::getURL() const +QString PartDownloader::getURL() const { const Source src = getSource(); - str dest; + QString dest; switch (src) { @@ -119,7 +119,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void PartDownloader::modifyDestination (str& dest) const +void PartDownloader::modifyDestination (QString& dest) const { dest = dest.simplified(); @@ -165,8 +165,8 @@ Subfiles (usually) have an s** prefix, in which case we use parts/s/. Note that the regex starts with a '^' so it won't catch already fully given part file names. */ - str partRegex = "^u?[0-9]+(c[0-9][0-9]+)*(d[0-9][0-9]+)*[a-z]?(p[0-9a-z][0-9a-z]+)*"; - str subpartRegex = partRegex + "s[0-9][0-9]+"; + QString partRegex = "^u?[0-9]+(c[0-9][0-9]+)*(d[0-9][0-9]+)*[a-z]?(p[0-9a-z][0-9a-z]+)*"; + QString subpartRegex = partRegex + "s[0-9][0-9]+"; partRegex += "\\.dat$"; subpartRegex += "\\.dat$"; @@ -213,7 +213,7 @@ } elif (btn == getButton (Download)) { - str dest = getInterface()->fname->text(); + QString dest = getInterface()->fname->text(); setPrimaryFile (null); setAborted (false); @@ -224,7 +224,7 @@ if (QFile::exists (PartDownloader::getDownloadPath() + DIRSLASH + dest)) { - const str overwritemsg = fmt (tr ("%1 already exists in download directory. Overwrite?"), dest); + const QString overwritemsg = fmt (tr ("%1 already exists in download directory. Overwrite?"), dest); if (!confirm (tr ("Overwrite?"), overwritemsg)) return; } @@ -242,7 +242,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void PartDownloader::downloadFile (str dest, str url, bool primary) +void PartDownloader::downloadFile (QString dest, QString url, bool primary) { const int row = getInterface()->progress->rowCount(); @@ -325,7 +325,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -PartDownloadRequest::PartDownloadRequest (str url, str dest, bool primary, PartDownloader* parent) : +PartDownloadRequest::PartDownloadRequest (QString url, QString dest, bool primary, PartDownloader* parent) : QObject (parent), m_State (ERequesting), m_Prompt (parent), @@ -338,7 +338,7 @@ m_FilePointer (null) { // Make sure that we have a valid destination. - str dirpath = dirname (getFilePath()); + QString dirpath = dirname (getFilePath()); QDir dir (dirpath); @@ -390,7 +390,7 @@ case EFinished: case EFailed: { - const str text = (getState() == EFinished) + const QString text = (getState() == EFinished) ? "FINISHED" : "FAILED"; @@ -467,7 +467,7 @@ if (!err || err->getFileReferenced().isEmpty()) continue; - str dest = err->getFileReferenced(); + QString dest = err->getFileReferenced(); getPrompt()->modifyDestination (dest); getPrompt()->downloadFile (dest, g_unofficialLibraryURL + dest, false); } diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/download.h --- a/src/download.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/download.h Tue Jan 07 12:21:46 2014 +0200 @@ -71,13 +71,13 @@ explicit PartDownloader (QWidget* parent = null); virtual ~PartDownloader(); - void downloadFile (str dest, str url, bool primary); + void downloadFile (QString dest, QString url, bool primary); QPushButton* getButton (Button i); - str getURL() const; + QString getURL() const; Source getSource() const; - void modifyDestination (str& dest) const; + void modifyDestination (QString& dest) const; - static str getDownloadPath(); + static QString getDownloadPath(); static void staticBegin(); public slots: @@ -104,9 +104,9 @@ PROPERTY (public, int, TableRow, NUM_OPS, STOCK_WRITE) PROPERTY (private, EState, State, NO_OPS, STOCK_WRITE) PROPERTY (private, PartDownloader*, Prompt, NO_OPS, STOCK_WRITE) - PROPERTY (private, str, URL, STR_OPS, STOCK_WRITE) - PROPERTY (private, str, Destinaton, STR_OPS, STOCK_WRITE) - PROPERTY (private, str, FilePath, STR_OPS, STOCK_WRITE) + PROPERTY (private, QString, URL, STR_OPS, STOCK_WRITE) + PROPERTY (private, QString, Destinaton, STR_OPS, STOCK_WRITE) + PROPERTY (private, QString, FilePath, STR_OPS, STOCK_WRITE) PROPERTY (private, QNetworkAccessManager*, NAM, NO_OPS, STOCK_WRITE) PROPERTY (private, QNetworkReply*, Reply, NO_OPS, STOCK_WRITE) PROPERTY (private, bool, FirstUpdate, BOOL_OPS, STOCK_WRITE) @@ -116,7 +116,7 @@ PROPERTY (private, QFile*, FilePointer, NO_OPS, STOCK_WRITE) public: - explicit PartDownloadRequest (str url, str dest, bool primary, PartDownloader* parent); + explicit PartDownloadRequest (QString url, QString dest, bool primary, PartDownloader* parent); PartDownloadRequest (const PartDownloadRequest&) = delete; virtual ~PartDownloadRequest(); void updateToTable(); diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/extprogs.cc --- a/src/extprogs.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/extprogs.cc Tue Jan 07 12:21:46 2014 +0200 @@ -58,7 +58,7 @@ cfg (String, prog_rectifier, ""); cfg (String, prog_edger2, ""); -str* const g_extProgPaths[] = +QString* const g_extProgPaths[] = { &prog_isecalc, &prog_intersector, @@ -101,7 +101,7 @@ // ----------------------------------------------------------------------------- static bool checkProgPath (const extprog prog) { - str& path = *g_extProgPaths[prog]; + QString& path = *g_extProgPaths[prog]; if (path.length() > 0) return true; @@ -119,13 +119,13 @@ // ============================================================================= // ----------------------------------------------------------------------------- -static str processErrorString (extprog prog, QProcess& proc) +static QString processErrorString (extprog prog, QProcess& proc) { switch (proc.error()) { case QProcess::FailedToStart: { - str wineblurb; + QString wineblurb; #ifndef _WIN32 if (*g_extProgWine[prog]) @@ -154,7 +154,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -static bool mkTempFile (QTemporaryFile& tmp, str& fname) +static bool mkTempFile (QTemporaryFile& tmp, QString& fname) { if (!tmp.open()) return false; @@ -187,7 +187,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -static void writeObjects (const QList& objects, str fname) +static void writeObjects (const QList& objects, QString fname) { // Write the input file File f (fname, File::Write); @@ -208,14 +208,14 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void writeSelection (str fname) +void writeSelection (QString fname) { writeObjects (selection(), fname); } // ============================================================================= // ----------------------------------------------------------------------------- -void writeColorGroup (const int colnum, str fname) +void writeColorGroup (const int colnum, QString fname) { QList objects; @@ -232,10 +232,10 @@ // ============================================================================= // ----------------------------------------------------------------------------- -bool runUtilityProcess (extprog prog, str path, str argvstr) +bool runUtilityProcess (extprog prog, QString path, QString argvstr) { QTemporaryFile input, output; - str inputname, outputname; + QString inputname, outputname; QStringList argv = argvstr.split (" ", QString::SkipEmptyParts); #ifndef _WIN32 @@ -273,7 +273,7 @@ // Wait while it runs proc.waitForFinished(); - str err = ""; + QString err = ""; if (proc.exitStatus() != QProcess::NormalExit) err = processErrorString (prog, proc); @@ -293,7 +293,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -static void insertOutput (str fname, bool replace, QList colorsToReplace) +static void insertOutput (QString fname, bool replace, QList colorsToReplace) { #ifdef DEBUG QFile::copy (fname, "./debug_lastOutput"); @@ -366,14 +366,14 @@ condAngle = ui.condAngle->value(); QTemporaryFile indat, outdat; - str inDATName, outDATName; + QString inDATName, outDATName; // Make temp files for the input and output files if (!mkTempFile (indat, inDATName) || !mkTempFile (outdat, outDATName)) return; // Compose the command-line arguments - str argv = join ( + QString argv = join ( { (axis == X) ? "-x" : (axis == Y) ? "-y" : "-z", (mode == Distance) ? "-d" : (mode == Symmetry) ? "-s" : (mode == Projection) ? "-p" : "-r", @@ -410,14 +410,14 @@ return; QTemporaryFile indat, outdat; - str inDATName, outDATName; + QString inDATName, outDATName; // Make temp files for the input and output files if (!mkTempFile (indat, inDATName) || !mkTempFile (outdat, outDATName)) return; // Compose arguments - str argv = join ( + QString argv = join ( { (!ui.cb_condense->isChecked()) ? "-q" : "", (!ui.cb_subst->isChecked()) ? "-r" : "", @@ -484,7 +484,7 @@ // outdat2 = inverse output // edgesdat = edges output (isecalc) QTemporaryFile indat, cutdat, outdat, outdat2, edgesdat; - str inDATName, cutDATName, outDATName, outDAT2Name, edgesDATName; + QString inDATName, cutDATName, outDATName, outDAT2Name, edgesDATName; if (!mkTempFile (indat, inDATName) || !mkTempFile (cutdat, cutDATName) || !mkTempFile (outdat, outDATName) || !mkTempFile (outdat2, outDAT2Name) || @@ -493,7 +493,7 @@ return; } - str parms = join ( + QString parms = join ( { (ui.cb_colorize->isChecked()) ? "-c" : "", (ui.cb_nocondense->isChecked()) ? "-t" : "", @@ -501,7 +501,7 @@ ui.dsb_prescale->value() }); - str argv_normal = join ( + QString argv_normal = join ( { parms, inDATName, @@ -509,7 +509,7 @@ outDATName }); - str argv_inverse = join ( + QString argv_inverse = join ( { parms, cutDATName, @@ -571,12 +571,12 @@ } QTemporaryFile in1dat, in2dat, outdat; - str in1DATName, in2DATName, outDATName; + QString in1DATName, in2DATName, outDATName; if (!mkTempFile (in1dat, in1DATName) || !mkTempFile (in2dat, in2DATName) || !mkTempFile (outdat, outDATName)) return; - str argv = join ( + QString argv = join ( { (ui.cb_oldsweep->isChecked() ? "-s" : ""), (ui.cb_reverse->isChecked() ? "-r" : ""), @@ -633,12 +633,12 @@ } QTemporaryFile in1dat, in2dat, outdat; - str in1DATName, in2DATName, outDATName; + QString in1DATName, in2DATName, outDATName; if (!mkTempFile (in1dat, in1DATName) || !mkTempFile (in2dat, in2DATName) || !mkTempFile (outdat, outDATName)) return; - str argv = join ( + QString argv = join ( { in1DATName, in2DATName, @@ -668,14 +668,14 @@ return; QTemporaryFile in, out; - str inName, outName; + QString inName, outName; if (!mkTempFile (in, inName) || !mkTempFile (out, outName)) return; int unmatched = ui.unmatched->currentIndex(); - str argv = join ( + QString argv = join ( { fmt ("-p %1", ui.precision->value()), fmt ("-af %1", ui.flatAngle->value()), diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/gldraw.cc --- a/src/gldraw.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/gldraw.cc Tue Jan 07 12:21:46 2014 +0200 @@ -139,7 +139,7 @@ // Init camera icons for (const GL::EFixedCamera cam : g_Cameras) { - str iconname = fmt ("camera-%1", tr (g_CameraNames[cam]).toLower()); + QString iconname = fmt ("camera-%1", tr (g_CameraNames[cam]).toLower()); CameraIcon* info = &m_cameraIcons[cam]; info->img = new QPixmap (getIcon (iconname)); @@ -618,7 +618,7 @@ } // Paint the coordinates onto the screen. - str text = fmt (tr ("X: %1, Y: %2, Z: %3"), m_hoverpos[X], m_hoverpos[Y], m_hoverpos[Z]); + QString text = fmt (tr ("X: %1, Y: %2, Z: %3"), m_hoverpos[X], m_hoverpos[Y], m_hoverpos[Z]); QFontMetrics metrics = QFontMetrics (font()); QRect textSize = metrics.boundingRect (0, 0, m_width, m_height, Qt::AlignCenter, text); @@ -697,7 +697,7 @@ if (gl_linelengths) { - const str label = str::number (poly3d[i].distanceTo (poly3d[j])); + const QString label = QString::number (poly3d[i].distanceTo (poly3d[j])); QPoint origin = QLineF (poly[i], poly[j]).pointAt (0.5).toPoint(); paint.drawText (origin, label); } @@ -712,7 +712,7 @@ if (angle < 0) angle = 180 - l1.angleTo (l0); - str label = str::number (angle) + str::fromUtf8 (QByteArray ("\302\260")); + QString label = QString::number (angle) + QString::fromUtf8 (QByteArray ("\302\260")); QPoint pos = poly[i]; pos.setY (pos.y() + metrics.height()); @@ -799,13 +799,13 @@ { // Draw the current radius in the middle of the circle. QPoint origin = coordconv3_2 (m_drawedVerts[0]); - str label = str::number (dist0); + QString label = QString::number (dist0); paint.setPen (textpen); paint.drawText (origin.x() - (metrics.width (label) / 2), origin.y(), label); if (m_drawedVerts.size() >= 2) { - label = str::number (dist1); + label = QString::number (dist1); paint.drawText (origin.x() - (metrics.width (label) / 2), origin.y() + metrics.height(), label); } } @@ -831,13 +831,13 @@ paint.drawPixmap (info.destRect, *info.img, info.srcRect); } - str fmtstr = tr ("%1 Camera"); + QString fmtstr = tr ("%1 Camera"); // Draw a label for the current camera in the bottom left corner { const int margin = 4; - str label; + QString label; label = fmt (fmtstr, tr (g_CameraNames[camera()])); paint.setPen (textpen); paint.drawText (QPoint (margin, height() - (margin + metrics.descent())), label); @@ -850,7 +850,7 @@ m_drawToolTip = false; else { - str label = fmt (fmtstr, tr (g_CameraNames[m_toolTipCamera])); + QString label = fmt (fmtstr, tr (g_CameraNames[m_toolTipCamera])); QToolTip::showText (m_globalpos, label); } } @@ -1835,7 +1835,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -bool GLRenderer::setupOverlay (EFixedCamera cam, str file, int x, int y, int w, int h) +bool GLRenderer::setupOverlay (EFixedCamera cam, QString file, int x, int y, int w, int h) { QImage* img = new QImage (QImage (file).convertToFormat (QImage::Format_ARGB32)); LDGLOverlay& info = getOverlay (cam); diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/gldraw.h --- a/src/gldraw.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/gldraw.h Tue Jan 07 12:21:46 2014 +0200 @@ -48,7 +48,7 @@ oy; double lw, lh; - str fname; + QString fname; QImage* img; }; @@ -137,7 +137,7 @@ void setBackground(); void setCamera (const EFixedCamera cam); void setDepthValue (double depth); - bool setupOverlay (EFixedCamera cam, str file, int x, int y, int w, int h); + bool setupOverlay (EFixedCamera cam, QString file, int x, int y, int w, int h); void updateOverlayObjects(); void zoomNotch (bool inward); void zoomToFit(); diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/gui.cc --- a/src/gui.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/gui.cc Tue Jan 07 12:21:46 2014 +0200 @@ -124,7 +124,7 @@ // ----------------------------------------------------------------------------- KeySequenceConfig* ForgeWindow::shortcutForAction (QAction* act) { - str keycfgname = fmt ("key_%1", act->objectName()); + QString keycfgname = fmt ("key_%1", act->objectName()); return KeySequenceConfig::getByName (keycfgname); } @@ -146,7 +146,7 @@ void ForgeWindow::slot_action() { // Get the name of the sender object and use it to compose the slot name. - str methodName = fmt ("slot_%1", sender()->objectName()); + QString methodName = fmt ("slot_%1", sender()->objectName()); #ifdef DEBUG log ("Action %1 triggered", sender()->objectName()); @@ -191,7 +191,7 @@ for (const QVariant& it : io_recentfiles) { - str file = it.toString(); + QString file = it.toString(); QAction* recent = new QAction (getIcon ("open-recent"), file, this); connect (recent, SIGNAL (triggered()), this, SLOT (slot_recentFile())); @@ -207,7 +207,7 @@ { QList colors; - for (str colorname : gui_colortoolbar.split (":")) + for (QString colorname : gui_colortoolbar.split (":")) { if (colorname == "|") colors << LDQuickColor::getSeparator(); @@ -266,7 +266,7 @@ // ----------------------------------------------------------------------------- void ForgeWindow::updateTitle() { - str title = fmt (APPNAME " %1", fullVersionString()); + QString title = fmt (APPNAME " %1", fullVersionString()); // Append our current file if we have one if (getCurrentDocument()) @@ -333,7 +333,7 @@ for (LDObject* obj : getCurrentDocument()->getObjects()) { - str descr; + QString descr; switch (obj->getType()) { @@ -780,11 +780,11 @@ // ----------------------------------------------------------------------------- bool ForgeWindow::save (LDDocument* f, bool saveAs) { - str path = f->getFullPath(); + QString path = f->getFullPath(); if (saveAs || path.isEmpty()) { - str name = f->getDefaultName(); + QString name = f->getDefaultName(); if (!f->getFullPath().isEmpty()) name = f->getFullPath(); @@ -814,7 +814,7 @@ return true; } - str message = fmt (tr ("Failed to save to %1: %2"), path, strerror (errno)); + QString message = fmt (tr ("Failed to save to %1: %2"), path, strerror (errno)); // Tell the user the save failed, and give the option for saving as with it. QMessageBox dlg (QMessageBox::Critical, tr ("Save Failure"), message, QMessageBox::Close, g_win); @@ -832,7 +832,7 @@ return false; } -void ForgeWindow::addMessage (str msg) +void ForgeWindow::addMessage (QString msg) { m_msglog->addLine (msg); } @@ -845,25 +845,25 @@ // ============================================================================= // ----------------------------------------------------------------------------- -QPixmap getIcon (str iconName) +QPixmap getIcon (QString iconName) { return (QPixmap (fmt (":/icons/%1.png", iconName))); } // ============================================================================= -bool confirm (str msg) +bool confirm (QString msg) { return confirm (ForgeWindow::tr ("Confirm"), msg); } -bool confirm (str title, str msg) +bool confirm (QString title, QString msg) { return QMessageBox::question (g_win, title, msg, (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes; } // ============================================================================= -void critical (str msg) +void critical (QString msg) { QMessageBox::critical (g_win, ForgeWindow::tr ("Error"), msg, (QMessageBox::Close), QMessageBox::Close); diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/gui.h --- a/src/gui.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/gui.h Tue Jan 07 12:21:46 2014 +0200 @@ -127,7 +127,7 @@ m_quickColors = colors; } - void addMessage (str msg); + void addMessage (QString msg); void refreshObjectList(); void updateActionShortcuts(); KeySequenceConfig* shortcutForAction (QAction* act); @@ -264,11 +264,11 @@ // ----------------------------------------------------------------------------- // Other GUI-related stuff not directly part of ForgeWindow: -QPixmap getIcon (str iconName); // Get an icon from the resource dir +QPixmap getIcon (QString iconName); // Get an icon from the resource dir QList quickColorsFromConfig(); // Make a list of quick colors based on config -bool confirm (str title, str msg); // Generic confirm prompt -bool confirm (str msg); // Generic confirm prompt -void critical (str msg); // Generic error prompt +bool confirm (QString title, QString msg); // Generic confirm prompt +bool confirm (QString msg); // Generic confirm prompt +void critical (QString msg); // Generic error prompt QIcon makeColorIcon (LDColor* colinfo, const int size); // Makes an icon for the given color void makeColorComboBox (QComboBox* box); // Fills the given combo-box with color information QImage imageFromScreencap (uchar* data, int w, int h); diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/gui_actions.cc --- a/src/gui_actions.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/gui_actions.cc Tue Jan 07 12:21:46 2014 +0200 @@ -52,7 +52,7 @@ Ui::NewPartUI ui; ui.setupUi (dlg); - str authortext = ld_defaultname; + QString authortext = ld_defaultname; if (!ld_defaultuser.isEmpty()) authortext.append (fmt (" [%1]", ld_defaultuser)); @@ -88,7 +88,7 @@ ui.rb_bfc_ccw->isChecked() ? LDBFC::CertifyCCW : ui.rb_bfc_cw->isChecked() ? LDBFC::CertifyCW : LDBFC::NoCertify; - const str license = + const QString license = ui.rb_license_ca->isChecked() ? CALicense : ui.rb_license_nonca->isChecked() ? NonCALicense : ""; @@ -118,7 +118,7 @@ // ----------------------------------------------------------------------------- DEFINE_ACTION (Open, CTRL (O)) { - str name = QFileDialog::getOpenFileName (g_win, "Open File", "", "LDraw files (*.dat *.ldr)"); + QString name = QFileDialog::getOpenFileName (g_win, "Open File", "", "LDraw files (*.dat *.ldr)"); if (name.length() == 0) return; @@ -323,7 +323,7 @@ // If we're selecting subfile references, the reference filename must also // be uniform. - str refName; + QString refName; if (type == LDObject::ESubfile) { @@ -382,7 +382,7 @@ // ----------------------------------------------------------------------------- DEFINE_ACTION (InsertFrom, 0) { - str fname = QFileDialog::getOpenFileName(); + QString fname = QFileDialog::getOpenFileName(); int idx = getInsertionPoint(); if (!fname.length()) @@ -420,7 +420,7 @@ if (selection().isEmpty()) return; - str fname = QFileDialog::getSaveFileName(); + QString fname = QFileDialog::getSaveFileName(); if (fname.length() == 0) return; @@ -435,7 +435,7 @@ for (LDObject* obj : selection()) { - str contents = obj->raw(); + QString contents = obj->raw(); QByteArray data = contents.toUtf8(); file.write (data, data.size()); file.write ("\r\n", 2); @@ -465,7 +465,7 @@ getCurrentDocument()->clearSelection(); - for (str line : str (te_edit->toPlainText()).split ("\n")) + for (QString line : QString (te_edit->toPlainText()).split ("\n")) { LDObject* obj = parseLine (line); @@ -489,13 +489,13 @@ uchar* imgdata = R()->getScreencap (w, h); QImage img = imageFromScreencap (imgdata, w, h); - str root = basename (getCurrentDocument()->getName()); + QString root = basename (getCurrentDocument()->getName()); if (root.right (4) == ".dat") root.chop (4); - str defaultname = (root.length() > 0) ? fmt ("%1.png", root) : ""; - str fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, + QString defaultname = (root.length() > 0) ? fmt ("%1.png", root) : ""; + QString fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); if (fname.length() > 0 && !img.save (fname)) @@ -710,28 +710,28 @@ if (selection().size() == 0) return; - str parentpath = getCurrentDocument()->getFullPath(); + QString parentpath = getCurrentDocument()->getFullPath(); // BFC type of the new subfile - it shall inherit the BFC type of the parent document LDBFC::Type bfctype = LDBFC::NoCertify; // Dirname of the new subfile - str subdirname = dirname (parentpath); + QString subdirname = dirname (parentpath); // Title of the new subfile - str subtitle; + QString subtitle; // Comment containing the title of the parent document LDComment* titleobj = dynamic_cast (getCurrentDocument()->getObject (0)); // License text for the subfile - str license = getLicenseText (ld_defaultlicense); + QString license = getLicenseText (ld_defaultlicense); // LDraw code body of the new subfile (i.e. code of the selection) QStringList code; // Full path of the subfile to be - str fullsubname; + QString fullsubname; // Where to insert the subfile reference? int refidx = selection()[0]->getIndex(); @@ -748,13 +748,13 @@ // If this the parent document isn't already in s/, we need to stuff it into // a subdirectory named s/. Ensure it exists! - str topdirname = basename (dirname (getCurrentDocument()->getFullPath())); + QString topdirname = basename (dirname (getCurrentDocument()->getFullPath())); if (topdirname != "s") { - str desiredPath = subdirname + "/s"; - str title = tr ("Create subfile directory?"); - str text = fmt (tr ("The directory %1 is suggested for " + QString desiredPath = subdirname + "/s"; + QString title = tr ("Create subfile directory?"); + QString text = fmt (tr ("The directory %1 is suggested for " "subfiles. This directory does not exist, create it?"), desiredPath); if (QDir (desiredPath).exists() || confirm (title, text)) @@ -777,9 +777,9 @@ parentpath.chop (subfilesuffix.matchedLength()); int subidx = 1; - str digits; + QString digits; QFile f; - str testfname; + QString testfname; do { @@ -833,7 +833,7 @@ }); // Add the actual subfile code to the new document - for (str line : code) + for (QString line : code) { LDObject* obj = parseLine (line); doc->addObject (obj); diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/gui_editactions.cc --- a/src/gui_editactions.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/gui_editactions.cc Tue Jan 07 12:21:46 2014 +0200 @@ -49,7 +49,7 @@ qApp->clipboard()->clear(); // Now, copy the contents into the clipboard. - str data; + QString data; for (LDObject* obj : objs) { @@ -85,12 +85,12 @@ // ----------------------------------------------------------------------------- DEFINE_ACTION (Paste, CTRL (V)) { - const str clipboardText = qApp->clipboard()->text(); + const QString clipboardText = qApp->clipboard()->text(); int idx = getInsertionPoint(); getCurrentDocument()->clearSelection(); int num = 0; - for (str line : clipboardText.split ("\n")) + for (QString line : clipboardText.split ("\n")) { LDObject* pasted = parseLine (line); getCurrentDocument()->insertObj (idx++, pasted); @@ -141,7 +141,7 @@ // Merge in the inlined objects for (LDObject * inlineobj : objs) { - str line = inlineobj->raw(); + QString line = inlineobj->raw(); inlineobj->deleteSelf(); LDObject* newobj = parseLine (line); getCurrentDocument()->insertObj (idx++, newobj); @@ -796,7 +796,7 @@ return; // Create the comment object based on input - str commentText = fmt ("!HISTORY %1 [%2] %3", + QString commentText = fmt ("!HISTORY %1 [%2] %3", ui->m_date->date().toString ("yyyy-MM-dd"), ui->m_username->text(), ui->m_comment->text()); diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/history.h --- a/src/history.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/history.h Tue Jan 07 12:21:46 2014 +0200 @@ -108,7 +108,7 @@ class DelHistory : public AbstractHistoryEntry { PROPERTY (private, int, Index, NO_OPS, STOCK_WRITE) - PROPERTY (private, str, Code, NO_OPS, STOCK_WRITE) + PROPERTY (private, QString, Code, NO_OPS, STOCK_WRITE) public: IMPLEMENT_HISTORY_TYPE (Del) @@ -121,13 +121,13 @@ class EditHistory : public AbstractHistoryEntry { PROPERTY (private, int, Index, NO_OPS, STOCK_WRITE) - PROPERTY (private, str, OldCode, NO_OPS, STOCK_WRITE) - PROPERTY (private, str, NewCode, NO_OPS, STOCK_WRITE) + PROPERTY (private, QString, OldCode, NO_OPS, STOCK_WRITE) + PROPERTY (private, QString, NewCode, NO_OPS, STOCK_WRITE) public: IMPLEMENT_HISTORY_TYPE (Edit) - EditHistory (int idx, str oldCode, str newCode) : + EditHistory (int idx, QString oldCode, QString newCode) : m_Index (idx), m_OldCode (oldCode), m_NewCode (newCode) {} @@ -139,7 +139,7 @@ class AddHistory : public AbstractHistoryEntry { PROPERTY (private, int, Index, NO_OPS, STOCK_WRITE) - PROPERTY (private, str, Code, NO_OPS, STOCK_WRITE) + PROPERTY (private, QString, Code, NO_OPS, STOCK_WRITE) public: IMPLEMENT_HISTORY_TYPE (Add) diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/ldconfig.cc --- a/src/ldconfig.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/ldconfig.cc Tue Jan 07 12:21:46 2014 +0200 @@ -25,7 +25,7 @@ // ============================================================================= // Helper function for parseLDConfig // ----------------------------------------------------------------------------- -static bool parseLDConfigTag (LDConfigParser& pars, char const* tag, str& val) +static bool parseLDConfigTag (LDConfigParser& pars, char const* tag, QString& val) { int pos; @@ -51,7 +51,7 @@ } // Read in the lines - for (str line : *f) + for (QString line : *f) { if (line.length() == 0 || line[0] != '0') continue; // empty or illogical @@ -63,7 +63,7 @@ LDConfigParser pars (line, ' '); int code = 0, alpha = 255; - str name, facename, edgename, valuestr; + QString name, facename, edgename, valuestr; // Check 0 !COLOUR, parse the name if (!pars.tokenCompare (0, "0") || !pars.tokenCompare (1, "!COLOUR") || !pars.getToken (name, 2)) @@ -116,7 +116,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -LDConfigParser::LDConfigParser (str inText, char sep) +LDConfigParser::LDConfigParser (QString inText, char sep) { m_tokens = inText.split (sep, QString::SkipEmptyParts); m_pos = -1; @@ -138,7 +138,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -bool LDConfigParser::getToken (str& val, const int pos) +bool LDConfigParser::getToken (QString& val, const int pos) { if (pos >= m_tokens.size()) return false; @@ -149,14 +149,14 @@ // ============================================================================= // ----------------------------------------------------------------------------- -bool LDConfigParser::getNextToken (str& val) +bool LDConfigParser::getNextToken (QString& val) { return getToken (val, ++m_pos); } // ============================================================================= // ----------------------------------------------------------------------------- -bool LDConfigParser::peekNextToken (str& val) +bool LDConfigParser::peekNextToken (QString& val) { return getToken (val, m_pos + 1); } @@ -202,7 +202,7 @@ // ----------------------------------------------------------------------------- bool LDConfigParser::tokenCompare (int inPos, const char* sOther) { - str tok; + QString tok; if (!getToken (tok, inPos)) return false; diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/ldconfig.h --- a/src/ldconfig.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/ldconfig.h Tue Jan 07 12:21:46 2014 +0200 @@ -30,20 +30,20 @@ class LDConfigParser { public: - LDConfigParser (str inText, char sep); + LDConfigParser (QString inText, char sep); bool isAtEnd(); bool isAtBeginning(); - bool getNextToken (str& val); - bool peekNextToken (str& val); - bool getToken (str& val, const int pos); + bool getNextToken (QString& val); + bool peekNextToken (QString& val); + bool getToken (QString& val, const int pos); bool findToken (int& result, char const* needle, int args); int getSize(); void rewind(); void seek (int amount, bool rel); bool tokenCompare (int inPos, const char* sOther); - inline str operator[] (const int idx) + inline QString operator[] (const int idx) { return m_tokens[idx]; } diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/ldtypes.cc --- a/src/ldtypes.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/ldtypes.cc Tue Jan 07 12:21:46 2014 +0200 @@ -90,7 +90,7 @@ return false; } -str LDObject::getTypeName() const +QString LDObject::getTypeName() const { return ""; } @@ -113,16 +113,16 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDComment::raw() const +QString LDComment::raw() const { return fmt ("0 %1", text); } // ============================================================================= // ----------------------------------------------------------------------------- -str LDSubfile::raw() const +QString LDSubfile::raw() const { - str val = fmt ("1 %1 %2 ", getColor(), getPosition()); + QString val = fmt ("1 %1 %2 ", getColor(), getPosition()); val += getTransform().stringRep(); val += ' '; val += getFileInfo()->getName(); @@ -131,9 +131,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDLine::raw() const +QString LDLine::raw() const { - str val = fmt ("2 %1", getColor()); + QString val = fmt ("2 %1", getColor()); for (int i = 0; i < 2; ++i) val += fmt (" %1", getVertex (i)); @@ -143,9 +143,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDTriangle::raw() const +QString LDTriangle::raw() const { - str val = fmt ("3 %1", getColor()); + QString val = fmt ("3 %1", getColor()); for (int i = 0; i < 3; ++i) val += fmt (" %1", getVertex (i)); @@ -155,9 +155,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDQuad::raw() const +QString LDQuad::raw() const { - str val = fmt ("4 %1", getColor()); + QString val = fmt ("4 %1", getColor()); for (int i = 0; i < 4; ++i) val += fmt (" %1", getVertex (i)); @@ -167,9 +167,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDCondLine::raw() const +QString LDCondLine::raw() const { - str val = fmt ("5 %1", getColor()); + QString val = fmt ("5 %1", getColor()); // Add the coordinates for (int i = 0; i < 4; ++i) @@ -180,21 +180,21 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDError::raw() const +QString LDError::raw() const { return contents; } // ============================================================================= // ----------------------------------------------------------------------------- -str LDVertex::raw() const +QString LDVertex::raw() const { return fmt ("0 !LDFORGE VERTEX %1 %2", getColor(), pos); } // ============================================================================= // ----------------------------------------------------------------------------- -str LDEmpty::raw() const +QString LDEmpty::raw() const { return ""; } @@ -215,7 +215,7 @@ "NOCLIP", }; -str LDBFC::raw() const +QString LDBFC::raw() const { return fmt ("0 BFC %1", LDBFC::statements[type]); } @@ -428,20 +428,20 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDObject::typeName (LDObject::Type type) +QString LDObject::typeName (LDObject::Type type) { LDObject* obj = LDObject::getDefault (type); - str name = obj->getTypeName(); + QString name = obj->getTypeName(); obj->deleteSelf(); return name; } // ============================================================================= // ----------------------------------------------------------------------------- -str LDObject::describeObjects (const QList& objs) +QString LDObject::describeObjects (const QList& objs) { bool firstDetails = true; - str text = ""; + QString text = ""; if (objs.isEmpty()) return "nothing"; // :) @@ -461,7 +461,7 @@ if (!firstDetails) text += ", "; - str noun = fmt ("%1%2", typeName (objType), plural (count)); + QString noun = fmt ("%1%2", typeName (objType), plural (count)); // Plural of "vertex" is "vertices", correct that if (objType == EVertex && count != 1) @@ -672,7 +672,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDOverlay::raw() const +QString LDOverlay::raw() const { return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6", getFileName(), getCamera(), getX(), getY(), getWidth(), getHeight()); @@ -694,9 +694,9 @@ if (obj->getFile() && (idx = obj->getIndex()) != -1) { - str before = obj->raw(); + QString before = obj->raw(); *ptr = val; - str after = obj->raw(); + QString after = obj->raw(); if (before != after) obj->getFile()->addToHistory (new EditHistory (idx, before, after)); @@ -806,7 +806,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str getLicenseText (int id) +QString getLicenseText (int id) { switch (id) { diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/ldtypes.h --- a/src/ldtypes.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/ldtypes.h Tue Jan 07 12:21:46 2014 +0200 @@ -35,10 +35,10 @@ { \ return LDObject::E##T; \ } \ - virtual str raw() const override; \ + virtual QString raw() const override; \ virtual void invert() override; -#define LDOBJ_NAME(N) virtual str getTypeName() const override { return #N; } +#define LDOBJ_NAME(N) virtual QString getTypeName() const override { return #N; } #define LDOBJ_VERTICES(V) virtual int vertices() const override { return V; } #define LDOBJ_SETCOLORED(V) virtual bool isColored() const override { return V; } #define LDOBJ_COLORED LDOBJ_SETCOLORED (true) @@ -112,7 +112,7 @@ const Vertex& getVertex (int i) const; // Type name of this object - virtual str getTypeName() const; + virtual QString getTypeName() const; // Does this object have a matrix and position? (see LDMatrixObject) virtual bool hasMatrix() const; @@ -136,7 +136,7 @@ LDObject* prev() const; // This object as LDraw code - virtual str raw() const = 0; + virtual QString raw() const = 0; // Replace this LDObject with another LDObject. Object is deleted in the process. void replace (LDObject* other); @@ -163,7 +163,7 @@ virtual int vertices() const; // Get type name by enumerator - static str typeName (LDObject::Type type); + static QString typeName (LDObject::Type type); // Returns a default-constructed LDObject by the given type static LDObject* getDefault (const LDObject::Type type); @@ -172,7 +172,7 @@ static void moveObjects (QList objs, const bool up); // Get a description of a list of LDObjects - static str describeObjects (const QList& objs); + static QString describeObjects (const QList& objs); static LDObject* fromID (int id); // TODO: make these private! @@ -290,17 +290,17 @@ LDOBJ_UNCOLORED LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX - PROPERTY (public, str, FileReferenced, STR_OPS, STOCK_WRITE) + PROPERTY (public, QString, FileReferenced, STR_OPS, STOCK_WRITE) public: LDError(); - LDError (str contents, str reason) : contents (contents), reason (reason) {} + LDError (QString contents, QString reason) : contents (contents), reason (reason) {} // Content of this unknown line - str contents; + QString contents; // Why is this gibberish? - str reason; + QString reason; }; // ============================================================================= @@ -335,9 +335,9 @@ public: LDComment() {} - LDComment (str text) : text (text) {} + LDComment (QString text) : text (text) {} - str text; // The text of this comment + QString text; // The text of this comment }; // ============================================================================= @@ -555,15 +555,15 @@ PROPERTY (public, int, Y, NUM_OPS, STOCK_WRITE) PROPERTY (public, int, Width, NUM_OPS, STOCK_WRITE) PROPERTY (public, int, Height, NUM_OPS, STOCK_WRITE) - PROPERTY (public, str, FileName, STR_OPS, STOCK_WRITE) + PROPERTY (public, QString, FileName, STR_OPS, STOCK_WRITE) }; // Other common LDraw stuff -static const str CALicense = "!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt", +static const QString CALicense = "!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt", NonCALicense = "!LICENSE Not redistributable : see NonCAreadme.txt"; static const int lores = 16; static const int hires = 48; -str getLicenseText (int id); +QString getLicenseText (int id); #endif // LDFORGE_LDTYPES_H diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/main.cc --- a/src/main.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/main.cc Tue Jan 07 12:21:46 2014 +0200 @@ -38,7 +38,7 @@ const QApplication* g_app = null; File g_file_stdout (stdout, File::Write); File g_file_stderr (stderr, File::Write); -static str g_versionString, g_fullVersionString; +static QString g_versionString, g_fullVersionString; const Vertex g_origin (0.0f, 0.0f, 0.0f); const Matrix g_identity ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}); @@ -91,7 +91,7 @@ // ----------------------------------------------------------------------------- void doPrint (File& f, initlist args) { - str msg = DoFormat (args); + QString msg = DoFormat (args); f.write (msg.toUtf8()); f.flush(); } @@ -100,7 +100,7 @@ // ----------------------------------------------------------------------------- void doPrint (FILE* fp, initlist args) { - str msg = DoFormat (args); + QString msg = DoFormat (args); fwrite (msg.toStdString().c_str(), 1, msg.length(), fp); fflush (fp); } diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/main.h --- a/src/main.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/main.h Tue Jan 07 12:21:46 2014 +0200 @@ -98,7 +98,7 @@ void dlog(void, ...) {} #else # ifdef DEBUG -# define dlog(...) log( str( __PRETTY_FUNCTION__ ) + ": " __VA_ARGS__) +# define dlog(...) log (QString (__PRETTY_FUNCTION__) + ": " __VA_ARGS__) # else # define dlog(...) # endif // DEBUG diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/messagelog.cc --- a/src/messagelog.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/messagelog.cc Tue Jan 07 12:21:46 2014 +0200 @@ -39,7 +39,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -MessageManager::Line::Line (str text) : +MessageManager::Line::Line (QString text) : text (text), alpha (1.0f), expiry (QDateTime::currentDateTime().addSecs (g_expiry)) {} @@ -75,7 +75,7 @@ // ============================================================================= // Add a line to the message manager. // ----------------------------------------------------------------------------- -void MessageManager::addLine (str line) +void MessageManager::addLine (QString line) { // If there's too many entries, pop the excess out while (m_lines.size() >= g_maxMessages) @@ -126,9 +126,9 @@ // ----------------------------------------------------------------------------- void DoLog (std::initializer_list args) { - const str msg = DoFormat (args); + const QString msg = DoFormat (args); - for (str& a : msg.split ("\n", QString::SkipEmptyParts)) + for (QString& a : msg.split ("\n", QString::SkipEmptyParts)) { if (g_win) g_win->addMessage (a); diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/messagelog.h --- a/src/messagelog.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/messagelog.h Tue Jan 07 12:21:46 2014 +0200 @@ -47,16 +47,16 @@ class Line { public: - Line (str text); + Line (QString text); bool update (bool& changed); - str text; + QString text; float alpha; QDateTime expiry; }; explicit MessageManager (QObject* parent = 0); - void addLine (str line); + void addLine (QString line); const QList& getLines() const; private: diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/misc.cc --- a/src/misc.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/misc.cc Tue Jan 07 12:21:46 2014 +0200 @@ -148,7 +148,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -bool numeric (const str& tok) +bool numeric (const QString& tok) { bool gotDot = false; @@ -283,7 +283,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str join (initlist vals, str delim) +QString join (initlist vals, QString delim) { QStringList list; diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/misc.h --- a/src/misc.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/misc.h Tue Jan 07 12:21:46 2014 +0200 @@ -34,14 +34,14 @@ extern const int g_primes[NUM_PRIMES]; // Returns whether a given string represents a floating point number. -bool numeric (const str& tok); +bool numeric (const QString& tok); // Simplifies the given fraction. void simplify (int& numer, int& denom); void roundToDecimals (double& a, int decimals); -str join (initlist vals, str delim = " "); +QString join (initlist vals, QString delim = " "); // Grid stuff struct gridinfo diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/primitives.cc --- a/src/primitives.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/primitives.cc Tue Jan 07 12:21:46 2014 +0200 @@ -36,7 +36,7 @@ extern_cfg (String, ld_defaultuser); extern_cfg (Int, ld_defaultlicense); -static const str g_radialNameRoots[] = +static const QStringList g_radialNameRoots = { "edge", "cyli", @@ -69,7 +69,7 @@ else { // Read primitives from prims.cfg - for (str line : conf) + for (QString line : conf) { int space = line.indexOf (" "); @@ -88,7 +88,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -static void recursiveGetFilenames (QDir dir, QList& fnames) +static void recursiveGetFilenames (QDir dir, QList& fnames) { QFileInfoList flist = dir.entryInfoList(); @@ -134,7 +134,7 @@ for (; m_i < j; ++m_i) { - str fname = m_files[m_i]; + QString fname = m_files[m_i]; File f (fname, File::Read); Primitive info; info.name = fname.mid (m_baselen + 1); // make full path relative @@ -198,7 +198,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -PrimitiveCategory::PrimitiveCategory (str name, QObject* parent) : +PrimitiveCategory::PrimitiveCategory (QString name, QObject* parent) : QObject (parent), m_Name (name) {} @@ -280,7 +280,7 @@ { PrimitiveCategory* cat = null; - for (str line : f) + for (QString line : f) { int colon; @@ -296,7 +296,7 @@ } elif (cat != null) { - str cmd = line.left (colon); + QString cmd = line.left (colon); ERegexType type = EFilenameRegex; if (cmd == "f") @@ -526,7 +526,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -static str primitiveTypeName (PrimitiveType type) +static QString primitiveTypeName (PrimitiveType type) { // Not translated as primitives are in English. return type == Circle ? "Circle" : @@ -538,7 +538,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str radialFileName (PrimitiveType type, int segs, int divs, int num) +QString radialFileName (PrimitiveType type, int segs, int divs, int num) { int numer = segs, denom = divs; @@ -554,10 +554,10 @@ } // Compose some general information: prefix, fraction, root, ring number - str prefix = (divs == lores) ? "" : fmt ("%1/", divs); - str frac = fmt ("%1-%2", numer, denom); - str root = g_radialNameRoots[type]; - str numstr = (type == Ring || type == Cone) ? fmt ("%1", num) : ""; + QString prefix = (divs == lores) ? "" : fmt ("%1/", divs); + QString frac = fmt ("%1-%2", numer, denom); + QString root = g_radialNameRoots[type]; + QString numstr = (type == Ring || type == Cone) ? fmt ("%1", num) : ""; // Truncate the root if necessary (7-16rin4.dat for instance). // However, always keep the root at least 2 characters. @@ -573,9 +573,9 @@ LDDocument* generatePrimitive (PrimitiveType type, int segs, int divs, int num) { // Make the description - str frac = str::number ((float) segs / divs); - str name = radialFileName (type, segs, divs, num); - str descr; + QString frac = QString::number ((float) segs / divs); + QString name = radialFileName (type, segs, divs, num); + QString descr; // Ensure that there's decimals, even if they're 0. if (frac.indexOf (".") == -1) @@ -583,7 +583,7 @@ if (type == Ring || type == Cone) { - str spacing = + QString spacing = (num < 10) ? " " : (num < 100) ? " " : ""; @@ -599,8 +599,8 @@ LDDocument* f = new LDDocument; f->setDefaultName (name); - str author = APPNAME; - str license = ""; + QString author = APPNAME; + QString license = ""; if (ld_defaultname.isEmpty() == false) { @@ -628,7 +628,7 @@ // ----------------------------------------------------------------------------- LDDocument* getPrimitive (PrimitiveType type, int segs, int divs, int num) { - str name = radialFileName (type, segs, divs, num); + QString name = radialFileName (type, segs, divs, num); LDDocument* f = getDocument (name); if (f != null) diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/primitives.h --- a/src/primitives.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/primitives.h Tue Jan 07 12:21:46 2014 +0200 @@ -29,14 +29,14 @@ class PrimitiveCategory; struct Primitive { - str name, title; + QString name, title; PrimitiveCategory* cat; }; class PrimitiveCategory : public QObject { Q_OBJECT - PROPERTY (public, str, Name, STR_OPS, STOCK_WRITE) + PROPERTY (public, QString, Name, STR_OPS, STOCK_WRITE) public: enum ERegexType @@ -54,7 +54,7 @@ QList regexes; QList prims; - explicit PrimitiveCategory (str name, QObject* parent = 0); + explicit PrimitiveCategory (QString name, QObject* parent = 0); bool isValidToInclude(); static void loadCategories(); @@ -129,6 +129,6 @@ // be automatically generated. LDDocument* getPrimitive (PrimitiveType type, int segs, int divs, int num); -str radialFileName (PrimitiveType type, int segs, int divs, int num); +QString radialFileName (PrimitiveType type, int segs, int divs, int num); #endif // LDFORGE_PRIMITIVES_H diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/types.cc --- a/src/types.cc Tue Jan 07 12:06:12 2014 +0200 +++ b/src/types.cc Tue Jan 07 12:21:46 2014 +0200 @@ -29,10 +29,10 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str DoFormat (QList args) +QString DoFormat (QList args) { assert (args.size() >= 1); - str text = args[0].value(); + QString text = args[0].value(); for (uchar i = 1; i < args.size(); ++i) text = text.arg (args[i].value()); @@ -81,9 +81,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str Vertex::stringRep (bool mangled) const +QString Vertex::stringRep (bool mangled) const { - str fmtstr = "%1 %2 %3"; + QString fmtstr = "%1 %2 %3"; if (mangled) fmtstr = "(%1, %2, %3)"; @@ -245,16 +245,16 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str Matrix::stringRep() const +QString Matrix::stringRep() const { - str val; + QString val; for (int i = 0; i < 9; ++i) { if (i > 0) val += ' '; - val += str::number (m_vals[i]); + val += QString::number (m_vals[i]); } return val; @@ -315,7 +315,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -StringFormatArg::StringFormatArg (const str& v) +StringFormatArg::StringFormatArg (const QString& v) { m_val = v; } @@ -337,12 +337,12 @@ StringFormatArg::StringFormatArg (const float& v) { - m_val = str::number (v); + m_val = QString::number (v); } StringFormatArg::StringFormatArg (const double& v) { - m_val = str::number (v); + m_val = QString::number (v); } StringFormatArg::StringFormatArg (const Vertex& v) @@ -374,7 +374,7 @@ m_textstream = null; } -File::File (str path, OpenType rtype) +File::File (QString path, OpenType rtype) { m_file = null; m_path = path; @@ -408,7 +408,7 @@ return open ("", rtype, fp); } -bool File::open (str path, OpenType rtype, FILE* fp) +bool File::open (QString path, OpenType rtype, FILE* fp) { close(); @@ -454,14 +454,14 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void File::write (str msg) +void File::write (QString msg) { m_file->write (msg.toUtf8(), msg.length()); } // ============================================================================= // ----------------------------------------------------------------------------- -bool File::readLine (str& line) +bool File::readLine (QString& line) { if (!m_textstream || m_textstream->atEnd()) return false; @@ -544,7 +544,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str File::iterator::operator*() +QString File::iterator::operator*() { return m_text; } diff -r 2983f7c7e7c9 -r 3dd6f343ec06 src/types.h --- a/src/types.h Tue Jan 07 12:06:12 2014 +0200 +++ b/src/types.h Tue Jan 07 12:21:46 2014 +0200 @@ -29,7 +29,6 @@ class QFile; class QTextStream; -using str = QString; using int8 = qint8; using int16 = qint16; using int32 = qint32; @@ -70,7 +69,7 @@ double getDeterminant() const; Matrix mult (Matrix other) const; void puts() const; - str stringRep() const; + QString stringRep() const; void zero(); Matrix& operator= (Matrix other); @@ -122,7 +121,7 @@ double distanceTo (const Vertex& other) const; Vertex midpoint (const Vertex& other); void move (const Vertex& other); - str stringRep (bool mangled) const; + QString stringRep (bool mangled) const; void transform (Matrix matr, Vertex pos); Vertex& operator+= (const Vertex& other); @@ -193,7 +192,7 @@ class StringFormatArg { public: - StringFormatArg (const str& v); + StringFormatArg (const QString& v); StringFormatArg (const char& v); StringFormatArg (const uchar& v); StringFormatArg (const QChar& v); @@ -240,12 +239,12 @@ m_val += "}"; } - str value() const + QString value() const { return m_val; } private: - str m_val; + QString m_val; }; // ============================================================================= @@ -265,13 +264,13 @@ iterator() : m_file (null) {} // end iterator has m_file == null iterator (File* f); void operator++(); - str operator*(); + QString operator*(); bool operator== (iterator& other); bool operator!= (iterator& other); private: File* m_file; - str m_text; + QString m_text; bool m_gotdata = false; }; @@ -284,7 +283,7 @@ }; File(); - File (str path, File::OpenType rtype); + File (QString path, File::OpenType rtype); File (FILE* fp, File::OpenType rtype); ~File(); @@ -294,22 +293,22 @@ iterator& end(); bool flush(); bool isNull() const; - bool readLine (str& line); + bool readLine (QString& line); void rewind(); bool open (FILE* fp, OpenType rtype); - bool open (str path, OpenType rtype, FILE* fp = null); - void write (str msg); + bool open (QString path, OpenType rtype, FILE* fp = null); + void write (QString msg); bool operator!() const; operator bool() const; - inline str getPath() const { return m_path; } + inline QString getPath() const { return m_path; } private: QFile* m_file; QTextStream* m_textstream; iterator m_endIterator; - str m_path; + QString m_path; }; // ============================================================================= @@ -338,7 +337,7 @@ }; // Formatter function -str DoFormat (QList args); +QString DoFormat (QList args); // printf replacement void doPrint (File& f, initlist args); @@ -354,7 +353,7 @@ # define fprint(F, ...) doPrint (F, {__VA_ARGS__}) # define log(...) DoLog({ __VA_ARGS__ }) #else -str fmt (const char* fmtstr, ...); +QString fmt (const char* fmtstr, ...); void fprint (File& f, const char* fmtstr, ...); void log (const char* fmtstr, ...); #endif