Ejemplo n.º 1
0
void PoTD::saveFile()
{
    KFileDialog *fd = qobject_cast<KFileDialog *>(sender());
    const QString &path = fd->selectedFile();
    if (path.isEmpty() || m_provider.isEmpty()) {
        return;
    }

    new SaveRunnable(dataEngine(QLatin1String("potd")), m_provider, path);
}
Ejemplo n.º 2
0
void KPrWebPresentationCreateDialog::saveConfig()
{
    QString filename = webPres.getConfig();
    if ( QFileInfo( filename ).exists() )
        filename = QFileInfo( filename ).absFilePath();
    else
        filename = QString::null;

    KFileDialog fd (filename, i18n("*.kpweb|KPresenter Web-Presentation (*.kpweb)"),
                    0/*parent*/, 0/*name*/, true/*modal*/);
    fd.setCaption (i18n ("Save Web Presentation Configuration"));
    fd.setOperationMode (KFileDialog::Saving);
    fd.setMode (KFile::File | KFile::LocalOnly);

    if (fd.exec ())
    {
        webPres.setConfig( fd.selectedFile () );
        webPres.saveConfig();
    }
}
Ejemplo n.º 3
0
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;
}