本文整理汇总了C++中KFileDialog::setObjectName方法的典型用法代码示例。如果您正苦于以下问题:C++ KFileDialog::setObjectName方法的具体用法?C++ KFileDialog::setObjectName怎么用?C++ KFileDialog::setObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KFileDialog
的用法示例。
在下文中一共展示了KFileDialog::setObjectName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: importDocument
void KoPAView::importDocument()
{
KFileDialog *dialog = new KFileDialog( KUrl("kfiledialog:///OpenDialog"),QString(), this );
dialog->setObjectName( "file dialog" );
dialog->setMode( KFile::File );
if ( d->doc->pageType() == KoPageApp::Slide ) {
dialog->setCaption(i18n("Import Slideshow"));
}
else {
dialog->setCaption(i18n("Import Document"));
}
// TODO make it possible to select also other supported types (then the default format) here.
// this needs to go via the filters to get the file in the correct format.
// For now we only support the native mime types
QStringList mimeFilter;
#if 1
mimeFilter << KoOdf::mimeType( d->doc->documentType() ) << KoOdf::templateMimeType( d->doc->documentType() );
#else
mimeFilter = KoFilterManager::mimeFilter( KoDocument::readNativeFormatMimeType(d->doc->componentData()), KoFilterManager::Import,
KoDocument::readExtraNativeMimeTypes() );
#endif
dialog->setMimeFilter( mimeFilter );
if (dialog->exec() == QDialog::Accepted) {
KUrl url(dialog->selectedUrl());
QString tmpFile;
if ( KIO::NetAccess::download( url, tmpFile, 0 ) ) {
QFile file( tmpFile );
file.open( QIODevice::ReadOnly );
QByteArray ba;
ba = file.readAll();
// set the correct mime type as otherwise it does not find the correct tag when loading
QMimeData data;
data.setData( KoOdf::mimeType( d->doc->documentType() ), ba);
KoPAPastePage paste( d->doc,d->activePage );
if ( ! paste.paste( d->doc->documentType(), &data ) ) {
KMessageBox::error(0, i18n("Could not import\n%1", url.pathOrUrl()));
}
}
else {
KMessageBox::error(0, i18n("Could not import\n%1", url.pathOrUrl()));
}
}
delete dialog;
}
示例2: exportRecipes
void RecipeActionsHandler::exportRecipes( const QList<int> &ids, const QString & caption, const QString &selection, RecipeDB *database )
{
KFileDialog * fd = new KFileDialog( KUrl(),
QString( "*.kre|%1 (*.kre)\n"
"*.kreml|Krecipes (*.kreml)\n"
"*.txt|%3 (*.txt)\n"
//"*.cml|CookML (*.cml)\n"
"*|%4\n"
"*.html|%2 (*.html)\n"
"*.mmf|Meal-Master (*.mmf)\n"
"*.xml|RecipeML (*.xml)\n"
"*.mx2|MasterCook (*.mx2)\n"
"*.rk|Rezkonv (*.rk)"
).arg( i18n( "Compressed Krecipes format" ) )
.arg( i18n( "Web page" ) )
.arg( i18n("Plain Text") )
.arg( i18n("Web Book") ),
0 );
fd->setObjectName( "export_dlg" );
fd->setModal( true );
fd->setCaption( caption );
fd->setOperationMode( KFileDialog::Saving );
fd->setSelection( selection );
fd->setMode( KFile::File | KFile::Directory );
if ( fd->exec() == KFileDialog::Accepted ) {
QString fileName = fd->selectedFile();
if ( !fileName.isEmpty() ) {
BaseExporter * exporter;
if ( fd->currentFilter() == "*.xml" )
exporter = new RecipeMLExporter( fileName, fd->currentFilter() );
else if ( fd->currentFilter() == "*.mx2" )
exporter = new MX2Exporter( fileName, fd->currentFilter() );
else if ( fd->currentFilter() == "*.mmf" )
exporter = new MMFExporter( fileName, fd->currentFilter() );
else if ( fd->currentFilter() == "*" ) {
CategoryTree *cat_structure = new CategoryTree;
database->loadCategories( cat_structure );
exporter = new HTMLBookExporter( cat_structure, fd->baseUrl().path(), "*.html" );
}
else if ( fd->currentFilter() == "*.html" ) {
exporter = new HTMLExporter( fileName, fd->currentFilter() );
XSLTExporter exporter_junk( fileName, "*.html" ); // AGH, i don't get build systems...
}
else if ( fd->currentFilter() == "*.cml" )
exporter = new CookMLExporter( fileName, fd->currentFilter() );
else if ( fd->currentFilter() == "*.txt" )
exporter = new PlainTextExporter( fileName, fd->currentFilter() );
else if ( fd->currentFilter() == "*.rk" )
exporter = new RezkonvExporter( fileName, fd->currentFilter() );
else {
CategoryTree *cat_structure = new CategoryTree;
database->loadCategories( cat_structure );
exporter = new KreExporter( cat_structure, fileName, fd->currentFilter() );
}
int overwrite = -1;
if ( QFile::exists( exporter->fileName() ) ) {
overwrite = KMessageBox::warningYesNo( 0, i18n( "File \"%1\" exists. Are you sure you want to overwrite it?" , exporter->fileName()), i18nc( "@title:window", "Saving recipe" ) );
}
if ( overwrite == KMessageBox::Yes || overwrite == -1 ) {
KProgressDialog progress_dialog( 0, QString(), i18nc( "@info:progress", "Saving recipes..." ) );
progress_dialog.setObjectName("export_progress_dialog");
exporter->exporter( ids, database, &progress_dialog );
}
delete exporter;
}
}
delete fd;
}