Examples of QFileDialog


Examples of com.trolltech.qt.gui.QFileDialog

        fileWatcher.addPath(file.fileName());
           
            // If we can't open it, then prompt the user to save it.
            if (!QDesktopServices.openUrl(url)) {
          logger.log(logger.EXTREME, "We can't handle this.  Where do we put it?");
              QFileDialog dialog = new QFileDialog();
              dialog.show();
              if (dialog.exec()!=0) {
                List<String> fileNames = dialog.selectedFiles(); //gets all selected filenames
                if (fileNames.size() == 0)
                  return;
                String sf = fileNames.get(0);
                QFile saveFile = new QFile(sf);
                mode.set(QFile.OpenModeFlag.WriteOnly);
View Full Code Here

Examples of com.trolltech.qt.gui.QFileDialog

  // * User chose to save an attachment. Pares out the request *
  // * into a guid & file. Save the result. *
  // ************************************************************
  public void downloadAttachment(QNetworkRequest request) {
    String guid;
    QFileDialog fd = new QFileDialog(this);
    fd.setFileMode(FileMode.AnyFile);
    fd.setConfirmOverwrite(true);
    fd.setWindowTitle(tr("Save File"));
    fd.setAcceptMode(AcceptMode.AcceptSave);
    fd.setDirectory(System.getProperty("user.home"));
    String name = request.url().toString();

    int pos = name.lastIndexOf(Global.attachmentNameDelimeter);
    if (pos > -1) {
      guid = name.substring(0, pos).replace("nnres://", "");
      name = name.substring(pos +Global.attachmentNameDelimeter.length());
      fd.selectFile(name);
      pos = name.lastIndexOf('.');
      if (pos > -1) {
        String mimeType = "(*." + name.substring(pos + 1)
            + ");; All Files (*)";
        fd.setFilter(tr(mimeType));
      }
    } else {
      guid = name;
    }

    // Strip URL prefix and base dir
    guid = guid.replace("nnres://", "")
            .replace(FileUtils.toForwardSlashedPath(Global.getFileManager().getResDirPath()), "");
    guid = guid.replace("file://", "").replace("/", "")
          .replace(FileUtils.toForwardSlashedPath(Global.getFileManager().getResDirPath()), "");

    pos = guid.lastIndexOf('.');
    if (pos > 0)
      guid = guid.substring(0,pos);
    if (fd.exec() != 0 && fd.selectedFiles().size() > 0) {
      name = name.replace('\\', '/');
      Resource resBinary = conn.getNoteTable().noteResourceTable.getNoteResource(guid, true);
      QFile saveFile = new QFile(fd.selectedFiles().get(0));
      QFile.OpenMode mode = new QFile.OpenMode();
      mode.set(QFile.OpenModeFlag.WriteOnly);
      saveFile.open(mode);
      QDataStream saveOut = new QDataStream(saveFile);
      QByteArray binData = new QByteArray(resBinary.getData().getBody());
View Full Code Here

Examples of com.trolltech.qt.gui.QFileDialog

  // ************************************************************
  // * User chose to save an attachment. Pares out the request *
  // * into a guid & file. Save the result. --- DONE FROM downloadAttachment now!!!!!  
  // ************************************************************
  public void downloadImage(QNetworkRequest request) {
    QFileDialog fd = new QFileDialog(this);
    fd.setFileMode(FileMode.AnyFile);
    fd.setConfirmOverwrite(true);
    fd.setWindowTitle(tr("Save File"));
    fd.setAcceptMode(AcceptMode.AcceptSave);
    fd.setDirectory(System.getProperty("user.home"));
    String name = request.url().toString();
    name = name.replace("nnres://", "");
    String dPath = FileUtils.toForwardSlashedPath(Global.getFileManager().getResDirPath());
    name = name.replace(dPath, "");
    int pos = name.lastIndexOf('.');
    String guid = name;
    if (pos > -1) {
      String mimeType = "(*." + name.substring(pos + 1)
      + ");; All Files (*)";
        fd.setFilter(tr(mimeType));
      guid = guid.substring(0,pos);
    }
    pos = name.lastIndexOf(Global.attachmentNameDelimeter);
    if (pos > -1) {
      guid = name.substring(0, pos);
      fd.selectFile(name.substring(pos+Global.attachmentNameDelimeter.length()));   
    }
    if (fd.exec() != 0 && fd.selectedFiles().size() > 0) {
      Resource resBinary = conn.getNoteTable().noteResourceTable.getNoteResource(guid, true);
      String fileName = fd.selectedFiles().get(0);
      QFile saveFile = new QFile(fileName);
      QFile.OpenMode mode = new QFile.OpenMode();
      mode.set(QFile.OpenModeFlag.WriteOnly);
      saveFile.open(mode);
      QDataStream saveOut = new QDataStream(saveFile);
View Full Code Here

Examples of com.trolltech.qt.gui.QFileDialog

  //**************************************************
  //* Backup & Restore
  //**************************************************
  @SuppressWarnings("unused")
  private void databaseBackup() {
    QFileDialog fd = new QFileDialog(this);
    fd.setFileMode(FileMode.AnyFile);
    fd.setConfirmOverwrite(true);
    fd.setWindowTitle(tr("Backup Database"));
    fd.setFilter(tr("NixNote Export (*.nnex);;All Files (*.*)"));
    fd.setAcceptMode(AcceptMode.AcceptSave);
    if (saveLastPath == null || saveLastPath.equals(""))
      fd.setDirectory(System.getProperty("user.home"));
    else
      fd.setDirectory(saveLastPath);
    if (fd.exec() == 0 || fd.selectedFiles().size() == 0) {
      return;
    }
   
   
      waitCursor(true);
      saveLastPath = fd.selectedFiles().get(0);
      saveLastPath = saveLastPath.substring(0,saveLastPath.lastIndexOf("/"));
      setMessage(tr("Backing up database"));
      saveNote();
//      conn.backupDatabase(Global.getUpdateSequenceNumber(), Global.getSequenceDate());
     
      ExportData noteWriter = new ExportData(conn, true);
      String fileName = fd.selectedFiles().get(0);

      if (!fileName.endsWith(".nnex"))
        fileName = fileName +".nnex";
      noteWriter.exportData(fileName);
      setMessage(tr("Database backup completed."));
View Full Code Here

Examples of com.trolltech.qt.gui.QFileDialog

        QMessageBox.StandardButton.No)==StandardButton.No.value()) {
          return;
        }
   
   
    QFileDialog fd = new QFileDialog(this);
    fd.setFileMode(FileMode.ExistingFile);
    fd.setConfirmOverwrite(true);
    fd.setWindowTitle(tr("Restore Database"));
    fd.setFilter(tr("NixNote Export (*.nnex);;All Files (*.*)"));
    fd.setAcceptMode(AcceptMode.AcceptOpen);
    if (saveLastPath == null || saveLastPath.equals(""))
      fd.setDirectory(System.getProperty("user.home"));
    else
      fd.setDirectory(saveLastPath);
    if (fd.exec() == 0 || fd.selectedFiles().size() == 0) {
      return;
    }
   
   
    waitCursor(true);
      saveLastPath = fd.selectedFiles().get(0);
      saveLastPath = saveLastPath.substring(0,saveLastPath.lastIndexOf("/"));

    setMessage(tr("Restoring database"));
      ImportData noteReader = new ImportData(conn, true);
      noteReader.importData(fd.selectedFiles().get(0));
     
      if (noteReader.lastError != 0) {
        setMessage(noteReader.getErrorMessage());
        logger.log(logger.LOW, "Restore problem: " +noteReader.lastError);
        waitCursor(false);
View Full Code Here

Examples of com.trolltech.qt.gui.QFileDialog

      setMessage(tr("Database has been restored."));
      waitCursor(false);
  }
  @SuppressWarnings("unused")
  private void exportNotes() {
    QFileDialog fd = new QFileDialog(this);
    fd.setFileMode(FileMode.AnyFile);
    fd.setConfirmOverwrite(true);
    fd.setWindowTitle(tr("Backup Database"));
    fd.setFilter(tr("NixNote Export (*.nnex);;All Files (*.*)"));
    fd.setAcceptMode(AcceptMode.AcceptSave);
    fd.setDirectory(System.getProperty("user.home"));
    if (fd.exec() == 0 || fd.selectedFiles().size() == 0) {
      return;
    }
   
   
      waitCursor(true);
      setMessage(tr("Exporting Notes"));
      saveNote();
     
    if (selectedNoteGUIDs.size() == 0 && !currentNoteGuid.equals(""))
      selectedNoteGUIDs.add(currentNoteGuid);
   
      ExportData noteWriter = new ExportData(conn, false, selectedNoteGUIDs);
      String fileName = fd.selectedFiles().get(0);

      if (!fileName.endsWith(".nnex"))
        fileName = fileName +".nnex";
      noteWriter.exportData(fileName);
      setMessage(tr("Export completed."));
View Full Code Here

Examples of com.trolltech.qt.gui.QFileDialog

      waitCursor(false);
   
  }
  @SuppressWarnings("unused")
  private void importNotes() {
    QFileDialog fd = new QFileDialog(this);
    fd.setFileMode(FileMode.ExistingFile);
    fd.setConfirmOverwrite(true);
    fd.setWindowTitle(tr("Import Notes"));
    fd.setFilter(tr("NixNote Export (*.nnex);;Evernote Export (*.enex);;All Files (*.*)"));
    fd.setAcceptMode(AcceptMode.AcceptOpen);
    if (saveLastPath == null || saveLastPath.equals(""))
      fd.setDirectory(System.getProperty("user.home"));
    else
      fd.setDirectory(saveLastPath);
    if (fd.exec() == 0 || fd.selectedFiles().size() == 0) {
      return;
    }
   
   
      waitCursor(true);
      setMessage(tr("Importing Notes"));
      saveNote();
     
    if (selectedNoteGUIDs.size() == 0 && !currentNoteGuid.equals(""))
      selectedNoteGUIDs.add(currentNoteGuid);
   
      String fileName = fd.selectedFiles().get(0);
//      saveLastPath.substring(0,fileName.lastIndexOf("/"));

      if (fileName.endsWith(".nnex")) {
          ImportData noteReader = new ImportData(conn, false);
        if (selectedNotebookGUIDs != null && selectedNotebookGUIDs.size() > 0)
View Full Code Here

Examples of com.trolltech.qt.gui.QFileDialog

    okButton.setEnabled(true);
  }
 
  @SuppressWarnings("unused")
  private void folderButtonClicked() {
    QFileDialog fileDialog = new QFileDialog();
    fileDialog.setFileMode(FileMode.DirectoryOnly);
    fileDialog.fileSelected.connect(this, "folderSelected(String)");
    fileDialog.exec();
  }
View Full Code Here

Examples of com.trolltech.qt.gui.QFileDialog

  }
 
  // Icon Button pressed
  @SuppressWarnings("unused")
  private void iconButtonPressed() {
    QFileDialog fd = new QFileDialog(this);
    fd.setFileMode(FileMode.ExistingFile);
    fd.setConfirmOverwrite(true);
    fd.setWindowTitle(tr("Icon"));
    fd.setFilter(tr("PNG (*.png);;All Files (*.*)"));
    fd.setAcceptMode(AcceptMode.AcceptOpen);
    if (path == null || path.equals(""))
      fd.setDirectory(Global.getFileManager().getImageDirPath(""));
    else
      fd.setDirectory(path);
    if (fd.exec() == 0 || fd.selectedFiles().size() == 0) {
      return;
    }
   
    this.path = fd.selectedFiles().get(0);
    this.path = path.substring(0,path.lastIndexOf("/"));
    ok.setEnabled(true);
    String path = fd.selectedFiles().get(0);
    iconButton.setIcon(new QIcon(path));
    iconButton.setSizePolicy(Policy.Fixed, Policy.Fixed);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.