• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

kdf

listview.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright (C) 1999  Espen Sand, espen@kde.org
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation; either version 2 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program; if not, write to the Free Software
00016  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017  *
00018  */
00019 
00020 //
00021 // 1999-11-28 Espen Sand
00022 // The purpose of this class is:
00023 // 1) Easily set minimum number of visible items and to adjust the sizeHint()
00024 // 2) Provide a pixmap collection
00025 //
00026 
00027 #include "listview.h"
00028 #include <QtGui/QBitmap>
00029 #include <Qt3Support/Q3Header>
00030 #include <QtGui/QPainter>
00031 //Added by qt3to4:
00032 #include <QtGui/QPixmap>
00033 
00034 #include <kiconloader.h>
00035 
00036 template class Q3Dict<QPixmap>;
00037 
00038 CListView::CListView( QWidget *parent, const char *name, int visibleItem )
00039   :K3ListView( parent ),  mVisibleItem(qMax( 1, visibleItem ))
00040 {
00041   setObjectName(name);
00042   setVisibleItem(visibleItem);
00043   mPixDict.setAutoDelete(true);
00044 }
00045 
00046 void CListView::setVisibleItem( int visibleItem, bool updateSize )
00047 {
00048   mVisibleItem = qMax( 1, visibleItem );
00049   if( updateSize == true )
00050   {
00051     QSize s = sizeHint();
00052     setMinimumSize( s.width() + verticalScrollBar()->sizeHint().width() +
00053             lineWidth() * 2, s.height() );
00054   }
00055 }
00056 
00057 QSize CListView::sizeHint( void ) const
00058 {
00059   QSize s = Q3ListView::sizeHint();
00060 
00061   int h = fontMetrics().height() + 2*itemMargin();
00062   if( h % 2 > 0 ) { h++; }
00063 
00064   s.setHeight( h*mVisibleItem + lineWidth()*2 + header()->sizeHint().height());
00065   return( s );
00066 }
00067 
00068 
00069 
00070 const QPixmap &CListView::icon( const QString &iconName, bool drawBorder )
00071 {
00072   QPixmap *pix = mPixDict[ iconName ];
00073   if( pix == 0 )
00074   {
00075     pix = new QPixmap( SmallIcon( iconName ) );
00076 
00077     if( drawBorder == true )
00078     {
00079       //
00080       // 2000-01-23 Espen Sand
00081       // Careful here: If the mask has not been defined we can
00082       // not use QPixmap::mask() because it returns 0 => segfault
00083       //
00084       if( !pix->mask().isNull() )
00085       {
00086     QBitmap *bm = new QBitmap((pix->mask()));
00087     if( bm != 0 )
00088     {
00089       QPainter qp(bm);
00090       qp.setPen(QPen(Qt::white,1));
00091       qp.drawRect(0,0,bm->width(),bm->height());
00092       qp.end();
00093       pix->setMask(*bm);
00094     }
00095 
00096     QPainter qp(pix);
00097     qp.setPen(QPen(Qt::red,1));
00098     qp.drawRect(0,0,pix->width(),pix->height());
00099     qp.end();
00100         delete bm;
00101 
00102       }
00103     }
00104     mPixDict.replace( iconName, pix );
00105   }
00106 
00107   return( *pix );
00108 }
00109 
00110 
00111 #include "listview.moc"
00112 
00113 
00114 
00115 

kdf

Skip menu "kdf"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • okteta
  • printer-applet
  • superkaramba
  • sweeper
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal