51 |
51 |
52 static bool g_bSelectionLocked = false; |
52 static bool g_bSelectionLocked = false; |
53 |
53 |
54 cfg (bool, lv_colorize, true); |
54 cfg (bool, lv_colorize, true); |
55 cfg (str, gui_colortoolbar, "16:24:|:1:2:4:14:0:15:|:33:34:36:46"); |
55 cfg (str, gui_colortoolbar, "16:24:|:1:2:4:14:0:15:|:33:34:36:46"); |
|
56 cfg (bool, gui_implicitfiles, false); |
56 extern_cfg (str, io_recentfiles); |
57 extern_cfg (str, io_recentfiles); |
57 extern_cfg (bool, gl_axes); |
58 extern_cfg (bool, gl_axes); |
58 extern_cfg (str, gl_maincolor); |
59 extern_cfg (str, gl_maincolor); |
59 extern_cfg (float, gl_maincolor_alpha); |
60 extern_cfg (float, gl_maincolor_alpha); |
60 extern_cfg (bool, gl_wireframe); |
61 extern_cfg (bool, gl_wireframe); |
825 |
826 |
826 void ForgeWindow::updateFileList() { |
827 void ForgeWindow::updateFileList() { |
827 ui->fileList->clear(); |
828 ui->fileList->clear(); |
828 |
829 |
829 for (LDFile* f : g_loadedFiles) { |
830 for (LDFile* f : g_loadedFiles) { |
830 /* |
831 /* Don't list implicit files unless explicitly desired. */ |
831 if (f->implicit()) |
832 if (f->implicit() && !gui_implicitfiles) |
832 continue; |
833 continue; |
833 */ |
834 |
834 |
835 /* Add an item to the list for this file and store a pointer to it in |
|
836 * the file, so we can find files by the list item. */ |
835 ui->fileList->addItem (""); |
837 ui->fileList->addItem (""); |
836 QListWidgetItem* item = ui->fileList->item (ui->fileList->count() - 1); |
838 QListWidgetItem* item = ui->fileList->item (ui->fileList->count() - 1); |
837 f->setListItem (item); |
839 f->setListItem (item); |
838 |
840 |
839 updateFileListItem (f); |
841 updateFileListItem (f); |
840 } |
842 } |
841 } |
843 } |
842 |
844 |
843 void ForgeWindow::updateFileListItem (LDFile* f) { |
845 void ForgeWindow::updateFileListItem (LDFile* f) { |
844 if (f->listItem() == null) { |
846 if (f->listItem() == null) { |
845 // We don't have a list item for this file, so the list |
847 /* We don't have a list item for this file, so the list either doesn't |
846 // doesn't exist yet. Create it - afterwards this will be |
848 * exist yet or is out of date. Build the list now. */ |
847 // up to date. |
|
848 updateFileList(); |
849 updateFileList(); |
849 return; |
850 return; |
850 } |
851 } |
851 |
852 |
|
853 /* If this is the current file, it also needs to be the selected item on |
|
854 * the list. */ |
852 if (f == LDFile::current()) |
855 if (f == LDFile::current()) |
853 ui->fileList->setCurrentItem (f->listItem()); |
856 ui->fileList->setCurrentItem (f->listItem()); |
854 |
857 |
|
858 /* If we list implicit files, draw them with a shade of gray to make them |
|
859 * distinct. */ |
855 if (f->implicit()) |
860 if (f->implicit()) |
856 f->listItem()->setForeground (QColor (96, 96, 96)); |
861 f->listItem()->setForeground (QColor (96, 96, 96)); |
857 |
862 |
858 f->listItem()->setText (f->getShortName()); |
863 f->listItem()->setText (f->getShortName()); |
|
864 |
|
865 /* If the file has unsaved changes, draw a little icon next to it to mark that. */ |
859 f->listItem()->setIcon (f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); |
866 f->listItem()->setIcon (f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); |
860 } |
867 } |
861 |
868 |
862 void ForgeWindow::beginAction (QAction* act) { |
869 void ForgeWindow::beginAction (QAction* act) { |
863 // Open the history so we can record the edits done during this action. |
870 // Open the history so we can record the edits done during this action. |
866 } |
873 } |
867 |
874 |
868 void ForgeWindow::endAction() { |
875 void ForgeWindow::endAction() { |
869 // Close the history now. |
876 // Close the history now. |
870 LDFile::current()->closeHistory(); |
877 LDFile::current()->closeHistory(); |
|
878 |
|
879 /* Update the list item of the current file - we may need to draw an icon |
|
880 * now that marks it as having unsaved changes. */ |
871 updateFileListItem (LDFile::current()); |
881 updateFileListItem (LDFile::current()); |
872 } |
882 } |
873 |
883 |
|
884 // ============================================================================= |
|
885 /* A file is selected from the list of files on the left of the screen. Find out |
|
886 * which file was picked and change to it. |
|
887 */ |
874 void ForgeWindow::changeCurrentFile() { |
888 void ForgeWindow::changeCurrentFile() { |
875 LDFile* f = null; |
889 LDFile* f = null; |
876 QListWidgetItem* item = ui->fileList->currentItem(); |
890 QListWidgetItem* item = ui->fileList->currentItem(); |
877 |
891 |
|
892 /* Find the file pointer of the item that was selected. */ |
878 for (LDFile* it : g_loadedFiles) { |
893 for (LDFile* it : g_loadedFiles) { |
879 if (it->listItem() == item) { |
894 if (it->listItem() == item) { |
880 f = it; |
895 f = it; |
881 break; |
896 break; |
882 } |
897 } |
883 } |
898 } |
884 |
899 |
|
900 /* If we picked the same file we're currently on, we don't need to do |
|
901 * anything. */ |
885 if (!f || f == LDFile::current()) |
902 if (!f || f == LDFile::current()) |
886 return; |
903 return; |
887 |
904 |
888 LDFile::setCurrent (f); |
905 LDFile::setCurrent (f); |
889 } |
906 } |