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

kaddressbook

cardview.h

Go to the documentation of this file.
00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #ifndef CARDVIEW_H
00025 #define CARDVIEW_H
00026 
00027 #include <QtCore/QPair>
00028 #include <QtCore/QPoint>
00029 #include <QtCore/QString>
00030 #include <Qt3Support/Q3ListBox>
00031 #include <Qt3Support/Q3PtrList>
00032 #include <Qt3Support/Q3ScrollView>
00033 
00034 class QEvent;
00035 class QFocusEvent;
00036 class QKeyEvent;
00037 class QLabel;
00038 class QMouseEvent;
00039 class QPainter;
00040 class QRect;
00041 class QResizeEvent;
00042 class QWheelEvent;
00043 
00044 class CardView;
00045 class CardViewItemPrivate;
00046 class CardViewPrivate;
00047 class CardViewTip;
00048 
00054 class CardViewItem
00055 {
00056   friend class CardView;
00057 
00058   public:
00063     typedef QPair<QString, QString> Field;
00064 
00073     CardViewItem( CardView *parent, const QString &caption = QString() );
00074     virtual ~CardViewItem();
00075 
00079     const QString &caption() const;
00080 
00086     void setCaption( const QString &caption );
00087 
00092     virtual void paintCard( QPainter *p, const QPalette &pal );
00093 
00098     virtual void repaintCard();
00099 
00107     void insertField( const QString &label, const QString &value );
00108 
00112     void removeField( const QString &label );
00113 
00117     QString fieldValue( const QString &label ) const;
00118 
00122     void clearFields();
00123 
00129     CardViewItem *nextItem() const;
00130 
00134     bool isSelected() const;
00135 
00141     void showFullString( const QPoint &pos, CardViewTip *tip );
00142 
00148     Field *fieldAt( const QPoint &itempos ) const;
00149 
00150     CardView *cardView() const { return mView; }
00151 
00160     int height( bool allowCache = true ) const;
00161 
00162   protected:
00167     void setSelected( bool selected );
00168 
00169   private:
00173     void initialize();
00174 
00181     QString trimString( const QString &text, int width, QFontMetrics &fm ) const;
00182 
00183     CardViewItemPrivate *d;
00184     CardView *mView;
00185 };
00186 
00199 class CardView : public Q3ScrollView
00200 {
00201   friend class CardViewItem;
00202 
00203   Q_OBJECT
00204 
00205   public:
00209     CardView( QWidget *parent, const char *name );
00210     virtual ~CardView();
00211 
00217     void insertItem( CardViewItem *item );
00218 
00223     void takeItem( CardViewItem *item );
00224 
00228     void clear();
00229 
00236     CardViewItem *currentItem() const;
00237 
00241     void setCurrentItem( CardViewItem *item );
00242 
00247     CardViewItem *itemAt( const QPoint &viewPos ) const;
00248 
00252     QRect itemRect( const CardViewItem *item ) const;
00253 
00257     void ensureItemVisible( const CardViewItem *item );
00258 
00262     void repaintItem( const CardViewItem *item );
00263 
00264     enum SelectionMode { Single, Multi, Extended, NoSelection };
00265 
00271     void setSelectionMode( SelectionMode mode );
00272 
00276     SelectionMode selectionMode() const;
00277 
00282     void setSelected( CardViewItem *item, bool selected );
00283 
00287     void selectAll( bool state );
00288 
00292     bool isSelected( CardViewItem *item ) const;
00293 
00299     CardViewItem *selectedItem() const;
00300 
00306     CardViewItem *firstItem() const;
00307 
00312     CardViewItem *itemAfter( const CardViewItem *item ) const;
00313 
00317     int childCount() const;
00318 
00328     CardViewItem *findItem( const QString &text, const QString &label,
00329                             Q3ListBox::StringComparisonMode compare = Q3ListBox::BeginsWith ) const;
00330 
00338     uint columnWidth() const;
00339 
00345     void setDrawCardBorder( bool enabled );
00346 
00350     bool drawCardBorder() const;
00351 
00358     void setDrawColSeparators( bool enabled );
00359 
00363     bool drawColSeparators() const;
00364 
00371     void setDrawFieldLabels( bool enabled );
00372 
00376     bool drawFieldLabels() const;
00377 
00382     void setShowEmptyFields( bool show );
00383 
00387     bool showEmptyFields() const;
00388 
00398     // Note: I looked for a value in QStyle::PixelMetric to use, but I could
00399     // not see a useful one. One may turn up in a future version of Qt.
00400     uint itemMargin() const;
00401 
00405     void setItemMargin( uint margin );
00406 
00413     // Note: There is no useful QStyle::PixelMetric to use for this atm.
00414     // An option would be using KDialog::spacingHint().
00415     uint itemSpacing() const;
00416 
00421     void setItemSpacing( uint spacing );
00422 
00426     int itemWidth() const;
00427 
00431     void setItemWidth( int width );
00432 
00436     void setHeaderFont( const QFont &fnt );
00437 
00441     QFont headerFont() const;
00442 
00446     void setFont( const QFont &fnt );
00447 
00451     void setSeparatorWidth( int width );
00452 
00456     int separatorWidth() const;
00457 
00462     void setMaxFieldLines( int howmany );
00463 
00467     int maxFieldLines() const;
00468 
00469   Q_SIGNALS:
00474     void selectionChanged();
00475 
00481     void selectionChanged( CardViewItem* );
00482 
00486     void clicked( CardViewItem* );
00487 
00493     void executed( CardViewItem* );
00494 
00498     void doubleClicked( CardViewItem* );
00499 
00503     void currentChanged( CardViewItem* );
00504 
00508     void returnPressed( CardViewItem* );
00509 
00513     void contextMenuRequested( CardViewItem*, const QPoint& );
00514 
00515   protected:
00520     void drawContents( QPainter *p, int clipx, int clipy, int clipw, int cliph );
00521 
00525     void resizeEvent( QResizeEvent* );
00526 
00530     void contentsWheelEvent( QWheelEvent* );
00531 
00535     void setLayoutDirty( bool dirty );
00536 
00542     void calcLayout();
00543 
00544     virtual void contentsMousePressEvent( QMouseEvent* );
00545     virtual void contentsMouseMoveEvent( QMouseEvent* );
00546     virtual void contentsMouseReleaseEvent( QMouseEvent* );
00547     virtual void contentsMouseDoubleClickEvent( QMouseEvent* );
00548 
00549     virtual void enterEvent( QEvent* );
00550     virtual void leaveEvent( QEvent* );
00551 
00552     virtual void focusInEvent( QFocusEvent* );
00553     virtual void focusOutEvent( QFocusEvent* );
00554 
00555     virtual void keyPressEvent( QKeyEvent* );
00556 
00562     virtual void startDrag();
00563 
00564   private Q_SLOTS:
00570     void tryShowFullText();
00571 
00572   private:
00579     void drawRubberBands( int pos );
00580 
00581     CardViewPrivate *d;
00582 };
00583 
00584 #endif

kaddressbook

Skip menu "kaddressbook"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim 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