Public Member Functions | Protected Member Functions | Protected Attributes

QmitkNodeTableViewKeyFilter Class Reference

#include <QmitkNodeTableViewKeyFilter.h>

List of all members.

Public Member Functions

 QmitkNodeTableViewKeyFilter (QObject *_DataManagerView=0)

Protected Member Functions

bool eventFilter (QObject *obj, QEvent *event)

Protected Attributes

berry::IPreferencesService::WeakPtr m_PreferencesService

Detailed Description

A small class which "eats" all Del-Key-pressed events on the node table. When the Del Key is pressed selected nodes should be removed.

Definition at line 29 of file QmitkNodeTableViewKeyFilter.h.


Constructor & Destructor Documentation

QmitkNodeTableViewKeyFilter::QmitkNodeTableViewKeyFilter ( QObject *  _DataManagerView = 0 )

Member Function Documentation

bool QmitkNodeTableViewKeyFilter::eventFilter ( QObject *  obj,
QEvent *  event 
) [protected]

Definition at line 31 of file QmitkNodeTableViewKeyFilter.cpp.

References QmitkDataManagerView::GlobalReinit(), QmitkDataManagerView::Load(), berry::WeakPointer< TObjectType >::Lock(), m_PreferencesService, QmitkDataManagerView::MakeAllNodesInvisible(), QmitkDataManagerView::ReinitSelectedNodes(), QmitkDataManagerView::RemoveSelectedNodes(), QmitkDataManagerView::SaveSelectedNodes(), QmitkDataManagerView::ShowInfoDialogForSelectedNodes(), and QmitkDataManagerView::ToggleVisibilityOfSelectedNodes().

{
  QmitkDataManagerView* _DataManagerView = qobject_cast<QmitkDataManagerView*>(this->parent());
  if (event->type() == QEvent::KeyPress && _DataManagerView) 
  {
    berry::IPreferencesService::Pointer prefService = m_PreferencesService.Lock();
    berry::IPreferences::Pointer nodeTableKeyPrefs = prefService->GetSystemPreferences()->Node("/DataManager/Hotkeys");

    QKeySequence _MakeAllInvisible = QKeySequence(QString::fromStdString(nodeTableKeyPrefs->Get("Make all nodes invisible", "Ctrl+, V")));
    QKeySequence _ToggleVisibility = QKeySequence(QString::fromStdString(nodeTableKeyPrefs->Get("Toggle visibility of selected nodes", "V")));
    QKeySequence _DeleteSelectedNodes = QKeySequence(QString::fromStdString(nodeTableKeyPrefs->Get("Delete selected nodes", "Del")));
    QKeySequence _Reinit = QKeySequence(QString::fromStdString(nodeTableKeyPrefs->Get("Reinit selected nodes", "R")));
    QKeySequence _GlobalReinit = QKeySequence(QString::fromStdString(nodeTableKeyPrefs->Get("Global Reinit", "Ctrl+, R")));
    QKeySequence _Save = QKeySequence(QString::fromStdString(nodeTableKeyPrefs->Get("Save selected nodes", "Ctrl+, S")));
    QKeySequence _Load = QKeySequence(QString::fromStdString(nodeTableKeyPrefs->Get("Load", "Ctrl+, L")));
    QKeySequence _ShowInfo = QKeySequence(QString::fromStdString(nodeTableKeyPrefs->Get("Show Node Information", "Ctrl+, I")));

    QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);

    QKeySequence _KeySequence = QKeySequence(keyEvent->modifiers(), keyEvent->key());
    // if no modifier was pressed the sequence is now empty
    if(_KeySequence.isEmpty())
      _KeySequence = QKeySequence(keyEvent->key());

    if(_KeySequence == _MakeAllInvisible)
    {
      // trigger deletion of selected node(s)
      _DataManagerView->MakeAllNodesInvisible(true);
      // return true: this means the delete key event is not send to the table
      return true;
    }    
    else if(_KeySequence == _DeleteSelectedNodes)
    {
      // trigger deletion of selected node(s)
      _DataManagerView->RemoveSelectedNodes(true);
      // return true: this means the delete key event is not send to the table
      return true;
    }    
    else if(_KeySequence == _ToggleVisibility)
    {
      // trigger deletion of selected node(s)
      _DataManagerView->ToggleVisibilityOfSelectedNodes(true);
      // return true: this means the delete key event is not send to the table
      return true;
    }    
    else if(_KeySequence == _Reinit)
    {
      _DataManagerView->ReinitSelectedNodes(true);
      return true;
    }    
    else if(_KeySequence == _GlobalReinit)
    {
      _DataManagerView->GlobalReinit(true);
      return true;
    }    
    else if(_KeySequence == _Save)
    {
      _DataManagerView->SaveSelectedNodes(true);
      return true;
    }    
    else if(_KeySequence == _Load)
    {
      _DataManagerView->Load(true);
      return true;
    }
    else if(_KeySequence == _ShowInfo)
    {
      _DataManagerView->ShowInfoDialogForSelectedNodes(true);
      return true;
    }
  }
  // standard event processing
  return QObject::eventFilter(obj, event);
}

Member Data Documentation

The Preferences Service to retrieve and store preferences.

Definition at line 40 of file QmitkNodeTableViewKeyFilter.h.

Referenced by eventFilter(), and QmitkNodeTableViewKeyFilter().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines