Logo Search packages:      
Sourcecode: k4dirstat version File versions  Download package

void KDirTreeView::popupContextMenu ( Q3ListViewItem *  listViewItem,
const QPoint &  pos,
int  column 
) [protected, slot]

Pop up context menu (i.e. emit the contextMenu() signal) or open a small info popup with exact information, depending on 'column'.

Definition at line 792 of file kdirtreeview.cpp.

References KDirStat::KFileInfo::allocatedSize(), KDirStat::KFileInfo::byteSize(), contextMenu(), KDirStat::KExcludeRules::excludeRules(), KDirStat::KFileInfo::isDir(), KDirStat::KFileInfo::isDotEntry(), KDirStat::KFileInfo::isExcluded(), KDirStat::KFileInfo::isFile(), KDirStat::KFileInfo::isSparseFile(), KDirStat::KFileInfo::latestMtime(), KDirStat::KFileInfo::links(), logActivity(), KDirStat::KExcludeRules::matchingRule(), KDirStat::KDirTreeViewItem::orig(), popupContextInfo(), popupContextSizeInfo(), KDirStat::KExcludeRule::regexp(), selectItem(), KDirStat::KFileInfo::size(), KDirStat::KFileInfo::totalSize(), and KDirStat::KFileInfo::url().

Referenced by KDirTreeView().

{
    KDirTreeViewItem *item = (KDirTreeViewItem *) listViewItem;

    if ( ! item )
      return;

    KFileInfo * orig = item->orig();

    if ( ! orig )
    {
      kdError() << "NULL item->orig()" << endl;
      return;
    }

    if ( column == _nameCol         ||
       column == _percentBarCol     ||
       column == _percentNumCol       )
    {
      if ( orig->isExcluded() && column == _percentBarCol )
      {
          // Show with exclude rule caused the exclusion

          const KExcludeRule * rule = KExcludeRules::excludeRules()->matchingRule( orig->url() );

          QString text;

          if ( rule )
          {
            text = i18n( "Matching exclude rule:   %1" ).arg( rule->regexp().pattern() );
          }
          else
          {
            text = i18n( "<Unknown exclude rule>" );
          }

          popupContextInfo( pos, text );
      }
      else
      {
          // Make the item the context menu is popping up over the current
          // selection - all user operations refer to the current selection.
          // Just right-clicking on an item does not make it the current
          // item!
          selectItem( item );

          // Let somebody from outside pop up the context menu, if so desired.
          emit contextMenu( item, pos );
      }
    }


    // If the column is one with a large size in kB/MB/GB, open a
    // info popup with the exact number.

    if ( column == _ownSizeCol && ! item->orig()->isDotEntry() )
    {
      if ( orig->isSparseFile() || ( orig->links() > 1 && orig->isFile() ) )
      {
          QString text;

          if ( orig->isSparseFile() )
          {
            text = i18n( "Sparse file: %1 (%2 Bytes) -- allocated: %3 (%4 Bytes)" )
                .arg( formatSize( orig->byteSize() ) )
                .arg( formatSizeLong( orig->byteSize()  ) )
                .arg( formatSize( orig->allocatedSize() ) )
                .arg( formatSizeLong( orig->allocatedSize() ) );
          }
          else
          {
            text = i18n( "%1 (%2 Bytes) with %3 hard links => effective size: %4 (%5 Bytes)" )
                .arg( formatSize( orig->byteSize() ) )
                .arg( formatSizeLong( orig->byteSize() ) )
                .arg( orig->links() )
                .arg( formatSize( orig->size() ) )
                .arg( formatSizeLong( orig->size() ) );
          }

          popupContextInfo( pos, text );
      }
      else
      {
          popupContextSizeInfo( pos, orig->size() );
      }
    }

    if ( column == _totalSizeCol &&
       ( item->orig()->isDir() || item->orig()->isDotEntry() ) )
    {
      popupContextSizeInfo( pos, item->orig()->totalSize() );
    }


    // Show alternate time / date format in time / date related columns.

    if ( column == _latestMtimeCol )
    {
      popupContextInfo( pos, formatTimeDate( item->orig()->latestMtime() ) );
    }

    logActivity( 3 );
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index