Logo Search packages:      
Sourcecode: k4dirstat version File versions  Download package

void KDirTreeView::deleteChild ( KFileInfo newChild ) [protected, slot]

Delete a cloned child.

The selected item is about to be deleted. Select some other item so there is still something selected: Preferably the next item or the parent if there is no next. This cannot be done from outside because the order of items is not known to the outside; it might appear very random if the next item in the KFileInfo list would be selected. The order of that list is definitely different than the order of this view - which is what the user sees. So let's give the user a reasonable next selection so he can continue working without having to explicitly select another item.

This is very useful if the user just activated a cleanup action that deleted an item: It makes sense to implicitly select the next item so he can clean up many items in a row.

Definition at line 409 of file kdirtreeview.cpp.

References locate(), KDirStat::KDirTreeViewItem::next(), KDirStat::KDirTreeViewItem::parent(), selectItem(), and KDirStat::KDirTreeViewItem::updateSummary().

Referenced by createTree().

{
    KDirTreeViewItem *clone = locate( child,
                              false,      // lazy
                              false );    // doClone
    KDirTreeViewItem *nextSelection = 0;

    if ( clone )
    {
      if ( clone == _selection )
      {
          /**
           * The selected item is about to be deleted. Select some other item
           * so there is still something selected: Preferably the next item
           * or the parent if there is no next. This cannot be done from
           * outside because the order of items is not known to the outside;
           * it might appear very random if the next item in the KFileInfo
           * list would be selected. The order of that list is definitely
           * different than the order of this view - which is what the user
           * sees. So let's give the user a reasonable next selection so he
           * can continue working without having to explicitly select another
           * item.
           *
           * This is very useful if the user just activated a cleanup action
           * that deleted an item: It makes sense to implicitly select the
           * next item so he can clean up many items in a row.
           **/

          nextSelection = clone->next() ? clone->next() : clone->parent();
          // kdDebug() << k_funcinfo << " Next selection: " << nextSelection << endl;
      }

      KDirTreeViewItem *parent = clone->parent();
      delete clone;

      while ( parent )
      {
          parent->updateSummary();
          parent = parent->parent();
      }

      if ( nextSelection )
          selectItem( nextSelection );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index