Add compatibility to load the recent list of paths from the recent list of files from old aseprite.ini files.

This commit is contained in:
David Capello 2012-02-11 19:09:50 -03:00
parent 6bcf559b35
commit 98fabee086
3 changed files with 23 additions and 3 deletions

View File

@ -24,6 +24,7 @@ public:
const_iterator begin() { return m_items.begin(); }
const_iterator end() { return m_items.end(); }
bool empty() const { return m_items.empty(); }
size_t size() const { return m_items.size(); }
size_t limit() const { return m_limit; }

View File

@ -26,6 +26,7 @@
#include <cstdio>
#include <cstring>
#include <set>
RecentFiles::RecentFiles()
: m_files(16)
@ -48,6 +49,25 @@ RecentFiles::RecentFiles()
if (path && *path)
m_paths.addItem(path);
}
// Create recent list of paths from filenames (for backward
// compatibility with previous versions of ASEPRITE).
if (m_paths.empty()) {
std::set<std::string> included;
// For each recent file...
const_iterator it = files_begin();
const_iterator end = files_end();
for (; it != end; ++it) {
base::string path = base::get_file_path(*it);
// Check if the path was not already included in the list
if (included.find(path) == included.end()) {
included.insert(path);
m_paths.addItem(path);
}
}
}
}
RecentFiles::~RecentFiles()

View File

@ -20,13 +20,12 @@
#define RECENT_FILES_H_INCLUDED
#include "base/recent_items.h"
#include <string>
#include "base/string.h"
class RecentFiles
{
public:
typedef base::RecentItems<std::string> List;
typedef base::RecentItems<base::string> List;
typedef List::iterator iterator;
typedef List::const_iterator const_iterator;