VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h@ 104158

Last change on this file since 104158 was 103977, checked in by vboxsync, 9 months ago

Apply RT_OVERRIDE/NS_OVERRIDE where required to shut up clang.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: UIDnDMIMEData.h 103977 2024-03-21 02:04:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIDnDMIMEData class declaration.
4 */
5
6/*
7 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_runtime_UIDnDMIMEData_h
29#define FEQT_INCLUDED_SRC_runtime_UIDnDMIMEData_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QMimeData>
36
37/* COM includes: */
38#include "CConsole.h"
39#include "CDnDSource.h"
40#include "CGuest.h"
41#include "CSession.h"
42
43#include "UIDnDHandler.h"
44
45/** @todo Subclass QWindowsMime / QMacPasteboardMime
46 * to register own/more MIME types. */
47
48/**
49 * Own implementation of QMimeData for starting and
50 * handling all guest-to-host transfers.
51 */
52class UIDnDMIMEData: public QMimeData
53{
54 Q_OBJECT;
55
56 enum State
57 {
58 /** Host is in dragging state, without
59 * having retrieved the metadata from the guest yet. */
60 Dragging = 0,
61 /** There has been a "dropped" action which indicates
62 * that the guest can continue sending more data (if any)
63 * over to the host, based on the (MIME) metadata. */
64 Dropped,
65 /** The operation has been canceled. */
66 Canceled,
67 /** An error occurred. */
68 Error,
69 /** The usual 32-bit type blow up. */
70 State_32BIT_Hack = 0x7fffffff
71 };
72
73public:
74
75 UIDnDMIMEData(UIDnDHandler *pDnDHandler, QStringList formats, Qt::DropAction defAction, Qt::DropActions actions);
76
77signals:
78
79 /**
80 * Signal which gets emitted if this object is ready to retrieve data
81 * in the specified MIME type.
82 *
83 * @returns IPRT status code.
84 * @param dropAction Drop action to perform.
85 * @param strMimeType MIME data type.
86 * @param vaType Qt's variant type of the MIME data.
87 * @param vaData Reference to QVariant where to store the retrieved data.
88 */
89 int sigGetData(Qt::DropAction dropAction, const QString &strMIMEType, QMetaType::Type vaType, QVariant &vaData) const;
90
91public slots:
92
93 /**
94 * Slot indicating that the current drop target has been changed.
95 * @note Does not work on OS X.
96 */
97 void sltDropActionChanged(Qt::DropAction dropAction);
98
99protected:
100 /** @name Overridden functions of QMimeData.
101 * @{ */
102 virtual QStringList formats(void) const RT_OVERRIDE;
103
104 virtual bool hasFormat(const QString &mimeType) const RT_OVERRIDE;
105
106 virtual QVariant retrieveData(const QString &strMIMEType, QMetaType metaType) const RT_OVERRIDE;
107 /** @} */
108
109public:
110
111 /** @name Internal helper functions.
112 * @{ */
113
114 /**
115 * Returns the matching meta type of a given MIME type.
116 *
117 * @returns Meta type.
118 * @param strMIMEType MIME type to retrieve variant type for.
119 */
120 static QMetaType::Type getMetaType(const QString &strMIMEType);
121
122 /**
123 * Fills a QVariant with data according to the given type and data.
124 *
125 * @returns IPRT status code.
126 * @param vecData Bytes data to set.
127 * @param strMIMEType MIME type to handle.
128 * @param vaType Variant type to set the variant to.
129 * @param vaData Variant holding the transformed result.
130 * Note: The variant's type might be different from the input vaType!
131 */
132 static int getDataAsVariant(const QVector<uint8_t> &vecData, const QString &strMIMEType, QMetaType::Type vaType, QVariant &vaData);
133 /** @} */
134
135protected:
136
137 /** Pointer to the parent. */
138 UIDnDHandler *m_pDnDHandler;
139 /** Available formats. */
140 QStringList m_lstFormats;
141 /** Default action on successful drop operation. */
142 Qt::DropAction m_defAction;
143 /** Current action, based on QDrag's status. */
144 Qt::DropAction m_curAction;
145 /** Available actions. */
146 Qt::DropActions m_actions;
147 /** The current dragging state. */
148 mutable State m_enmState;
149};
150
151#endif /* !FEQT_INCLUDED_SRC_runtime_UIDnDMIMEData_h */
152
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette