forked from mia/Aegisub
Add a function to remove items from MRU lists, in preparation for a fix for #717. Also a bit of prettyfication of the MRU handling code.
Originally committed to SVN as r2220.
This commit is contained in:
parent
5a2e91c00a
commit
67bfd70f82
2 changed files with 37 additions and 4 deletions
|
@ -644,7 +644,7 @@ void OptionsManager::AddToRecentList (wxString entry,wxString list) {
|
|||
int recentMax = AsInt(list + _T(" max"));
|
||||
int n = 0;
|
||||
for (int i=0;i<recentMax;i++) {
|
||||
wxString key = list + _T(" #") + wxString::Format(_T("%i"),i+1);
|
||||
wxString key = wxString::Format(_T("%s #%i"), list.c_str(), i+1);
|
||||
if (IsDefined(key)) {
|
||||
cur = AsText(key);
|
||||
if (cur != entry) {
|
||||
|
@ -659,7 +659,7 @@ void OptionsManager::AddToRecentList (wxString entry,wxString list) {
|
|||
SetText(list + _T(" #1"),entry);
|
||||
if (n > recentMax-1) n = recentMax-1;
|
||||
for (int i=0;i<n;i++) {
|
||||
wxString key = list + _T(" #") + wxString::Format(_T("%i"),i+2);
|
||||
wxString key = wxString::Format(_T("%s #%i"), list.c_str(), i+2);
|
||||
SetText(key,orig[i]);
|
||||
}
|
||||
|
||||
|
@ -668,14 +668,45 @@ void OptionsManager::AddToRecentList (wxString entry,wxString list) {
|
|||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Removes an item from a list of recents, if it's in the list
|
||||
void OptionsManager::RemoveFromRecentList (wxString entry,wxString list) {
|
||||
// Find strings already in recent list
|
||||
wxArrayString cleaned;
|
||||
wxString cur;
|
||||
int recentMax = AsInt(list + _T(" max"));
|
||||
int n = 0;
|
||||
for (int i=0;i<recentMax;i++) {
|
||||
wxString key = wxString::Format(_T("%s #%i"), list.c_str(), i+1);
|
||||
if (IsDefined(key)) {
|
||||
cur = AsText(key);
|
||||
if (cur != entry) {
|
||||
cleaned.Add(cur);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
||||
// Write back to options
|
||||
if (n > recentMax-1) n = recentMax-1;
|
||||
for (int i=0;i<n;i++) {
|
||||
wxString key = wxString::Format(_T("%s #%i"), list.c_str(), i+1);
|
||||
SetText(key,cleaned[i]);
|
||||
}
|
||||
|
||||
// Save options
|
||||
Save();
|
||||
}
|
||||
|
||||
|
||||
///////////////////
|
||||
// Get recent list
|
||||
wxArrayString OptionsManager::GetRecentList (wxString list) {
|
||||
wxArrayString work;
|
||||
int recentMax = AsInt(list + _T(" max"));
|
||||
for (int i=0;i<recentMax;i++) {
|
||||
wxString n = wxString::Format(_T("%i"),i+1);
|
||||
wxString key = list + _T(" #") + n;
|
||||
wxString key = wxString::Format(_T("%s #%i"), list.c_str(), i+1);
|
||||
if (IsDefined(key)) {
|
||||
work.Add(Options.AsText(key));
|
||||
}
|
||||
|
|
|
@ -82,7 +82,9 @@ public:
|
|||
void Save();
|
||||
void Load();
|
||||
void LoadDefaults(bool onlyDefaults=false,bool versionOverride=false);
|
||||
|
||||
void AddToRecentList (wxString entry,wxString list);
|
||||
void RemoveFromRecentList (wxString entry,wxString list);
|
||||
wxArrayString GetRecentList (wxString list);
|
||||
|
||||
void SetInt(wxString key,int param,int ifLastVersion=-1);
|
||||
|
|
Loading…
Reference in a new issue