support url lists as well
TODO: the DeclarativeMimeData object shouldn't be a mimedata itself, but a container object. in this way it will be possible to reimplement all the methods, also non virtuals
This commit is contained in:
parent
32b9547634
commit
2c7e559f04
@ -68,7 +68,7 @@ DeclarativeMimeData::DeclarativeMimeData(const QMimeData* copy)
|
|||||||
QUrl DeclarativeMimeData::url() const
|
QUrl DeclarativeMimeData::url() const
|
||||||
{
|
{
|
||||||
if ( this->hasUrls() && !this->urls().isEmpty()) {
|
if ( this->hasUrls() && !this->urls().isEmpty()) {
|
||||||
return urls().first();
|
return QMimeData::urls().first();
|
||||||
}
|
}
|
||||||
return QUrl();
|
return QUrl();
|
||||||
}
|
}
|
||||||
@ -79,10 +79,29 @@ void DeclarativeMimeData::setUrl(const QUrl &url)
|
|||||||
|
|
||||||
QList<QUrl> urlList;
|
QList<QUrl> urlList;
|
||||||
urlList.append(url);
|
urlList.append(url);
|
||||||
setUrls(urlList);
|
QMimeData::setUrls(urlList);
|
||||||
emit urlChanged();
|
emit urlChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantList DeclarativeMimeData::urls() const
|
||||||
|
{
|
||||||
|
QVariantList varUrls;
|
||||||
|
foreach (const QUrl &url, QMimeData::urls()) {
|
||||||
|
varUrls << url;
|
||||||
|
}
|
||||||
|
return varUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeMimeData::setUrls(const QVariantList &urls)
|
||||||
|
{
|
||||||
|
QList<QUrl> urlList;
|
||||||
|
foreach (const QVariant &varUrl, urls) {
|
||||||
|
urlList << varUrl.value<QUrl>();
|
||||||
|
}
|
||||||
|
QMimeData::setUrls(urlList);
|
||||||
|
emit urlsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
// color
|
// color
|
||||||
QColor DeclarativeMimeData::color() const
|
QColor DeclarativeMimeData::color() const
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,8 @@ class DeclarativeMimeData : public QMimeData
|
|||||||
|
|
||||||
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
||||||
Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged)
|
Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged)
|
||||||
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) //TODO: use QDeclarativeListProperty<QUrls> to return the whole list instead of only the first url
|
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
|
||||||
|
Q_PROPERTY(QVariantList urls READ urls WRITE setUrls NOTIFY urlsChanged)
|
||||||
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
||||||
Q_PROPERTY(QDeclarativeItem* source READ source WRITE setSource NOTIFY sourceChanged)
|
Q_PROPERTY(QDeclarativeItem* source READ source WRITE setSource NOTIFY sourceChanged)
|
||||||
//TODO: Image property
|
//TODO: Image property
|
||||||
@ -47,12 +48,16 @@ public:
|
|||||||
QUrl url() const;
|
QUrl url() const;
|
||||||
void setUrl(const QUrl &url);
|
void setUrl(const QUrl &url);
|
||||||
|
|
||||||
|
QVariantList urls() const;
|
||||||
|
void setUrls(const QVariantList &urls);
|
||||||
|
|
||||||
QColor color() const;
|
QColor color() const;
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
|
|
||||||
QDeclarativeItem* source() const;
|
QDeclarativeItem* source() const;
|
||||||
void setSource(QDeclarativeItem* source);
|
void setSource(QDeclarativeItem* source);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QString text() const; //TODO: Reimplement this to issue the onChanged signals
|
QString text() const; //TODO: Reimplement this to issue the onChanged signals
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
@ -64,12 +69,12 @@ signals:
|
|||||||
void textChanged(); //FIXME not being used
|
void textChanged(); //FIXME not being used
|
||||||
void htmlChanged(); //FIXME not being used
|
void htmlChanged(); //FIXME not being used
|
||||||
void urlChanged();
|
void urlChanged();
|
||||||
|
void urlsChanged();
|
||||||
void colorChanged();
|
void colorChanged();
|
||||||
void sourceChanged();
|
void sourceChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDeclarativeItem* m_source;
|
QDeclarativeItem* m_source;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DECLARATIVEMIMEDATA_H
|
#endif // DECLARATIVEMIMEDATA_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user