当前位置: 首页>>代码示例>>C++>>正文


C++ ColumnView类代码示例

本文整理汇总了C++中ColumnView的典型用法代码示例。如果您正苦于以下问题:C++ ColumnView类的具体用法?C++ ColumnView怎么用?C++ ColumnView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ColumnView类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: paint

void tst_QColumnView::dynamicModelChanges()
{
    struct MyItemDelegate : public QItemDelegate
    {
        void paint(QPainter *painter,
                   const QStyleOptionViewItem &option,
                   const QModelIndex &index) const
        {
            paintedIndexes += index;
            QItemDelegate::paint(painter, option, index);
        }

        mutable QSet<QModelIndex> paintedIndexes;

    } delegate;;
    QStandardItemModel model;
    ColumnView view;
    view.setModel(&model);
    view.setItemDelegate(&delegate);
    view.show();

    QStandardItem *item = new QStandardItem(QLatin1String("item"));
    model.appendRow(item);

    QTest::qWait(200); //let the time for painting to occur
    QCOMPARE(delegate.paintedIndexes.count(), 1);
    QCOMPARE(*delegate.paintedIndexes.begin(), model.index(0,0));


}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:30,代码来源:tst_qcolumnview.cpp

示例2: setSelection

void tst_QColumnView::setSelection()
{
    ColumnView view;
    // shouldn't do anything, it falls to the columns to handle this
    QRect r;
    view.setSelection(r, QItemSelectionModel::NoUpdate);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:7,代码来源:tst_qcolumnview.cpp

示例3: isIndexHidden

void tst_QColumnView::isIndexHidden()
{
    ColumnView view;
    QModelIndex idx;
    QCOMPARE(view.IsIndexHidden(idx), false);
    QDirModel model;
    view.setModel(&model);
    QCOMPARE(view.IsIndexHidden(idx), false);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:9,代码来源:tst_qcolumnview.cpp

示例4: rowDelegate

void tst_QColumnView::rowDelegate()
{
    ColumnView view;
    QItemDelegate *d = new QItemDelegate;
    view.setItemDelegateForRow(3, d);

    QDirModel model;
    view.setModel(&model);
    for (int i = 0; i < view.createdColumns.count(); ++i) {
        QAbstractItemView *column = view.createdColumns.at(i);
        QCOMPARE(column->itemDelegateForRow(3), (QAbstractItemDelegate*)d);
    }
    delete d;
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:14,代码来源:tst_qcolumnview.cpp

示例5: QFETCH

void tst_QColumnView::pullRug()
{
    QFETCH(bool, removeModel);
    ColumnView view;
    TreeModel model;
    view.setModel(&model);
    QModelIndex home = model.thirdLevel();
    view.setCurrentIndex(home);
    if (removeModel)
        view.setModel(0);
    else
        view.setCurrentIndex(QModelIndex());
    QTest::qWait(ANIMATION_DELAY);
    // don't crash
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:15,代码来源:tst_qcolumnview.cpp

示例6: clicked

void tst_QColumnView::clicked()
{
    ColumnView view;

    QDirModel model;
    view.setModel(&model);
    view.resize(800,300);
    view.show();

    QModelIndex home = model.index(QDir::homePath());
    QVERIFY(home.isValid());
    view.setCurrentIndex(home);
    QTest::qWait(ANIMATION_DELAY);

    QModelIndex parent = home.parent();
    QVERIFY(parent.isValid());

    qRegisterMetaType<QModelIndex>("QModelIndex");
    QSignalSpy clickedSpy(&view, SIGNAL(clicked(const QModelIndex &)));

    QPoint localPoint = view.visualRect(home).center();
    QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, localPoint);
    QCOMPARE(clickedSpy.count(), 1);
    qApp->processEvents();
    
    if (sizeof(qreal) != sizeof(double)) {
        QSKIP("Skipped due to rounding errors", SkipAll);
    }
    
    for (int i = 0; i < view.createdColumns.count(); ++i) {
        QAbstractItemView *column = view.createdColumns.at(i);
        if (column && column->selectionModel() && (column->rootIndex() == home))
                QVERIFY(column->selectionModel()->selectedIndexes().isEmpty());
    }
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:35,代码来源:tst_qcolumnview.cpp

示例7: resize

void tst_QColumnView::resize()
{
    ColumnView view;
    QDirModel model;
    view.setModel(&model);
    view.resize(200, 200);

    view.show();
    QModelIndex home = model.index(QDir::homePath()).parent();
    view.setCurrentIndex(home);
    QTest::qWait(ANIMATION_DELAY);
    view.resize(200, 300);
    QTest::qWait(ANIMATION_DELAY);

    QVERIFY(view.horizontalScrollBar()->maximum() != 0);
    view.resize(view.horizontalScrollBar()->maximum() * 10, 300);
    QTest::qWait(ANIMATION_DELAY);
    QVERIFY(view.horizontalScrollBar()->maximum() <= 0);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:19,代码来源:tst_qcolumnview.cpp

示例8: selectedColumns

void tst_QColumnView::selectedColumns()
{
    ColumnView view;
    QDirModel model;
    view.setModel(&model);
    view.resize(800,300);
    view.show();

    QModelIndex home = model.index(QDir::homePath());
    view.setCurrentIndex(home);

    QTest::qWait(ANIMATION_DELAY);

    for (int i = 0; i < view.createdColumns.count(); ++i) {
        QAbstractItemView *column = view.createdColumns.at(i);
        if (!column)
            continue;
        if (!column->rootIndex().isValid() || column->rootIndex() == home)
            continue;
        QTRY_VERIFY(column->currentIndex().isValid());
    }
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:22,代码来源:tst_qcolumnview.cpp

示例9: visualRegionForSelection

void tst_QColumnView::visualRegionForSelection()
{
    ColumnView view;
    QItemSelection emptyItemSelection;
    QCOMPARE(QRegion(), view.visualRegionForSelection(emptyItemSelection));

    // a region that isn't empty
    QDirModel model;
    view.setModel(&model);

    // On Windows CE the home directory might actually be empty.
#ifndef Q_OS_WINCE
    QString location = QDir::homePath();
#else
    QString location = QLatin1String("/Windows");
#endif

    QModelIndex home = model.index(location);
    QVERIFY(model.rowCount(home) > 1);
    QItemSelection itemSelection(model.index(0, 0, home), model.index(model.rowCount(home) - 1, 0, home));
    QVERIFY(QRegion() != view.visualRegionForSelection(itemSelection));
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:22,代码来源:tst_qcolumnview.cpp

示例10: setSelectionModel

void tst_QColumnView::setSelectionModel()
{
    ColumnView view;
    QDirModel model;
    view.setModel(&model);
    view.show();

    QModelIndex home = model.index(QDir::homePath());
    view.setCurrentIndex(home);
    QTest::qWait(ANIMATION_DELAY);

    QItemSelectionModel *selectionModel = new QItemSelectionModel(&model);
    view.setSelectionModel(selectionModel);

    bool found = false;
    for (int i = 0; i < view.createdColumns.count(); ++i) {
        if (view.createdColumns.at(i)->selectionModel() == selectionModel) {
            found = true;
            break;
        }
    }
    QVERIFY(found);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:23,代码来源:tst_qcolumnview.cpp

示例11: changeSameColumn

void tst_QColumnView::changeSameColumn()
{
    ColumnView view;
    TreeModel model;
    view.setModel(&model);
    QModelIndex second;

    QModelIndex home = model.secondLevel();
    //index(QDir::homePath());
    view.setCurrentIndex(home);
    for (int i = 0; i < model.rowCount(home.parent()); ++i) {
        QModelIndex idx = model.index(i, 0, home.parent());
        if (model.hasChildren(idx) && idx != home) {
            second = idx;
            break;
        }
    }
    QVERIFY(second.isValid());

    QList<QPointer<QAbstractItemView> > old = view.createdColumns;
    view.setCurrentIndex(second);

    QCOMPARE(old, view.createdColumns);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:24,代码来源:tst_qcolumnview.cpp

示例12: rootIndex

void tst_QColumnView::rootIndex()
{
    ColumnView view;
    // no model
    view.setRootIndex(QModelIndex());

    TreeModel model;
    view.setModel(&model);

    // A top level index
    QModelIndex drive = model.firstLevel();
    QVERIFY(view.visualRect(drive).isValid());
    view.setRootIndex(QModelIndex());
    QCOMPARE(view.HorizontalOffset(), 0);
    QCOMPARE(view.rootIndex(), QModelIndex());
    QVERIFY(view.visualRect(drive).isValid());

    // A item under the rootIndex exists
    QModelIndex home = model.thirdLevel();
    QModelIndex homeFile = model.index(0, 0, home);
    int i = 0;
    while (i < model.rowCount(home) - 1 && !model.hasChildren(homeFile))
        homeFile = model.index(++i, 0, home);
    view.setRootIndex(home);
    QCOMPARE(view.HorizontalOffset(), 0);
    QCOMPARE(view.rootIndex(), home);
    QVERIFY(!view.visualRect(drive).isValid());
    QVERIFY(!view.visualRect(home).isValid());
    if (homeFile.isValid())
        QVERIFY(view.visualRect(homeFile).isValid());

    // set root when there already is one and everything should still be ok
    view.setRootIndex(home);
    view.setCurrentIndex(homeFile);
    view.scrollTo(model.index(0,0, homeFile));
    QCOMPARE(view.HorizontalOffset(), 0);
    QCOMPARE(view.rootIndex(), home);
    QVERIFY(!view.visualRect(drive).isValid());
    QVERIFY(!view.visualRect(home).isValid());
     if (homeFile.isValid())
        QVERIFY(view.visualRect(homeFile).isValid());

    //
    homeFile = model.thirdLevel();
    home = homeFile.parent();
    view.setRootIndex(home);
    view.setCurrentIndex(homeFile);
    view.show();
    i = 0;
    QModelIndex two = model.index(0, 0, homeFile);
    while (i < model.rowCount(homeFile) - 1 && !model.hasChildren(two))
        two = model.index(++i, 0, homeFile);
    qApp->processEvents();
    QTest::qWait(ANIMATION_DELAY);
    view.setCurrentIndex(two);
    view.scrollTo(two);
    QTest::qWait(ANIMATION_DELAY);
    qApp->processEvents();
    QVERIFY(two.isValid());
    QVERIFY(view.HorizontalOffset() != 0);

    view.setRootIndex(homeFile);
    QCOMPARE(view.HorizontalOffset(), 0);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:64,代码来源:tst_qcolumnview.cpp

示例13: selectAll

void tst_QColumnView::selectAll()
{
    ColumnView view;
    view.selectAll();

    QDirModel model;
    view.setModel(&model);
    view.selectAll();
    QVERIFY(view.selectionModel()->selectedIndexes().count() >= 0);

    QModelIndex home = model.index(QDir::homePath());
    view.setCurrentIndex(home);
    view.selectAll();
    QVERIFY(view.selectionModel()->selectedIndexes().count() > 0);

    QModelIndex file;
    for (int i = 0; i < model.rowCount(home); ++i)
        if (!model.hasChildren(model.index(i, 0, home))) {
            file = model.index(i, 0, home);
            break;
        }
    view.setCurrentIndex(file);
    view.selectAll();
    QVERIFY(view.selectionModel()->selectedIndexes().count() > 0);

    view.setCurrentIndex(QModelIndex());
    QVERIFY(view.selectionModel()->selectedIndexes().count() == 0);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:28,代码来源:tst_qcolumnview.cpp


注:本文中的ColumnView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。