1 /*=========================================================================
5 Author : Joel Schaerer (joel.schaerer@insa-lyon.fr)
8 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
9 CREATIS-LRMN http://www.creatis.insa-lyon.fr
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, version 3 of the License.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 =========================================================================*/
29 #include "clitkCommon.h"
32 const std::string vv_user_file=".vv_settings.txt";
33 typedef std::list<std::string> FileListType;
35 ///Returns the last images opened by the user
36 FileListType GetRecentlyOpenedImages()
38 std::ifstream in((QDir::homePath().toStdString() + "/" + vv_user_file).c_str());
39 std::string current_file;
44 result.push_back(current_file);
51 ///Adds an image to the list of recently opened images
52 void AddToRecentlyOpenedImages(std::string filename)
54 FileListType file_list = GetRecentlyOpenedImages();
55 FileListType::iterator i = std::find(file_list.begin(),file_list.end(),filename);
56 if (i != file_list.end()) // avoid dupes
58 while (file_list.size() >= 6) //keep list to a reasonable size
60 file_list.push_front(filename);
61 std::ofstream out((QDir::homePath().toStdString() + "/" + vv_user_file).c_str(),std::ios_base::out | std::ios_base::trunc);
62 for (FileListType::iterator j = file_list.begin() ; j != file_list.end() ; j++)
63 out << (*j) << std::endl;