37#include "keylistview.h" 
   41#include <tqfontmetrics.h> 
   53#include <gpgmepp/key.h> 
   60static const int updateDelayMilliSecs = 500;
 
   64  class ItemToolTip : 
public TQToolTip {
 
   66    ItemToolTip( Kleo::KeyListView * parent );
 
   68    void maybeTip( 
const TQPoint & p );
 
   70    Kleo::KeyListView * mKeyListView;
 
   73  ItemToolTip::ItemToolTip( Kleo::KeyListView * parent )
 
   74    : TQToolTip( parent->viewport() ), mKeyListView( parent ) {}
 
   76  void ItemToolTip::maybeTip( 
const TQPoint & p ) {
 
   80    const TQListViewItem * item = mKeyListView->itemAt( p );
 
   84    const TQRect itemRect = mKeyListView->itemRect( item );
 
   85    if ( !itemRect.isValid() )
 
   88    const int col = mKeyListView->header()->sectionAt( p.x() );
 
   92    const TQRect headerRect = mKeyListView->header()->sectionRect( col );
 
   93    if ( !headerRect.isValid() )
 
   96    const TQRect cellRect( headerRect.left(), itemRect.top(),
 
   97              headerRect.width(), itemRect.height() );
 
  100    if ( 
const Kleo::KeyListViewItem * klvi = Kleo::lvi_cast<Kleo::KeyListViewItem>( item ) )
 
  101      tipStr = klvi->toolTip( col );
 
  103      tipStr = item->text( col ) ;
 
  105    if ( !tipStr.isEmpty() )
 
  106      tip( cellRect, tipStr );
 
  111struct Kleo::KeyListView::Private {
 
  112  Private() : updateTimer( 0 ), itemToolTip( 0 ) {}
 
  114  std::vector<GpgME::Key> keyBuffer;
 
  115  TQTimer * updateTimer;
 
  116  TQToolTip * itemToolTip;
 
  117  std::map<TQCString,KeyListViewItem*> itemMap;
 
  125} signalReplacements[] = {
 
  126  { TQ_SIGNAL(doubleClicked(TQListViewItem*,
const TQPoint&,
int)),
 
  127    TQ_SLOT(slotEmitDoubleClicked(TQListViewItem*,
const TQPoint&,
int)) },
 
  128  { TQ_SIGNAL(returnPressed(TQListViewItem*)),
 
  129    TQ_SLOT(slotEmitReturnPressed(TQListViewItem*)) },
 
  130  { TQ_SIGNAL(selectionChanged(TQListViewItem*)),
 
  131    TQ_SLOT(slotEmitSelectionChanged(TQListViewItem*)) },
 
  132  { TQ_SIGNAL(contextMenu(TDEListView*, TQListViewItem*,
const TQPoint&)),
 
  133    TQ_SLOT(slotEmitContextMenu(TDEListView*, TQListViewItem*,
const TQPoint&)) },
 
  135static const int numSignalReplacements = 
sizeof signalReplacements / 
sizeof *signalReplacements;
 
  138Kleo::KeyListView::KeyListView( 
const ColumnStrategy * columnStrategy, 
const DisplayStrategy * displayStrategy, TQWidget * parent, 
const char * name, WFlags f )
 
  139  : TDEListView( parent, name ),
 
  140    mColumnStrategy( columnStrategy ),
 
  141    mDisplayStrategy ( displayStrategy  ),
 
  142    mHierarchical( false )
 
  148  d->updateTimer = 
new TQTimer( 
this );
 
  149  connect( d->updateTimer, TQ_SIGNAL(timeout()), TQ_SLOT(slotUpdateTimeout()) );
 
  151  if ( !columnStrategy ) {
 
  152    kdWarning(5150) << 
"Kleo::KeyListView: need a column strategy to work with!" << endl;
 
  156  const TQFontMetrics fm = fontMetrics();
 
  158  for ( 
int col = 0 ; !columnStrategy->title( col ).isEmpty() ; ++col ) {
 
  159    addColumn( columnStrategy->title( col ), columnStrategy->width( col, fm ) );
 
  160    setColumnWidthMode( col, columnStrategy->widthMode( col ) );
 
  163  setAllColumnsShowFocus( 
true );
 
  164  setShowToolTips( 
false ); 
 
  166  for ( 
int i = 0 ; i < numSignalReplacements ; ++i )
 
  167    connect( 
this, signalReplacements[i].source, signalReplacements[i].target );
 
  169  TQToolTip::remove( 
this );
 
  170  TQToolTip::remove( viewport() ); 
 
  171  d->itemToolTip = 
new ItemToolTip( 
this );
 
  174Kleo::KeyListView::~KeyListView() {
 
  175  d->updateTimer->stop();
 
  180  assert( d->itemMap.size() == 0 );
 
  182  delete d->itemToolTip; d->itemToolTip = 0;
 
  184  delete mColumnStrategy; mColumnStrategy = 0;
 
  185  delete mDisplayStrategy; mDisplayStrategy = 0;
 
  188void Kleo::KeyListView::insertItem( TQListViewItem * qlvi ) {
 
  190  TDEListView::insertItem( qlvi );
 
  191  if ( KeyListViewItem * item = lvi_cast<KeyListViewItem>( qlvi ) )
 
  192    registerItem( item );
 
  195void Kleo::KeyListView::takeItem( TQListViewItem * qlvi ) {
 
  197  if ( KeyListViewItem * item = lvi_cast<KeyListViewItem>( qlvi ) )
 
  198    deregisterItem( item );
 
  199  TDEListView::takeItem( qlvi );
 
  203void Kleo::KeyListView::setHierarchical( 
bool hier ) {
 
  204  if ( hier == mHierarchical )
 
  206  mHierarchical = hier;
 
  210    scatterGathered( firstChild() );
 
  213void Kleo::KeyListView::slotAddKey( 
const GpgME::Key & key ) {
 
  217  d->keyBuffer.push_back( key );
 
  218  if ( !d->updateTimer->isActive() )
 
  219    d->updateTimer->start( updateDelayMilliSecs, 
true  );
 
  222void Kleo::KeyListView::slotUpdateTimeout() {
 
  223  if ( d->keyBuffer.empty() )
 
  226  const bool wasUpdatesEnabled = viewport()->isUpdatesEnabled();
 
  227  if ( wasUpdatesEnabled )
 
  228    viewport()->setUpdatesEnabled( 
false );
 
  229  kdDebug( 5150 ) << 
"Kleo::KeyListView::slotUpdateTimeout(): processing " 
  230          << d->keyBuffer.size() << 
" items en block" << endl;
 
  231  if ( hierarchical() ) {
 
  232    for ( std::vector<GpgME::Key>::const_iterator it = d->keyBuffer.begin() ; it != d->keyBuffer.end() ; ++it )
 
  233      doHierarchicalInsert( *it );
 
  236    for ( std::vector<GpgME::Key>::const_iterator it = d->keyBuffer.begin() ; it != d->keyBuffer.end() ; ++it )
 
  237      (void)
new KeyListViewItem( 
this, *it );
 
  239  if ( wasUpdatesEnabled )
 
  240    viewport()->setUpdatesEnabled( 
true );
 
  241  d->keyBuffer.clear();
 
  244void Kleo::KeyListView::clear() {
 
  245  d->updateTimer->stop();
 
  246  d->keyBuffer.clear();
 
  247  TDEListView::clear();
 
  250void Kleo::KeyListView::registerItem( KeyListViewItem * item ) {
 
  254  const TQCString fpr = item->key().primaryFingerprint();
 
  255  if ( !fpr.isEmpty() )
 
  256    d->itemMap.insert( std::make_pair( fpr, item ) );
 
  259void Kleo::KeyListView::deregisterItem( 
const KeyListViewItem * item ) {
 
  263  std::map<TQCString,KeyListViewItem*>::iterator it
 
  264    = d->itemMap.find( item->key().primaryFingerprint() );
 
  265  if ( it == d->itemMap.end() )
 
  267  Q_ASSERT( it->second == item );
 
  268  if ( it->second != item )
 
  270  d->itemMap.erase( it );
 
  273void Kleo::KeyListView::doHierarchicalInsert( 
const GpgME::Key & key ) {
 
  274  const TQCString fpr = key.primaryFingerprint();
 
  277  KeyListViewItem * item = 0;
 
  279    if ( KeyListViewItem * parent = itemByFingerprint( key.chainID() ) ) {
 
  280      item = 
new KeyListViewItem( parent, key );
 
  281      parent->setOpen( 
true );
 
  284    item = 
new KeyListViewItem( 
this, key ); 
 
  286  d->itemMap.insert( std::make_pair( fpr, item ) );
 
  289void Kleo::KeyListView::gatherScattered() {
 
  290  KeyListViewItem * item = firstChild();
 
  292    KeyListViewItem * cur = item;
 
  293    item = item->nextSibling();
 
  294    if ( cur->key().isRoot() )
 
  296    if ( KeyListViewItem * parent = itemByFingerprint( cur->key().chainID() ) ) {
 
  300      parent->insertItem( cur );
 
  301      parent->setOpen( 
true );
 
  306void Kleo::KeyListView::scatterGathered( TQListViewItem * start ) {
 
  307  TQListViewItem * item = start;
 
  309    TQListViewItem * cur = item;
 
  310    item = item->nextSibling();
 
  312    scatterGathered( cur->firstChild() );
 
  313    assert( cur->childCount() == 0 );
 
  317      cur->parent()->takeItem( cur );
 
  324Kleo::KeyListViewItem * Kleo::KeyListView::itemByFingerprint( 
const TQCString & s )
 const {
 
  327  const std::map<TQCString,KeyListViewItem*>::const_iterator it = d->itemMap.find( s );
 
  328  if ( it == d->itemMap.end() )
 
  334void Kleo::KeyListView::slotRefreshKey( 
const GpgME::Key & key ) {
 
  335  const char * fpr = key.primaryFingerprint();
 
  339  if ( KeyListViewItem * item = itemByFingerprint( fpr ) ) {
 
  340    item->setKey ( key );
 
  350void Kleo::KeyListView::slotEmitDoubleClicked( TQListViewItem * item, 
const TQPoint & p, 
int col ) {
 
  351  if ( !item || lvi_cast<KeyListViewItem>( item ) )
 
  352    emit doubleClicked( 
static_cast<KeyListViewItem*
>( item ), p, col );
 
  355void Kleo::KeyListView::slotEmitReturnPressed( TQListViewItem * item ) {
 
  356  if ( !item || lvi_cast<KeyListViewItem>( item ) )
 
  357    emit returnPressed( 
static_cast<KeyListViewItem*
>( item ) );
 
  360void Kleo::KeyListView::slotEmitSelectionChanged( TQListViewItem * item ) {
 
  361  if ( !item || lvi_cast<KeyListViewItem>( item ) )
 
  362    emit selectionChanged( 
static_cast<KeyListViewItem*
>( item ) );
 
  365void Kleo::KeyListView::slotEmitContextMenu( TDEListView*, TQListViewItem * item, 
const TQPoint & p ) {
 
  366  if ( !item || lvi_cast<KeyListViewItem>( item ) )
 
  367    emit contextMenu( 
static_cast<KeyListViewItem*
>( item ), p );
 
  376Kleo::KeyListViewItem::KeyListViewItem( KeyListView * parent, 
const GpgME::Key & key )
 
  377  : TQListViewItem( parent )
 
  382Kleo::KeyListViewItem::KeyListViewItem( KeyListView * parent, KeyListViewItem * after, 
const GpgME::Key & key )
 
  383  : TQListViewItem( parent, after )
 
  388Kleo::KeyListViewItem::KeyListViewItem( KeyListViewItem * parent, 
const GpgME::Key & key )
 
  389  : TQListViewItem( parent )
 
  394Kleo::KeyListViewItem::KeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, 
const GpgME::Key & key )
 
  395  : TQListViewItem( parent, after )
 
  400Kleo::KeyListViewItem::~KeyListViewItem() {
 
  405  while ( TQListViewItem * item = firstChild() )
 
  411  if ( KeyListView * lv = listView() )
 
  412    lv->deregisterItem( 
this );
 
  415void Kleo::KeyListViewItem::setKey( 
const GpgME::Key & key ) {
 
  416  KeyListView * lv = listView();
 
  418    lv->deregisterItem( 
this );
 
  421    lv->registerItem( 
this );
 
  425  const Kleo::KeyListView::ColumnStrategy * cs = lv ? lv->columnStrategy() : 0 ;
 
  428  const int numCols = lv ? lv->columns() : 0 ;
 
  429  for ( 
int i = 0 ; i < numCols ; ++i ) {
 
  430    setText( i, cs->text( key, i ) );
 
  431    if ( 
const TQPixmap * pix = cs->pixmap( key, i ) )
 
  432      setPixmap( i, *pix );
 
  437TQString Kleo::KeyListViewItem::toolTip( 
int col )
 const {
 
  438  return listView() && listView()->columnStrategy()
 
  439    ? listView()->columnStrategy()->toolTip( key(), col )
 
  443int Kleo::KeyListViewItem::compare( TQListViewItem * item, 
int col, 
bool ascending )
 const {
 
  444  if ( !item || item->rtti() != RTTI || !listView() || !listView()->columnStrategy() )
 
  445    return TQListViewItem::compare( item, col, ascending );
 
  446  KeyListViewItem * that = 
static_cast<KeyListViewItem*
>( item );
 
  447  return listView()->columnStrategy()->compare( this->key(), that->key(), col );
 
  450void Kleo::KeyListViewItem::paintCell( TQPainter * p, 
const TQColorGroup & cg, 
int column, 
int width, 
int alignment ) {
 
  451  const KeyListView::DisplayStrategy * ds = listView() ? listView()->displayStrategy() : 0 ;
 
  453    TQListViewItem::paintCell( p, cg, column, width, alignment );
 
  456  const TQColor fg = ds->keyForeground( key(), cg.text() );
 
  457  const TQColor bg = ds->keyBackground( key(), cg.base() );
 
  458  const TQFont f = ds->keyFont( key(), p->font() );
 
  460  TQColorGroup _cg = cg;
 
  462  _cg.setColor( TQColorGroup::Text, fg );
 
  463  _cg.setColor( TQColorGroup::Base, bg );
 
  465  TQListViewItem::paintCell( p, _cg, column, width, alignment );
 
  468void Kleo::KeyListViewItem::insertItem( TQListViewItem * qlvi ) {
 
  470  TQListViewItem::insertItem( qlvi );
 
  471  if ( KeyListViewItem * item = lvi_cast<KeyListViewItem>( qlvi ) )
 
  472    listView()->registerItem( item );
 
  475void Kleo::KeyListViewItem::takeItem( TQListViewItem * qlvi ) {
 
  477  if ( KeyListViewItem * item = lvi_cast<KeyListViewItem>( qlvi ) )
 
  478    listView()->deregisterItem( item );
 
  479  TQListViewItem::takeItem( qlvi );
 
  489Kleo::SubkeyKeyListViewItem::SubkeyKeyListViewItem( KeyListView * parent, 
const GpgME::Subkey & subkey )
 
  490  : KeyListViewItem( parent, subkey.parent() ), mSubkey( subkey )
 
  495Kleo::SubkeyKeyListViewItem::SubkeyKeyListViewItem( KeyListView * parent, KeyListViewItem * after, 
const GpgME::Subkey & subkey )
 
  496  : KeyListViewItem( parent, after, subkey.parent() ), mSubkey( subkey )
 
  501Kleo::SubkeyKeyListViewItem::SubkeyKeyListViewItem( KeyListViewItem * parent, 
const GpgME::Subkey & subkey )
 
  502  : KeyListViewItem( parent, subkey.parent() ), mSubkey( subkey )
 
  507Kleo::SubkeyKeyListViewItem::SubkeyKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, 
const GpgME::Subkey & subkey )
 
  508  : KeyListViewItem( parent, after, subkey.parent() ), mSubkey( subkey )
 
  513void Kleo::SubkeyKeyListViewItem::setSubkey( 
const GpgME::Subkey & subkey ) {
 
  515  setKey( subkey.parent() );
 
  518TQString Kleo::SubkeyKeyListViewItem::text( 
int col )
 const {
 
  519  return listView() && listView()->columnStrategy()
 
  520    ? listView()->columnStrategy()->subkeyText( subkey(), col )
 
  524TQString Kleo::SubkeyKeyListViewItem::toolTip( 
int col )
 const {
 
  525  return listView() && listView()->columnStrategy()
 
  526    ? listView()->columnStrategy()->subkeyToolTip( subkey(), col )
 
  530const TQPixmap * Kleo::SubkeyKeyListViewItem::pixmap( 
int col )
 const {
 
  531  return listView() && listView()->columnStrategy()
 
  532    ? listView()->columnStrategy()->subkeyPixmap( subkey(), col ) : 0 ;
 
  535int Kleo::SubkeyKeyListViewItem::compare( TQListViewItem * item, 
int col, 
bool ascending )
 const {
 
  536  if ( !item || item->rtti() != RTTI || !listView() || !listView()->columnStrategy() )
 
  537    return KeyListViewItem::compare( item, col, ascending );
 
  538  SubkeyKeyListViewItem * that = 
static_cast<SubkeyKeyListViewItem*
>( item );
 
  539  return listView()->columnStrategy()->subkeyCompare( this->subkey(), that->subkey(), col );
 
  542void Kleo::SubkeyKeyListViewItem::paintCell( TQPainter * p, 
const TQColorGroup & cg, 
int column, 
int width, 
int alignment ) {
 
  543  const KeyListView::DisplayStrategy * ds = listView() ? listView()->displayStrategy() : 0 ;
 
  545    TQListViewItem::paintCell( p, cg, column, width, alignment );
 
  548  const TQColor fg = ds->subkeyForeground( subkey(), cg.text() );
 
  549  const TQColor bg = ds->subkeyBackground( subkey(), cg.base() );
 
  550  const TQFont f = ds->subkeyFont( subkey(), p->font() );
 
  552  TQColorGroup _cg = cg;
 
  554  _cg.setColor( TQColorGroup::Text, fg );
 
  555  _cg.setColor( TQColorGroup::Base, bg );
 
  557  TQListViewItem::paintCell( p, _cg, column, width, alignment );
 
  567Kleo::UserIDKeyListViewItem::UserIDKeyListViewItem( KeyListView * parent, 
const GpgME::UserID & userID )
 
  568  : KeyListViewItem( parent, userID.parent() ), mUserID( userID )
 
  573Kleo::UserIDKeyListViewItem::UserIDKeyListViewItem( KeyListView * parent, KeyListViewItem * after, 
const GpgME::UserID & userID )
 
  574  : KeyListViewItem( parent, after, userID.parent() ), mUserID( userID )
 
  579Kleo::UserIDKeyListViewItem::UserIDKeyListViewItem( KeyListViewItem * parent, 
const GpgME::UserID & userID )
 
  580  : KeyListViewItem( parent, userID.parent() ), mUserID( userID )
 
  585Kleo::UserIDKeyListViewItem::UserIDKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, 
const GpgME::UserID & userID )
 
  586  : KeyListViewItem( parent, after, userID.parent() ), mUserID( userID )
 
  591void Kleo::UserIDKeyListViewItem::setUserID( 
const GpgME::UserID & userID ) {
 
  593  setKey( userID.parent() );
 
  596TQString Kleo::UserIDKeyListViewItem::text( 
int col )
 const {
 
  597  return listView() && listView()->columnStrategy()
 
  598    ? listView()->columnStrategy()->userIDText( userID(), col )
 
  602TQString Kleo::UserIDKeyListViewItem::toolTip( 
int col )
 const {
 
  603  return listView() && listView()->columnStrategy()
 
  604    ? listView()->columnStrategy()->userIDToolTip( userID(), col )
 
  608const TQPixmap * Kleo::UserIDKeyListViewItem::pixmap( 
int col )
 const {
 
  609  return listView() && listView()->columnStrategy()
 
  610    ? listView()->columnStrategy()->userIDPixmap( userID(), col ) : 0 ;
 
  613int Kleo::UserIDKeyListViewItem::compare( TQListViewItem * item, 
int col, 
bool ascending )
 const {
 
  614  if ( !item || item->rtti() != RTTI || !listView() || !listView()->columnStrategy() )
 
  615    return KeyListViewItem::compare( item, col, ascending );
 
  616  UserIDKeyListViewItem * that = 
static_cast<UserIDKeyListViewItem*
>( item );
 
  617  return listView()->columnStrategy()->userIDCompare( this->userID(), that->userID(), col );
 
  621void Kleo::UserIDKeyListViewItem::paintCell( TQPainter * p, 
const TQColorGroup & cg, 
int column, 
int width, 
int alignment ) {
 
  622  const KeyListView::DisplayStrategy * ds = listView() ? listView()->displayStrategy() : 0 ;
 
  624    TQListViewItem::paintCell( p, cg, column, width, alignment );
 
  627  const TQColor fg = ds->useridForeground( userID(), cg.text() );
 
  628  const TQColor bg = ds->useridBackground( userID(), cg.base() );
 
  629  const TQFont f = ds->useridFont( userID(), p->font() );
 
  631  TQColorGroup _cg = cg;
 
  633  _cg.setColor( TQColorGroup::Text, fg );
 
  634  _cg.setColor( TQColorGroup::Base, bg );
 
  636  TQListViewItem::paintCell( p, _cg, column, width, alignment );
 
  646Kleo::SignatureKeyListViewItem::SignatureKeyListViewItem( KeyListView * parent, 
const GpgME::UserID::Signature & signature )
 
  647  : KeyListViewItem( parent, signature.parent().parent() ), mSignature( signature )
 
  652Kleo::SignatureKeyListViewItem::SignatureKeyListViewItem( KeyListView * parent, KeyListViewItem * after, 
const GpgME::UserID::Signature & signature )
 
  653  : KeyListViewItem( parent, after, signature.parent().parent() ), mSignature( signature )
 
  658Kleo::SignatureKeyListViewItem::SignatureKeyListViewItem( KeyListViewItem * parent, 
const GpgME::UserID::Signature & signature )
 
  659  : KeyListViewItem( parent, signature.parent().parent() ), mSignature( signature )
 
  664Kleo::SignatureKeyListViewItem::SignatureKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, 
const GpgME::UserID::Signature & signature )
 
  665  : KeyListViewItem( parent, after, signature.parent().parent() ), mSignature( signature )
 
  670void Kleo::SignatureKeyListViewItem::setSignature( 
const GpgME::UserID::Signature & signature ) {
 
  671  mSignature = signature;
 
  672  setKey( signature.parent().parent() );
 
  675TQString Kleo::SignatureKeyListViewItem::text( 
int col )
 const {
 
  676  return listView() && listView()->columnStrategy()
 
  677    ? listView()->columnStrategy()->signatureText( signature(), col )
 
  681TQString Kleo::SignatureKeyListViewItem::toolTip( 
int col )
 const {
 
  682  return listView() && listView()->columnStrategy()
 
  683    ? listView()->columnStrategy()->signatureToolTip( signature(), col )
 
  687const TQPixmap * Kleo::SignatureKeyListViewItem::pixmap( 
int col )
 const {
 
  688  return listView() && listView()->columnStrategy()
 
  689    ? listView()->columnStrategy()->signaturePixmap( signature(), col ) : 0 ;
 
  692int Kleo::SignatureKeyListViewItem::compare( TQListViewItem * item, 
int col, 
bool ascending )
 const {
 
  693  if ( !item || item->rtti() != RTTI || !listView() || !listView()->columnStrategy() )
 
  694    return KeyListViewItem::compare( item, col, ascending );
 
  695  SignatureKeyListViewItem * that = 
static_cast<SignatureKeyListViewItem*
>( item );
 
  696  return listView()->columnStrategy()->signatureCompare( this->signature(), that->signature(), col );
 
  699void Kleo::SignatureKeyListViewItem::paintCell( TQPainter * p, 
const TQColorGroup & cg, 
int column, 
int width, 
int alignment ) {
 
  700  const KeyListView::DisplayStrategy * ds = listView() ? listView()->displayStrategy() : 0 ;
 
  702    TQListViewItem::paintCell( p, cg, column, width, alignment );
 
  705  const TQColor fg = ds->signatureForeground( signature(), cg.text() );
 
  706  const TQColor bg = ds->signatureBackground( signature(), cg.base() );
 
  707  const TQFont f = ds->signatureFont( signature(), p->font() );
 
  709  TQColorGroup _cg = cg;
 
  711  _cg.setColor( TQColorGroup::Text, fg );
 
  712  _cg.setColor( TQColorGroup::Base, bg );
 
  714  TQListViewItem::paintCell( p, _cg, column, width, alignment );
 
  724Kleo::KeyListView::ColumnStrategy::~ColumnStrategy() {}
 
  726int Kleo::KeyListView::ColumnStrategy::compare( 
const GpgME::Key & key1, 
const GpgME::Key & key2, 
int col )
 const {
 
  727  return TQString::localeAwareCompare( text( key1, col ), text( key2, col ) );
 
  730int Kleo::KeyListView::ColumnStrategy::width( 
int col, 
const TQFontMetrics & fm )
 const {
 
  731  return fm.width( title( col ) ) * 2;
 
  734int Kleo::KeyListView::ColumnStrategy::subkeyCompare( 
const GpgME::Subkey & sub1, 
const GpgME::Subkey & sub2, 
int col )
 const {
 
  735  return TQString::localeAwareCompare( subkeyText( sub1, col ), subkeyText( sub2, col ) );
 
  738int Kleo::KeyListView::ColumnStrategy::userIDCompare( 
const GpgME::UserID & uid1, 
const GpgME::UserID & uid2, 
int col )
 const {
 
  739  return TQString::localeAwareCompare( userIDText( uid1, col ), userIDText( uid2, col ) );
 
  742int Kleo::KeyListView::ColumnStrategy::signatureCompare( 
const GpgME::UserID::Signature & sig1, 
const GpgME::UserID::Signature & sig2, 
int col )
 const {
 
  743  return TQString::localeAwareCompare( signatureText( sig1, col ), signatureText( sig2, col ) );
 
  746TQString Kleo::KeyListView::ColumnStrategy::toolTip( 
const GpgME::Key & key, 
int col )
 const {
 
  747  return text( key, col );
 
  750TQString Kleo::KeyListView::ColumnStrategy::subkeyToolTip( 
const GpgME::Subkey & sub, 
int col )
 const {
 
  751  return subkeyText( sub, col );
 
  754TQString Kleo::KeyListView::ColumnStrategy::userIDToolTip( 
const GpgME::UserID & uid, 
int col )
 const {
 
  755  return userIDText( uid, col );
 
  758TQString Kleo::KeyListView::ColumnStrategy::signatureToolTip( 
const GpgME::UserID::Signature & sig, 
int col )
 const {
 
  759  return signatureText( sig, col );
 
  768Kleo::KeyListView::DisplayStrategy::~DisplayStrategy() {}
 
  772TQFont Kleo::KeyListView::DisplayStrategy::keyFont( 
const GpgME::Key &, 
const TQFont & font )
 const {
 
  776TQFont Kleo::KeyListView::DisplayStrategy::subkeyFont( 
const GpgME::Subkey &, 
const TQFont & font )
 const {
 
  780TQFont Kleo::KeyListView::DisplayStrategy::useridFont( 
const GpgME::UserID &, 
const TQFont & font )
 const {
 
  784TQFont Kleo::KeyListView::DisplayStrategy::signatureFont( 
const GpgME::UserID::Signature &, 
const TQFont & font )
 const {
 
  789TQColor Kleo::KeyListView::DisplayStrategy::keyForeground( 
const GpgME::Key &, 
const TQColor & fg )
const {
 
  793TQColor Kleo::KeyListView::DisplayStrategy::subkeyForeground( 
const GpgME::Subkey &, 
const TQColor & fg )
 const {
 
  797TQColor Kleo::KeyListView::DisplayStrategy::useridForeground( 
const GpgME::UserID &, 
const TQColor & fg )
 const {
 
  801TQColor Kleo::KeyListView::DisplayStrategy::signatureForeground( 
const GpgME::UserID::Signature &, 
const TQColor & fg )
 const {
 
  806TQColor Kleo::KeyListView::DisplayStrategy::keyBackground( 
const GpgME::Key &, 
const TQColor & bg )
const {
 
  810TQColor Kleo::KeyListView::DisplayStrategy::subkeyBackground( 
const GpgME::Subkey &, 
const TQColor & bg )
 const {
 
  814TQColor Kleo::KeyListView::DisplayStrategy::useridBackground( 
const GpgME::UserID &, 
const TQColor & bg )
 const {
 
  818TQColor Kleo::KeyListView::DisplayStrategy::signatureBackground( 
const GpgME::UserID::Signature &, 
const TQColor & bg )
 const {
 
  830Kleo::KeyListView * Kleo::KeyListViewItem::listView()
 const {
 
  831  return static_cast<Kleo::KeyListView*
>( TQListViewItem::listView() );
 
  834Kleo::KeyListViewItem * Kleo::KeyListViewItem::nextSibling()
 const {
 
  835  return static_cast<Kleo::KeyListViewItem*
>( TQListViewItem::nextSibling() );
 
  838Kleo::KeyListViewItem * Kleo::KeyListView::firstChild()
 const {
 
  839  return static_cast<Kleo::KeyListViewItem*
>( TDEListView::firstChild() );
 
  842Kleo::KeyListViewItem * Kleo::KeyListView::selectedItem()
 const {
 
  843  return static_cast<Kleo::KeyListViewItem*
>( TDEListView::selectedItem() );
 
  846static void selectedItems( TQPtrList<Kleo::KeyListViewItem> & result, TQListViewItem * start ) {
 
  847  for ( TQListViewItem * item = start ; item ; item = item->nextSibling() ) {
 
  848    if ( item->isSelected() )
 
  849      if ( Kleo::KeyListViewItem * i = Kleo::lvi_cast<Kleo::KeyListViewItem>( item ) )
 
  851    selectedItems( result, item->firstChild() );
 
  855TQPtrList<Kleo::KeyListViewItem> Kleo::KeyListView::selectedItems()
 const {
 
  856  TQPtrList<KeyListViewItem> result;
 
  857  ::selectedItems( result, firstChild() );
 
  861static bool hasSelection( TQListViewItem * start ) {
 
  862  for ( TQListViewItem * item = start ; item ; item = item->nextSibling() )
 
  863    if ( item->isSelected() || hasSelection( item->firstChild() ) )
 
  868bool Kleo::KeyListView::hasSelection()
 const {
 
  869  return ::hasSelection( firstChild() );
 
  872#include "keylistview.moc"