コード例 #1
0
bool KAResourceRemote::setUrls(const KUrl& downloadUrl, const KUrl& uploadUrl)
{
	if (mReconfiguring == 1)
	{
		mNewDownloadUrl = downloadUrl;
		mNewUploadUrl   = uploadUrl;
		return true;
	}
	if (downloadUrl.equals(mDownloadUrl)
	&&  uploadUrl.equals(mUploadUrl))
		return false;
	kDebug(KARES_DEBUG) << downloadUrl.prettyUrl() << "," << uploadUrl.prettyUrl();
	if (isOpen())
		close();
	bool active = isActive();
	if (active)
		enableResource(false);
	mDownloadUrl = downloadUrl;
	mUploadUrl   = uploadUrl;
	if (active)
		enableResource(true);
	// Trigger loading the new resource, and ensure that the new configuration is saved
	emit locationChanged(this);
	return true;
}
コード例 #2
0
static KUrl::List thread_getProjectFiles(const KUrl dir, bool recursive, const QStringList include,
                                         const QStringList exlude, volatile bool &abort)
{
    ///@todo This is not thread-safe!
    KDevelop::IProject *project = KDevelop::ICore::self()->projectController()->findProjectForUrl( dir );
    KUrl::List res;
    if(!project)
        return res;

    const QSet<IndexedString> fileSet = project->fileSet();
    foreach( const IndexedString &item, fileSet )
    {
        if(abort)
            break;
        KUrl url = item.toUrl();
        if( !url.equals(dir) )
        {
            if( recursive && !dir.isParentOf(url) )
                continue;
            if( !recursive && !url.upUrl().equals(dir, KUrl::CompareWithoutTrailingSlash))
                continue;
        }
        if( QDir::match(include, url.fileName()) && !QDir::match(exlude, url.toLocalFile()) )
            res << url;
    }

    return res;
}
コード例 #3
0
ファイル: kimagefilepreview.cpp プロジェクト: vasi/kdelibs
void KImageFilePreview::showPreview( const KUrl &url, bool force )
{
    if (!url.isValid() ||
        (d->lastShownURL.isValid() &&
         url.equals(d->lastShownURL, KUrl::CompareWithoutTrailingSlash) &&
         d->currentURL.isValid()))
        return;

    d->clear = false;
    d->currentURL = url;
    d->lastShownURL = url;

    int w = d->imageLabel->contentsRect().width() - 4;
    int h = d->imageLabel->contentsRect().height() - 4;

    if (d->m_job) {
        disconnect(d->m_job, SIGNAL(result(KJob *)),
                    this, SLOT( _k_slotResult( KJob * )));
        disconnect(d->m_job, SIGNAL(gotPreview(const KFileItem&,
                                                const QPixmap& )), this,
                SLOT( gotPreview( const KFileItem&, const QPixmap& ) ));

        disconnect(d->m_job, SIGNAL(failed(const KFileItem&)),
                    this, SLOT(_k_slotFailed(const KFileItem&)));

        d->m_job->kill();
    }
コード例 #4
0
ファイル: stackfolder.cpp プロジェクト: KDE/stackfolder
void StackFolder::updateIconWidget()
{
    if (!m_placesModel) {
        m_placesModel = new KFilePlacesModel(this);

        const QModelIndex index = m_placesModel->closestItem(m_topUrl);
        const KUrl url = m_placesModel->url(index);

        KFileItem item = m_dirModel->itemForIndex(QModelIndex());

        if (!item.isNull() && item.iconName() != "inode-directory") {
            m_icon = KIcon(item.iconName(), 0, item.overlays());
        } 
        else if (m_topUrl.protocol() == "desktop") {
            m_icon = KIcon("user-desktop");
        } 
        else if (m_topUrl.protocol() == "trash") {
            m_icon = m_model->rowCount() > 0 ? KIcon("user-trash-full") : KIcon("user-trash");
        } 
        else if (index.isValid() && url.equals(m_topUrl, KUrl::CompareWithoutTrailingSlash)) {
            m_icon = m_placesModel->icon(index);
        }

        m_iconAnimation1 = new QPropertyAnimation(this, "popupIconSize");
        m_iconAnimation1->setDuration(600);
        m_iconAnimation2 = new QPropertyAnimation(this, "popupIconSize");
        m_iconAnimation1->setDuration(600);
        m_iconAnimationGroup = new QSequentialAnimationGroup;
        m_iconAnimationGroup->addAnimation(m_iconAnimation1);
        m_iconAnimationGroup->addAnimation(m_iconAnimation2);
        m_iconAnimationGroup->setLoopCount(4);
        connect(m_iconAnimationGroup, SIGNAL(finished()), this, SLOT(iconAnimationFinished()));

        setPopupIcon(m_icon);

        // Update the tooltip
        Plasma::ToolTipContent data;
        data.setMainText(i18n("Stack Folder"));
        data.setSubText(m_topUrl.fileName(KUrl::IgnoreTrailingSlash));
        data.setImage(m_icon);
        Plasma::ToolTipManager::self()->setContent(this, data);

    }
}
コード例 #5
0
ファイル: projectmodel.cpp プロジェクト: ShermanHuang/kdesdk
/**
 * Makes a list of indices where pot items map to poItems.
 * result[potRow] = poRow or -1 if the pot entry is not found in po.
 * Does not use internal pot and po row number cache.
 */
void ProjectModel::generatePOTMapping(QVector<int> & result, const QModelIndex& poParent, const QModelIndex& potParent) const
{
    result.clear();

    int poRows = m_poModel.rowCount(poParent);
    int potRows = m_potModel.rowCount(potParent);

    if (potRows == 0)
        return;

    QList<KUrl> poOccupiedUrls;

    for (int poPos = 0; poPos < poRows; poPos ++)
    {
        KFileItem file = m_poModel.itemForIndex(m_poModel.index(poPos, 0, poParent));
        KUrl potUrl = poToPot(file.url());
        poOccupiedUrls.append(potUrl);
    }

    for  (int potPos = 0; potPos < potRows; potPos ++)
    {

        KUrl potUrl = m_potModel.itemForIndex(m_potModel.index(potPos, 0, potParent)).url();
        int occupiedPos = -1;

        //TODO: this is slow
        for (int poPos = 0; occupiedPos == -1 && poPos < poOccupiedUrls.count(); poPos ++)
        {
            KUrl& occupiedUrl = poOccupiedUrls[poPos];
            if (potUrl.equals(occupiedUrl))
                occupiedPos = poPos;
        }

        result.append(occupiedPos);
    }
}
コード例 #6
0
ファイル: kurlnavigator.cpp プロジェクト: fluxer/kdelibs
void KUrlNavigator::Private::updateButtonVisibility()
{
    if (m_editable) {
        return;
    }

    const int buttonsCount = m_navButtons.count();
    if (buttonsCount == 0) {
        m_dropDownButton->hide();
        return;
    }

    // Subtract all widgets from the available width, that must be shown anyway
    int availableWidth = q->width() - m_toggleEditableMode->minimumWidth();

    if ((m_placesSelector != 0) && m_placesSelector->isVisible()) {
        availableWidth -= m_placesSelector->width();
    }

    if ((m_protocols != 0) && m_protocols->isVisible()) {
        availableWidth -= m_protocols->width();
    }

    // Check whether buttons must be hidden at all...
    int requiredButtonWidth = 0;
    foreach (const KUrlNavigatorButton* button, m_navButtons) {
        requiredButtonWidth += button->minimumWidth();
    }

    if (requiredButtonWidth > availableWidth) {
        // At least one button must be hidden. This implies that the
        // drop-down button must get visible, which again decreases the
        // available width.
        availableWidth -= m_dropDownButton->width();
    }

    // Hide buttons...
    QList<KUrlNavigatorButton*>::const_iterator it = m_navButtons.constEnd();
    const QList<KUrlNavigatorButton*>::const_iterator itBegin = m_navButtons.constBegin();
    bool isLastButton = true;
    bool hasHiddenButtons = false;

    QLinkedList<KUrlNavigatorButton*> buttonsToShow;
    while (it != itBegin) {
        --it;
        KUrlNavigatorButton* button = (*it);
        availableWidth -= button->minimumWidth();
        if ((availableWidth <= 0) && !isLastButton) {
            button->hide();
            hasHiddenButtons = true;
        }
        else {
            // Don't show the button immediately, as setActive()
            // might change the size and a relayout gets triggered
            // after showing the button. So the showing of all buttons
            // is postponed until all buttons have the correct
            // activation state.
            buttonsToShow.append(button);
        }
        isLastButton = false;
    }

    // All buttons have the correct activation state and
    // can be shown now
    foreach (KUrlNavigatorButton* button, buttonsToShow) {
        button->show();
    }

    if (hasHiddenButtons) {
        m_dropDownButton->show();
    } else {
        // Check whether going upwards is possible. If this is the case, show the drop-down button.
        KUrl url = m_navButtons.front()->url();
        url.adjustPath(KUrl::AddTrailingSlash);
        const bool visible = !url.equals(url.upUrl());
        m_dropDownButton->setVisible(visible);
    }
}