Back to index

salome-gui  6.5.0
Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes
SalomeApp_ListView Class Reference

parent class for Data Viewer and Properties Viewer More...

#include <SalomeApp_ListView.h>

Inheritance diagram for SalomeApp_ListView:
Inheritance graph
[legend]
Collaboration diagram for SalomeApp_ListView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SalomeApp_ListView (QWidget *parent)
 Constructor.
virtual ~SalomeApp_ListView ()
 Destructor.
virtual void updateViewer ()
 Updates all data viewer.
virtual void updateSelected ()
 Updates currently selected item(s)
virtual QString popupClientType () const
 Returns popup client type.
virtual void contextMenuPopup (QMenu *)
 Fills popup menu with items.
void enableEditing (bool theFlag)
 Setting editing of items availbale/not available.
bool isEnableEditing ()
 Says if editing is enabled.
void accept ()
 Calls finishEditing(true)...
void clear ()
 Clears view.
bool eventFilter (QObject *object, QEvent *event)
 Event filter.
QRect tip (QPoint aPos, QString &aText, QRect &dspRect, QFont &dspFnt) const

Protected Slots

virtual void onSelectionChanged ()
 Slot, called when selection changed in List Viewer.
void onEditOk ()
 Called when user finishes in editing of item.
void onEditCancel ()
 Called when user cancels item editing.
void onHeaderSizeChange (int, int, int)
 Slot, called when columns sizes are changed.

Protected Member Functions

void resizeEvent (QResizeEvent *e)
 Called when Data Viewer is resized.
void viewportPaintEvent (QPaintEvent *e)
 Handler for paint event.
virtual UpdateType finishEditing (bool ok)
 Finishes editing of entity.
bool isMouseEnabled ()
void enableMouse (bool enable)
 Enables/disables mouse events (excluding MouseMove)

Protected Attributes

SalomeApp_EntityEditmyEdit
SalomeApp_ListViewItemmyEditedItem
bool myEditingEnabled
bool myMouseEnabled

Detailed Description

parent class for Data Viewer and Properties Viewer

Definition at line 61 of file SalomeApp_ListView.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 76 of file SalomeApp_ListView.cxx.

  : QTreeWidget/*QtxListView*/( parent )
{
  myMouseEnabled = true;
  myEditingEnabled = false;
  setSelectionMode(QAbstractItemView::SingleSelection);
  setRootIsDecorated(false);
  setAllColumnsShowFocus(false);
//  header()->setClickEnabled(false);
  header()->setMovable(false);

  myEditedItem = 0;
  myEdit = 0;

  viewport()->installEventFilter(this);

  connect(this, SIGNAL(itemSelectionChanged()),
          this, SLOT(onSelectionChanged()));
  connect(header(), SIGNAL(sizeChange(int, int, int)),
          this,     SLOT(onHeaderSizeChange(int, int, int)));
}

Here is the call graph for this function:

Destructor.

Definition at line 101 of file SalomeApp_ListView.cxx.

{
  if (myEdit) {
    delete myEdit;
  }
  myEdit = 0;
  myEditedItem = 0;
}

Member Function Documentation

Calls finishEditing(true)...

Definition at line 231 of file SalomeApp_ListView.cxx.

