Exemple #1
0
void __fastcall TfrmChoseItem::ebMultiRemoveClick(TObject *Sender)
{
	if (tvMulti->Selected){
    	TElTreeItem *cur = tvMulti->Selected;
	    TElTreeItem *node = tvItems->Items->LookForItem(0,cur->Text,0,0,false,true,false,true,true);
        if (node) node->Checked = false;
        tvMulti->Selected = cur->GetNext()?cur->GetNext():cur->GetPrev();
    	cur->Delete();
    }
}
Exemple #2
0
void __fastcall TfrmChoseItem::tvItemsItemChange(TObject *Sender,
      TElTreeItem *Item, TItemChangeMode ItemChangeMode)
{
	if (Item&&(ItemChangeMode==icmCheckState)){
        AnsiString fn;
        FHelper.MakeName(Item,0,fn,false);
	    TElTreeItem *node = tvMulti->Items->LookForItem(0,fn.c_str(),0,0,false,true,false,true,true);
        if (node&&!Item->Checked) node->Delete();
        if (!node&&Item->Checked){
	    	if ((tvMulti->Items->Count+1)<=iMultiSelLimit){
    	        tvMulti->Items->AddObject(0,fn,(void*)TYPE_OBJECT);
            }else{
            	Item->Checked 	= false;
	        	Msg				("#Limit %d item(s).",iMultiSelLimit);
            }
        }
    }
}
Exemple #3
0
//---------------------------------------------------------------------------
// Drag'n'Drop
//---------------------------------------------------------------------------
void CFolderHelper::DragDrop(TObject *Sender, TObject* Source, int X, int Y, TOnItemRename after_drag)
{
	R_ASSERT(after_drag);

	TElTree* tv = dynamic_cast<TElTree*>(Sender); VERIFY(tv);

    tv->IsUpdating = true;
    
    TSTItemPart IP=(TSTItemPart)0;
    int 		hc=0;
	TElTreeItem* tgt_folder = tv->GetItemAt(X, Y, IP, hc);
    if (tgt_folder&&(IsObject(tgt_folder))) tgt_folder=tgt_folder->Parent;

    AnsiString base_name;
    MakeName(tgt_folder,0,base_name,true);
    AnsiString cur_fld_name=base_name;
    TElTreeItem* cur_folder=tgt_folder;

//..FS.lock_rescan();
    for (ELVecIt it=drag_items.begin(); it!=drag_items.end(); it++){
        TElTreeItem* item 	= *it;
        int drg_level		= item->Level;

        bool bFolderMove	= IsFolder(item);

        do{
            // проверяем есть ли в таргете такой элемент
            EItemType type 	= EItemType(item->Data);
            TElTreeItem* pNode = FindItemInFolder(type,tv,cur_folder,item->Text);
            if (pNode&&IsObject(item)){
                Msg			("#!Item '%s' already exist in folder '%s'.",AnsiString(item->Text).c_str(),AnsiString(cur_folder->Text).c_str());
                item		= item->GetNext();
                continue;
            }
            // если нет добавляем
            if (!pNode){ 
                pNode 				= (type==TYPE_FOLDER)?LL_CreateFolder(tv,cur_folder,item->Text,item->ForceButtons):LL_CreateObject(tv,cur_folder,item->Text);
                if (type==TYPE_OBJECT) pNode->Assign(item);
            }
            if (IsFolder(item)){
                cur_folder 			= pNode;
                MakeName			(cur_folder,0,cur_fld_name,true);
                item				= item->GetNext();
            }else{
                // rename
                AnsiString old_name, new_name;
                MakeName			(item,0,old_name,false);
                MakeName			(pNode,0,new_name,false);

                after_drag			(old_name.c_str(),new_name.c_str(),TYPE_OBJECT);

                TElTreeItem* parent	= item->Parent;
                // get next item && delete existence
                TElTreeItem* next	= item->GetNext();
                item->Delete		();

                if (parent&&((parent->GetLastChild()==item)||(0==parent->ChildrenCount))){
    //	            if (0==parent->ChildrenCount) parent->Delete();
                    cur_folder = cur_folder?cur_folder->Parent:0;
                }

                item=next;
            }
        }while(item&&(item->Level>drg_level));
        // delete folders
        if (bFolderMove){
            AnsiString 		old_name;
            MakeName		(*it,0,old_name,false);
            after_drag		(old_name.c_str(),0,TYPE_FOLDER);
            (*it)->Delete	();
        }
    }
//..FS.unlock_rescan();

    tv->IsUpdating = false;
 }