Thu, 01 Aug 2013 02:33:07 +0300
Renamed LDOpenFile to LDFile
--- a/src/addObjectDialog.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/addObjectDialog.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -373,7 +373,7 @@ if (name.length () == 0) return; // no subfile filename - LDOpenFile* file = getFile (name); + LDFile* file = getFile (name); if (!file) { critical (fmt ("Couldn't open `%1': %2", name, strerror (errno))); return; @@ -398,7 +398,7 @@ if (newObject) { ulong idx = g_win->getInsertionPoint (); - LDOpenFile::current()->insertObj (idx, obj); + LDFile::current()->insertObj (idx, obj); } g_win->fullRefresh ();
--- a/src/extprogs.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/extprogs.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -166,7 +166,7 @@ void writeColorGroup (const short colnum, str fname) { List<LDObject*> objects; - for (LDObject* obj : *LDOpenFile::current()) { + for (LDObject* obj : *LDFile::current()) { if (obj->isColored() == false || obj->color() != colnum) continue; @@ -263,7 +263,7 @@ continue; } - LDOpenFile::current()->addObject (obj); + LDFile::current()->addObject (obj); g_win->sel() << obj; }
--- a/src/file.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/file.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -38,9 +38,9 @@ static const int g_MaxRecentFiles = 5; static bool g_aborted = false; -LDOpenFile* LDOpenFile::m_curfile = null; +LDFile* LDFile::m_curfile = null; -DEFINE_PROPERTY (QListWidgetItem*, LDOpenFile, listItem, setListItem) +DEFINE_PROPERTY (QListWidgetItem*, LDFile, listItem, setListItem) // ============================================================================= namespace LDPaths { @@ -93,7 +93,7 @@ } // ============================================================================= -LDOpenFile::LDOpenFile() { +LDFile::LDFile() { setImplicit (true); setSavePos (-1); setListItem (null); @@ -101,7 +101,7 @@ } // ============================================================================= -LDOpenFile::~LDOpenFile() { +LDFile::~LDFile() { // Clear everything from the model for (LDObject* obj : m_objs) delete obj; @@ -120,20 +120,20 @@ // If we just closed the current file, we need to set the current // file as something else. - if( this == LDOpenFile::current() ) { + if( this == LDFile::current() ) { // If we closed the last file, create a blank one. if( g_loadedFiles.size() == 0 ) newFile(); else - LDOpenFile::setCurrent( g_loadedFiles[0] ); + LDFile::setCurrent( g_loadedFiles[0] ); } g_win->updateFileList(); } // ============================================================================= -LDOpenFile* findLoadedFile (str name) { - for (LDOpenFile* file : g_loadedFiles) +LDFile* findLoadedFile (str name) { + for (LDFile* file : g_loadedFiles) if (file->name () == name) return file; @@ -177,10 +177,10 @@ relpath.replace ("\\", "/"); #endif // WIN32 - if (LDOpenFile::current()) { + if (LDFile::current()) { // First, try find the file in the current model's file path. We want a file // in the immediate vicinity of the current model to override stock LDraw stuff. - str partpath = fmt ("%1" DIRSLASH "%2", dirname (LDOpenFile::current()->name ()), relpath); + str partpath = fmt ("%1" DIRSLASH "%2", dirname (LDFile::current()->name ()), relpath); if (f->open (partpath, File::Read)) { return f; @@ -337,7 +337,7 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -LDOpenFile* openDATFile (str path, bool search) { +LDFile* openDATFile (str path, bool search) { // Convert the file name to lowercase since some parts contain uppercase // file names. I'll assume here that the library will always use lowercase // file names for the actual parts.. @@ -357,7 +357,7 @@ if (!f) return null; - LDOpenFile* load = new LDOpenFile; + LDFile* load = new LDFile; load->setName (path); ulong numWarnings; @@ -374,7 +374,7 @@ g_loadedFiles << load; if (g_loadingMainFile) { - LDOpenFile::setCurrent (load); + LDFile::setCurrent (load); g_win->R()->setFile (load); log (QObject::tr ("File %1 parsed successfully (%2 errors)."), path, numWarnings); } @@ -385,7 +385,7 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -bool LDOpenFile::safeToClose() { +bool LDFile::safeToClose() { typedef QMessageBox msgbox; setlocale (LC_ALL, "C"); @@ -402,7 +402,7 @@ // If we don't have a file path yet, we have to ask the user for one. if (name().length() == 0) { str newpath = QFileDialog::getSaveFileName (g_win, "Save As", - LDOpenFile::current()->name(), "LDraw files (*.dat *.ldr)"); + LDFile::current()->name(), "LDraw files (*.dat *.ldr)"); if (newpath.length() == 0) return false; @@ -438,8 +438,8 @@ // ============================================================================= void closeAll() { // Remove all loaded files and the objects they contain - List<LDOpenFile*> files = g_loadedFiles; - for( LDOpenFile* file : files ) + List<LDFile*> files = g_loadedFiles; + for( LDFile* file : files ) delete file; } @@ -448,13 +448,13 @@ // ============================================================================= void newFile () { // Create a new anonymous file and set it to our current - LDOpenFile* f = new LDOpenFile; + LDFile* f = new LDFile; f->setName (""); f->setImplicit (false); g_loadedFiles << f; - LDOpenFile::setCurrent (f); + LDFile::setCurrent (f); - LDOpenFile::closeInitialFile(); + LDFile::closeInitialFile(); g_win->R()->setFile (f); g_win->fullRefresh(); @@ -498,7 +498,7 @@ // ============================================================================= void openMainFile (str path) { g_loadingMainFile = true; - LDOpenFile* file = openDATFile (path, false); + LDFile* file = openDATFile (path, false); if (!file) { // Loading failed, thus drop down to a new file since we @@ -519,7 +519,7 @@ // If we have an anonymous, unchanged file open as the only open file // (aside of the one we just opened), close it now. - LDOpenFile::closeInitialFile(); + LDFile::closeInitialFile(); // Rebuild the object tree view now. g_win->fullRefresh(); @@ -531,13 +531,13 @@ addRecentFile (path); g_loadingMainFile = false; - LDOpenFile::setCurrent (file); + LDFile::setCurrent (file); } // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -bool LDOpenFile::save (str savepath) { +bool LDFile::save (str savepath) { if (!savepath.length()) savepath = name(); @@ -691,7 +691,7 @@ // not loading the main file now, but the subfile in question. bool tmp = g_loadingMainFile; g_loadingMainFile = false; - LDOpenFile* load = getFile (tokens[14]); + LDFile* load = getFile (tokens[14]); g_loadingMainFile = tmp; // If we cannot open the file, mark it an error @@ -769,9 +769,9 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -LDOpenFile* getFile (str filename) { +LDFile* getFile (str filename) { // Try find the file in the list of loaded files - LDOpenFile* load = findLoadedFile (filename); + LDFile* load = findLoadedFile (filename); // If it's not loaded, try open it if (!load) @@ -784,17 +784,17 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void reloadAllSubfiles () { - if (!LDOpenFile::current()) + if (!LDFile::current()) return; g_loadedFiles.clear(); - g_loadedFiles << LDOpenFile::current(); + g_loadedFiles << LDFile::current(); // Go through all objects in the current file and reload the subfiles - for (LDObject* obj : LDOpenFile::current()->objs()) { + for (LDObject* obj : LDFile::current()->objs()) { if (obj->getType() == LDObject::Subfile) { LDSubfileObject* ref = static_cast<LDSubfileObject*> (obj); - LDOpenFile* fileInfo = getFile (ref->fileInfo()->name()); + LDFile* fileInfo = getFile (ref->fileInfo()->name()); if (fileInfo) ref->setFileInfo (fileInfo); @@ -809,13 +809,13 @@ } // Close all files left unused - LDOpenFile::closeUnused(); + LDFile::closeUnused(); } // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -ulong LDOpenFile::addObject (LDObject* obj) { +ulong LDFile::addObject (LDObject* obj) { m_history.add (new AddHistory (m_objs.size(), obj)); m_objs << obj; @@ -829,7 +829,7 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -void LDOpenFile::insertObj (const ulong pos, LDObject* obj) { +void LDFile::insertObj (const ulong pos, LDObject* obj) { m_history.add (new AddHistory (pos, obj)); m_objs.insert (pos, obj); obj->setFile (this); @@ -838,7 +838,7 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -void LDOpenFile::forgetObject (LDObject* obj) { +void LDFile::forgetObject (LDObject* obj) { ulong idx = obj->getIndex(); m_history.add (new DelHistory (idx, obj)); m_objs.erase (idx); @@ -847,7 +847,7 @@ // ============================================================================= bool safeToCloseAll () { - for (LDOpenFile* f : g_loadedFiles) + for (LDFile* f : g_loadedFiles) if (!f->safeToClose()) return false; @@ -855,7 +855,7 @@ } // ============================================================================= -void LDOpenFile::setObject (ulong idx, LDObject* obj) { +void LDFile::setObject (ulong idx, LDObject* obj) { assert (idx < numObjs()); // Mark this change to history @@ -867,8 +867,8 @@ m_objs[idx] = obj; } -static List<LDOpenFile*> getFilesUsed (LDOpenFile* node) { - List<LDOpenFile*> filesUsed; +static List<LDFile*> getFilesUsed (LDFile* node) { + List<LDFile*> filesUsed; for (LDObject* obj : *node) { if (obj->getType() != LDObject::Subfile) @@ -884,11 +884,11 @@ // ============================================================================= // Find out which files are unused and close them. -void LDOpenFile::closeUnused () { - List<LDOpenFile*> filesUsed = getFilesUsed (LDOpenFile::current()); +void LDFile::closeUnused () { + List<LDFile*> filesUsed = getFilesUsed (LDFile::current()); // Anything that's explicitly opened must not be closed - for (LDOpenFile* file : g_loadedFiles) + for (LDFile* file : g_loadedFiles) if (!file->implicit()) filesUsed << file; @@ -896,10 +896,10 @@ filesUsed.makeUnique(); // Close all open files that aren't in filesUsed - for (LDOpenFile* file : g_loadedFiles) { + for (LDFile* file : g_loadedFiles) { bool isused = false; - for (LDOpenFile* usedFile : filesUsed) { + for (LDFile* usedFile : filesUsed) { if (file == usedFile) { isused = true; break; @@ -914,38 +914,38 @@ g_loadedFiles << filesUsed; } -LDObject* LDOpenFile::object (ulong pos) const { +LDObject* LDFile::object (ulong pos) const { if (m_objs.size() <= pos) return null; return m_objs[pos]; } -LDObject* LDOpenFile::obj (ulong pos) const { +LDObject* LDFile::obj (ulong pos) const { return object (pos); } -ulong LDOpenFile::numObjs() const { +ulong LDFile::numObjs() const { return m_objs.size(); } -LDOpenFile& LDOpenFile::operator<< (List<LDObject*> objs) { +LDFile& LDFile::operator<< (List<LDObject*> objs) { for (LDObject* obj : objs) addObject (obj); return *this; } -bool LDOpenFile::hasUnsavedChanges() const { +bool LDFile::hasUnsavedChanges() const { return !implicit() && history().pos() != savePos(); } // ============================================================================= -LDOpenFile* LDOpenFile::current() { +LDFile* LDFile::current() { return m_curfile; } -void LDOpenFile::setCurrent (LDOpenFile* f) { +void LDFile::setCurrent (LDFile* f) { m_curfile = f; if (g_win && f) @@ -955,7 +955,7 @@ // ============================================================================= // This little beauty closes the initial file that was open at first when opening // a new file over it. -void LDOpenFile::closeInitialFile() { +void LDFile::closeInitialFile() { if (g_loadedFiles.size() == 2 && g_loadedFiles[0]->name() == "" && !g_loadedFiles[0]->hasUnsavedChanges())
--- a/src/file.h Tue Jul 30 21:31:36 2013 +0300 +++ b/src/file.h Thu Aug 01 02:33:07 2013 +0300 @@ -24,7 +24,7 @@ #include "history.h" #include <QObject> -#define curfile LDOpenFile::current() +#define curfile LDFile::current() class History; class OpenProgressDialog; @@ -40,15 +40,15 @@ } // ============================================================================= -// LDOpenFile +// LDFile // -// The LDOpenFile class stores a file opened in LDForge either as a editable file +// The LDFile class stores a file opened in LDForge either as a editable file // for the user or for subfile caching. Its methods handle file input and output. // // A file is implicit when they are opened automatically for caching purposes // and are hidden from the user. User-opened files are explicit (not implicit). // ============================================================================= -class LDOpenFile : public QObject { +class LDFile : public QObject { Q_OBJECT READ_PROPERTY (List<LDObject*>, objs, setObjects) READ_PROPERTY (History, history, setHistory) @@ -63,8 +63,8 @@ typedef List<LDObject*>::it it; typedef List<LDObject*>::c_it c_it; - LDOpenFile(); - ~LDOpenFile(); + LDFile(); + ~LDFile(); ulong addObject (LDObject* obj); // Adds an object to this file at the end of the file. void forgetObject (LDObject* obj); // Deletes the given object from the object chain. @@ -77,12 +77,12 @@ bool safeToClose(); // Perform safety checks. Do this before closing any files! void setObject (ulong idx, LDObject* obj); - LDOpenFile& operator<< (LDObject* obj) { + LDFile& operator<< (LDObject* obj) { addObject (obj); return *this; } - LDOpenFile& operator<< (List<LDObject*> objs); + LDFile& operator<< (List<LDObject*> objs); it begin() { return PROP_NAME (objs).begin(); @@ -125,12 +125,12 @@ } static void closeUnused(); - static LDOpenFile* current(); - static void setCurrent (LDOpenFile* f); + static LDFile* current(); + static void setCurrent (LDFile* f); static void closeInitialFile(); private: - static LDOpenFile* m_curfile; + static LDFile* m_curfile; }; // Close all current loaded files and start off blank. @@ -140,11 +140,11 @@ void openMainFile (str path); // Finds an OpenFile by name or null if not open -LDOpenFile* findLoadedFile (str name); +LDFile* findLoadedFile (str name); // Opens the given file and parses the LDraw code within. Returns a pointer // to the opened file or null on error. -LDOpenFile* openDATFile (str path, bool search); +LDFile* openDATFile (str path, bool search); // Opens the given file and returns a pointer to it, potentially looking in /parts and /p File* openLDrawFile (str relpath, bool subdirs); @@ -156,7 +156,7 @@ LDObject* parseLine (str line); // Retrieves the pointer to - or loads - the given subfile. -LDOpenFile* getFile (str filename); +LDFile* getFile (str filename); // Re-caches all subfiles. void reloadAllSubfiles(); @@ -166,13 +166,13 @@ List<LDObject*> loadFileContents (File* f, ulong* numWarnings, bool* ok = null); -extern List<LDOpenFile*> g_loadedFiles; +extern List<LDFile*> g_loadedFiles; void addRecentFile (str path); str basename (str path); str dirname (str path); -extern List<LDOpenFile*> g_loadedFiles; // Vector of all currently opened files. +extern List<LDFile*> g_loadedFiles; // Vector of all currently opened files. // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
--- a/src/gldraw.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/gldraw.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -1227,12 +1227,12 @@ update(); } -READ_ACCESSOR( LDOpenFile*, GLRenderer::file ) +READ_ACCESSOR( LDFile*, GLRenderer::file ) { return m_file; } -SET_ACCESSOR( LDOpenFile*, GLRenderer::setFile ) +SET_ACCESSOR( LDFile*, GLRenderer::setFile ) { m_file = val;
--- a/src/gldraw.h Tue Jul 30 21:31:36 2013 +0300 +++ b/src/gldraw.h Thu Aug 01 02:33:07 2013 +0300 @@ -29,7 +29,7 @@ class QDoubleSpinBox; class QSpinBox; class QLineEdit; -class LDOpenFile; +class LDFile; class QTimer; enum EditMode { @@ -60,7 +60,7 @@ PROPERTY( double, zoom, setZoom ) PROPERTY( MessageManager*, msglog, setMessageLog ) READ_PROPERTY (bool, picking, setPicking) - DECLARE_PROPERTY (LDOpenFile*, file, setFile) + DECLARE_PROPERTY (LDFile*, file, setFile) DECLARE_PROPERTY (EditMode, editMode, setEditMode) public:
--- a/src/gui.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/gui.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -224,21 +224,21 @@ str title = fmt (APPNAME " %1", fullVersionString()); // Append our current file if we have one - if (LDOpenFile::current()) { - if (LDOpenFile::current()->name().length() > 0) - title += fmt (": %1", basename (LDOpenFile::current()->name())); + if (LDFile::current()) { + if (LDFile::current()->name().length() > 0) + title += fmt (": %1", basename (LDFile::current()->name())); else title += fmt (": <anonymous>"); - if (LDOpenFile::current()->numObjs() > 0 && - LDOpenFile::current()->obj (0)->getType() == LDObject::Comment) + if (LDFile::current()->numObjs() > 0 && + LDFile::current()->obj (0)->getType() == LDObject::Comment) { // Append title - LDCommentObject* comm = static_cast<LDCommentObject*> (LDOpenFile::current()->obj (0)); + LDCommentObject* comm = static_cast<LDCommentObject*> (LDFile::current()->obj (0)); title += fmt (": %1", comm->text); } - if (LDOpenFile::current()->history().pos() != LDOpenFile::current()->savePos()) + if (LDFile::current()->history().pos() != LDFile::current()->savePos()) title += '*'; } @@ -258,7 +258,7 @@ // Delete the objects that were being selected for (LDObject* obj : selCopy) { - LDOpenFile::current()->forgetObject (obj); + LDFile::current()->forgetObject (obj); ++num; delete obj; } @@ -271,7 +271,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void ForgeWindow::buildObjList() { - if (!LDOpenFile::current()) + if (!LDFile::current()) return; // Lock the selection while we do this so that refreshing the object list @@ -284,7 +284,7 @@ ui->objectList->clear(); - for (LDObject* obj : LDOpenFile::current()->objs()) { + for (LDObject* obj : LDFile::current()->objs()) { str descr; switch (obj->getType()) { @@ -397,7 +397,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void ForgeWindow::slot_selectionChanged() { - if (g_bSelectionLocked == true || LDOpenFile::current() == null) + if (g_bSelectionLocked == true || LDFile::current() == null) return; // Update the shared selection array, though don't do this if this was @@ -412,7 +412,7 @@ m_sel.clear(); const QList<QListWidgetItem*> items = ui->objectList->selectedItems(); - for (LDObject* obj : LDOpenFile::current()->objs()) + for (LDObject* obj : LDFile::current()->objs()) for (QListWidgetItem* item : items) { if (item == obj->qObjListEntry) { m_sel << obj; @@ -481,7 +481,7 @@ } // Otherwise place the object at the end. - return LDOpenFile::current()->numObjs(); + return LDFile::current()->numObjs(); } // ============================================================================= @@ -503,7 +503,7 @@ void ForgeWindow::updateSelection() { g_bSelectionLocked = true; - for (LDObject* obj : LDOpenFile::current()->objs()) + for (LDObject* obj : LDFile::current()->objs()) obj->setSelected (false); ui->objectList->clearSelection(); @@ -624,7 +624,7 @@ // ============================================================================= void ForgeWindow::deleteObjVector (List<LDObject*> objs) { for (LDObject* obj : objs) { - LDOpenFile::current()->forgetObject (obj); + LDFile::current()->forgetObject (obj); delete obj; } } @@ -632,7 +632,7 @@ // ============================================================================= void ForgeWindow::deleteByColor (const short colnum) { List<LDObject*> objs; - for (LDObject* obj : LDOpenFile::current()->objs()) { + for (LDObject* obj : LDFile::current()->objs()) { if (!obj->isColored() || obj->color() != colnum) continue; @@ -651,7 +651,7 @@ void ForgeWindow::slot_editObject (QListWidgetItem* listitem) { LDObject* obj = null; - for (LDObject* it : *LDOpenFile::current()) { + for (LDObject* it : *LDFile::current()) { if (it->qObjListEntry == listitem) { obj = it; break; @@ -684,12 +684,12 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -void ForgeWindow::save (LDOpenFile* f, bool saveAs) { +void ForgeWindow::save (LDFile* f, bool saveAs) { str path = f->name(); if (path.length() == 0 || saveAs) { path = QFileDialog::getSaveFileName (g_win, tr ("Save As"), - LDOpenFile::current()->name(), tr ("LDraw files (*.dat *.ldr)")); + LDFile::current()->name(), tr ("LDraw files (*.dat *.ldr)")); if (path.length() == 0) { // User didn't give a file name. This happens if the user cancelled @@ -701,7 +701,7 @@ if (f->save (path)) { f->setName (path); - if (f == LDOpenFile::current()) + if (f == LDFile::current()) g_win->updateTitle(); log ("Saved to %1.", path); @@ -782,7 +782,7 @@ void makeColorSelector (QComboBox* box) { std::map<short, ulong> counts; - for (LDObject* obj : LDOpenFile::current()->objs()) { + for (LDObject* obj : LDFile::current()->objs()) { if (!obj->isColored()) continue; @@ -825,7 +825,7 @@ void ForgeWindow::updateFileList() { ui->fileList->clear(); - for (LDOpenFile* f : g_loadedFiles) { + for (LDFile* f : g_loadedFiles) { /* if (f->implicit()) continue; @@ -839,7 +839,7 @@ } } -void ForgeWindow::updateFileListItem (LDOpenFile* f) { +void ForgeWindow::updateFileListItem (LDFile* f) { if (f->listItem() == null) { // We don't have a list item for this file, so the list // doesn't exist yet. Create it - afterwards this will be @@ -854,7 +854,7 @@ else name = basename (f->name()); - if (f == LDOpenFile::current()) + if (f == LDFile::current()) ui->fileList->setCurrentItem (f->listItem()); if (f->implicit()) @@ -867,31 +867,31 @@ void ForgeWindow::beginAction (QAction* act) { // Open the history so we can record the edits done during this action. if (act != ACTION (Undo) && act != ACTION (Redo) && act != ACTION (Open)) - LDOpenFile::current()->openHistory(); + LDFile::current()->openHistory(); } void ForgeWindow::endAction() { // Close the history now. - LDOpenFile::current()->closeHistory(); - updateFileListItem (LDOpenFile::current()); + LDFile::current()->closeHistory(); + updateFileListItem (LDFile::current()); } void ForgeWindow::changeCurrentFile() { - LDOpenFile* f = null; + LDFile* f = null; QListWidgetItem* item = ui->fileList->currentItem(); - for (LDOpenFile* it : g_loadedFiles) { + for (LDFile* it : g_loadedFiles) { if (it->listItem() == item) { f = it; break; } } - if (!f || f == LDOpenFile::current()) + if (!f || f == LDFile::current()) return; clearSelection(); - LDOpenFile::setCurrent (f); + LDFile::setCurrent (f); log ("Changed file to %1", basename (f->name())); @@ -903,7 +903,7 @@ void ForgeWindow::refreshObjectList() { #if 0 ui->objectList->clear(); - LDOpenFile* f = LDOpenFile::current(); + LDFile* f = LDFile::current(); for (LDObject* obj : *f) ui->objectList->addItem (obj->qObjListEntry);
--- a/src/gui.h Tue Jul 30 21:31:36 2013 +0300 +++ b/src/gui.h Thu Aug 01 02:33:07 2013 +0300 @@ -99,7 +99,7 @@ void updateGridToolBar(); void updateEditModeActions(); void updateFileList(); - void updateFileListItem (LDOpenFile* f); + void updateFileListItem (LDFile* f); bool isSelected (LDObject* obj); short getSelectedColor(); LDObject::Type uniformSelectedType(); @@ -108,7 +108,7 @@ void deleteObjVector (List< LDObject* > objs); int deleteSelection(); void deleteByColor (const short int colnum); - void save (LDOpenFile* f, bool saveAs); + void save (LDFile* f, bool saveAs); GLRenderer* R() { return m_renderer; } List<LDObject*>& sel() { return m_sel; } void setQuickColors (List<LDQuickColor>& colors) { m_quickColors = colors; }
--- a/src/gui_actions.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/gui_actions.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -64,7 +64,7 @@ ui.rb_license_ca->isChecked() ? CALicense : ui.rb_license_nonca->isChecked() ? NonCALicense : ""; - LDOpenFile* f = LDOpenFile::current(); + LDFile* f = LDFile::current(); *f << new LDCommentObject (ui.le_title->text()); *f << new LDCommentObject ("Name: <untitled>.dat" ); *f << new LDCommentObject (fmt ("Author: %1", ui.le_author->text())); @@ -96,21 +96,21 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= DEFINE_ACTION (Save, CTRL (S)) { - g_win->save (LDOpenFile::current(), false); + g_win->save (LDFile::current(), false); } // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= DEFINE_ACTION (SaveAs, CTRL_SHIFT (S)) { - g_win->save (LDOpenFile::current(), true); + g_win->save (LDFile::current(), true); } // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= DEFINE_ACTION (SaveAll, CTRL (L)) { - for (LDOpenFile* file : g_loadedFiles) { + for (LDFile* file : g_loadedFiles) { if (file->implicit()) continue; @@ -122,10 +122,10 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= DEFINE_ACTION (Close, CTRL (W)) { - if (!LDOpenFile::current()->safeToClose()) + if (!LDFile::current()->safeToClose()) return; - delete LDOpenFile::current(); + delete LDFile::current(); } // ============================================================================= @@ -225,7 +225,7 @@ DEFINE_ACTION (SelectAll, CTRL (A)) { g_win->sel().clear(); - for (LDObject* obj : LDOpenFile::current()->objs()) + for (LDObject* obj : LDFile::current()->objs()) g_win->sel() << obj; g_win->updateSelection(); @@ -239,7 +239,7 @@ return; // no consensus on color g_win->sel().clear(); - for (LDObject* obj : LDOpenFile::current()->objs()) + for (LDObject* obj : LDFile::current()->objs()) if (obj->color() == colnum) g_win->sel() << obj; @@ -269,7 +269,7 @@ } g_win->sel().clear(); - for (LDObject* obj : LDOpenFile::current()->objs()) { + for (LDObject* obj : LDFile::current()->objs()) { if (obj->getType() != type) continue; @@ -329,7 +329,7 @@ g_win->sel().clear(); for (LDObject* obj : objs) { - LDOpenFile::current()->insertObj (idx, obj); + LDFile::current()->insertObj (idx, obj); g_win->sel() << obj; idx++; @@ -390,7 +390,7 @@ for (str line : str (te_edit->toPlainText()).split ("\n")) { LDObject* obj = parseLine (line); - LDOpenFile::current()->insertObj (idx, obj); + LDFile::current()->insertObj (idx, obj); g_win->sel() << obj; idx++; } @@ -406,7 +406,7 @@ uchar* imgdata = g_win->R()->screencap (w, h); QImage img = imageFromScreencap (imgdata, w, h); - str root = basename (LDOpenFile::current()->name()); + str root = basename (LDFile::current()->name()); if (root.right (4) == ".dat") root.chop (4); @@ -482,7 +482,7 @@ // but I can't figure how to generate these pictures properly. Multi-threading // these is an immense pain. DEFINE_ACTION (testpic, "Test picture", "", "", (0)) { - LDOpenFile* file = getFile ("axle.dat"); + LDFile* file = getFile ("axle.dat"); setlocale (LC_ALL, "C"); if (!file) {
--- a/src/gui_editactions.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/gui_editactions.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -89,7 +89,7 @@ for (str line : clipboardText.split ("\n")) { LDObject* pasted = parseLine (line); - LDOpenFile::current()->insertObj (idx++, pasted); + LDFile::current()->insertObj (idx++, pasted); g_win->sel() << pasted; g_win->R()->compileObject (pasted); ++num; @@ -135,12 +135,12 @@ delete inlineobj; LDObject* newobj = parseLine (line); - LDOpenFile::current()->insertObj (idx++, newobj); + LDFile::current()->insertObj (idx++, newobj); g_win->sel() << newobj; } // Delete the subfile now as it's been inlined. - LDOpenFile::current()->forgetObject (obj); + LDFile::current()->forgetObject (obj); delete obj; } @@ -176,8 +176,8 @@ // Replace the quad with the first triangle and add the second triangle // after the first one. - LDOpenFile::current()->setObject (index, triangles[0]); - LDOpenFile::current()->insertObj (index + 1, triangles[1]); + LDFile::current()->setObject (index, triangles[0]); + LDFile::current()->insertObj (index + 1, triangles[1]); // Delete this quad now, it has been split. delete obj; @@ -289,7 +289,7 @@ ulong idx = obj->getIndex() + i + 1; lines[i]->setColor (edgecolor); - LDOpenFile::current()->insertObj (idx, lines[i]); + LDFile::current()->insertObj (idx, lines[i]); g_win->R()->compileObject (lines[i]); } @@ -317,7 +317,7 @@ vert->pos = obj->getVertex (i); vert->setColor (obj->color()); - LDOpenFile::current()->insertObj (++idx, vert); + LDFile::current()->insertObj (++idx, vert); g_win->R()->compileObject (vert); ++num; } @@ -348,11 +348,11 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= DEFINE_ACTION (Undo, CTRL (Z)) { - LDOpenFile::current()->undo(); + LDFile::current()->undo(); } DEFINE_ACTION (Redo, CTRL_SHIFT (Z)) { - LDOpenFile::current()->redo(); + LDFile::current()->redo(); } // ============================================================================= @@ -618,7 +618,7 @@ // ================================================================================================= static bool isColorUsed (short colnum) { - for (LDObject* obj : LDOpenFile::current()->objs()) + for (LDObject* obj : LDFile::current()->objs()) if (obj->isColored() && obj->color() == colnum) return true;
--- a/src/history.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/history.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -122,7 +122,7 @@ // ============================================================================= void AddHistory::undo() const { - LDOpenFile* f = parent()->file(); + LDFile* f = parent()->file(); LDObject* obj = f->object (index()); f->forgetObject (obj); delete obj; @@ -131,7 +131,7 @@ } void AddHistory::redo() const { - LDOpenFile* f = parent()->file(); + LDFile* f = parent()->file(); LDObject* obj = parseLine (code()); f->insertObj (index(), obj); g_win->R()->compileObject (obj); @@ -142,14 +142,14 @@ // ============================================================================= // heh void DelHistory::undo() const { - LDOpenFile* f = parent()->file(); + LDFile* f = parent()->file(); LDObject* obj = parseLine (code()); f->insertObj (index(), obj); g_win->R()->compileObject (obj); } void DelHistory::redo() const { - LDOpenFile* f = parent()->file(); + LDFile* f = parent()->file(); LDObject* obj = f->object (index()); f->forgetObject (obj); delete obj; @@ -161,14 +161,14 @@ // ============================================================================= void EditHistory::undo() const { - LDObject* obj = LDOpenFile::current()->object (index()); + LDObject* obj = LDFile::current()->object (index()); LDObject* newobj = parseLine (oldCode()); obj->replace (newobj); g_win->R()->compileObject (newobj); } void EditHistory::redo() const { - LDObject* obj = LDOpenFile::current()->object (index()); + LDObject* obj = LDFile::current()->object (index()); LDObject* newobj = parseLine (newCode()); obj->replace (newobj); g_win->R()->compileObject (newobj);
--- a/src/history.h Tue Jul 30 21:31:36 2013 +0300 +++ b/src/history.h Thu Aug 01 02:33:07 2013 +0300 @@ -33,7 +33,7 @@ // ============================================================================= class History { PROPERTY (long, pos, setPos) - PROPERTY (LDOpenFile*, file, setFile) + PROPERTY (LDFile*, file, setFile) READ_PROPERTY (bool, opened, setOpened) public:
--- a/src/ldtypes.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/ldtypes.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -196,7 +196,7 @@ assert (idx != -1); // Replace the instance of the old object with the new object - LDOpenFile::current()->setObject (idx, other); + LDFile::current()->setObject (idx, other); // Remove the old object delete this; @@ -206,14 +206,14 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void LDObject::swap (LDObject* other) { - for (LDObject*& obj : *LDOpenFile::current()) { + for (LDObject*& obj : *LDFile::current()) { if (obj == this) obj = other; elif (obj == other) obj = this; } - LDOpenFile::current()->addToHistory (new SwapHistory (id(), other->id())); + LDFile::current()->addToHistory (new SwapHistory (id(), other->id())); } LDLineObject::LDLineObject (vertex v1, vertex v2) { @@ -361,7 +361,7 @@ const long idx = obj->getIndex(), target = idx + (up ? -1 : 1); - if ((up && idx == 0) || (!up && idx == (long) (LDOpenFile::current()->objs().size() - 1))) { + if ((up && idx == 0) || (!up && idx == (long) (LDFile::current()->objs().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 // abort the entire operation. @@ -370,9 +370,9 @@ } objsToCompile << obj; - objsToCompile << LDOpenFile::current()->obj (target); + objsToCompile << LDFile::current()->obj (target); - obj->swap (LDOpenFile::current()->obj (target)); + obj->swap (LDFile::current()->obj (target)); } objsToCompile.makeUnique(); @@ -445,10 +445,10 @@ long idx = getIndex(); assert (idx != -1); - if (idx == (long) LDOpenFile::current()->numObjs() - 1) + if (idx == (long) LDFile::current()->numObjs() - 1) return null; - return LDOpenFile::current()->obj (idx + 1); + return LDFile::current()->obj (idx + 1); } // ============================================================================= @@ -459,7 +459,7 @@ if (idx == 0) return null; - return LDOpenFile::current()->obj (idx - 1); + return LDFile::current()->obj (idx - 1); } // ============================================================================= @@ -564,7 +564,7 @@ if (bfc && bfc->type == LDBFCObject::InvertNext) { // This is prefixed with an invertnext, thus remove it. - LDOpenFile::current()->forgetObject (bfc); + LDFile::current()->forgetObject (bfc); delete bfc; return; } @@ -572,7 +572,7 @@ // Not inverted, thus prefix it with a new invertnext. LDBFCObject* bfc = new LDBFCObject (LDBFCObject::InvertNext); - LDOpenFile::current()->insertObj (idx, bfc); + LDFile::current()->insertObj (idx, bfc); } static void invertLine (LDObject* line) { @@ -638,7 +638,7 @@ *ptr = val; str after = obj->raw(); - LDOpenFile::current()->addToHistory (new EditHistory (idx, before, after)); + LDFile::current()->addToHistory (new EditHistory (idx, before, after)); } else *ptr = val; }
--- a/src/ldtypes.h Tue Jul 30 21:31:36 2013 +0300 +++ b/src/ldtypes.h Thu Aug 01 02:33:07 2013 +0300 @@ -51,7 +51,7 @@ class QListWidgetItem; class LDSubfileObject; -class LDOpenFile; +class LDFile; // ============================================================================= // LDObject @@ -65,7 +65,7 @@ PROPERTY (bool, hidden, setHidden) PROPERTY (bool, selected, setSelected) PROPERTY (LDObject*, parent, setParent) - PROPERTY (LDOpenFile*, file, setFile) + PROPERTY (LDFile*, file, setFile) READ_PROPERTY (qint32, id, setID) DECLARE_PROPERTY (short, color, setColor) @@ -112,7 +112,7 @@ static str typeName (LDObject::Type type); // Get type name by enumerator static LDObject* getDefault (const LDObject::Type type); // Returns a sample object by the given enumerator - static void moveObjects (List<LDObject*> objs, const bool up); // TODO: move this to LDOpenFile? + static void moveObjects (List<LDObject*> objs, const bool up); // TODO: move this to LDFile? static str objectListContents (const List<LDObject*>& objs); // Get a description of a list of LDObjects static LDObject* fromID (int id); @@ -273,7 +273,7 @@ LDOBJ_COLORED LDOBJ_SCEMANTIC LDOBJ_HAS_MATRIX - PROPERTY (LDOpenFile*, fileInfo, setFileInfo) + PROPERTY (LDFile*, fileInfo, setFileInfo) public: LDSubfileObject() {
--- a/src/main.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/main.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -29,7 +29,7 @@ #include "types.h" #include "primitives.h" -List<LDOpenFile*> g_loadedFiles; +List<LDFile*> g_loadedFiles; ForgeWindow* g_win = null; const QApplication* g_app = null; File g_file_stdout (stdout, File::Write); @@ -60,7 +60,7 @@ int main (int argc, char* argv[]) { const QApplication app (argc, argv); g_app = &app; - LDOpenFile::setCurrent (null); + LDFile::setCurrent (null); // Load or create the configuration if (!config::load ()) {
--- a/src/primitives.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/primitives.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -529,7 +529,7 @@ if( divs == hires ) descr.insert( 0, "Hi-Res " ); - LDOpenFile* f = new LDOpenFile; + LDFile* f = new LDFile; f->setName (QFileDialog::getSaveFileName (null, QObject::tr ("Save Primitive"), name)); *f << new LDCommentObject (descr);
--- a/src/types.cpp Tue Jul 30 21:31:36 2013 +0300 +++ b/src/types.cpp Thu Aug 01 02:33:07 2013 +0300 @@ -498,10 +498,10 @@ void LDBoundingBox::calculate() { reset(); - if (!LDOpenFile::current()) + if (!LDFile::current()) return; - for (LDObject* obj : LDOpenFile::current()->objs()) + for (LDObject* obj : LDFile::current()->objs()) calcObject (obj); }