��������: AddAt ��������: bool ������Ϣ: CControlUI * pControl ������Ϣ: int iIndex �ò�������Ե�ǰ�ڵ��µ��ֵ������������б���ͼ���� ����˵��:
| 231 | // ����˵��: |
| 232 | //************************************ |
| 233 | bool CTreeNodeUI::AddAt( CControlUI* pControl, int iIndex ) |
| 234 | { |
| 235 | if (!pControl) |
| 236 | return false; |
| 237 | |
| 238 | if(_tcsicmp(pControl->GetClass(), _T("TreeNodeUI")) != 0) |
| 239 | return false; |
| 240 | |
| 241 | if (!GetFolderButton()->IsSelected()) //add by��Redrain 2014.8.8 |
| 242 | { |
| 243 | m_pManager->SendNotify(this, DUI_MSGTYPE_ITEMDBCLICK); |
| 244 | } |
| 245 | |
| 246 | //filter invalidate index |
| 247 | int iDestIndex = iIndex; |
| 248 | if (iDestIndex < 0) |
| 249 | { |
| 250 | iDestIndex = 0; |
| 251 | } |
| 252 | else if (iDestIndex > GetCountChild()) |
| 253 | { |
| 254 | iDestIndex = GetCountChild(); |
| 255 | } |
| 256 | if(iIndex != iDestIndex) iIndex = iDestIndex; |
| 257 | |
| 258 | CTreeNodeUI* pIndexNode = static_cast<CTreeNodeUI*>(mTreeNodes.GetAt(iIndex)); |
| 259 | |
| 260 | pControl = CalLocation((CTreeNodeUI*)pControl); |
| 261 | |
| 262 | bool bRet = false; |
| 263 | int iTreeIndex = -1; |
| 264 | if (pTreeView) |
| 265 | { |
| 266 | //Get TreeView insert index |
| 267 | if (pIndexNode) |
| 268 | { |
| 269 | iTreeIndex = pIndexNode->GetTreeIndex(); |
| 270 | bRet = pTreeView->AddAt((CTreeNodeUI*)pControl, iTreeIndex) >= 0; |
| 271 | if (bRet) |
| 272 | { |
| 273 | mTreeNodes.InsertAt(iIndex, pControl); |
| 274 | } |
| 275 | } |
| 276 | else |
| 277 | { |
| 278 | CTreeNodeUI *pChildNode = NULL; |
| 279 | //insert child node position index(new node insert to tail, default add tail) |
| 280 | int iChIndex = -1; |
| 281 | //insert child node tree-view position index(new node insert to tail) |
| 282 | int iChTreeIndex = -1; |
| 283 | //search tree index reverse |
| 284 | for (int i = GetCountChild(); i > 0; i++) |
| 285 | { |
| 286 | pChildNode = GetChildNode(i - 1); |
| 287 | iChTreeIndex = pChildNode->GetTreeIndex(); |
| 288 | if (iChTreeIndex >= GetTreeIndex() && iChTreeIndex <= GetTreeIndex() + GetCountChild() ) |
| 289 | { |
| 290 | //new child node position |
no test coverage detected