Q3Header Class Reference

#include <q3header.h>

Inheritance diagram for Q3Header:

Inheritance graph
[legend]
Collaboration diagram for Q3Header:

Collaboration graph
[legend]
List of all members.

Detailed Description

The Q3Header class provides a header row or column, e.g. for tables and listviews.

This class provides a header, e.g. a vertical header to display row labels, or a horizontal header to display column labels. It is used by Q3Table and Q3ListView for example.

A header is composed of one or more sections, each of which can display a text label and an icon. A sort indicator (an arrow) can also be displayed using setSortIndicator().

Sections are added with addLabel() and removed with removeLabel(). The label and icon are set in addLabel() and can be changed later with setLabel(). Use count() to retrieve the number of sections in the header.

The orientation of the header is set with setOrientation(). If setStretchEnabled() is true, the sections will expand to take up the full width (height for vertical headers) of the header. The user can resize the sections manually if setResizeEnabled() is true. Call adjustHeaderSize() to have the sections resize to occupy the full width (or height).

A section can be moved with moveSection(). If setMovingEnabled() is true (the default)the user may drag a section from one position to another. If a section is moved, the index positions at which sections were added (with addLabel()), may not be the same after the move. You don't have to worry about this in practice because the Q3Header API works in terms of section numbers, so it doesn't matter where a particular section has been moved to.

If you want the current index position of a section call mapToIndex() giving it the section number. (This is the number returned by the addLabel() call which created the section.) If you want to get the section number of a section at a particular index position call mapToSection() giving it the index number.

Here's an example to clarify mapToSection() and mapToIndex():

Index positions 0 1 2 3 Original section ordering Sect 0 Sect 1 Sect 2 Sect 3 Ordering after the user moves a section Sect 0 Sect 2 Sect 3 Sect 1

k mapToSection(k) mapToIndex(k) 0 0 0 1 2 3 2 3 1 3 1 2

In the example above, if we wanted to find out which section is at index position 3 we'd call mapToSection(3) and get a section number of 1 since section 1 was moved. Similarly, if we wanted to know which index position section 2 occupied we'd call mapToIndex(2) and get an index of 1.

Q3Header provides the clicked(), pressed() and released() signals. If the user changes the size of a section, the sizeChange() signal is emitted. If you want to have a sizeChange() signal emitted continuously whilst the user is resizing (rather than just after the resizing is finished), use setTracking(). If the user moves a section the indexChange() signal is emitted.

See also:
Q3ListView Q3Table

Definition at line 42 of file q3header.h.

Public Slots

void setUpdatesEnabled (bool enable)
virtual void setOffset (int pos)

Signals

void clicked (int section)
void pressed (int section)
void released (int section)
void sizeChange (int section, int oldSize, int newSize)
void indexChange (int section, int fromIndex, int toIndex)
void sectionClicked (int)
void moved (int, int)
void sectionHandleDoubleClicked (int section)

Public Member Functions

 Q3Header (QWidget *parent=0, const char *name=0)
 Q3Header (int, QWidget *parent=0, const char *name=0)
 ~Q3Header ()
int addLabel (const QString &, int size=-1)
int addLabel (const QIcon &, const QString &, int size=-1)
void removeLabel (int section)
virtual void setLabel (int, const QString &, int size=-1)
virtual void setLabel (int, const QIcon &, const QString &, int size=-1)
QString label (int section) const
QIconiconSet (int section) const
virtual void setOrientation (Qt::Orientation)
Qt::Orientation orientation () const
virtual void setTracking (bool enable)
bool tracking () const
virtual void setClickEnabled (bool, int section=-1)
virtual void setResizeEnabled (bool, int section=-1)
virtual void setMovingEnabled (bool)
virtual void setStretchEnabled (bool b, int section)
void setStretchEnabled (bool b)
bool isClickEnabled (int section=-1) const
bool isResizeEnabled (int section=-1) const
bool isMovingEnabled () const
bool isStretchEnabled () const
bool isStretchEnabled (int section) const
void resizeSection (int section, int s)
int sectionSize (int section) const
int sectionPos (int section) const
int sectionAt (int pos) const
int count () const
int headerWidth () const
QRect sectionRect (int section) const
virtual void setCellSize (int, int)
int cellSize (int i) const
int cellPos (int) const
int cellAt (int pos) const
int offset () const
QSize sizeHint () const
int mapToSection (int index) const
int mapToIndex (int section) const
int mapToLogical (int) const
int mapToActual (int) const
void moveSection (int section, int toIndex)
virtual void moveCell (int, int)
void setSortIndicator (int section, bool ascending=true)
void setSortIndicator (int section, Qt::SortOrder order)
int sortIndicatorSection () const
Qt::SortOrder sortIndicatorOrder () const
void adjustHeaderSize ()

Protected Member Functions

void paintEvent (QPaintEvent *)
void showEvent (QShowEvent *e)
void resizeEvent (QResizeEvent *e)
QRect sRect (int index)
virtual void paintSection (QPainter *p, int index, const QRect &fr)
virtual void paintSectionLabel (QPainter *p, int index, const QRect &fr)
void changeEvent (QEvent *)
void mousePressEvent (QMouseEvent *)
void mouseReleaseEvent (QMouseEvent *)
void mouseMoveEvent (QMouseEvent *)
void mouseDoubleClickEvent (QMouseEvent *)
void keyPressEvent (QKeyEvent *)
void keyReleaseEvent (QKeyEvent *)

Private Types

enum  State

Private Member Functions

void handleColumnMove (int fromIdx, int toIdx)
void adjustHeaderSize (int diff)
void init (int)
void paintRect (int p, int s)
void markLine (int idx)
void unMarkLine (int idx)
int pPos (int i) const
int pSize (int i) const
int findLine (int)
int handleAt (int p)
bool reverse () const
void calculatePositions (bool onlyVisible=false, int start=0)
void handleColumnResize (int, int, bool, bool=true)
QSize sectionSizeHint (int section, const QFontMetrics &fm) const
void setSectionSizeAndHeight (int section, int size)
void resizeArrays (int size)
void setIsATableHeader (bool b)

Private Attributes

int offs
int handleIdx
int oldHIdxSize
int moveToIdx
State state
int clickPos
bool trackingIsOn
int oldHandleIdx
int cachedPos
Qt::Orientation orient
Q3HeaderDatad

Friends

class Q3Table
class Q3TableHeader
class Q3ListView


Member Enumeration Documentation

enum Q3Header::State [private]

Definition at line 174 of file q3header.h.


Constructor & Destructor Documentation

Q3Header::Q3Header ( QWidget parent = 0,
const char *  name = 0 
)

Constructs a horizontal header called name, with parent parent.

Definition at line 236 of file q3header.cpp.

References Qt::Horizontal, init(), and orient.

00237     : QWidget(parent, name, Qt::WStaticContents)
00238 {
00239     orient = Qt::Horizontal;
00240     init(0);
00241 }

Here is the call graph for this function:

Q3Header::Q3Header ( int  n,
QWidget parent = 0,
const char *  name = 0 
)

Constructs a horizontal header called name, with n sections and parent parent.

Definition at line 248 of file q3header.cpp.

References Qt::Horizontal, init(), and orient.

00249     : QWidget(parent, name, Qt::WStaticContents)
00250 {
00251     orient = Qt::Horizontal;
00252     init(n);
00253 }

Here is the call graph for this function:

Q3Header::~Q3Header (  ) 

Destroys the header and all its sections.

Definition at line 259 of file q3header.cpp.

References d.

00260 {
00261     delete d;
00262     d = 0;
00263 }


Member Function Documentation

int Q3Header::addLabel ( const QString s,
int  size = -1 
)

Adds a new section with label text s. Returns the index position where the section was added (at the right for horizontal headers, at the bottom for vertical headers). The section's width is set to size. If size < 0, an appropriate size for the text s is chosen.

Definition at line 1178 of file q3header.cpp.

References calculatePositions(), Q3HeaderData::clicks, Q3HeaderData::clicks_default, Q3HeaderData::count, d, Q3HeaderData::i2s, Q3HeaderData::icons, index, QVector< T >::insert(), Q3HeaderData::is_a_table_header, Q3HeaderData::labels, Q3HeaderData::lastPos, n, Q3HeaderData::nullStringLabels, Q3HeaderData::positions, QBitArray::resize(), Q3HeaderData::resize, QVector< T >::resize(), Q3HeaderData::resize_default, s, Q3HeaderData::s2i, QBitArray::setBit(), setSectionSizeAndHeight(), QVector< T >::size(), Q3HeaderData::sizes, QWidget::update(), QWidget::updateGeometry(), and QWidget::updatesEnabled().

Referenced by Q3ListView::addColumn(), Q3TableHeader::addLabel(), and addLabel().

01179 {
01180     int n = ++d->count;
01181     if ((int)d->icons.size() < n )
01182         d->icons.resize(n);
01183     if ((int)d->sizes.size() < n ) {
01184         d->labels.resize(n);
01185         d->nullStringLabels.resize(n);
01186         d->sizes.resize(n);
01187         d->positions.resize(n);
01188         d->i2s.resize(n);
01189         d->s2i.resize(n);
01190         d->clicks.resize(n);
01191         d->resize.resize(n);
01192     }
01193     int section = d->count - 1;
01194     if (!d->is_a_table_header || !s.isNull()) {
01195         d->labels.insert(section, s);
01196         d->nullStringLabels.setBit(section, s.isNull());
01197     }
01198 
01199     if (size >= 0 && s.isNull() && d->is_a_table_header) {
01200         d->sizes[section] = size;
01201     } else {
01202         d->sizes[section] = -1;
01203         setSectionSizeAndHeight(section, size);
01204     }
01205 
01206     int index = section;
01207     d->positions[index] = d->lastPos;
01208 
01209     d->s2i[section] = index;
01210     d->i2s[index] = section;
01211     d->clicks.setBit(section, d->clicks_default);
01212     d->resize.setBit(section, d->resize_default);
01213 
01214     if (updatesEnabled()) {
01215         updateGeometry();
01216         calculatePositions();
01217         update();
01218     }
01219     return index;
01220 }

Here is the call graph for this function:

