void SettingsDialog::setFile( QLineEdit *le, const QString &caption )
{
    QFileDialog *fd = new QFileDialog( this );
    fd->setCaption( caption );
    fd->setMode( QFileDialog::AnyFile );
    fd->setDir( QDir::homeDirPath() );

    if ( fd->exec() == QDialog::Accepted ) {
	if ( !fd->selectedFile().isEmpty() )
	   le->setText( fd->selectedFile() );
    }
}
Exemple #2
0
QString View::getOpenFileName()
{
    static QString workingDirectory = QDir::currentDirPath();

    QFileDialog *dlg = new QFileDialog( workingDirectory,
	    QString::null, 0, 0, TRUE );
    dlg->setCaption( QFileDialog::tr( "Open" ) );
    dlg->setMode( QFileDialog::ExistingFile );
    QString result;
    if ( dlg->exec() == QDialog::Accepted ) {
	result = dlg->selectedFile();
	workingDirectory = dlg->url();
    }
    delete dlg;
    return result;
}
void FLJasperEngine::execExportFileDialog(const QString &defaultFileName,
                                          const QString &defaultFormat)
{
  bool multiLang = aqApp->multiLangEnabled();
  aqApp->setMultiLang(false);

  QFileDialog *fd = new QFileDialog(0, "aq_execExportFileDialog", true);

  fd->setMode(QFileDialog::AnyFile);
  fd->setFilters(QStringList()
                 << "Pdf"
                 << "Csv"
                 << "Docx"
                 << "EmbeddedImagesXml"
                 << "Html"
                 << "MultipleSheetsXls"
                 << "Odt"
                 << "Rtf"
                 << "SingleSheetXls"
                 << "Xml");
  setDefaultExportFormat(defaultFormat);
  fd->setSelectedFilter(d->defaultExportFormat());
  fd->setSelection(defaultFileName);
  fd->setCaption(tr("Exportar Informe a..."));

  connect(fd, SIGNAL(filterSelected(const QString &)),
          this, SLOT(setDefaultExportFormat(const QString &)));

  if (fd->exec() == QDialog::Accepted) {
    QString outFile(fd->selectedFile());
    if (!outFile.isEmpty())
      exportReportToFile(outFile, d->defaultExportFormat());
  }

  delete fd;
  aqApp->setMultiLang(multiLang);
}
Exemple #4
0
void ZhscWidget::educe()
{
  if ( !bConStatus ) 
  {
    return;
  }

  uint len = 0;
  uint index = 0;
  int n = 0;

  QString tmp;

  QChar c( 0x2028 );

  tePoem->setTextFormat( Qt::PlainText );
  teMemo->setTextFormat( Qt::PlainText );
  tePoet->setTextFormat( Qt::PlainText );

  tmp = tePoem->text() + "\n" + teMemo->text() + "\n" + tePoet->text();

  tePoem->setTextFormat( Qt::AutoText );
  teMemo->setTextFormat( Qt::AutoText );
  tePoet->setTextFormat( Qt::AutoText );

  len = tmp.length();
  
  while ( 1 )
  {
    n = tmp.find( c, index );
    if ( n < 0 )
      break;
    tmp.replace( n, 1, "\n" );
    index = n;
  }

  QString sFileName;

  QFileDialog *fd = new QFileDialog( this );

  fd->setMode( QFileDialog::AnyFile );
  fd->setFilter( Unicode( "所有文件 (*.*)" ) );
  fd->setViewMode( QFileDialog::Detail );
  fd->setCaption( Unicode( "中华诗词 Qt版" ) );

  if ( fd->exec() == QDialog::Accepted )
  {
    sFileName = fd->selectedFile(); 
    if ( QFile::exists( sFileName ) )
    {
      if ( QMessageBox::warning( NULL, Unicode( "中华诗词 Qt版" ),
          Unicode( "这个文件已经存在,覆盖它?" ),
          Unicode( "确定" ),
          Unicode( "取消" ), 0, 0, 1 ) == 1)
      {
        delete fd;
        return;
      }
    }
    delete fd;
  }

  if ( sFileName != "" )
  {
    QFile f( sFileName );
    if ( f.open( IO_WriteOnly | IO_Truncate ) ) 
    {
      QTextCodec *codec = new QGb18030Codec();
      QTextStream ts( &f );
      ts.setCodec( codec );
      ts << tmp;
      f.close();
    }
  }
  
  return;
}