Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qheader.h 3.3.8 edited Jan 11 14:38 $ 00003 ** 00004 ** Definition of QHeader widget class (table header) 00005 ** 00006 ** Created : 961105 00007 ** 00008 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00009 ** 00010 ** This file is part of the widgets module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech ASA of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00022 ** licenses may use this file in accordance with the Qt Commercial License 00023 ** Agreement provided with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QHEADER_H 00039 #define QHEADER_H 00040 00041 #ifndef QT_H 00042 #include "qwidget.h" 00043 #include "qstring.h" 00044 #include "qiconset.h" // conversion QPixmap->QIconset 00045 #endif // QT_H 00046 00047 #ifndef QT_NO_HEADER 00048 00049 class QShowEvent; 00050 class QHeaderData; 00051 class QTable; 00052 00053 class Q_EXPORT QHeader : public QWidget 00054 { 00055 friend class QTable; 00056 friend class QTableHeader; 00057 friend class QListView; 00058 00059 Q_OBJECT 00060 Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) 00061 Q_PROPERTY( bool tracking READ tracking WRITE setTracking ) 00062 Q_PROPERTY( int count READ count ) 00063 Q_PROPERTY( int offset READ offset WRITE setOffset ) 00064 Q_PROPERTY( bool moving READ isMovingEnabled WRITE setMovingEnabled ) 00065 Q_PROPERTY( bool stretching READ isStretchEnabled WRITE setStretchEnabled ) 00066 00067 public: 00068 QHeader( QWidget* parent=0, const char* name=0 ); 00069 QHeader( int, QWidget* parent=0, const char* name=0 ); 00070 ~QHeader(); 00071 00072 int addLabel( const QString &, int size = -1 ); 00073 int addLabel( const QIconSet&, const QString &, int size = -1 ); 00074 void removeLabel( int section ); 00075 00076 //### AbanQ Optimization Hack 00077 void removeLabels( int fromSection, int toSection ); 00078 //### 00079 00080 virtual void setLabel( int, const QString &, int size = -1 ); 00081 virtual void setLabel( int, const QIconSet&, const QString &, int size = -1 ); 00082 QString label( int section ) const; 00083 QIconSet* iconSet( int section ) const; 00084 00085 virtual void setOrientation( Orientation ); 00086 Orientation orientation() const; 00087 virtual void setTracking( bool enable ); 00088 bool tracking() const; 00089 00090 virtual void setClickEnabled( bool, int section = -1 ); 00091 virtual void setResizeEnabled( bool, int section = -1 ); 00092 virtual void setMovingEnabled( bool ); 00093 virtual void setStretchEnabled( bool b, int section ); 00094 void setStretchEnabled( bool b ) { setStretchEnabled( b, -1 ); } 00095 bool isClickEnabled( int section = -1 ) const; 00096 bool isResizeEnabled( int section = -1 ) const; 00097 bool isMovingEnabled() const; 00098 bool isStretchEnabled() const; 00099 bool isStretchEnabled( int section ) const; 00100 00101 void resizeSection( int section, int s ); 00102 int sectionSize( int section ) const; 00103 int sectionPos( int section ) const; 00104 int sectionAt( int pos ) const; 00105 int count() const; 00106 int headerWidth() const; 00107 QRect sectionRect( int section ) const; 00108 00109 virtual void setCellSize( int , int ); // obsolete, do not use 00110 int cellSize( int i ) const { return sectionSize( mapToSection(i) ); } // obsolete, do not use 00111 int cellPos( int ) const; // obsolete, do not use 00112 int cellAt( int pos ) const { return mapToIndex( sectionAt(pos + offset()) ); } // obsolete, do not use 00113 00114 int offset() const; 00115 00116 QSize sizeHint() const; 00117 00118 int mapToSection( int index ) const; 00119 int mapToIndex( int section ) const; 00120 int mapToLogical( int ) const; // obsolete, do not use 00121 int mapToActual( int ) const; // obsolete, do not use 00122 00123 void moveSection( int section, int toIndex ); 00124 virtual void moveCell( int, int); // obsolete, do not use 00125 00126 void setSortIndicator( int section, bool ascending = TRUE ); // obsolete, do not use 00127 inline void setSortIndicator( int section, SortOrder order ) 00128 { setSortIndicator( section, (order == Ascending) ); } 00129 int sortIndicatorSection() const; 00130 SortOrder sortIndicatorOrder() const; 00131 00132 void adjustHeaderSize() { adjustHeaderSize( -1 ); } 00133 00134 public slots: 00135 void setUpdatesEnabled( bool enable ); 00136 virtual void setOffset( int pos ); 00137 00138 signals: 00139 void clicked( int section ); 00140 void pressed( int section ); 00141 void released( int section ); 00142 void sizeChange( int section, int oldSize, int newSize ); 00143 void indexChange( int section, int fromIndex, int toIndex ); 00144 void sectionClicked( int ); // obsolete, do not use 00145 void moved( int, int ); // obsolete, do not use 00146 void sectionHandleDoubleClicked( int section ); 00147 00148 protected: 00149 void paintEvent( QPaintEvent * ); 00150 void showEvent( QShowEvent *e ); 00151 void resizeEvent( QResizeEvent *e ); 00152 QRect sRect( int index ); 00153 00154 virtual void paintSection( QPainter *p, int index, const QRect& fr); 00155 virtual void paintSectionLabel( QPainter* p, int index, const QRect& fr ); 00156 00157 void fontChange( const QFont & ); 00158 00159 void mousePressEvent( QMouseEvent * ); 00160 void mouseReleaseEvent( QMouseEvent * ); 00161 void mouseMoveEvent( QMouseEvent * ); 00162 void mouseDoubleClickEvent( QMouseEvent * ); 00163 00164 void keyPressEvent( QKeyEvent * ); 00165 void keyReleaseEvent( QKeyEvent * ); 00166 00167 private: 00168 void handleColumnMove( int fromIdx, int toIdx ); 00169 void adjustHeaderSize( int diff ); 00170 void init( int ); 00171 00172 void paintRect( int p, int s ); 00173 void markLine( int idx ); 00174 void unMarkLine( int idx ); 00175 int pPos( int i ) const; 00176 int pSize( int i ) const; 00177 int findLine( int ); 00178 int handleAt( int p ); 00179 bool reverse() const; 00180 void calculatePositions( bool onlyVisible = FALSE, int start = 0 ); 00181 void handleColumnResize(int, int, bool, bool = TRUE ); 00182 QSize sectionSizeHint( int section, const QFontMetrics& fm ) const; 00183 void setSectionSizeAndHeight( int section, int size ); 00184 00185 void resizeArrays( int size ); 00186 void setIsATableHeader( bool b ); 00187 int offs; 00188 int handleIdx; 00189 int oldHIdxSize; 00190 int moveToIdx; 00191 enum State { Idle, Sliding, Pressed, Moving, Blocked }; 00192 State state; 00193 QCOORD clickPos; 00194 bool trackingIsOn; 00195 int oldHandleIdx; 00196 int cachedPos; // not used 00197 Orientation orient; 00198 00199 QHeaderData *d; 00200 00201 private: // Disabled copy constructor and operator= 00202 #if defined(Q_DISABLE_COPY) 00203 QHeader( const QHeader & ); 00204 QHeader &operator=( const QHeader & ); 00205 #endif 00206 }; 00207 00208 00209 inline QHeader::Orientation QHeader::orientation() const 00210 { 00211 return orient; 00212 } 00213 00214 inline void QHeader::setTracking( bool enable ) { trackingIsOn = enable; } 00215 inline bool QHeader::tracking() const { return trackingIsOn; } 00216 00217 extern Q_EXPORT bool qt_qheader_label_return_null_strings; // needed for professional edition 00218 00219 #endif // QT_NO_HEADER 00220 00221 #endif // QHEADER_H