kalarm/lib
combobox.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qlineedit.h>
00022 #include "combobox.moc"
00023
00024
00025 ComboBox::ComboBox(QWidget* parent, const char* name)
00026 : QComboBox(parent, name),
00027 mReadOnly(false)
00028 { }
00029
00030 ComboBox::ComboBox(bool rw, QWidget* parent, const char* name)
00031 : QComboBox(rw, parent, name),
00032 mReadOnly(false)
00033 { }
00034
00035 void ComboBox::setReadOnly(bool ro)
00036 {
00037 if ((int)ro != (int)mReadOnly)
00038 {
00039 mReadOnly = ro;
00040 if (lineEdit())
00041 lineEdit()->setReadOnly(ro);
00042 }
00043 }
00044
00045 void ComboBox::mousePressEvent(QMouseEvent* e)
00046 {
00047 if (mReadOnly)
00048 {
00049
00050 if (e->button() == LeftButton)
00051 return;
00052 }
00053 QComboBox::mousePressEvent(e);
00054 }
00055
00056 void ComboBox::mouseReleaseEvent(QMouseEvent* e)
00057 {
00058 if (!mReadOnly)
00059 QComboBox::mouseReleaseEvent(e);
00060 }
00061
00062 void ComboBox::mouseMoveEvent(QMouseEvent* e)
00063 {
00064 if (!mReadOnly)
00065 QComboBox::mouseMoveEvent(e);
00066 }
00067
00068 void ComboBox::keyPressEvent(QKeyEvent* e)
00069 {
00070 if (!mReadOnly || e->key() == Qt::Key_Escape)
00071 QComboBox::keyPressEvent(e);
00072 }
00073
00074 void ComboBox::keyReleaseEvent(QKeyEvent* e)
00075 {
00076 if (!mReadOnly)
00077 QComboBox::keyReleaseEvent(e);
00078 }
|