Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
add dependent file property
Browse files Browse the repository at this point in the history
  • Loading branch information
MPIBR-tushevg committed Nov 9, 2017
1 parent b502bc2 commit eca0622
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## ---
## remove autosaves generate by the Matlab editor
## ---

# windows default autosave extension
*.asv

# OSX / *nix default autosave extension
*.m~

# Compiled MEX binaries (all platforms)
*.mex*

# OSX index file
.DS_Store

# Text files
*.txt

28 changes: 8 additions & 20 deletions WidgetFolderBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
% Max-Planck Institute For Brain Research
%

properties (Dependent)
properties (SetObservable = true)

file

Expand All @@ -22,11 +22,6 @@

end

events

event_file

end

methods

Expand All @@ -50,16 +45,12 @@
error('WidgetFolderBrowserModel: initailizing model failed!');
end


% link ui events
addlistener(obj.ui, 'event_fileLoad', @obj.fcnCallback_fileLoad);
addlistener(obj.ui, 'event_fileNext', @obj.fcnCallback_fileNext);
addlistener(obj.ui, 'event_filePrevious', @obj.fcnCallback_filePrevious);
addlistener(obj.ui, 'event_folderLoad', @obj.fcnCallback_folderLoad);

% link model events
addlistener(obj.model, 'file', 'PostSet', @obj.fcnCallback_fileUpdated);

end
end

Expand All @@ -69,43 +60,40 @@
function obj = fcnCallback_fileLoad(obj, ~, ~)

obj.model.fileLoad();
obj.requestNewFile();

end

%% @ ui event_fileNext
function obj = fcnCallback_fileNext(obj, ~, ~)

obj.model.fileUpdate(1);
obj.requestNewFile();

end

%% @ ui event_filePrevious
function obj = fcnCallback_filePrevious(obj, ~, ~)

obj.model.fileUpdate(-1);
obj.requestNewFile();

end

%% @ ui event_folderLoad
function obj = fcnCallback_folderLoad(obj, ~, ~)

obj.model.folderLoad();
obj.requestNewFile();

end

%% @ model event_fileUpdate
function obj = fcnCallback_fileUpdated(obj, ~, ~)
%% @ request newfile
function obj = requestNewFile(obj)

obj.ui.updateFileName(obj.model.fileTag);
obj.ui.updateFileCounter(obj.model.index, obj.model.listSize);
notify(obj, 'event_file');

end

%% @ request file
function varfile = get.file(obj)

varfile = obj.model.file;
obj.file = obj.model.file();

end

Expand Down
19 changes: 8 additions & 11 deletions WidgetFolderBrowserModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@

end

properties (SetObservable)

file

end

properties (Dependent)

listSize
fileTag
file

end

Expand All @@ -46,7 +41,6 @@
obj.path = pathName(1:end-1); % uigetfile retunrns pathName with filesep
obj.list = {[pathName, fileName]};
obj.index = 1;
obj.file = obj.list{obj.index};

end

Expand Down Expand Up @@ -79,7 +73,6 @@
obj.path = pathName;
obj.list = cellfun(@(x) {[pathName, filesep, x]},{folderInfo.name}');
obj.index = 1;
obj.file = obj.list{obj.index};

end

Expand Down Expand Up @@ -110,9 +103,6 @@

end

% update filename
obj.file = obj.list{obj.index};

end

function value = get.listSize(obj)
Expand All @@ -126,5 +116,12 @@
[~, vartag] = fileparts(obj.file);

end

function varchar = get.file(obj)

varchar = obj.list{obj.index};

end

end
end

0 comments on commit eca0622

Please sign in to comment.