{
sel.push_back(GetTreeHandler()->GetTree().GetTree());
}
- else
- {
- int n = GetCtrl(l-1)->GetItemCount();
- for (int i = 0; i < n; i++)
- {
- if ( GetCtrl(l-1)->GetItemState(i,wxLIST_STATE_SELECTED))
- {
- long adr = GetCtrl(l-1)->GetItemData(i);
- tree::Node* n = ((ItemData*)adr)->node;
- if(mLastSelected==i)
- {
- std::vector<tree::Node*>::iterator it;
- it = sel.begin();
- it = sel.insert ( it , n );
- }
- else
+ else if (level < 5)
+ {
+ int n = GetCtrl(l-1)->GetItemCount();
+ for (int i = 0; i < n; i++)
+ {
+ if ( GetCtrl(l-1)->GetItemState(i,wxLIST_STATE_SELECTED))
{
- sel.push_back(n);
+ long adr = GetCtrl(l-1)->GetItemData(i);
+ tree::Node* n = ((ItemData*)adr)->node;
+ if(mLastSelected==i)
+ {
+ std::vector<tree::Node*>::iterator it;
+ it = sel.begin();
+ it = sel.insert ( it , n );
+ }
+ else
+ {
+ sel.push_back(n);
+ }
}
}
- }
- }
+ }
+ else
+ {
+ // NOTHING
+ }
+
+
// return mLevelList[level-1].Selected;
return sel;
// NOT SPECIFIC
void WxTreeView::RemoveSelected()
{
+ unsigned int tempLevel = mLastLevel;
mLastLevel+=1;
const std::vector<tree::Node*>& sel=GetSelected(mLastLevel+1);
- bool erase=false;
- std::stringstream out;
- std::string levelName=GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName();
- out<<"Delete ";
- out<<sel.size();
- if(sel.size()>1&&levelName.at(levelName.size()-1)!='s')
- {
- out<<" "<<levelName;
- out<<"s?";
- }
- else
- {
- out<<" "<<GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName()<<"?";
- }
- if (wxMessageBox(crea::std2wx(out.str()),
- _T("Remove Files"),
- wxYES_NO,this ) == wxYES)
- {
- erase = true;
- }
- if(erase)
- {
- bool needRefresh=false;
- std::vector<tree::Node*>::const_iterator i;
- for (i=sel.begin(); i!=sel.end(); ++i)
- {
- GimmickMessage(1,
- "deleting '"
- <<(*i)->GetLabel()
- <<"'"<<mLastLevel
- <<std::endl);
- if((*i)->GetParent()->GetNumberOfChildren()<2)
- {
- needRefresh=true;
- }
- GetTreeHandler()->Remove(*i);
- }
-
- if(needRefresh && mLastLevel>1)
+ // if no selection, no remove action.
+ if(sel.size() != 0)
+ {
+ bool erase=false;
+ std::stringstream out;
+ std::string levelName=GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName();
+ out<<"Delete ";
+ out<<sel.size();
+ if(sel.size()>1&&levelName.at(levelName.size()-1)!='s')
{
- UpdateLevel(mLastLevel-2);
+ out<<" "<<levelName;
+ out<<"s?";
}
- else if(mLastLevel>1)
+ else
{
- UpdateLevel(mLastLevel-1);
+ out<<" "<<GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName()<<"?";
}
- else
+ if (wxMessageBox(crea::std2wx(out.str()),
+ _T("Remove Files"),
+ wxYES_NO,this ) == wxYES)
{
- UpdateLevel(mLastLevel);
+ erase = true;
}
- }
+ if(erase)
+ {
+ bool needRefresh=false;
+ std::vector<tree::Node*>::const_iterator i;
+ for (i=sel.begin(); i!=sel.end(); ++i)
+ {
+ GimmickMessage(1,
+ "deleting '"
+ <<(*i)->GetLabel()
+ <<"'"<<mLastLevel
+ <<std::endl);
+ if((*i)->GetParent()->GetNumberOfChildren()<2)
+ {
+ needRefresh=true;
+ }
+ GetTreeHandler()->Remove(*i);
+ }
+
+ if(needRefresh && mLastLevel>1)
+ {
+ UpdateLevel(mLastLevel-2);
+ }
+ else if(mLastLevel>1)
+ {
+ UpdateLevel(mLastLevel-1);
+ }
+ else
+ {
+ UpdateLevel(mLastLevel);
+ }
+ }
+ }
+ else
+ {
+ // no need to incremente level
+ mLastLevel = tempLevel;
+ }
}
for (i=sel.begin(); i!=sel.end(); ++i)
{
- GimmickDebugMessage(2,
+ GimmickDebugMessage(1,
"adding children of '"
<<(*i)->GetLabel()
<<"'"
<<std::endl);
- int _id=1;
+ int _id=0;
//Adds items and sets their attributes
- //GetCtrl(l)->InsertItem(0, _T(""));
+
GetTreeHandler()->LoadChildren(*i,1);
tree::Node::ChildrenListType::reverse_iterator j;
for (j = (*i)->GetChildrenList().rbegin();
j!= (*i)->GetChildrenList().rend();
++j)
{
- wxListItem* item= new wxListItem;
- item->SetMask(wxLIST_MASK_STATE |
- wxLIST_MASK_TEXT |
- // wxLIST_MASK_IMAGE |
- wxLIST_MASK_DATA |
- // wxLIST_MASK_WIDTH |
- wxLIST_MASK_FORMAT
- );
-
- ItemData* data = new ItemData;
-
- data->node = *j;
- item->SetId(_id);
-
- data->id = _id;
- item->SetData(data);
-
- _id++;
- GetCtrl(l)->InsertItem(*item);
-
- //Setting attributes
-
- for (int k=0; k<GetCtrl(l)->GetColumnCount(); k++)
- {
- std::string val = (*j)->GetAttribute(mLevelList[l].key[k]);
- if (val.size()==0) val = "?";
- item->SetText( crea::std2wx(val));
- item->SetColumn(k);
- GetCtrl(l)->SetItem(*item);
- }
-
- }
- //GetCtrl(l)->DeleteItem(0);
+ GimmickDebugMessage(1,
+ "adding children "
+ <<(*j)->GetLabel()
+ <<"'"
+ <<std::endl);
+
+ wxListItem item;
+ item.SetMask(wxLIST_MASK_STATE |
+ wxLIST_MASK_TEXT |
+ // wxLIST_MASK_IMAGE |
+ wxLIST_MASK_DATA |
+ // wxLIST_MASK_WIDTH |
+ wxLIST_MASK_FORMAT
+ );
+
+ ItemData* data = new ItemData;
+ data->node = *j;
+ data->id = _id;
+
+ item.SetId(_id);
+ item.SetData(data);
+
+ _id++;
+ GetCtrl(l)->InsertItem(item);
+
+ //Setting attributes
+
+ for (int k=0; k<GetCtrl(l)->GetColumnCount(); k++)
+ {
+ std::string val = (*j)->GetAttribute(mLevelList[l].key[k]);
+ if (val.size()==0) val = "?";
+ item.SetText( crea::std2wx(val));
+ item.SetColumn(k);
+ GetCtrl(l)->SetItem(item);
+ }
+
+ }
}
-
SortLevel(l);
GetCtrl(l)->Show();
-
-
-
}
//=====================================================================