ViewInterface* Session::open( const QString& file_name, const std::function<ViewInterface*()>& view_factory ) { QFileInfo fileInfo( file_name ); if ( fileInfo.isReadable() ) { return openAlways( file_name, view_factory, nullptr ); } else { throw FileUnreadableErr(); } }
std::vector<std::pair<QString, ViewInterface*>> Session::restore( const std::function<ViewInterface*()>& view_factory, int *current_file_index ) { const auto& session = Persistable::getSynced<SessionInfo>(); std::vector<SessionInfo::OpenFile> session_files = session.openFiles(); LOG(logDEBUG) << "Session returned " << session_files.size(); std::vector<std::pair<QString, ViewInterface*>> result; for ( auto file: session_files ) { LOG(logDEBUG) << "Create view for " << file.fileName.toLocal8Bit().data(); ViewInterface* view = openAlways( file.fileName, view_factory, file.viewContext ); result.emplace_back( file.fileName, view ); } *current_file_index = -1; return result; }
std::vector<std::pair<QString, ViewInterface*>> Session::restore( std::function<ViewInterface*()> view_factory, int *current_file_index ) { GetPersistentInfo().retrieve( QString( "session" ) ); std::shared_ptr<SessionInfo> session = Persistent<SessionInfo>( "session" ); std::vector<SessionInfo::OpenFile> session_files = session->openFiles(); LOG(logDEBUG) << "Session returned " << session_files.size(); std::vector<std::pair<QString, ViewInterface*>> result; for ( auto file: session_files ) { LOG(logDEBUG) << "Create view for " << file.fileName.toLocal8Bit().data(); ViewInterface* view = openAlways( file.fileName, view_factory, file.viewContext ); result.push_back( { file.fileName, view } ); } *current_file_index = -1; return result; }