QString DolphinView::selectionStatusBarText() const
{
    QString text;
    const KFileItemList* list = selectedItems();
    assert((list != 0) && !list->isEmpty());

    int fileCount = 0;
    int folderCount = 0;
    KIO::filesize_t byteSize = 0;
    for (KFileItemListIterator it(*list); it.current() != 0; ++it) {
        KFileItem* item = it.current();
        if (item->isDir()) {
            ++folderCount;
        }
        else {
            ++fileCount;
            byteSize += item->size();
        }
    }

    if (folderCount>0) {
        text = i18n("1 Folder selected","%n Folders selected", folderCount);
    }

    if ((fileCount > 0) && (folderCount > 0)) {
        text += ", ";
    }

    if (fileCount > 0) {
        const QString sizeText(KIO::convertSize(byteSize));
        text += i18n("1 File selected (%1)", "%n Files selected (%1)", fileCount).arg(sizeText);
    }

    return text;
}
Example #2
0
KfFileLVI::KfFileLVI(KfindWindow* lv, const KFileItem &item, const TQString& matchingLine)
  : TQListViewItem(lv),
    fileitem(item)
{
  fileInfo = new TQFileInfo(item.url().path());

  TQString size = TDEGlobal::locale()->formatNumber(item.size(), 0);

  TQDateTime dt;
  dt.setTime_t(item.time(TDEIO::UDS_MODIFICATION_TIME));
  TQString date = TDEGlobal::locale()->formatDateTime(dt);

  int perm_index;
  if(fileInfo->isReadable())
    perm_index = fileInfo->isWritable() ? RW : RO;
  else
    perm_index = fileInfo->isWritable() ? WO : NA;

  // Fill the item with data
  setText(0, item.url().fileName(false));
  setText(1, lv->reducedDir(item.url().directory(false)));
  setText(2, size);
  setText(3, date);
  setText(4, i18n(perm[perm_index]));
  setText(5, matchingLine);

  // put the icon into the leftmost column
  setPixmap(0, item.pixmap(16));
}
Example #3
0
bool KFileItem::cmp( const KFileItem & item )
{
    bool hasSize1,hasSize2,hasTime1,hasTime2;
    hasSize1 = hasSize2 = hasTime1 = hasTime2 = false;
    return ( m_strName == item.m_strName
             && m_bIsLocalURL == item.m_bIsLocalURL
             && m_fileMode == item.m_fileMode
             && m_permissions == item.m_permissions
             && m_user == item.m_user
             && m_group == item.m_group
             && m_bLink == item.m_bLink
             && m_hidden == item.m_hidden
             && size(hasSize1) == item.size(hasSize2)
	     && hasSize1 == hasSize2
             && time(KIO::UDS_MODIFICATION_TIME, hasTime1) == item.time(KIO::UDS_MODIFICATION_TIME, hasTime2)
	     && hasTime1 == hasTime2
             && (!d || !item.d || d->iconName == item.d->iconName) );

    // Don't compare the mimetypes here. They might not be known, and we don't want to
    // do the slow operation of determining them here.
}
Example #4
0
void KFileDetailView::slotSortingChanged( int col )
{
    // col is the section here, not the index!
    
    TQDir::SortSpec sort = sorting();
    int sortSpec = -1;
    bool reversed = (col == m_sortingCol) && (sort & TQDir::Reversed) == 0;
    m_sortingCol = col;

    switch( col ) {
        case COL_NAME:
            sortSpec = (sort & ~TQDir::SortByMask | TQDir::Name);
            break;
        case COL_SIZE:
            sortSpec = (sort & ~TQDir::SortByMask | TQDir::Size);
            break;
        case COL_DATE:
            sortSpec = (sort & ~TQDir::SortByMask | TQDir::Time);
            break;

        // the following columns have no equivalent in TQDir, so we set it
        // to TQDir::Unsorted and remember the column (m_sortingCol)
        case COL_OWNER:
        case COL_GROUP:
        case COL_PERM:
            // grmbl, TQDir::Unsorted == SortByMask.
            sortSpec = (sort & ~TQDir::SortByMask);// | TQDir::Unsorted;
            break;
        default:
            break;
    }

    if ( reversed )
        sortSpec |= TQDir::Reversed;
    else
        sortSpec &= ~TQDir::Reversed;

    if ( sort & TQDir::IgnoreCase )
        sortSpec |= TQDir::IgnoreCase;
    else
        sortSpec &= ~TQDir::IgnoreCase;


    KFileView::setSorting( static_cast<TQDir::SortSpec>( sortSpec ) );

    KFileItem *item;
    KFileItemListIterator it( *items() );

    if ( sortSpec & TQDir::Time ) {
        for ( ; (item = it.current()); ++it )
            viewItem(item)->setKey( sortingKey( item->time( TDEIO::UDS_MODIFICATION_TIME ), item->isDir(), sortSpec ));
    }

    else if ( sortSpec & TQDir::Size ) {
        for ( ; (item = it.current()); ++it )
            viewItem(item)->setKey( sortingKey( item->size(), item->isDir(),
                                                sortSpec ));
    }
    else { // Name or Unsorted -> use column text
        for ( ; (item = it.current()); ++it ) {
            KFileListViewItem *i = viewItem( item );
            i->setKey( sortingKey( i->text(m_sortingCol), item->isDir(),
                                   sortSpec ));
        }
    }

    TDEListView::setSorting( m_sortingCol, !reversed );
    TDEListView::sort();

    if ( !m_blockSortingSignal )
        sig->changeSorting( static_cast<TQDir::SortSpec>( sortSpec ) );
}