int Q3Header::addLabel ( const QIcon icon,
const QString s,
int  size = -1 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Adds a new section with icon icon and label text s. Returns the index position where the section was added (at the right for horizontal headers, at the bottom for vertical headers). The section's width is set to size, unless size is negative in which case the size is calculated taking account of the size of the text.

Definition at line 1040 of file q3header.cpp.

References addLabel(), count(), d, Q3HeaderData::icons, QVector< T >::insert(), n, QVector< T >::resize(), and s.

01041 {
01042     int n = count() + 1;
01043     d->icons.resize(n + 1);
01044     d->icons.insert(n - 1, new QIcon(icon));
01045     return addLabel(s, size);
01046 }

Here is the call graph for this function:

void Q3Header::removeLabel ( int  section  ) 

Removes section section. If the section does not exist, nothing happens.

Definition at line 1052 of file q3header.cpp.

References calculatePositions(), Q3HeaderData::count, count(), d, i, Q3HeaderData::i2s, Q3HeaderData::icons, index, Q3HeaderData::labels, n, Q3HeaderData::nullStringLabels, Q3HeaderData::positions, QBitArray::resize(), QVector< T >::resize(), Q3HeaderData::s2i, Q3HeaderData::sizes, QWidget::update(), QWidget::updateGeometry(), and QWidget::updatesEnabled().

Referenced by Q3ListView::removeColumn(), and Q3TableHeader::removeLabel().

01053 {
01054     if (section < 0 || section > count() - 1)
01055         return;
01056 
01057     int index = d->s2i[section];
01058     int n = --d->count;
01059     int i;
01060     for (i = section; i < n; ++i) {
01061         d->sizes[i] = d->sizes[i+1];
01062         d->labels[i] = d->labels[i+1];
01063         d->labels[i+1] = QString();
01064         d->nullStringLabels[i] = d->nullStringLabels[i+1];
01065         d->nullStringLabels[i+1] = 0;
01066         d->icons[i] = d->icons[i+1];
01067         d->icons[i+1] = 0;
01068     }
01069 
01070     d->sizes.resize(n);
01071     d->positions.resize(n);
01072     d->labels.resize(n);
01073     d->nullStringLabels.resize(n);
01074     d->icons.resize(n);
01075 
01076     for (i = section; i < n; ++i)
01077         d->s2i[i] = d->s2i[i+1];
01078     d->s2i.resize(n);
01079 
01080     if (updatesEnabled()) {
01081         for (i = 0; i < n; ++i)
01082             if (d->s2i[i] > index)
01083                 --d->s2i[i];
01084     }
01085 
01086     for (i = index; i < n; ++i)
01087         d->i2s[i] = d->i2s[i+1];
01088     d->i2s.resize(n);
01089 
01090     if (updatesEnabled()) {
01091         for (i = 0; i < n; ++i)
01092             if (d->i2s[i] > section)
01093                 --d->i2s[i];
01094     }
01095 
01096     if (updatesEnabled()) {
01097         updateGeometry();
01098         calculatePositions();
01099         update();
01100     }
01101 }

Here is the call graph for this function:

void Q3Header::setLabel ( int  section,
const QString s,
int  size = -1 
) [virtual]

Sets the text of section section to s. The section's width is set to size if size >= 0; otherwise it is left unchanged. Any icon set that has been set for this section remains unchanged.

If the section does not exist, nothing happens.

Definition at line 982 of file q3header.cpp.

References calculatePositions(), count(), d, Q3HeaderData::labels, Q3HeaderData::nullStringLabels, s, QBitArray::setBit(), setSectionSizeAndHeight(), QWidget::update(), QWidget::updateGeometry(), and QWidget::updatesEnabled().

Referenced by Q3DataTable::beginInsert(), Q3DataTable::endInsert(), Q3DataTable::refresh(), Q3ListView::setColumnText(), Q3TableHeader::setLabel(), setLabel(), and Q3TableHeader::setLabels().

00983 {
00984     if (section < 0 || section >= count())
00985         return;
00986     d->labels[section] = s;
00987     d->nullStringLabels.setBit(section, s.isNull());
00988 
00989     setSectionSizeAndHeight(section, size);
00990 
00991     if (updatesEnabled()) {
00992         updateGeometry();
00993         calculatePositions();
00994         update();
00995     }
00996 }

Here is the call graph for this function:

void Q3Header::setLabel ( int  section,
const QIcon icon,
const QString s,
int  size = -1 
) [virtual]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the icon for section section to icon and the text to s. The section's width is set to size if size >= 0; otherwise it is left unchanged.

If the section does not exist, nothing happens.

Definition at line 965 of file q3header.cpp.

References count(), d, Q3HeaderData::icons, s, and setLabel().

00967 {
00968     if (section < 0 || section >= count())
00969         return;
00970     d->icons[section] = new QIcon(icon);
00971     setLabel(section, s, size);
00972 }

Here is the call graph for this function:

QString Q3Header::label ( int  section  )  const

Returns the text for section section. If the section does not exist, returns an empty string.

Definition at line 1004 of file q3header.cpp.

References count(), d, l, Q3HeaderData::labels, Q3HeaderData::nullStringLabels, QString::number(), qt_qheader_label_return_null_strings, QBitArray::testBit(), and QVector< T >::value().

Referenced by Q3DataTable::beginInsert(), Q3ListView::columnText(), paintSectionLabel(), sectionSizeHint(), Q3TableHeader::swapSections(), and Q3AccessibleHeader::text().

01005 {
01006     if (section < 0 || section >= count())
01007         return QString();
01008     QString l = d->labels.value(section);
01009     if (!l.isNull())
01010         return l;
01011     if (d->nullStringLabels.testBit(section) || qt_qheader_label_return_null_strings)
01012         return l;
01013     else
01014         return QString::number(section + 1);
01015 }

Here is the call graph for this function:

QIcon * Q3Header::iconSet ( int  section  )  const

Returns the icon set for section section. If the section does not exist, 0 is returned.

Definition at line 1022 of file q3header.cpp.

References count(), d, and Q3HeaderData::icons.

Referenced by Q3ListView::adjustColumn(), Q3Table::adjustColumn(), Q3Table::adjustRow(), and Q3TableHeader::swapSections().

01023 {
01024     if (section < 0 || section >= count())
01025         return 0;
01026     return d->icons[section];
01027 }

Here is the call graph for this function:

void Q3Header::setOrientation ( Qt::Orientation   )  [virtual]

Definition at line 426 of file q3header.cpp.

References QSizePolicy::Fixed, Qt::Horizontal, orient, QSizePolicy::Preferred, QWidget::setSizePolicy(), QWidget::update(), and QWidget::updateGeometry().

Referenced by Q3Table::init().

Here is the call graph for this function:

Qt::Orientation Q3Header::orientation (  )  const [inline]

Definition at line 189 of file q3header.h.

References orient.

Referenced by adjustHeaderSize(), calculatePositions(), Q3TableHeader::doAutoScroll(), Q3TableHeader::doSelection(), keyPressEvent(), Q3TableHeader::mouseDoubleClickEvent(), Q3TableHeader::mouseMoveEvent(), Q3TableHeader::mousePressEvent(), Q3TableHeader::mouseReleaseEvent(), Q3TableHeader::paintEvent(), Q3TableHeader::paintSection(), resizeEvent(), Q3TableHeader::sectionLabelChanged(), Q3TableHeader::sectionWidthChanged(), Q3TableHeader::setSectionState(), Q3TableHeader::setSectionStateToAll(), Q3TableHeader::swapSections(), Q3TableHeader::updateSelections(), and Q3TableHeader::updateStretches().

00190 {
00191     return orient;
00192 }

void Q3Header::setTracking ( bool  enable  )  [inline, virtual]

Definition at line 194 of file q3header.h.

References trackingIsOn.

Referenced by Q3ListView::init(), and Q3Table::init().

00194 { trackingIsOn = enable; }

bool Q3Header::tracking (  )  const [inline]

Definition at line 195 of file q3header.h.

References trackingIsOn.

Referenced by handleColumnResize().

00195 { return trackingIsOn; }

void Q3Header::setClickEnabled ( bool  enable,
int  section = -1 
) [virtual]

If enable is true, any clicks on section section will result in clicked() signals being emitted; otherwise the section will ignore clicks.

If section is -1 (the default) then the enable value is set for all existing sections and will be applied to any new sections that are added.

See also:
setMovingEnabled(), setResizeEnabled()

Definition at line 1444 of file q3header.cpp.

References Q3HeaderData::clicks, Q3HeaderData::clicks_default, count(), d, and QBitArray::fill().

01445 {
01446     if (section < 0) {
01447         d->clicks.fill(enable);
01448         // and future ones...
01449         d->clicks_default = enable;
01450     } else if (section < count()) {
01451         d->clicks[section] = enable;
01452     }
01453 }

Here is the call graph for this function:

void Q3Header::setResizeEnabled ( bool  enable,
int  section = -1 
) [virtual]

If enable is true the user may resize section section; otherwise the section may not be manually resized.

If section is negative (the default) then the enable value is set for all existing sections and will be applied to any new sections that are added. Example:

    // Allow resizing of all current and future sections
    header->setResizeEnabled(true);
    // Disable resizing of section 3, (the fourth section added)
    header->setResizeEnabled(false, 3);

If the user resizes a section, a sizeChange() signal is emitted.

See also:
setMovingEnabled() setClickEnabled() setTracking()

Definition at line 1404 of file q3header.cpp.

References count(), d, QBitArray::fill(), Q3HeaderData::resize, and Q3HeaderData::resize_default.

Referenced by Q3Table::hideColumn(), Q3Table::hideRow(), Q3Table::showColumn(), and Q3Table::showRow().

01405 {
01406     if (section < 0) {
01407         d->resize.fill(enable);
01408         // and future ones...
01409         d->resize_default = enable;
01410     } else if (section < count()) {
01411         d->resize[section] = enable;
01412     }
01413 }

Here is the call graph for this function:

void Q3Header::setMovingEnabled ( bool   )  [virtual]

Definition at line 1426 of file q3header.cpp.

References d, and Q3HeaderData::move.

Referenced by Q3Table::init(), and Q3FileDialogQFileListView::Q3FileDialogQFileListView().

01427 {
01428     d->move = enable;
01429 }

void Q3Header::setStretchEnabled ( bool  b,
int  section 
) [virtual]

If b is true, section section will be resized when the header is resized, so that the sections take up the full width (or height for vertical headers) of the header; otherwise section section will be set to be unstretchable and will not resize when the header is resized.

If section is -1, and if b is true, then all sections will be resized equally when the header is resized so that they take up the full width (or height for vertical headers) of the header; otherwise all the sections will be set to be unstretchable and will not resize when the header is resized.

See also:
adjustHeaderSize()

Definition at line 1992 of file q3header.cpp.

References adjustHeaderSize(), d, and Q3HeaderData::fullSize.

Referenced by Q3FileDialog::init(), Q3ListView::removeColumn(), and Q3ListView::setResizeMode().

01993 {
01994     if (b)
01995         d->fullSize = section;
01996     else
01997         d->fullSize = -2;
01998     adjustHeaderSize();
01999 }

Here is the call graph for this function:

void Q3Header::setStretchEnabled ( bool  b  )  [inline]

Definition at line 78 of file q3header.h.

00078 { setStretchEnabled(b, -1); }

bool Q3Header::isClickEnabled ( int  section = -1  )  const

Returns true if section section is clickable; otherwise returns false.

If section is out of range (negative or larger than count() - 1): returns true if all sections are clickable; otherwise returns false.

See also:
setClickEnabled()

Definition at line 1808 of file q3header.cpp.

References Q3HeaderData::clicks, count(), d, and i.

Referenced by Q3TableHeader::paintSection(), and paintSection().

01809 {
01810     if (section >= 0 && section < count()) {
01811         return (bool)d->clicks[section];
01812     }
01813 
01814     for (int i = 0; i < count(); ++i) {
01815         if (!d->clicks[i])
01816             return false;
01817     }
01818     return true;
01819 }

Here is the call graph for this function:

bool Q3Header::isResizeEnabled ( int  section = -1  )  const

Returns true if section section is resizeable; otherwise returns false.

If section is -1 then this function applies to all sections, i.e. returns true if all sections are resizeable; otherwise returns false.

See also:
setResizeEnabled()

Definition at line 1832 of file q3header.cpp.

References count(), d, i, and Q3HeaderData::resize.

01833 {
01834     if (section >= 0 && section < count()) {
01835         return (bool)d->resize[section];
01836     }
01837 
01838     for (int i = 0; i < count();++i) {
01839         if (!d->resize[i])
01840             return false;
01841     }
01842     return true;
01843 }

Here is the call graph for this function:

bool Q3Header::isMovingEnabled (  )  const

Definition at line 1845 of file q3header.cpp.

References d, and Q3HeaderData::move.

01846 {
01847     return d->move;
01848 }

bool Q3Header::isStretchEnabled (  )  const

Definition at line 2001 of file q3header.cpp.

References d, and Q3HeaderData::fullSize.

Referenced by Q3ListView::adjustColumn(), and Q3ListView::widthChanged().

02002 {
02003     return d->fullSize == -1;
02004 }

bool Q3Header::isStretchEnabled ( int  section  )  const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns true if section section will resize to take up the full width (or height) of the header; otherwise returns false. If at least one section has stretch enabled the sections will always take up the full width of the header.

See also:
setStretchEnabled()

Definition at line 2017 of file q3header.cpp.

References d, and Q3HeaderData::fullSize.

02018 {
02019     return d->fullSize == section;
02020 }

void Q3Header::resizeSection ( int  section,
int  s 
)

Resizes section section to s pixels wide (or high).

Definition at line 1698 of file q3header.cpp.

References setCellSize(), and QWidget::update().

Referenced by Q3ListView::adjustColumn(), Q3Table::hideColumn(), Q3Table::hideRow(), Q3Table::init(), Q3Table::setColumnWidth(), Q3ListView::setColumnWidth(), Q3Table::setRowHeight(), Q3TableHeader::swapSections(), and Q3TableHeader::updateStretches().

01699 {
01700     setCellSize(section, s);
01701     update();
01702 }

Here is the call graph for this function:

int Q3Header::sectionSize ( int  section  )  const

Returns the width (or height) of the section in pixels.

Definition at line 1708 of file q3header.cpp.

References count(), d, and Q3HeaderData::sizes.

Referenced by Q3ListView::adjustColumn(), adjustHeaderSize(), paintSection(), Q3TableHeader::sectionSize(), Q3TableHeader::sectionWidthChanged(), Q3TableHeader::setCaching(), Q3ListView::setColumnWidth(), Q3ListViewItem::startRename(), and Q3TableHeader::updateCache().

01709 {
01710     if (section < 0 || section >= count())
01711         return 0;
01712     return d->sizes[section];
01713 }

Here is the call graph for this function:

int Q3Header::sectionPos ( int  section  )  const

Returns the position (in pixels) at which the section starts.

See also:
offset()

Definition at line 1721 of file q3header.cpp.

References count(), d, Q3HeaderData::positions, Q3HeaderData::positionsDirty, and Q3HeaderData::s2i.

Referenced by Q3CheckListItem::activate(), adjustHeaderSize(), cellPos(), Q3ListView::contentsMousePressEventEx(), Q3TableHeader::sectionPos(), Q3TableHeader::sectionWidthChanged(), Q3TableHeader::setCaching(), Q3ListViewItem::startRename(), and Q3TableHeader::updateCache().

01722 {
01723     if (d->positionsDirty)
01724         ((Q3Header *)this)->calculatePositions();
01725     if (section < 0 || section >= count() )
01726         return 0;
01727     return d->positions[d->s2i[section]];
01728 }

Here is the call graph for this function:

int Q3Header::sectionAt ( int  pos  )  const

Returns the index of the section which contains the position pos given in pixels from the left (or top).

See also:
offset()

Definition at line 1737 of file q3header.cpp.

References d, Q3HeaderData::lastPos, reverse(), and Q3HeaderData::sectionAt().

Referenced by Q3ListView::contentsMouseReleaseEventEx(), Q3ListView::eventFilter(), findLine(), paintEvent(), and Q3TableHeader::sectionAt().

01738 {
01739     if (reverse())
01740         pos = d->lastPos - pos;
01741     return d->sectionAt(pos);
01742 }

Here is the call graph for this function:

int Q3Header::count (  )  const

Definition at line 374 of file q3header.cpp.

References Q3HeaderData::count, and d.

Referenced by Q3TableHeader::addLabel(), addLabel(), adjustHeaderSize(), calculatePositions(), cellPos(), Q3AccessibleHeader::childCount(), Q3ListView::drawContentsOffset(), handleAt(), handleColumnResize(), iconSet(), isClickEnabled(), isResizeEnabled(), keyPressEvent(), Q3ListView::keyPressEvent(), label(), mapToIndex(), mapToSection(), Q3TableHeader::mouseDoubleClickEvent(), mousePressEvent(), Q3TableHeader::mouseReleaseEvent(), moveSection(), Q3Table::numCols(), Q3Table::numRows(), Q3TableHeader::paintEvent(), paintEvent(), paintSection(), pPos(), Q3ListView::removeColumn(), removeLabel(), Q3TableHeader::saveStates(), Q3TableHeader::sectionAt(), Q3TableHeader::sectionPos(), sectionPos(), sectionSize(), Q3TableHeader::sectionSize(), Q3TableHeader::setCaching(), setCellSize(), setClickEnabled(), setLabel(), Q3TableHeader::setLabels(), setResizeEnabled(), Q3TableHeader::setSectionStateToAll(), sizeHint(), sRect(), Q3TableHeader::updateCache(), Q3TableHeader::updateSelections(), Q3TableHeader::updateStretches(), and Q3ListView::widthChanged().

00375 {
00376     return d->count;
00377 }

int Q3Header::headerWidth (  )  const

Returns the total width of all the header columns.

Definition at line 1945 of file q3header.cpp.

References d, Q3HeaderData::lastPos, and Q3HeaderData::pos_dirty.

Referenced by Q3ListView::updateGeometries().

01946 {
01947     if (d->pos_dirty) {
01948         ((Q3Header*)this)->calculatePositions();
01949         d->pos_dirty = false;
01950     }
01951     return d->lastPos;
01952 }

QRect Q3Header::sectionRect ( int  section  )  const

Returns the rectangle covered by section section.

Definition at line 940 of file q3header.cpp.

References d, QWidget::height(), Qt::Horizontal, index, Q3HeaderData::lastPos, mapToIndex(), offset(), orient, Q3HeaderData::positions, QWidget::rect(), reverse(), Q3HeaderData::sizes, and QWidget::width().

Referenced by Q3AccessibleHeader::rect().

00941 {
00942     int index = mapToIndex(section);
00943     if (section < 0)
00944         return rect(); // ### eeeeevil
00945 
00946     if (reverse())
00947         return QRect( d->lastPos - d->positions[index] - d->sizes[section] -offset(),
00948                        0, d->sizes[section], height());
00949     else if (orient == Qt::Horizontal)
00950         return QRect( d->positions[index]-offset(), 0, d->sizes[section], height());
00951     else
00952         return QRect(0, d->positions[index]-offset(), width(), d->sizes[section]);
00953 }

Here is the call graph for this function:

void Q3Header::setCellSize ( int  section,
int  s 
) [virtual]

Use resizeSection() instead.

Sets the size of the section section to s pixels.

Warning:
does not repaint or send out signals

Definition at line 1374 of file q3header.cpp.

References calculatePositions(), count(), d, Q3HeaderData::sizes, and QWidget::updatesEnabled().

Referenced by adjustHeaderSize(), and resizeSection().

01375 {
01376     if (section < 0 || section >= count())
01377         return;
01378     d->sizes[section] = s;
01379     if (updatesEnabled())
01380         calculatePositions();
01381 }

Here is the call graph for this function:

int Q3Header::cellSize ( int  i  )  const [inline]

Use sectionSize() instead.

Returns the size in pixels of the section that is displayed at the index i.

Definition at line 94 of file q3header.h.

Referenced by Q3ListView::columnWidth(), Q3ListView::drawContentsOffset(), Q3ListView::handleSizeChange(), and Q3TableHeader::paintSection().

00094 { return sectionSize(mapToSection(i)); } // obsolete, do not use

int Q3Header::cellPos ( int  i  )  const

Use sectionPos() instead.

Returns the position in pixels of the section that is displayed at the index i. The position is measured from the start of the header.

Definition at line 361 of file q3header.cpp.

References count(), d, Q3HeaderData::i2s, mapToSection(), Q3HeaderData::positions, sectionPos(), and Q3HeaderData::sizes.

Referenced by Q3ListView::contentsMousePressEventEx(), Q3ListView::contentsMouseReleaseEventEx(), Q3ListView::drawContentsOffset(), Q3ListView::handleSizeChange(), and Q3CheckListItem::paintFocus().

00362 {
00363     if (i == count() && i > 0)
00364         return  d->positions[i-1] + d->sizes[d->i2s[i-1]]; // compatibility
00365     return sectionPos(mapToSection(i));
00366 }

Here is the call graph for this function:

int Q3Header::cellAt ( int  pos  )  const [inline]

Use sectionAt() instead.

Returns the index at which the section is displayed, which contains pos in widget coordinates, or -1 if pos is outside the header sections.

Definition at line 96 of file q3header.h.

Referenced by Q3ListView::contentsContextMenuEvent(), Q3ListView::contentsMouseDoubleClickEvent(), Q3ListView::contentsMousePressEventEx(), and Q3ListView::contentsMouseReleaseEventEx().

00096 { return mapToIndex(sectionAt(pos + offset())); } // obsolete, do not use

int Q3Header::offset (  )  const

Definition at line 1285 of file q3header.cpp.

References d, Q3HeaderData::lastPos, offs, reverse(), and QWidget::width().

Referenced by calculatePositions(), Q3ListView::contentsMousePressEventEx(), Q3ListView::contentsMouseReleaseEventEx(), Q3TableHeader::doAutoScroll(), Q3TableHeader::doSelection(), handleColumnResize(), Q3TableHeader::mouseDoubleClickEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), Q3TableHeader::paintEvent(), paintEvent(), pPos(), sectionRect(), setOffset(), Q3TableHeader::setSectionState(), sRect(), Q3ListView::updateGeometries(), and Q3Table::updateGeometries().

