Wed, 05 Mar 2014 05:30:36 +0200
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
--- a/CMakeLists.txt Wed Mar 05 03:45:49 2014 +0200 +++ b/CMakeLists.txt Wed Mar 05 05:30:36 2014 +0200 @@ -47,7 +47,7 @@ ) set (LDForgeHeaders - src/PropertyMacro.h + src/Macros.h src/CrashCatcher.h src/Colors.h src/misc/DocumentPointer.h
--- a/src/AddObjectDialog.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/AddObjectDialog.cc Wed Mar 05 05:30:36 2014 +0200 @@ -36,23 +36,23 @@ #include "Primitives.h" // ============================================================================= -// ============================================================================= +// class SubfileListItem : public QTreeWidgetItem { - PROPERTY (public, Primitive*, PrimitiveInfo, NO_OPS, STOCK_WRITE) + PROPERTY (public, Primitive*, primitive, setPrimitive, STOCK_WRITE) public: SubfileListItem (QTreeWidgetItem* parent, Primitive* info) : QTreeWidgetItem (parent), - m_PrimitiveInfo (info) {} + m_primitive (info) {} SubfileListItem (QTreeWidget* parent, Primitive* info) : QTreeWidgetItem (parent), - m_PrimitiveInfo (info) {} + m_primitive (info) {} }; // ============================================================================= -// ============================================================================= +// AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObject* obj, QWidget* parent) : QDialog (parent) { @@ -68,7 +68,7 @@ le_comment = new QLineEdit; if (obj) - le_comment->setText (static_cast<LDComment*> (obj)->text); + le_comment->setText (static_cast<LDComment*> (obj)->text()); le_comment->setMinimumWidth (384); } break; @@ -108,7 +108,7 @@ } if (obj) - rb_bfcType->setValue ( (int) static_cast<LDBFC*> (obj)->m_statement); + rb_bfcType->setValue ( (int) static_cast<LDBFC*> (obj)->statement()); } break; case LDObject::ESubfile: @@ -120,7 +120,7 @@ for (PrimitiveCategory* cat : g_PrimitiveCategories) { SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, null); - parentItem->setText (0, cat->getName()); + parentItem->setText (0, cat->name()); QList<QTreeWidgetItem*> subfileItems; for (Primitive& prim : cat->prims) @@ -131,7 +131,7 @@ // If this primitive is the one the current object points to, // select it by default - if (obj && static_cast<LDSubfile*> (obj)->getFileInfo()->getName() == prim.name) + if (obj && static_cast<LDSubfile*> (obj)->fileInfo()->name() == prim.name) tw_subfileList->setCurrentItem (item); } @@ -146,7 +146,7 @@ if (obj) { LDSubfile* ref = static_cast<LDSubfile*> (obj); - le_subfileName->setText (ref->getFileInfo()->getName()); + le_subfileName->setText (ref->fileInfo()->name()); } } break; @@ -166,7 +166,7 @@ if (defaults->isColored()) { if (obj != null) - colnum = obj->getColor(); + colnum = obj->color(); else colnum = (type == LDObject::ECondLine || type == LDObject::ELine) ? edgecolor : maincolor; @@ -233,9 +233,9 @@ if (mo) { for_axes (ax) - dsb_coords[ax]->setValue (mo->getPosition()[ax]); + dsb_coords[ax]->setValue (mo->position()[ax]); - defaultMatrix = mo->getTransform(); + defaultMatrix = mo->transform(); } le_matrix->setText (defaultMatrix.toString()); @@ -271,7 +271,7 @@ // ============================================================================= void AddObjectDialog::setButtonBackground (QPushButton* button, int colnum) { - LDColor* col = getColor (colnum); + LDColor* col = ::getColor (colnum); button->setIcon (getIcon ("palette")); button->setAutoFillBackground (true); @@ -286,10 +286,10 @@ { SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem()); - if (item->getPrimitiveInfo() == null) + if (item->primitive() == null) return ""; // selected a heading - return item->getPrimitiveInfo()->name; + return item->primitive()->name; } // ============================================================================= @@ -363,7 +363,7 @@ case LDObject::EComment: { LDComment* comm = initObj<LDComment> (obj); - comm->text = dlg.le_comment->text(); + comm->setText (dlg.le_comment->text()); } break; @@ -389,7 +389,7 @@ case LDObject::EBFC: { LDBFC* bfc = initObj<LDBFC> (obj); - bfc->m_statement = (LDBFC::Statement) dlg.rb_bfcType->value(); + bfc->setStatement ((LDBFC::Statement) dlg.rb_bfcType->value()); } break; case LDObject::EVertex:
--- a/src/ColorSelector.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/ColorSelector.cc Wed Mar 05 05:30:36 2014 +0200 @@ -115,7 +115,7 @@ numtext->setDefaultTextColor ( (luma (col) < 80) ? Qt::white : Qt::black); numtext->setPos (x, y); - if (getSelection() && i == getSelection()->index) + if (selection() && i == selection()->index) { auto curspic = m_scene->addPixmap (getIcon ("colorcursor")); curspic->setPos (x, y); @@ -141,13 +141,13 @@ // ============================================================================= void ColorSelector::drawColorInfo() { - if (!getSelection()) + if (!selection()) { ui->colorLabel->setText ("---"); return; } - ui->colorLabel->setText (fmt ("%1 - %2", getSelection()->index, getSelection()->name)); + ui->colorLabel->setText (fmt ("%1 - %2", selection()->index, selection()->name)); } // ============================================================================= @@ -161,9 +161,9 @@ { int visibleColors = (ui->viewport->height() / g_squareSize) * g_numColumns; - if (getSelection() && getSelection()->index >= visibleColors) + if (selection() && selection()->index >= visibleColors) { - int y = (getSelection()->index / g_numColumns) * g_squareSize; + int y = (selection()->index / g_numColumns) * g_squareSize; ui->viewport->verticalScrollBar()->setValue (y); } @@ -200,9 +200,9 @@ { ColorSelector dlg (defval, parent); - if (dlg.exec() && dlg.getSelection() != null) + if (dlg.exec() && dlg.selection() != null) { - val = dlg.getSelection()->index; + val = dlg.selection()->index; return true; }
--- a/src/ColorSelector.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/ColorSelector.h Wed Mar 05 05:30:36 2014 +0200 @@ -27,7 +27,7 @@ class ColorSelector : public QDialog { Q_OBJECT - PROPERTY (private, LDColor*, Selection, NO_OPS, STOCK_WRITE) + PROPERTY (private, LDColor*, selection, setSelection, STOCK_WRITE) public: explicit ColorSelector (int defval = -1, QWidget* parent = null);
--- a/src/Configuration.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Configuration.cc Wed Mar 05 05:30:36 2014 +0200 @@ -53,7 +53,7 @@ } Config::Config (QString name) : - m_Name (name) {} + m_name (name) {} // ============================================================================= // Load the configuration from file @@ -68,9 +68,9 @@ if (!cfg) break; - QVariant val = settings->value (cfg->getName(), cfg->getDefaultAsVariant()); + QVariant val = settings->value (cfg->name(), cfg->getDefaultAsVariant()); cfg->loadFromVariant (val); - g_configsByName[cfg->getName()] = cfg; + g_configsByName[cfg->name()] = cfg; g_configs << cfg; } @@ -89,9 +89,9 @@ for (Config* cfg : g_configs) { if (!cfg->isDefault()) - settings->setValue (cfg->getName(), cfg->toVariant()); + settings->setValue (cfg->name(), cfg->toVariant()); else - settings->remove (cfg->getName()); + settings->remove (cfg->name()); } settings->sync();
--- a/src/Configuration.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Configuration.h Wed Mar 05 05:30:36 2014 +0200 @@ -20,7 +20,7 @@ #include <QString> #include <QVariant> #include <QKeySequence> -#include "PropertyMacro.h" +#include "Macros.h" #include "Types.h" class QSettings; @@ -37,7 +37,7 @@ // ========================================================= class Config { - PROPERTY (private, QString, Name, STR_OPS, STOCK_WRITE) + PROPERTY (private, QString, name, setName, STOCK_WRITE) public: enum Type
--- a/src/ConfigurationDialog.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/ConfigurationDialog.cc Wed Mar 05 05:30:36 2014 +0200 @@ -411,7 +411,7 @@ } else { - LDColor* col = entry.getColor(); + LDColor* col = entry.color(); if (col == null) { @@ -459,7 +459,7 @@ return; // don't color separators } - int defval = entry ? entry->getColor()->index : -1; + int defval = entry ? entry->color()->index : -1; int val; if (ColorSelector::selectColor (val, defval, this) == false) @@ -519,8 +519,9 @@ } // ============================================================================= +// // Add a separator to quick colors -// ============================================================================= +// void ConfigDialog::slot_addColorSeparator() { quickColors << LDQuickColor::getSeparator(); @@ -528,8 +529,9 @@ } // ============================================================================= +// // Clear all quick colors -// ============================================================================= +// void ConfigDialog::slot_clearColors() { quickColors.clear(); @@ -537,8 +539,9 @@ } // ============================================================================= +// // Pick a color and set the appropriate configuration option. -// ============================================================================= +// void ConfigDialog::pickColor (QString& conf, QPushButton* button) { QColor col = QColorDialog::getColor (QColor (conf)); @@ -641,7 +644,7 @@ ShortcutListItem* item = sel[0]; - if (KeySequenceDialog::staticDialog (item->getKeyConfig(), this)) + if (KeySequenceDialog::staticDialog (item->keyConfig(), this)) setShortcutText (item); } @@ -654,7 +657,7 @@ for (ShortcutListItem* item : sel) { - item->getKeyConfig()->reset(); + item->keyConfig()->reset(); setShortcutText (item); } } @@ -668,7 +671,7 @@ for (ShortcutListItem* item : sel) { - item->getKeyConfig()->setValue (QKeySequence()); + item->keyConfig()->setValue (QKeySequence()); setShortcutText (item); } } @@ -699,8 +702,9 @@ } // ============================================================================= +// // '...' button pressed for the download path -// ============================================================================= +// void ConfigDialog::slot_findDownloadFolder() { QString dpath = QFileDialog::getExistingDirectory(); @@ -708,13 +712,14 @@ } // ============================================================================= +// // Updates the text string for a given shortcut list item -// ============================================================================= +// void ConfigDialog::setShortcutText (ShortcutListItem* item) { - QAction* act = item->getAction(); + QAction* act = item->action(); QString label = act->iconText(); - QString keybind = item->getKeyConfig()->getValue().toString(); + QString keybind = item->keyConfig()->getValue().toString(); item->setText (fmt ("%1 (%2)", label, keybind)); } @@ -733,7 +738,7 @@ if (entry.isSeparator()) val += '|'; else - val += fmt ("%1", entry.getColor()->index); + val += fmt ("%1", entry.color()->index); } return val;
--- a/src/ConfigurationDialog.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/ConfigurationDialog.h Wed Mar 05 05:30:36 2014 +0200 @@ -27,8 +27,8 @@ // ============================================================================= class ShortcutListItem : public QListWidgetItem { - PROPERTY (public, KeySequenceConfig*, KeyConfig, NO_OPS, STOCK_WRITE) - PROPERTY (public, QAction*, Action, NO_OPS, STOCK_WRITE) + PROPERTY (public, KeySequenceConfig*, keyConfig, setKeyConfig, STOCK_WRITE) + PROPERTY (public, QAction*, action, setAction, STOCK_WRITE) public: explicit ShortcutListItem (QListWidget* view = null, int type = Type) :
--- a/src/Dialogs.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Dialogs.cc Wed Mar 05 05:30:36 2014 +0200 @@ -267,7 +267,7 @@ ui->setupUi (this); ui->progressText->setText ("Parsing..."); setNumLines (0); - m_Progress = 0; + m_progress = 0; } // ============================================================================= @@ -281,8 +281,8 @@ // ============================================================================= void OpenProgressDialog::setNumLines (int const& a) { - m_NumLines = a; - ui->progressBar->setRange (0, getNumLines()); + m_numLines = a; + ui->progressBar->setRange (0, numLines()); updateValues(); } @@ -290,8 +290,8 @@ // ============================================================================= void OpenProgressDialog::updateValues() { - ui->progressText->setText (fmt ("Parsing... %1 / %2", getProgress(), getNumLines())); - ui->progressBar->setValue (getProgress()); + ui->progressText->setText (fmt ("Parsing... %1 / %2", progress(), numLines())); + ui->progressBar->setValue (progress()); } // =============================================================================
--- a/src/Dialogs.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Dialogs.h Wed Mar 05 05:30:36 2014 +0200 @@ -93,8 +93,8 @@ class OpenProgressDialog : public QDialog { Q_OBJECT - PROPERTY (public, int, Progress, NUM_OPS, STOCK_WRITE) - PROPERTY (public, int, NumLines, NUM_OPS, CUSTOM_WRITE) + PROPERTY (public, int, progress, setProgress, STOCK_WRITE) + PROPERTY (public, int, numLines, setNumLines, CUSTOM_WRITE) public: explicit OpenProgressDialog (QWidget* parent = null, Qt::WindowFlags f = 0);
--- a/src/Document.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Document.cc Wed Mar 05 05:30:36 2014 +0200 @@ -46,7 +46,7 @@ const QStringList g_specialSubdirectories ({ "s", "48", "8" }); // ============================================================================= -// ============================================================================= +// namespace LDPaths { static QString pathError; @@ -119,7 +119,7 @@ } // ============================================================================= -// ============================================================================= +// LDDocument::LDDocument() : m_gldata (new LDGLData) { @@ -127,28 +127,28 @@ setSavePosition (-1); setTabIndex (-1); setHistory (new History); - m_History->setDocument (this); + history()->setDocument (this); } // ============================================================================= -// ============================================================================= +// LDDocument::~LDDocument() { // Remove this file from the list of files. This MUST be done FIRST, otherwise // a ton of other functions will think this file is still valid when it is not! g_loadedFiles.removeOne (this); - m_History->setIgnoring (true); + m_history->setIgnoring (true); // Clear everything from the model - for (LDObject* obj : getObjects()) + for (LDObject* obj : objects()) obj->destroy(); // Clear the cache as well - for (LDObject* obj : getCache()) + for (LDObject* obj : cache()) obj->destroy(); - delete m_History; + delete m_history; delete m_gldata; // If we just closed the current file, we need to set the current @@ -179,22 +179,22 @@ g_logoedStud2 = null; g_win->updateDocumentList(); - log ("Closed %1", getName()); + log ("Closed %1", name()); } // ============================================================================= -// ============================================================================= +// LDDocument* findDocument (QString name) { for (LDDocument * file : g_loadedFiles) - if (!file->getName().isEmpty() && file->getName() == name) + if (!file->name().isEmpty() && file->name() == name) return file; return null; } // ============================================================================= -// ============================================================================= +// QString dirname (QString path) { long lastpos = path.lastIndexOf (DIRSLASH); @@ -211,7 +211,7 @@ } // ============================================================================= -// ============================================================================= +// QString basename (QString path) { long lastpos = path.lastIndexOf (DIRSLASH); @@ -223,7 +223,7 @@ } // ============================================================================= -// ============================================================================= +// static QString findLDrawFilePath (QString relpath, bool subdirs) { QString fullPath; @@ -241,10 +241,10 @@ for (LDDocument* doc : g_loadedFiles) { - if (doc->getFullPath().isEmpty()) + if (doc->fullPath().isEmpty()) continue; - QString partpath = fmt ("%1/%2", dirname (doc->getFullPath()), relpath); + QString partpath = fmt ("%1/%2", dirname (doc->fullPath()), relpath); QFile f (partpath); if (f.exists()) @@ -318,7 +318,7 @@ } // ============================================================================= -// ============================================================================= +// void LDFileLoader::start() { setDone (false); @@ -334,7 +334,7 @@ // Of course we cannot exec() the dialog because then the dialog would // block. dlg = new OpenProgressDialog (g_win); - dlg->setNumLines (getLines().size()); + dlg->setNumLines (lines().size()); dlg->setModal (true); dlg->show(); @@ -350,16 +350,16 @@ } // ============================================================================= -// ============================================================================= +// void LDFileLoader::work (int i) { // User wishes to abort, so stop here now. if (isAborted()) { - for (LDObject* obj : m_Objects) + for (LDObject* obj : m_objects) obj->destroy(); - m_Objects.clear(); + m_objects.clear(); setDone (true); return; } @@ -367,9 +367,9 @@ // Parse up to 300 lines per iteration int max = i + 300; - for (; i < max && i < (int) getLines().size(); ++i) + for (; i < max && i < (int) lines().size(); ++i) { - QString line = getLines()[i]; + QString line = lines()[i]; // Trim the trailing newline QChar c; @@ -382,13 +382,13 @@ // Check for parse errors and warn about tthem if (obj->type() == LDObject::EError) { - log ("Couldn't parse line #%1: %2", getProgress() + 1, static_cast<LDError*> (obj)->reason); + log ("Couldn't parse line #%1: %2", progress() + 1, static_cast<LDError*> (obj)->reason()); - if (getWarnings() != null) - (*getWarnings())++; + if (warnings() != null) + (*warnings())++; } - m_Objects << obj; + m_objects << obj; setProgress (i); // If we have a dialog pointer, update the progress now @@ -397,7 +397,7 @@ } // If we're done now, tell the environment we're done and stop. - if (i >= ((int) getLines().size()) - 1) + if (i >= ((int) lines().size()) - 1) { emit workDone(); setDone (true); @@ -425,7 +425,7 @@ } // ============================================================================= -// ============================================================================= +// void LDFileLoader::abort() { setAborted (true); @@ -435,7 +435,7 @@ } // ============================================================================= -// ============================================================================= +// LDObjectList loadFileContents (QFile* fp, int* numWarnings, bool* ok) { QStringList lines; @@ -465,12 +465,12 @@ if (ok) *ok = !loader->isAborted(); - objs = loader->getObjects(); + objs = loader->objects(); return objs; } // ============================================================================= -// ============================================================================= +// LDDocument* openDocument (QString path, bool search) { // Convert the file name to lowercase since some parts contain uppercase @@ -498,12 +498,12 @@ LDDocument* load = new LDDocument; load->setFullPath (fullpath); - load->setName (LDDocument::shortenName (load->getFullPath())); - dlog ("name: %1 (%2)", load->getName(), load->getFullPath()); + load->setName (LDDocument::shortenName (load->fullPath())); + dlog ("name: %1 (%2)", load->name(), load->fullPath()); g_loadedFiles << load; // Don't take the file loading as actual edits to the file - load->getHistory()->setIgnoring (true); + load->history()->setIgnoring (true); int numWarnings; bool ok; @@ -523,16 +523,16 @@ if (g_loadingMainFile) { LDDocument::setCurrent (load); - g_win->R()->setFile (load); + g_win->R()->setDocument (load); log (QObject::tr ("File %1 parsed successfully (%2 errors)."), path, numWarnings); } - load->getHistory()->setIgnoring (false); + load->history()->setIgnoring (false); return load; } // ============================================================================= -// ============================================================================= +// bool LDDocument::isSafeToClose() { typedef QMessageBox msgbox; @@ -542,7 +542,7 @@ if (hasUnsavedChanges()) { QString message = fmt (tr ("There are unsaved changes to %1. Should it be saved?"), - (getName().length() > 0) ? getName() : tr ("<anonymous>")); + (name().length() > 0) ? name() : tr ("<anonymous>")); int button = msgbox::question (g_win, tr ("Unsaved Changes"), message, (msgbox::Yes | msgbox::No | msgbox::Cancel), msgbox::Cancel); @@ -552,10 +552,10 @@ case msgbox::Yes: { // If we don't have a file path yet, we have to ask the user for one. - if (getName().length() == 0) + if (name().length() == 0) { QString newpath = QFileDialog::getSaveFileName (g_win, tr ("Save As"), - getCurrentDocument()->getName(), tr ("LDraw files (*.dat *.ldr)")); + getCurrentDocument()->name(), tr ("LDraw files (*.dat *.ldr)")); if (newpath.length() == 0) return false; @@ -566,7 +566,7 @@ if (!save()) { message = fmt (tr ("Failed to save %1 (%2)\nDo you still want to close?"), - getName(), strerror (errno)); + name(), strerror (errno)); if (msgbox::critical (g_win, tr ("Save Failure"), message, (msgbox::Yes | msgbox::No), msgbox::No) == msgbox::No) @@ -588,7 +588,7 @@ } // ============================================================================= -// ============================================================================= +// void closeAll() { // Remove all loaded files and the objects they contain @@ -599,7 +599,7 @@ } // ============================================================================= -// ============================================================================= +// void newFile() { // Create a new anonymous file and set it to our current @@ -609,14 +609,14 @@ g_loadedFiles << f; LDDocument::setCurrent (f); LDDocument::closeInitialFile(); - g_win->R()->setFile (f); + g_win->R()->setDocument (f); g_win->doFullRefresh(); g_win->updateTitle(); g_win->updateActions(); } // ============================================================================= -// ============================================================================= +// void addRecentFile (QString path) { auto& rfiles = io_recentfiles; @@ -656,7 +656,7 @@ for (LDDocument* doc : g_loadedFiles) { - if (doc->getName() == shortName) + if (doc->name() == shortName) { documentToReplace = doc; break; @@ -695,14 +695,14 @@ // Replace references to the old file with the new file. if (documentToReplace != null) { - for (LDDocumentPointer* ptr : documentToReplace->getReferences()) + for (LDDocumentPointer* ptr : documentToReplace->references()) { dlog ("ptr: %1 (%2)\n", - ptr, ptr->getPointer() ? ptr->getPointer()->getName() : "<null>"); + ptr, ptr->pointer() ? ptr->pointer()->name() : "<null>"); - ptr->operator= (file); + *ptr = file; } - assert (documentToReplace->countReferences() == 0); + assert (documentToReplace->references().isEmpty()); delete documentToReplace; } @@ -720,11 +720,11 @@ } // ============================================================================= -// ============================================================================= +// bool LDDocument::save (QString savepath) { if (!savepath.length()) - savepath = getFullPath(); + savepath = fullPath(); QFile f (savepath); @@ -739,24 +739,24 @@ { LDComment* nameComment = static_cast<LDComment*> (nameObject); - if (nameComment->text.left (6) == "Name: ") + if (nameComment->text().left (6) == "Name: ") { QString newname = shortenName (savepath); - nameComment->text = fmt ("Name: %1", newname); + nameComment->setText (fmt ("Name: %1", newname)); g_win->buildObjList(); } } // File is open, now save the model to it. Note that LDraw requires files to // have DOS line endings, so we terminate the lines with \r\n. - for (LDObject* obj : getObjects()) + for (LDObject* obj : objects()) f.write ((obj->asText() + "\r\n").toUtf8()); // File is saved, now clean up. f.close(); // We have successfully saved, update the save position now. - setSavePosition (getHistory()->getPosition()); + setSavePosition (history()->position()); setFullPath (savepath); setName (shortenName (savepath)); @@ -766,23 +766,25 @@ } // ============================================================================= -// ============================================================================= +// class LDParseError : public std::exception { - PROPERTY (private, QString, Error, STR_OPS, STOCK_WRITE) - PROPERTY (private, QString, Line, STR_OPS, STOCK_WRITE) + PROPERTY (private, QString, error, setError, STOCK_WRITE) + PROPERTY (private, QString, line, setLine, STOCK_WRITE) public: - LDParseError (QString line, QString a) : m_Error (a), m_Line (line) {} + LDParseError (QString line, QString a) : + m_error (a), + m_line (line) {} const char* what() const throw() { - return getError().toLocal8Bit().constData(); + return qPrintable (error()); } }; // ============================================================================= -// ============================================================================= +// void checkTokenCount (QString line, const QStringList& tokens, int num) { if (tokens.size() != num) @@ -790,7 +792,7 @@ } // ============================================================================= -// ============================================================================= +// void checkTokenNumbers (QString line, const QStringList& tokens, int min, int max) { bool ok; @@ -808,7 +810,7 @@ } // ============================================================================= -// ============================================================================= +// static Vertex parseVertex (QStringList& s, const int n) { Vertex v; @@ -908,7 +910,7 @@ // Just a regular comment: LDComment* obj = new LDComment; - obj->text = comm; + obj->setText (comm); return obj; } @@ -1006,12 +1008,12 @@ } catch (LDParseError& e) { - return new LDError (e.getLine(), e.getError()); + return new LDError (e.line(), e.error()); } } // ============================================================================= -// ============================================================================= +// LDDocument* getDocument (QString filename) { // Try find the file in the list of loaded files @@ -1025,7 +1027,7 @@ } // ============================================================================= -// ============================================================================= +// void reloadAllSubfiles() { if (!getCurrentDocument()) @@ -1035,47 +1037,47 @@ g_loadedFiles << getCurrentDocument(); // Go through all objects in the current file and reload the subfiles - for (LDObject* obj : getCurrentDocument()->getObjects()) + for (LDObject* obj : getCurrentDocument()->objects()) { if (obj->type() == LDObject::ESubfile) { LDSubfile* ref = static_cast<LDSubfile*> (obj); - LDDocument* fileInfo = getDocument (ref->getFileInfo()->getName()); + LDDocument* fileInfo = getDocument (ref->fileInfo()->name()); if (fileInfo) ref->setFileInfo (fileInfo); else - ref->replace (new LDError (ref->asText(), fmt ("Could not open %1", ref->getFileInfo()->getName()))); + ref->replace (new LDError (ref->asText(), fmt ("Could not open %1", ref->fileInfo()->name()))); } // Reparse gibberish files. It could be that they are invalid because // of loading errors. Circumstances may be different now. if (obj->type() == LDObject::EError) - obj->replace (parseLine (static_cast<LDError*> (obj)->contents)); + obj->replace (parseLine (static_cast<LDError*> (obj)->contents())); } } // ============================================================================= -// ============================================================================= +// int LDDocument::addObject (LDObject* obj) { - getHistory()->add (new AddHistory (getObjects().size(), obj)); - m_Objects << obj; + history()->add (new AddHistory (objects().size(), obj)); + m_objects << obj; if (obj->type() == LDObject::EVertex) - m_Vertices << obj; + m_vertices << obj; #ifdef DEBUG if (!isImplicit()) - dlog ("Added object #%1 (%2)\n", obj->getID(), obj->typeName()); + dlog ("Added object #%1 (%2)\n", obj->id(), obj->typeName()); #endif - obj->setFile (this); + obj->setDocument (this); return getObjectCount() - 1; } // ============================================================================= -// ============================================================================= +// void LDDocument::addObjects (const LDObjectList objs) { for (LDObject* obj : objs) @@ -1084,36 +1086,36 @@ } // ============================================================================= -// ============================================================================= +// void LDDocument::insertObj (int pos, LDObject* obj) { - getHistory()->add (new AddHistory (pos, obj)); - m_Objects.insert (pos, obj); - obj->setFile (this); + history()->add (new AddHistory (pos, obj)); + m_objects.insert (pos, obj); + obj->setDocument (this); #ifdef DEBUG if (!isImplicit()) - dlog ("Inserted object #%1 (%2) at %3\n", obj->getID(), obj->typeName(), pos); + dlog ("Inserted object #%1 (%2) at %3\n", obj->id(), obj->typeName(), pos); #endif } // ============================================================================= -// ============================================================================= +// void LDDocument::forgetObject (LDObject* obj) { int idx = obj->lineNumber(); obj->unselect(); - assert (m_Objects[idx] == obj); + assert (m_objects[idx] == obj); - if (!getHistory()->isIgnoring()) - getHistory()->add (new DelHistory (idx, obj)); + if (!history()->isIgnoring()) + history()->add (new DelHistory (idx, obj)); - m_Objects.removeAt (idx); - obj->setFile (null); + m_objects.removeAt (idx); + obj->setDocument (null); } // ============================================================================= -// ============================================================================= +// bool safeToCloseAll() { for (LDDocument* f : g_loadedFiles) @@ -1124,74 +1126,75 @@ } // ============================================================================= -// ============================================================================= +// void LDDocument::setObject (int idx, LDObject* obj) { - assert (idx >= 0 && idx < m_Objects.size()); + assert (idx >= 0 && idx < m_objects.size()); // Mark this change to history - if (!m_History->isIgnoring()) + if (!m_history->isIgnoring()) { QString oldcode = getObject (idx)->asText(); QString newcode = obj->asText(); - *m_History << new EditHistory (idx, oldcode, newcode); + *m_history << new EditHistory (idx, oldcode, newcode); } - m_Objects[idx]->unselect(); - m_Objects[idx]->setFile (null); - obj->setFile (this); - m_Objects[idx] = obj; + m_objects[idx]->unselect(); + m_objects[idx]->setDocument (null); + obj->setDocument (this); + m_objects[idx] = obj; } // ============================================================================= -// Close all implicit files with no references -// ============================================================================= +// +// Close all documents we don't need anymore +// void LDDocument::closeUnused() { for (LDDocument* file : g_loadedFiles) - if (file->isImplicit() && file->countReferences() == 0) + if (file->isImplicit() && file->references().isEmpty()) delete file; } // ============================================================================= -// ============================================================================= +// LDObject* LDDocument::getObject (int pos) const { - if (m_Objects.size() <= pos) + if (m_objects.size() <= pos) return null; - return m_Objects[pos]; + return m_objects[pos]; } // ============================================================================= -// ============================================================================= +// int LDDocument::getObjectCount() const { - return getObjects().size(); + return objects().size(); } // ============================================================================= -// ============================================================================= +// bool LDDocument::hasUnsavedChanges() const { - return !isImplicit() && getHistory()->getPosition() != getSavePosition(); + return !isImplicit() && history()->position() != savePosition(); } // ============================================================================= -// ============================================================================= +// QString LDDocument::getDisplayName() { - if (!getName().isEmpty()) - return getName(); + if (!name().isEmpty()) + return name(); - if (!getDefaultName().isEmpty()) - return "[" + getDefaultName() + "]"; + if (!defaultName().isEmpty()) + return "[" + defaultName() + "]"; return tr ("<anonymous>"); } // ============================================================================= -// ============================================================================= +// LDObjectList LDDocument::inlineContents (LDSubfile::InlineFlags flags) { // Possibly substitute with logoed studs: @@ -1202,9 +1205,9 @@ // Ensure logoed studs are loaded first loadLogoedStuds(); - if (getName() == "stud.dat" && g_logoedStud) + if (name() == "stud.dat" && g_logoedStud) return g_logoedStud->inlineContents (flags); - elif (getName() == "stud2.dat" && g_logoedStud2) + elif (name() == "stud2.dat" && g_logoedStud2) return g_logoedStud2->inlineContents (flags); } @@ -1215,14 +1218,14 @@ if (m_needsCache) { - clearCache(); + m_cache.clear(); doCache = true; } // If we have this cached, just create a copy of that - if (deep && getCache().isEmpty() == false) + if (deep && cache().isEmpty() == false) { - for (LDObject* obj : getCache()) + for (LDObject* obj : cache()) objs << obj->createCopy(); } else @@ -1230,7 +1233,7 @@ if (!deep) doCache = false; - for (LDObject* obj : getObjects()) + for (LDObject* obj : objects()) { // Skip those without scemantic meaning if (!obj->isScemantic()) @@ -1273,7 +1276,7 @@ } // ============================================================================= -// ============================================================================= +// LDDocument* LDDocument::current() { return m_curdoc; @@ -1300,14 +1303,14 @@ g_win->updateDocumentListItem (f); g_win->buildObjList(); g_win->updateTitle(); - g_win->R()->setFile (f); + g_win->R()->setDocument (f); g_win->R()->repaint(); log ("Changed file to %1", f->getDisplayName()); } } // ============================================================================= -// ============================================================================= +// int LDDocument::countExplicitFiles() { int count = 0; @@ -1327,15 +1330,15 @@ { if ( countExplicitFiles() == 2 && - g_loadedFiles[0]->getName().isEmpty() && - g_loadedFiles[1]->getName().isEmpty() == false && + g_loadedFiles[0]->name().isEmpty() && + g_loadedFiles[1]->name().isEmpty() == false && !g_loadedFiles[0]->hasUnsavedChanges() ) delete g_loadedFiles[0]; } // ============================================================================= -// ============================================================================= +// void loadLogoedStuds() { if (g_logoedStud && g_logoedStud2) @@ -1351,31 +1354,31 @@ } // ============================================================================= -// ============================================================================= +// void LDDocument::addToSelection (LDObject* obj) // [protected] { if (obj->isSelected()) return; - assert (obj->getFile() == this); + assert (obj->document() == this); m_sel << obj; obj->setSelected (true); } // ============================================================================= -// ============================================================================= +// void LDDocument::removeFromSelection (LDObject* obj) // [protected] { if (!obj->isSelected()) return; - assert (obj->getFile() == this); + assert (obj->document() == this); m_sel.removeOne (obj); obj->setSelected (false); } // ============================================================================= -// ============================================================================= +// void LDDocument::clearSelection() { for (LDObject* obj : m_sel) @@ -1385,26 +1388,26 @@ } // ============================================================================= -// ============================================================================= +// const LDObjectList& LDDocument::getSelection() const { return m_sel; } // ============================================================================= -// ============================================================================= +// void LDDocument::swapObjects (LDObject* one, LDObject* other) { - int a = m_Objects.indexOf (one); - int b = m_Objects.indexOf (other); + int a = m_objects.indexOf (one); + int b = m_objects.indexOf (other); assert (a != b && a != -1 && b != -1); - m_Objects[b] = one; - m_Objects[a] = other; - addToHistory (new SwapHistory (one->getID(), other->getID())); + m_objects[b] = one; + m_objects[a] = other; + addToHistory (new SwapHistory (one->id(), other->id())); } // ============================================================================= -// ============================================================================= +// QString LDDocument::shortenName (QString a) // [static] { QString shortname = basename (a); @@ -1417,18 +1420,18 @@ } // ============================================================================= -// ============================================================================= +// void LDDocument::addReference (LDDocumentPointer* ptr) { - pushToReferences (ptr); + m_references << ptr; } // ============================================================================= -// ============================================================================= +// void LDDocument::removeReference (LDDocumentPointer* ptr) { - removeFromReferences (ptr); + m_references.removeOne (ptr); - if (getReferences().size() == 0) + if (references().isEmpty()) invokeLater (closeUnused); } \ No newline at end of file
--- a/src/Document.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Document.h Wed Mar 05 05:30:36 2014 +0200 @@ -51,19 +51,21 @@ // class LDDocument : public QObject { - properties: + public: + using ReferenceList = QList<LDDocumentPointer*>; + Q_OBJECT - PROPERTY (private, LDObjectList, Objects, LIST_OPS, STOCK_WRITE) - PROPERTY (private, History*, History, NO_OPS, STOCK_WRITE) - PROPERTY (private, LDObjectList, Vertices, LIST_OPS, STOCK_WRITE) - PROPERTY (private, QList<LDDocumentPointer*>, References, LIST_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, LDObjectList, Cache, LIST_OPS, STOCK_WRITE) - PROPERTY (public, long, SavePosition, NUM_OPS, STOCK_WRITE) - PROPERTY (public, int, TabIndex, NO_OPS, STOCK_WRITE) + PROPERTY (public, QString, name, setName, STOCK_WRITE) + PROPERTY (private, LDObjectList, objects, setObjects, STOCK_WRITE) + PROPERTY (private, LDObjectList, cache, setCache, STOCK_WRITE) + PROPERTY (private, History*, history, setHistory, STOCK_WRITE) + PROPERTY (private, LDObjectList, vertices, setVertices, STOCK_WRITE) + PROPERTY (private, ReferenceList, references, setReferences, STOCK_WRITE) + PROPERTY (public, QString, fullPath, setFullPath, STOCK_WRITE) + PROPERTY (public, QString, defaultName, setDefaultName, STOCK_WRITE) + PROPERTY (public, bool, isImplicit, setImplicit, STOCK_WRITE) + PROPERTY (public, long, savePosition, setSavePosition, STOCK_WRITE) + PROPERTY (public, int, tabIndex, setTabIndex, STOCK_WRITE) public: LDDocument(); @@ -75,7 +77,7 @@ void forgetObject (LDObject* obj); // Deletes the given object from the object chain. QString getDisplayName(); const LDObjectList& getSelection() const; - bool hasUnsavedChanges() const; // Does this Document.have unsaved changes? + bool hasUnsavedChanges() const; // Does this document have unsaved changes? LDObjectList inlineContents (LDSubfile::InlineFlags flags); void insertObj (int pos, LDObject* obj); int getObjectCount() const; @@ -95,27 +97,27 @@ inline void addHistoryStep() { - m_History->addStep(); + history()->addStep(); } inline void undo() { - m_History->undo(); + history()->undo(); } inline void redo() { - m_History->redo(); + history()->redo(); } inline void clearHistory() { - m_History->clear(); + history()->clear(); } inline void addToHistory (AbstractHistoryEntry* entry) { - *m_History << entry; + *history() << entry; } static void closeUnused(); @@ -214,13 +216,13 @@ class LDFileLoader : public QObject { Q_OBJECT - PROPERTY (private, LDObjectList, Objects, NO_OPS, STOCK_WRITE) - PROPERTY (private, bool, Done, BOOL_OPS, STOCK_WRITE) - PROPERTY (private, int, Progress, NUM_OPS, STOCK_WRITE) - PROPERTY (private, bool, Aborted, BOOL_OPS, STOCK_WRITE) - PROPERTY (public, QStringList, Lines, NO_OPS, STOCK_WRITE) - PROPERTY (public, int*, Warnings, NO_OPS, STOCK_WRITE) - PROPERTY (public, bool, OnForeground, BOOL_OPS, STOCK_WRITE) + PROPERTY (private, LDObjectList, objects, setObjects, STOCK_WRITE) + PROPERTY (private, bool, isDone, setDone, STOCK_WRITE) + PROPERTY (private, int, progress, setProgress, STOCK_WRITE) + PROPERTY (private, bool, isAborted, setAborted, STOCK_WRITE) + PROPERTY (public, QStringList, lines, setLines, STOCK_WRITE) + PROPERTY (public, int*, warnings, setWarnings, STOCK_WRITE) + PROPERTY (public, bool, isOnForeground, setOnForeground, STOCK_WRITE) public slots: void start();
--- a/src/EditHistory.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/EditHistory.cc Wed Mar 05 05:30:36 2014 +0200 @@ -26,19 +26,19 @@ // ============================================================================= // History::History() : - m_Position (-1) {} + m_position (-1) {} // ============================================================================= // void History::undo() { - if (m_changesets.isEmpty() || getPosition() == -1) + if (m_changesets.isEmpty() || position() == -1) return; // Don't take the changes done here as actual edits to the document setIgnoring (true); - const Changeset& set = getChangeset (getPosition()); + const Changeset& set = getChangeset (position()); // Iterate the list in reverse and undo all actions for (int i = set.size() - 1; i >= 0; --i) @@ -47,10 +47,10 @@ change->undo(); } - decreasePosition(); + m_position--; g_win->refresh(); g_win->updateActions(); - dlog ("Position is now %1", getPosition()); + dlog ("Position is now %1", position()); setIgnoring (false); } @@ -58,20 +58,20 @@ // void History::redo() { - if (getPosition() == m_changesets.size()) + if (position() == m_changesets.size()) return; setIgnoring (true); - const Changeset& set = getChangeset (getPosition() + 1); + const Changeset& set = getChangeset (position() + 1); // Redo things - in the order as they were done in the first place for (const AbstractHistoryEntry* change : set) change->redo(); - setPosition (getPosition() + 1); + setPosition (position() + 1); g_win->refresh(); g_win->updateActions(); - dlog ("Position is now %1", getPosition()); + dlog ("Position is now %1", position()); setIgnoring (false); } @@ -94,7 +94,7 @@ if (m_currentChangeset.isEmpty()) return; - while (getPosition() < getSize() - 1) + while (position() < getSize() - 1) { Changeset last = m_changesets.last(); @@ -107,7 +107,7 @@ dlog ("History: step added (%1 changes)", m_currentChangeset.size()); m_changesets << m_currentChangeset; m_currentChangeset.clear(); - setPosition (getPosition() + 1); + setPosition (position() + 1); g_win->updateActions(); } @@ -130,7 +130,7 @@ // void AddHistory::undo() const { - LDObject* obj = getParent()->getDocument()->getObject (getIndex()); + LDObject* obj = parent()->document()->getObject (index()); obj->destroy(); } @@ -138,24 +138,24 @@ // void AddHistory::redo() const { - LDObject* obj = parseLine (getCode()); - getParent()->getDocument()->insertObj (getIndex(), obj); + LDObject* obj = parseLine (code()); + parent()->document()->insertObj (index(), obj); g_win->R()->compileObject (obj); } // ============================================================================= // DelHistory::DelHistory (int idx, LDObject* obj) : - m_Index (idx), - m_Code (obj->asText()) {} + m_index (idx), + m_code (obj->asText()) {} // ============================================================================= // heh // void DelHistory::undo() const { - LDObject* obj = parseLine (getCode()); - getParent()->getDocument()->insertObj (getIndex(), obj); + LDObject* obj = parseLine (code()); + parent()->document()->insertObj (index(), obj); g_win->R()->compileObject (obj); } @@ -163,7 +163,7 @@ // void DelHistory::redo() const { - LDObject* obj = getParent()->getDocument()->getObject (getIndex()); + LDObject* obj = parent()->document()->getObject (index()); obj->destroy(); } @@ -171,8 +171,8 @@ // void EditHistory::undo() const { - LDObject* obj = getCurrentDocument()->getObject (getIndex()); - LDObject* newobj = parseLine (getOldCode()); + LDObject* obj = getCurrentDocument()->getObject (index()); + LDObject* newobj = parseLine (oldCode()); obj->replace (newobj); g_win->R()->compileObject (newobj); } @@ -181,8 +181,8 @@ // void EditHistory::redo() const { - LDObject* obj = getCurrentDocument()->getObject (getIndex()); - LDObject* newobj = parseLine (getNewCode()); + LDObject* obj = getCurrentDocument()->getObject (index()); + LDObject* newobj = parseLine (newCode()); obj->replace (newobj); g_win->R()->compileObject (newobj); }
--- a/src/EditHistory.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/EditHistory.h Wed Mar 05 05:30:36 2014 +0200 @@ -40,9 +40,9 @@ // ============================================================================= class History { - PROPERTY (private, int, Position, NUM_OPS, STOCK_WRITE) - PROPERTY (public, LDDocument*, Document, NO_OPS, STOCK_WRITE) - PROPERTY (public, bool, Ignoring, BOOL_OPS, STOCK_WRITE) + PROPERTY (private, int, position, setPosition, STOCK_WRITE) + PROPERTY (public, LDDocument*, document, setDocument, STOCK_WRITE) + PROPERTY (public, bool, isIgnoring, setIgnoring, STOCK_WRITE) public: typedef QList<AbstractHistoryEntry*> Changeset; @@ -86,11 +86,10 @@ }; // ============================================================================= -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// ============================================================================= +// class AbstractHistoryEntry { - PROPERTY (public, History*, Parent, NO_OPS, STOCK_WRITE) + PROPERTY (public, History*, parent, setParent, STOCK_WRITE) public: virtual ~AbstractHistoryEntry() {} @@ -101,12 +100,11 @@ }; // ============================================================================= -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// ============================================================================= +// class DelHistory : public AbstractHistoryEntry { - PROPERTY (private, int, Index, NO_OPS, STOCK_WRITE) - PROPERTY (private, QString, Code, NO_OPS, STOCK_WRITE) + PROPERTY (private, int, index, setIndex, STOCK_WRITE) + PROPERTY (private, QString, code, setCode, STOCK_WRITE) public: IMPLEMENT_HISTORY_TYPE (Del) @@ -114,21 +112,20 @@ }; // ============================================================================= -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// ============================================================================= +// class EditHistory : public AbstractHistoryEntry { - PROPERTY (private, int, Index, NO_OPS, STOCK_WRITE) - PROPERTY (private, QString, OldCode, NO_OPS, STOCK_WRITE) - PROPERTY (private, QString, NewCode, NO_OPS, STOCK_WRITE) + PROPERTY (private, int, index, setIndex, STOCK_WRITE) + PROPERTY (private, QString, oldCode, setOldCode, STOCK_WRITE) + PROPERTY (private, QString, newCode, setNewCode, STOCK_WRITE) public: IMPLEMENT_HISTORY_TYPE (Edit) EditHistory (int idx, QString oldCode, QString newCode) : - m_Index (idx), - m_OldCode (oldCode), - m_NewCode (newCode) {} + m_index (idx), + m_oldCode (oldCode), + m_newCode (newCode) {} }; // ============================================================================= @@ -136,20 +133,19 @@ // ============================================================================= class AddHistory : public AbstractHistoryEntry { - PROPERTY (private, int, Index, NO_OPS, STOCK_WRITE) - PROPERTY (private, QString, Code, NO_OPS, STOCK_WRITE) + PROPERTY (private, int, index, setIndex, STOCK_WRITE) + PROPERTY (private, QString, code, setCode, STOCK_WRITE) public: IMPLEMENT_HISTORY_TYPE (Add) AddHistory (int idx, LDObject* obj) : - m_Index (idx), - m_Code (obj->asText()) {} + m_index (idx), + m_code (obj->asText()) {} }; // ============================================================================= -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// ============================================================================= +// class MoveHistory : public AbstractHistoryEntry { public: @@ -164,16 +160,15 @@ }; // ============================================================================= -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// ============================================================================= +// class SwapHistory : public AbstractHistoryEntry { public: IMPLEMENT_HISTORY_TYPE (Swap) SwapHistory (int a, int b) : - a (a), - b (b) {} + a (a), + b (b) {} private: int a, b;
--- a/src/ExternalPrograms.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/ExternalPrograms.cc Wed Mar 05 05:30:36 2014 +0200 @@ -219,9 +219,9 @@ { LDObjectList objects; - for (LDObject* obj : getCurrentDocument()->getObjects()) + for (LDObject* obj : getCurrentDocument()->objects()) { - if (obj->isColored() == false || obj->getColor() != colnum) + if (obj->isColored() == false || obj->color() != colnum) continue; objects << obj;
--- a/src/GLRenderer.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/GLRenderer.cc Wed Mar 05 05:30:36 2014 +0200 @@ -115,13 +115,13 @@ // GLRenderer::GLRenderer (QWidget* parent) : QGLWidget (parent) { - m_Picking = m_rangepick = false; + m_isPicking = m_rangepick = false; m_camera = (GL::EFixedCamera) gl_camera; m_drawToolTip = false; - m_EditMode = ESelectMode; + m_editMode = ESelectMode; m_rectdraw = false; m_panning = false; - setFile (null); + setDocument (null); setDrawOnly (false); setMessageLog (null); m_width = m_height = -1; @@ -295,7 +295,7 @@ // ID again from the color we get from the picking results. Be sure to use // the top level parent's index since we want a subfile's children point // to the subfile itself. - long i = obj->topLevelParent()->getID(); + long i = obj->topLevelParent()->id(); // Calculate a color based from this index. This method caters for // 16777216 objects. I don't think that'll be exceeded anytime soon. :) @@ -319,21 +319,21 @@ } else { - if (obj->getColor() == maincolor) + if (obj->color() == maincolor) qcol = getMainColor(); else { - LDColor* col = getColor (obj->getColor()); + LDColor* col = ::getColor (obj->color()); if (col) qcol = col->faceColor; } - if (obj->getColor() == edgecolor) + if (obj->color() == edgecolor) { LDColor* col; - if (!gl_blackedges && obj->getParent() && (col = getColor (obj->getParent()->getColor()))) + if (!gl_blackedges && obj->parent() && (col = ::getColor (obj->parent()->color()))) qcol = col->edgeColor; else qcol = (m_darkbg == false) ? Qt::black : Qt::white; @@ -343,16 +343,16 @@ { // The color was unknown. Use main color to make the object at least // not appear pitch-black. - if (obj->getColor() != edgecolor) + if (obj->color() != edgecolor) qcol = getMainColor(); // Warn about the unknown colors, but only once. for (int i : g_warnedColors) - if (obj->getColor() == i) + if (obj->color() == i) return; - log ("%1: Unknown color %2!\n", __func__, obj->getColor()); - g_warnedColors << obj->getColor(); + log ("%1: Unknown color %2!\n", __func__, obj->color()); + g_warnedColors << obj->color(); return; } } @@ -416,7 +416,7 @@ // void GLRenderer::drawGLScene() { - if (getFile() == null) + if (document() == null) return; if (gl_wireframe && !isPicking()) @@ -467,7 +467,7 @@ { glEnable (GL_CULL_FACE); - for (LDObject* obj : getFile()->getObjects()) + for (LDObject* obj : document()->objects()) { if (obj->isHidden()) continue; @@ -483,7 +483,7 @@ } else { - for (LDObject* obj : getFile()->getObjects()) + for (LDObject* obj : document()->objects()) { if (obj->isHidden()) continue; @@ -621,7 +621,7 @@ linepen.setColor (luma (m_bgcolor) < 40 ? Qt::white : Qt::black); // Mode-specific rendering - if (getEditMode() == EDrawMode) + if (editMode() == EDrawMode) { QPoint poly[4]; Vertex poly3d[4]; @@ -712,7 +712,7 @@ } } } - elif (getEditMode() == ECircleMode) + elif (editMode() == ECircleMode) { // If we have not specified the center point of the circle yet, preview it on the screen. if (m_drawedVerts.isEmpty()) @@ -722,7 +722,7 @@ QVector<Vertex> verts, verts2; const double dist0 = getCircleDrawDist (0), dist1 = (m_drawedVerts.size() >= 2) ? getCircleDrawDist (1) : -1; - const int segs = lores; + const int segs = g_lores; const double angleUnit = (2 * pi) / segs; Axis relX, relY; QVector<QPoint> ringpoints, circlepoints, circle2points; @@ -815,7 +815,7 @@ for (CameraIcon& info : m_cameraIcons) { // Don't draw the free camera icon when in draw mode - if (&info == &m_cameraIcons[GL::EFreeCamera] && getEditMode() != ESelectMode) + if (&info == &m_cameraIcons[GL::EFreeCamera] && editMode() != ESelectMode) continue; paint.drawPixmap (info.destRect, *info.img, info.srcRect); @@ -847,13 +847,13 @@ } // Message log - if (getMessageLog()) + if (messageLog()) { int y = 0; const int margin = 2; QColor penColor = textpen.color(); - for (const MessageManager::Line& line : getMessageLog()->getLines()) + for (const MessageManager::Line& line : messageLog()->getLines()) { penColor.setAlphaF (line.alpha); paint.setPen (penColor); @@ -896,7 +896,7 @@ // void GLRenderer::compileAllObjects() { - if (!getFile()) + if (!document()) return; // Compiling all is a big job, use a busy cursor @@ -904,7 +904,7 @@ m_knownVerts.clear(); - for (LDObject* obj : getFile()->getObjects()) + for (LDObject* obj : document()->objects()) compileObject (obj); // Compile axes @@ -990,12 +990,12 @@ objs = ref->inlineContents (LDSubfile::DeepCacheInline | LDSubfile::RendererInline); bool oldinvert = g_glInvert; - if (ref->getTransform().getDeterminant() < 0) + if (ref->transform().getDeterminant() < 0) g_glInvert = !g_glInvert; LDObject* prev = ref->previous(); - if (prev && prev->type() == LDObject::EBFC && static_cast<LDBFC*> (prev)->m_statement == LDBFC::InvertNext) + if (prev && prev->type() == LDObject::EBFC && static_cast<LDBFC*> (prev)->statement() == LDBFC::InvertNext) g_glInvert = !g_glInvert; for (LDObject* obj : objs) @@ -1035,7 +1035,7 @@ void GLRenderer::addDrawnVertex (Vertex pos) { // If we picked an already-existing vertex, stop drawing - if (getEditMode() == EDrawMode) + if (editMode() == EDrawMode) { for (Vertex& vert : m_drawedVerts) { @@ -1076,7 +1076,7 @@ } } - switch (getEditMode()) + switch (editMode()) { case EDrawMode: { @@ -1136,7 +1136,7 @@ m_rangepick = false; } - if (wasMid && getEditMode() != ESelectMode && m_drawedVerts.size() < 4 && m_totalmove < 10) + if (wasMid && editMode() != ESelectMode && m_drawedVerts.size() < 4 && m_totalmove < 10) { // Find the closest vertex to our cursor double mindist = 1024.0f; @@ -1427,7 +1427,7 @@ // void GLRenderer::setEditMode (EditMode const& a) { - m_EditMode = a; + m_editMode = a; switch (a) { @@ -1469,9 +1469,9 @@ // ============================================================================= // -void GLRenderer::setFile (LDDocument* const& a) +void GLRenderer::setDocument (LDDocument* const& a) { - m_File = a; + m_document = a; if (a != null) { @@ -1512,7 +1512,7 @@ QList<Vertex>& verts = m_drawedVerts; LDObjectList objs; - switch (getEditMode()) + switch (editMode()) { case EDrawMode: { @@ -1570,7 +1570,7 @@ case ECircleMode: { - const int segs = lores, divs = lores; // TODO: make customizable + const int segs = g_lores, divs = g_lores; // TODO: make customizable double dist0 = getCircleDrawDist (0), dist1 = getCircleDrawDist (1); LDDocument* refFile = null; @@ -1601,9 +1601,9 @@ { // Get a ref file for this primitive. If we cannot find it in the // LDraw library, generate it. - if ((refFile = ::getDocument (radialFileName (::Ring, lores, lores, cmp.num))) == null) + if ((refFile = ::getDocument (radialFileName (::Ring, g_lores, g_lores, cmp.num))) == null) { - refFile = generatePrimitive (::Ring, lores, lores, cmp.num); + refFile = generatePrimitive (::Ring, g_lores, g_lores, cmp.num); refFile->setImplicit (false); } @@ -1681,7 +1681,7 @@ { for (LDObject* obj : objs) { - getFile()->addObject (obj); + document()->addObject (obj); compileObject (obj); } @@ -1940,7 +1940,7 @@ // void GLRenderer::zoomToFit() { - if (getFile() == null || m_width == -1 || m_height == -1) + if (document() == null || m_width == -1 || m_height == -1) { zoom() = 30.0f; return; @@ -2089,7 +2089,7 @@ // void GLRenderer::mouseDoubleClickEvent (QMouseEvent* ev) { - if (!(ev->buttons() & Qt::LeftButton) || getEditMode() != ESelectMode) + if (!(ev->buttons() & Qt::LeftButton) || editMode() != ESelectMode) return; pick (ev->x(), ev->y()); @@ -2109,9 +2109,9 @@ { LDOverlay* ovlobj = null; - for (LDObject* obj : getFile()->getObjects()) + for (LDObject* obj : document()->objects()) { - if (obj->type() == LDObject::EOverlay && static_cast<LDOverlay*> (obj)->getCamera() == cam) + if (obj->type() == LDObject::EOverlay && static_cast<LDOverlay*> (obj)->camera() == cam) { ovlobj = static_cast<LDOverlay*> (obj); break; @@ -2139,9 +2139,10 @@ { delete meta.img; meta.img = null; - } elif (ovlobj && (!meta.img || meta.fname != ovlobj->getFileName())) - setupOverlay (cam, ovlobj->getFileName(), ovlobj->getX(), - ovlobj->getY(), ovlobj->getWidth(), ovlobj->getHeight()); + } + elif (ovlobj && (!meta.img || meta.fname != ovlobj->fileName())) + setupOverlay (cam, ovlobj->fileName(), ovlobj->x(), + ovlobj->y(), ovlobj->width(), ovlobj->height()); } } @@ -2183,9 +2184,9 @@ int i, lastOverlay = -1; bool found = false; - for (i = 0; i < getFile()->getObjectCount(); ++i) + for (i = 0; i < document()->getObjectCount(); ++i) { - LDObject* obj = getFile()->getObject (i); + LDObject* obj = document()->getObject (i); if (obj->isScemantic()) { @@ -2198,13 +2199,13 @@ } if (lastOverlay != -1) - getFile()->insertObj (lastOverlay + 1, ovlobj); + document()->insertObj (lastOverlay + 1, ovlobj); else { - getFile()->insertObj (i, ovlobj); + document()->insertObj (i, ovlobj); if (found) - getFile()->insertObj (i + 1, new LDEmpty); + document()->insertObj (i + 1, new LDEmpty); } }
--- a/src/GLRenderer.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/GLRenderer.h Wed Mar 05 05:30:36 2014 +0200 @@ -93,7 +93,7 @@ // class GLRenderer : public QGLWidget { - typedefs: + public: enum EFixedCamera { ETopCamera, @@ -125,13 +125,12 @@ EFixedCamera cam; }; - properties: Q_OBJECT - PROPERTY (public, bool, DrawOnly, BOOL_OPS, STOCK_WRITE) - PROPERTY (public, MessageManager*, MessageLog, NO_OPS, STOCK_WRITE) - PROPERTY (private, bool, Picking, BOOL_OPS, STOCK_WRITE) - PROPERTY (public, LDDocument*, File, NO_OPS, CUSTOM_WRITE) - PROPERTY (public, EditMode, EditMode, NO_OPS, CUSTOM_WRITE) + PROPERTY (public, bool, isDrawOnly, setDrawOnly, STOCK_WRITE) + PROPERTY (public, MessageManager*, messageLog, setMessageLog, STOCK_WRITE) + PROPERTY (private, bool, isPicking, setPicking, STOCK_WRITE) + PROPERTY (public, LDDocument*, document, setDocument, CUSTOM_WRITE) + PROPERTY (public, EditMode, editMode, setEditMode, CUSTOM_WRITE) public: GLRenderer (QWidget* parent = null); @@ -187,7 +186,7 @@ private: CameraIcon m_cameraIcons[7]; QTimer* m_toolTipTimer; - Qt::MouseButtons m_lastButtons; + Qt::MouseButtons m_lastButtons; Qt::KeyboardModifiers m_keymods; Vertex m_hoverpos; double m_virtWidth, @@ -254,7 +253,7 @@ LDGLData& currentDocumentData() const { - return *getFile()->getGLData(); + return *document()->getGLData(); } // Get a rotation value
--- a/src/LDConfig.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/LDConfig.h Wed Mar 05 05:30:36 2014 +0200 @@ -20,11 +20,10 @@ #include "Types.h" #include <QStringList> -// ============================================================================= -// LDConfigParser +// ============================================================================ // // String parsing utility for parsing ldconfig.ldr -// ============================================================================= +// class LDConfigParser { public:
--- a/src/LDObject.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/LDObject.cc Wed Mar 05 05:30:36 2014 +0200 @@ -36,11 +36,11 @@ // LDObject constructors // LDObject::LDObject() : - m_Hidden (false), - m_Selected (false), - m_Parent (null), - m_File (null), - m_GLInit (false), + m_isHidden (false), + m_isSelected (false), + m_parent (null), + m_document (null), + m_isGLInit (false), qObjListEntry (null) { memset (m_coords, 0, sizeof m_coords); @@ -58,8 +58,8 @@ { assert (obj != this); - if (obj->getID() >= id) - id = obj->getID() + 1; + if (obj->id() >= id) + id = obj->id() + 1; } setID (id); @@ -80,17 +80,17 @@ // QString LDComment::asText() const { - return fmt ("0 %1", text); + return fmt ("0 %1", text()); } // ============================================================================= // QString LDSubfile::asText() const { - QString val = fmt ("1 %1 %2 ", getColor(), getPosition()); - val += getTransform().toString(); + QString val = fmt ("1 %1 %2 ", color(), position()); + val += transform().toString(); val += ' '; - val += getFileInfo()->getName(); + val += fileInfo()->name(); return val; } @@ -98,7 +98,7 @@ // QString LDLine::asText() const { - QString val = fmt ("2 %1", getColor()); + QString val = fmt ("2 %1", color()); for (int i = 0; i < 2; ++i) val += fmt (" %1", vertex (i)); @@ -110,7 +110,7 @@ // QString LDTriangle::asText() const { - QString val = fmt ("3 %1", getColor()); + QString val = fmt ("3 %1", color()); for (int i = 0; i < 3; ++i) val += fmt (" %1", vertex (i)); @@ -122,7 +122,7 @@ // QString LDQuad::asText() const { - QString val = fmt ("4 %1", getColor()); + QString val = fmt ("4 %1", color()); for (int i = 0; i < 4; ++i) val += fmt (" %1", vertex (i)); @@ -134,7 +134,7 @@ // QString LDCondLine::asText() const { - QString val = fmt ("5 %1", getColor()); + QString val = fmt ("5 %1", color()); // Add the coordinates for (int i = 0; i < 4; ++i) @@ -147,14 +147,14 @@ // QString LDError::asText() const { - return contents; + return contents(); } // ============================================================================= // QString LDVertex::asText() const { - return fmt ("0 !LDFORGE VERTEX %1 %2", getColor(), pos); + return fmt ("0 !LDFORGE VERTEX %1 %2", color(), pos); } // ============================================================================= @@ -199,8 +199,8 @@ LDTriangle* tri2 = new LDTriangle (vertex (1), vertex (2), vertex (3)); // The triangles also inherit the quad's color - tri1->setColor (getColor()); - tri2->setColor (getColor()); + tri1->setColor (color()); + tri2->setColor (color()); QList<LDTriangle*> triangles; triangles << tri1; @@ -216,7 +216,7 @@ assert (idx != -1); // Replace the instance of the old object with the new object - getFile()->setObject (idx, other); + document()->setObject (idx, other); // Remove the old object destroy(); @@ -226,8 +226,8 @@ // void LDObject::swap (LDObject* other) { - assert (getFile() == other->getFile()); - getFile()->swapObjects (this, other); + assert (document() == other->document()); + document()->swapObjects (this, other); } // ============================================================================= @@ -265,8 +265,8 @@ unselect(); // If this object was associated to a file, remove it off it now - if (getFile()) - getFile()->forgetObject (this); + if (document()) + document()->forgetObject (this); // Delete the GL lists GL::deleteLists (this); @@ -300,8 +300,8 @@ case LDObject::ESubfile: { LDSubfile* ref = static_cast<LDSubfile*> (obj); - Matrix newMatrix = transform * ref->getTransform(); - Vertex newpos = ref->getPosition(); + Matrix newMatrix = transform * ref->transform(); + Vertex newpos = ref->position(); newpos.transform (transform, pos); ref->setPosition (newpos); @@ -313,7 +313,7 @@ break; } - if (obj->getColor() == maincolor) + if (obj->color() == maincolor) obj->setColor (parentcolor); } @@ -321,14 +321,14 @@ // LDObjectList LDSubfile::inlineContents (InlineFlags flags) { - LDObjectList objs = getFileInfo()->inlineContents (flags); + LDObjectList objs = fileInfo()->inlineContents (flags); // Transform the objects for (LDObject* obj : objs) { // Set the parent now so we know what inlined the object. obj->setParent (this); - transformObject (obj, getTransform(), getPosition(), getColor()); + transformObject (obj, transform(), position(), color()); } return objs; @@ -338,10 +338,10 @@ // long LDObject::lineNumber() const { - assert (getFile() != null); + assert (document() != null); - for (int i = 0; i < getFile()->getObjectCount(); ++i) - if (getFile()->getObject (i) == this) + for (int i = 0; i < document()->getObjectCount(); ++i) + if (document()->getObject (i) == this) return i; return -1; @@ -359,7 +359,7 @@ const long end = up ? objs.size() : -1; const long incr = up ? 1 : -1; LDObjectList objsToCompile; - LDDocument* file = objs[0]->getFile(); + LDDocument* file = objs[0]->document(); for (long i = start; i != end; i += incr) { @@ -368,7 +368,7 @@ const long idx = obj->lineNumber(), target = idx + (up ? -1 : 1); - if ( (up && idx == 0) || (!up && idx == (long) (file->getObjects().size() - 1))) + if ((up && idx == 0) || (!up && idx == (long) (file->objects().size() - 1))) { // One of the objects hit the extrema. If this happens, this should be the first // object to be iterated on. Thus, nothing has changed yet and it's safe to just @@ -443,13 +443,13 @@ // LDObject* LDObject::topLevelParent() { - if (!getParent()) + if (parent() == null) return this; LDObject* it = this; - while (it->getParent()) - it = it->getParent(); + while (it->parent() != null) + it = it->parent(); return it; } @@ -461,10 +461,10 @@ long idx = lineNumber(); assert (idx != -1); - if (idx == (long) getFile()->getObjectCount() - 1) + if (idx == (long) document()->getObjectCount() - 1) return null; - return getFile()->getObject (idx + 1); + return document()->getObject (idx + 1); } // ============================================================================= @@ -477,7 +477,7 @@ if (idx == 0) return null; - return getFile()->getObject (idx - 1); + return document()->getObject (idx - 1); } // ============================================================================= @@ -487,7 +487,7 @@ if (hasMatrix()) { LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (this); - mo->setPosition (mo->getPosition() + vect); + mo->setPosition (mo->position() + vect); } elif (type() == LDObject::EVertex) { @@ -573,7 +573,7 @@ { LDBFC* bfc = dynamic_cast<LDBFC*> (previous()); - if (bfc && bfc->m_statement == LDBFC::InvertNext) + if (bfc && bfc->statement() == LDBFC::InvertNext) { // This is prefixed with an invertnext, thus remove it. bfc->destroy(); @@ -583,7 +583,7 @@ // Not inverted, thus prefix it with a new invertnext. LDBFC* bfc = new LDBFC (LDBFC::InvertNext); - getFile()->insertObj (idx, bfc); + document()->insertObj (idx, bfc); } // ============================================================================= @@ -618,7 +618,7 @@ for (int i = 0; i < repl->vertices(); ++i) repl->setVertex (i, vertex (i)); - repl->setColor (getColor()); + repl->setColor (color()); replace (repl); return repl; @@ -629,7 +629,7 @@ LDObject* LDObject::fromID (int id) { for (LDObject* obj : g_LDObjects) - if (obj->getID() == id) + if (obj->id() == id) return obj; return null; @@ -640,7 +640,7 @@ QString LDOverlay::asText() const { return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6", - getFileName(), getCamera(), getX(), getY(), getWidth(), getHeight()); + fileName(), camera(), x(), y(), width(), height()); } void LDOverlay::invert() {} @@ -657,14 +657,14 @@ if (*ptr == val) return; - if (obj->getFile() && (idx = obj->lineNumber()) != -1) + if (obj->document() && (idx = obj->lineNumber()) != -1) { QString before = obj->asText(); *ptr = val; QString after = obj->asText(); if (before != after) - obj->getFile()->addToHistory (new EditHistory (idx, before, after)); + obj->document()->addToHistory (new EditHistory (idx, before, after)); } else *ptr = val; @@ -674,7 +674,7 @@ // void LDObject::setColor (const int& val) { - changeProperty (this, &m_Color, val); + changeProperty (this, &m_color, val); } // ============================================================================= @@ -695,14 +695,14 @@ // void LDMatrixObject::setPosition (const Vertex& a) { - changeProperty (getLinkPointer(), &m_Position, LDSharedVertex::getSharedVertex (a)); + changeProperty (linkPointer(), &m_position, LDSharedVertex::getSharedVertex (a)); } // ============================================================================= // void LDMatrixObject::setTransform (const Matrix& val) { - changeProperty (getLinkPointer(), &m_Transform, val); + changeProperty (linkPointer(), &m_transform, val); } // ============================================================================= @@ -747,26 +747,26 @@ // void LDObject::select() { - if (!getFile()) + if (!document()) { - log ("Warning: Object #%1 cannot be selected as it is not assigned a file!\n", getID()); + log ("Warning: Object #%1 cannot be selected as it is not assigned a file!\n", id()); return; } - getFile()->addToSelection (this); + document()->addToSelection (this); } // ============================================================================= // void LDObject::unselect() { - if (!getFile()) + if (!document()) { - log ("Warning: Object #%1 cannot be unselected as it is not assigned a file!\n", getID()); + log ("Warning: Object #%1 cannot be unselected as it is not assigned a file!\n", id()); return; } - getFile()->removeFromSelection (this); + document()->removeFromSelection (this); } // ============================================================================= @@ -776,10 +776,10 @@ switch (id) { case 0: - return CALicense; + return g_CALicense; case 1: - return NonCALicense; + return g_nonCALicense; case 2: return ""; @@ -803,14 +803,14 @@ /* LDObject* copy = getDefault (getType()); - copy->setColor (getColor()); + copy->setColor (color()); if (hasMatrix()) { LDMatrixObject* copyMo = static_cast<LDMatrixObject*> (copy); const LDMatrixObject* mo = static_cast<const LDMatrixObject*> (this); copyMo->setPosition (mo->getPosition()); - copyMo->setTransform (mo->getTransform()); + copyMo->setTransform (mo->transform()); } else { @@ -825,7 +825,7 @@ LDSubfile* copyRef = static_cast<LDSubfile*> (copy); const LDSubfile* ref = static_cast<const LDSubfile*> (this); - copyRef->setFileInfo (ref->getFileInfo()); + copyRef->setFileInfo (ref->fileInfo()); } } */
--- a/src/LDObject.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/LDObject.h Wed Mar 05 05:30:36 2014 +0200 @@ -65,13 +65,13 @@ // ============================================================================= class LDObject { - PROPERTY (public, bool, Hidden, BOOL_OPS, STOCK_WRITE) - PROPERTY (public, bool, Selected, BOOL_OPS, STOCK_WRITE) - PROPERTY (public, LDObject*, Parent, NO_OPS, STOCK_WRITE) - PROPERTY (public, LDDocument*, File, NO_OPS, STOCK_WRITE) // TODO: rename~ - PROPERTY (private, int, ID, NUM_OPS, STOCK_WRITE) - PROPERTY (public, int, Color, NUM_OPS, CUSTOM_WRITE) - PROPERTY (public, bool, GLInit, BOOL_OPS, STOCK_WRITE) + PROPERTY (public, bool, isHidden, setHidden, STOCK_WRITE) + PROPERTY (public, bool, isSelected, setSelected, STOCK_WRITE) + PROPERTY (public, LDObject*, parent, setParent, STOCK_WRITE) + PROPERTY (public, LDDocument*, document, setDocument, STOCK_WRITE) + PROPERTY (private, int, id, setID, STOCK_WRITE) + PROPERTY (public, int, color, setColor, CUSTOM_WRITE) + PROPERTY (public, bool, isGLInit, setGLInit, STOCK_WRITE) public: // Object type codes. @@ -227,8 +227,6 @@ }; // ============================================================================= -// LDMatrixObject -// ============================================================================= // // Common code for objects with matrices. This class is multiple-derived in // and thus not used directly other than as a common storage point for matrices @@ -240,28 +238,28 @@ // In 0.1-alpha, there was a separate 'radial' type which had a position and // matrix as well. Even though right now only LDSubfile uses this, I'm keeping // this class distinct in case I get new extension ideas. :) -// ============================================================================= +// class LDMatrixObject { - PROPERTY (public, LDObject*, LinkPointer, NO_OPS, STOCK_WRITE) - PROPERTY (public, Matrix, Transform, NO_OPS, CUSTOM_WRITE) + PROPERTY (public, LDObject*, linkPointer, setLinkPointer, STOCK_WRITE) + PROPERTY (public, Matrix, transform, setTransform, CUSTOM_WRITE) public: LDMatrixObject() : - m_Position (LDSharedVertex::getSharedVertex (g_origin)) {} + m_position (LDSharedVertex::getSharedVertex (g_origin)) {} LDMatrixObject (const Matrix& transform, const Vertex& pos) : - m_Transform (transform), - m_Position (LDSharedVertex::getSharedVertex (pos)) {} + m_transform (transform), + m_position (LDSharedVertex::getSharedVertex (pos)) {} - inline const Vertex& getPosition() const + inline const Vertex& position() const { - return m_Position->data(); + return m_position->data(); } void setCoordinate (const Axis ax, double value) { - Vertex v = getPosition(); + Vertex v = position(); v[ax] = value; setPosition (v); } @@ -269,17 +267,15 @@ void setPosition (const Vertex& a); private: - LDSharedVertex* m_Position; + LDSharedVertex* m_position; }; // ============================================================================= -// LDError // // Represents a line in the LDraw file that could not be properly parsed. It is // represented by a (!) ERROR in the code view. It exists for the purpose of -// allowing garbage lines be debugged and corrected within LDForge. The member -// zContent contains the contents of the unparsable line. -// ============================================================================= +// allowing garbage lines be debugged and corrected within LDForge. +// class LDError : public LDObject { LDOBJ (Error) @@ -288,24 +284,21 @@ LDOBJ_UNCOLORED LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX - PROPERTY (public, QString, FileReferenced, STR_OPS, STOCK_WRITE) + PROPERTY (public, QString, fileReferenced, setFileReferenced, STOCK_WRITE) + PROPERTY (private, QString, contents, setContents, STOCK_WRITE) + PROPERTY (private, QString, reason, setReason, STOCK_WRITE) public: LDError(); - LDError (QString contents, QString reason) : contents (contents), reason (reason) {} - - // Content of this unknown line - QString contents; - - // Why is this gibberish? - QString reason; + LDError (QString contents, QString reason) : + m_contents (contents), + m_reason (reason) {} }; // ============================================================================= -// LDEmpty // // Represents an empty line in the LDraw code file. -// ============================================================================= +// class LDEmpty : public LDObject { LDOBJ (Empty) @@ -317,13 +310,12 @@ }; // ============================================================================= -// LDComment // -// Represents a code-0 comment in the LDraw code file. Member text contains -// the text of the comment. -// ============================================================================= +// Represents a code-0 comment in the LDraw code file. +// class LDComment : public LDObject { + PROPERTY (public, QString, text, setText, STOCK_WRITE) LDOBJ (Comment) LDOBJ_NAME (comment) LDOBJ_VERTICES (0) @@ -333,17 +325,14 @@ public: LDComment() {} - LDComment (QString text) : text (text) {} - - QString text; // The text of this comment + LDComment (QString text) : m_text (text) {} }; // ============================================================================= -// LDBFC // // Represents a 0 BFC statement in the LDraw code. eStatement contains the type // of this statement. -// ============================================================================= +// class LDBFC : public LDObject { public: @@ -366,8 +355,9 @@ LDOBJ_NAME (bfc) LDOBJ_VERTICES (0) LDOBJ_UNCOLORED - LDOBJ_CUSTOM_SCEMANTIC { return (m_statement == InvertNext); } + LDOBJ_CUSTOM_SCEMANTIC { return (statement() == InvertNext); } LDOBJ_NO_MATRIX + PROPERTY (public, Statement, statement, setStatement, STOCK_WRITE) public: LDBFC() {} @@ -376,8 +366,6 @@ // Statement strings static const char* k_statementStrings[]; - - Statement m_statement; }; // ============================================================================= @@ -393,7 +381,7 @@ LDOBJ_COLORED LDOBJ_SCEMANTIC LDOBJ_HAS_MATRIX - PROPERTY (public, LDDocumentPointer, FileInfo, NO_OPS, STOCK_WRITE) + PROPERTY (public, LDDocumentPointer, fileInfo, setFileInfo, STOCK_WRITE) public: enum InlineFlag @@ -401,8 +389,7 @@ DeepInline = (1 << 0), CacheInline = (1 << 1), RendererInline = (1 << 2), - - DeepCacheInline = DeepInline | CacheInline, + DeepCacheInline = (DeepInline | CacheInline), }; Q_DECLARE_FLAGS (InlineFlags, InlineFlag) @@ -549,18 +536,18 @@ LDOBJ_UNCOLORED LDOBJ_NON_SCEMANTIC LDOBJ_NO_MATRIX - PROPERTY (public, int, Camera, NUM_OPS, STOCK_WRITE) - PROPERTY (public, int, X, NUM_OPS, STOCK_WRITE) - 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, QString, FileName, STR_OPS, STOCK_WRITE) + PROPERTY (public, int, camera, setCamera, STOCK_WRITE) + PROPERTY (public, int, x, setX, STOCK_WRITE) + PROPERTY (public, int, y, setY, STOCK_WRITE) + PROPERTY (public, int, width, setWidth, STOCK_WRITE) + PROPERTY (public, int, height, setHeight, STOCK_WRITE) + PROPERTY (public, QString, fileName, setFileName, STOCK_WRITE) }; // Other common LDraw stuff -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; +static const QString g_CALicense ("!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt"); +static const QString g_nonCALicense ("!LICENSE Not redistributable : see NonCAreadme.txt"); +static const int g_lores = 16; +static const int g_hires = 48; QString getLicenseText (int id);
--- a/src/Main.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Main.cc Wed Mar 05 05:30:36 2014 +0200 @@ -100,4 +100,3 @@ fwrite (msg.toStdString().c_str(), 1, msg.length(), fp); fflush (fp); } -
--- a/src/Main.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Main.h Wed Mar 05 05:30:36 2014 +0200 @@ -27,77 +27,15 @@ #include <stdarg.h> #include <QString> #include <QTextFormat> - +#include "Macros.h" #include "Version.h" -#include "PropertyMacro.h" #include "Configuration.h" -// ============================================= -#define alias auto& -#define elif(A) else if (A) - // Null pointer static const std::nullptr_t null = nullptr; -#ifdef WIN32 -# define DIRSLASH "\\" -# define DIRSLASH_CHAR '\\' -#else // WIN32 -# define DIRSLASH "/" -# define DIRSLASH_CHAR '/' -#endif // WIN32 - -#ifdef __GNUC__ -#define FUNCNAME __PRETTY_FUNCTION__ -#else -#define FUNCNAME __func__ -#endif // __GNUC__ - -#ifdef IN_IDE_PARSER -void dlog(void, ...) {} -#else -# ifdef DEBUG -# define dlog(...) log (QString (__PRETTY_FUNCTION__) + ": " __VA_ARGS__) -# else -# define dlog(...) -# endif // DEBUG -#endif // IN_IDE_PARSER - -#define dvalof(A) dlog ("value of '%1' = %2\n", #A, A) - -// Replace assert with a version that shows a GUI dialog if possible. -// On Windows I just can't get the actual error messages otherwise. void assertionFailure (const char* file, int line, const char* funcname, const char* expr); -#undef assert - -#ifdef DEBUG -# define assert(N) { ((N) ? (void) 0 : assertionFailure (__FILE__, __LINE__, FUNCNAME, #N)); } -#else -# define assert(N) {} -#endif // DEBUG - // Version string identifier. These are defined in Version.cc. const char* versionString(); const char* fullVersionString(); - -#define properties private -#define typedefs public -#define for_axes(AX) for (const Axis AX : std::initializer_list<const Axis> ({X, Y, Z})) - -// ============================================================================= -#ifdef IN_IDE_PARSER // KDevelop workarounds: -# error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds) -# define COMPILE_DATE "14-01-10 10:31:09" - -# ifndef va_start -# define va_start(va, arg) -# endif // va_start - -# ifndef va_end -# define va_end(va) -# endif // va_end - -static const char* __func__ = ""; // Current function name -typedef void FILE; // :| -#endif // IN_IDE_PARSER
--- a/src/MainWindow.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/MainWindow.cc Wed Mar 05 05:30:36 2014 +0200 @@ -228,9 +228,9 @@ else { QToolButton* colorButton = new QToolButton; - colorButton->setIcon (makeColorIcon (entry.getColor(), 22)); + colorButton->setIcon (makeColorIcon (entry.color(), 22)); colorButton->setIconSize (QSize (22, 22)); - colorButton->setToolTip (entry.getColor()->name); + colorButton->setToolTip (entry.color()->name); connect (colorButton, SIGNAL (clicked()), this, SLOT (slot_quickColor())); ui->colorToolbar->addWidget (colorButton); @@ -262,8 +262,8 @@ // Append our current file if we have one if (getCurrentDocument()) { - if (getCurrentDocument()->getName().length() > 0) - title += fmt (": %1", basename (getCurrentDocument()->getName())); + if (getCurrentDocument()->name().length() > 0) + title += fmt (": %1", basename (getCurrentDocument()->name())); else title += fmt (": <anonymous>"); @@ -272,10 +272,10 @@ { // Append title LDComment* comm = static_cast<LDComment*> (getCurrentDocument()->getObject (0)); - title += fmt (": %1", comm->text); + title += fmt (": %1", comm->text()); } - if (getCurrentDocument()->getHistory()->getPosition() != getCurrentDocument()->getSavePosition()) + if (getCurrentDocument()->hasUnsavedChanges()) title += '*'; } @@ -326,7 +326,7 @@ ui->objectList->clear(); - for (LDObject* obj : getCurrentDocument()->getObjects()) + for (LDObject* obj : getCurrentDocument()->objects()) { QString descr; @@ -334,7 +334,7 @@ { case LDObject::EComment: { - descr = static_cast<LDComment*> (obj)->text; + descr = static_cast<LDComment*> (obj)->text(); // Remove leading whitespace while (descr[0] == ' ') @@ -377,10 +377,10 @@ { LDSubfile* ref = static_cast<LDSubfile*> (obj); - descr = fmt ("%1 %2, (", ref->getFileInfo()->getDisplayName(), ref->getPosition().toString (true)); + descr = fmt ("%1 %2, (", ref->fileInfo()->getDisplayName(), ref->position().toString (true)); for (int i = 0; i < 9; ++i) - descr += fmt ("%1%2", ref->getTransform()[i], (i != 8) ? " " : ""); + descr += fmt ("%1%2", ref->transform()[i], (i != 8) ? " " : ""); descr += ')'; break; @@ -388,16 +388,16 @@ case LDObject::EBFC: { - descr = LDBFC::k_statementStrings[static_cast<LDBFC*> (obj)->m_statement]; + descr = LDBFC::k_statementStrings[static_cast<LDBFC*> (obj)->statement()]; break; } case LDObject::EOverlay: { LDOverlay* ovl = static_cast<LDOverlay*> (obj); - descr = fmt ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->getCamera()], - basename (ovl->getFileName()), ovl->getX(), ovl->getY(), - ovl->getWidth(), ovl->getHeight()); + descr = fmt ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->camera()], + basename (ovl->fileName()), ovl->x(), ovl->y(), + ovl->width(), ovl->height()); break; } @@ -425,11 +425,11 @@ item->setBackground (QColor ("#AA0000")); item->setForeground (QColor ("#FFAA00")); } - elif (lv_colorize && obj->isColored() && obj->getColor() != maincolor && obj->getColor() != edgecolor) + elif (lv_colorize && obj->isColored() && obj->color() != maincolor && obj->color() != edgecolor) { // If the object isn't in the main or edge color, draw this // list entry in said color. - LDColor* col = getColor (obj->getColor()); + LDColor* col = getColor (obj->color()); if (col) item->setForeground (col->faceColor); @@ -474,7 +474,7 @@ getCurrentDocument()->clearSelection(); const QList<QListWidgetItem*> items = ui->objectList->selectedItems(); - for (LDObject* obj : getCurrentDocument()->getObjects()) + for (LDObject* obj : getCurrentDocument()->objects()) { for (QListWidgetItem* item : items) { @@ -513,9 +513,9 @@ for (const LDQuickColor& entry : m_quickColors) { - if (entry.getToolButton() == button) + if (entry.toolButton() == button) { - col = entry.getColor(); + col = entry.color(); break; } } @@ -572,7 +572,7 @@ { g_isSelectionLocked = true; - for (LDObject* obj : getCurrentDocument()->getObjects()) + for (LDObject* obj : getCurrentDocument()->objects()) obj->setSelected (false); ui->objectList->clearSelection(); @@ -601,11 +601,11 @@ if (obj->isColored() == false) continue; // doesn't use color - if (result != -1 && obj->getColor() != result) + if (result != -1 && obj->color() != result) return -1; // No consensus in object color if (result == -1) - result = obj->getColor(); + result = obj->color(); } return result; @@ -619,7 +619,7 @@ for (LDObject* obj : selection()) { - if (result != LDObject::EUnidentified && obj->getColor() != result) + if (result != LDObject::EUnidentified && obj->color() != result) return LDObject::EUnidentified; if (result == LDObject::EUnidentified) @@ -695,36 +695,28 @@ } // ============================================================================= -// TODO: what the heh? // -void MainWindow::deleteObjects (LDObjectList objs) +void MainWindow::deleteByColor (const int colnum) { + LDObjectList objs; + + for (LDObject* obj : getCurrentDocument()->objects()) + { + if (!obj->isColored() || obj->color() != colnum) + continue; + + objs << obj; + } + for (LDObject* obj : objs) obj->destroy(); } // ============================================================================= // -void MainWindow::deleteByColor (const int colnum) -{ - LDObjectList objs; - - for (LDObject* obj : getCurrentDocument()->getObjects()) - { - if (!obj->isColored() || obj->getColor() != colnum) - continue; - - objs << obj; - } - - deleteObjects (objs); -} - -// ============================================================================= -// void MainWindow::updateEditModeActions() { - const EditMode mode = R()->getEditMode(); + const EditMode mode = R()->editMode(); ui->actionModeSelect->setChecked (mode == ESelectMode); ui->actionModeDraw->setChecked (mode == EDrawMode); ui->actionModeCircle->setChecked (mode == ECircleMode); @@ -736,7 +728,7 @@ { LDObject* obj = null; - for (LDObject* it : getCurrentDocument()->getObjects()) + for (LDObject* it : getCurrentDocument()->objects()) { if (it->qObjListEntry == listitem) { @@ -752,16 +744,16 @@ // bool MainWindow::save (LDDocument* f, bool saveAs) { - QString path = f->getFullPath(); + QString path = f->fullPath(); if (saveAs || path.isEmpty()) { - QString name = f->getDefaultName(); + QString name = f->defaultName(); - if (!f->getFullPath().isEmpty()) - name = f->getFullPath(); - elif (!f->getName().isEmpty()) - name = f->getName(); + if (!f->fullPath().isEmpty()) + name = f->fullPath(); + elif (!f->name().isEmpty()) + name = f->name(); name.replace ("\\", "/"); path = QFileDialog::getSaveFileName (g_win, tr ("Save As"), @@ -872,15 +864,15 @@ { std::map<int, int> counts; - for (LDObject* obj : getCurrentDocument()->getObjects()) + for (LDObject* obj : getCurrentDocument()->objects()) { if (!obj->isColored()) continue; - if (counts.find (obj->getColor()) == counts.end()) - counts[obj->getColor()] = 1; + if (counts.find (obj->color()) == counts.end()) + counts[obj->color()] = 1; else - counts[obj->getColor()]++; + counts[obj->color()]++; } box->clear(); @@ -927,7 +919,7 @@ bool oldUpdatingTabs = m_updatingTabs; m_updatingTabs = true; - if (f->getTabIndex() == -1) + if (f->tabIndex() == -1) { // We don't have a list item for this file, so the list either doesn't // exist yet or is out of date. Build the list now. @@ -938,12 +930,12 @@ // If this is the current file, it also needs to be the selected item on // the list. if (f == getCurrentDocument()) - m_tabs->setCurrentIndex (f->getTabIndex()); + m_tabs->setCurrentIndex (f->tabIndex()); - m_tabs->setTabText (f->getTabIndex(), f->getDisplayName()); + m_tabs->setTabText (f->tabIndex(), f->getDisplayName()); // If the document.has unsaved changes, draw a little icon next to it to mark that. - m_tabs->setTabIcon (f->getTabIndex(), f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); + m_tabs->setTabIcon (f->tabIndex(), f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); m_updatingTabs = oldUpdatingTabs; } @@ -961,7 +953,7 @@ // Find the file pointer of the item that was selected. for (LDDocument* it : g_loadedFiles) { - if (it->getTabIndex() == tabIndex) + if (it->tabIndex() == tabIndex) { f = it; break; @@ -992,8 +984,8 @@ void MainWindow::updateActions() { - History* his = getCurrentDocument()->getHistory(); - int pos = his->getPosition(); + History* his = getCurrentDocument()->history(); + int pos = his->position(); ui->actionUndo->setEnabled (pos != -1); ui->actionRedo->setEnabled (pos < (long) his->getSize() - 1); ui->actionAxes->setChecked (gl_axes); @@ -1010,8 +1002,8 @@ // ============================================================================= // LDQuickColor::LDQuickColor (LDColor* color, QToolButton* toolButton) : - m_Color (color), - m_ToolButton (toolButton) {} + m_color (color), + m_toolButton (toolButton) {} LDQuickColor LDQuickColor::getSeparator() { @@ -1020,5 +1012,5 @@ bool LDQuickColor::isSeparator() const { - return getColor() == null; + return color() == null; }
--- a/src/MainWindow.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/MainWindow.h Wed Mar 05 05:30:36 2014 +0200 @@ -57,8 +57,8 @@ // ============================================================================= class LDQuickColor { - PROPERTY (public, LDColor*, Color, NO_OPS, STOCK_WRITE) - PROPERTY (public, QToolButton*, ToolButton, NO_OPS, STOCK_WRITE) + PROPERTY (public, LDColor*, color, setColor, STOCK_WRITE) + PROPERTY (public, QToolButton*, toolButton, setToolButton, STOCK_WRITE) public: LDQuickColor (LDColor* color, QToolButton* toolButton); @@ -109,7 +109,6 @@ LDObject::Type getUniformSelectedType(); void scrollToSelection(); void spawnContextMenu (const QPoint pos); - void deleteObjects (LDObjectList objs); int deleteSelection(); void deleteByColor (const int colnum); bool save (LDDocument* f, bool saveAs);
--- a/src/MessageLog.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/MessageLog.cc Wed Mar 05 05:30:36 2014 +0200 @@ -83,8 +83,8 @@ m_lines << Line (line); // Update the renderer view - if (getRenderer()) - getRenderer()->update(); + if (renderer()) + renderer()->update(); } // ============================================================================= @@ -108,8 +108,8 @@ changed |= lineChanged; } - if (changed && getRenderer()) - getRenderer()->update(); + if (changed && renderer()) + renderer()->update(); } // =============================================================================
--- a/src/MessageLog.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/MessageLog.h Wed Mar 05 05:30:36 2014 +0200 @@ -38,7 +38,7 @@ class MessageManager : public QObject { Q_OBJECT - PROPERTY (public, GLRenderer*, Renderer, NO_OPS, STOCK_WRITE) + PROPERTY (public, GLRenderer*, renderer, setRenderer, STOCK_WRITE) public: // Single line of the message log.
--- a/src/Misc.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Misc.cc Wed Mar 05 05:30:36 2014 +0200 @@ -220,7 +220,7 @@ for (LDObject* obj : objs) { if (obj->hasMatrix()) - box << dynamic_cast<LDMatrixObject*> (obj)->getPosition(); + box << dynamic_cast<LDMatrixObject*> (obj)->position(); else box << obj; }
--- a/src/Misc.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Misc.h Wed Mar 05 05:30:36 2014 +0200 @@ -45,7 +45,7 @@ struct gridinfo { const char* const name; - float* const confs[4]; + float* const confs[4]; }; extern_cfg (Int, grid);
--- a/src/PartDownloader.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/PartDownloader.cc Wed Mar 05 05:30:36 2014 +0200 @@ -73,17 +73,17 @@ PartDownloader::PartDownloader (QWidget* parent) : QDialog (parent) { setInterface (new Ui_DownloadFrom); - getInterface()->setupUi (this); - getInterface()->fname->setFocus(); - getInterface()->progress->horizontalHeader()->setResizeMode (PartLabelColumn, QHeaderView::Stretch); + interface()->setupUi (this); + interface()->fname->setFocus(); + interface()->progress->horizontalHeader()->setResizeMode (PartLabelColumn, QHeaderView::Stretch); setDownloadButton (new QPushButton (tr ("Download"))); - getInterface()->buttonBox->addButton (getDownloadButton(), QDialogButtonBox::ActionRole); + interface()->buttonBox->addButton (downloadButton(), QDialogButtonBox::ActionRole); getButton (Abort)->setEnabled (false); - connect (getInterface()->source, SIGNAL (currentIndexChanged (int)), + connect (interface()->source, SIGNAL (currentIndexChanged (int)), this, SLOT (sourceChanged (int))); - connect (getInterface()->buttonBox, SIGNAL (clicked (QAbstractButton*)), + connect (interface()->buttonBox, SIGNAL (clicked (QAbstractButton*)), this, SLOT (buttonClicked (QAbstractButton*))); } @@ -91,7 +91,7 @@ // PartDownloader::~PartDownloader() { - delete getInterface(); + delete interface(); } // ============================================================================= @@ -104,12 +104,12 @@ switch (src) { case PartsTracker: - dest = getInterface()->fname->text(); + dest = interface()->fname->text(); modifyDestination (dest); return g_unofficialLibraryURL + dest; case CustomURL: - return getInterface()->fname->text(); + return interface()->fname->text(); } // Shouldn't happen @@ -182,7 +182,7 @@ // PartDownloader::Source PartDownloader::getSource() const { - return (Source) getInterface()->source->currentIndex(); + return (Source) interface()->source->currentIndex(); } // ============================================================================= @@ -190,9 +190,9 @@ void PartDownloader::sourceChanged (int i) { if (i == CustomURL) - getInterface()->fileNameLabel->setText (tr ("URL:")); + interface()->fileNameLabel->setText (tr ("URL:")); else - getInterface()->fileNameLabel->setText (tr ("File name:")); + interface()->fileNameLabel->setText (tr ("File name:")); } // ============================================================================= @@ -207,12 +207,12 @@ { setAborted (true); - for (PartDownloadRequest* req : getRequests()) + for (PartDownloadRequest* req : requests()) req->abort(); } elif (btn == getButton (Download)) { - QString dest = getInterface()->fname->text(); + QString dest = interface()->fname->text(); setPrimaryFile (null); setAborted (false); @@ -228,10 +228,10 @@ return; } - getDownloadButton()->setEnabled (false); - getInterface()->progress->setEnabled (true); - getInterface()->fname->setEnabled (false); - getInterface()->source->setEnabled (false); + downloadButton()->setEnabled (false); + interface()->progress->setEnabled (true); + interface()->fname->setEnabled (false); + interface()->source->setEnabled (false); downloadFile (dest, getURL(), true); getButton (Close)->setEnabled (false); getButton (Abort)->setEnabled (true); @@ -243,19 +243,17 @@ // void PartDownloader::downloadFile (QString dest, QString url, bool primary) { - const int row = getInterface()->progress->rowCount(); + const int row = interface()->progress->rowCount(); // Don't download files repeadetly. - if (getFilesToDownload().indexOf (dest) != -1) + if (filesToDownload().indexOf (dest) != -1) return; modifyDestination (dest); - log ("DOWNLOAD: %1 -> %2\n", url, PartDownloader::getDownloadPath() + DIRSLASH + dest); PartDownloadRequest* req = new PartDownloadRequest (url, dest, primary, this); - - pushToFilesToDownload (dest); - pushToRequests (req); - getInterface()->progress->insertRow (row); + m_filesToDownload << dest; + m_requests << req; + interface()->progress->insertRow (row); req->setTableRow (row); req->updateToTable(); } @@ -267,24 +265,24 @@ bool failed = isAborted(); // If there is some download still working, we're not finished. - for (PartDownloadRequest* req : getRequests()) + for (PartDownloadRequest* req : requests()) { if (!req->isFinished()) return; - if (req->getState() == PartDownloadRequest::EFailed) + if (req->state() == PartDownloadRequest::EFailed) failed = true; } - for (PartDownloadRequest* req : getRequests()) + for (PartDownloadRequest* req : requests()) delete req; - clearRequests(); + m_requests.clear(); // Update everything now - if (getPrimaryFile()) + if (primaryFile() != null) { - LDDocument::setCurrent (getPrimaryFile()); + LDDocument::setCurrent (primaryFile()); reloadAllSubfiles(); g_win->doFullRefresh(); g_win->R()->resetAngles(); @@ -310,13 +308,13 @@ switch (i) { case Download: - return getDownloadButton(); + return downloadButton(); case Abort: - return qobject_cast<QPushButton*> (getInterface()->buttonBox->button (QDialogButtonBox::Abort)); + return qobject_cast<QPushButton*> (interface()->buttonBox->button (QDialogButtonBox::Abort)); case Close: - return qobject_cast<QPushButton*> (getInterface()->buttonBox->button (QDialogButtonBox::Close)); + return qobject_cast<QPushButton*> (interface()->buttonBox->button (QDialogButtonBox::Close)); } return null; @@ -326,18 +324,18 @@ // PartDownloadRequest::PartDownloadRequest (QString url, QString dest, bool primary, PartDownloader* parent) : QObject (parent), - m_State (ERequesting), - m_Prompt (parent), - m_URL (url), - m_Destinaton (dest), - m_FilePath (PartDownloader::getDownloadPath() + DIRSLASH + dest), - m_NAM (new QNetworkAccessManager), - m_FirstUpdate (true), - m_Primary (primary), - m_FilePointer (null) + m_state (ERequesting), + m_prompt (parent), + m_url (url), + m_destinaton (dest), + m_filePath (PartDownloader::getDownloadPath() + DIRSLASH + dest), + m_networkManager (new QNetworkAccessManager), + m_isFirstUpdate (true), + m_isPrimary (primary), + m_filePointer (null) { // Make sure that we have a valid destination. - QString dirpath = dirname (getFilePath()); + QString dirpath = dirname (filePath()); QDir dir (dirpath); @@ -349,10 +347,10 @@ critical (fmt (tr ("Couldn't create the directory %1!"), dirpath)); } - setReply (getNAM()->get (QNetworkRequest (QUrl (url)))); - connect (getReply(), SIGNAL (finished()), this, SLOT (downloadFinished())); - connect (getReply(), SIGNAL (readyRead()), this, SLOT (readyRead())); - connect (getReply(), SIGNAL (downloadProgress (qint64, qint64)), + setNetworkReply (networkManager()->get (QNetworkRequest (QUrl (url)))); + connect (networkReply(), SIGNAL (finished()), this, SLOT (downloadFinished())); + connect (networkReply(), SIGNAL (readyRead()), this, SLOT (readyRead())); + connect (networkReply(), SIGNAL (downloadProgress (qint64, qint64)), this, SLOT (downloadProgress (qint64, qint64))); } @@ -365,46 +363,46 @@ void PartDownloadRequest::updateToTable() { const int labelcol = PartDownloader::PartLabelColumn, - progcol = PartDownloader::ProgressColumn; - QTableWidget* table = getPrompt()->getInterface()->progress; + progcol = PartDownloader::ProgressColumn; + QTableWidget* table = prompt()->interface()->progress; QProgressBar* prog; - switch (getState()) + switch (state()) { case ERequesting: case EDownloading: { - prog = qobject_cast<QProgressBar*> (table->cellWidget (getTableRow(), progcol)); + prog = qobject_cast<QProgressBar*> (table->cellWidget (tableRow(), progcol)); if (!prog) { prog = new QProgressBar; - table->setCellWidget (getTableRow(), progcol, prog); + table->setCellWidget (tableRow(), progcol, prog); } - prog->setRange (0, getBytesTotal()); - prog->setValue (getBytesRead()); + prog->setRange (0, numBytesTotal()); + prog->setValue (numBytesRead()); } break; case EFinished: case EFailed: { - const QString text = (getState() == EFinished) + const QString text = (state() == EFinished) ? "<b><span style=\"color: #080\">FINISHED</span></b>" : "<b><span style=\"color: #800\">FAILED</span></b>"; QLabel* lb = new QLabel (text); lb->setAlignment (Qt::AlignCenter); - table->setCellWidget (getTableRow(), progcol, lb); + table->setCellWidget (tableRow(), progcol, lb); } break; } - QLabel* lb = qobject_cast<QLabel*> (table->cellWidget (getTableRow(), labelcol)); + QLabel* lb = qobject_cast<QLabel*> (table->cellWidget (tableRow(), labelcol)); if (isFirstUpdate()) { - lb = new QLabel (fmt ("<b>%1</b>", getDestinaton()), table); - table->setCellWidget (getTableRow(), labelcol, lb); + lb = new QLabel (fmt ("<b>%1</b>", destinaton()), table); + table->setCellWidget (tableRow(), labelcol, lb); } // Make sure that the cell is big enough to contain the label @@ -418,37 +416,37 @@ // void PartDownloadRequest::downloadFinished() { - if (getReply()->error() != QNetworkReply::NoError) + if (networkReply()->error() != QNetworkReply::NoError) { - if (isPrimary() && !getPrompt()->isAborted()) - critical (getReply()->errorString()); + if (isPrimary() && !prompt()->isAborted()) + critical (networkReply()->errorString()); setState (EFailed); } - elif (getState() != EFailed) + elif (state() != EFailed) setState (EFinished); - setBytesRead (getBytesTotal()); + setNumBytesRead (numBytesTotal()); updateToTable(); - if (getFilePointer()) + if (filePointer()) { - getFilePointer()->close(); - delete getFilePointer(); + filePointer()->close(); + delete filePointer(); setFilePointer (null); - if (getState() == EFailed) - QFile::remove (getFilePath()); + if (state() == EFailed) + QFile::remove (filePath()); } - if (getState() != EFinished) + if (state() != EFinished) { - getPrompt()->checkIfFinished(); + prompt()->checkIfFinished(); return; } // Try to load this file now. - LDDocument* f = openDocument (getFilePath(), false); + LDDocument* f = openDocument (filePath(), false); if (!f) return; @@ -459,33 +457,33 @@ // from unknown file references, try resolve that by downloading the reference. // This is why downloading a part may end up downloading multiple files, as // it resolves dependencies. - for (LDObject* obj : f->getObjects()) + for (LDObject* obj : f->objects()) { LDError* err = dynamic_cast<LDError*> (obj); - if (!err || err->getFileReferenced().isEmpty()) + if (err == null || err->fileReferenced().isEmpty()) continue; - QString dest = err->getFileReferenced(); - getPrompt()->modifyDestination (dest); - getPrompt()->downloadFile (dest, g_unofficialLibraryURL + dest, false); + QString dest = err->fileReferenced(); + prompt()->modifyDestination (dest); + prompt()->downloadFile (dest, g_unofficialLibraryURL + dest, false); } if (isPrimary()) { - addRecentFile (getFilePath()); - getPrompt()->setPrimaryFile (f); + addRecentFile (filePath()); + prompt()->setPrimaryFile (f); } - getPrompt()->checkIfFinished(); + prompt()->checkIfFinished(); } // ============================================================================= // void PartDownloadRequest::downloadProgress (int64 recv, int64 total) { - setBytesRead (recv); - setBytesTotal (total); + setNumBytesRead (recv); + setNumBytesTotal (total); setState (EDownloading); updateToTable(); } @@ -494,43 +492,43 @@ // void PartDownloadRequest::readyRead() { - if (getState() == EFailed) + if (state() == EFailed) return; - if (getFilePointer() == null) + if (filePointer() == null) { - replaceInFilePath ("\\", "/"); + m_filePath.replace ("\\", "/"); // We have already asked the user whether we can overwrite so we're good // to go here. - setFilePointer (new QFile (getFilePath().toLocal8Bit())); + setFilePointer (new QFile (filePath().toLocal8Bit())); - if (!getFilePointer()->open (QIODevice::WriteOnly)) + if (!filePointer()->open (QIODevice::WriteOnly)) { - critical (fmt (tr ("Couldn't open %1 for writing: %2"), getFilePath(), strerror (errno))); + critical (fmt (tr ("Couldn't open %1 for writing: %2"), filePath(), strerror (errno))); setState (EFailed); - getReply()->abort(); + networkReply()->abort(); updateToTable(); - getPrompt()->checkIfFinished(); + prompt()->checkIfFinished(); return; } } - getFilePointer()->write (getReply()->readAll()); + filePointer()->write (networkReply()->readAll()); } // ============================================================================= // bool PartDownloadRequest::isFinished() const { - return getState() == EFinished || getState() == EFailed; + return state() == EFinished || state() == EFailed; } // ============================================================================= // void PartDownloadRequest::abort() { - getReply()->abort(); + networkReply()->abort(); } // =============================================================================
--- a/src/PartDownloader.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/PartDownloader.h Wed Mar 05 05:30:36 2014 +0200 @@ -34,7 +34,7 @@ // class PartDownloader : public QDialog { - typedefs: + public: enum Source { PartsTracker, @@ -56,26 +56,25 @@ using RequestList = QList<PartDownloadRequest*>; - properties: Q_OBJECT - PROPERTY (public, LDDocument*, PrimaryFile, NO_OPS, STOCK_WRITE) - PROPERTY (public, bool, Aborted, BOOL_OPS, STOCK_WRITE) - PROPERTY (private, Ui_DownloadFrom*, Interface, NO_OPS, STOCK_WRITE) - PROPERTY (private, QStringList, FilesToDownload, LIST_OPS, STOCK_WRITE) - PROPERTY (private, RequestList, Requests, LIST_OPS, STOCK_WRITE) - PROPERTY (private, QPushButton*, DownloadButton, NO_OPS, STOCK_WRITE) + PROPERTY (public, LDDocument*, primaryFile, setPrimaryFile, STOCK_WRITE) + PROPERTY (public, bool, isAborted, setAborted, STOCK_WRITE) + PROPERTY (private, Ui_DownloadFrom*, interface, setInterface, STOCK_WRITE) + PROPERTY (private, QStringList, filesToDownload, setFilesToDownload, STOCK_WRITE) + PROPERTY (private, RequestList, requests, setRequests, STOCK_WRITE) + PROPERTY (private, QPushButton*, downloadButton, setDownloadButton, STOCK_WRITE) public: explicit PartDownloader (QWidget* parent = null); virtual ~PartDownloader(); void downloadFile (QString dest, QString url, bool primary); - QPushButton* getButton (Button i); - QString getURL() const; + QPushButton* getButton (Button i); + QString getURL() const; Source getSource() const; void modifyDestination (QString& dest) const; - static QString getDownloadPath(); + static QString getDownloadPath(); static void staticBegin(); public slots: @@ -88,7 +87,7 @@ // class PartDownloadRequest : public QObject { - typedefs: + public: enum EState { ERequesting, @@ -97,21 +96,20 @@ EFailed, }; - properties: Q_OBJECT - 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, 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) - PROPERTY (private, int64, BytesRead, NUM_OPS, STOCK_WRITE) - PROPERTY (private, int64, BytesTotal, NUM_OPS, STOCK_WRITE) - PROPERTY (private, bool, Primary, BOOL_OPS, STOCK_WRITE) - PROPERTY (private, QFile*, FilePointer, NO_OPS, STOCK_WRITE) + PROPERTY (public, int, tableRow, setTableRow, STOCK_WRITE) + PROPERTY (private, EState, state, setState, STOCK_WRITE) + PROPERTY (private, PartDownloader*, prompt, setPrompt, STOCK_WRITE) + PROPERTY (private, QString, url, setURL, STOCK_WRITE) + PROPERTY (private, QString, destinaton, setDestination, STOCK_WRITE) + PROPERTY (private, QString, filePath, setFilePath, STOCK_WRITE) + PROPERTY (private, QNetworkAccessManager*, networkManager, setNetworkManager, STOCK_WRITE) + PROPERTY (private, QNetworkReply*, networkReply, setNetworkReply, STOCK_WRITE) + PROPERTY (private, bool, isFirstUpdate, setFirstUpdate, STOCK_WRITE) + PROPERTY (private, int64, numBytesRead, setNumBytesRead, STOCK_WRITE) + PROPERTY (private, int64, numBytesTotal, setNumBytesTotal, STOCK_WRITE) + PROPERTY (private, bool, isPrimary, setPrimary, STOCK_WRITE) + PROPERTY (private, QFile*, filePointer, setFilePointer, STOCK_WRITE) public: explicit PartDownloadRequest (QString url, QString dest, bool primary, PartDownloader* parent); @@ -119,7 +117,6 @@ virtual ~PartDownloadRequest(); void updateToTable(); bool isFinished() const; - void operator= (const PartDownloadRequest&) = delete; public slots:
--- a/src/Primitives.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Primitives.cc Wed Mar 05 05:30:36 2014 +0200 @@ -143,7 +143,7 @@ Primitive info; info.name = fname.mid (m_baselen + 1); // make full path relative info.name.replace ('/', '\\'); // use DOS backslashes, they're expected - info.cat = null; + info.category = null; QByteArray titledata = f.readLine(); if (titledata != QByteArray()) @@ -207,7 +207,7 @@ // PrimitiveCategory::PrimitiveCategory (QString name, QObject* parent) : QObject (parent), - m_Name (name) {} + m_name (name) {} // ============================================================================= // @@ -220,7 +220,7 @@ for (Primitive& prim : g_primitives) { bool matched = false; - prim.cat = null; + prim.category = null; // Go over the categories and their regexes, if and when there's a match, // the primitive's category is set to the category the regex beloings to. @@ -245,20 +245,20 @@ if (matched) { - prim.cat = cat; + prim.category = cat; break; } } // Drop out if a category was decided on. - if (prim.cat != null) + if (prim.category != null) break; } // If there was a match, add the primitive to the category. // Otherwise, add it to the list of unmatched primitives. - if (prim.cat != null) - prim.cat->prims << prim; + if (prim.category != null) + prim.category->prims << prim; else g_unmatched->prims << prim; } @@ -308,7 +308,7 @@ elif (cat != null) { QString cmd = line.left (colon); - ERegexType type = EFilenameRegex; + RegexType type = EFilenameRegex; if (cmd == "f") type = EFilenameRegex; @@ -345,7 +345,7 @@ { if (regexes.size() == 0) { - log (tr ("Warning: category \"%1\" left without patterns"), getName()); + log (tr ("Warning: category \"%1\" left without patterns"), name()); deleteLater(); return false; } @@ -565,7 +565,7 @@ } // Compose some general information: prefix, fraction, root, ring number - QString prefix = (divs == lores) ? "" : fmt ("%1/", divs); + QString prefix = (divs == g_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) : ""; @@ -604,7 +604,7 @@ descr = fmt ("%1 %2", primitiveTypeName (type), frac); // Prepend "Hi-Res" if 48/ primitive. - if (divs == hires) + if (divs == g_hires) descr.insert (0, "Hi-Res "); LDDocument* f = new LDDocument; @@ -624,7 +624,7 @@ new LDComment (descr), new LDComment (fmt ("Name: %1", name)), new LDComment (fmt ("Author: %1", author)), - new LDComment (fmt ("!LDRAW_ORG Unofficial_%1Primitive", divs == hires ? "48_" : "")), + new LDComment (fmt ("!LDRAW_ORG Unofficial_%1Primitive", divs == g_hires ? "48_" : "")), new LDComment (license), new LDEmpty, new LDBFC (LDBFC::CertifyCCW), @@ -669,12 +669,12 @@ // void PrimitivePrompt::hiResToggled (bool on) { - ui->sb_segs->setMaximum (on ? hires : lores); + ui->sb_segs->setMaximum (on ? g_hires : g_lores); // If the current value is 16 and we switch to hi-res, default the // spinbox to 48. - if (on && ui->sb_segs->value() == lores) - ui->sb_segs->setValue (hires); + if (on && ui->sb_segs->value() == g_lores) + ui->sb_segs->setValue (g_hires); } // ============================================================================= @@ -687,7 +687,7 @@ return; int segs = dlg->ui->sb_segs->value(); - int divs = dlg->ui->cb_hires->isChecked() ? hires : lores; + int divs = dlg->ui->cb_hires->isChecked() ? g_hires : g_lores; int num = dlg->ui->sb_ringnum->value(); PrimitiveType type = dlg->ui->rb_circle->isChecked() ? Circle :
--- a/src/Primitives.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Primitives.h Wed Mar 05 05:30:36 2014 +0200 @@ -27,17 +27,18 @@ class PrimitiveCategory; struct Primitive { - QString name, title; - PrimitiveCategory* cat; + QString name, + title; + PrimitiveCategory* category; }; class PrimitiveCategory : public QObject { Q_OBJECT - PROPERTY (public, QString, Name, STR_OPS, STOCK_WRITE) + PROPERTY (public, QString, name, setName, STOCK_WRITE) public: - enum ERegexType + enum RegexType { EFilenameRegex, ETitleRegex @@ -46,7 +47,7 @@ struct RegexEntry { QRegExp regex; - ERegexType type; + RegexType type; }; QList<RegexEntry> regexes; @@ -60,13 +61,12 @@ }; // ============================================================================= -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// ============================================================================= +// // PrimitiveScanner // // Worker object that scans the primitives folder for primitives and // builds an index of them. -// ============================================================================= +// class PrimitiveScanner : public QObject { Q_OBJECT
--- a/src/PropertyMacro.h Wed Mar 05 03:45:49 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,200 +0,0 @@ -/* - * LDForge: LDraw parts authoring CAD - * Copyright (C) 2013, 2014 Santeri Piippo - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -// ============================================================================= -// -// Identifier names -// -#define PROPERTY_SET_ACCESSOR(NAME) set##NAME -#define PROPERTY_GET_ACCESSOR(NAME) get##NAME -#define PROPERTY_IS_ACCESSOR(NAME) is##NAME // for bool types -#define PROPERTY_MEMBER_NAME(NAME) m_##NAME - -// Names of operations -#define PROPERTY_APPEND_OPERATION(NAME) appendTo##NAME -#define PROPERTY_PREPEND_OPERATION(NAME) prependTo##NAME -#define PROPERTY_REPLACE_OPERATION(NAME) replaceIn##NAME -#define PROPERTY_INCREASE_OPERATION(NAME) increase##NAME -#define PROPERTY_DECREASE_OPERATION(NAME) decrease##NAME -#define PROPERTY_TOGGLE_OPERATION(NAME) toggle##NAME -#define PROPERTY_PUSH_OPERATION(NAME) pushTo##NAME -#define PROPERTY_REMOVE_OPERATION(NAME) removeFrom##NAME -#define PROPERTY_CLEAR_OPERATION(NAME) clear##NAME -#define PROPERTY_COUNT_OPERATION(NAME) count##NAME - -// Operation definitions -// These are the methods of the list type that are called in the operations. -#define PROPERTY_APPEND_METHOD_NAME append // QString::append -#define PROPERTY_PREPEND_METHOD_NAME prepend // QString::prepend -#define PROPERTY_REPLACE_METHOD_NAME replace // QString::replace -#define PROPERTY_PUSH_METHOD_NAME append // QList<T>::append -#define PROPERTY_REMOVE_METHOD_NAME removeOne // QList<T>::removeOne -#define PROPERTY_CLEAR_METHOD_NAME clear // QList<T>::clear - -// ============================================================================= -// -// Main PROPERTY macro -// -#define PROPERTY(ACCESS, TYPE, NAME, OPS, WRITETYPE) \ - private: \ - TYPE PROPERTY_MEMBER_NAME(NAME); \ - \ - public: \ - inline TYPE const& PROPERTY_GET_READ_METHOD (NAME, OPS) const \ - { \ - return PROPERTY_MEMBER_NAME(NAME); \ - } \ - \ - ACCESS: \ - PROPERTY_MAKE_WRITE (TYPE, NAME, WRITETYPE) \ - PROPERTY_DEFINE_OPERATIONS (TYPE, NAME, OPS) - -// ============================================================================= -// -// PROPERTY_GET_READ_METHOD -// -// This macro uses the OPS argument to construct the name of the actual -// macro which returns the name of the get accessor. This is so that the -// bool properties get is<NAME>() accessors while non-bools get get<NAME>() -// -#define PROPERTY_GET_READ_METHOD(NAME, OPS) \ - PROPERTY_GET_READ_METHOD_##OPS (NAME) - -#define PROPERTY_GET_READ_METHOD_BOOL_OPS(NAME) PROPERTY_IS_ACCESSOR (NAME)() -#define PROPERTY_GET_READ_METHOD_NO_OPS(NAME) PROPERTY_GET_ACCESSOR (NAME)() -#define PROPERTY_GET_READ_METHOD_STR_OPS(NAME) PROPERTY_GET_ACCESSOR (NAME)() -#define PROPERTY_GET_READ_METHOD_NUM_OPS(NAME) PROPERTY_GET_ACCESSOR (NAME)() -#define PROPERTY_GET_READ_METHOD_LIST_OPS(NAME) PROPERTY_GET_ACCESSOR (NAME)() - -// ============================================================================= -// -// PROPERTY_MAKE_WRITE -// -// This macro uses the WRITETYPE argument to construct the set accessor of the -// property. If WRITETYPE is STOCK_WRITE, an inline method is defined to just -// set the new value of the property. If WRITETYPE is CUSTOM_WRITE, the accessor -// is merely declared and is left for the user to define. -// -#define PROPERTY_MAKE_WRITE(TYPE, NAME, WRITETYPE) \ - PROPERTY_MAKE_WRITE_##WRITETYPE (TYPE, NAME) - -#define PROPERTY_MAKE_WRITE_STOCK_WRITE(TYPE, NAME) \ - inline void set##NAME (TYPE const& new##NAME) \ - { \ - PROPERTY_MEMBER_NAME(NAME) = new##NAME; \ - } - -#define PROPERTY_MAKE_WRITE_CUSTOM_WRITE(TYPE, NAME) \ - void set##NAME (TYPE const& new##NAME); \ - -// ============================================================================= -// -// PROPERTY_DEFINE_OPERATIONS -// -// This macro may expand into methods defining additional operations for the -// method. - -#define PROPERTY_DEFINE_OPERATIONS(TYPE, NAME, OPS) \ - DEFINE_PROPERTY_##OPS (TYPE, NAME) - -// ============================================================================= -// -// DEFINE_PROPERTY_NO_OPS -// -// Obviously NO_OPS expands into no operations. -// -#define DEFINE_PROPERTY_NO_OPS(TYPE, NAME) - -// ============================================================================= -// -// DEFINE_PROPERTY_STR_OPS -// -#define DEFINE_PROPERTY_STR_OPS(TYPE, NAME) \ - void PROPERTY_APPEND_OPERATION(NAME) (const TYPE& a) \ - { \ - TYPE tmp (PROPERTY_MEMBER_NAME(NAME)); \ - tmp.PROPERTY_APPEND_METHOD_NAME (a); \ - set##NAME (tmp); \ - } \ - \ - void PROPERTY_PREPEND_OPERATION(NAME) (const TYPE& a) \ - { \ - TYPE tmp (PROPERTY_MEMBER_NAME(NAME)); \ - tmp.PROPERTY_PREPEND_METHOD_NAME (a); \ - set##NAME (tmp); \ - } \ - \ - void PROPERTY_REPLACE_OPERATION(NAME) (const TYPE& a, const TYPE& b) \ - { \ - TYPE tmp (PROPERTY_MEMBER_NAME(NAME)); \ - tmp.PROPERTY_REPLACE_METHOD_NAME (a, b); \ - set##NAME (tmp); \ - } - -// ============================================================================= -// -// DEFINE_PROPERTY_NUM_OPS -// -#define DEFINE_PROPERTY_NUM_OPS(TYPE, NAME) \ - inline void PROPERTY_INCREASE_OPERATION(NAME) (TYPE a = 1) \ - { \ - set##NAME (PROPERTY_MEMBER_NAME(NAME) + a); \ - } \ - \ - inline void PROPERTY_DECREASE_OPERATION(NAME) (TYPE a = 1) \ - { \ - set##NAME (PROPERTY_MEMBER_NAME(NAME) - a); \ - } - -// ============================================================================= -// -// DEFINE_PROPERTY_BOOL_OPS -// -#define DEFINE_PROPERTY_BOOL_OPS(TYPE, NAME) \ - inline void PROPERTY_TOGGLE_OPERATION(NAME)() \ - { \ - set##NAME (!PROPERTY_MEMBER_NAME(NAME)); \ - } - -// ============================================================================= -// -// DEFINE_PROPERTY_LIST_OPS -// -#define DEFINE_PROPERTY_LIST_OPS(TYPE, NAME) \ - void PROPERTY_PUSH_OPERATION(NAME) (const TYPE::value_type& a) \ - { \ - PROPERTY_MEMBER_NAME(NAME).PROPERTY_PUSH_METHOD_NAME (a); \ - } \ - \ - void PROPERTY_REMOVE_OPERATION(NAME) (const TYPE::value_type& a) \ - { \ - PROPERTY_MEMBER_NAME(NAME).PROPERTY_REMOVE_METHOD_NAME (a); \ - } \ - \ - inline void PROPERTY_CLEAR_OPERATION(NAME)() \ - { \ - PROPERTY_MEMBER_NAME(NAME).PROPERTY_CLEAR_METHOD_NAME(); \ - } \ - \ - public: \ - inline int PROPERTY_COUNT_OPERATION(NAME)() const \ - { \ - return PROPERTY_GET_ACCESSOR (NAME)().size(); \ - }
--- a/src/Types.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Types.cc Wed Mar 05 05:30:36 2014 +0200 @@ -307,7 +307,7 @@ if (!getCurrentDocument()) return; - for (LDObject* obj : getCurrentDocument()->getObjects()) + for (LDObject* obj : getCurrentDocument()->objects()) calcObject (obj); } @@ -366,8 +366,8 @@ { for_axes (ax) { - m_Vertex0[ax] = min (v[ax], m_Vertex0[ax]); - m_Vertex1[ax] = max (v[ax], m_Vertex1[ax]); + m_vertex0[ax] = min (v[ax], m_vertex0[ax]); + m_vertex1[ax] = max (v[ax], m_vertex1[ax]); } setEmpty (false); @@ -377,8 +377,8 @@ // void LDBoundingBox::reset() { - m_Vertex0[X] = m_Vertex0[Y] = m_Vertex0[Z] = 10000.0; - m_Vertex1[X] = m_Vertex1[Y] = m_Vertex1[Z] = -10000.0; + m_vertex0[X] = m_vertex0[Y] = m_vertex0[Z] = 10000.0; + m_vertex1[X] = m_vertex1[Y] = m_vertex1[Z] = -10000.0; setEmpty (true); } @@ -386,9 +386,9 @@ // double LDBoundingBox::size() const { - double xscale = (m_Vertex0[X] - m_Vertex1[X]); - double yscale = (m_Vertex0[Y] - m_Vertex1[Y]); - double zscale = (m_Vertex0[Z] - m_Vertex1[Z]); + double xscale = (m_vertex0[X] - m_vertex1[X]); + double yscale = (m_vertex0[Y] - m_vertex1[Y]); + double zscale = (m_vertex0[Z] - m_vertex1[Z]); double size = zscale; if (xscale > yscale) @@ -410,7 +410,7 @@ Vertex LDBoundingBox::center() const { return Vertex ( - (m_Vertex0[X] + m_Vertex1[X]) / 2, - (m_Vertex0[Y] + m_Vertex1[Y]) / 2, - (m_Vertex0[Z] + m_Vertex1[Z]) / 2); + (m_vertex0[X] + m_vertex1[X]) / 2, + (m_vertex0[Y] + m_vertex1[Y]) / 2, + (m_vertex0[Z] + m_vertex1[Z]) / 2); }
--- a/src/Types.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/Types.h Wed Mar 05 05:30:36 2014 +0200 @@ -21,7 +21,7 @@ #include <QObject> #include <QStringList> #include <QMetaType> -#include "PropertyMacro.h" +#include "Macros.h" class LDObject; class QFile; @@ -265,9 +265,9 @@ // ============================================================================= class LDBoundingBox { - PROPERTY (private, bool, Empty, BOOL_OPS, STOCK_WRITE) - PROPERTY (private, Vertex, Vertex0, NO_OPS, STOCK_WRITE) - PROPERTY (private, Vertex, Vertex1, NO_OPS, STOCK_WRITE) + PROPERTY (private, bool, isEmpty, setEmpty, STOCK_WRITE) + PROPERTY (private, Vertex, vertex0, setVertex0, STOCK_WRITE) + PROPERTY (private, Vertex, vertex1, setVertex1, STOCK_WRITE) public: LDBoundingBox();
--- a/src/actions/EditActions.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/actions/EditActions.cc Wed Mar 05 05:30:36 2014 +0200 @@ -217,7 +217,7 @@ ui.code->setText (obj->asText()); if (obj->type() == LDObject::EError) - ui.errorDescription->setText (static_cast<LDError*> (obj)->reason); + ui.errorDescription->setText (static_cast<LDError*> (obj)->reason()); else { ui.errorDescription->hide(); @@ -339,7 +339,7 @@ { LDVertex* vert = new LDVertex; vert->pos = obj->vertex (i); - vert->setColor (obj->getColor()); + vert->setColor (obj->color()); getCurrentDocument()->insertObj (++ln, vert); R()->compileObject (vert); @@ -502,12 +502,12 @@ LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj); // Transform the position - Vertex v = mo->getPosition(); + Vertex v = mo->position(); rotateVertex (v, rotpoint, transform); mo->setPosition (v); // Transform the matrix - mo->setTransform (transform * mo->getTransform()); + mo->setTransform (transform * mo->transform()); } elif (obj->type() == LDObject::EVertex) { @@ -568,8 +568,8 @@ if (mo != null) { - Vertex v = mo->getPosition(); - Matrix t = mo->getTransform(); + Vertex v = mo->position(); + Matrix t = mo->transform(); for_axes (ax) roundToDecimals (v[ax], 3); @@ -740,8 +740,8 @@ // static bool isColorUsed (int colnum) { - for (LDObject* obj : getCurrentDocument()->getObjects()) - if (obj->isColored() && obj->getColor() == colnum) + for (LDObject* obj : getCurrentDocument()->objects()) + if (obj->isColored() && obj->color() == colnum) return true; return false; @@ -810,7 +810,7 @@ { LDComment* comm = dynamic_cast<LDComment*> (obj); - if (comm && comm->text.startsWith ("!HISTORY ")) + if (comm != null && comm->text().startsWith ("!HISTORY ")) ishistory = true; if (prevIsHistory && !ishistory)
--- a/src/actions/MainActions.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/actions/MainActions.cc Wed Mar 05 05:30:36 2014 +0200 @@ -89,8 +89,8 @@ ui.rb_bfc_cw->isChecked() ? LDBFC::CertifyCW : LDBFC::NoCertify; const QString license = - ui.rb_license_ca->isChecked() ? CALicense : - ui.rb_license_nonca->isChecked() ? NonCALicense : ""; + ui.rb_license_ca->isChecked() ? g_CALicense : + ui.rb_license_nonca->isChecked() ? g_nonCALicense : ""; getCurrentDocument()->addObjects ( { @@ -285,7 +285,7 @@ // DEFINE_ACTION (SelectAll, CTRL (A)) { - for (LDObject* obj : getCurrentDocument()->getObjects()) + for (LDObject* obj : getCurrentDocument()->objects()) obj->select(); updateSelection(); @@ -302,8 +302,8 @@ getCurrentDocument()->clearSelection(); - for (LDObject* obj : getCurrentDocument()->getObjects()) - if (obj->getColor() == colnum) + for (LDObject* obj : getCurrentDocument()->objects()) + if (obj->color() == colnum) obj->select(); updateSelection(); @@ -327,21 +327,21 @@ if (type == LDObject::ESubfile) { - refName = static_cast<LDSubfile*> (selection()[0])->getFileInfo()->getName(); + refName = static_cast<LDSubfile*> (selection()[0])->fileInfo()->name(); for (LDObject* obj : selection()) - if (static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName) + if (static_cast<LDSubfile*> (obj)->fileInfo()->name() != refName) return; } getCurrentDocument()->clearSelection(); - for (LDObject* obj : getCurrentDocument()->getObjects()) + for (LDObject* obj : getCurrentDocument()->objects()) { if (obj->type() != type) continue; - if (type == LDObject::ESubfile && static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName) + if (type == LDObject::ESubfile && static_cast<LDSubfile*> (obj)->fileInfo()->name() != refName) continue; obj->select(); @@ -489,7 +489,7 @@ uchar* imgdata = R()->getScreencap (w, h); QImage img = imageFromScreencap (imgdata, w, h); - QString root = basename (getCurrentDocument()->getName()); + QString root = basename (getCurrentDocument()->name()); if (root.right (4) == ".dat") root.chop (4); @@ -519,7 +519,7 @@ DEFINE_ACTION (VisibilityToggle, 0) { for (LDObject* obj : selection()) - obj->toggleHidden(); + obj->setHidden (!obj->isHidden()); refresh(); } @@ -710,7 +710,7 @@ if (selection().size() == 0) return; - QString parentpath = getCurrentDocument()->getFullPath(); + QString parentpath = getCurrentDocument()->fullPath(); // BFC type of the new subfile - it shall inherit the BFC type of the parent document LDBFC::Statement bfctype = LDBFC::NoCertify; @@ -738,7 +738,7 @@ // Determine title of subfile if (titleobj != null) - subtitle = "~" + titleobj->text; + subtitle = "~" + titleobj->text(); else subtitle = "~subfile"; @@ -748,7 +748,7 @@ // If this the parent document isn't already in s/, we need to stuff it into // a subdirectory named s/. Ensure it exists! - QString topdirname = basename (dirname (getCurrentDocument()->getFullPath())); + QString topdirname = basename (dirname (getCurrentDocument()->fullPath())); if (topdirname != "s") { @@ -795,14 +795,14 @@ // Determine the BFC winding type used in the main document - it is to // be carried over to the subfile. - for (LDObject* obj : getCurrentDocument()->getObjects()) + for (LDObject* obj : getCurrentDocument()->objects()) { LDBFC* bfc = dynamic_cast<LDBFC*> (obj); if (!bfc) continue; - LDBFC::Statement a = bfc->m_statement; + LDBFC::Statement a = bfc->statement(); if (a == LDBFC::CertifyCCW || a == LDBFC::CertifyCW || a == LDBFC::NoCertify) { @@ -847,7 +847,7 @@ obj->destroy(); // Compile all objects in the new subfile - for (LDObject* obj : doc->getObjects()) + for (LDObject* obj : doc->objects()) R()->compileObject (obj); g_loadedFiles << doc;
--- a/src/misc/DocumentPointer.cc Wed Mar 05 03:45:49 2014 +0200 +++ b/src/misc/DocumentPointer.cc Wed Mar 05 05:30:36 2014 +0200 @@ -20,12 +20,12 @@ #include "../Document.h" #include "../Misc.h" -LDDocumentPointer::LDDocumentPointer() : m_Pointer (null) {} +LDDocumentPointer::LDDocumentPointer() : m_pointer (null) {} // ============================================================================= // ----------------------------------------------------------------------------- LDDocumentPointer::LDDocumentPointer (LDDocument* ptr) : - m_Pointer (ptr) + m_pointer (ptr) { addReference (); } @@ -33,7 +33,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- LDDocumentPointer::LDDocumentPointer (const LDDocumentPointer& other) : - m_Pointer (other.getPointer()) + m_pointer (other.pointer()) { addReference (); } @@ -49,23 +49,23 @@ // ----------------------------------------------------------------------------- void LDDocumentPointer::addReference() { - if (getPointer() != null) - getPointer()->addReference (this); + if (pointer() != null) + pointer()->addReference (this); } // ============================================================================= // ----------------------------------------------------------------------------- void LDDocumentPointer::removeReference() { - if (getPointer() != null) - getPointer()->removeReference (this); + if (pointer() != null) + pointer()->removeReference (this); } // ============================================================================= // ----------------------------------------------------------------------------- LDDocumentPointer& LDDocumentPointer::operator= (LDDocument* ptr) { - if (ptr != getPointer()) + if (ptr != pointer()) { removeReference(); setPointer (ptr);
--- a/src/misc/DocumentPointer.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/misc/DocumentPointer.h Wed Mar 05 05:30:36 2014 +0200 @@ -25,7 +25,7 @@ class LDDocumentPointer { - PROPERTY (private, LDDocument*, Pointer, NO_OPS, STOCK_WRITE) + PROPERTY (private, LDDocument*, pointer, setPointer, STOCK_WRITE) public: LDDocumentPointer(); @@ -36,17 +36,17 @@ inline LDDocumentPointer& operator= (LDDocumentPointer& other) { - return operator= (other.getPointer()); + return operator= (other.pointer()); } inline LDDocument* operator->() const { - return getPointer(); + return pointer(); } inline operator LDDocument*() const { - return getPointer(); + return pointer(); } private:
--- a/src/misc/InvokationDeferer.h Wed Mar 05 03:45:49 2014 +0200 +++ b/src/misc/InvokationDeferer.h Wed Mar 05 05:30:36 2014 +0200 @@ -17,7 +17,6 @@ */ #pragma once - #include <QObject> class InvokationDeferer : public QObject @@ -41,4 +40,3 @@ }; void invokeLater (InvokationDeferer::FunctionType func); -