Ejemplo n.º 1
0
bool CFolderHelper::RenameItem(TElTree* tv, TElTreeItem* node, AnsiString& new_text, TOnItemRename OnRename)
{
    R_ASSERT(OnRename);
    if (new_text.IsEmpty()) return false;
    new_text = new_text.LowerCase();

    // find item with some name
    for (TElTreeItem* item=node->GetFirstSibling(); item; item=item->GetNextSibling()){
        if ((item->Text==new_text)&&(item!=node))
            return false;
    }
    AnsiString full_name;
    if (IsFolder(node)){
    	// is folder - rename all folder items
        for (TElTreeItem* item=node->GetFirstChild(); item&&(item->Level>node->Level); item=item->GetNext()){
            if (IsObject(item)){
                MakeName(item,0,full_name,false);
                VERIFY(node->Level<_GetItemCount(full_name.c_str(),'\\'));
                AnsiString new_full_name;
                _ReplaceItem(full_name.c_str(),node->Level,new_text.c_str(),new_full_name,'\\');
		        if (full_name!=new_full_name)
        	        OnRename(full_name.c_str(),new_full_name.c_str(),TYPE_OBJECT);
            }
        }
        AnsiString new_full_name;
        MakeName(node,0,full_name,true);
        _ReplaceItem(full_name.c_str(),node->Level,new_text.c_str(),new_full_name,'\\');
        if (full_name!=new_full_name)
			OnRename(full_name.c_str(),new_full_name.c_str(),TYPE_FOLDER);
    }else if (IsObject(node)){
    	// is object - rename only this item
        MakeName(node,0,full_name,false);
        VERIFY(node->Level<_GetItemCount(full_name.c_str(),'\\'));
        AnsiString new_full_name;
        _ReplaceItem(full_name.c_str(),node->Level,new_text.c_str(),new_full_name,'\\');
        if (full_name!=new_full_name)
			OnRename(full_name.c_str(),new_full_name.c_str(),TYPE_OBJECT);
    }
    tv->Selected=node;
    return true;
}
Ejemplo n.º 2
0
void __fastcall TItemList::InplaceEditValidateResult(
      TObject *Sender, bool &InputValid)
{
	R_ASSERT(m_Flags.is(ilEditMenu));
	TElTreeInplaceAdvancedEdit* IE	= InplaceEdit;
    AnsiString new_text 			= AnsiString(IE->Editor->Text).LowerCase();
    InputValid						= false;
    if (!new_text.IsEmpty()){
	    IE->Editor->Text 			= new_text;
		AnsiString old_name, new_name;
		FHelper.MakeName			(IE->Item,0,old_name,false);
	    _ReplaceItem				(old_name.c_str(),IE->Item->Level,new_text.c_str(),new_name,'\\');
	    TElTreeItem* find_item		= FHelper.FindItem(tvItems,new_name);
    	InputValid 					= (find_item==IE->Item)||(!find_item);//.(!find_item); нужно для того чтобы принимало 
    }
}
Ejemplo n.º 3
0
bool
BListView::DoMiscellaneous(MiscCode code, MiscData* data)
{
	if (code > B_SWAP_OP)
		return false;

	switch (code) {
		case B_NO_OP:
			break;

		case B_REPLACE_OP:
			return _ReplaceItem(data->replace.index, data->replace.item);

		case B_MOVE_OP:
			return _MoveItem(data->move.from, data->move.to);

		case B_SWAP_OP:
			return _SwapItems(data->swap.a, data->swap.b);
	}

	return false;
}
Ejemplo n.º 4
0
bool CFolderHelper::NameAfterEdit(TElTreeItem* node, AnsiString value, AnsiString& N)
{
	VERIFY(node);
	N=N.LowerCase();
    if (N.IsEmpty()){ N=value; return false; }
	int cnt=_GetItemCount(N.c_str(),'\\');
    if (cnt>1)		{ N=value; return false; }
    VERIFY(node);

    for (TElTreeItem* itm=node->GetFirstSibling(); itm; itm=itm->GetNextSibling()){
        if ((itm->Text==N)&&(itm!=node)){
	        N=value;
            return false;
        }
    }
    // all right
    node->Text=N;
	cnt=_GetItemCount(value.c_str(),'\\');
    AnsiString new_name;
	_ReplaceItem(value.c_str(),cnt-1,N.c_str(),new_name,'\\');
    N=new_name;
    return true;
}
Ejemplo n.º 5
0
AnsiString CFolderHelper::ReplacePart(AnsiString old_name, AnsiString ren_part, int level, LPSTR dest)
{
    VERIFY(level<_GetItemCount(old_name.c_str(),'\\'));
    _ReplaceItem(old_name.c_str(),level,ren_part.c_str(),dest,'\\');
    return dest;
}