1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
22 #include "clitkCommon.h"
25 const std::string vv_user_file=".vv_settings.txt";
26 typedef std::list<std::string> FileListType;
28 ///Returns the last images opened by the user
29 FileListType GetRecentlyOpenedImages()
31 std::ifstream in((QDir::homePath().toStdString() + "/" + vv_user_file).c_str());
32 std::string current_file;
36 result.push_back(current_file);
43 ///Adds an image to the list of recently opened images
44 void AddToRecentlyOpenedImages(std::string filename)
46 FileListType file_list = GetRecentlyOpenedImages();
47 FileListType::iterator i = std::find(file_list.begin(),file_list.end(),filename);
48 if (i != file_list.end()) // avoid dupes
50 while (file_list.size() >= 6) //keep list to a reasonable size
52 file_list.push_front(filename);
53 std::ofstream out((QDir::homePath().toStdString() + "/" + vv_user_file).c_str(),std::ios_base::out | std::ios_base::trunc);
54 for (FileListType::iterator j = file_list.begin() ; j != file_list.end() ; j++)
55 out << (*j) << std::endl;