01286 {
01287     if (reverse())
01288         return d->lastPos - width() - offs;
01289     return offs;
01290 }

Here is the call graph for this function:

QSize Q3Header::sizeHint (  )  const [virtual]

Reimplemented from QWidget.

Definition at line 1241 of file q3header.cpp.

References count(), QStyle::CT_Q3Header, d, QWidget::ensurePolished(), QSize::expandedTo(), QWidget::fontMetrics(), getStyleOption(), QApplication::globalStrut(), h, Q3HeaderData::height, QWidget::height(), QSize::height(), Q3HeaderData::heightDirty, Qt::Horizontal, i, QFontMetrics::lineSpacing(), orient, qMax(), sectionSizeHint(), QStyle::sizeFromContents(), Q3HeaderData::sizes, QWidget::style(), QSize::width(), QWidget::width(), and QFontMetrics::width().

Referenced by Q3ListView::clear(), Q3TableHeader::sectionLabelChanged(), Q3ListView::sizeHint(), and Q3ListView::updateGeometries().

01242 {
01243     int width;
01244     int height;
01245 
01246     ensurePolished();
01247     QFontMetrics fm = fontMetrics();
01248 
01249     if (d->heightDirty) {
01250         d->height = fm.lineSpacing() + 6;
01251         for (int i = 0; i < count(); i++) {
01252             int h = orient == Qt::Horizontal ?
01253                     sectionSizeHint(i, fm).height() : sectionSizeHint(i, fm).width();
01254             d->height = qMax(d->height, h);
01255         }
01256         d->heightDirty = false;
01257     }
01258 
01259     if (orient == Qt::Horizontal) {
01260         height = fm.lineSpacing() + 6;
01261         width = 0;
01262         height = qMax(height, d->height);
01263         for (int i = 0; i < count(); i++)
01264             width += d->sizes[i];
01265     } else {
01266         width = fm.width(' ');
01267         height = 0;
01268         width = qMax(width, d->height);
01269         for (int i = 0; i < count(); i++)
01270             height += d->sizes[i];
01271     }
01272     QStyleOptionHeader opt = getStyleOption(this, 0);
01273     return style()->sizeFromContents(QStyle::CT_Q3Header, &opt, QSize(width, height),
01274                                     this).expandedTo(QApplication::globalStrut());
01275 }

