Qt 4.8
Public Functions | List of all members
QMacPasteboardMimeUrl Class Reference
Inheritance diagram for QMacPasteboardMimeUrl:
QMacPasteboardMime

Public Functions

bool canConvert (const QString &mime, QString flav)
 Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false. More...
 
QList< QByteArrayconvertFromMime (const QString &mime, QVariant data, QString flav)
 Returns data converted from MIME type mime to Mac UTI flav. More...
 
QString convertorName ()
 Returns a name for the convertor. More...
 
QVariant convertToMime (const QString &mime, QList< QByteArray > data, QString flav)
 Returns data converted from Mac UTI flav to MIME type mime. More...
 
QString flavorFor (const QString &mime)
 Returns the Mac UTI used for MIME type mime, or 0 if this convertor does not support mime. More...
 
QString mimeFor (QString flav)
 Returns the MIME UTI used for Mac flavor flav, or 0 if this convertor does not support flav. More...
 
 QMacPasteboardMimeUrl ()
 
- Public Functions inherited from QMacPasteboardMime
 QMacPasteboardMime (char)
 Constructs a new conversion object of type t, adding it to the globally accessed list of available convertors. More...
 
virtual ~QMacPasteboardMime ()
 Destroys a conversion object, removing it from the global list of available convertors. More...
 

Additional Inherited Members

- Public Types inherited from QMacPasteboardMime
enum  QMacPasteboardMimeType {
  MIME_DND =0x01, MIME_CLIP =0x02, MIME_QT_CONVERTOR =0x04, MIME_QT3_CONVERTOR =0x08,
  MIME_ALL =MIME_DND|MIME_CLIP
}
 
- Static Public Functions inherited from QMacPasteboardMime
static QList< QMacPasteboardMime * > all (uchar)
 Returns a list of all currently defined QMacPasteboardMime objects of type t. More...
 
static QMacPasteboardMimeconvertor (uchar, const QString &mime, QString flav)
 Returns the most-recently created QMacPasteboardMime of type t that can convert between the mime and flav formats. More...
 
static QString flavorToMime (uchar, QString flav)
 Returns a MIME type of type t for flav, or 0 if none exists. More...
 
static void initialize ()
 This is an internal function. More...
 

Detailed Description

Definition at line 842 of file qmime_mac.cpp.

Constructors and Destructors

◆ QMacPasteboardMimeUrl()

QMacPasteboardMimeUrl::QMacPasteboardMimeUrl ( )
inline

Definition at line 844 of file qmime_mac.cpp.

QMacPasteboardMime(char)
Constructs a new conversion object of type t, adding it to the globally accessed list of available co...
Definition: qmime_mac.cpp:180

Functions

◆ canConvert()

bool QMacPasteboardMimeUrl::canConvert ( const QString mime,
QString  flav 
)
virtual

Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 873 of file qmime_mac.cpp.

874 {
875  return flav == QLatin1String("public.url")
876  && mime == QLatin1String("text/uri-list");
877 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ convertFromMime()

QList< QByteArray > QMacPasteboardMimeUrl::convertFromMime ( const QString mime,
QVariant  data,
QString  flav 
)
virtual

Returns data converted from MIME type mime to Mac UTI flav.

Note that Mac flavors must all be self-terminating. The return value may contain trailing data.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 895 of file qmime_mac.cpp.

896 {
897  QList<QByteArray> ret;
898  if (!canConvert(mime, flav))
899  return ret;
900 
901  QList<QVariant> urls = data.toList();
902  for(int i=0; i<urls.size(); ++i) {
903  QUrl url = urls.at(i).toUrl();
904  if (url.scheme().isEmpty())
905  url.setScheme(QLatin1String("file"));
906  if (url.scheme().toLower() == QLatin1String("file")) {
907  if (url.host().isEmpty())
908  url.setHost(QLatin1String("localhost"));
910  }
911  ret.append(url.toEncoded());
912  }
913  return ret;
914 }
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
void setPath(const QString &path)
Sets the path of the URL to path.
Definition: qurl.cpp:4960
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
QString host() const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4837
QString normalized(NormalizationForm mode) const Q_REQUIRED_RESULT
Returns the string in the given Unicode normalization mode.
Definition: qstring.cpp:6635
void setHost(const QString &host)
Sets the host of the URL to host.
Definition: qurl.cpp:4821
bool canConvert(const QString &mime, QString flav)
Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false...
Definition: qmime_mac.cpp:873
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QUrl toUrl() const
Returns the variant as a QUrl if the variant has type() Url ; otherwise returns an invalid QUrl...
Definition: qvariant.cpp:2528
QByteArray toEncoded(FormattingOptions options=None) const
Returns the encoded representation of the URL if it&#39;s valid; otherwise an empty QByteArray is returne...
Definition: qurl.cpp:5949
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
Definition: qurl.cpp:4533

◆ convertorName()

QString QMacPasteboardMimeUrl::convertorName ( )
virtual

Returns a name for the convertor.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 854 of file qmime_mac.cpp.

855 {
856  return QLatin1String("URL");
857 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ convertToMime()

QVariant QMacPasteboardMimeUrl::convertToMime ( const QString mime,
QList< QByteArray data,
QString  flav 
)
virtual

Returns data converted from Mac UTI flav to MIME type mime.

Note that Mac flavors must all be self-terminating. The input data may contain trailing data.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 879 of file qmime_mac.cpp.

880 {
881  if(!canConvert(mime, flav))
882  return QVariant();
883 
884  QList<QVariant> ret;
885  for (int i=0; i<data.size(); ++i) {
886  QUrl url = QUrl::fromEncoded(data.at(i));
887  if (url.host().toLower() == QLatin1String("localhost"))
888  url.setHost(QString());
890  ret.append(url);
891  }
892  return QVariant(ret);
893 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void setPath(const QString &path)
Sets the path of the URL to path.
Definition: qurl.cpp:4960
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString host() const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4837
QString normalized(NormalizationForm mode) const Q_REQUIRED_RESULT
Returns the string in the given Unicode normalization mode.
Definition: qstring.cpp:6635
void setHost(const QString &host)
Sets the host of the URL to host.
Definition: qurl.cpp:4821
bool canConvert(const QString &mime, QString flav)
Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false...
Definition: qmime_mac.cpp:873
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static QUrl fromEncoded(const QByteArray &url)
Parses input and returns the corresponding QUrl.
Definition: qurl.cpp:5964

◆ flavorFor()

QString QMacPasteboardMimeUrl::flavorFor ( const QString mime)
virtual

Returns the Mac UTI used for MIME type mime, or 0 if this convertor does not support mime.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 859 of file qmime_mac.cpp.

860 {
861  if(mime.startsWith(QLatin1String("text/uri-list")))
862  return QLatin1String("public.url");
863  return QString();
864 }
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654

◆ mimeFor()

QString QMacPasteboardMimeUrl::mimeFor ( QString  flav)
virtual

Returns the MIME UTI used for Mac flavor flav, or 0 if this convertor does not support flav.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 866 of file qmime_mac.cpp.

867 {
868  if(flav == QLatin1String("public.url"))
869  return QLatin1String("text/uri-list");
870  return QString();
871 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83

The documentation for this class was generated from the following file: