.CtrlLib: FileSel improved handling of active type

git-svn-id: svn://ultimatepp.org/upp/trunk@2423 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2010-05-26 09:28:36 +00:00
parent 43d02d34b9
commit 72a6de8db6
2 changed files with 27 additions and 11 deletions

View file

@ -1109,6 +1109,14 @@ FileSel& FileSel::ClearTypes()
return *this;
}
FileSel& FileSel::ActiveType(int i)
{
activetype.Clear();
if(i >= 0 && i < type.GetCount())
activetype = type.GetValue(i);
return *this;
}
FileSel& FileSel::AllFilesType() {
return Type(t_("All files"), "*.*");
}
@ -1291,8 +1299,12 @@ bool FileSel::Execute(int _mode) {
px += dp;
}
dir.HSizePos(dr.left, px + 4);
if(activetype >= 0 && activetype < type.GetCount())
type.SetIndex(activetype);
int q = type.FindValue(activetype);
if(q >= 0)
type <<= q;
else
if(type.GetCount())
type.SetIndex(0);
int dlc = type.GetCount();
Load();
ActiveFocus(file.IsEditable() ? (Ctrl&)file : (Ctrl&)list);
@ -1319,10 +1331,10 @@ bool FileSel::Execute(int _mode) {
int c = TopWindow::Run(appmodal);
TopWindow::Close();
lastsby = list.GetSbPos();
int ti = ~type;
type.Trim(dlc);
activetype = type.GetIndex();
if(activetype >= dlc || activetype < 0)
activetype = 0;
if(ti >= 0 && ti < type.GetCount())
activetype = type.GetValue(ti);
if(c == IDOK) {
String d = ~dir;
if(filesystem->IsWin32())
@ -1360,10 +1372,15 @@ void FileSel::Serialize(Stream& s) {
netstack.Clear();
}
#endif
int version = 9;
int version = 10;
s / version;
String ad = ~dir;
s / activetype % ad;
int dummy;
if(version < 10)
s / dummy;
else
s % activetype;
s % ad;
dir <<= ad;
if(version < 1) {
String n = fn.At(0);
@ -1624,7 +1641,6 @@ FileSel::FileSel() {
dir.DisplayAll();
dir.SetDropLines(24);
activetype = 0;
readonly.Hide();
lastsby = 0;

View file

@ -137,7 +137,7 @@ protected:
String olddir;
String basedir;
int activetype;
String activetype;
String defext;
String preselect;
Vector<String> fn;
@ -226,7 +226,7 @@ public:
bool GetReadOnly() const { return readonly; }
String GetActiveDir() const { return dir.GetData(); }
int GetActiveType() const { return activetype; }
int GetActiveType() const { return type.GetIndex(); }
void Filesystem(FileSystemInfo& fsys) { filesystem = &fsys;}
FileSystemInfo& GetFilesystem() const { return *filesystem; }
@ -236,7 +236,7 @@ public:
FileSel& AllFilesType();
FileSel& ClearTypes();
FileSel& ActiveDir(const String& d) { dir <<= d; return *this; }
FileSel& ActiveType(int i) { activetype = i; return *this; }
FileSel& ActiveType(int i);
FileSel& PreSelect(const String& path);
FileSel& DefaultExt(const char *ext) { defext = ext; return *this; }
FileSel& Multi(bool b = true) { multi = b; return *this; }