Public Member Functions | Protected Attributes

QmitkInputDevicesPrefPage Class Reference

#include <QmitkInputDevicesPrefPage.h>

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

List of all members.

Public Member Functions

 QmitkInputDevicesPrefPage ()
void Init (berry::IWorkbench::Pointer workbench)
void CreateQtControl (QWidget *widget)
QWidget * GetQtControl () const
virtual bool PerformOk ()
virtual void PerformCancel ()
virtual void Update ()

Protected Attributes

QWidget * m_MainControl
QHash< QCheckBox *, std::string > m_InputDevices
berry::IPreferences::Pointer m_InputDevicesPrefNode

Detailed Description

Definition at line 29 of file QmitkInputDevicesPrefPage.h.


Constructor & Destructor Documentation

QmitkInputDevicesPrefPage::QmitkInputDevicesPrefPage (  )

Default constructor

Definition at line 35 of file QmitkInputDevicesPrefPage.cpp.

References berry::Platform::GetServiceRegistry(), ID, mitk::CoreExtConstants::INPUTDEVICE_PREFERENCES, and m_InputDevicesPrefNode.

: m_MainControl(0)
{
  // gets the old setting of the preferences and loads them into the preference node
  berry::IPreferencesService::Pointer prefService 
    = berry::Platform::GetServiceRegistry()
    .GetServiceById<berry::IPreferencesService>(berry::IPreferencesService::ID);
  this->m_InputDevicesPrefNode = prefService->GetSystemPreferences()->Node(mitk::CoreExtConstants::INPUTDEVICE_PREFERENCES);
}

Member Function Documentation

void QmitkInputDevicesPrefPage::CreateQtControl ( QWidget *  widget ) [virtual]
See also:
berry::IPreferencePage::CreateQtControl(void* parent)

Implements berry::IQtPreferencePage.

Definition at line 49 of file QmitkInputDevicesPrefPage.cpp.

References berry::Platform::GetServiceRegistry(), mitk::CoreExtConstants::INPUTDEVICE_SERVICE, m_InputDevices, m_MainControl, and Update().

{
  m_MainControl = new QWidget(parent);
  QVBoxLayout *layout = new QVBoxLayout;

  mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry =
    berry::Platform::GetServiceRegistry().GetServiceById<mitk::IInputDeviceRegistry>(mitk::CoreExtConstants::INPUTDEVICE_SERVICE);
  std::vector<mitk::IInputDeviceDescriptor::Pointer> temp(inputDeviceRegistry->GetInputDevices());

  for(std::vector<mitk::IInputDeviceDescriptor::Pointer>::const_iterator it = temp.begin(); it != temp.end();++it)
  {
    QCheckBox* checkBox = new QCheckBox(QString::fromStdString((*it)->GetName()),m_MainControl);
    layout->addWidget(checkBox);
    m_InputDevices.insert(checkBox,(*it)->GetID());
  }

  layout->addStretch();
  m_MainControl->setLayout(layout);
  this->Update();
}
QWidget * QmitkInputDevicesPrefPage::GetQtControl (  ) const [virtual]
See also:
berry::IPreferencePage::CreateQtControl()

Implements berry::IQtPreferencePage.

Definition at line 70 of file QmitkInputDevicesPrefPage.cpp.

References m_MainControl.

{
  return m_MainControl;
}
void QmitkInputDevicesPrefPage::Init ( berry::IWorkbench::Pointer  workbench ) [virtual]
void QmitkInputDevicesPrefPage::PerformCancel (  ) [virtual]
bool QmitkInputDevicesPrefPage::PerformOk (  ) [virtual]
See also:
berry::IPreferencePage::PerformOk()

Implements berry::IPreferencePage.

Definition at line 75 of file QmitkInputDevicesPrefPage.cpp.

References berry::Platform::GetServiceRegistry(), mitk::CoreExtConstants::INPUTDEVICE_SERVICE, m_InputDevices, and m_InputDevicesPrefNode.

{
  bool result = true;
  mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry =
    berry::Platform::GetServiceRegistry().GetServiceById<mitk::IInputDeviceRegistry>(mitk::CoreExtConstants::INPUTDEVICE_SERVICE);
  QHashIterator<QCheckBox*, std::string> it(m_InputDevices);
  while (it.hasNext())
  {
    it.next();
    mitk::IInputDeviceDescriptor::Pointer inputdevice(inputDeviceRegistry->Find(it.value()));
    if(it.key()->isChecked())
    {
      result &= inputdevice->CreateInputDevice()->RegisterInputDevice();
    }
    else
    {
      result &= inputdevice->CreateInputDevice()->UnRegisterInputDevice();

      // temporary fix, unclean solution:
      // e.g. user activates SpaceNavigator and leaves the 
      // the wiimote deactivated, the user will get the warning
      // despite the fact that it has never been activated 
      if(it.value() == "org.mitk.inputdevices.wiimote")
      {
        // until now 2010-09-06 there were some unfixed problems
        // with reconnecting the wiimote after disconnecting it.
        // It was suggested that it might have something to do 
        // with the type of stack, that is used for the pairing.
        // MS-Stack for example does not work properly.
        QMessageBox::information(NULL,"WiiMote supportproblem",
          "A reconnect of the WiiMote is not yet supported! "
          "Please restart the application, if you want to "
          "activate the Wii remote/s again.");
      }
    }

    if(result)
    {
      this->m_InputDevicesPrefNode->PutBool(it.value(),it.key()->isChecked());
    }
  }
  return result;
}
void QmitkInputDevicesPrefPage::Update (  ) [virtual]
See also:
berry::IPreferencePage::Update()

Implements berry::IPreferencePage.

Definition at line 124 of file QmitkInputDevicesPrefPage.cpp.

References m_InputDevices, and m_InputDevicesPrefNode.

Referenced by CreateQtControl().

{
  QHashIterator<QCheckBox*, std::string> it(m_InputDevices);
  while (it.hasNext())
  {
    it.next();
    it.key()->setChecked(this->m_InputDevicesPrefNode->GetBool(it.value(), false));
  }
}

Member Data Documentation

QHash<QCheckBox*,std::string> QmitkInputDevicesPrefPage::m_InputDevices [protected]

Definition at line 74 of file QmitkInputDevicesPrefPage.h.

Referenced by CreateQtControl(), PerformOk(), and Update().

Definition at line 76 of file QmitkInputDevicesPrefPage.h.

Referenced by PerformOk(), QmitkInputDevicesPrefPage(), and Update().

Definition at line 72 of file QmitkInputDevicesPrefPage.h.

Referenced by CreateQtControl(), and GetQtControl().


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