Changeset 561 for trunk/src/gui/itemviews/qcolumnview.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/itemviews/qcolumnview.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 53 53 #include <qpainter.h> 54 54 #include <qdebug.h> 55 #include <qpainterpath.h>56 55 57 56 QT_BEGIN_NAMESPACE … … 65 64 \ingroup model-view 66 65 \ingroup advanced 67 \mainclass 66 68 67 69 68 QColumnView displays a model in a number of QListViews, one for each … … 109 108 Q_Q(QColumnView); 110 109 q->setTextElideMode(Qt::ElideMiddle); 111 q->connect(¤tAnimation, SIGNAL(frameChanged(int)), 112 q->horizontalScrollBar(), SLOT(setValue(int))); 113 q->connect(¤tAnimation, SIGNAL(finished()), q, SLOT(_q_changeCurrentColumn())); 110 #ifndef QT_NO_ANIMATION 111 QObject::connect(¤tAnimation, SIGNAL(finished()), q, SLOT(_q_changeCurrentColumn())); 112 currentAnimation.setDuration(ANIMATION_DURATION_MSEC); 113 currentAnimation.setTargetObject(hbar); 114 currentAnimation.setPropertyName("value"); 115 currentAnimation.setEasingCurve(QEasingCurve::InOutQuad); 116 #endif //QT_NO_ANIMATION 114 117 delete itemDelegate; 115 118 q->setItemDelegate(new QColumnViewDelegate(q)); … … 261 264 return; 262 265 263 if (d->currentAnimation.state() == QTimeLine::Running) 266 #ifndef QT_NO_ANIMATION 267 if (d->currentAnimation.state() == QPropertyAnimation::Running) 264 268 return; 265 269 266 270 d->currentAnimation.stop(); 271 #endif //QT_NO_ANIMATION 267 272 268 273 // Fill up what is needed to get to index … … 327 332 } 328 333 329 //horizontalScrollBar()->setValue(newScrollbarValue); 330 //d->_q_changeCurrentColumn(); 331 //return; 332 // or do the following currentAnimation 333 334 int oldValue = horizontalScrollBar()->value(); 335 336 if (oldValue < newScrollbarValue) { 337 d->currentAnimation.setFrameRange(oldValue, newScrollbarValue); 338 d->currentAnimation.setDirection(QTimeLine::Forward); 339 d->currentAnimation.setCurrentTime(0); 340 } else { 341 d->currentAnimation.setFrameRange(newScrollbarValue, oldValue); 342 d->currentAnimation.setDirection(QTimeLine::Backward); 343 } 334 #ifndef QT_NO_ANIMATION 335 d->currentAnimation.setEndValue(newScrollbarValue); 344 336 d->currentAnimation.start(); 337 #else 338 horizontalScrollBar()->setValue(newScrollbarValue); 339 #endif //QT_NO_ANIMATION 345 340 } 346 341 … … 411 406 { 412 407 Q_Q(QColumnView); 413 if (currentAnimation.state() == QTimeLine::Running) 414 return; 408 #ifndef QT_NO_ANIMATION 409 if (currentAnimation.state() == QPropertyAnimation::Running) 410 return; 411 #endif //QT_NO_ANIMATION 415 412 416 413 // find the total horizontal length of the laid out columns … … 422 419 } 423 420 424 QSize viewportSize = q->viewport()->size();425 if (horizontalLength < viewportSize.width() && q->horizontalScrollBar()->value() == 0) {426 q->horizontalScrollBar()->setRange(0, 0);421 QSize viewportSize = viewport->size(); 422 if (horizontalLength < viewportSize.width() && hbar->value() == 0) { 423 hbar->setRange(0, 0); 427 424 } else { 428 425 int visibleLength = qMin(horizontalLength + q->horizontalOffset(), viewportSize.width()); 429 426 int hiddenLength = horizontalLength - visibleLength; 430 if (hiddenLength != q->horizontalScrollBar()->maximum())431 q->horizontalScrollBar()->setRange(0, hiddenLength);427 if (hiddenLength != hbar->maximum()) 428 hbar->setRange(0, hiddenLength); 432 429 } 433 430 if (!columns.isEmpty()) { 434 431 int pageStepSize = columns.at(0)->width(); 435 if (pageStepSize != q->horizontalScrollBar()->pageStep())436 q->horizontalScrollBar()->setPageStep(pageStepSize);437 } 438 bool visible = ( q->horizontalScrollBar()->maximum() > 0);439 if (visible != q->horizontalScrollBar()->isVisible())440 q->horizontalScrollBar()->setVisible(visible);432 if (pageStepSize != hbar->pageStep()) 433 hbar->setPageStep(pageStepSize); 434 } 435 bool visible = (hbar->maximum() > 0); 436 if (visible != hbar->isVisible()) 437 hbar->setVisible(visible); 441 438 } 442 439 … … 676 673 if (model->hasChildren(index)) { 677 674 view = q->createColumn(index); 678 q->connect(view, SIGNAL(clicked( const QModelIndex &)),679 q, SLOT(_q_clicked( const QModelIndex &)));675 q->connect(view, SIGNAL(clicked(QModelIndex)), 676 q, SLOT(_q_clicked(QModelIndex))); 680 677 } else { 681 678 if (!previewColumn) … … 685 682 } 686 683 687 q->connect(view, SIGNAL(activated( const QModelIndex &)),688 q, SIGNAL(activated( const QModelIndex &)));689 q->connect(view, SIGNAL(clicked( const QModelIndex &)),690 q, SIGNAL(clicked( const QModelIndex &)));691 q->connect(view, SIGNAL(doubleClicked( const QModelIndex &)),692 q, SIGNAL(doubleClicked( const QModelIndex &)));693 q->connect(view, SIGNAL(entered( const QModelIndex &)),694 q, SIGNAL(entered( const QModelIndex &)));695 q->connect(view, SIGNAL(pressed( const QModelIndex &)),696 q, SIGNAL(pressed( const QModelIndex &)));684 q->connect(view, SIGNAL(activated(QModelIndex)), 685 q, SIGNAL(activated(QModelIndex))); 686 q->connect(view, SIGNAL(clicked(QModelIndex)), 687 q, SIGNAL(clicked(QModelIndex))); 688 q->connect(view, SIGNAL(doubleClicked(QModelIndex)), 689 q, SIGNAL(doubleClicked(QModelIndex))); 690 q->connect(view, SIGNAL(entered(QModelIndex)), 691 q, SIGNAL(entered(QModelIndex))); 692 q->connect(view, SIGNAL(pressed(QModelIndex)), 693 q, SIGNAL(pressed(QModelIndex))); 697 694 698 695 view->setFocusPolicy(Qt::NoFocus); 699 view->setParent( q->viewport());696 view->setParent(viewport); 700 697 Q_ASSERT(view); 701 698 … … 708 705 709 706 if (columnSizes.count() > columns.count()) { 710 view->setGeometry(0, 0, columnSizes.at(columns.count()), q->viewport()->height());707 view->setGeometry(0, 0, columnSizes.at(columns.count()), viewport->height()); 711 708 } else { 712 709 int initialWidth = view->sizeHint().width(); 713 710 if (q->isRightToLeft()) 714 view->setGeometry( q->viewport()->width() - initialWidth, 0, initialWidth, q->viewport()->height());711 view->setGeometry(viewport->width() - initialWidth, 0, initialWidth, viewport->height()); 715 712 else 716 view->setGeometry(0, 0, initialWidth, q->viewport()->height());713 view->setGeometry(0, 0, initialWidth, viewport->height()); 717 714 columnSizes.resize(qMax(columnSizes.count(), columns.count() + 1)); 718 715 columnSizes[columns.count()] = initialWidth; … … 897 894 \reimp 898 895 */ 896 void QColumnView::rowsInserted(const QModelIndex &parent, int start, int end) 897 { 898 QAbstractItemView::rowsInserted(parent, start, end); 899 d_func()->checkColumnCreation(parent); 900 } 901 902 /*! 903 \reimp 904 */ 899 905 void QColumnView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) 900 906 { … … 1037 1043 ,showResizeGrips(true) 1038 1044 ,offset(0) 1039 ,currentAnimation(ANIMATION_DURATION_MSEC)1040 1045 ,previewWidget(0) 1041 1046 ,previewColumn(0) … … 1049 1054 /*! 1050 1055 \internal 1056 1057 */ 1058 void QColumnViewPrivate::_q_columnsInserted(const QModelIndex &parent, int start, int end) 1059 { 1060 QAbstractItemViewPrivate::_q_columnsInserted(parent, start, end); 1061 checkColumnCreation(parent); 1062 } 1063 1064 /*! 1065 \internal 1066 1067 Makes sure we create a corresponding column as a result of changing the model. 1068 1069 */ 1070 void QColumnViewPrivate::checkColumnCreation(const QModelIndex &parent) 1071 { 1072 if (parent == q_func()->currentIndex() && model->hasChildren(parent)) { 1073 //the parent has children and is the current 1074 //let's try to find out if there is already a mapping that is good 1075 for (int i = 0; i < columns.count(); ++i) { 1076 QAbstractItemView *view = columns.at(i); 1077 if (view->rootIndex() == parent) { 1078 if (view == previewColumn) { 1079 //let's recreate the parent 1080 closeColumns(parent, false); 1081 createColumn(parent, true /*show*/); 1082 } 1083 break; 1084 } 1085 } 1086 } 1087 } 1088 1089 /*! 1090 \internal 1051 1091 Place all of the columns where they belong inside of the viewport, resize as necessary. 1052 1092 */ … … 1057 1097 return; 1058 1098 1059 int viewportHeight = q->viewport()->height();1099 int viewportHeight = viewport->height(); 1060 1100 int x = columns.at(0)->x(); 1061 1101 1062 1102 if (q->isRightToLeft()) { 1063 x = q->viewport()->width() + q->horizontalOffset();1103 x = viewport->width() + q->horizontalOffset(); 1064 1104 for (int i = 0; i < columns.size(); ++i) { 1065 1105 QAbstractItemView *view = columns.at(i); … … 1117 1157 if (index.model()->hasChildren(index)) { 1118 1158 const QWidget *view = opt.widget; 1119 QStyle *style = view ? view->style() : qApp->style();1159 QStyle *style = view ? view->style() : QApplication::style(); 1120 1160 style->drawPrimitive(QStyle::PE_IndicatorColumnViewArrow, &opt, painter, view); 1121 1161 }
Note:
See TracChangeset
for help on using the changeset viewer.