Here is the call graph for this function:

int Q3Header::mapToSection ( int  index  )  const

Returns the number of the section that is displayed at index position index.

Definition at line 1749 of file q3header.cpp.

References count(), d, and Q3HeaderData::i2s.

Referenced by adjustHeaderSize(), cellPos(), Q3ListView::contentsMousePressEventEx(), Q3ListView::keyPressEvent(), mapToLogical(), moveCell(), paintEvent(), Q3TableHeader::paintSection(), paintSection(), paintSectionLabel(), Q3TableHeader::sectionAt(), and sRect().

01750 {
01751     return (index >= 0 && index < count()) ? d->i2s[index] : -1;
01752 }

Here is the call graph for this function:

int Q3Header::mapToIndex ( int  section  )  const

Returns the index position at which section section is displayed.

Definition at line 1759 of file q3header.cpp.

References count(), d, and Q3HeaderData::s2i.

Referenced by adjustHeaderSize(), Q3TableHeader::indexChanged(), mapToActual(), moveSection(), Q3TableHeader::paintEvent(), paintEvent(), and sectionRect().

01760 {
01761     return (section >= 0 && section < count()) ? d->s2i[section] : -1;
01762 }

Here is the call graph for this function:

int Q3Header::mapToLogical ( int  a  )  const

Use mapToSection() instead.

Translates from actual index a (index at which the section is displayed) to logical index of the section. Returns -1 if a is outside the legal range.

See also:
mapToActual()

Definition at line 1345 of file q3header.cpp.

References mapToSection().

Referenced by Q3ListView::changeSortColumn(), Q3FileDialogQFileListView::changeSortColumn2(), Q3ListView::contentsContextMenuEvent(), Q3ListView::contentsMouseDoubleClickEvent(), Q3ListView::contentsMousePressEventEx(), Q3ListView::contentsMouseReleaseEventEx(), and Q3ListView::drawContentsOffset().

01346 {
01347     return mapToSection(a);
01348 }

Here is the call graph for this function:

int Q3Header::mapToActual ( int  l  )  const

Use mapToIndex() instead.

Translates from logical index l to actual index (index at which the section l is displayed) . Returns -1 if l is outside the legal range.

See also:
mapToLogical()

Definition at line 1360 of file q3header.cpp.

References mapToIndex().

Referenced by Q3ListView::columnWidth(), Q3ListView::contentsMousePressEventEx(), Q3ListView::contentsMouseReleaseEventEx(), Q3ListView::drawContentsOffset(), Q3ListView::handleSizeChange(), and Q3CheckListItem::paintFocus().

01361 {
01362     return mapToIndex(l);
01363 }

Here is the call graph for this function:

void Q3Header::moveSection ( int  section,
int  toIndex 
)

Moves section section to index position toIndex.

Definition at line 1768 of file q3header.cpp.

References calculatePositions(), count(), d, i, Q3HeaderData::i2s, mapToIndex(), Q3HeaderData::s2i, and t.

Referenced by handleColumnMove(), Q3TableHeader::indexChanged(), mouseReleaseEvent(), and moveCell().

01769 {
01770     int fromIndex = mapToIndex(section);
01771     if (fromIndex == toIndex ||
01772          fromIndex < 0 || fromIndex > count() ||
01773          toIndex < 0 || toIndex > count())
01774         return;
01775     int i;
01776     int idx = d->i2s[fromIndex];
01777     if (fromIndex < toIndex) {
01778         for (i = fromIndex; i < toIndex - 1; i++) {
01779             int t;
01780             d->i2s[i] = t = d->i2s[i+1];
01781             d->s2i[t] = i;
01782         }
01783         d->i2s[toIndex-1] = idx;
01784         d->s2i[idx] = toIndex-1;
01785     } else {
01786         for (i = fromIndex; i > toIndex; i--) {
01787             int t;
01788             d->i2s[i] = t = d->i2s[i-1];
01789             d->s2i[t] = i;
01790         }
01791         d->i2s[toIndex] = idx;
01792         d->s2i[idx] = toIndex;
01793     }
01794     calculatePositions();
01795 }

Here is the call graph for this function:

void Q3Header::moveCell ( int  fromIdx,
int  toIdx 
) [virtual]

Use moveSection() instead.

Moves the section that is currently displayed at index fromIdx to index toIdx.

Definition at line 573 of file q3header.cpp.

References mapToSection(), and moveSection().

00574 {
00575     moveSection(mapToSection(fromIdx), toIdx);
00576 }

Here is the call graph for this function:

