Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/controlobjectthreadwidget.cpp

Go to the documentation of this file.
00001 //
00002 // C++ Implementation: controlobjecthreadwidget.cpp
00003 //
00004 // Description:
00005 //
00006 //
00007 // Author: Tue Haste Andersen <haste@diku.dk>, (C) 2004
00008 //
00009 // Copyright: See COPYING file that comes with this distribution
00010 //
00011 //
00012 
00013 #include <qapplication.h>
00014 #include "controlobjectthreadwidget.h"
00015 #include "controlobject.h"
00016 #include "controlevent.h"
00017 
00018 ControlObjectThreadWidget::ControlObjectThreadWidget(ControlObject * pControlObject, QObject* pParent)
00019         : ControlObjectThreadMain(pControlObject, pParent) {
00020     // Initialize value
00021     m_dValue = m_pControlObject->getValueToWidget(m_pControlObject->get());
00022     emitValueChanged();
00023 }
00024 
00025 ControlObjectThreadWidget::~ControlObjectThreadWidget() {
00026 }
00027 
00028 void ControlObjectThreadWidget::setWidget(QWidget * widget, bool connectValueFromWidget,
00029                                           bool connectValueToWidget,
00030                                           EmitOption emitOption, Qt::MouseButton state)
00031 {
00032 
00033     if (connectValueFromWidget) {
00034         if (emitOption & EMIT_ON_PRESS) {
00035             if (state == Qt::NoButton)
00036                 connect(widget, SIGNAL(valueChangedDown(double)),
00037                         this, SLOT(slotSet(double)));
00038             else if (state == Qt::LeftButton)
00039                 connect(widget, SIGNAL(valueChangedLeftDown(double)),
00040                         this, SLOT(slotSet(double)));
00041             else if (state == Qt::RightButton)
00042                 connect(widget, SIGNAL(valueChangedRightDown(double)),
00043                         this, SLOT(slotSet(double)));
00044         }
00045 
00046         if (emitOption & EMIT_ON_RELEASE) {
00047             if (state == Qt::NoButton)
00048                 connect(widget, SIGNAL(valueChangedUp(double)),
00049                         this, SLOT(slotSet(double)));
00050             else if (state == Qt::LeftButton)
00051                 connect(widget, SIGNAL(valueChangedLeftUp(double)),
00052                         this, SLOT(slotSet(double)));
00053             else if (state == Qt::RightButton)
00054                 connect(widget, SIGNAL(valueChangedRightUp(double)),
00055                         this, SLOT(slotSet(double)));
00056         }
00057     }
00058 
00059     if (connectValueToWidget) {
00060         connect(this, SIGNAL(valueChanged(double)),
00061                 widget, SLOT(setValue(double)));
00062     }
00063     emitValueChanged();
00064 }
00065 
00066 void ControlObjectThreadWidget::setWidgetOnOff(QWidget * widget)
00067 {
00068     QApplication::connect(this,   SIGNAL(valueChanged(double)),    widget, SLOT(setOnOff(double)));
00069     emit(valueChanged(m_dValue));
00070 }
00071 
00072 void ControlObjectThreadWidget::updateControlObject()
00073 {
00074     m_pControlObject->queueFromThread(m_pControlObject->getValueFromWidget(get()), this);
00075 }
00076 
00077 bool ControlObjectThreadWidget::setExtern(double v)
00078 {
00079     //qDebug() << "set extern widget";
00080     QApplication::postEvent(this, new ControlEvent(m_pControlObject->getValueToWidget(v)));
00081     return true;
00082 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines