157{
158 if(dynamic_cast<QListWidget*>(Target)) {
159 auto decode = [
this] (
const QMimeData *
const data) -> QPair<bool, QStringList>
160 {
161 bool allGood = true;
162 QStringList newItems;
163
164 if(
data->hasFormat(
"application/vnd.text.list") ==
true) {
165 QByteArray encodedData =
data->data(
"application/vnd.text.list");
166 QDataStream stream(&encodedData, QIODevice::ReadOnly);
167
169
170 while(!stream.atEnd()) {
171 QStringList text;
172 stream >> text;
173
174 const QString& obj_id = text.at(0);
175 const QString& obj_class = text.at(1);
176
177 if((obj_class.toStdString() == referenceClass) ||
179 {
180 newItems.append(obj_id);
181 } else {
182 allGood = false;
183 }
184 }
185 } else {
186 allGood = false;
187 }
188
189 return qMakePair(allGood, newItems);
190 };
191
192 if(Event->type() == QEvent::DragEnter) {
193 QDragEnterEvent *tDropEvent = static_cast<QDragEnterEvent *>(Event);
194
195 const QMimeData *
const data = tDropEvent->mimeData();
196 const auto& decodedData = decode(data);
197 if((decodedData.first == true) && (decodedData.second.size() > 0)) {
198 tDropEvent->acceptProposedAction();
199 }
200
201 return true;
202 }
203
204 if(Event->type() == QEvent::Drop) {
205 QDropEvent *tDropEvent = static_cast<QDropEvent *>(Event);
206
207 const QMimeData *
const data = tDropEvent->mimeData();
208 for(const QString& o : decode(data).second) {
209
211 }
212
213 tDropEvent->acceptProposedAction();
214
215 return true;
216 }
217 } else if(QComboBox * Box = dynamic_cast<QComboBox *>(Target)) {
218 if(Event->type() == QEvent::Wheel) {
219 return true;
220 }
221
222 if(Event->type() == QEvent::KeyPress) {
223 QKeyEvent * KeyEvent = dynamic_cast<QKeyEvent *>(Event);
224
225 if(KeyEvent->key() == Qt::Key_Up || KeyEvent->key() == Qt::Key_Down) {
226 return true;
227 } else {
228 return false;
229 }
230 }
231
232 if(Event->type() == QEvent::FocusOut) {
233 QWidget * popup = Box->findChild<QFrame *>();
234 QWidget * popup1 = Box->lineEdit()->findChild<QFrame *>();
235
236 if(popup != popup1 and not popup->isHidden()) {
237 return true;
238 }
239
242 FirstItem =
new QListWidgetItem(
"Type here");
243 } else {
245 FirstItem =
new QListWidgetItem(
"No Object");
246 } else {
248 }
249 }
250
252
254 FirstItem->setBackgroundColor(Qt::GlobalColor::lightGray);
255 FirstItem->setTextColor(QColor(0, 0, 0, 127));
256 }
257
259 }
else if(
FirstItem->listWidget() == ListWidget && ListWidget->itemWidget(
FirstItem) != 0) {
260 ListWidget->takeItem(ListWidget->row(
FirstItem));
261 ListWidget->setItemWidget(
FirstItem,
nullptr);
263
265 FirstItem =
new QListWidgetItem(
"Type here");
266 } else {
268 FirstItem =
new QListWidgetItem(
"No Object");
269 } else {
271 }
272 }
273
275
277 FirstItem->setBackgroundColor(Qt::GlobalColor::lightGray);
278 FirstItem->setTextColor(QColor(0, 0, 0, 127));
279 }
280
282 }
283
284 return false;
285 }
286 } else if(QLineEdit* le = dynamic_cast<QLineEdit *>(Target)) {
287 if(Event->type() == QEvent::MouseButtonDblClick) {
288 const QString& value = le->text();
289
290
291 if((value.isEmpty() == false) && (value != "Type here") && (value != "No Object")) {
293 return false;
294 }
295 }
296 }
297
298 return false;
299}
static bool derived(std::string const &fromclass, std::string const &aclass)