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() );
    }
}
示例#2
0
void CDPWizard::promptForFileName(QLineEdit * theLineEdit, QString theShortName, QString theLongName)
{
    QSettings myQSettings;
    QString myFilterList;
    FileReader::getGdalDriverMap(myFilterList);
    QString myWorkDirString = myQSettings.readEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Dir",QDir::homeDirPath());

    std::cout << "Filter List: " << myFilterList << std::endl;
    QString myFileNameQString;
    QFileDialog myFileDialog (myWorkDirString,myFilterList,0,"Select " + theLongName ,"Select " + theLongName);
    QString myLastFilter = myQSettings.readEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Filter","");
    if (!myLastFilter.isEmpty())
    {
      myFileDialog.setSelectedFilter(myLastFilter);
    }
    if ( myFileDialog.exec() == QDialog::Accepted )
    {
      myFileNameQString = myFileDialog.selectedFile();
      theLineEdit->setText(myFileNameQString);
      QFileInfo myFileInfo(myFileNameQString);
      myQSettings.writeEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Dir",myFileInfo.dirPath());
      myQSettings.writeEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Filter",myFileDialog.selectedFilter());
      checkInputFilenames();
    }
}
示例#3
0
void
WaveMaker::loadFile()
{
  QFileDialog* fd = new QFileDialog(this, "Wave Maker Input File", TRUE);
  fd->setMode(QFileDialog::AnyFile);
  fd->setViewMode(QFileDialog::Detail);
  QString fileName;
  if (fd->exec() == QDialog::Accepted)
    {
      fileName = fd->selectedFile();
      printf("Loading new file: %s\n", fileName.latin1());
      setComment("File Name", fileName);
      wave.clear();
      QFile file(fileName);
      if (file.open(IO_ReadOnly))
        {
          QTextStream stream(&file);
          double value;
          while (!stream.atEnd())
            {
              stream >> value;
              wave.push_back(value);
            }
          filename = fileName;
        }
void ossimQtSingleImageWindow::openImage()
{
    QString caption = "iview : open image";
    QString directory;
    if (!theLastOpenedDirectory.empty())
    {
        if (theLastOpenedDirectory.exists())
        {
            directory = theLastOpenedDirectory.c_str();
        }
    }

    QFileDialog* fd = new QFileDialog( this, caption, directory );
    fd->setFileMode( QFileDialog::ExistingFile );

    ossimFilename fileName;

    if ( fd->exec() == QDialog::Accepted )
    {
        fileName = fd->selectedFile().ascii();
        theLastOpenedDirectory = fileName.path();
    }

    delete fd;
    fd = 0;

    if (fileName.empty())
    {
        return;
    }

    displayImage(fileName);
}
示例#5
0
 /**
 Handler for the onbrowse event.
 */
 void SlicingAlgorithmDialog::onBrowse()
 {
   QFileDialog dialog;
   dialog.setDirectory(QDir::homePath());
   dialog.setNameFilter("Nexus files (*.nxs)");
   if (dialog.exec())
   {
     ui.txt_filename->setText(dialog.selectedFile());
   }
 }
示例#6
0
void CDPWizard::pbtnOutputPath_clicked()
{
  QSettings myQSettings;
  QString myLastDir = myQSettings.readEntry("/qgis/cdpwizard/DefaultDirectories/OutputDir",QDir::homeDirPath());
  QString myFileNameQString;
  QFileDialog myFileDialog (myLastDir,"",this,"Select Output Directory");
  myFileDialog.setMode(QFileDialog::DirectoryOnly);
  if ( myFileDialog.exec() == QDialog::Accepted )
  {
    myFileNameQString = myFileDialog.selectedFile();
    leOutputPath->setText(myFileNameQString);
    myQSettings.writeEntry("/qgis/cdpwizard/DefaultDirectories/OutputDir",myFileNameQString);
  }
}
示例#7
0
文件: vcwidget.cpp 项目: speakman/qlc
void VCWidget::chooseBackgroundImage()
{
	QLCImagePreview* preview = new QLCImagePreview();
	QFileDialog* fd = new QFileDialog(this);
	fd->setContentsPreviewEnabled(true);
	fd->setContentsPreview(preview, preview);
	fd->setPreviewMode(QFileDialog::Contents);
	fd->setFilter("Images (*.png *.xpm *.jpg *.gif)");
	fd->setSelection(backgroundImage());
	
	if (fd->exec() == QDialog::Accepted)
		setBackgroundImage(fd->selectedFile());
	
	delete preview;
	delete fd;
}
示例#8
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 ossimQtElevationManagerDialog::addDirectoryClicked()
{
   if (!theController) return;

   QFileDialog* fd = new QFileDialog( this );
   fd->setMode(QFileDialog::DirectoryOnly);
   fd->setDir(ossimQtElevationManagerController::getLatestOpenCellPath().c_str());
   
   QString directory;
   if (fd->exec() == QDialog::Accepted )
   {
      directory = fd->selectedFile();
      theController->onAddDirectory(directory);
   }

   // Delete fd???
   delete fd;
   fd = NULL;
}
示例#10
0
void ossimQtIgenDialog::saveSpecFilePushButtonClicked()
{
   if (theController)
   {
      QFileDialog* fd = new QFileDialog( this );
      fd->setMode(QFileDialog::AnyFile);
      fd->setDir(ossimQtIgenController::getLatestOutputFilePath().c_str());
      
      QString file;
      if (fd->exec() == QDialog::Accepted )
      {
         file = fd->selectedFile();
         theController->saveSpecFile(file);
      }
      
      // Delete fd???
      delete fd;
      fd = NULL;
   }
}
示例#11
0
void ossimQtIcpDialog::outputImageClicked()
{
   if (!theOutputImageField)
   {
      return;
   }
   
   QFileDialog* fd = new QFileDialog( this, "file dialog", TRUE );
   fd->setMode( QFileDialog::AnyFile );
   
   QString fileName;
   
   if ( fd->exec() == QDialog::Accepted )
   {
      fileName = fd->selectedFile();
   }
   delete fd;
   fd = NULL;
   
   if (fileName.isEmpty())
   {
      return;
   }
   
   // Make sure output filename is not the same as input.
   QString source_file = getImageFileName();
   if (source_file == fileName)
   {
      QString caption = "Sorry:";
      QString text = "Output file cannot be the same as input file.";
      QMessageBox::information( this,
                                caption,
                                text,
                                QMessageBox::Ok );
      theOutputImageField->setText("");
      return;      
   }
   
   theOutputImageField->setText(fileName);
}
示例#12
0
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);
}
示例#13
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;
}