Ejemplo n.º 1
0
void BaseTreeBranch::updateOpenFolder()
{
  KFileTreeViewItem *newItem;
  KFileTreeViewItem *item = root();
  while (item) {
    if (item->isDir() && item->isOpen()) {
      updateDirectory( item->url() );
      kapp->processEvents(QEventLoop::ExcludeUserInput | QEventLoop::ExcludeSocketNotifiers);
      // dive into the tree first
      newItem = dynamic_cast<KFileTreeViewItem *>(item->firstChild());
      if (newItem) {
        // found child go ahead
        item = newItem;
        continue;
      };
    };
    // go up if no sibling available
    if (! item->nextSibling())
      item = dynamic_cast<KFileTreeViewItem *>(item->parent());
    if (item == root())
      break;
    if (item)
      item = dynamic_cast<KFileTreeViewItem *>(item->nextSibling());
  };
}
Ejemplo n.º 2
0
void BaseTreeBranch::addOpenFolder(QStringList* openFolder)
{
  if (! openFolder)  // just in case
    return;
  KFileTreeViewItem *newItem;
  KFileTreeViewItem *item = root();
  while (item) {
    if (item->isDir() && item->isOpen()) {
      openFolder->append( item->url().url() );
      // dive into the tree first
      newItem = dynamic_cast<KFileTreeViewItem *>(item->firstChild());
      if (newItem) {
        // found child go ahead
        item = newItem;
        continue;
      };
    };
    // move up in the tree
    while (item && item != root())
    {
      if (item->nextSibling())
      {
        item = dynamic_cast<KFileTreeViewItem *>(item->nextSibling());
        break;
      }
      else
      {
        item = dynamic_cast<KFileTreeViewItem *>(item->parent());
      }
    }
    if (item == root())
      break;
  };
}
Ejemplo n.º 3
0
/*
 * The signal that tells that a directory was deleted may arrive before the signal
 * for its children arrive. Thus, we must walk through the children of a dir and
 * remove them before removing the dir itself.
 */
void KFileTreeBranch::slotDeleteItem( KFileItem *it )
{
    if( !it ) return;
    kdDebug(250) << "Slot Delete Item hitted for " << it->url().prettyURL() << endl;

    KFileTreeViewItem *kfti = static_cast<KFileTreeViewItem*>(it->extraData(this));

    if( kfti )
    {
        kdDebug( 250 ) << "Child count: " << kfti->childCount() << endl;
        if( kfti->childCount() > 0 )
        {
            KFileTreeViewItem *child = static_cast<KFileTreeViewItem*>(kfti->firstChild());

            while( child )
            {
                kdDebug(250) << "Calling child to be deleted !" << endl;
                KFileTreeViewItem *nextChild = static_cast<KFileTreeViewItem*>(child->nextSibling());
                slotDeleteItem( child->fileItem());
                child = nextChild;
            }
        }

        kdDebug(250) << "Found corresponding KFileTreeViewItem" << endl;
        if( m_lastFoundURL.equals(it->url(), true ))
        {
          m_lastFoundURL = KURL();
          m_lastFoundItem = 0L;
        }
        delete( kfti );
    }
    else
    {
        kdDebug(250) << "Error: tdefiletreeviewitem: "<< kfti << endl;
    }
}