gwenhywfar  4.7.0beta
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 
51  if (flags & GWEN_WIDGET_FLAGS_PASSWORD)
52  qw->setEchoMode(QLineEdit::Password);
53  else
54  qw->setEchoMode(QLineEdit::Normal);
55 
57 
58  qtDialog=dynamic_cast<QT4_GuiDialog*>(getDialog());
59  assert(qtDialog);
60 
61  qw->connect(qw, SIGNAL(returnPressed()),
62  qtDialog->getMainWindow(),
63  SLOT(slotActivated()));
64 
65  qw->connect(qw, SIGNAL(textChanged(const QString&)),
66  qtDialog->getMainWindow(),
67  SLOT(slotValueChanged()));
68 
69 
70  if (wParent)
72  return 0;
73  }
74 
75 
76 
78  int index,
79  const char *value,
80  int doSignal) {
81  QLineEdit *qw;
82  QString text;
83 
85  assert(qw);
86 
87  if (value)
88  text=QString::fromUtf8(value);
89 
90  switch(prop) {
92  qw->setText(text);
93  return 0;
94  default:
95  break;
96  }
97 
99  "Function is not appropriate for this type of widget (%s)",
101  return GWEN_ERROR_INVALID;
102  };
103 
104 
105 
107  int index,
108  const char *defaultValue) {
109  QLineEdit *qw;
110  QString str;
111 
113  assert(qw);
114 
115  switch(prop) {
117  str=qw->text();
118  if (str.isEmpty())
119  return defaultValue;
120  else {
123  }
124  break;
125 
126  default:
127  break;
128  }
129 
131  "Function is not appropriate for this type of widget (%s)",
133  return defaultValue;
134  };
135 
136 };
137 
138 
139 
140 
141 
142 
143