Make it possible to fetch data for a said format

This commit is contained in:
Aleix Pol 2014-01-17 17:24:04 +01:00
parent f517765bd0
commit 6b86584dd0
2 changed files with 10 additions and 2 deletions

View File

@ -54,11 +54,18 @@ QClipboard::Mode Clipboard::mode() const
return m_mode;
}
QVariant Clipboard::content() const
QVariant Clipboard::contentFormat(const QString &format) const
{
const QMimeData* data = m_clipboard->mimeData(m_mode);
return data->data(data->formats().first());
QByteArray variant = data->data(format.isEmpty() ? data->formats().first(): format);
return variant;
}
QVariant Clipboard::content() const
{
return contentFormat(m_clipboard->mimeData(m_mode)->formats().first());
}
void Clipboard::setContent(const QVariant &content)

View File

@ -50,6 +50,7 @@ class Clipboard : public QObject
QClipboard::Mode mode() const;
void setMode(QClipboard::Mode mode);
Q_SCRIPTABLE QVariant contentFormat(const QString &format) const;
QVariant content() const;
void setContent(const QVariant &content);