コード例 #1
0
ファイル: sorteddirmodel.cpp プロジェクト: KDE/gwenview
bool SortedDirModel::filterAcceptsRow(int row, const QModelIndex& parent) const
{
    QModelIndex index = d->mSourceModel->index(row, 0, parent);
    KFileItem fileItem = d->mSourceModel->itemForIndex(index);

    MimeTypeUtils::Kinds kind = MimeTypeUtils::fileItemKind(fileItem);
    if (d->mKindFilter != MimeTypeUtils::Kinds() && !(d->mKindFilter & kind)) {
        return false;
    }

    if (kind != MimeTypeUtils::KIND_DIR && kind != MimeTypeUtils::KIND_ARCHIVE) {
        int dotPos = fileItem.name().lastIndexOf('.');
        if (dotPos >= 1) {
            QString extension = fileItem.name().mid(dotPos + 1).toLower();
            if (d->mBlackListedExtensions.contains(extension)) {
                return false;
            }
        }
#ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
        if (!d->mSourceModel->semanticInfoAvailableForIndex(index)) {
            Q_FOREACH(const AbstractSortedDirModelFilter * filter, d->mFilters) {
                // Make sure we have semanticinfo, otherwise retrieve it and
                // return false, we will be called again later when it is
                // there.
                if (filter->needsSemanticInfo()) {
                    d->mSourceModel->retrieveSemanticInfoForIndex(index);
                    return false;
                }
            }
        }
コード例 #2
0
ファイル: renamedialog.cpp プロジェクト: fluxer/kde-baseapps
HgRenameDialog::HgRenameDialog(const KFileItem &source, QWidget *parent):
    KDialog(parent, Qt::Dialog),
    m_source(source.name()),
    m_source_dir(source.url().directory())
{
    this->setCaption(i18nc("@title:window",
                "<application>Hg</application> Rename"));
    this->setButtons(KDialog::Ok | KDialog::Cancel);
    this->setDefaultButton(KDialog::Ok);
    this->setButtonText(KDialog::Ok, i18nc("@action:button", "Rename"));

    QFrame *frame = new QFrame(this);
    QGridLayout *mainLayout = new QGridLayout(frame);

    QLabel *sourceLabel = new QLabel(i18nc("@label:label to source file",
                "Source "), frame);
    QLabel *sourceFileLabel = new QLabel("<b>" + m_source + "</b>");
    mainLayout->addWidget(sourceLabel, 0, 0);
    mainLayout->addWidget(sourceFileLabel, 0, 1);

    QLabel *destinationLabel 
        = new QLabel(i18nc("@label:rename", "Rename to "), frame);
    m_destinationFile = new KLineEdit(m_source, frame);
    mainLayout->addWidget(destinationLabel, 1, 0);
    mainLayout->addWidget(m_destinationFile, 1, 1);

    frame->setLayout(mainLayout);
    setMainWidget(frame);

    m_destinationFile->setFocus();
    m_destinationFile->selectAll();

    connect(m_destinationFile, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotTextChanged(const QString &)));
}
コード例 #3
0
void KFileView::setCurrentItem(const QString &filename )
{
    if (!filename.isNull()) {
        KFileItem *item;
        for ( (item = firstFileItem()); item; item = nextItem( item ) ) {
            if (item->name() == filename) {
                setCurrentItem( item );
                return;
            }
        }
    }

    kdDebug(kfile_area) << "setCurrentItem: no match found: " << filename << endl;
}
コード例 #4
0
//
// private methods
//
void ExportSymlinks::doExport()
{
    KFileItem * currentFile;
    for ( currentFile = m_sourceFiles->first(); currentFile; currentFile = m_sourceFiles->next() ) {
    
        QString symlink = QString("%1/%2").arg(*m_destinationDir).arg(currentFile->name());
        m_progressDialog->setLabel(symlink);
        kapp->processEvents();
    
        createSymlink(currentFile->url().path(), symlink);
    
        // in any case increase progress
        m_progressDialog->progressBar()->advance(1);
    
        // exit loop if cancel was called
        if (m_cancelling) {
        break;
        }
    }
    
    m_progressDialog->hide();
}
コード例 #5
0
bool
DirPlaylistTrackFilterProxyModel::filterAcceptsRow( int source_row,
                                                    const QModelIndex& source_parent ) const
{
    QModelIndex index = sourceModel()->index( source_row, 0, source_parent );

    QVariant qvar = index.data( KDirModel::FileItemRole );
    if( !qvar.canConvert<KFileItem>() )
        return false;

    KFileItem item = qvar.value<KFileItem>();

    if( item.name() == "." )
        return false;

    if( item.isDir() ||
        Playlists::isPlaylist( item.url() ) ||
        MetaFile::Track::isTrack( item.url() ) )
    {
        return QSortFilterProxyModel::filterAcceptsRow( source_row, source_parent );
    }

    return false;
}