950 // ============================================================================= |
950 // ============================================================================= |
951 LDFile* LDFile::current() { |
951 LDFile* LDFile::current() { |
952 return m_curfile; |
952 return m_curfile; |
953 } |
953 } |
954 |
954 |
|
955 // ============================================================================= |
|
956 /* Sets the given file as the current one on display. At some point in time this |
|
957 * was an operation completely unheard of. ;) |
|
958 * |
|
959 * FIXME: f can be temporarily null. This probably should not be the case. |
|
960 */ |
955 void LDFile::setCurrent (LDFile* f) { |
961 void LDFile::setCurrent (LDFile* f) { |
|
962 /* Implicit files were loaded for caching purposes and must never be set |
|
963 * current. */ |
|
964 if( f && f->implicit() ) |
|
965 return; |
|
966 |
956 m_curfile = f; |
967 m_curfile = f; |
957 |
968 |
958 if( g_win && f ) { |
969 if( g_win && f ) { |
959 g_win->clearSelection(); |
970 g_win->clearSelection(); |
960 g_win->updateFileListItem( f ); |
971 g_win->updateFileListItem( f ); |
961 g_win->buildObjList(); |
972 g_win->buildObjList(); |
962 g_win->R()->setFile( f ); |
973 g_win->R()->setFile( f ); |
963 g_win->R()->update(); |
974 g_win->R()->repaint(); |
964 |
975 |
965 log( "Changed file to %1", f->getShortName()); |
976 log( "Changed file to %1", f->getShortName()); |
966 } |
977 } |
|
978 } |
|
979 |
|
980 // ============================================================================= |
|
981 int LDFile::countExplicitFiles() { |
|
982 int count = 0; |
|
983 |
|
984 for( LDFile* f : g_loadedFiles ) |
|
985 if( f->implicit() == false ) |
|
986 count++; |
|
987 |
|
988 return count; |
967 } |
989 } |
968 |
990 |
969 // ============================================================================= |
991 // ============================================================================= |
970 // This little beauty closes the initial file that was open at first when opening |
992 // This little beauty closes the initial file that was open at first when opening |
971 // a new file over it. |
993 // a new file over it. |
972 void LDFile::closeInitialFile() { |
994 void LDFile::closeInitialFile() { |
973 if (g_loadedFiles.size() == 2 && |
995 if (countExplicitFiles() == 2 && |
974 g_loadedFiles[0]->name() == "" && |
996 g_loadedFiles[0]->name() == "" && |
975 !g_loadedFiles[0]->hasUnsavedChanges()) |
997 !g_loadedFiles[0]->hasUnsavedChanges()) |
976 { |
998 { |
977 delete g_loadedFiles[0]; |
999 delete g_loadedFiles[0]; |
978 } |
1000 } |