Sat, 28 Jan 2017 14:13:01 +0200
Replaced '.length()' with 'length()' where appropriate
--- a/src/addObjectDialog.cpp Sat Jan 28 14:01:19 2017 +0200 +++ b/src/addObjectDialog.cpp Sat Jan 28 14:13:01 2017 +0200 @@ -269,7 +269,7 @@ { QString name = currentSubfileName(); - if (name.length() > 0) + if (not name.isEmpty()) le_subfileName->setText (name); } @@ -366,7 +366,7 @@ { QString name = dlg.le_subfileName->text(); - if (name.length() == 0) + if (name.isEmpty()) return; // no subfile filename LDDocument* document = g_win->documents()->getDocumentByName (name);
--- a/src/basics.h Sat Jan 28 14:01:19 2017 +0200 +++ b/src/basics.h Sat Jan 28 14:13:01 2017 +0200 @@ -92,6 +92,11 @@ Q_DECLARE_METATYPE (Vertex) uint qHash(const Vertex& key); +static inline qreal abs(const QVector3D &vector) +{ + return vector.length(); +} + // // Defines a bounding box that encompasses a given set of objects. // vertex0 is the minimum vertex, vertex1 is the maximum vertex.
--- a/src/dialogs/configdialog.cpp Sat Jan 28 14:01:19 2017 +0200 +++ b/src/dialogs/configdialog.cpp Sat Jan 28 14:13:01 2017 +0200 @@ -655,7 +655,7 @@ for (const ColorToolbarItem& entry : quickColors) { - if (val.length() > 0) + if (not val.isEmpty()) val += ':'; if (entry.isSeparator())
--- a/src/editmodes/abstractEditMode.cpp Sat Jan 28 14:01:19 2017 +0200 +++ b/src/editmodes/abstractEditMode.cpp Sat Jan 28 14:13:01 2017 +0200 @@ -190,7 +190,7 @@ if (not m_config->drawLineLengths()) return; - const QString label = QString::number ((v1 - v0).length(), 'f', 2); + const QString label = QString::number(abs(v1 - v0), 'f', 2); QPoint origin = QLineF (v0p, v1p).pointAt (0.5).toPoint(); painter.drawText (origin, label); }
--- a/src/ldDocument.cpp Sat Jan 28 14:01:19 2017 +0200 +++ b/src/ldDocument.cpp Sat Jan 28 14:13:01 2017 +0200 @@ -221,12 +221,12 @@ case msgbox::Yes: { // If we don't have a file path yet, we have to ask the user for one. - if (name().length() == 0) + if (name().isEmpty()) { QString newpath = QFileDialog::getSaveFileName (m_window, QObject::tr ("Save As"), name(), QObject::tr ("LDraw files (*.dat *.ldr)")); - if (newpath.length() == 0) + if (newpath.isEmpty()) return false; setName (newpath); @@ -264,7 +264,7 @@ if (isCache()) return false; - if (not path.length()) + if (path.isEmpty()) path = fullPath(); // If the second object in the list holds the file name, update that now. @@ -401,7 +401,7 @@ return LDSpawn<LDEmpty>(); } - if (tokens[0].length() != 1 or not tokens[0][0].isDigit()) + if (length(tokens[0]) != 1 or not tokens[0][0].isDigit()) throw QString ("Illogical line code"); int num = tokens[0][0].digitValue();
--- a/src/partdownloader.cpp Sat Jan 28 14:01:19 2017 +0200 +++ b/src/partdownloader.cpp Sat Jan 28 14:13:01 2017 +0200 @@ -106,8 +106,8 @@ // Remove the existing extension, if any. It may be we're here over a typo in the .dat extension. int dotPosition = destination.lastIndexOf("."); - if ((dotPosition != -1) and (dotPosition >= destination.length() - 4)) - destination.chop (destination.length() - dotPosition); + if ((dotPosition != -1) and (dotPosition >= length(destination) - 4)) + destination.chop(length(destination) - dotPosition); destination += ".dat"; }
--- a/src/primitives.cpp Sat Jan 28 14:01:19 2017 +0200 +++ b/src/primitives.cpp Sat Jan 28 14:13:01 2017 +0200 @@ -189,7 +189,7 @@ { QString line = QString::fromUtf8(categoriesFile.readLine()).trimmed(); - if (line.length() == 0 or line[0] == '#') + if (line.isEmpty() or line[0] == '#') continue; int colon = line.indexOf (":"); @@ -436,7 +436,7 @@ // Truncate the root if necessary (7-16rin4.dat for instance). // However, always keep the root at least 2 characters. - int extra = (frac.length() + numberString.length() + root.length()) - 8; + int extra = (length(frac) + length(numberString) + length(root)) - 8; root.chop(qBound(0, extra, 2)); // Stick them all together and return the result. @@ -581,7 +581,7 @@ m_manager(parent), m_iterator(LDPaths::primitivesDir(), QDirIterator::Subdirectories) { - m_basePathLength = LDPaths::primitivesDir().absolutePath().length(); + m_basePathLength = length(LDPaths::primitivesDir().absolutePath()); print("Scanning primitives..."); }
--- a/src/toolsets/algorithmtoolset.cpp Sat Jan 28 14:01:19 2017 +0200 +++ b/src/toolsets/algorithmtoolset.cpp Sat Jan 28 14:13:01 2017 +0200 @@ -513,7 +513,7 @@ digits.setNum (subidx++); // pad it with a zero - if (digits.length() == 1) + if (length(digits) == 1) digits.prepend ("0"); fullsubname = subdirname + "/" + Basename (parentpath) + "s" + digits + ".dat";
--- a/src/toolsets/filetoolset.cpp Sat Jan 28 14:01:19 2017 +0200 +++ b/src/toolsets/filetoolset.cpp Sat Jan 28 14:13:01 2017 +0200 @@ -147,10 +147,10 @@ QString filePath = QFileDialog::getSaveFileName(); - if (filePath.length() == 0) + if (filePath.isEmpty()) return; - QFile file = {filePath}; + QFile file {filePath}; if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
--- a/src/toolsets/viewtoolset.cpp Sat Jan 28 14:01:19 2017 +0200 +++ b/src/toolsets/viewtoolset.cpp Sat Jan 28 14:13:01 2017 +0200 @@ -117,7 +117,7 @@ if (root.right (4) == ".dat") root.chop (4); - QString defaultname = (root.length() > 0) ? format ("%1.png", root) : ""; + QString defaultname = (not root.isEmpty()) ? format ("%1.png", root) : ""; QString filename = QFileDialog::getSaveFileName (m_window, "Save Screencap", defaultname, imageformats); if (not filename.isEmpty() and not image.save (filename))