Tue, 16 Jul 2013 03:12:03 +0300
some rework with closing files, not right there, seems
src/file.cpp | file | annotate | diff | comparison | revisions | |
src/gui.cpp | file | annotate | diff | comparison | revisions |
--- a/src/file.cpp Tue Jul 16 02:47:11 2013 +0300 +++ b/src/file.cpp Tue Jul 16 03:12:03 2013 +0300 @@ -102,7 +102,7 @@ // ============================================================================= LDOpenFile::~LDOpenFile() { - ulong i; + ulong currentIndex = 0; // Clear everything from the model for (LDObject* obj : m_objs) @@ -113,8 +113,9 @@ delete obj; // Remove this file from the list of files - for (i = 0; i < g_loadedFiles.size(); ++i) { + for (ulong i = 0; i < g_loadedFiles.size(); ++i) { if (g_loadedFiles[i] == this) { + currentIndex = i; g_loadedFiles.erase (i); break; } @@ -123,11 +124,15 @@ // If we just closed the current file, we need to set the current // file as something else. if (this == LDOpenFile::current()) { + ulong i = currentIndex; if (i > 0) i--; + while (i != -1u && g_loadedFiles[i]->implicit()) + --i; + // If we closed the last file, create a blank one. - if (g_loadedFiles.size() < i + 1) + if (i == -1u) newFile(); else LDOpenFile::setCurrent (g_loadedFiles[i]);
--- a/src/gui.cpp Tue Jul 16 02:47:11 2013 +0300 +++ b/src/gui.cpp Tue Jul 16 03:12:03 2013 +0300 @@ -841,8 +841,10 @@ ui->fileList->clear(); for (LDOpenFile* f : g_loadedFiles) { + /* if (f->implicit()) continue; + */ ui->fileList->addItem (""); QListWidgetItem* item = ui->fileList->item (ui->fileList->count() - 1); @@ -870,6 +872,9 @@ if (f == LDOpenFile::current()) ui->fileList->setCurrentItem (f->listItem()); + if (f->implicit()) + f->listItem()->setForeground (QColor (96, 96, 96)); + f->listItem()->setText (name); f->listItem()->setIcon (f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); }