예제 #1
0
bool KDevelop::removeUrl(const KDevelop::IProject* project, const KUrl& url, const bool isFolder)
{
    QWidget* window(ICore::self()->uiController()->activeMainWindow()->window());

    if ( !KIO::NetAccess::exists(url, KIO::NetAccess::DestinationSide, window) ) {
        kWarning() << "tried to remove non-existing url:" << url << project << isFolder;
        return true;
    }

    IPlugin* vcsplugin=project->versionControlPlugin();
    if(vcsplugin) {
        IBasicVersionControl* vcs=vcsplugin->extension<IBasicVersionControl>();

        // We have a vcs and the file/folder is controller, need to make the rename through vcs
        if(vcs->isVersionControlled(url)) {
            VcsJob* job=vcs->remove(KUrl::List() << url);
            if(job) {
                return job->exec();
            }
        }
    }

    //if we didn't find a VCS, we remove using KIO
    if ( !KIO::NetAccess::del( url, window ) ) {
        KMessageBox::error( window,
            isFolder ? i18n( "Cannot remove folder <i>%1</i>.", url.pathOrUrl() )
                        : i18n( "Cannot remove file <i>%1</i>.", url.pathOrUrl() ) );
        return false;
    }
    return true;
}
예제 #2
0
파일: signature.cpp 프로젝트: KDE/kget
GpgME::VerificationResult SignaturePrivate::verify(const KUrl &dest, const QByteArray &sig)
{
    GpgME::VerificationResult result;
    if (!QFile::exists(dest.pathOrUrl()) || sig.isEmpty()) {
        return result;
    }

    GpgME::initializeLibrary();
    GpgME::Error error = GpgME::checkEngine(GpgME::OpenPGP);
    if (error) {
        kDebug(5001) << "OpenPGP not supported!";
        return result;
    }

    QScopedPointer<GpgME::Context> context(GpgME::Context::createForProtocol(GpgME::OpenPGP));
    if (!context.data()) {
        kDebug(5001) << "Could not create context.";
        return result;
    }

    boost::shared_ptr<QFile> qFile(new QFile(dest.pathOrUrl()));
    qFile->open(QIODevice::ReadOnly);
    QGpgME::QIODeviceDataProvider *file = new QGpgME::QIODeviceDataProvider(qFile);
    GpgME::Data dFile(file);

    QGpgME::QByteArrayDataProvider signatureBA(sig);
    GpgME::Data signature(&signatureBA);

    return context->verifyDetachedSignature(signature, dFile);
}
예제 #3
0
/**
 * Emits the fileRequested() signal when a file name is selected in the file 
 * tree. An item is selected by either double-clicking it or by hittin 
 * "ENTER" when it is highlighted.
 * This slot is connected to the doubleClicked() and returnPressed() signals
 * of the KFileTreeView object.
 * @param	pItem	The selected tree item
 */
