function [FileList, Dir, Nav] = prjDlgAdd(ce, FileList, Options, Dir, Nav);
% FileList = prjAdd(CE);
% CE poa sa fie 'file', 'dir'
% pentru Quadra, 2.11.03
% v.045, 13.12.2003, - add index unde inserezi
exportdir =1;
if nargin < 5 Nav = uConstr('nav'); disp('prjDlgAdd: inserting at top'); end; % introdu la top, by default
if nargin < 4 Dir = uConstr('Dir'); disp('prjDlgAdd: using default dir'); exportdir = 0; end;
if nargin < 3 Options = uConstr('options'); disp('prjDlgAdd: using default options'); end;
if nargin < 2
FileList = uConstr('fileinfo'); disp('prjDlgAdd: no list, building from scratch');
else
if isempty(FileList)
FileList = uConstr('fileinfo'); disp('prjDlgAdd: empty list, resetting');
end;
end;
if nargin < 1 ce = 'file'; end;
updated = 0;
cmd= ['Dir.working = pwd; cd ''' Dir.lastopen '''']; eval(cmd);
switch ce
case 'file'
[filename, pathname] = uigetfile({'*.jpg; *.jpeg; *.gif; *.tif; *.tiff; *.gif; *.bmp; *.png; *.hdf; *.pcx; *.xwd; *.cur; *.ico', 'imagini recunoscute'; ...
'*.*', 'orice tip de fisier (*.*)'}, ...
'add File to list : valid image types only');
if isequal(filename,0)|isequal(pathname,0)
disp('empty, keeping the old list.');
else
Dir.lastopen = pathname;
FileEntry_cand = prjCheckFile(pathname, filename, Options);
if ~strcmp(FileEntry_cand.path, '$empty') FileEntry=FileEntry_cand; updated = 1;end;
end;
case 'dir'
Dir = prjDir(Dir, 'lastopen');
if Dir.loadok
candidates = dir(Dir.lastopen); ix=0;
for i=1:size(candidates,1)
if ~candidates(i).isdir
FileEntry_cand = prjCheckFile(Dir.lastopen, candidates(i).name, Options);
if ~strcmp(FileEntry_cand.path, '$empty') ix=ix+1; FileEntry(ix)=FileEntry_cand; end;
end;
end;
if ix updated = 1; end;
end;
end;
cmd = ['cd ''' Dir.working ''''];
eval(cmd)
if updated
if isempty(FileList) | strcmp(FileList(1).path,'$empty')
FileList = FileEntry;
else FileList = [FileList(1:Nav.image_index) FileEntry FileList(Nav.image_index+1:size(FileList,2))];
Nav.image_index=Nav.image_index+size(FileEntry,2);
end;
clear FileEntry;
else
disp('nothing new');
end;