Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/itemviews/qcolumnview.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    5353#include <qpainter.h>
    5454#include <qdebug.h>
    55 #include <qpainterpath.h>
    5655
    5756QT_BEGIN_NAMESPACE
     
    6564    \ingroup model-view
    6665    \ingroup advanced
    67     \mainclass
     66
    6867
    6968    QColumnView displays a model in a number of QListViews, one for each
     
    109108    Q_Q(QColumnView);
    110109    q->setTextElideMode(Qt::ElideMiddle);
    111     q->connect(&currentAnimation, SIGNAL(frameChanged(int)),
    112             q->horizontalScrollBar(), SLOT(setValue(int)));
    113     q->connect(&currentAnimation, SIGNAL(finished()), q, SLOT(_q_changeCurrentColumn()));
     110#ifndef QT_NO_ANIMATION
     111    QObject::connect(&currentAnimation, 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
    114117    delete itemDelegate;
    115118    q->setItemDelegate(new QColumnViewDelegate(q));
     
    261264        return;
    262265
    263     if (d->currentAnimation.state() == QTimeLine::Running)
     266#ifndef QT_NO_ANIMATION
     267    if (d->currentAnimation.state() == QPropertyAnimation::Running)
    264268        return;
    265269
    266270    d->currentAnimation.stop();
     271#endif //QT_NO_ANIMATION
    267272
    268273    // Fill up what is needed to get to index
     
    327332    }
    328333
    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);
    344336    d->currentAnimation.start();
     337#else
     338    horizontalScrollBar()->setValue(newScrollbarValue);
     339#endif //QT_NO_ANIMATION
    345340}
    346341
     
    411406{
    412407    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
    415412
    416413    // find the total horizontal length of the laid out columns
     
    422419    }
    423420
    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);
    427424    } else {
    428425        int visibleLength = qMin(horizontalLength + q->horizontalOffset(), viewportSize.width());
    429426        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);
    432429    }
    433430    if (!columns.isEmpty()) {
    434431        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);
    441438}
    442439
     
    676673    if (model->hasChildren(index)) {
    677674        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)));
    680677    } else {
    681678        if (!previewColumn)
     
    685682    }
    686683
    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)));
    697694
    698695    view->setFocusPolicy(Qt::NoFocus);
    699     view->setParent(q->viewport());
     696    view->setParent(viewport);
    700697    Q_ASSERT(view);
    701698
     
    708705
    709706    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());
    711708    } else {
    712709        int initialWidth = view->sizeHint().width();
    713710        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());
    715712        else
    716             view->setGeometry(0, 0, initialWidth, q->viewport()->height());
     713            view->setGeometry(0, 0, initialWidth, viewport->height());
    717714        columnSizes.resize(qMax(columnSizes.count(), columns.count() + 1));
    718715        columnSizes[columns.count()] = initialWidth;
     
    897894    \reimp
    898895*/
     896void 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*/
    899905void QColumnView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
    900906{
     
    10371043,showResizeGrips(true)
    10381044,offset(0)
    1039 ,currentAnimation(ANIMATION_DURATION_MSEC)
    10401045,previewWidget(0)
    10411046,previewColumn(0)
     
    10491054/*!
    10501055    \internal
     1056
     1057  */
     1058void 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  */
     1070void 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
    10511091    Place all of the columns where they belong inside of the viewport, resize as necessary.
    10521092*/
     
    10571097        return;
    10581098
    1059     int viewportHeight = q->viewport()->height();
     1099    int viewportHeight = viewport->height();
    10601100    int x = columns.at(0)->x();
    10611101
    10621102    if (q->isRightToLeft()) {
    1063         x = q->viewport()->width() + q->horizontalOffset();
     1103        x = viewport->width() + q->horizontalOffset();
    10641104        for (int i = 0; i < columns.size(); ++i) {
    10651105            QAbstractItemView *view = columns.at(i);
     
    11171157    if (index.model()->hasChildren(index)) {
    11181158        const QWidget *view = opt.widget;
    1119         QStyle *style = view ? view->style() : qApp->style();
     1159        QStyle *style = view ? view->style() : QApplication::style();
    11201160        style->drawPrimitive(QStyle::PE_IndicatorColumnViewArrow, &opt, painter, view);
    11211161    }
Note: See TracChangeset for help on using the changeset viewer.