Exemple #1
0
bool NetAccess::statInternal( const KUrl & url, int details, StatSide side,
                              QWidget* window )
{
  d->bJobOK = true; // success unless further error occurs
  KIO::JobFlags flags = url.isLocalFile() ? KIO::HideProgressInfo : KIO::DefaultFlags;
  KIO::StatJob * job = KIO::stat( url, flags );
  job->ui()->setWindow (window);
  job->setDetails( details );
  job->setSide( side == SourceSide ? StatJob::SourceSide : StatJob::DestinationSide );
  connect( job, SIGNAL( result (KJob *) ),
           this, SLOT( slotResult (KJob *) ) );
  enter_loop();
  return d->bJobOK;
}
Exemple #2
0
bool KPlatoWork_MainWindow::openDocument(const QUrl & url)
{
    // TODO: m_part->openUrl will find out about this as well, no?
    KIO::StatJob* statJob = KIO::stat( url );
    statJob->setSide(  KIO::StatJob::SourceSide );

    const bool isUrlReadable = statJob->exec();

    if (! isUrlReadable) {
        KMessageBox::error(0L, i18n("The file %1 does not exist.", url.url()));
//        d->recent->removeUrl(url); //remove the file from the recent-opened-file-list
//        saveRecentFiles();
        return false;
    }
    return m_part->openUrl( url );
}
Exemple #3
0
/* return true if the url exists*/
bool QExtFileInfo::internalExists(const KURL& url)
{
  bJobOK = true;
 // kdDebug(24000)<<"QExtFileInfo::internalExists"<<endl;
  KIO::StatJob * job = KIO::stat( url, false);
  job->setDetails(0);
  job->setSide(false); //check the url for writing
  connect( job, SIGNAL( result (KIO::Job *) ),
           this, SLOT( slotResult (KIO::Job *) ) );

  //To avoid lock-ups, start a timer.
  QTimer::singleShot(60*1000, this,SLOT(slotTimeout()));
//  kdDebug(24000)<<"QExtFileInfo::internalExists:before enter_loop"<<endl;
  enter_loop();
//  kdDebug(24000)<<"QExtFileInfo::internalExists:after enter_loop"<<endl;
  return bJobOK;
}
Exemple #4
0
static QUrl getNewFileName(const QUrl &u, const QString &text, const QString &suggestedFileName, QWidget *widget)
{
    bool ok;
    QString dialogText(text);
    if (dialogText.isEmpty()) {
        dialogText = i18n("Filename for clipboard content:");
    }
    QString file = QInputDialog::getText(widget, QString(), dialogText, QLineEdit::Normal, suggestedFileName, &ok);
    if (!ok) {
        return QUrl();
    }

    QUrl myurl(u);
    myurl.setPath(myurl.path() + '/' + file);

    KIO::StatJob *job = KIO::stat(myurl, myurl.isLocalFile() ? KIO::HideProgressInfo : KIO::DefaultFlags);
    job->setDetails(0);
    job->setSide(KIO::StatJob::DestinationSide);
    KJobWidgets::setWindow(job, widget);

    // Check for existing destination file.
    // When we were using CopyJob, we couldn't let it do that (would expose
    // an ugly tempfile name as the source URL)
    // And now we're using a put job anyway, no destination checking included.
    if (job->exec()) {
        //qDebug() << "Paste will overwrite file.  Prompting...";
        KIO::RenameDialog dlg(widget,
                              i18n("File Already Exists"),
                              u,
                              myurl,
                              KIO::RenameDialog_Overwrite);
        KIO::RenameDialog_Result res = static_cast<KIO::RenameDialog_Result>(dlg.exec());

        if (res == KIO::Result_Rename) {
            myurl = dlg.newDestUrl();
        } else if (res == KIO::Result_Cancel) {
            return QUrl();
        } else if (res == KIO::Result_Overwrite) {
            // OK, proceed
        }
    }

    return myurl;
}
void AsyncFileTester::delayedFolderCheck(const KUrl &url)
{
    KIO::StatJob *job = KIO::stat(url, KIO::HideProgressInfo);
    job->setSide(KIO::StatJob::SourceSide); // We will only read the file
    connect(job, SIGNAL(result(KJob*)), SLOT(statResult(KJob*)));
}