本文整理汇总了C++中KFileDialog::selectedURL方法的典型用法代码示例。如果您正苦于以下问题:C++ KFileDialog::selectedURL方法的具体用法?C++ KFileDialog::selectedURL怎么用?C++ KFileDialog::selectedURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KFileDialog
的用法示例。
在下文中一共展示了KFileDialog::selectedURL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveResults
void KfindWindow::saveResults()
{
TQListViewItem *item;
KFileDialog *dlg = new KFileDialog(TQString::null, TQString::null, this,
"filedialog", true);
dlg->setOperationMode (KFileDialog::Saving);
dlg->setCaption(i18n("Save Results As"));
TQStringList list;
list << "text/plain" << "text/html";
dlg->setOperationMode(KFileDialog::Saving);
dlg->setMimeFilter(list, TQString("text/plain"));
dlg->exec();
KURL u = dlg->selectedURL();
KMimeType::Ptr mimeType = dlg->currentFilterMimeType();
delete dlg;
if (!u.isValid() || !u.isLocalFile())
return;
TQString filename = u.path();
TQFile file(filename);
if ( !file.open(IO_WriteOnly) )
KMessageBox::error(parentWidget(),
i18n("Unable to save results."));
else {
TQTextStream stream( &file );
stream.setEncoding( TQTextStream::Locale );
if ( mimeType->name() == "text/html") {
stream << TQString::fromLatin1("<HTML><HEAD>\n"
"<!DOCTYPE %1>\n"
"<TITLE>%2</TITLE></HEAD>\n"
"<BODY><H1>%3</H1>"
"<DL><p>\n")
.arg(i18n("KFind Results File"))
.arg(i18n("KFind Results File"))
.arg(i18n("KFind Results File"));
item = firstChild();
while(item != NULL)
{
TQString path=((KfFileLVI*)item)->fileitem.url().url();
TQString pretty=((KfFileLVI*)item)->fileitem.url().htmlURL();
stream << TQString::fromLatin1("<DT><A HREF=\"") << path
<< TQString::fromLatin1("\">") << pretty
<< TQString::fromLatin1("</A>\n");
item = item->nextSibling();
}
stream << TQString::fromLatin1("</DL><P></BODY></HTML>\n");
}
else {
item = firstChild();
while(item != NULL)
{
TQString path=((KfFileLVI*)item)->fileitem.url().url();
stream << path << endl;
item = item->nextSibling();
}
}
file.close();
KMessageBox::information(parentWidget(),
i18n("Results were saved to file\n")+
filename);
}
}