gwenhywfar  5.14.1
qt5/w_combobox.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 
12 public:
14  }
15 
16 
17 
19  }
20 
21 
22 
23  virtual int setup() {
24  QComboBox *qw;
25  uint32_t flags;
26  GWEN_WIDGET *wParent;
27  QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
28  QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
29  QT5_GuiDialog *qtDialog;
30 
32  wParent=GWEN_Widget_Tree_GetParent(_widget);
33 
34  qw=new QComboBox();
35 
36  /* handle flags */
37  if (flags & GWEN_WIDGET_FLAGS_FILLX)
38  hpolicy=QSizePolicy::Expanding;
39  if (flags & GWEN_WIDGET_FLAGS_FILLY)
40  vpolicy=QSizePolicy::Expanding;
41  qw->setSizePolicy(hpolicy, vpolicy);
42  qw->setEditable((flags & GWEN_WIDGET_FLAGS_READONLY)?false:true);
43 
45 
46  qtDialog=dynamic_cast<QT5_GuiDialog*>(getDialog());
47  assert(qtDialog);
48 
49  qw->connect(qw, SIGNAL(activated(int)),
50  qtDialog->getMainWindow(),
51  SLOT(slotActivated()));
52 
53 
54  if (wParent)
56  return 0;
57  }
58 
59 
60 
62  int index,
63  int value,
64  int doSignal) {
65  QComboBox *qw;
66 
68  assert(qw);
69 
70  switch(prop) {
72  qw->setCurrentIndex(value);
73  return 0;
74 
76  qw->clear();
77  return 0;
78 
79  default:
80  return Qt5_W_Widget::setIntProperty(prop, index, value, doSignal);
81  }
82  };
83 
84 
85 
87  int index,
88  int defaultValue) {
89  QComboBox *qw;
90 
92  assert(qw);
93 
94  switch(prop) {
96  return qw->currentIndex();
97 
99  return qw->count();
100 
101  default:
102  return Qt5_W_Widget::getIntProperty(prop, index, defaultValue);
103  }
104  };
105 
106 
107 
109  GWEN_UNUSED int index,
110  const char *value,
111  GWEN_UNUSED int doSignal) {
112  QComboBox *qw;
113  QString text;
114 
116  assert(qw);
117 
118  if (value)
119  text=QString::fromUtf8(value);
120 
121  switch(prop) {
123  // undefined
124  break;
125 
127  qw->addItem(text);
128  return 0;
129 
131  qw->clear();
132  return 0;
133  default:
134  break;
135  }
136 
138  "Function is not appropriate for this type of widget (%s)",
140  return GWEN_ERROR_INVALID;
141  };
142 
143 
144 
146  int index,
147  const char *defaultValue) {
148  QComboBox *qw;
149  QString str;
150 
152  assert(qw);
153 
154  switch(prop) {
156  str=qw->itemText(index);
157  if (str.isEmpty())
158  return defaultValue;
159  else {
162  }
163  break;
164 
165  default:
166  break;
167  }
168 
170  "Function is not appropriate for this type of widget (%s)",
172  return defaultValue;
173  };
174 
175 };
176 
177 
178 
179 
180 
181 
182 
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
#define GWEN_ERROR_INVALID
Definition: error.h:67
int getIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
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
virtual int setup()
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition: widget.c:136
#define DBG_WARN(dbg_logger, format,...)
Definition: debug.h:125
int setIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
void * GWEN_Widget_GetImplData(const GWEN_WIDGET *w, int index)
Definition: widget.c:122
const char * getCharProperty(GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
struct GWEN_WIDGET GWEN_WIDGET
Definition: widget_be.h:34
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition: widget.c:836
#define GWEN_WIDGET_FLAGS_FILLY
Definition: dialog.h:62
QT5_DialogBox * getMainWindow()
#define GWEN_WIDGET_FLAGS_FILLX
Definition: dialog.h:61
#define QT5_DIALOG_STRING_TITLE
int setIntProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int value, GWEN_UNUSED int doSignal)
Qt5_W_ComboBox(GWEN_WIDGET *w)
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
int getIntProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int defaultValue)
#define QT5_DIALOG_WIDGET_REAL
const char * GWEN_Widget_GetText(const GWEN_WIDGET *w, int idx)
Definition: widget.c:293
#define GWEN_UNUSED
int setCharProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *value, GWEN_UNUSED int doSignal)