Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <gwen-gui-cpp/cppwidget.hpp>
00012
00013
00014 class Qt4_W_LineEdit: public Qt4_W_Widget {
00015 public:
00016 Qt4_W_LineEdit(GWEN_WIDGET *w):Qt4_W_Widget(w) {
00017 }
00018
00019
00020
00021 ~Qt4_W_LineEdit() {
00022 }
00023
00024
00025
00026 virtual int setup() {
00027 QLineEdit *qw;
00028 uint32_t flags;
00029 GWEN_WIDGET *wParent;
00030 QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
00031 QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
00032 const char *s;
00033 QString text;
00034 QT4_GuiDialog *qtDialog;
00035
00036 flags=GWEN_Widget_GetFlags(_widget);
00037 wParent=GWEN_Widget_Tree_GetParent(_widget);
00038 s=GWEN_Widget_GetText(_widget, 0);
00039 if (s)
00040 text=QString::fromUtf8(s);
00041
00042 qw=new QLineEdit(text);
00043
00044
00045 if (flags & GWEN_WIDGET_FLAGS_FILLX)
00046 hpolicy=QSizePolicy::Expanding;
00047 if (flags & GWEN_WIDGET_FLAGS_FILLY)
00048 vpolicy=QSizePolicy::Expanding;
00049 qw->setSizePolicy(hpolicy, vpolicy);
00050
00051 if (flags & GWEN_WIDGET_FLAGS_PASSWORD)
00052 qw->setEchoMode(QLineEdit::Password);
00053 else
00054 qw->setEchoMode(QLineEdit::Normal);
00055
00056 GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_REAL, (void*) qw);
00057
00058 qtDialog=dynamic_cast<QT4_GuiDialog*>(getDialog());
00059 assert(qtDialog);
00060
00061 qw->connect(qw, SIGNAL(returnPressed()),
00062 qtDialog->getMainWindow(),
00063 SLOT(slotActivated()));
00064
00065 qw->connect(qw, SIGNAL(textChanged(const QString&)),
00066 qtDialog->getMainWindow(),
00067 SLOT(slotValueChanged()));
00068
00069
00070 if (wParent)
00071 GWEN_Widget_AddChildGuiWidget(wParent, _widget);
00072 return 0;
00073 }
00074
00075
00076
00077 int setCharProperty(GWEN_DIALOG_PROPERTY prop,
00078 int index,
00079 const char *value,
00080 int doSignal) {
00081 QLineEdit *qw;
00082 QString text;
00083
00084 qw=(QLineEdit*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00085 assert(qw);
00086
00087 if (value)
00088 text=QString::fromUtf8(value);
00089
00090 switch(prop) {
00091 case GWEN_DialogProperty_Value:
00092 qw->setText(text);
00093 return 0;
00094 default:
00095 break;
00096 }
00097
00098 DBG_WARN(GWEN_LOGDOMAIN,
00099 "Function is not appropriate for this type of widget (%s)",
00100 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00101 return GWEN_ERROR_INVALID;
00102 };
00103
00104
00105
00106 const char *getCharProperty(GWEN_DIALOG_PROPERTY prop,
00107 int index,
00108 const char *defaultValue) {
00109 QLineEdit *qw;
00110 QString str;
00111
00112 qw=(QLineEdit*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00113 assert(qw);
00114
00115 switch(prop) {
00116 case GWEN_DialogProperty_Value:
00117 str=qw->text();
00118 if (str.isEmpty())
00119 return defaultValue;
00120 else {
00121 GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8());
00122 return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE);
00123 }
00124 break;
00125
00126 default:
00127 break;
00128 }
00129
00130 DBG_WARN(GWEN_LOGDOMAIN,
00131 "Function is not appropriate for this type of widget (%s)",
00132 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00133 return defaultValue;
00134 };
00135
00136 };
00137
00138
00139
00140
00141
00142
00143