Make TreeView sorting unrecursivable
And update coding style.
This commit is contained in:
parent
0c80bf8cb9
commit
585cc27b1f
@ -262,10 +262,11 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||||||
generic_string addedFilePath = file2Change[0].substr(0, sepPos + 1);
|
generic_string addedFilePath = file2Change[0].substr(0, sepPos + 1);
|
||||||
addedFilePath += pathSuffix;
|
addedFilePath += pathSuffix;
|
||||||
bool isAdded = addInTree(rootPath, addedFilePath, nullptr, linarPathArray);
|
bool isAdded = addInTree(rootPath, addedFilePath, nullptr, linarPathArray);
|
||||||
if (not isAdded)
|
if (!isAdded)
|
||||||
{
|
{
|
||||||
//MessageBox(NULL, addedFilePath.c_str(), TEXT("file/folder is not added"), MB_OK);
|
//MessageBox(NULL, addedFilePath.c_str(), TEXT("file/folder is not added"), MB_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +288,7 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||||||
// search recursively and modify the tree structure
|
// search recursively and modify the tree structure
|
||||||
|
|
||||||
bool isRemoved = deleteFromTree(rootPath, nullptr, linarPathArray);
|
bool isRemoved = deleteFromTree(rootPath, nullptr, linarPathArray);
|
||||||
if (not isRemoved)
|
if (!isRemoved)
|
||||||
{
|
{
|
||||||
//MessageBox(NULL, file2Change[0].c_str(), TEXT("file/folder is not removed"), MB_OK);
|
//MessageBox(NULL, file2Change[0].c_str(), TEXT("file/folder is not removed"), MB_OK);
|
||||||
}
|
}
|
||||||
@ -318,7 +319,7 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||||||
vector<generic_string> linarPathArray2 = split(pathSuffix2, '\\');
|
vector<generic_string> linarPathArray2 = split(pathSuffix2, '\\');
|
||||||
|
|
||||||
bool isRenamed = renameInTree(rootPath, nullptr, linarPathArray, linarPathArray2[linarPathArray2.size() - 1]);
|
bool isRenamed = renameInTree(rootPath, nullptr, linarPathArray, linarPathArray2[linarPathArray2.size() - 1]);
|
||||||
if (not isRenamed)
|
if (!isRenamed)
|
||||||
{
|
{
|
||||||
//MessageBox(NULL, file2Change[0].c_str(), TEXT("file/folder is not removed"), MB_OK);
|
//MessageBox(NULL, file2Change[0].c_str(), TEXT("file/folder is not removed"), MB_OK);
|
||||||
}
|
}
|
||||||
@ -464,7 +465,7 @@ void FileBrowser::destroyMenus()
|
|||||||
|
|
||||||
generic_string FileBrowser::getNodePath(HTREEITEM node) const
|
generic_string FileBrowser::getNodePath(HTREEITEM node) const
|
||||||
{
|
{
|
||||||
if (not node) return TEXT("");
|
if (!node) return TEXT("");
|
||||||
|
|
||||||
vector<generic_string> fullPathArray;
|
vector<generic_string> fullPathArray;
|
||||||
generic_string fullPath;
|
generic_string fullPath;
|
||||||
@ -760,7 +761,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
|||||||
//
|
//
|
||||||
case IDM_FILEBROWSER_REMOVEROOTFOLDER:
|
case IDM_FILEBROWSER_REMOVEROOTFOLDER:
|
||||||
{
|
{
|
||||||
if (not selectedNode) return;
|
if (!selectedNode) return;
|
||||||
|
|
||||||
generic_string *rootPath = (generic_string *)_treeView.getItemParam(selectedNode);
|
generic_string *rootPath = (generic_string *)_treeView.getItemParam(selectedNode);
|
||||||
if (_treeView.getParent(selectedNode) != nullptr || rootPath == nullptr)
|
if (_treeView.getParent(selectedNode) != nullptr || rootPath == nullptr)
|
||||||
@ -782,7 +783,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
|||||||
|
|
||||||
case IDM_FILEBROWSER_EXPLORERHERE:
|
case IDM_FILEBROWSER_EXPLORERHERE:
|
||||||
{
|
{
|
||||||
if (not selectedNode) return;
|
if (!selectedNode) return;
|
||||||
|
|
||||||
generic_string path = getNodePath(selectedNode);
|
generic_string path = getNodePath(selectedNode);
|
||||||
if (::PathFileExists(path.c_str()))
|
if (::PathFileExists(path.c_str()))
|
||||||
@ -800,7 +801,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
|||||||
|
|
||||||
case IDM_FILEBROWSER_CMDHERE:
|
case IDM_FILEBROWSER_CMDHERE:
|
||||||
{
|
{
|
||||||
if (not selectedNode) return;
|
if (!selectedNode) return;
|
||||||
|
|
||||||
if (getNodeType(selectedNode) == browserNodeType_file)
|
if (getNodeType(selectedNode) == browserNodeType_file)
|
||||||
selectedNode = _treeView.getParent(selectedNode);
|
selectedNode = _treeView.getParent(selectedNode);
|
||||||
@ -816,7 +817,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
|||||||
|
|
||||||
case IDM_FILEBROWSER_COPYPATH:
|
case IDM_FILEBROWSER_COPYPATH:
|
||||||
{
|
{
|
||||||
if (not selectedNode) return;
|
if (!selectedNode) return;
|
||||||
generic_string path = getNodePath(selectedNode);
|
generic_string path = getNodePath(selectedNode);
|
||||||
str2Clipboard(path, _hParent);
|
str2Clipboard(path, _hParent);
|
||||||
}
|
}
|
||||||
@ -824,7 +825,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
|||||||
|
|
||||||
case IDM_FILEBROWSER_COPYFILENAME:
|
case IDM_FILEBROWSER_COPYFILENAME:
|
||||||
{
|
{
|
||||||
if (not selectedNode) return;
|
if (!selectedNode) return;
|
||||||
generic_string fileName = getNodeName(selectedNode);
|
generic_string fileName = getNodeName(selectedNode);
|
||||||
str2Clipboard(fileName, _hParent);
|
str2Clipboard(fileName, _hParent);
|
||||||
}
|
}
|
||||||
@ -832,7 +833,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
|||||||
|
|
||||||
case IDM_FILEBROWSER_FINDINFILES:
|
case IDM_FILEBROWSER_FINDINFILES:
|
||||||
{
|
{
|
||||||
if (not selectedNode) return;
|
if (!selectedNode) return;
|
||||||
generic_string path = getNodePath(selectedNode);
|
generic_string path = getNodePath(selectedNode);
|
||||||
::SendMessage(_hParent, NPPM_LAUNCHFINDINFILESDLG, reinterpret_cast<WPARAM>(path.c_str()), 0);
|
::SendMessage(_hParent, NPPM_LAUNCHFINDINFILESDLG, reinterpret_cast<WPARAM>(path.c_str()), 0);
|
||||||
}
|
}
|
||||||
@ -1149,7 +1150,7 @@ bool FileBrowser::addInTree(const generic_string& rootPath, const generic_string
|
|||||||
if (linarPathArray.size() == 1)
|
if (linarPathArray.size() == 1)
|
||||||
{
|
{
|
||||||
// Of course item to add should be exist on the disk
|
// Of course item to add should be exist on the disk
|
||||||
if (not::PathFileExists(addItemFullPath.c_str()))
|
if (!::PathFileExists(addItemFullPath.c_str()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Search : if no found, add
|
// Search : if no found, add
|
||||||
@ -1166,6 +1167,7 @@ bool FileBrowser::addInTree(const generic_string& rootPath, const generic_string
|
|||||||
{
|
{
|
||||||
_treeView.addItem(linarPathArray[0].c_str(), node, INDEX_LEAF);
|
_treeView.addItem(linarPathArray[0].c_str(), node, INDEX_LEAF);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1251,7 +1253,8 @@ bool FileBrowser::renameInTree(const generic_string& rootPath, HTREEITEM node, c
|
|||||||
|
|
||||||
// found it, rename it
|
// found it, rename it
|
||||||
_treeView.renameItem(foundItem, renameTo.c_str());
|
_treeView.renameItem(foundItem, renameTo.c_str());
|
||||||
return true;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FolderInfo::addToStructure(generic_string & fullpath, std::vector<generic_string> linarPathArray)
|
bool FolderInfo::addToStructure(generic_string & fullpath, std::vector<generic_string> linarPathArray)
|
||||||
@ -1476,7 +1479,7 @@ DWORD WINAPI FolderUpdater::watching(void *params)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FILE_ACTION_RENAMED_NEW_NAME:
|
case FILE_ACTION_RENAMED_NEW_NAME:
|
||||||
if (not oldName.empty())
|
if (!oldName.empty())
|
||||||
{
|
{
|
||||||
file2Change.push_back(oldName);
|
file2Change.push_back(oldName);
|
||||||
file2Change.push_back(wstrFilename);
|
file2Change.push_back(wstrFilename);
|
||||||
|
@ -198,7 +198,7 @@ void FunctionListPanel::sortOrUnsort()
|
|||||||
{
|
{
|
||||||
bool doSort = shouldSort();
|
bool doSort = shouldSort();
|
||||||
if (doSort)
|
if (doSort)
|
||||||
_pTreeView->sort(_pTreeView->getRoot());
|
_pTreeView->sort(_pTreeView->getRoot(), true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TCHAR text2search[MAX_PATH] ;
|
TCHAR text2search[MAX_PATH] ;
|
||||||
@ -369,7 +369,7 @@ void FunctionListPanel::reload()
|
|||||||
bool isSort = (previousParams->_searchParameters)._doSort;
|
bool isSort = (previousParams->_searchParameters)._doSort;
|
||||||
setSort(isSort);
|
setSort(isSort);
|
||||||
if (isSort)
|
if (isSort)
|
||||||
_pTreeView->sort(_pTreeView->getRoot());
|
_pTreeView->sort(_pTreeView->getRoot(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,7 +627,7 @@ void FunctionListPanel::searchFuncAndSwitchView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (doSort)
|
if (doSort)
|
||||||
_pTreeView->sort(_pTreeView->getRoot());
|
_pTreeView->sort(_pTreeView->getRoot(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WNDPROC oldFunclstToolbarProc = NULL;
|
static WNDPROC oldFunclstToolbarProc = NULL;
|
||||||
|
@ -103,7 +103,7 @@ bool TreeView::setItemParam(HTREEITEM Item2Set, const TCHAR *paramStr)
|
|||||||
|
|
||||||
LPARAM TreeView::getItemParam(HTREEITEM Item2Get) const
|
LPARAM TreeView::getItemParam(HTREEITEM Item2Get) const
|
||||||
{
|
{
|
||||||
if (not Item2Get)
|
if (!Item2Get)
|
||||||
return false;
|
return false;
|
||||||
//TCHAR textBuffer[MAX_PATH];
|
//TCHAR textBuffer[MAX_PATH];
|
||||||
TVITEM tvItem;
|
TVITEM tvItem;
|
||||||
@ -117,7 +117,7 @@ LPARAM TreeView::getItemParam(HTREEITEM Item2Get) const
|
|||||||
|
|
||||||
generic_string TreeView::getItemDisplayName(HTREEITEM Item2Set) const
|
generic_string TreeView::getItemDisplayName(HTREEITEM Item2Set) const
|
||||||
{
|
{
|
||||||
if (not Item2Set)
|
if (!Item2Set)
|
||||||
return TEXT("");
|
return TEXT("");
|
||||||
TCHAR textBuffer[MAX_PATH];
|
TCHAR textBuffer[MAX_PATH];
|
||||||
TVITEM tvItem;
|
TVITEM tvItem;
|
||||||
@ -131,7 +131,7 @@ generic_string TreeView::getItemDisplayName(HTREEITEM Item2Set) const
|
|||||||
|
|
||||||
bool TreeView::renameItem(HTREEITEM Item2Set, const TCHAR *newName)
|
bool TreeView::renameItem(HTREEITEM Item2Set, const TCHAR *newName)
|
||||||
{
|
{
|
||||||
if (not Item2Set || not newName)
|
if (!Item2Set || !newName)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TVITEM tvItem;
|
TVITEM tvItem;
|
||||||
@ -712,10 +712,12 @@ bool TreeView::restoreFoldingStateFrom(const TreeStateNode & treeState2Compare,
|
|||||||
return isOk;
|
return isOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeView::sort(HTREEITEM hTreeItem)
|
void TreeView::sort(HTREEITEM hTreeItem, bool isRecusive)
|
||||||
{
|
{
|
||||||
::SendMessage(_hSelf, TVM_SORTCHILDREN, TRUE, reinterpret_cast<LPARAM>(hTreeItem));
|
::SendMessage(_hSelf, TVM_SORTCHILDREN, TRUE, reinterpret_cast<LPARAM>(hTreeItem));
|
||||||
|
if (!isRecusive)
|
||||||
|
return;
|
||||||
|
|
||||||
for (HTREEITEM hItem = getChildFrom(hTreeItem); hItem != NULL; hItem = getNextSibling(hItem))
|
for (HTREEITEM hItem = getChildFrom(hTreeItem); hItem != NULL; hItem = getNextSibling(hItem))
|
||||||
sort(hItem);
|
sort(hItem, isRecusive);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ public:
|
|||||||
bool restoreFoldingStateFrom(const TreeStateNode & treeState2Compare, HTREEITEM treeviewNode);
|
bool restoreFoldingStateFrom(const TreeStateNode & treeState2Compare, HTREEITEM treeviewNode);
|
||||||
bool retrieveFoldingStateTo(TreeStateNode & treeState2Construct, HTREEITEM treeviewNode);
|
bool retrieveFoldingStateTo(TreeStateNode & treeState2Construct, HTREEITEM treeviewNode);
|
||||||
bool searchLeafAndBuildTree(TreeView & tree2Build, const generic_string & text2Search, int index2Search);
|
bool searchLeafAndBuildTree(TreeView & tree2Build, const generic_string & text2Search, int index2Search);
|
||||||
void sort(HTREEITEM hTreeItem);
|
void sort(HTREEITEM hTreeItem, bool isRecusive);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WNDPROC _defaultProc;
|
WNDPROC _defaultProc;
|
||||||
|
Loading…
Reference in New Issue
Block a user