{
  finishEditing(true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Clears view.

Definition at line 164 of file SalomeApp_ListView.cxx.

{
  if (myEdit) {
    delete myEdit;
    myEdit = 0;
    myEditedItem = 0;
  }
  QTreeWidget::clear();
}
void SalomeApp_ListView::contextMenuPopup ( QMenu *  aPopup) [virtual]

Fills popup menu with items.

Definition at line 154 of file SalomeApp_ListView.cxx.

{
  if (aPopup) {
    // add items here...
  }
}

Setting editing of items availbale/not available.

Definition at line 208 of file SalomeApp_ListView.cxx.

{
  myEditingEnabled = theFlag;
  if (!myEditingEnabled) {
    if (myEdit) {
      delete myEdit;
      myEdit = 0;
      myEditedItem = 0;
    }
  }
}
void SalomeApp_ListView::enableMouse ( bool  enable) [protected]

Enables/disables mouse events (excluding MouseMove)

Definition at line 185 of file SalomeApp_ListView.cxx.

{
  myMouseEnabled = enable;
}
bool SalomeApp_ListView::eventFilter ( QObject object,
QEvent *  event 
)

Event filter.

Definition at line 193 of file SalomeApp_ListView.cxx.

{
  if (object == viewport() &&
       (event->type() == QEvent::MouseButtonPress   ||
        event->type() == QEvent::MouseButtonRelease ||
        event->type() == QEvent::MouseButtonDblClick)  &&
      !isMouseEnabled())
    return true;
  else
    return QTreeWidget::eventFilter(object, event);
}

Here is the call graph for this function:

UpdateType SalomeApp_ListView::finishEditing ( bool  ok) [protected, virtual]

Finishes editing of entity.

Definition at line 323 of file SalomeApp_ListView.cxx.

{
  UpdateType aNeedsUpdate = utCancel;
  if (myEditedItem && myEdit)
  {
    disconnect(myEdit, SIGNAL(returnPressed()), this, SLOT(onEditOk()));
    disconnect(myEdit, SIGNAL(escapePressed()), this, SLOT(onEditCancel()));
    myEditedItem->setAccepted(true);
    if (ok) {
      aNeedsUpdate = myEditedItem->finishEditing(myEdit);
      if (aNeedsUpdate == utCancel) {
        // something to do here on Cancel...
      }
      else {
        // something to do here on OK...
      }
      // updating contents
      switch (aNeedsUpdate) {
      case utUpdateItem:
        {
          if (myEditedItem)
            myEditedItem->updateAllLevels();
          break;
        }
      case utUpdateParent:
        {
          if (myEditedItem) {
            SalomeApp_ListViewItem* aParent = (SalomeApp_ListViewItem*)(myEditedItem->parent());
            if (aParent)
              aParent->updateAllLevels();
            else
              myEditedItem->updateAllLevels();
          }
          break;
        }
      case utUpdateViewer:
        {
          updateViewer();
          break;
        }
      case utUpdateAll:
        {
          // doing the same as for utUpdateViewer here
          // descendants can add extra processing
          updateViewer();
          break;
        }
      default:
        break;
      }
    }
  }

  // hide <myEdit> widget
  if (myEdit) {
    myEdit->hide();
  }

  return aNeedsUpdate;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Says if editing is enabled.

Definition at line 223 of file SalomeApp_ListView.cxx.

{
  return myEditingEnabled;
}

Here is the caller graph for this function:

bool SalomeApp_ListView::isMouseEnabled ( ) [protected]
Returns:
true if mouse events are enabled

Definition at line 177 of file SalomeApp_ListView.cxx.

{
  return myMouseEnabled;
}

Here is the caller graph for this function:

void SalomeApp_ListView::onEditCancel ( ) [protected, slot]

Called when user cancels item editing.

Definition at line 315 of file SalomeApp_ListView.cxx.

{
  finishEditing(false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SalomeApp_ListView::onEditOk ( ) [protected, slot]

Called when user finishes in editing of item.

Definition at line 307 of file SalomeApp_ListView.cxx.

{
  finishEditing(true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SalomeApp_ListView::onHeaderSizeChange ( int  ,
int  ,
int   
) [protected, slot]

Slot, called when columns sizes are changed.

Definition at line 285 of file SalomeApp_ListView.cxx.

{
  int aW = columnWidth(columnCount()-1);
  int aX = header()->sectionPosition(columnCount()-1);
  if (aW < width() - frameWidth() * 2 - aX - 1)
    setColumnWidth(columnCount()-1, width() - frameWidth() * 2 - aX - 1);
}

Here is the caller graph for this function:

void SalomeApp_ListView::onSelectionChanged ( ) [protected, virtual, slot]

Slot, called when selection changed in List Viewer.

Definition at line 239 of file SalomeApp_ListView.cxx.

{
  if (myEdit) {
    finishEditing(true);
    delete myEdit;
    myEdit = 0;
    if (myEditedItem && !myEditedItem->isAccepted()) {
      delete myEditedItem;
      update( contentsRect() );//updateContents();
    }
    myEditedItem = 0;
  }
  // editing is allowed in Single Selection Mode only
  if (selectionMode() != QAbstractItemView::SingleSelection || !isEnableEditing())
    return;
  SalomeApp_ListViewItem* anItem = (SalomeApp_ListViewItem*)(selectedItems().first());
  if (anItem) {
    if (!anItem->isEditable())
      return;
    myEdit = anItem->startEditing();
    if (myEdit) {
      connect(myEdit, SIGNAL(returnPressed()), this, SLOT(onEditOk()));
      connect(myEdit, SIGNAL(escapePressed()), this, SLOT(onEditCancel()));
      myEditedItem = anItem;
      myEdit->show();
      myEdit->setFocus();
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

QString SalomeApp_ListView::popupClientType ( ) const [virtual]

Returns popup client type.

Definition at line 146 of file SalomeApp_ListView.cxx.

{
  return "SalomeApp_ListView";
}
void SalomeApp_ListView::resizeEvent ( QResizeEvent *  e) [protected]

Called when Data Viewer is resized.

Definition at line 272 of file SalomeApp_ListView.cxx.

{
  QTreeWidget::resizeEvent(e);
  int aW = columnWidth(columnCount()-1);
  int aX = header()->sectionPosition(columnCount()-1);
  if (aW < width() - frameWidth() * 2 - aX - 1)
    setColumnWidth(columnCount()-1, width() - frameWidth() * 2 - aX - 1);
  update( contentsRect() );//updateContents();
}
QRect SalomeApp_ListView::tip ( QPoint  aPos,
QString &  aText,
QRect &  dspRect,
QFont &  dspFnt 
) const
Returns:
current tooltip for list view
Return values:
validrect in success

Definition at line 388 of file SalomeApp_ListView.cxx.

{
  QRect result( -1, -1, -1, -1 );
  SalomeApp_ListViewItem* aItem = (SalomeApp_ListViewItem*)itemAt( aPos );
  if ( aItem ) {
    for (int i = 0; i < columnCount(); i++) {
      QRect aItemRect = aItem->itemRect(i);
      QRect aTextRect = aItem->textRect(i);
      if ( !aItem->text(i).isEmpty() &&
           ( aItemRect.width()  > header()->sectionSize(i) ||
             aTextRect.left()   < 0 ||
             aTextRect.top()    < 0 ||
             aTextRect.right()  > viewport()->width() ||
             aTextRect.bottom() > viewport()->height() ) ) {
        // calculating tip data
        aText   = aItem->tipText();
        dspRect = aItem->tipRect();
        dspFnt  = font();
        if (dspRect.isValid()) {
          result  = QRect(QPoint(0, aItemRect.top()),
                          QSize(viewport()->width(), aItemRect.height()));
        }
      }
    }
  }
  return result;
}

Here is the call graph for this function:

Updates currently selected item(s)

Definition at line 130 of file SalomeApp_ListView.cxx.

{
  // temporary disconnecting selection changed SIGNAL
  blockSignals(true);
  SalomeApp_ListViewItem* aChild = (SalomeApp_ListViewItem*)(selectedItems().first());
  if (aChild)
    aChild->updateAllLevels();
  update( contentsRect() );//updateContents();
  // connecting again selection changed SIGNAL
  blockSignals(false);
  emit itemSelectionChanged();
}

Here is the call graph for this function:

Updates all data viewer.

Definition at line 113 of file SalomeApp_ListView.cxx.

{
  // temporary disconnecting selection changed SIGNAL
  blockSignals(true);
  QTreeWidgetItemIterator it( this );
  SalomeApp_ListViewItem* aRoot = (SalomeApp_ListViewItem*)(*it);
  if (aRoot)
    aRoot->updateAllLevels();
  update( contentsRect() );//updateContents();
  // connecting again selection changed SIGNAL
  blockSignals(false);
  emit itemSelectionChanged();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SalomeApp_ListView::viewportPaintEvent ( QPaintEvent *  e) [protected]

Handler for paint event.

Definition at line 296 of file SalomeApp_ListView.cxx.

{
  QTreeWidget::paintEvent(e);
  if (myEditedItem && myEdit) {
    computeEditGeometry(myEditedItem, myEdit);
  }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 121 of file SalomeApp_ListView.h.

Definition at line 122 of file SalomeApp_ListView.h.

Definition at line 123 of file SalomeApp_ListView.h.

Definition at line 124 of file SalomeApp_ListView.h.


The documentation for this class was generated from the following files: