Update function names, indentation and added comments
This commit is contained in:
@@ -428,7 +428,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(__WXQT__)
|
#if defined(__WXQT__)
|
||||||
void DoSetDataFrom(const class QMimeData &mimeData, const wxDataFormat &format) wxOVERRIDE;
|
// Overridden to set text directly instead of extracting byte array
|
||||||
|
void QtSetDataSingleFormat(const class QMimeData &mimeData, const wxDataFormat &format) wxOVERRIDE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxString m_text;
|
wxString m_text;
|
||||||
|
@@ -21,11 +21,15 @@ public:
|
|||||||
virtual ~wxDataObject();
|
virtual ~wxDataObject();
|
||||||
|
|
||||||
virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const;
|
virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const;
|
||||||
virtual void AddDataTo(QMimeData &mimeData) const;
|
|
||||||
virtual bool SetDataFrom(const QMimeData &mimeData);
|
// Adds object's data to Qt mime data appropriately for type
|
||||||
|
virtual void QtAddDataTo(QMimeData &mimeData) const;
|
||||||
|
// Sets object's data from Qt mime data appropriately for type
|
||||||
|
virtual bool QtSetDataFrom(const QMimeData &mimeData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void DoSetDataFrom(const QMimeData &mimeData, const wxDataFormat &format);
|
// Sets object's data from Qt mime data in specific format
|
||||||
|
virtual void QtSetDataSingleFormat(const QMimeData &mimeData, const wxDataFormat &format);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_QT_DATAOBJ_H_
|
#endif // _WX_QT_DATAOBJ_H_
|
||||||
|
@@ -14,8 +14,10 @@ public:
|
|||||||
wxBitmapDataObject();
|
wxBitmapDataObject();
|
||||||
wxBitmapDataObject(const wxBitmap& bitmap);
|
wxBitmapDataObject(const wxBitmap& bitmap);
|
||||||
|
|
||||||
void AddDataTo(QMimeData &mimeData) const wxOVERRIDE;
|
// Overridden to set image data directly, which Qt will write to clipboard in many formats
|
||||||
bool SetDataFrom(const QMimeData &mimeData) wxOVERRIDE;
|
void QtAddDataTo(QMimeData &mimeData) const wxOVERRIDE;
|
||||||
|
// Overridden to retrieve image data from any format that Qt can read from clipboard
|
||||||
|
bool QtSetDataFrom(const QMimeData &mimeData) wxOVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@@ -88,8 +88,8 @@ bool wxClipboard::IsOpened() const
|
|||||||
|
|
||||||
bool wxClipboard::AddData( wxDataObject *data )
|
bool wxClipboard::AddData( wxDataObject *data )
|
||||||
{
|
{
|
||||||
QMimeData *MimeData = new QMimeData;
|
QMimeData *MimeData = new QMimeData;
|
||||||
data->AddDataTo(*MimeData);
|
data->QtAddDataTo(*MimeData);
|
||||||
delete data;
|
delete data;
|
||||||
|
|
||||||
QtClipboard->setMimeData(MimeData, (QClipboard::Mode)Mode());
|
QtClipboard->setMimeData(MimeData, (QClipboard::Mode)Mode());
|
||||||
@@ -113,7 +113,7 @@ bool wxClipboard::GetData( wxDataObject& data )
|
|||||||
wxCHECK_MSG( m_open, false, wxT("clipboard not open") );
|
wxCHECK_MSG( m_open, false, wxT("clipboard not open") );
|
||||||
|
|
||||||
const QMimeData *MimeData = QtClipboard->mimeData( (QClipboard::Mode)Mode() );
|
const QMimeData *MimeData = QtClipboard->mimeData( (QClipboard::Mode)Mode() );
|
||||||
return data.SetDataFrom(*MimeData);
|
return data.QtSetDataFrom(*MimeData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxClipboard::Clear()
|
void wxClipboard::Clear()
|
||||||
|
@@ -156,56 +156,56 @@ bool wxDataObject::IsSupportedFormat(const wxDataFormat& format,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataObject::AddDataTo(QMimeData &mimeData) const
|
void wxDataObject::QtAddDataTo(QMimeData &mimeData) const
|
||||||
{
|
{
|
||||||
const size_t count = GetFormatCount();
|
const size_t count = GetFormatCount();
|
||||||
wxDataFormatArray formats(count);
|
wxDataFormatArray formats(count);
|
||||||
GetAllFormats(formats.get());
|
GetAllFormats(formats.get());
|
||||||
|
|
||||||
// how to add timestamp?
|
// how to add timestamp?
|
||||||
|
|
||||||
// Unfortunately I cannot find a way to use the qt clipboard with
|
// Unfortunately I cannot find a way to use the qt clipboard with
|
||||||
// a callback to select the data type, so I must copy it all here
|
// a callback to select the data type, so I must copy it all here
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
const wxDataFormat format(formats[i]);
|
const wxDataFormat format(formats[i]);
|
||||||
|
|
||||||
int size = GetDataSize(format);
|
int size = GetDataSize(format);
|
||||||
if (!size)
|
if (!size)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QByteArray bytearray(size, 0);
|
QByteArray bytearray(size, 0);
|
||||||
GetDataHere(format, bytearray.data());
|
GetDataHere(format, bytearray.data());
|
||||||
mimeData.setData(wxQtConvertString(format.GetMimeType()), bytearray);
|
mimeData.setData(wxQtConvertString(format.GetMimeType()), bytearray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataObject::SetDataFrom(const QMimeData &mimeData)
|
bool wxDataObject::QtSetDataFrom(const QMimeData &mimeData)
|
||||||
{
|
{
|
||||||
const size_t count = GetFormatCount(Set);
|
const size_t count = GetFormatCount(Set);
|
||||||
wxDataFormatArray formats(count);
|
wxDataFormatArray formats(count);
|
||||||
GetAllFormats(formats.get(), Set);
|
GetAllFormats(formats.get(), Set);
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
const wxDataFormat format(formats[i]);
|
const wxDataFormat format(formats[i]);
|
||||||
|
|
||||||
// is this format supported by clipboard ?
|
// is this format supported by clipboard ?
|
||||||
if (!mimeData.hasFormat(wxQtConvertString(format.GetMimeType())))
|
if (!mimeData.hasFormat(wxQtConvertString(format.GetMimeType())))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DoSetDataFrom(mimeData, format);
|
QtSetDataSingleFormat(mimeData, format);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataObject::DoSetDataFrom(const QMimeData &mimeData, const wxDataFormat &format)
|
void wxDataObject::QtSetDataSingleFormat(const QMimeData &mimeData, const wxDataFormat &format)
|
||||||
{
|
{
|
||||||
QByteArray bytearray = mimeData.data(wxQtConvertString(format.GetMimeType()));
|
QByteArray bytearray = mimeData.data(wxQtConvertString(format.GetMimeType()));
|
||||||
SetData(format, bytearray.size(), bytearray.constData());
|
SetData(format, bytearray.size(), bytearray.constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################
|
//############################################################################
|
||||||
@@ -219,18 +219,18 @@ wxBitmapDataObject::wxBitmapDataObject( const wxBitmap &bitmap )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapDataObject::AddDataTo(QMimeData &mimeData) const
|
void wxBitmapDataObject::QtAddDataTo(QMimeData &mimeData) const
|
||||||
{
|
{
|
||||||
mimeData.setImageData(GetBitmap().GetHandle()->toImage());
|
mimeData.setImageData(GetBitmap().GetHandle()->toImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapDataObject::SetDataFrom(const QMimeData &mimeData)
|
bool wxBitmapDataObject::QtSetDataFrom(const QMimeData &mimeData)
|
||||||
{
|
{
|
||||||
if (!mimeData.hasImage())
|
if (!mimeData.hasImage())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SetBitmap(wxBitmap(QPixmap::fromImage(qvariant_cast<QImage>(mimeData.imageData()))));
|
SetBitmap(wxBitmap(QPixmap::fromImage(qvariant_cast<QImage>(mimeData.imageData()))));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
@@ -247,9 +247,9 @@ void wxTextDataObject::GetAllFormats(wxDataFormat *formats,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void wxTextDataObject::DoSetDataFrom(const QMimeData &mimeData, const wxDataFormat &WXUNUSED(format))
|
void wxTextDataObject::QtSetDataSingleFormat(const QMimeData &mimeData, const wxDataFormat &WXUNUSED(format))
|
||||||
{
|
{
|
||||||
SetText(wxQtConvertString(mimeData.text()));
|
SetText(wxQtConvertString(mimeData.text()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
|
Reference in New Issue
Block a user