1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
// This file is auto-generated by rute_gen. DO NOT EDIT.
use std::cell::Cell;
use std::rc::Rc;

#[allow(unused_imports)]
use std::marker::PhantomData;

#[allow(unused_imports)]
use std::os::raw::c_void;

#[allow(unused_imports)]
use std::mem::transmute;

#[allow(unused_imports)]
use std::ffi::{CStr, CString};

use rute_ffi_base::*;

#[allow(unused_imports)]
use auto::*;

/// **Notice these docs are heavy WIP and not very relevent yet**
///
/// QMimeData is used to describe information that can be stored in
/// the [clipboard](QClipboard)
/// , and transferred via the [drag
/// and drop](drag%0A%20%20%20%20and%20drop)
/// mechanism. QMimeData objects associate the data that
/// they hold with the corresponding MIME types to ensure that
/// information can be safely transferred between applications, and
/// copied around within the same application.
///
/// QMimeData objects are usually created using `new` and supplied
/// to QDrag or QClipboard objects. This is to enable Qt to manage
/// the memory that they use.
///
/// A single QMimeData object can store the same data using several
/// different formats at the same time. The formats() function
/// returns a list of the available formats in order of preference.
/// The data() function returns the raw data associated with a MIME
/// type, and setData() allows you to set the data for a MIME type.
///
/// For the most common MIME types, QMimeData provides convenience
/// functions to access the data:
///
/// * Tester
/// * Getter
/// * Setter
/// * MIME Types
/// * hasText()
/// * text()
/// * setText()
/// * `text/plain`
/// * hasHtml()
/// * html()
/// * setHtml()
/// * `text/html`
/// * hasUrls()
/// * urls()
/// * setUrls()
/// * `text/uri-list`
/// * hasImage()
/// * imageData()
/// * setImageData()
/// * `image/` *
/// * hasColor()
/// * colorData()
/// * setColorData()
/// * `application/x-color`
///
/// For example, if your write a widget that accepts URL drags, you
/// would end up writing code like this:
///
/// There are three approaches for storing custom data in a QMimeData
/// object:
///
/// * Custom data can be stored directly in a QMimeData object as a QByteArray using setData(). For example:
/// * We can subclass QMimeData and reimplement hasFormat(), formats(), and retrieveData().
/// * If the drag and drop operation occurs within a single application, we can subclass QMimeData and add extra data in it, and use a qobject_cast() in the receiver's drop event handler. For example:
///
/// # Platform-Specific MIME Types
///
/// On Windows, formats() will also return custom formats available
/// in the MIME data, using the `x-qt-windows-mime` subtype to
/// indicate that they represent data in non-standard formats.
/// The formats will take the following form:
///
/// The following are examples of custom MIME types:
///
/// The `value` declaration of each format describes the way in which the
/// data is encoded.
///
/// In some cases (e.g. dropping multiple email attachments), multiple data
/// values are available. They can be accessed by adding an `index` value:
///
/// On Windows, the MIME format does not always map directly to the
/// clipboard formats. Qt provides QWinMime to map clipboard
/// formats to open-standard MIME formats. Similarly, the
/// QMacPasteboardMime maps MIME to Mac flavors.
///
/// **See also:** [`Clipboard`]
/// [`DragEnterEvent`]
/// [`DragMoveEvent`]
/// [`DropEvent`]
/// [`Drag`]
/// [`MacPasteboardMime`]
/// {Drag and Drop}
/// # Licence
///
/// The documentation is an adoption of the original [Qt Documentation](http://doc.qt.io/) and provided herein is licensed under the terms of the [GNU Free Documentation License version 1.3](http://www.gnu.org/licenses/fdl.html) as published by the Free Software Foundation.
#[derive(Clone)]
pub struct MimeData<'a> {
    #[doc(hidden)]
    pub data: Rc<Cell<Option<*const RUBase>>>,
    #[doc(hidden)]
    pub all_funcs: *const RUMimeDataAllFuncs,
    #[doc(hidden)]
    pub owned: bool,
    #[doc(hidden)]
    pub _marker: PhantomData<::std::cell::Cell<&'a ()>>,
}

impl<'a> MimeData<'a> {
    pub fn new() -> MimeData<'a> {
        let ffi_data = unsafe { ((*rute_ffi_get()).create_mime_data)(::std::ptr::null()) };
        MimeData {
            data: Rc::new(Cell::new(Some(ffi_data.qt_data))),
            all_funcs: ffi_data.all_funcs,
            owned: true,
            _marker: PhantomData,
        }
    }
    #[allow(dead_code)]
    pub(crate) fn new_from_rc(ffi_data: RUMimeData) -> MimeData<'a> {
        MimeData {
            data: unsafe { Rc::from_raw(ffi_data.host_data as *const Cell<Option<*const RUBase>>) },
            all_funcs: ffi_data.all_funcs,
            owned: false,
            _marker: PhantomData,
        }
    }

    #[allow(dead_code)]
    pub(crate) fn new_from_owned(ffi_data: RUMimeData) -> MimeData<'a> {
        MimeData {
            data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
            all_funcs: ffi_data.all_funcs,
            owned: true,
            _marker: PhantomData,
        }
    }

    #[allow(dead_code)]
    pub(crate) fn new_from_temporary(ffi_data: RUMimeData) -> MimeData<'a> {
        MimeData {
            data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
            all_funcs: ffi_data.all_funcs,
            owned: false,
            _marker: PhantomData,
        }
    }
    ///
    /// Returns a list of URLs contained within the MIME data object.
    ///
    /// URLs correspond to the MIME type `text/uri-list.`
    ///
    /// **See also:** [`has_urls()`]
    /// [`data()`]
    ///
    /// Sets the URLs stored in the MIME data object to those specified by *urls.*
    ///
    /// URLs correspond to the MIME type `text/uri-list.`
    ///
    /// Since Qt 5.0, setUrls also exports the urls as plain text, if setText
    /// was not called before, to make it possible to drop them into any lineedit
    /// and text editor.
    ///
    /// **See also:** [`has_urls()`]
    /// [`set_data()`]
    ///
    /// Returns `true` if the object can return a list of urls; otherwise
    /// returns `false.`
    ///
    /// URLs correspond to the MIME type `text/uri-list.`
    ///
    /// **See also:** [`set_urls()`]
    /// [`urls()`]
    /// [`has_format()`]
    pub fn has_urls(&self) -> bool {
        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).has_urls)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns a plain text (MIME type `text/plain)` representation of
    /// the data.
    ///
    /// **See also:** [`has_text()`]
    /// [`html()`]
    /// [`data()`]
    pub fn text(&self) -> String {
        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).text)(obj_data);
            let ret_val = CStr::from_ptr(ret_val).to_string_lossy().into_owned();
            ret_val
        }
    }
    ///
    /// Sets *text* as the plain text (MIME type `text/plain)` used to
    /// represent the data.
    ///
    /// **See also:** [`has_text()`]
    /// [`set_html()`]
    /// [`set_data()`]
    pub fn set_text(&self, text: &str) -> &Self {
        let str_in_text_1 = CString::new(text).unwrap();

        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            ((*funcs).set_text)(obj_data, str_in_text_1.as_ptr());
        }
        self
    }
    ///
    /// Returns `true` if the object can return plain text (MIME type `text/plain);` otherwise returns `false.`
    ///
    /// **See also:** [`set_text()`]
    /// [`text()`]
    /// [`has_html()`]
    /// [`has_format()`]
    pub fn has_text(&self) -> bool {
        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).has_text)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns a string if the data stored in the object is HTML (MIME
    /// type `text/html);` otherwise returns an empty string.
    ///
    /// **See also:** [`has_html()`]
    /// [`set_data()`]
    pub fn html(&self) -> String {
        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).html)(obj_data);
            let ret_val = CStr::from_ptr(ret_val).to_string_lossy().into_owned();
            ret_val
        }
    }
    ///
    /// Sets *html* as the HTML (MIME type `text/html)` used to
    /// represent the data.
    ///
    /// **See also:** [`has_html()`]
    /// [`set_text()`]
    /// [`set_data()`]
    pub fn set_html(&self, html: &str) -> &Self {
        let str_in_html_1 = CString::new(html).unwrap();

        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            ((*funcs).set_html)(obj_data, str_in_html_1.as_ptr());
        }
        self
    }
    ///
    /// Returns `true` if the object can return HTML (MIME type `text/html);` otherwise returns `false.`
    ///
    /// **See also:** [`set_html()`]
    /// [`html()`]
    /// [`has_format()`]
    pub fn has_html(&self) -> bool {
        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).has_html)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns a QVariant storing a QImage if the object can return an
    /// image; otherwise returns a null variant.
    ///
    /// A QVariant is used because QMimeData belongs to the Qt Core
    /// module, whereas QImage belongs to Qt GUI. To convert the
    /// QVariant to a QImage, simply use qvariant_cast(). For example:
    ///
    /// **See also:** [`has_image()`]
    ///
    /// Sets the data in the object to the given *image.*
    ///
    /// A QVariant is used because QMimeData belongs to the Qt Core
    /// module, whereas QImage belongs to Qt GUI. The conversion
    /// from QImage to QVariant is implicit. For example:
    ///
    /// **See also:** [`has_image()`]
    /// [`set_data()`]
    ///
    /// Returns `true` if the object can return an image; otherwise returns
    /// false.
    ///
    /// **See also:** [`set_image_data()`]
    /// [`image_data()`]
    /// [`has_format()`]
    pub fn has_image(&self) -> bool {
        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).has_image)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns a color if the data stored in the object represents a
    /// color (MIME type `application/x-color);` otherwise returns a
    /// null variant.
    ///
    /// A QVariant is used because QMimeData belongs to the Qt Core
    /// module, whereas QColor belongs to Qt GUI. To convert the
    /// QVariant to a QColor, simply use qvariant_cast(). For example:
    ///
    /// **See also:** [`has_color()`]
    /// [`set_color_data()`]
    /// [`data()`]
    ///
    /// Sets the color data in the object to the given *color.*
    ///
    /// Colors correspond to the MIME type `application/x-color.`
    ///
    /// **See also:** [`has_color()`]
    /// [`set_data()`]
    ///
    /// Returns `true` if the object can return a color (MIME type `application/x-color);` otherwise returns `false.`
    ///
    /// **See also:** [`set_color_data()`]
    /// [`color_data()`]
    /// [`has_format()`]
    pub fn has_color(&self) -> bool {
        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).has_color)(obj_data);
            ret_val
        }
    }
    ///
    /// Removes the data entry for *mimeType* in the object.
    pub fn remove_format(&self, mimetype: &str) -> &Self {
        let str_in_mimetype_1 = CString::new(mimetype).unwrap();

        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            ((*funcs).remove_format)(obj_data, str_in_mimetype_1.as_ptr());
        }
        self
    }
    ///
    /// Returns `true` if the object can return data for the MIME type
    /// specified by *mimeType;* otherwise returns `false.`
    ///
    /// For the most common types of data, you can call the higher-level
    /// functions hasText(), hasHtml(), hasUrls(), hasImage(), and
    /// hasColor() instead.
    ///
    /// **See also:** [`formats()`]
    /// [`set_data()`]
    /// [`data()`]
    pub fn has_format(&self, mimetype: &str) -> bool {
        let str_in_mimetype_1 = CString::new(mimetype).unwrap();

        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).has_format)(obj_data, str_in_mimetype_1.as_ptr());
            ret_val
        }
    }
    ///
    /// Returns a list of formats supported by the object. This is a list
    /// of MIME types for which the object can return suitable data. The
    /// formats in the list are in a priority order.
    ///
    /// For the most common types of data, you can call the higher-level
    /// functions hasText(), hasHtml(), hasUrls(), hasImage(), and
    /// hasColor() instead.
    ///
    /// **See also:** [`has_format()`]
    /// [`set_data()`]
    /// [`data()`]
    ///
    /// Removes all the MIME type and data entries in the object.
    pub fn clear(&self) -> &Self {
        let (obj_data, funcs) = self.get_mime_data_obj_funcs();
        unsafe {
            ((*funcs).clear)(obj_data);
        }
        self
    }
    #[doc(hidden)]
    pub fn object_name(&self) -> String {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).object_name)(obj_data);
            let ret_val = CStr::from_ptr(ret_val).to_string_lossy().into_owned();
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn set_object_name(&self, name: &str) -> &Self {
        let str_in_name_1 = CString::new(name).unwrap();

        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            ((*funcs).set_object_name)(obj_data, str_in_name_1.as_ptr());
        }
        self
    }
    #[doc(hidden)]
    pub fn is_widget_type(&self) -> bool {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).is_widget_type)(obj_data);
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn is_window_type(&self) -> bool {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).is_window_type)(obj_data);
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn signals_blocked(&self) -> bool {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).signals_blocked)(obj_data);
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn block_signals(&self, b: bool) -> bool {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).block_signals)(obj_data, b);
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn start_timer(&self, interval: i32, timer_type: TimerType) -> i32 {
        let enum_timer_type_2 = timer_type as i32;

        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).start_timer)(obj_data, interval, enum_timer_type_2);
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn start_timer_2(&self, time: u32, timer_type: TimerType) -> i32 {
        let enum_timer_type_2 = timer_type as i32;

        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).start_timer_2)(obj_data, time, enum_timer_type_2);
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn kill_timer(&self, id: i32) -> &Self {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            ((*funcs).kill_timer)(obj_data, id);
        }
        self
    }
    #[doc(hidden)]
    pub fn set_parent<O: ObjectTrait<'a>>(&self, parent: &O) -> &Self {
        let (obj_parent_1, _funcs) = parent.get_object_obj_funcs();

        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            ((*funcs).set_parent)(obj_data, obj_parent_1);
        }
        self
    }
    #[doc(hidden)]
    pub fn install_event_filter<O: ObjectTrait<'a>>(&self, filter_obj: &O) -> &Self {
        let (obj_filter_obj_1, _funcs) = filter_obj.get_object_obj_funcs();

        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            ((*funcs).install_event_filter)(obj_data, obj_filter_obj_1);
        }
        self
    }
    #[doc(hidden)]
    pub fn dump_object_tree(&self) -> &Self {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            ((*funcs).dump_object_tree)(obj_data);
        }
        self
    }
    #[doc(hidden)]
    pub fn dump_object_info(&self) -> &Self {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            ((*funcs).dump_object_info)(obj_data);
        }
        self
    }
    #[doc(hidden)]
    pub fn dump_object_tree_2(&self) -> &Self {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            ((*funcs).dump_object_tree_2)(obj_data);
        }
        self
    }
    #[doc(hidden)]
    pub fn dump_object_info_2(&self) -> &Self {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            ((*funcs).dump_object_info_2)(obj_data);
        }
        self
    }
    #[doc(hidden)]
    pub fn parent(&self) -> Option<Object> {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).parent)(obj_data);
            if ret_val.qt_data == ::std::ptr::null() {
                return None;
            }
            let t = ret_val;
            let ret_val;
            if t.host_data != ::std::ptr::null() {
                ret_val = Object::new_from_rc(t);
            } else {
                ret_val = Object::new_from_owned(t);
            }
            Some(ret_val)
        }
    }
    #[doc(hidden)]
    pub fn delete_later(&self) -> &Self {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        unsafe {
            ((*funcs).delete_later)(obj_data);
        }
        self
    }
    #[doc(hidden)]
    pub fn set_custom_event_ud<F, T>(&self, data: &'a T, func: F) -> &Self
    where
        F: Fn(&T, &Event) + 'a,
        T: 'a,
    {
        let (obj_data, funcs) = self.get_object_obj_funcs();

        let f: Box<Box<Fn(&T, &Event) + 'a>> = Box::new(Box::new(func));
        let user_data = data as *const _ as *const c_void;

        unsafe {
            ((*funcs).set_custom_event)(
                obj_data,
                user_data,
                Box::into_raw(f) as *const _,
                transmute(object_custom_trampoline_ud::<T> as usize),
            );
        }

        self
    }

    pub fn set_custom_event<F>(&self, func: F) -> &Self
    where
        F: Fn(&Event) + 'a,
    {
        let (obj_data, funcs) = self.get_object_obj_funcs();
        let f: Box<Box<Fn(&Event) + 'a>> = Box::new(Box::new(func));

        unsafe {
            ((*funcs).set_custom_event)(
                obj_data,
                ::std::ptr::null(),
                Box::into_raw(f) as *const _,
                transmute(object_custom_trampoline as usize),
            );
        }

        self
    }
}
pub trait MimeDataTrait<'a> {
    #[inline]
    #[doc(hidden)]
    fn get_mime_data_obj_funcs(&self) -> (*const RUBase, *const RUMimeDataFuncs);
}

impl<'a> ObjectTrait<'a> for MimeData<'a> {
    #[doc(hidden)]
    fn get_object_obj_funcs(&self) -> (*const RUBase, *const RUObjectFuncs) {
        let obj = self.data.get().unwrap();
        unsafe { (obj, (*self.all_funcs).object_funcs) }
    }
}

impl<'a> MimeDataTrait<'a> for MimeData<'a> {
    #[doc(hidden)]
    fn get_mime_data_obj_funcs(&self) -> (*const RUBase, *const RUMimeDataFuncs) {
        let obj = self.data.get().unwrap();
        unsafe { (obj, (*self.all_funcs).mime_data_funcs) }
    }
}