Skip to content

Commit

Permalink
[#36] File Manager: General improvements and bugfixes (Part 4: Item s…
Browse files Browse the repository at this point in the history
…election toggling via Insert key)
  • Loading branch information
tomas-nestorovic committed Nov 14, 2019
1 parent 3a414b7 commit a39c627
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions Main/res/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
#define ID_TDI_SWITCH_BACK 40034
#define ID_EDIT_SELECT_NONE 40057
#define ID_EDIT_SELECT_INVERSE 40058
#define ID_EDIT_SELECT_TOGGLE 40059
#define ID_BOOKMARK_TOGGLE 40062
#define ID_DATA 40068
#define ID_RECURRENCY 40080
Expand Down
1 change: 1 addition & 0 deletions Main/res/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ BEGIN
VK_DELETE, ID_FILEMANAGER_FILE_DELETE, VIRTKEY, NOINVERT
VK_F2, ID_FILEMANAGER_FILE_EDIT, VIRTKEY, NOINVERT
VK_F5, ID_FILEMANAGER_REFRESH, VIRTKEY, NOINVERT
VK_INSERT, ID_EDIT_SELECT_TOGGLE, VIRTKEY, NOINVERT
VK_RETURN, ID_FILEMANAGER_FILE_INFORMATION, VIRTKEY, ALT, NOINVERT
"X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
END
Expand Down
12 changes: 12 additions & 0 deletions Main/src/ViewFileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
ON_COMMAND(ID_EDIT_SELECT_ALL,__selectAllFilesInCurrentDir__)
ON_COMMAND(ID_EDIT_SELECT_NONE,__unselectAllFilesInCurrentDir__)
ON_COMMAND(ID_EDIT_SELECT_INVERSE,__invertSelectionInCurrentDir__)
ON_COMMAND(ID_EDIT_SELECT_TOGGLE,__toggleFocusedItemSelection__)
ON_COMMAND(ID_FILEMANAGER_FILE_DELETE,__deleteSelectedFilesUponConfirmation__)
ON_UPDATE_COMMAND_UI(ID_FILEMANAGER_FILE_DELETE,__imageWritableAndFileSelected_updateUI__)
ON_COMMAND(ID_EDIT_COPY,__copyFilesToClipboard__)
Expand Down Expand Up @@ -313,6 +314,17 @@
SetRedraw(TRUE);
}

afx_msg void CFileManagerView::__toggleFocusedItemSelection__(){
// toggles selection status of currently focused File, and moves focus to the next File
CListCtrl &lv=GetListCtrl();
if (const int nItems=lv.GetItemCount()){
int iFocused=std::max( 0, lv.GetNextItem(-1,LVNI_FOCUSED) );
if (lv.GetSelectedCount()!=1 || lv.GetNextItem(-1,LVNI_SELECTED)!=iFocused) // A|B; A = multiple items already selected (maybe by sequentially toggling their statuses), B = the focused and first selected items are different (user selected one item, now wants to select another)
lv.SetItemState( iFocused, ~lv.GetItemState(iFocused,LVIS_SELECTED), LVIS_SELECTED );
lv.SetItemState( std::min(++iFocused,nItems-1), LVIS_FOCUSED, LVIS_FOCUSED );
}
}

afx_msg void CFileManagerView::__deleteSelectedFilesUponConfirmation__(){
// shows confirmation dialog and eventually deletes selected Files
// - at least one File must be selected
Expand Down
1 change: 1 addition & 0 deletions Main/src/ViewFileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
afx_msg void __selectAllFilesInCurrentDir__();
afx_msg void __unselectAllFilesInCurrentDir__();
afx_msg void __invertSelectionInCurrentDir__();
afx_msg void __toggleFocusedItemSelection__();
afx_msg void __fileSelected_updateUI__(CCmdUI *pCmdUI);
afx_msg void __deleteSelectedFilesUponConfirmation__();
afx_msg void __onBeginDrag__(NMHDR *pNMHDR,LRESULT *pResult);
Expand Down

0 comments on commit a39c627

Please sign in to comment.