本文整理汇总了C++中QMimeData::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QMimeData::clear方法的具体用法?C++ QMimeData::clear怎么用?C++ QMimeData::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMimeData
的用法示例。
在下文中一共展示了QMimeData::clear方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setUrls
void tst_QMimeData::setUrls() const
{
QMimeData mimeData;
QList<QUrl> shortUrlList;
QList<QUrl> longUrlList;
// set up
shortUrlList += QUrl("http://qt-project.org");
longUrlList = shortUrlList;
longUrlList += QUrl("http://www.google.com");
// verify initial state
QCOMPARE(mimeData.hasUrls(), false);
// set a few, verify
mimeData.setUrls(shortUrlList);
QCOMPARE(mimeData.urls(), shortUrlList);
QCOMPARE(mimeData.text(), QString("http://qt-project.org"));
// change them, verify
mimeData.setUrls(longUrlList);
QCOMPARE(mimeData.urls(), longUrlList);
QCOMPARE(mimeData.text(), QString("http://qt-project.org\nhttp://www.google.com\n"));
// clear, verify
mimeData.clear();
QCOMPARE(mimeData.hasUrls(), false);
QCOMPARE(mimeData.hasText(), false);
}
示例2: setText
void tst_QMimeData::setText() const
{
QMimeData mimeData;
// verify initial state
QCOMPARE(mimeData.text(), QLatin1String(""));
QVERIFY(mimeData.hasText() == false);
// set, verify
mimeData.setText("pirates");
QVERIFY(mimeData.hasText());
QCOMPARE(mimeData.text(), QLatin1String("pirates"));
QCOMPARE(mimeData.text().toLatin1(), mimeData.data("text/plain"));
// reset, verify
mimeData.setText("ninjas");
QVERIFY(mimeData.hasText());
QCOMPARE(mimeData.text(), QLatin1String("ninjas"));
QCOMPARE(mimeData.text().toLatin1(), mimeData.data("text/plain"));
// clear, verify
mimeData.clear();
QCOMPARE(mimeData.text(), QLatin1String(""));
QVERIFY(mimeData.hasText() == false);
}
示例3: PasteFiles
void MainUI::PasteFiles(QString dir, QStringList raw){
qDebug() << "Paste Files:" << dir;
QStringList cut, copy, newcut, newcopy;
if(raw.isEmpty()){
//Pull info from the clipboard
const QMimeData *dat = QApplication::clipboard()->mimeData();
raw = QString(dat->data("x-special/lumina-copied-files")).split("\n");
}
if(!dir.endsWith("/")){ dir.append("/"); }
for(int i=0; i<raw.length(); i++){
if(raw[i].startsWith("cut::::")){
cut << raw[i].section("::::",1,50);
newcut << dir+raw[i].section("::::",1,50).section("/",-1);
}
else if(raw[i].startsWith("copy::::")){
copy << raw[i].section("::::",1,50);
newcopy<< dir+raw[i].section("::::",1,50).section("/",-1);
}
}
bool errs = false;
//Perform the copy/move operations
worker->pauseData = true; //pause any info requests
if(!copy.isEmpty()){
qDebug() << "Paste Copy:" << copy << "->" << newcopy;
FODialog dlg(this);
if( !dlg.CopyFiles(copy, newcopy) ){ return; } //cancelled
dlg.show();
dlg.exec();
errs = errs || !dlg.noerrors;
}
if(!cut.isEmpty()){
qDebug() << "Paste Cut:" << cut << "->" << newcut;
FODialog dlg(this);
if(!dlg.MoveFiles(cut, newcut) ){ return; } //cancelled
dlg.show();
dlg.exec();
errs = errs || !dlg.noerrors;
}
worker->pauseData = false; //resume info requests
//Modify the clipboard appropriately
if(!errs && !cut.isEmpty()){
//Now clear the clipboard since those old file locations are now invalid
QApplication::clipboard()->clear();
if(!copy.isEmpty()){
//There were also files copied: save those files back into the clipboard
QMimeData *dat = new QMimeData;
dat->clear();
dat->setData("x-special/lumina-copied-files", raw.filter("copy::::").join("\n").toLocal8Bit());
QApplication::clipboard()->setMimeData(dat);
}
}
//Update all the buttons to account for clipboard change
for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refresh(); }
}
示例4: clear
void tst_QMimeData::clear() const
{
QMimeData mimeData;
// set, clear, verify empty
mimeData.setData("text/plain", "pirates");
QVERIFY(mimeData.hasText());
mimeData.clear();
QVERIFY(mimeData.hasText() == false);
// repopulate, verify not empty
mimeData.setData("text/plain", "pirates");
QVERIFY(mimeData.hasText());
}
示例5: imageData
void tst_QMimeData::imageData() const
{
QMimeData mimeData;
// initial state
QCOMPARE(mimeData.imageData(), QVariant());
// set, test
mimeData.setImageData(QImage());
QVERIFY(mimeData.hasImage());
QCOMPARE(mimeData.imageData(), QVariant(QImage()));
// clear, verify
mimeData.clear();
QCOMPARE(mimeData.imageData(), QVariant());
}
示例6: hasFormat
void tst_QMimeData::hasFormat() const
{
QMimeData mimeData;
// initial state
QVERIFY(mimeData.hasFormat("text/plain") == false);
// add, verify
mimeData.setData("text/plain", "pirates");
QVERIFY(mimeData.hasFormat("text/plain"));
QVERIFY(mimeData.hasFormat("text/html") == false);
// clear, verify
mimeData.clear();
QVERIFY(mimeData.hasFormat("text/plain") == false);
QVERIFY(mimeData.hasFormat("text/html") == false);
}
示例7: hasImage
void tst_QMimeData::hasImage() const
{
QMimeData mimeData;
// initial state
QVERIFY(mimeData.hasImage() == false);
// add text, verify false
mimeData.setData("text/plain", "pirates");
QVERIFY(mimeData.hasImage() == false);
// add image
mimeData.setImageData(QImage());
QVERIFY(mimeData.hasImage());
// clear, verify
mimeData.clear();
QVERIFY(mimeData.hasImage() == false);
}
示例8: hasColor
void tst_QMimeData::hasColor() const
{
QMimeData mimeData;
// initial state
QVERIFY(mimeData.hasColor() == false);
// set, verify
mimeData.setColorData(QColor(Qt::red));
QVERIFY(mimeData.hasColor());
// clear, verify
mimeData.clear();
QVERIFY(mimeData.hasColor() == false);
// set something else, verify
mimeData.setData("text/plain", "pirates");
QVERIFY(mimeData.hasColor() == false);
}
示例9: CopyFiles
void MainUI::CopyFiles(QStringList list){
qDebug() << "Copy Files:" << list;
if(list.isEmpty()){ return; } //nothing selected
//Format the data string
QList<QUrl> urilist; //Also assemble a URI list for cros-app compat (no copy/cut distinguishing)
for(int i=0; i<list.length(); i++){
urilist << QUrl::fromLocalFile(list[i]);
list[i] = list[i].prepend("copy::::");
}
//Now save that data to the global clipboard
QMimeData *dat = new QMimeData;
dat->clear();
dat->setData("x-special/lumina-copied-files", list.join("\n").toLocal8Bit());
dat->setUrls(urilist); //the text/uri-list mimetype - built in Qt conversion/use
QApplication::clipboard()->clear();
QApplication::clipboard()->setMimeData(dat);
//Update all the buttons to account for clipboard change
for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refreshButtons(); }
}
示例10: formats
void tst_QMimeData::formats() const
{
QMimeData mimeData;
// set text, verify
mimeData.setData("text/plain", "pirates");
QCOMPARE(mimeData.formats(), QStringList() << "text/plain");
// set html, verify
mimeData.setData("text/html", "ninjas");
QCOMPARE(mimeData.formats(), QStringList() << "text/plain" << "text/html");
// clear, verify
mimeData.clear();
QCOMPARE(mimeData.formats(), QStringList());
// set an odd format, verify
mimeData.setData("foo/bar", "somevalue");
QCOMPARE(mimeData.formats(), QStringList() << "foo/bar");
}
示例11: hasHtml
void tst_QMimeData::hasHtml() const
{
QMimeData mimeData;
// initial state
QVERIFY(mimeData.hasHtml() == false);
// add plain, verify false
mimeData.setData("text/plain", "pirates");
QVERIFY(mimeData.hasHtml() == false);
// add html, verify
mimeData.setData("text/html", "ninjas");
QVERIFY(mimeData.hasHtml());
// clear, verify
mimeData.clear();
QVERIFY(mimeData.hasHtml() == false);
// readd, verify
mimeData.setData("text/html", "ninjas");
QVERIFY(mimeData.hasHtml());
}