Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifdef HAVE_CONFIG_H
00011 # include <config.h>
00012 #endif
00013
00014
00015
00016 #include "qt4dialogbox.hpp"
00017 #include "qt4_gui_dialog.hpp"
00018
00019 #include <QCloseEvent>
00020
00021 #include <gwenhywfar/debug.h>
00022
00023
00024
00025
00026 QT4_DialogBox::QT4_DialogBox(QT4_GuiDialog *dialog,
00027 QWidget *parent,
00028 bool modal,
00029 Qt::WindowFlags f)
00030 :QDialog(parent, f)
00031 ,_dialog(dialog)
00032 {
00033 setModal(modal);
00034 }
00035
00036
00037
00038 QT4_DialogBox::~QT4_DialogBox() {
00039 }
00040
00041
00042
00043 void QT4_DialogBox::accept() {
00044 QDialog::accept();
00045 }
00046
00047
00048
00049 void QT4_DialogBox::reject() {
00050 QDialog::reject();
00051 }
00052
00053
00054
00055 int QT4_DialogBox::cont() {
00056 return exec();
00057 }
00058
00059
00060
00061 void QT4_DialogBox::closeEvent(QCloseEvent *e){
00062 if (_dialog) {
00063 int rv;
00064
00065 rv=GWEN_Dialog_EmitSignal(_dialog->getCInterface(), GWEN_DialogEvent_TypeClose, "");
00066 if (rv!=GWEN_DialogEvent_ResultReject) {
00067 e->accept();
00068 }
00069 }
00070 else {
00071 e->accept();
00072 }
00073 }
00074
00075
00076
00077 void QT4_DialogBox::unlinkFromDialog() {
00078 _dialog=NULL;
00079 }
00080
00081
00082
00083 void QT4_DialogBox::slotActivated() {
00084 const QObject *snd;
00085
00086 snd=sender();
00087 if (snd) {
00088 GWEN_WIDGET *w;
00089 const char *wname;
00090 int rv=GWEN_DialogEvent_ResultNotHandled;
00091
00092 w=GWEN_Dialog_FindWidgetByImplData(_dialog->getCInterface(), QT4_DIALOG_WIDGET_REAL, snd);
00093 if (w==NULL) {
00094 DBG_INFO(0, "Widget not found");
00095 return;
00096 }
00097 wname=GWEN_Widget_GetName(w);
00098
00099 DBG_INFO(GWEN_LOGDOMAIN, "Command for [%s] (type: %s)",
00100 wname?wname:"(unnamed)",
00101 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00102
00103 switch(GWEN_Widget_GetType(w)) {
00104 case GWEN_Widget_TypeUnknown:
00105 case GWEN_Widget_TypeNone:
00106 break;
00107
00108 case GWEN_Widget_TypePushButton:
00109 case GWEN_Widget_TypeLineEdit:
00110 case GWEN_Widget_TypeComboBox:
00111 case GWEN_Widget_TypeListBox:
00112 case GWEN_Widget_TypeCheckBox:
00113 case GWEN_Widget_TypeLabel:
00114 case GWEN_Widget_TypeTextEdit:
00115 case GWEN_Widget_TypeSpinBox:
00116 rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
00117 GWEN_DialogEvent_TypeActivated,
00118 GWEN_Widget_GetName(w));
00119 break;
00120 case GWEN_Widget_TypeRadioButton:
00121 case GWEN_Widget_TypeProgressBar:
00122 case GWEN_Widget_TypeGroupBox:
00123 case GWEN_Widget_TypeHSpacer:
00124 case GWEN_Widget_TypeVSpacer:
00125 case GWEN_Widget_TypeHLayout:
00126 case GWEN_Widget_TypeVLayout:
00127 case GWEN_Widget_TypeGridLayout:
00128 case GWEN_Widget_TypeDialog:
00129 case GWEN_Widget_TypeTabBook:
00130 case GWEN_Widget_TypeTabPage:
00131 case GWEN_Widget_TypeScrollArea:
00132 case GWEN_Widget_TypeWidgetStack:
00133 case GWEN_Widget_TypeHLine:
00134 case GWEN_Widget_TypeVLine:
00135 case GWEN_Widget_TypeTextBrowser:
00136
00137 ;
00138 }
00139
00140 if (rv==GWEN_DialogEvent_ResultAccept) {
00141 accept();
00142 }
00143 else if (rv==GWEN_DialogEvent_ResultReject) {
00144 reject();
00145 }
00146 }
00147 }
00148
00149
00150
00151 void QT4_DialogBox::slotValueChanged() {
00152 const QObject *snd;
00153
00154 snd=sender();
00155 if (snd) {
00156 GWEN_WIDGET *w;
00157 const char *wname;
00158 int rv=GWEN_DialogEvent_ResultNotHandled;
00159
00160 w=GWEN_Dialog_FindWidgetByImplData(_dialog->getCInterface(), QT4_DIALOG_WIDGET_REAL, snd);
00161 if (w==NULL) {
00162 DBG_INFO(0, "Widget not found");
00163 return;
00164 }
00165 wname=GWEN_Widget_GetName(w);
00166
00167 DBG_INFO(GWEN_LOGDOMAIN, "ValueChanged for [%s] (type: %s)",
00168 wname?wname:"(unnamed)",
00169 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00170
00171 switch(GWEN_Widget_GetType(w)) {
00172 case GWEN_Widget_TypeUnknown:
00173 case GWEN_Widget_TypeNone:
00174 break;
00175
00176 case GWEN_Widget_TypePushButton:
00177 case GWEN_Widget_TypeLineEdit:
00178 case GWEN_Widget_TypeComboBox:
00179 case GWEN_Widget_TypeListBox:
00180 case GWEN_Widget_TypeCheckBox:
00181 case GWEN_Widget_TypeLabel:
00182 case GWEN_Widget_TypeTextEdit:
00183 case GWEN_Widget_TypeSpinBox:
00184 rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
00185 GWEN_DialogEvent_TypeValueChanged,
00186 GWEN_Widget_GetName(w));
00187 break;
00188
00189 case GWEN_Widget_TypeRadioButton:
00190 case GWEN_Widget_TypeProgressBar:
00191 case GWEN_Widget_TypeGroupBox:
00192 case GWEN_Widget_TypeHSpacer:
00193 case GWEN_Widget_TypeVSpacer:
00194 case GWEN_Widget_TypeHLayout:
00195 case GWEN_Widget_TypeVLayout:
00196 case GWEN_Widget_TypeGridLayout:
00197 case GWEN_Widget_TypeDialog:
00198 case GWEN_Widget_TypeTabBook:
00199 case GWEN_Widget_TypeTabPage:
00200 case GWEN_Widget_TypeScrollArea:
00201 case GWEN_Widget_TypeWidgetStack:
00202 case GWEN_Widget_TypeHLine:
00203 case GWEN_Widget_TypeVLine:
00204 case GWEN_Widget_TypeTextBrowser:
00205
00206 ;
00207 }
00208
00209 if (rv==GWEN_DialogEvent_ResultAccept) {
00210 accept();
00211 }
00212 else if (rv==GWEN_DialogEvent_ResultReject) {
00213 reject();
00214 }
00215 }
00216 }
00217
00218
00219
00220 #include "qt4dialogbox.moc"
00221
00222
00223