Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes

QmitkInfoDialog Class Reference

#include <QmitkInfoDialog.h>

List of all members.

Public Slots

void OnSelectionChanged (const mitk::DataNode *)
void OnSearchButtonClicked (bool checked=false)
void OnCancelButtonClicked (bool checked=false)
void KeyWordTextChanged (const QString &text)

Public Member Functions

 QmitkInfoDialog (std::vector< mitk::DataNode * > _Nodes, QWidget *parent=0, Qt::WindowFlags f=0)

Protected Member Functions

bool eventFilter (QObject *obj, QEvent *event)

Protected Attributes

QLineEdit * m_KeyWord
QPushButton * m_SearchButton
QTextBrowser * m_TextBrowser

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 37 of file QmitkInfoDialog.h.


Constructor & Destructor Documentation

QmitkInfoDialog::QmitkInfoDialog ( std::vector< mitk::DataNode * >  _Nodes,
QWidget *  parent = 0,
Qt::WindowFlags  f = 0 
)

Definition at line 31 of file QmitkInfoDialog.cpp.

References QmitkDataStorageComboBox::AddNode(), KeyWordTextChanged(), m_KeyWord, m_SearchButton, m_TextBrowser, OnCancelButtonClicked(), OnSearchButtonClicked(), and OnSelectionChanged().

: QDialog(parent, f)
{
  // DIM
  QGridLayout* parentLayout = new QGridLayout;
  QmitkDataStorageComboBox* _QmitkDataStorageComboBox = new QmitkDataStorageComboBox(this, true);
  m_KeyWord = new QLineEdit;
  m_KeyWord->installEventFilter(this);
  m_SearchButton = new QPushButton("Search (F3)", this);
  m_SearchButton->installEventFilter(this);
  m_TextBrowser = new QTextBrowser(this);
  QPushButton* _CancelButton = new QPushButton("Cancel", this);

  // SET
  this->setMinimumSize(512, 512);
  this->setLayout(parentLayout);
  this->setSizeGripEnabled(true);
  this->setModal(true);
  
  parentLayout->addWidget(_QmitkDataStorageComboBox, 0, 0, 1, 2);
  parentLayout->addWidget(m_KeyWord, 1, 0);
  parentLayout->addWidget(m_SearchButton, 1, 1);
  parentLayout->addWidget(m_TextBrowser, 2, 0, 1, 2);
  parentLayout->addWidget(_CancelButton, 3, 0, 1, 2);

  QObject::connect( _QmitkDataStorageComboBox, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) )
    , this, SLOT( OnSelectionChanged( const mitk::DataNode* ) ) );

  for (std::vector<mitk::DataNode*>::iterator it = _Nodes.begin()
    ; it != _Nodes.end(); it++)
  {
    _QmitkDataStorageComboBox->AddNode(*it);
  }

  QObject::connect( m_KeyWord, SIGNAL( textChanged ( const QString & )  )
    , this, SLOT( KeyWordTextChanged(const QString &) ) );

  QObject::connect( m_SearchButton, SIGNAL( clicked ( bool ) )
    , this, SLOT( OnSearchButtonClicked( bool ) ) );

  QObject::connect( _CancelButton, SIGNAL( clicked ( bool ) )
    , this, SLOT( OnCancelButtonClicked( bool ) ) );

  _CancelButton->setDefault(true);
  
}

Member Function Documentation

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

Definition at line 105 of file QmitkInfoDialog.cpp.

References mitk::Key_F3, mitk::Key_Return, and OnSearchButtonClicked().

{
  if (event->type() == QEvent::KeyPress) 
  {
    QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
    if(keyEvent->key() == Qt::Key_F3  || keyEvent->key() == Qt::Key_Return)
    {
      // trigger deletion of selected node(s)
      this->OnSearchButtonClicked(true);
      // return true: this means the delete key event is not send to the table
      return true;
    }
  }
  // standard event processing
  return QObject::eventFilter(obj, event);
}
void QmitkInfoDialog::KeyWordTextChanged ( const QString &  text ) [slot]

Definition at line 122 of file QmitkInfoDialog.cpp.

References m_SearchButton, and m_TextBrowser.

Referenced by QmitkInfoDialog().

{
  QTextCursor textCursor = m_TextBrowser->textCursor();
  textCursor.setPosition(0);
  m_TextBrowser->setTextCursor(textCursor);
  m_SearchButton->setText("Search (F3)");
}
void QmitkInfoDialog::OnCancelButtonClicked ( bool  checked = false ) [slot]

Definition at line 100 of file QmitkInfoDialog.cpp.

Referenced by QmitkInfoDialog().

{
  this->done(0);
}
void QmitkInfoDialog::OnSearchButtonClicked ( bool  checked = false ) [slot]

Definition at line 88 of file QmitkInfoDialog.cpp.

References m_KeyWord, m_SearchButton, and m_TextBrowser.

Referenced by eventFilter(), and QmitkInfoDialog().

{
  QString keyWord = m_KeyWord->text();
  QString text = m_TextBrowser->toPlainText();
  
  if(keyWord.isEmpty() || text.isEmpty())
    return;

  m_TextBrowser->find(keyWord);
  m_SearchButton->setText("Search Next(F3)");
}
void QmitkInfoDialog::OnSelectionChanged ( const mitk::DataNode node ) [slot]

Definition at line 78 of file QmitkInfoDialog.cpp.

References mitk::DataNode::GetData(), and m_TextBrowser.

Referenced by QmitkInfoDialog().

{
  std::ostringstream s;
  itk::Indent i(2);
  mitk::BaseData* _BaseData = node->GetData();
  if(_BaseData)
    _BaseData->Print(s, i);
  m_TextBrowser->setPlainText(QString::fromStdString(s.str()));
}

Member Data Documentation

QLineEdit* QmitkInfoDialog::m_KeyWord [protected]

Definition at line 51 of file QmitkInfoDialog.h.

Referenced by OnSearchButtonClicked(), and QmitkInfoDialog().

QPushButton* QmitkInfoDialog::m_SearchButton [protected]

Definition at line 52 of file QmitkInfoDialog.h.

Referenced by KeyWordTextChanged(), OnSearchButtonClicked(), and QmitkInfoDialog().

QTextBrowser* QmitkInfoDialog::m_TextBrowser [protected]

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