gwenhywfar  5.14.1
qt4/w_lineedit.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Mon Feb 15 2010
3  copyright : (C) 2010 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 
11 #include <gwen-gui-cpp/cppwidget.hpp>
12 
13 
15 public:
17  }
18 
19 
20 
22  }
23 
24 
25 
26  virtual int setup() {
27  QLineEdit *qw;
28  uint32_t flags;
29  GWEN_WIDGET *wParent;
30  QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
31  QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
32  const char *s;
33  QString text;
34  QT4_GuiDialog *qtDialog;
35 
37  wParent=GWEN_Widget_Tree_GetParent(_widget);
39  if (s)
40  text=QString::fromUtf8(s);
41 
42  qw=new QLineEdit(text);
43 
44  /* handle flags */
45  if (flags & GWEN_WIDGET_FLAGS_FILLX)
46  hpolicy=QSizePolicy::Expanding;
47  if (flags & GWEN_WIDGET_FLAGS_FILLY)
48  vpolicy=QSizePolicy::Expanding;
49  qw->setSizePolicy(hpolicy, vpolicy);
50  qw->setReadOnly(flags & GWEN_WIDGET_FLAGS_READONLY);
51 
52  if (flags & GWEN_WIDGET_FLAGS_PASSWORD)
53  qw->setEchoMode(QLineEdit::Password);
54  else
55  qw->setEchoMode(QLineEdit::Normal);
56 
58 
59  qtDialog=dynamic_cast<QT4_GuiDialog*>(getDialog());
60  assert(qtDialog);
61 
62  qw->connect(qw, SIGNAL(returnPressed()),
63  qtDialog->getMainWindow(),
64  SLOT(slotActivated()));
65 
66  qw->connect(qw, SIGNAL(textChanged(const QString&)),
67  qtDialog->getMainWindow(),
68  SLOT(slotValueChanged()));
69 
70 
71  if (wParent)
73  return 0;
74  }
75 
76 
77 
79  int index,
80  const char *value,
81  int doSignal) {
82  QLineEdit *qw;
83  QString text;
84 
86  assert(qw);
87 
88  if (value)
89  text=QString::fromUtf8(value);
90 
91  switch(prop) {
93  qw->setText(text);
94  return 0;
95  default:
96  break;
97  }
98 
100  "Function is not appropriate for this type of widget (%s)",
102  return GWEN_ERROR_INVALID;
103  };
104 
105 
106 
108  int index,
109  const char *defaultValue) {
110  QLineEdit *qw;
111  QString str;
112 
114  assert(qw);
115 
116  switch(prop) {
118  str=qw->text();
119  if (str.isEmpty())
120  return defaultValue;
121  else {
124  }
125  break;
126 
127  default:
128  break;
129  }
130 
132  "Function is not appropriate for this type of widget (%s)",
134  return defaultValue;
135  };
136 
137 };
138 
139 
140 
141 
142 
143 
144 
GWEN_WIDGET_TYPE GWEN_Widget_GetType(const GWEN_WIDGET *w)
Definition: widget.c:185
void GWEN_Widget_SetText(GWEN_WIDGET *w, int idx, const char *s)
Definition: widget.c:304
int setCharProperty(GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
virtual int setup()
#define GWEN_ERROR_INVALID
Definition: error.h:67
GWEN_DIALOG_PROPERTY
Definition: dialog.h:260
uint32_t GWEN_Widget_GetFlags(const GWEN_WIDGET *w)
Definition: widget.c:149
#define GWEN_LOGDOMAIN
Definition: logger.h:32
#define GWEN_WIDGET_FLAGS_READONLY
Definition: dialog.h:63
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition: widget.c:136
#define QT4_DIALOG_STRING_TITLE
#define DBG_WARN(dbg_logger, format,...)
Definition: debug.h:125
void * GWEN_Widget_GetImplData(const GWEN_WIDGET *w, int index)
Definition: widget.c:122
#define GWEN_WIDGET_FLAGS_PASSWORD
Definition: dialog.h:64
Qt4_W_LineEdit(GWEN_WIDGET *w)
struct GWEN_WIDGET GWEN_WIDGET
Definition: widget_be.h:34
const char * getCharProperty(GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition: widget.c:836
#define GWEN_WIDGET_FLAGS_FILLY
Definition: dialog.h:62
#define GWEN_WIDGET_FLAGS_FILLX
Definition: dialog.h:61
#define QT4_DIALOG_WIDGET_REAL
const char * GWEN_Widget_Type_toString(GWEN_WIDGET_TYPE t)
Definition: widget.c:456
CppDialog * getDialog()
Definition: cppwidget.cpp:174
GWEN_WIDGET * _widget
Definition: cppwidget.hpp:66
const char * GWEN_Widget_GetText(const GWEN_WIDGET *w, int idx)
Definition: widget.c:293
QT4_DialogBox * getMainWindow()