void Q3Header::setSortIndicator ( int  section,
bool  ascending = true 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the sort indicator to ascending. Use the other overload instead.

Definition at line 1649 of file q3header.cpp.

References d, oldHandleIdx, Q3HeaderData::sortDirection, Q3HeaderData::sortSection, QWidget::update(), and QWidget::updateGeometry().

Referenced by Q3Table::columnIndexChanged(), Q3DataTable::reset(), Q3ListView::setShowSortIndicator(), Q3Table::setSorting(), Q3ListView::setSorting(), Q3Table::sortColumn(), and Q3DataTable::sortColumn().

01650 {
01651     d->sortSection = section;
01652     if (section != -1)
01653         oldHandleIdx = section;
01654     d->sortDirection = ascending;
01655     update();
01656     updateGeometry();
01657 }

Here is the call graph for this function:

void Q3Header::setSortIndicator ( int  section,
Qt::SortOrder  order 
) [inline]

Sets a sort indicator onto the specified section. The indicator's order is either Ascending or Descending.

Only one section can show a sort indicator at any one time. If you don't want any section to show a sort indicator pass a section number of -1.

See also:
sortIndicatorSection(), sortIndicatorOrder()

Definition at line 111 of file q3header.h.

References Qt::AscendingOrder.

00112         { setSortIndicator(section, (order == Qt::AscendingOrder)); }

int Q3Header::sortIndicatorSection (  )  const

Returns the section showing the sort indicator or -1 if there is no sort indicator.

See also:
setSortIndicator(), sortIndicatorOrder()

Definition at line 1678 of file q3header.cpp.

References d, and Q3HeaderData::sortSection.

01679 {
01680     return d->sortSection;
01681 }

Qt::SortOrder Q3Header::sortIndicatorOrder (  )  const

Returns the implied sort order of the Q3Headers sort indicator.

See also:
setSortIndicator(), sortIndicatorSection()

Definition at line 1689 of file q3header.cpp.

References Qt::AscendingOrder, d, Qt::DescendingOrder, and Q3HeaderData::sortDirection.

Referenced by Q3Table::columnIndexChanged().

01690 {
01691     return d->sortDirection ? Qt::AscendingOrder : Qt::DescendingOrder;
01692 }

void Q3Header::adjustHeaderSize (  )  [inline]

Adjusts the size of the sections to fit the size of the header as completely as possible. Only sections for which isStretchEnabled() is true will be resized.

Definition at line 116 of file q3header.h.

Referenced by Q3ListView::adjustColumn(), handleColumnResize(), resizeEvent(), Q3ListView::resizeEvent(), setStretchEnabled(), and Q3ListView::updateContents().

00116 { adjustHeaderSize(-1); }

void Q3Header::setUpdatesEnabled ( bool  enable  )  [slot]

Reimplemented from QWidget.

Definition at line 1852 of file q3header.cpp.

References calculatePositions(), and QWidget::setUpdatesEnabled().

Referenced by Q3Table::init(), Q3Table::insertColumns(), Q3Table::insertRows(), Q3TableHeader::setLabels(), Q3Table::setNumCols(), Q3Table::setNumRows(), and Q3Table::updateHeaderStates().

01853 {
01854     if (enable)
01855         calculatePositions();
01856     QWidget::setUpdatesEnabled(enable);
01857 }

void Q3Header::setOffset ( int  pos  )  [virtual, slot]

Definition at line 1292 of file q3header.cpp.

References d, QWidget::height(), Qt::Horizontal, Q3HeaderData::lastPos, offs, offset(), orient, reverse(), QWidget::scroll(), and QWidget::width().

01293 {
01294     int oldOff = offset();
01295     offs = x;
01296     if(d->lastPos < (orient == Qt::Horizontal ? width() : height()))
01297         offs = 0;
01298     else if (reverse())
01299         offs = d->lastPos - width() - x;
01300     if (orient == Qt::Horizontal)
01301         scroll(oldOff-offset(), 0);
01302     else
01303         scroll(0, oldOff-offset());
01304 }

void Q3Header::clicked ( int  section  )  [signal]

If isClickEnabled() is true, this signal is emitted when the user clicks section section.

See also:
pressed(), released()

Referenced by keyReleaseEvent(), and mouseReleaseEvent().

void Q3Header::pressed ( int  section  )  [signal]

This signal is emitted when the user presses section section down.

See also:
released()

Referenced by keyPressEvent(), and mousePressEvent().

void Q3Header::released ( int  section  )  [signal]

This signal is emitted when section section is released.

See also:
pressed()

Referenced by keyReleaseEvent(), and mouseReleaseEvent().

void Q3Header::sizeChange ( int  section,
int  oldSize,
int  newSize 
) [signal]

This signal is emitted when the user has changed the size of a section from oldSize to newSize. This signal is typically connected to a slot that repaints the table or list that contains the header.

Referenced by Q3ListView::adjustColumn(), adjustHeaderSize(), handleColumnResize(), Q3TableHeader::mouseDoubleClickEvent(), Q3TableHeader::Q3TableHeader(), and Q3ListView::setColumnWidth().

void Q3Header::indexChange ( int  section,
int  fromIndex,
int  toIndex 
) [signal]

This signal is emitted when the user moves section section from index position fromIndex, to index position toIndex.

Referenced by handleColumnMove(), mouseReleaseEvent(), and Q3TableHeader::Q3TableHeader().

void Q3Header::sectionClicked ( int  index  )  [signal]

Use clicked() instead.

This signal is emitted when a part of the header is clicked. index is the index at which the section is displayed.

In a list view this signal would typically be connected to a slot that sorts the specified column (or row).

Referenced by keyReleaseEvent(), and mouseReleaseEvent().

void Q3Header::moved ( int  fromIndex,
int  toIndex 
) [signal]

Use indexChange() instead.

This signal is emitted when the user has moved the section which is displayed at the index fromIndex to the index toIndex.

Referenced by handleColumnMove(), and mouseReleaseEvent().

void Q3Header::sectionHandleDoubleClicked ( int  section  )  [signal]

This signal is emitted when the user doubleclicks on the edge (handle) of section section.

Referenced by mouseDoubleClickEvent().

void Q3Header::paintEvent ( QPaintEvent e  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 1596 of file q3header.cpp.

References QRect::bottom(), Q3HeaderData::clicks, Q3HeaderData::count, count(), d, QStyle::drawPrimitive(), Q3HeaderData::focusIdx, QWidget::hasFocus(), Qt::Horizontal, i, QRect::left(), mapToIndex(), mapToSection(), offset(), orient, p, paintSection(), QWidget::palette(), QStyleOption::palette, QStyle::PE_FrameFocusRect, QWidget::pos(), QPaintEvent::rect(), QStyleOption::rect, reverse(), right(), QRect::right(), sectionAt(), QRect::setRect(), sRect(), QStyleOption::state, QStyle::State_None, QWidget::style(), QRect::top(), and Qt::Vertical.

01597 {
01598     QPainter p(this);
01599     p.setPen(palette().buttonText().color());
01600     int pos = orient == Qt::Horizontal ? e->rect().left() : e->rect().top();
01601     int id = mapToIndex(sectionAt(pos + offset()));
01602     if (id < 0) {
01603         if (pos > 0)
01604             id = d->count;
01605         else if (reverse())
01606             id = d->count - 1;
01607         else
01608             id = 0;
01609     }
01610     if (reverse()) {
01611         for (int i = id; i >= 0; i--) {
01612             QRect r = sRect(i);
01613             paintSection(&p, i, r);
01614             if (r.right() >= e->rect().right())
01615                 return;
01616         }
01617     } else {
01618         if (count() > 0) {
01619             for (int i = id; i <= count(); i++) {
01620                 QRect r = sRect(i);
01621                 /*
01622                   If the last section is clickable (and thus is
01623                   painted raised), draw the virtual section count()
01624                   as well. Otherwise it looks ugly.
01625                 */
01626                 if (i < count() || d->clicks[mapToSection(count() - 1)])
01627                     paintSection(&p, i, r);
01628                 if (hasFocus() && d->focusIdx == i) {
01629                     QStyleOptionFocusRect opt;
01630                     opt.rect.setRect(r.x()+2, r.y()+2, r.width()-4, r.height()-4);
01631                     opt.palette = palette();
01632                     opt.state = QStyle::State_None;
01633                     style()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, &p, this);
01634                 }
01635                 if (orient == Qt::Horizontal && r. right() >= e->rect().right() ||
01636                      orient == Qt::Vertical && r. bottom() >= e->rect().bottom())
01637                     return;
01638             }
01639         }
01640     }
01641 }

Here is the call graph for this function:

void Q3Header::showEvent ( QShowEvent e  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 268 of file q3header.cpp.

References calculatePositions(), and QWidget::showEvent().

00269 {
00270     calculatePositions();
00271     QWidget::showEvent(e);
00272 }

Here is the call graph for this function:

void Q3Header::resizeEvent ( QResizeEvent e  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 1870 of file q3header.cpp.

References adjustHeaderSize(), d, QWidget::height(), Qt::Horizontal, Q3HeaderData::lastPos, offs, orientation(), QWidget::resizeEvent(), QWidget::update(), Qt::Vertical, and QWidget::width().

Referenced by Q3TableHeader::resizeEvent().

01871 {
01872     if (e)
01873         QWidget::resizeEvent(e);
01874 
01875     if(d->lastPos < width()) {
01876             offs = 0;
01877     }
01878 
01879     if (e) {
01880         adjustHeaderSize(orientation() == Qt::Horizontal ?
01881                           width() - e->oldSize().width() : height() - e->oldSize().height());
01882         if ((orientation() == Qt::Horizontal && height() != e->oldSize().height())
01883              || (orientation() == Qt::Vertical && width() != e->oldSize().width()))
01884             update();
01885     } else
01886         adjustHeaderSize();
01887 }

Here is the call graph for this function:

QRect Q3Header::sRect ( int  index  )  [protected]

Returns the rectangle covered by the section at index index.

Definition at line 912 of file q3header.cpp.

References count(), d, QWidget::height(), Qt::Horizontal, Q3HeaderData::lastPos, mapToSection(), offset(), orient, Q3HeaderData::positions, QWidget::rect(), reverse(), s, Q3HeaderData::sizes, and QWidget::width().

Referenced by handleColumnMove(), keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mousePressEvent(), Q3TableHeader::mouseReleaseEvent(), mouseReleaseEvent(), Q3TableHeader::paintEvent(), and paintEvent().

00913 {
00914 
00915     int section = mapToSection(index);
00916     if (count() > 0 && index >= count()) {
00917         int s = d->positions[count() - 1] - offset() +
00918                 d->sizes[mapToSection(count() - 1)];
00919         if (orient == Qt::Horizontal)
00920             return QRect(s, 0, width() - s + 10, height());
00921         else
00922             return QRect(0, s, width(), height() - s + 10);
00923     }
00924     if (section < 0)
00925         return rect(); // ### eeeeevil
00926 
00927     if (reverse())
00928         return QRect( d->lastPos - d->positions[index] - d->sizes[section] -offset(),
00929                        0, d->sizes[section], height());
00930     else if (orient == Qt::Horizontal)
00931         return QRect( d->positions[index]-offset(), 0, d->sizes[section], height());
00932     else
00933         return QRect(0, d->positions[index]-offset(), width(), d->sizes[section]);
00934 }

Here is the call graph for this function:

void Q3Header::paintSection ( QPainter p,
int  index,
const QRect fr 
) [protected, virtual]

Paints the section at position index, inside rectangle fr (which uses widget coordinates) using painter p.

Calls paintSectionLabel().

Definition at line 1463 of file q3header.cpp.

References QStyle::CE_HeaderSection, Q3HeaderData::clicks, count(), d, QStyle::drawControl(), getStyleOption(), handleIdx, QRect::height(), Qt::Horizontal, isClickEnabled(), QWidget::isEnabled(), QPalette::Light, mapToSection(), QPalette::Mid, Moving, orient, p, paintSectionLabel(), QWidget::palette(), Pressed, QStyleOption::rect, sectionSize(), QRect::setRect(), Q3HeaderData::sortDirection, QStyleOptionHeader::SortDown, QStyleOptionHeader::sortIndicator, Q3HeaderData::sortSection, QStyleOptionHeader::SortUp, state, QStyleOption::state, QStyle::State_Enabled, QStyle::State_Horizontal, QStyle::State_None, QStyle::State_Raised, QStyle::State_Sunken, QWidget::style(), QRect::topLeft(), QRect::width(), QWidget::width(), QRect::x(), and QRect::y().

Referenced by paintEvent(), and Q3TableHeader::paintSection().

01464 {
01465     int section = mapToSection(index);
01466     QStyleOptionHeader opt = getStyleOption(this, section);
01467     opt.state |= QStyle::State_Raised;
01468     opt.rect = fr;
01469 
01470     if (section < 0) {
01471         style()->drawControl(QStyle::CE_HeaderSection, &opt, p, this);
01472         return;
01473     }
01474 
01475     if (sectionSize(section) <= 0)
01476         return;
01477 
01478     opt.state = (orient == Qt::Horizontal ? QStyle::State_Horizontal : QStyle::State_None);
01479     if (d->sortSection == section)
01480         opt.sortIndicator = d->sortDirection ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;
01481 
01482     if (isEnabled())
01483         opt.state |= QStyle::State_Enabled;
01484     if (isClickEnabled(section) && (state == Pressed || state == Moving) && index == handleIdx)
01485         opt.state |= QStyle::State_Sunken; //currently pressed
01486     if (!(opt.state & QStyle::State_Sunken))
01487         opt.state |= QStyle::State_Raised;
01488     p->setBrushOrigin(fr.topLeft());
01489     if (d->clicks[section]) {
01490         style()->drawControl(QStyle::CE_HeaderSection, &opt, p, this);
01491     } else {
01492         p->save();
01493         p->setClipRect(fr); // hack to keep styles working
01494         opt.rect.setRect(fr.x() - 2, fr.y() - 2, fr.width() + 4, fr.height() + 4);
01495         style()->drawControl(QStyle::CE_HeaderSection, &opt, p, this);
01496         if (orient == Qt::Horizontal) {
01497             p->setPen(palette().color(QPalette::Mid));
01498             p->drawLine(fr.x(), fr.y() + fr.height() - 1,
01499                          fr.x() + fr.width() - 1, fr.y() + fr.height() - 1);
01500             p->drawLine(fr.x() + fr.width() - 1, fr.y(),
01501                          fr.x() + fr.width() - 1, fr.y() + fr.height() - 1);
01502             p->setPen(palette().color(QPalette::Light));
01503             if (index > 0)
01504                 p->drawLine(fr.x(), fr.y(), fr.x(), fr.y() + fr.height() - 1);
01505             if (index == count() - 1) {
01506                 p->drawLine(fr.x() + fr.width() - 1, fr.y(),
01507                              fr.x() + fr.width() - 1, fr.y() + fr.height() - 1);
01508                 p->setPen(palette().color(QPalette::Mid));
01509                 p->drawLine(fr.x() + fr.width() - 2, fr.y(),
01510                              fr.x() + fr.width() - 2, fr.y() + fr.height() - 1);
01511             }
01512         } else {
01513             p->setPen(palette().color(QPalette::Mid));
01514             p->drawLine(fr.x() + width() - 1, fr.y(),
01515                          fr.x() + fr.width() - 1, fr.y() + fr.height() - 1);
01516             p->drawLine(fr.x(), fr.y() + fr.height() - 1,
01517                          fr.x() + fr.width() - 1, fr.y() + fr.height() - 1);
01518             p->setPen(palette().color(QPalette::Light));
01519             if (index > 0)
01520                 p->drawLine(fr.x(), fr.y(), fr.x() + fr.width() - 1, fr.y());
01521             if (index == count() - 1) {
01522                 p->drawLine(fr.x(), fr.y() + fr.height() - 1,
01523                              fr.x() + fr.width() - 1, fr.y() + fr.height() - 1);
01524                 p->setPen(palette().color(QPalette::Mid));
01525                 p->drawLine(fr.x(), fr.y() + fr.height() - 2,
01526                              fr.x() + fr.width() - 1, fr.y() + fr.height() - 2);
01527             }
01528         }
01529         p->restore();
01530     }
01531 
01532     paintSectionLabel(p, index, fr);
01533 }

Here is the call graph for this function:

void Q3Header::paintSectionLabel ( QPainter p,
int  index,
const QRect fr 
) [protected, virtual]

Paints the label of the section at position index, inside rectangle fr (which uses widget coordinates) using painter p.

Called by paintSection()

Definition at line 1542 of file q3header.cpp.

References Qt::AlignRight, QStyle::CE_HeaderLabel, d, QStyle::drawControl(), QStyle::drawPrimitive(), getStyleOption(), handleIdx, QWidget::height(), QRect::height(), QSize::height(), Qt::Horizontal, QWidget::isEnabled(), QWidget::isRightToLeft(), label(), mapToSection(), Moving, orient, p, QStyle::PE_IndicatorHeaderArrow, QStyle::pixelMetric(), QStyle::PM_ButtonShiftHorizontal, QStyle::PM_ButtonShiftVertical, QStyle::PM_HeaderMargin, Pressed, QStyleOption::rect, reverse(), QRect::right(), sectionSizeHint(), QRect::setRect(), QStyle::SH_Header_ArrowAlignment, Q3HeaderData::sortDirection, QStyleOptionHeader::SortDown, QStyleOptionHeader::sortIndicator, Q3HeaderData::sortSection, QStyleOptionHeader::SortUp, state, QStyleOption::state, QStyle::State_DownArrow, QStyle::State_Enabled, QStyle::State_None, QStyle::State_Sunken, QStyle::State_UpArrow, QWidget::style(), styleHint(), QRect::width(), QSize::width(), QWidget::width(), QRect::x(), and QRect::y().

Referenced by Q3TableHeader::paintSection(), and paintSection().

01543 {
01544     int section = mapToSection(index);
01545     if (section < 0)
01546         return;
01547 
01548     int dx = 0, dy = 0;
01549     QStyleOptionHeader opt = getStyleOption(this, section);
01550     if (d->sortSection == section)
01551         opt.sortIndicator = d->sortDirection ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;
01552     if (index == handleIdx && (state == Pressed || state == Moving)) {
01553         dx = style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &opt, this);
01554         dy = style()->pixelMetric(QStyle::PM_ButtonShiftVertical, &opt, this);
01555         opt.state |= QStyle::State_Sunken;
01556     }
01557     if (isEnabled())
01558         opt.state |= QStyle::State_Enabled;
01559 
01560 
01561     opt.rect.setRect(fr.x() + style()->pixelMetric(QStyle::PM_HeaderMargin) + dx, fr.y() + 2 + dy,
01562                      fr.width() - 6, fr.height() - 4);
01563 
01564     style()->drawControl(QStyle::CE_HeaderLabel, &opt, p, this);
01565 
01566     int arrowWidth = (orient == Qt::Horizontal ? height() : width()) / 2;
01567     int arrowHeight = fr.height() - 6;
01568     QSize ssh = sectionSizeHint(section, p->fontMetrics());
01569     int tw = (orient == Qt::Horizontal ? ssh.width() : ssh.height());
01570     int ew = 0;
01571 
01572     if (style()->styleHint(QStyle::SH_Header_ArrowAlignment, 0, this) & Qt::AlignRight)
01573         ew = fr.width() - tw - 8;
01574     if (d->sortSection == section && tw <= fr.width()) {
01575         if (reverse()) {
01576             tw = fr.width() - tw;
01577             ew = fr.width() - ew - tw;
01578         }
01579         opt.state = QStyle::State_None;
01580         if (isEnabled())
01581             opt.state |= QStyle::State_Enabled;
01582         if (d->sortDirection)
01583             opt.state |= QStyle::State_DownArrow;
01584         else
01585             opt.state |= QStyle::State_UpArrow;
01586         QRect ar(fr.x() + tw - arrowWidth - 6 + ew, 4, arrowWidth, arrowHeight);
01587         if (label(section).isRightToLeft())
01588             ar.moveBy( 2*(fr.right() - ar.right()) + ar.width() - fr.width(), 0 );
01589         opt.rect = ar;
01590         style()->drawPrimitive(QStyle::PE_IndicatorHeaderArrow, &opt, p, this);
01591     }
01592 }

Here is the call graph for this function:

void Q3Header::changeEvent ( QEvent ev  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 2025 of file q3header.cpp.

References QWidget::changeEvent(), d, QEvent::FontChange, QWidget::fontMetrics(), Q3HeaderData::height, Qt::Horizontal, orient, and QEvent::type().

02026 {
02027     if(ev->type() == QEvent::FontChange) {
02028         QFontMetrics fm = fontMetrics();
02029         d->height = (orient == Qt::Horizontal) ? fm.lineSpacing() + 6 : fm.width(' ');
02030     }
02031     QWidget::changeEvent(ev);
02032 }

Here is the call graph for this function:

void Q3Header::mousePressEvent ( QMouseEvent e  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 666 of file q3header.cpp.

References Blocked, QMouseEvent::button(), c, clickPos, Q3HeaderData::clicks, count(), d, emit, Q3HeaderData::fullSize, handleIdx, QWidget::height(), Qt::Horizontal, Q3HeaderData::i2s, Idle, index, Q3HeaderData::lastPos, Qt::LeftButton, moveToIdx, offset(), oldHandleIdx, oldHIdxSize, orient, QStyle::pixelMetric(), QStyle::PM_HeaderGripMargin, QMouseEvent::pos(), positions, Q3HeaderData::positions, Q3HeaderData::pressDelta, Pressed, pressed(), QWidget::repaint(), Q3HeaderData::resize, reverse(), Q3HeaderData::s2i, Q3HeaderData::sectionAt(), Q3HeaderData::sizes, Sliding, sRect(), state, QWidget::style(), QWidget::width(), QPoint::x(), and QPoint::y().

Referenced by Q3TableHeader::mousePressEvent().

00667 {
00668     if (e->button() != Qt::LeftButton || state != Idle)
00669         return;
00670     oldHIdxSize = handleIdx;
00671     handleIdx = 0;
00672     int c = orient == Qt::Horizontal ? e->pos().x() : e->pos().y();
00673     c += offset();
00674     if (reverse())
00675         c = d->lastPos - c;
00676 
00677     int section = d->sectionAt(c);
00678     if (section < 0)
00679         return;
00680     int GripMargin = (bool)d->resize[section] ?
00681         style()->pixelMetric(QStyle::PM_HeaderGripMargin) : 0;
00682     int index = d->s2i[section];
00683 
00684     if ((index > 0 && c < d->positions[index] + GripMargin) ||
00685          (c > d->positions[index] + d->sizes[section] - GripMargin)) {
00686         if (c < d->positions[index] + GripMargin)
00687             handleIdx = index-1;
00688         else
00689             handleIdx = index;
00690         if (d->lastPos <= (orient == Qt::Horizontal ? width() :
00691                              height()) && d->fullSize != -2 && handleIdx == count() - 1) {
00692             handleIdx = -1;
00693             return;
00694         }
00695         oldHIdxSize = d->sizes[d->i2s[handleIdx]];
00696         state = d->resize[d->i2s[handleIdx] ] ? Sliding : Blocked;
00697     } else if (index >= 0) {
00698         oldHandleIdx = handleIdx = index;
00699         moveToIdx = -1;
00700         state = d->clicks[d->i2s[handleIdx] ] ? Pressed : Blocked;
00701         clickPos = c;
00702         repaint(sRect(handleIdx));
00703         if(oldHandleIdx != handleIdx)
00704             repaint(sRect(oldHandleIdx));
00705         emit pressed(section);
00706     }
00707 
00708     d->pressDelta = c - (d->positions[handleIdx] + d->sizes[d->i2s[handleIdx]]);
00709 }

Here is the call graph for this function:

void Q3Header::mouseReleaseEvent ( QMouseEvent e  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 714 of file q3header.cpp.

References Blocked, QMouseEvent::button(), c, clicked(), d, emit, handleColumnResize(), handleIdx, Qt::Horizontal, Q3HeaderData::i2s, Idle, indexChange(), Q3HeaderData::lastPos, Qt::LeftButton, moved(), moveSection(), moveToIdx, Moving, offset(), oldHandleIdx, orient, QMouseEvent::pos(), Q3HeaderData::pressDelta, Pressed, released(), QWidget::repaint(), reverse(), sectionClicked(), Sliding, sRect(), state, QWidget::unsetCursor(), QPoint::x(), and QPoint::y().

Referenced by Q3TableHeader::mouseReleaseEvent().

00715 {
00716     if (e->button() != Qt::LeftButton)
00717         return;
00718     int oldOldHandleIdx = oldHandleIdx;
00719     State oldState = state;
00720     state = Idle;
00721     switch (oldState) {
00722     case Pressed: {
00723         int section = d->i2s[handleIdx];
00724         emit released(section);
00725         if (sRect(handleIdx).contains(e->pos())) {
00726             oldHandleIdx = handleIdx;
00727             emit sectionClicked(handleIdx);
00728             emit clicked(section);
00729         } else {
00730             handleIdx = oldHandleIdx;
00731         }
00732         repaint(sRect(handleIdx));
00733         if (oldOldHandleIdx != handleIdx)
00734             repaint(sRect(oldOldHandleIdx));
00735         } break;
00736     case Sliding: {
00737         int c = orient == Qt::Horizontal ? e->pos().x() : e->pos().y();
00738         c += offset();
00739         if (reverse())
00740             c = d->lastPos - c;
00741         handleColumnResize(handleIdx, c - d->pressDelta, true);
00742     } break;
00743     case Moving: {
00744 #ifndef QT_NO_CURSOR
00745         unsetCursor();
00746 #endif
00747         int section = d->i2s[handleIdx];
00748         if (handleIdx != moveToIdx && moveToIdx != -1) {
00749             moveSection(section, moveToIdx);
00750             handleIdx = oldHandleIdx;
00751             emit moved(handleIdx, moveToIdx);
00752             emit indexChange(section, handleIdx, moveToIdx);
00753             emit released(section);
00754             repaint(); // a bit overkill, but removes the handle as well
00755         } else {
00756             if (sRect(handleIdx).contains(e->pos())) {
00757                 oldHandleIdx = handleIdx;
00758                 emit released(section);
00759                 emit sectionClicked(handleIdx);
00760                 emit clicked(section);
00761             } else {
00762                 handleIdx = oldHandleIdx;
00763             }
00764             repaint(sRect(handleIdx));
00765             if(oldOldHandleIdx != handleIdx)
00766                 repaint(sRect(oldOldHandleIdx));
00767         }
00768         break;
00769     }
00770     case Blocked:
00771         //nothing
00772         break;
00773     default:
00774         // empty, probably.  Idle, at any rate.
00775         break;
00776     }
00777 }

Here is the call graph for this function:

void Q3Header::mouseMoveEvent ( QMouseEvent e  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 782 of file q3header.cpp.

References Blocked, c, clickPos, d, data, findLine(), handleAt(), handleColumnResize(), handleIdx, Qt::Horizontal, Idle, Q3HeaderData::lastPos, markLine(), Q3HeaderData::move, moveToIdx, Moving, QObject::objectName(), offset(), orient, paintRect(), QMouseEvent::pos(), QWidget::pos(), pPos(), Pressed, pSize(), qWarning(), QWidget::repaint(), reverse(), QWidget::setCursor(), Qt::SizeHorCursor, Qt::SizeVerCursor, Sliding, sRect(), state, unMarkLine(), QWidget::unsetCursor(), QPoint::x(), and QPoint::y().

Referenced by Q3TableHeader::mouseMoveEvent().

00783 {
00784     int c = orient == Qt::Horizontal ? e->pos().x() : e->pos().y();
00785     c += offset();
00786 
00787     int pos = c;
00788     if(reverse())
00789         c = d->lastPos - c;
00790 
00791     switch(state) {
00792     case Idle:
00793 #ifndef QT_NO_CURSOR
00794         if (handleAt(c) < 0)
00795             unsetCursor();
00796         else if (orient == Qt::Horizontal)
00797             setCursor(Qt::splitHCursor);
00798         else
00799             setCursor(Qt::splitVCursor);
00800 #endif
00801         break;
00802     case Blocked:
00803         break;
00804     case Pressed:
00805         if (QABS(c - clickPos) > 4 && d->move) {
00806             state = Moving;
00807             moveToIdx = -1;
00808 #ifndef QT_NO_CURSOR
00809             if (orient == Qt::Horizontal)
00810                 setCursor(Qt::SizeHorCursor);
00811             else
00812                 setCursor(Qt::SizeVerCursor);
00813 #endif
00814         }
00815         break;
00816     case Sliding:
00817         handleColumnResize(handleIdx, c, false, false);
00818         break;
00819     case Moving: {
00820         int newPos = findLine(pos);
00821         if (newPos != moveToIdx) {
00822             if (moveToIdx == handleIdx || moveToIdx == handleIdx + 1)
00823                 repaint(sRect(handleIdx));
00824             else
00825                 unMarkLine(moveToIdx);
00826             moveToIdx = newPos;
00827             if (moveToIdx == handleIdx || moveToIdx == handleIdx + 1)
00828                 paintRect(pPos(handleIdx), pSize(handleIdx));
00829             else
00830                 markLine(moveToIdx);
00831         }
00832         break;
00833     }
00834     default:
00835         qWarning("Q3Header::mouseMoveEvent: (%s) unknown state", objectName().toLocal8Bit().data());
00836         break;
00837     }
00838 }

Here is the call graph for this function:

void Q3Header::mouseDoubleClickEvent ( QMouseEvent e  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 842 of file q3header.cpp.

References d, emit, handleAt(), header(), Qt::Horizontal, Q3HeaderData::lastPos, offset(), orient, p, QMouseEvent::pos(), reverse(), sectionHandleDoubleClicked(), QPoint::x(), and QPoint::y().

00843 {
00844     int p = orient == Qt::Horizontal ? e->pos().x() : e->pos().y();
00845     p += offset();
00846     if(reverse())
00847         p = d->lastPos - p;
00848 
00849     int header = handleAt(p);
00850     if (header >= 0)
00851         emit sectionHandleDoubleClicked(header);
00852 }

Here is the call graph for this function:

void Q3Header::keyPressEvent ( QKeyEvent e  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 600 of file q3header.cpp.

References c, Q3HeaderData::clicks, count(), d, emit, Q3HeaderData::focusIdx, handleColumnMove(), handleColumnResize(), handleIdx, Qt::Horizontal, i, Q3HeaderData::i2s, Idle, QEvent::ignore(), QKeyEvent::key(), Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, Qt::Key_Space, Qt::Key_Up, Q3HeaderData::move, orientation(), Q3HeaderData::positions, Pressed, pressed(), QWidget::repaint(), Q3HeaderData::resize, s, Q3HeaderData::sizes, sRect(), state, QWidget::update(), and Qt::Vertical.

00601 {
00602     int i = d->focusIdx;
00603     if (e->key() == Qt::Key_Space) {
00604         //don't do it if we're doing something with the mouse
00605         if (state == Idle && d->clicks[d->i2s[d->focusIdx] ]) {
00606             handleIdx = i;
00607             state = Pressed;
00608             repaint(sRect(handleIdx));
00609             emit pressed(d->i2s[i]);
00610         }
00611     } else if (orientation() == Qt::Horizontal &&
00612                 (e->key() == Qt::Key_Right || e->key() == Qt::Key_Left)
00613                 || orientation() == Qt::Vertical &&
00614                 (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)) {
00615         int dir = e->key() == Qt::Key_Right || e->key() == Qt::Key_Down ? 1 : -1;
00616         int s = d->i2s[i];
00617         if (e->state() & Qt::ControlButton  && d->resize[s]) {
00618             //resize
00619             int step = e->state() & Qt::ShiftButton ? dir : 10*dir;
00620             int c = d->positions[i] + d->sizes[s] +  step;
00621             handleColumnResize(i, c, true);
00622         } else         if (e->state() & (Qt::AltButton|Qt::MetaButton) && d->move) {
00623             //move section
00624             int i2 = (i + count() + dir) % count();
00625             d->focusIdx = i2;
00626             handleColumnMove(i, i2);
00627         } else {
00628             //focus on different section
00629             QRect r = sRect(d->focusIdx);
00630             d->focusIdx = (d->focusIdx + count() + dir) % count();
00631             r |= sRect(d->focusIdx);
00632             update(r);
00633         }
00634     } else {
00635         e->ignore();
00636     }
00637 }

Here is the call graph for this function:

void Q3Header::keyReleaseEvent ( QKeyEvent e  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 642 of file q3header.cpp.

References clicked(), d, emit, Q3HeaderData::focusIdx, handleIdx, Q3HeaderData::i2s, Idle, QEvent::ignore(), QKeyEvent::key(), Qt::Key_Space, Pressed, released(), QWidget::repaint(), sectionClicked(), sRect(), and state.

00643 {
00644     switch (e->key()) {
00645     case Qt::Key_Space:
00646         //double check that this wasn't started with the mouse
00647         if (state == Pressed && handleIdx == d->focusIdx) {
00648             repaint(sRect(handleIdx));
00649             int section = d->i2s[d->focusIdx];
00650             emit released(section);
00651             emit sectionClicked(handleIdx);
00652             emit clicked(section);
00653             state = Idle;
00654             handleIdx = -1;
00655         }
00656         break;
00657     default:
00658         e->ignore();
00659     }
00660 }

Here is the call graph for this function:

void Q3Header::handleColumnMove ( int  fromIdx,
int  toIdx 
) [private]

Move and signal and repaint.

Definition at line 584 of file q3header.cpp.

References d, emit, Q3HeaderData::i2s, indexChange(), moved(), moveSection(), s, sRect(), and QWidget::update().

Referenced by keyPressEvent().

00585 {
00586     int s = d->i2s[fromIdx];
00587     if (fromIdx < toIdx)
00588         toIdx++; //Convert to
00589     QRect r = sRect(fromIdx);
00590     r |= sRect(toIdx);
00591     moveSection(s, toIdx);
00592     update(r);
00593     emit moved(fromIdx, toIdx);
00594     emit indexChange(s, fromIdx, toIdx);
00595 }

Here is the call graph for this function:

void Q3Header::adjustHeaderSize ( int  diff  )  [private]

Definition at line 1897 of file q3header.cpp.

References count(), d, emit, Q3HeaderData::fullSize, QWidget::height(), Qt::Horizontal, i, Q3HeaderData::lastPos, mapToIndex(), mapToSection(), ns, orient, orientation(), QWidget::repaint(), sectionPos(), sectionSize(), setCellSize(), sizeChange(), Q3HeaderData::sizes, and QWidget::width().

01898 {
01899     if (!count())
01900         return;
01901 
01902     // we skip the adjustHeaderSize when trying to resize the last column which is set to stretchable
01903     if (d->fullSize == (count() -1) &&
01904          (d->lastPos - d->sizes[count() -1]) > (orient == Qt::Horizontal ? width() : height()))
01905         return;
01906 
01907     if (d->fullSize >= 0) {
01908         int sec = mapToSection(d->fullSize);
01909         int lsec = mapToSection(count() - 1);
01910         int ns = sectionSize(sec) +
01911                  (orientation() == Qt::Horizontal ?
01912                    width() : height()) - (sectionPos(lsec) + sectionSize(lsec));
01913         int os = sectionSize(sec);
01914         if (ns < 20)
01915             ns = 20;
01916         setCellSize(sec, ns);
01917         repaint();
01918         emit sizeChange(sec, os, ns);
01919     } else if (d->fullSize == -1) {
01920         int df = diff / count();
01921         int part = orientation() == Qt::Horizontal ? width() / count() : height() / count();
01922         for (int i = 0; i < count() - 1; ++i) {
01923             int sec = mapToIndex(i);
01924             int os = sectionSize(sec);
01925             int ns = diff != -1 ? os + df : part;
01926             if (ns < 20)
01927                 ns = 20;
01928             setCellSize(sec, ns);
01929             emit sizeChange(sec, os, ns);
01930         }
01931         int sec = mapToIndex(count() - 1);
01932         int ns = (orientation() == Qt::Horizontal ? width() : height()) - sectionPos(sec);
01933         int os = sectionSize(sec);
01934         if (ns < 20)
01935             ns = 20;
01936         setCellSize(sec, ns);
01937         repaint();
01938         emit sizeChange(sec, os, ns);
01939     }
01940 }

Here is the call graph for this function:

void Q3Header::init ( int   )  [private]

Definition at line 396 of file q3header.cpp.

References QPalette::Button, cachedPos, d, QSizePolicy::Fixed, handleIdx, Q3HeaderData::height, Q3HeaderData::heightDirty, Idle, Q3HeaderData::lastPos, offs, oldHandleIdx, oldHIdxSize, QSizePolicy::Preferred, reverse(), QWidget::setAttribute(), QWidget::setBackgroundRole(), QWidget::setMouseTracking(), QWidget::setSizePolicy(), state, trackingIsOn, Qt::WA_PaintOutsidePaintEvent, and QWidget::width().

Referenced by Q3Header().

00397 {
00398     state = Idle;
00399     cachedPos = 0; // unused
00400     d = new Q3HeaderData(n);
00401     d->height = 0;
00402     d->heightDirty = true;
00403     offs = 0;
00404     if(reverse())
00405         offs = d->lastPos - width();
00406     oldHandleIdx = oldHIdxSize = handleIdx = 0;
00407 
00408     setMouseTracking(true);
00409     trackingIsOn = false;
00410     setBackgroundRole(QPalette::Button);
00411     setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
00412     setAttribute(Qt::WA_PaintOutsidePaintEvent);
00413 }

Here is the call graph for this function:

void Q3Header::paintRect ( int  p,
int  s 
) [private]

Definition at line 443 of file q3header.cpp.

References Qt::black, Qt::DotLine, QPainter::drawRect(), QWidget::height(), Qt::Horizontal, orient, reverse(), and QPainter::setPen().

Referenced by mouseMoveEvent().

00444 {
00445     QPainter paint(this);
00446     paint.setPen(QPen(Qt::black, 1, Qt::DotLine));
00447     if (reverse())
00448         paint.drawRect(p - s, 3, s, height() - 5);
00449     else if (orient == Qt::Horizontal)
00450         paint.drawRect(p, 3, s, height() - 5);
00451     else
00452         paint.drawRect(3, p, height() - 5, s);
00453 }

Here is the call graph for this function:

void Q3Header::markLine ( int  idx  )  [private]

Definition at line 458 of file q3header.cpp.

References Qt::black, Qt::DotLine, QPainter::drawLine(), QWidget::height(), orient, p, QStyle::pixelMetric(), QStyle::PM_HeaderMarkSize, pPos(), QPainter::setPen(), QWidget::style(), t, Qt::Vertical, QWidget::x(), and QWidget::y().

Referenced by mouseMoveEvent().

00459 {
00460     QPainter paint(this);
00461     paint.setPen(QPen(Qt::black, 1, Qt::DotLine));
00462     int MARKSIZE = style()->pixelMetric(QStyle::PM_HeaderMarkSize);
00463     int p = pPos(idx);
00464     int x = p - MARKSIZE/2;
00465     int y = 2;
00466     int x2 = p + MARKSIZE/2;
00467     int y2 = height() - 3;
00468     if (orient == Qt::Vertical) {
00469         int t = x; x = y; y = t;
00470         t = x2; x2 = y2; y2 = t;
00471     }
00472 
00473     paint.drawLine(x, y, x2, y);
00474     paint.drawLine(x, y+1, x2, y+1);
00475 
00476     paint.drawLine(x, y2, x2, y2);
00477     paint.drawLine(x, y2-1, x2, y2-1);
00478 
00479     paint.drawLine(x, y, x, y2);
00480     paint.drawLine(x+1, y, x+1, y2);
00481 
00482     paint.drawLine(x2, y, x2, y2);
00483     paint.drawLine(x2-1, y, x2-1, y2);
00484 }

Here is the call graph for this function:

void Q3Header::unMarkLine ( int  idx  )  [private]

Definition at line 489 of file q3header.cpp.

References QWidget::height(), orient, p, QStyle::pixelMetric(), QStyle::PM_HeaderMarkSize, pPos(), QWidget::repaint(), QWidget::style(), t, Qt::Vertical, QWidget::x(), and QWidget::y().

Referenced by mouseMoveEvent().

00490 {
00491     if (idx < 0)
00492         return;
00493     int MARKSIZE = style()->pixelMetric(QStyle::PM_HeaderMarkSize);
00494     int p = pPos(idx);
00495     int x = p - MARKSIZE/2;
00496     int y = 2;
00497     int x2 = p + MARKSIZE/2;
00498     int y2 = height() - 3;
00499     if (orient == Qt::Vertical) {
00500         int t = x; x = y; y = t;
00501         t = x2; x2 = y2; y2 = t;
00502     }
00503     repaint(x, y, x2-x+1, y2-y+1);
00504 }

Here is the call graph for this function:

int Q3Header::pPos ( int  i  )  const [private]

Definition at line 1315 of file q3header.cpp.

References count(), d, Q3HeaderData::lastPos, offset(), QWidget::pos(), Q3HeaderData::positions, and reverse().

Referenced by findLine(), markLine(), mouseMoveEvent(), and unMarkLine().

01316 {
01317     int pos;
01318     if (i == count())
01319         pos = d->lastPos;
01320     else
01321         pos = d->positions[i];
01322     if (reverse())
01323         pos = d->lastPos - pos;
01324     return pos - offset();
01325 }

Here is the call graph for this function:

int Q3Header::pSize ( int  i  )  const [private]

Definition at line 1331 of file q3header.cpp.

References d, Q3HeaderData::i2s, and Q3HeaderData::sizes.

Referenced by findLine(), and mouseMoveEvent().

01332 {
01333     return d->sizes[d->i2s[i]];
01334 }

int Q3Header::findLine ( int   )  [private]

Definition at line 518 of file q3header.cpp.

References Q3HeaderData::count, d