Beispiel #1
0
bool KugarPart::initDoc( InitDocFlags /*flags*/, QWidget* /*parentWidget*/ )
{
    QString filename;
    bool ok = false;

    KFileDialog *dialog = 
        new KFileDialog( QString::null, QString::null, 0L, "file dialog", true );
    dialog->setMimeFilter( KoFilterManager::mimeFilter( KoDocument::readNativeFormatMimeType(),
                           KoFilterManager::Import ) );
    if ( dialog->exec() != QDialog::Accepted )
    {
        delete dialog;
        return false;
    }

    KURL url( dialog->selectedURL() );
    delete dialog;

    if ( url.isEmpty() )
        return false;

    if ( url.isValid() )
    {
        ok = openURL( url );
    }
    return ok;

    // If nothing is loaded, do initialize here
    return TRUE;
}
Beispiel #2
0
void KMSoundTestWidget::openSoundDialog( KURLRequester * )
{
    static bool init = true;
    if ( !init )
        return;

    init = false;

    KFileDialog *fileDialog = m_urlRequester->fileDialog();
    fileDialog->setCaption( i18n("Select Sound File") );
    QStringList filters;
    filters << "audio/x-wav" << "audio/x-mp3" << "application/x-ogg"
            << "audio/x-adpcm";
    fileDialog->setMimeFilter( filters );

   QStringList soundDirs = KGlobal::dirs()->resourceDirs( "sound" );

    if ( !soundDirs.isEmpty() ) {
        KURL soundURL;
        QDir dir;
        dir.setFilter( QDir::Files | QDir::Readable );
        QStringList::ConstIterator it = soundDirs.begin();
        while ( it != soundDirs.end() ) {
            dir = *it;
            if ( dir.isReadable() && dir.count() > 2 ) {
                soundURL.setPath( *it );
                fileDialog->setURL( soundURL );
                break;
            }
            ++it;
        }
    }

}
Beispiel #3
0
void
APG::PresetModel::exportActive()
{
    KFileDialog* d = new ExportDialog( activePreset() );
    connect( d, SIGNAL( pleaseExport( const QString&, const QList<APG::PresetPtr> ) ),
          this, SLOT( savePresetsToXml( const QString&, const QList<APG::PresetPtr> ) ) );
    d->exec();
}
Beispiel #4
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);
}
Beispiel #5
0
void PoTD::getSaveFileLocation()
{
    if (m_provider.isNull()) {
        return;
    }

    KFileDialog *fd = new KFileDialog(KUrl("kfiledialog:///frameplasmoid"), QString(), 0);
    fd->setOperationMode(KFileDialog::Saving);
    fd->setMode(KFile::LocalOnly);
    fd->setAttribute(Qt::WA_DeleteOnClose, true);
    connect(fd, SIGNAL(okClicked()), this, SLOT(saveFile()));
    fd->show();
}
Beispiel #6
0
HENHMETAFILE QueryOpenEMFFile(TCHAR szFileName[])
{
	KFileDialog fd;

	if ( fd.GetOpenFileName(NULL, _T("emf|spl"), _T("Enhanced Metafiles|Win NT/2000 EMF Spool Files")) )
	{
		if ( szFileName )
			_tcscpy(szFileName, fd.m_TitleName);
		
		return  GetEnhMetaFile(fd.m_TitleName);
	}
	else
		return NULL;
}
Beispiel #7
0
HDC QuerySaveEMFFile(const TCHAR * description, const RECT * rcFrame, TCHAR szFileName[])
{
	KFileDialog fd;

	if ( fd.GetSaveFileName(NULL, _T("emf"), _T("Enhanced Metafiles")) )
	{
		if ( szFileName )
			_tcscpy(szFileName, fd.m_TitleName);

		return CreateEnhMetaFile(NULL, fd.m_TitleName, rcFrame, description);
	}
	else
		return NULL;
}
Beispiel #8
0
void KFDTest::doit()
{
    KFileDialog *dlg = new KFileDialog( m_startDir, QString(), 0L);
    dlg->setMode( KFile::File);
    dlg->setOperationMode( KFileDialog::Saving );
    QStringList filter;
    filter << "all/allfiles" << "text/plain";
    dlg->setMimeFilter( filter, "all/allfiles" );

    if ( dlg->exec() == KDialog::Accepted )
    {
        KMessageBox::information(0, QString::fromLatin1("You selected the file: %1").arg( dlg->selectedUrl().prettyUrl() ));
    }

//     qApp->quit();
}
Beispiel #9
0
void Demo_WritePort(void)
{
	KFileDialog fd;

	if ( fd.GetOpenFileName(NULL, "prn", "Raw printer data") )
	{
		HANDLE hPort = CreateFile("lpt1:", GENERIC_WRITE, FILE_SHARE_READ,
		                   NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

		if ( hPort!=INVALID_HANDLE_VALUE )
		{
			SendFile(hPort, fd.m_TitleName, false);
			CloseHandle(hPort);
		}
	}
}
void KstVectorDialogI::selectingFolder()
{
  QString strFolder = _w->FileName->url();
  KFileDialog *fileDlg = _w->FileName->fileDialog();
  QFileInfo fileInfo(strFolder);

  if (fileDlg) {
    if (fileInfo.isDir()) {
      QDir dir(strFolder);

      if (dir.cdUp()) {
        fileDlg->setURL(KURL(dir.absPath()));
      }
    }
  }
}
Beispiel #11
0
void Demo_WritePrinter(void)
{
	PRINTDLG  pd;

	memset(&pd, 0, sizeof(PRINTDLG));
	pd.lStructSize = sizeof(PRINTDLG);

	if ( PrintDlg(&pd)==IDOK )
	{
		HANDLE hPrinter;

		DEVMODE * pDevMode = (DEVMODE *) GlobalLock(pd.hDevMode);

		PRINTER_DEFAULTS prn;
		prn.pDatatype     = "NT EMF 1.008";
		prn.pDevMode      = pDevMode;
		prn.DesiredAccess = PRINTER_ACCESS_USE;

		if ( OpenPrinter((char *) pDevMode->dmDeviceName, & hPrinter, & prn) )
		{
			KFileDialog fd;

			if ( fd.GetOpenFileName(NULL, "spl", "Windows 2000 EMF Spool file") )
			{
				DOC_INFO_1 docinfo;

				docinfo.pDocName    = "Testing WritePrinter";
				docinfo.pOutputFile = NULL;
				docinfo.pDatatype   = "NT EMF 1.008";

				StartDocPrinter(hPrinter, 1, (BYTE *) & docinfo);
				StartPagePrinter(hPrinter);
				
				SendFile(hPrinter, fd.m_TitleName, true);
				
				EndPagePrinter(hPrinter);
				EndDocPrinter(hPrinter);
			}

			ClosePrinter(hPrinter);
		}

		if ( pd.hDevMode )	GlobalFree(pd.hDevMode);
		if ( pd.hDevNames ) GlobalFree(pd.hDevNames);
	}
}
Beispiel #12
0
void KFindTreeView::saveResults()
{
    KFileDialog *dlg = new KFileDialog(QUrl(), QString(), this);
    dlg->setOperationMode (KFileDialog::Saving);
    dlg->setWindowTitle( i18nc("@title:window", "Save Results As") );
    dlg->setFilter( QString::fromLatin1("*.html|%1\n*.txt|%2").arg( i18n("HTML page"), i18n("Text file") ) );
    dlg->setConfirmOverwrite(true);    
    
    dlg->exec();

    QUrl u = dlg->selectedUrl();
    
    QString filter = dlg->currentFilter();
    delete dlg;

    if (!u.isValid() || !u.isLocalFile())
        return;

    QString filename = u.toLocalFile();

    QFile file(filename);

    if ( !file.open(QIODevice::WriteOnly) )
    {
        KMessageBox::error(parentWidget(),
                i18n("Unable to save results."));
    }
    else
    {
        QTextStream stream( &file );
        stream.setCodec( QTextCodec::codecForLocale() );
        
        QList<KFindItem> itemList = m_model->getItemList();
        if ( filter == QLatin1String("*.html") ) 
        {
            stream << QString::fromLatin1("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
            "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
                            "<head>\n"
                            "<title>%2</title></head>\n"
                            "<meta charset=\"%1\">\n"
                            "<body>\n<h1>%2</h1>\n"
                            "<dl>\n")
            .arg(QString::fromLatin1(QTextCodec::codecForLocale()->name()))
            .arg(i18n("KFind Results File"));

            Q_FOREACH( const KFindItem & item, itemList )
            {
                const KFileItem fileItem = item.getFileItem();
                stream << QString::fromLatin1("<dt><a href=\"%1\">%2</a></dt>\n").arg( 
                    fileItem.url().url(), fileItem.url().toDisplayString() );

            }
            stream << QString::fromLatin1("</dl>\n</body>\n</html>\n");
        }
        else 
        {
Beispiel #13
0
BOOL SaveDIBToFile(const TCHAR * pFileName, const BITMAPINFO * pBMI, const void * pBits)
{
	KFileDialog fi;

	if ( pFileName==NULL )
	{
		if ( ! fi.GetSaveFileName(NULL, _T("bmp"), _T("Bitmap Files")) )
			return FALSE;

		pFileName = fi.m_TitleName;
	}

	HANDLE handle = CreateFile(pFileName, GENERIC_WRITE, FILE_SHARE_READ, 
		NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
	
	if ( handle == INVALID_HANDLE_VALUE )
		return FALSE;

	BITMAPFILEHEADER bmFH;

	int nHeadSize = sizeof(BITMAPINFOHEADER) + 
						sizeof(RGBQUAD) * GetDIBColorCount(pBMI->bmiHeader);

	bmFH.bfType      = 0x4D42;
	bmFH.bfSize      = nHeadSize + GetDIBPixelSize(pBMI->bmiHeader);
	bmFH.bfReserved1 = 0;
	bmFH.bfReserved2 = 0;
	bmFH.bfOffBits   = nHeadSize + sizeof(BITMAPFILEHEADER);

	DWORD dwRead = 0;
	WriteFile(handle, & bmFH, sizeof(bmFH), & dwRead, NULL);

	if ( pBits==NULL ) // packed DIB
		pBits = (BYTE *) pBMI + nHeadSize;
	
	WriteFile(handle, pBMI,  nHeadSize,						   & dwRead, NULL);
	WriteFile(handle, pBits, GetDIBPixelSize(pBMI->bmiHeader), & dwRead, NULL);

	CloseHandle(handle);

	return TRUE;
}
Beispiel #14
0
KURL ScriptGUIClient::openScriptFile(const QString& caption)
{
    QStringList mimetypes;
    QMap<QString, InterpreterInfo*> infos = Manager::scriptManager()->getInterpreterInfos();
    for(QMap<QString, InterpreterInfo*>::Iterator it = infos.begin(); it != infos.end(); ++it)
        mimetypes.append( it.data()->getMimeTypes().join(" ").stripWhiteSpace() );

    KFileDialog* filedialog = new KFileDialog(
        QString::null, // startdir
        mimetypes.join(" "), // filter
        0, // parent widget
        "ScriptGUIClientFileDialog", // name
        true // modal
    );
    if(! caption.isNull())
        filedialog->setCaption(caption);
    if( filedialog->exec() )
        return filedialog->selectedURL();
    return KURL();
}
Beispiel #15
0
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;
}
Beispiel #16
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();
    }
}
Beispiel #17
0
LRESULT KEMFView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch( uMsg )
	{
		case WM_CREATE:
			m_hWnd		= hWnd;
			m_hViewMenu = LoadMenu(m_hInst, MAKEINTRESOURCE(IDR_VIEWER));

			{
				RECT rect;

				GetClientRect(m_hWnd, & rect);
				 m_emftree.Create(hWnd, 101, 0, 0, m_nDivision, rect.bottom, m_hInst);

				m_emfpanel.CreateEx(WS_EX_CLIENTEDGE, "EMFPanel", NULL, WS_VISIBLE | WS_BORDER | WS_CHILD, 
						m_nDivision+3, 0, rect.right - m_nDivision+3, rect.bottom, hWnd, NULL, m_hInst);

				{
					KEmfDC emfdc;

					if ( m_emfpanel.m_hEmf )
						emfdc.DeCompile(NULL, m_emfpanel.m_hEmf, & m_emftree);
					else
						emfdc.DeCompile(NULL, m_FileName, & m_emftree, m_emfpanel.m_hEmf);
				}

				// palette message handling is in KWindow class, which needs m_hPalette to be set
				{
					HDC hDC = GetDC(hWnd);
					
					m_hPalette = GetEMFPalette(m_emfpanel.m_hEmf, hDC);

					m_emfpanel.m_hPalette = m_hPalette;
					ReleaseDC(hWnd, hDC);
				}
			}

			return 0;

		case WM_SIZE:
			MoveWindow( m_emftree.m_hWnd,  0, 0, m_nDivision, HIWORD(lParam), TRUE);	
			MoveWindow(m_emfpanel.m_hWnd, m_nDivision+3, 0, LOWORD(lParam)-m_nDivision+3, HIWORD(lParam), TRUE);	
			return 0;

		case WM_MOUSEMOVE: // handle split window adjustment
			if ( wParam & MK_LBUTTON )
			{
				if ( GetCapture() != hWnd )
					SetCapture(hWnd);
			
				RECT rect;
				GetClientRect(hWnd, & rect);

				m_nDivision = LOWORD(lParam);
				SendMessage(hWnd, WM_SIZE, 0, MAKELONG(rect.right, rect.bottom));
			}
			else
				if ( GetCapture() == hWnd )
					ReleaseCapture();
			return 0;

		case WM_COMMAND:
			switch ( LOWORD(wParam) )
			{
				case IDM_FILE_SAVETEXT:
					{
						KFileDialog fd;
						ofstream    out;

						if ( fd.GetSaveFileName(NULL, "txt", "Text Files") )
						{
							out.open(fd.m_TitleName);
							SimpleEnumerateEMF(m_emfpanel.m_hEmf, out);
							out.close();
						}
						return 0;
					}

				case IDM_FILE_DECOMPILE:
					{
						KFileDialog fd;

						if ( fd.GetSaveFileName(NULL, "cpp", "C++ Programs") )
						{
							KEmfDC dc;
							dc.DeCompile(fd.m_TitleName, m_emfpanel.m_hEmf, NULL);
						}
					}
					return 0;

				case IDM_FILE_FILTER:
					{
						KGrayEMF gray;

						HENHMETAFILE hEmf = FilterEMF(m_emfpanel.m_hEmf, gray);
						DeleteEnhMetaFile(hEmf);
					}
					break;

				case IDM_VIEW_DELAY:
					{
						m_emfpanel.m_mode = 1;
						m_emfpanel.SetZoom(0, true);
					}
					return 0;


				case IDM_VIEW_GRAY:
					{
						m_emfpanel.m_mode = 2;
						m_emfpanel.SetZoom(0, true);
					}
					return 0;

				case IDM_VIEW_TRACE:
					{
						m_emfpanel.m_mode = 3;
						m_emfpanel.SetZoom(0, true);
					}
					return 0;

				case IDM_VIEW_ZOOM50:
					m_emfpanel.SetZoom(50); return 0;

				case IDM_VIEW_ZOOM100:
					m_emfpanel.SetZoom(100); return 0;

				case IDM_VIEW_ZOOM200:
					m_emfpanel.SetZoom(200); return 0;
			}

		case WM_PALETTECHANGED:
			return OnPaletteChanged(hWnd, wParam);

		case WM_QUERYNEWPALETTE:
			return OnQueryNewPalette();
			
		default:
			return CommonMDIChildProc(hWnd, uMsg, wParam, lParam, m_hViewMenu, 4);
	}
}
Beispiel #18
0
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);
  }
}
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;
}
Beispiel #20
0
int main(int argc, char **argv)
{
    KCmdLineOptions options;
    options.add("+[cmd]");
    options.add("+[url]");

    KCmdLineArgs::init(argc, argv, "kfstest", 0, ki18n("kfstest"), "0", ki18n("test app"));
    KCmdLineArgs::addCmdLineOptions(options);
    KApplication a;
    a.setQuitOnLastWindowClosed(false);

    QString name1;
    QStringList names;

    QString argv1;
    KUrl startDir;
    if (argc > 1)
        argv1 = QLatin1String(argv[1]);
    if ( argc > 2 )
        startDir = KUrl( argv[2] );

#if 0 // SPLIT-TODO
    if (argv1 == QLatin1String("diroperator")) {
        KDirOperator *op = new KDirOperator(startDir, 0);
        KConfigGroup grp(KGlobal::config(), "TestGroup" );
        op->setViewConfig(grp);
        op->setView(KFile::Simple);
        op->show();
        a.exec();
    } else
#endif
    if (argv1 == QLatin1String("localonly")) {
        QString name = KFileDialog::getOpenFileName(startDir);
        qDebug("filename=%s",name.toLatin1().constData());
    }
    else if (argv1 == QLatin1String("oneurl")) {
        KUrl url = KFileDialog::getOpenUrl(startDir);
        qDebug() << "url=" << url;
    }

    else if (argv1 == QLatin1String("existingDirectoryUrl")) {
        KUrl url = KFileDialog::getExistingDirectoryUrl();
        qDebug("URL=%s",url.url().toLatin1().constData());
        name1 = url.url();
    }

    else if (argv1 == QLatin1String("preview")) {
        KUrl u =  KFileDialog::getImageOpenUrl();
        qDebug("filename=%s", u.url().toLatin1().constData());
    }

    else if (argv1 == QLatin1String("preselect")) {
        names = KFileDialog::getOpenFileNames(KUrl("/etc/passwd"));
        QStringList::Iterator it = names.begin();
        while ( it != names.end() ) {
            qDebug("selected file: %s", (*it).toLatin1().constData());
            ++it;
        }
    }

    else if (argv1 == QLatin1String("dirs"))
        name1 = KFileDialog::getExistingDirectory();

    else if (argv1 == QLatin1String("heap")) {
        KFileDialog *dlg = new KFileDialog( startDir, QString(), 0L);
        dlg->setMode( KFile::File);
        dlg->setOperationMode( KFileDialog::Saving );
        QStringList filter;
        filter << "all/allfiles" << "text/plain";
        dlg->setMimeFilter( filter, "all/allfiles" );
#if 0 // SPLIT-TODO
        KUrlBar *urlBar = dlg->speedBar();
        if ( urlBar )
        {
            urlBar->insertDynamicItem( KUrl("ftp://ftp.kde.org"),
                                       QLatin1String("KDE FTP Server") );
        }
#endif
        if ( dlg->exec() == KDialog::Accepted )
            name1 = dlg->selectedUrl().url();
    }

    else if ( argv1 == QLatin1String("eventloop") )
    {
        new KFDTest( startDir );
        return a.exec();
    }

    else if (argv1 == QLatin1String("save")) {
        KUrl u = KFileDialog::getSaveUrl(startDir);
//        QString(QDir::homePath() + QLatin1String("/testfile")),
//        QString(), 0L);
        name1 = u.url();
    }

    else if (argv1 == QLatin1String("icon")) {
        KIconDialog dlg;
        QString icon = dlg.getIcon();
        kDebug() << icon;
    }

//     else if ( argv1 == QLatin1String("dirselect") ) {
//         KUrl url;
//         url.setPath( "/" );
//         KUrl selected = KDirSelectDialog::selectDirectory( url );
//         name1 = selected.url();
//         qDebug("*** selected: %s", selected.url().toLatin1().constData());
//     }

    else {
        KFileDialog dlg(startDir,
                        QString::fromLatin1("*|All Files\n"
                                            "*.lo *.o *.la|All libtool Files"),0);
//    dlg.setFilter( "*.kdevelop" );
        dlg.setMode( KFile::Files |
                     KFile::Directory |
                     KFile::ExistingOnly |
                     KFile::LocalOnly );
//        QStringList filter;
//        filter << "text/plain" << "text/html" << "image/png";
//        dlg.setMimeFilter( filter );
//        KMimeType::List types;
//        types.append( KMimeType::mimeType( "text/plain" ) );
//        types.append( KMimeType::mimeType( "text/html" ) );
//        dlg.setFilterMimeType( "Filetypes:", types, types.first() );
        if ( dlg.exec() == QDialog::Accepted ) {
            const KUrl::List list = dlg.selectedUrls();
            KUrl::List::ConstIterator it = list.constBegin();
            qDebug("*** selectedUrls(): ");
            while ( it != list.constEnd() ) {
                name1 = (*it).url();
                qDebug("  -> %s", name1.toLatin1().constData());
                ++it;
            }
            qDebug("*** selectedFile: %s", dlg.selectedFile().toLatin1().constData());
            qDebug("*** selectedUrl: %s", dlg.selectedUrl().url().toLatin1().constData());
            qDebug("*** selectedFiles: ");
            QStringList l = dlg.selectedFiles();
            QStringList::Iterator it2 = l.begin();
            while ( it2 != l.end() ) {
                qDebug("  -> %s", (*it2).toLatin1().constData());
                ++it2;
            }
        }
    }

    if (!(name1.isNull()))
        KMessageBox::information(0, QLatin1String("You selected the file " ) + name1,
                                 QLatin1String("Your Choice"));
    return 0;
}