Source Code (Use browser search to find items of interest.)

Class Index

kdat'Node (./kdeadmin/kdat/Node.h:34)

class Node : public KTreeViewItem {
    int _type;
protected:
    void insertNode( Node* child );
public:
    enum {
        ArchiveableNodeType,
        ArchiveNodeType,
        BackupProfileNodeType,
        BackupProfileRootNodeType,
        DirectoryNodeType,
        FileNodeType,
        MountedArchiveNodeType,
        MountedTapeDirectoryNodeType,
        MountedTapeFileNodeType,
        NodeType,
        RangeableNodeType,
        RootNodeType,
        SelectableNodeType,
        TapeNodeType,
        TapeDirectoryNodeType,
        TapeDriveNodeType,
        TapeFileNodeType,
        TapeIndexRootNodeType
    };

    /**
     * Create a new tree node.
     *
     * @param type   Should be one of the enums.
     * @param text   Text label for the node.
     * @param pixmap A pixmap to display to the left of the text.
     */
    Node( int type, const char* text, const QPixmap& pixmap );

    /**
     * There must be a virtual destructor in the base class so that all the
     * destructors in the inherited classes get called.
     */
    virtual ~Node();

    /**
     * Get the node's type.
     *
     * @return The type of this node.  This information can be used to safely
     *         downcast a Node pointer.
     */
    int getType();

    /**
     * Determine whether the node is an instance of the given node type.
     *
     * @param type The type to compare against.
     */
    virtual bool isType( int type );

    /**
     * This method is called immediately before the node is to be expanded.
     * This method can be used to fill in the children of this node, or
     * prevent the node from expanding.  The default implementation does
     * nothing.
     *
     * @param expand The method sets this to TRUE to allow the node to be
     *               expanded or FALSE to prevent the node from being expanded.
     */
    virtual void expanding( bool expand=TRUE );

    /**
     * This method is called immediately after the node has been expanded.
     * The default implementation does nothing.
     */
    virtual void expanded();

    /**
     * This method is called immediately after the node has been collapsed.
     * The default implementation does nothing.
     */
    virtual void collapsed();

    /**
     * This method is called immediately after the node has been selected.
     * The default implementation does nothing.
     */
    virtual void selected();

    /**
     * This method is called when the user right-clicks the mouse over the
     * node.
     */
    virtual void popupMenu( const QPoint& );
};


kdat'Node::Node() (./kdeadmin/kdat/Node.cpp:40)

Node::Node( int type, const char* text, const QPixmap& pixmap )
        : KTreeViewItem( text, pixmap ),
          _type( type )
{
}


kdat'Node::~Node() (./kdeadmin/kdat/Node.cpp:46)

Node::~Node()
{
}


kdat'Node::insertNode() (./kdeadmin/kdat/Node.cpp:50)

void Node::insertNode( Node* child )
{
    static Node* lastParent   = 0;
    static uint  lastDirIndex = 0;

    if ( lastParent != this ) {
        // Recompute lastDirIndex.
        for ( lastDirIndex = 0;
              ( lastDirIndex < childCount() ) && ( ((Node*)childAt( lastDirIndex ))->getType() == TapeDirectoryNodeType );
              lastDirIndex++ );
        lastParent = this;
    }

    int min, mid, max, smin, smax;
    if ( ( child->getType() == TapeDirectoryNodeType ) || ( child->getType() == MountedTapeDirectoryNodeType ) ) {
        min = 0;
        max = lastDirIndex - 1;
        lastDirIndex++;
    } else {
        min = lastDirIndex;
        max = childCount() - 1;
    }

    if ( min > max ) min = max;

    smin = min;
    smax = max;
    //printf( "min = %d, max = %d\n", min, max );

    mid = min;
    while ( min < max ) {
        mid = ( max - min ) / 2 + min;
        //mid = ( min + max ) / 2;
        if ( strcmp( child->getText().data(), childAt( mid )->getText().data() ) < 0 ) {
            max = mid - 1;
        } else {
            min = mid + 1;
        }
    }
    
    if ( childCount() ) {
        // KLUDGE!
        mid -= 5;
        if ( mid < smin ) mid = smin;
        if ( ((Node*)childAt( mid ))->getType() != child->getType() ) mid++;
        for ( ; ( mid <= smax ) && ( strcmp( child->getText().data(), childAt( mid )->getText().data() ) > 0 ); mid++ );
        //printf( "index = %d, text = '%s'\n", mid, child->getText().data() );
        insertChild( mid, child );
    } else {
        //printf( "index = %d, text = '%s'\n", 0, child->getText().data() );
        insertChild( 0, child );
    }
}


kdat'Node::getType() (./kdeadmin/kdat/Node.cpp:104)

int Node::getType()
{
    return _type;
}


kdat'Node::isType() (./kdeadmin/kdat/Node.cpp:109)

bool Node::isType( int type )
{
    return type == NodeType;
}


kdat'Node::expanding() (./kdeadmin/kdat/Node.cpp:114)

void Node::expanding( bool expand )
{
    expand = TRUE;
}


kdat'Node::expanded() (./kdeadmin/kdat/Node.cpp:119)

void Node::expanded()
{
}


kdat'Node::collapsed() (./kdeadmin/kdat/Node.cpp:123)

void Node::collapsed()
{
}


kdat'Node::selected() (./kdeadmin/kdat/Node.cpp:127)

void Node::selected()
{
    KDat::getInstance()->hideInfo();
}


kdat'Node::popupMenu() (./kdeadmin/kdat/Node.cpp:132)

void Node::popupMenu( const QPoint& )
{
}