Logo Search packages:      
Sourcecode: kdbg version File versions

void KTreeView::mousePressEvent ( QMouseEvent *  e  )  [protected, virtual]

Reimplemented for mouse event handling. The mouse press event is first forwarded to the item that has been clicked on (if there is one) by calling KTreeViewItem::mouseEvent. The clicked on item is made the current item.

Definition at line 1663 of file ktreeview.cpp.

References KTreeViewItem::boundingRect(), cellCoords(), collapseSubTree(), KTreeViewItem::expandButtonClicked(), expandSubTree(), indentation(), KTreeViewItem::isExpanded(), itemAt(), KTreeViewItem::mouseEvent(), rightPressed(), scrollVisible(), and setCurrentItem().

    /* first: cancel rubberbanding if it's on */
    if (rubberband_mode)
      // another button was pressed while rubberbanding, stop the move.
      // RB: if we allow other buttons while rubberbanding the tree can expand
      //     while rubberbanding - we then need to recalculate and resize the
      //     rubberband rect and show the new size

    // find out which row has been clicked
    int itemClicked = findRow(e->y());

    // nothing to do if not on valid row
    if (itemClicked < 0)
    KTreeViewItem* item = itemAt(itemClicked);
    if (!item)

    // translate mouse coord to cell coord
    QPoint cellCoord = cellCoords(itemClicked, e->pos());

    // give the item a crack
    if (item->mouseEvent(e, cellCoord))
      return;                       /* event eaten by item */

    // check for rubberbanding
    if (e->button() == MidButton)
      // RB: the MMB is hardcoded to the "rubberband" scroll mode
      if (!rubberband_mode) {

    if (e->button() == RightButton) {
      emit rightPressed(itemClicked, e->pos());
    /* hit test expand button (doesn't set currentItem) */
    else if (item->expandButtonClicked(cellCoord)) {
      if (item->isExpanded()) {
          collapseSubTree(item, true);
      } else {
          expandSubTree(item, true);
          scrollVisible(item, true);      /* make children visible */
    // hit test item
    else if (item->boundingRect(indentation(item)).contains(cellCoord)) {

Generated by  Doxygen 1.6.0   Back to index