FileSel: Show hidden files Option (not directories..)

git-svn-id: svn://ultimatepp.org/upp/trunk@1010 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-03-27 18:18:16 +00:00
parent 6980724a19
commit ae16bd0f6a
3 changed files with 24 additions and 13 deletions

View file

@ -30,15 +30,16 @@ LAYOUT(FileSelectorLayout, 516, 400)
ITEM(Label, filename, HSizePosZ(8, 208).BottomPosZ(88, 16))
ITEM(Label, filesize, RightPosZ(148, 56).BottomPosZ(88, 16))
ITEM(Label, filetime, RightPosZ(8, 136).BottomPosZ(88, 16))
ITEM(Label, file_lbl, SetLabel(t_("&File")).LeftPosZ(8, 64).BottomPosZ(67, 15))
ITEM(EditString, file, HSizePosZ(76, 8).BottomPosZ(65, 19))
ITEM(Label, type_lbl, SetLabel(t_("&Type")).LeftPosZ(8, 64).BottomPosZ(43, 15))
ITEM(DropList, type, HSizePosZ(76, 116).BottomPosZ(41, 19))
ITEM(Label, file_lbl, SetLabel(t_("&File")).LeftPosZ(8, 52).BottomPosZ(67, 15))
ITEM(EditString, file, HSizePosZ(60, 8).BottomPosZ(65, 19))
ITEM(Label, type_lbl, SetLabel(t_("&Type")).LeftPosZ(8, 52).BottomPosZ(43, 15))
ITEM(DropList, type, HSizePosZ(60, 116).BottomPosZ(41, 19))
ITEM(EditString, search, RightPosZ(8, 104).BottomPosZ(41, 19))
ITEM(Label, sort_lbl, SetLabel(t_("&Sort by")).LeftPosZ(8, 64).BottomPosZ(21, 15))
ITEM(Switch, sortext, SetLabel(t_("Name\nExtension")).LeftPosZ(76, 84).BottomPosZ(4, 32))
ITEM(Option, readonly, SetLabel(t_("Read only")).HSizePosZ(164, 256).BottomPosZ(6, 18))
ITEM(Option, hidden, SetLabel(t_("Show hidden")).HSizePosZ(260, 156).BottomPosZ(6, 18))
ITEM(Label, sort_lbl, SetLabel(t_("&Sort by")).LeftPosZ(8, 52).BottomPosZ(21, 15))
ITEM(Switch, sortext, SetLabel(t_("Name\nExtension")).LeftPosZ(60, 84).BottomPosZ(4, 32))
ITEM(Option, readonly, SetLabel(t_("Read only")).HSizePosZ(148, 296).BottomPosZ(4, 16))
ITEM(Option, hidden, SetLabel(t_("Show hidden items")).HSizePosZ(232, 164).BottomPosZ(18, 18))
ITEM(Option, hiddenfiles, SetLabel(t_("Show hidden files")).LeftPosZ(232, 120).TopPosZ(380, 16))
ITEM(Button, ok, SetLabel(t_("Open")).RightPosZ(84, 68).BottomPosZ(8, 24))
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 68).BottomPosZ(8, 24))
END_LAYOUT

View file

@ -242,7 +242,7 @@ bool MatchSearch(const String& filename, const String& search)
bool Load(FileList& list, const String& dir, const char *patterns, bool dirs,
Callback3<bool, const String&, Image&> WhenIcon, FileSystemInfo& filesystem,
const String& search, bool hidden)
const String& search, bool hidden, bool hiddenfiles)
{
if(dir.IsEmpty()) {
Array<FileSystemInfo::FileInfo> root = filesystem.Find(Null);
@ -269,10 +269,14 @@ bool Load(FileList& list, const String& dir, const char *patterns, bool dirs,
for(int t = 0; t < ffi.GetCount(); t++) {
const FileSystemInfo::FileInfo& fi = ffi[t];
bool nd = dirs && !fi.is_directory;
bool show = hidden;
if(!show && filesystem.IsWin32() ? !fi.is_hidden : fi.filename[0] != '.')
show = true;
if(!show && hiddenfiles && fi.is_file)
show = true;
if(fi.filename != "." && fi.filename != ".." != 0 &&
(fi.is_directory || PatternMatchMulti(patterns, fi.filename)) &&
MatchSearch(fi.filename, search) &&
(hidden || (filesystem.IsWin32() ? !fi.is_hidden : fi.filename[0] != '.'))) {
MatchSearch(fi.filename, search) && show) {
#ifdef PLATFORM_X11
Image img = isdrive ? PosixGetDriveImage(fi.filename)
: GetFileIcon(dir, fi.filename, fi.is_directory, fi.unix_mode & 0111);
@ -399,7 +403,7 @@ void FileSel::SearchLoad()
list.Clear();
String d = GetDir();
String emask = GetMask();
if(!UPP::Load(list, d, emask, mode == SELECTDIR, WhenIcon, *filesystem, ~search, ~hidden)) {
if(!UPP::Load(list, d, emask, mode == SELECTDIR, WhenIcon, *filesystem, ~search, ~hidden, ~hiddenfiles)) {
Exclamation(t_("[A3* Unable to read the directory !]&&") + DeQtf((String)~dir) + "&&" +
GetErrorMessage(GetLastError()));
if(!basedir.IsEmpty() && String(~dir).IsEmpty()) {
@ -410,6 +414,7 @@ void FileSel::SearchLoad()
olddir = Null;
SearchLoad();
}
hiddenfiles.Enable(!hidden);
if(d.IsEmpty()) {
if(filesystem->IsWin32()) {
mkdir.Disable();
@ -1186,6 +1191,9 @@ void FileSel::Serialize(Stream& s) {
if(version >= 7) {
s % hidden;
}
if(version >= 8) {
s % hiddenfiles;
}
}
String FileSel::GetFile(int i) const {
@ -1242,6 +1250,8 @@ FileSel::FileSel() {
Add(sortext);
hidden <<= THISBACK(SearchLoad);
Add(hidden);
hiddenfiles <<= THISBACK(SearchLoad);
Add(hiddenfiles);
mkdir <<= THISBACK(MkDir);
Add(mkdir);
plus <<= THISBACK(Plus);

View file

@ -109,7 +109,7 @@ public:
bool Load(FileList& list, const String& dir, const char *patterns, bool dirs = false,
Callback3<bool, const String&, Image&> WhenIcon = CNULL,
FileSystemInfo& filesystem = StdFileSystemInfo(), const String& search = String(),
bool hidden = true);
bool hidden = true, bool hiddenfiles = true);
void SortByName(FileList& list);
void SortByExt(FileList& list);