void FileView::slotTreeItemSelected(const KUrl& url)
{
	QFileInfo fileInfo = QFileInfo(url.pathOrUrl());

	if (! fileInfo.isDir())
		emit fileRequested(url.pathOrUrl(), 0);
}
예제 #4
0
void VerificationThread::doBrokenPieces()
{
    m_mutex.lock();
    const QString type = m_types.takeFirst();
    const QStringList checksums = m_checksums;
    m_checksums.clear();
    const KUrl url = m_files.takeFirst();
    const KIO::filesize_t length = m_length;
    m_mutex.unlock();

    QList<KIO::fileoffset_t> broken;

    if (QFile::exists(url.pathOrUrl()))
    {
        QFile file(url.pathOrUrl());
        if (!file.open(QIODevice::ReadOnly))
        {
            emit brokenPieces(broken, length);
            return;
        }

        const KIO::filesize_t fileSize = file.size();
        if (!length || !fileSize)
        {
            emit brokenPieces(broken, length);
            return;
        }

        const QStringList fileChecksums = Verifier::partialChecksums(url, type, length, &m_abort).checksums();
        if (m_abort)
        {
            emit brokenPieces(broken, length);
            return;
        }

        if (fileChecksums.size() != checksums.size())
        {
            kDebug(5001) << "Number of checksums differs!";
            emit brokenPieces(broken, length);
            return;
        }

        for (int i = 0; i < checksums.size(); ++i)
        {
            if (fileChecksums.at(i) != checksums.at(i))
            {
                const int brokenStart = length * i;
                kDebug(5001) << url << "broken segment" << i << "start" << brokenStart << "length" << length;
                broken.append(brokenStart);
            }
        }
    }

    emit brokenPieces(broken, length);
}
DvcsJob::JobStatus GitRunner::createWorkingCopy(const KUrl &repoOrigin,
                                                const KUrl &repoDestination)
{
    // TODO: now supports only cloning a local repo(not very useful, I know =P),
    // so extend the method to be used over the Internet.
    m_lastRepoRoot->setDirectory(repoDestination.pathOrUrl());
    DvcsJob *job = new DvcsJob();
    initJob(*job);

    *job << "clone";
    *job << repoOrigin.pathOrUrl();
    startJob(*job);
    return m_jobStatus;
}
예제 #6
0
bool AddToArchive::addInput(const KUrl& url)
{
    m_inputs << url.pathOrUrl(
        QFileInfo(url.pathOrUrl()).isDir() ?
        KUrl::AddTrailingSlash :
        KUrl::RemoveTrailingSlash
    );

    if (m_firstPath.isEmpty()) {
        QString firstEntry = url.pathOrUrl(KUrl::RemoveTrailingSlash);
        m_firstPath = QFileInfo(firstEntry).dir().absolutePath();
    }

    return true;
}
예제 #7
0
void GitRunner::createWorkingCopy(const KUrl &repoOrigin,
                                                const KUrl &repoDestination)
{
    // TODO: now supports only cloning a local repo(not very useful, I know =P),
    // so extend the method to be used over the Internet.
    m_lastRepoRoot->setDirectory(repoDestination.pathOrUrl());

    QStringList command;
    command << "clone " + repoOrigin.pathOrUrl();
    KJob *job = initJob(command);

    connect(job, SIGNAL(result(KJob*)), this, SLOT(handleCreateWorkingCopy(KJob*)));

    job->start();
}
예제 #8
0
KoTarStore::KoTarStore(QWidget* window, const KUrl& _url, const QString & _filename, Mode _mode, const QByteArray & appIdentification)
{
    kDebug(30002) << "KoTarStore Constructor url=" << _url.pathOrUrl()
    << " filename = " << _filename
    << " mode = " << int(_mode) << endl;
    Q_D(KoStore);

    d->url = _url;
    d->window = window;

    if (_mode == KoStore::Read) {
        d->fileMode = KoStorePrivate::RemoteRead;
        d->localFileName = _filename;

    } else {
        d->fileMode = KoStorePrivate::RemoteWrite;
        d->localFileName = "/tmp/kozip"; // ### FIXME with KTempFile
    }

    m_pTar = new KTar(d->localFileName, "application/x-gzip");

    d->good = init(_mode);   // open the targz file and init some vars

    if (d->good && _mode == Write)
        m_pTar->setOrigFileName(completeMagic(appIdentification));
}
예제 #9
0
bool DocumentChild::setDoc( const Document *doc )
{
    Q_ASSERT ( m_doc == 0 );
    if ( isOpen() ) {
        KMessageBox::error( 0, i18n( "Document is already open:<br>%1", doc->url().pathOrUrl() ) );
        return false;
    }
    m_doc = doc;
    KUrl url;
    if ( doc->sendAs() == Document::SendAs_Copy ) {
        url = parentPackage()->extractFile( doc );
        if ( url.url().isEmpty() ) {
            KMessageBox::error( 0, i18n( "Could not extract document from storage:<br>%1", doc->url().pathOrUrl() ) );
            return false;
        }
        m_copy = true;
    } else {
        url = doc->url();
    }
    if ( ! url.isValid() ) {
        KMessageBox::error( 0, i18n( "Invalid URL:<br>%1", url.pathOrUrl() ) );
        return false;
    }
    setFileInfo( url );
    return true;
}
예제 #10
0
KUrl KUrlNavigator::Private::buttonUrl(int index) const
{
    if (index < 0) {
        index = 0;
    }

    // Keep scheme, hostname etc. as this is needed for e. g. browsing
    // FTP directories
    const KUrl currentUrl = q->locationUrl();
    KUrl newUrl = currentUrl;
    newUrl.setPath(QString());

    QString pathOrUrl = currentUrl.pathOrUrl();
    if (!pathOrUrl.isEmpty()) {
        if (index == 0) {
            // prevent the last "/" from being stripped
            // or we end up with an empty path
            pathOrUrl = QLatin1String("/");
        } else {
            pathOrUrl = pathOrUrl.section('/', 0, index);
        }
    }

    newUrl.setPath(KUrl(pathOrUrl).path());
    return newUrl;
}
예제 #11
0
QString Verifier::checksum(const KUrl &dest, const QString &type)
{
    QStringList supported = supportedVerficationTypes();
    if (!supported.contains(type))
    {
        return QString();
    }

    QFile file(dest.pathOrUrl());
    if (!file.open(QIODevice::ReadOnly))
    {
        return QString();
    }

    if (type == VerifierPrivate::MD5) {
        QByteArray hash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Md5);
        file.close();
        return hash.toHex();
    } else if (type == VerifierPrivate::SHA1) {
        QByteArray hash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Sha1);
        file.close();
        return hash.toHex();
    }

    return QString();
}
예제 #12
0
void GvCore::saveAs(const KUrl& url)
{
    QByteArray format;
    KUrl saveAsUrl;
    if (!d->showSaveAsDialog(url, &saveAsUrl, &format)) {
        return;
    }

    // Check for overwrite
    if (KIO::NetAccess::exists(saveAsUrl, KIO::NetAccess::DestinationSide, d->mMainWindow)) {
        int answer = KMessageBox::warningContinueCancel(
                         d->mMainWindow,
                         i18nc("@info",
                               "A file named <filename>%1</filename> already exists.\n"
                               "Are you sure you want to overwrite it?",
                               saveAsUrl.fileName()),
                         QString(),
                         KStandardGuiItem::overwrite());
        if (answer == KMessageBox::Cancel) {
            return;
        }
    }

    // Start save
    Document::Ptr doc = DocumentFactory::instance()->load(url);
    KJob* job = doc->save(saveAsUrl, format.data());
    if (!job) {
        const QString name = saveAsUrl.fileName().isEmpty() ? saveAsUrl.pathOrUrl() : saveAsUrl.fileName();
        const QString msg = i18nc("@info", "<b>Saving <filename>%1</filename> failed:</b><br>%2",
                                  name, doc->errorString());
        KMessageBox::sorry(QApplication::activeWindow(), msg);
    } else {
        connect(job, SIGNAL(result(KJob*)), SLOT(slotSaveResult(KJob*)));
    }
}
예제 #13
0
QString MetaDataManager::urlToTitle(const KUrl &url)
{
    QString title = QFileInfo(url.pathOrUrl()).completeBaseName();
    title = title.replace(QString("%20"), QChar(' '));
    title = title.replace(QChar('_'), QChar(' '));

    return title;
}
예제 #14
0
bool ServiceItemHandler::openUrl(const KUrl& url)
{
    int result = KToolInvocation::startServiceByDesktopPath(url.pathOrUrl(), QStringList(), 0, 0, 0, "", true);

    if (result == 0) {
        KService::Ptr service = KService::serviceByDesktopPath(url.pathOrUrl());

        if (service) {
            RecentApplications::self()->add(service);
        } else {
            qWarning() << "Failed to find service for" << url;
            return false;
        }
    }

    return result == 0;
}
예제 #15
0
QVariant PlaylistModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid() || (index.row() >= m_tracks.count()))
    {
        return QVariant();
    }

    const KUrl url(m_tracks.at(index.row()));

    if (role == Qt::DecorationRole && index.column() == FileTypeColumn && url.isValid())
    {
        return ((index.row() == m_currentTrack)?KIcon((m_manager->state() != StoppedState && isCurrent())?"media-playback-start":"arrow-right"):MetaDataManager::icon(url));
    }
    else if (role == Qt::DisplayRole || role == Qt::EditRole)
    {
        if (index.column() == FileTypeColumn || index.column() == FileNameColumn)
        {
            if (index.column() == FileNameColumn && role == Qt::DisplayRole)
            {
                return QFileInfo(url.pathOrUrl()).fileName();
            }

            return url.pathOrUrl();
        }
        else if (index.column() == DurationColumn)
        {
            return MetaDataManager::timeToString(MetaDataManager::duration(url));
        }
        else
        {
            return MetaDataManager::metaData(url, translateColumn(index.column()));
        }
    }
    else if (role == Qt::ToolTipRole)
    {
        return ((MetaDataManager::duration(url) > 0)?QString("<nobr>%1 - %2 (%3)</nobr>").arg(MetaDataManager::metaData(url, ArtistKey)).arg(MetaDataManager::metaData(url, TitleKey)).arg(MetaDataManager::timeToString(MetaDataManager::duration(url))):QString("<nobr>%1 - %2</nobr>").arg(MetaDataManager::metaData(url, ArtistKey)).arg(MetaDataManager::metaData(url, TitleKey)));
    }
    else if (role == Qt::UserRole)
    {
        return url.pathOrUrl();
    }

    return QVariant();
}
예제 #16
0
bool
MediaDeviceTrack::isPlayable() const
{
    KUrl trackUrl = playableUrl();
    QFileInfo trackFileInfo = QFileInfo( trackUrl.pathOrUrl() );
    if( trackFileInfo.exists() && trackFileInfo.isFile() && trackFileInfo.isReadable() )
        return true;

    return false;
}
DvcsJob::JobStatus GitRunner::init(const KUrl &directory)
{
    // We need to tell the runner to change dir!
    m_lastRepoRoot->setDirectory(directory.pathOrUrl());
    DvcsJob *job = new DvcsJob();
    initJob(*job);

    *job << "init";
    startJob(*job);
    return m_jobStatus;
}
예제 #18
0
QString IncludeFileData::htmlDescription() const
{
  KUrl path = m_item.url();
  
  if( m_item.isDirectory ) {
    return QString( i18n("Directory %1", path.pathOrUrl()) );
  } else {
    return i18n( "In %1th include path", m_item.pathNumber );
  }

  return " ";
}
예제 #19
0
bool KDevelop::createFile(const KUrl& file)
{
    if (KIO::NetAccess::exists( file, KIO::NetAccess::DestinationSide, QApplication::activeWindow() )) {
        KMessageBox::error( QApplication::activeWindow(),
                            i18n( "The file <i>%1</i> exists already.", file.pathOrUrl() ) );
        return false;
    }

    {
        KTemporaryFile temp;
        if ( !temp.open() || temp.write("\n") == -1 ) {
            KMessageBox::error( QApplication::activeWindow(),
                                i18n( "Cannot create temporary file to create <i>%1</i>.", file.pathOrUrl() ) );
            return false;
        }
        if ( !KIO::NetAccess::upload( temp.fileName(), file, QApplication::activeWindow() ) ) {
            KMessageBox::error( QApplication::activeWindow(),
                                i18n( "Cannot create file <i>%1</i>.", file.pathOrUrl() ) );
            return false;
        }
    }
    return true;
}
예제 #20
0
QVariantMap MetaDataManager::metaData(const KUrl &url)
{
    QVariantMap trackData;
    trackData["title"] = metaData(url, TitleKey, false);
    trackData["artist"] = metaData(url, ArtistKey, false);
    trackData["album"] = metaData(url, AlbumKey, false);
    trackData["date"] = metaData(url, DateKey, false);
    trackData["genre"] = metaData(url, GenreKey, false);
    trackData["description"] = metaData(url, DescriptionKey, false);
    trackData["tracknumber"] = metaData(url, TrackNumberKey, false);
    trackData["time"] = duration(url);
    trackData["location"] = url.pathOrUrl();

    return trackData;
}
예제 #21
0
void ImageSource::loadImage(const QString &who, const KUrl &url)
{
    if (who.isEmpty()) {
        return;
    }
    if (!m_imageCache) {
        m_imageCache = new KImageCache("plasma_engine_preview", 10485760); // Re-use previewengine's cache
    }

    // Make sure we only start one job per user
    if (m_loadedPersons.contains(who)) {
        return;
    }

    const QString cacheKey = who + "@" + url.pathOrUrl();

    // Check if the image is in the cache, if so return it
    QImage preview = QImage(QSize(48, 48), QImage::Format_ARGB32_Premultiplied);
    preview.fill(Qt::transparent);
    if (m_imageCache->findImage(cacheKey, &preview)) {
        // cache hit
        //kDebug() << "cache hit: " << cacheKey;
        setData(who, polishImage(preview));
        Q_EMIT dataChanged();
        checkForUpdate();
        return;
    }
    if (!url.isValid()) {
        return;
    }
    m_loadedPersons << who;
    //FIXME: since kio_http bombs the system with too many request put a temporary
    // arbitrary limit here, revert as soon as BUG 192625 is fixed
    // Note: seems fixed.
    if (m_runningJobs < 500) {
        m_runningJobs++;
        KIO::Job *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
        job->setAutoDelete(true);
        m_jobs[job] = who;
        connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
                this, SLOT(recv(KIO::Job*,QByteArray)));
        connect(job, SIGNAL(result(KJob*)), this, SLOT(result(KJob*)));
        job->start();
    } else {
예제 #22
0
void StartMainPage::showRecentFoldersViewContextMenu(const QPoint& pos)
{
    QAbstractItemView* view = qobject_cast<QAbstractItemView*>(sender());
    KUrl url;
    QModelIndex index = view->indexAt(pos);
    if (index.isValid()) {
        QVariant data = index.data(KFilePlacesModel::UrlRole);
        url = data.toUrl();
    }

    // Create menu
    QMenu menu(this);
    bool fromRecentUrls = view == d->mRecentUrlsView;
    QAction* addToPlacesAction = fromRecentUrls ? 0 : menu.addAction(KIcon("bookmark-new"), i18n("Add to Places"));
    QAction* removeAction = menu.addAction(KIcon("edit-delete"), fromRecentUrls ? i18n("Forget this URL") : i18n("Forget this Folder"));
    menu.addSeparator();
    QAction* clearAction = menu.addAction(KIcon("edit-delete-all"), i18n("Forget All"));

    if (!index.isValid()) {
        if (addToPlacesAction) {
            addToPlacesAction->setEnabled(false);
        }
        removeAction->setEnabled(false);
    }

    // Handle menu
    QAction* action = menu.exec(view->mapToGlobal(pos));
    if (!action) {
        return;
    }
    if (action == addToPlacesAction) {
        QString text = url.fileName();
        if (text.isEmpty()) {
            text = url.pathOrUrl();
        }
        d->mBookmarksModel->addPlace(text, url);
    } else if (action == removeAction) {
        view->model()->removeRow(index.row());
    } else if (action == clearAction) {
        view->model()->removeRows(0, view->model()->rowCount());
    }
}
예제 #23
0
void GvCore::slotSaveResult(KJob* _job)
{
    SaveJob* job = static_cast<SaveJob*>(_job);
    KUrl oldUrl = job->oldUrl();
    KUrl newUrl = job->newUrl();

    if (job->error()) {
        QString name = newUrl.fileName().isEmpty() ? newUrl.pathOrUrl() : newUrl.fileName();
        QString msg = i18nc("@info", "<b>Saving <filename>%1</filename> failed:</b><br>%2",
                            name, job->errorString());

        int result = KMessageBox::warningContinueCancel(
                         d->mMainWindow, msg,
                         QString() /* caption */,
                         KStandardGuiItem::saveAs());

        if (result == KMessageBox::Continue) {
            saveAs(newUrl);
        }
        return;
    }

    if (oldUrl != newUrl) {
        d->mMainWindow->goToUrl(newUrl);

        ViewMainPage* page = d->mMainWindow->viewMainPage();
        if (page->isVisible()) {
            HudMessageBubble* bubble = new HudMessageBubble();
            bubble->setText(i18n("You are now viewing the new document."));
            KGuiItem item = KStandardGuiItem::back();
            item.setText(i18n("Go back to the original"));
            HudButton* button = bubble->addButton(item);

            BinderRef<MainWindow, KUrl>::bind(button, SIGNAL(clicked()), d->mMainWindow, &MainWindow::goToUrl, oldUrl);
            connect(button, SIGNAL(clicked()),
                bubble, SLOT(deleteLater()));

            page->showMessageWidget(bubble);
        }
    }
}
예제 #24
0
void QuantaProjectPart::slotInsertFolder()
{
  KUrl url = KUrl();
  url = KFileDialog::getExistingUrl(m_projectBase, Koncrete::Core::mainWindow(), i18n("Insert Folder in Project"));

  if (!url.isEmpty())
  {
    if (!m_projectBase.isParentOf(url))
    {
      KUrlRequesterDialog urlRequesterDlg(m_projectBase.pathOrUrl(), Koncrete::Core::mainWindow());
      urlRequesterDlg.setWindowTitle(i18n("%1: Copy to Project", url.pathOrUrl()));
      urlRequesterDlg.urlRequester()->setMode(KFile::Directory | KFile::ExistingOnly);
      urlRequesterDlg.exec();
      KUrl destination = urlRequesterDlg.selectedUrl();
      if (!destination.isEmpty())
      {
        destination.adjustPath(KUrl::AddTrailingSlash);
        QuantaNetAccess::dircopy(url, destination, this, false);
      }
    } else
    {
      KUrl::List urls = ExtFileInfo::allFilesRelative(url, "*");
      QStringList filenames;
      KUrl u = KUrl::relativeUrl(m_projectBase, url);
      QStringList sections = u.path(KUrl::AddTrailingSlash).split('/', QString::SkipEmptyParts);
      QString section;
      for (int i = 0 ; i < sections.count(); i++)
      {
        section += sections[i] + '/';
        filenames += section;
      }
      KUrl::List::ConstIterator end = urls.constEnd();
      for (KUrl::List::ConstIterator it = urls.begin(); it != end; ++it)
      {
        filenames += url.fileName() + '/' + (*it).path();
      }
      addFiles(filenames);
    }
  }
}
예제 #25
0
void KUrlNavigator::Private::updateContent()
{
    const KUrl currentUrl = q->locationUrl();
    if (m_placesSelector != 0) {
        m_placesSelector->updateSelection(currentUrl);
    }

    if (m_editable) {
        m_protocols->hide();
        m_dropDownButton->hide();

        deleteButtons();
        m_toggleEditableMode->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
        q->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);

        m_pathBox->show();
        m_pathBox->setUrl(currentUrl);
    } else {
        m_pathBox->hide();

        m_protocols->hide();

        m_toggleEditableMode->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
        q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

        // Calculate the start index for the directories that should be shown as buttons
        // and create the buttons
        KUrl placeUrl;
        if ((m_placesSelector != 0) && !m_showFullPath) {
            placeUrl = m_placesSelector->selectedPlaceUrl();
        }

        QString placePath = placeUrl.isValid() ? placeUrl.pathOrUrl() : retrievePlacePath();
        removeTrailingSlash(placePath);

        const int startIndex = placePath.count('/');
        updateButtons(startIndex);
    }
}
예제 #26
0
void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
{
    if (KProtocolManager::supportsListing(url)) {
        setSearchModeEnabled(isSearchUrl(url));

        m_view->setUrl(url);
        if (isActive() && !isSearchUrl(url)) {
            // When an URL has been entered, the view should get the focus.
            // The focus must be requested asynchronously, as changing the URL might create
            // a new view widget.
            QTimer::singleShot(0, this, SLOT(requestFocus()));
        }
    } else if (KProtocolManager::isSourceProtocol(url)) {
        QString app = "konqueror";
        if (url.protocol().startsWith(QLatin1String("http"))) {
            showErrorMessage(i18nc("@info:status",
                                   "Dolphin does not support web pages, the web browser has been launched"));
            const KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), "General");
            const QString browser = config.readEntry("BrowserApplication");
            if (!browser.isEmpty()) {
                app = browser;
                if (app.startsWith('!')) {
                    // a literal command has been configured, remove the '!' prefix
                    app = app.mid(1);
                }
            }
        } else {
            showErrorMessage(i18nc("@info:status",
                                   "Protocol not supported by Dolphin, Konqueror has been launched"));
        }

        const QString secureUrl = KShell::quoteArg(url.pathOrUrl());
        const QString command = app + ' ' + secureUrl;
        KRun::runCommand(command, app, app, this);
    } else {
        showErrorMessage(i18nc("@info:status", "Invalid protocol"));
    }
}
예제 #27
0
void BookmarkList::contextMenuForFileItem( const QPoint& p, FileItem* fItem )
{
    Q_UNUSED( p );
    if ( !fItem )
        return;

    const KUrl itemurl = fItem->data( 0, UrlRole ).value< KUrl >();
    const bool thisdoc = itemurl == m_document->currentDocument();

    KMenu menu( this );
    QAction * open = 0;
    if ( !thisdoc )
        open = menu.addAction( i18nc( "Opens the selected document", "Open Document" ) );
    QAction * editbm = menu.addAction( KIcon( "edit-rename" ), i18n( "Rename Bookmark" ) );
    QAction * removebm = menu.addAction( KIcon( "list-remove" ), i18n( "Remove Bookmarks" ) );
    QAction * res = menu.exec( QCursor::pos() );
    if ( !res )
        return;

    if ( res == open )
    {
        Okular::GotoAction action( itemurl.pathOrUrl(), Okular::DocumentViewport() );
        m_document->processAction( &action );
    }
    else if ( res == editbm )
        m_tree->editItem( fItem, 0 );
    else if ( res == removebm )
    {
        KBookmark::List list;
        for ( int i = 0; i < fItem->childCount(); ++i )
        {
            list.append( static_cast<BookmarkItem*>( fItem->child( i ) )->bookmark() );
        }
        m_document->bookmarkManager()->removeBookmarks( itemurl, list );
    }
}
예제 #28
0
void AddToArchive::setFilename(const KUrl& path)
{
    m_filename = path.pathOrUrl();
}
void CodeCompletionModel::completionInvokedInternal(KTextEditor::View* view, const KTextEditor::Range& range, InvocationType invocationType, const KUrl& url)
{
    Q_UNUSED(invocationType)

    DUChainReadLocker lock(DUChain::lock(), 400);
    if( !lock.locked() ) {
        kDebug() << "could not lock du-chain in time";
        return;
    }

    TopDUContext* top = DUChainUtils::standardContextForUrl( url );
    if(!top) {
        return;
    }
    setCurrentTopContext(TopDUContextPointer(top));

    if (top) {
        kDebug() << "completion invoked for context" << (DUContext*)top;

        kDebug() << top->localScopeIdentifier().toString() << top->range().textRange();

        if( top->parsingEnvironmentFile() && top->parsingEnvironmentFile()->modificationRevision() != ModificationRevision::revisionForFile(IndexedString(url.pathOrUrl())) ) {
            kDebug() << "Found context is not current. Its revision is " /*<< top->parsingEnvironmentFile()->modificationRevision() << " while the document-revision is " << ModificationRevision::revisionForFile(IndexedString(url.pathOrUrl()))*/;
        }

        DUContextPointer thisContext;
        {
            kDebug() << "apply specialization:" << range.start();
            {
                if ( DUContext* ctx = top->findContextAt(SimpleCursor(range.start())) ) {
                    kDebug() << "context at" << range.start() << ":" << ctx << ctx->localScopeIdentifier().toString() << ctx->range().textRange();
                }
            }
            thisContext = SpecializationStore::self().applySpecialization(top->findContextAt(SimpleCursor(range.start())), top);

            if ( thisContext ) {
                kDebug() << "after specialization:" << thisContext->localScopeIdentifier().toString() << thisContext->range().textRange();
            }

            if(!thisContext)
                thisContext = top;

            kDebug() << "context is set to" << thisContext.data();
            if( thisContext ) {
                /*          kDebug() << "================== duchain for the context =======================";
                          DumpChain dump;
                          dump.dump(thisContext.data());*/
            } else {
                kDebug() << "================== NO CONTEXT FOUND =======================";
                m_completionItems.clear();
                m_navigationWidgets.clear();
                reset();
                return;
            }
        }

        lock.unlock();

        if(m_forceWaitForModel)
            emit waitForReset();

        emit completionsNeeded(thisContext, range.start(), view);
    } else {
        kDebug() << "Completion invoked for unknown context. Document:" << url << ", Known documents:" << DUChain::self()->documents();
    }
}
예제 #30
0
void ZipPlugin::init(const KUrl &fileName)
{
    m_archive = new KZip(fileName.pathOrUrl());
}