void TradeTableModel::fillHeaderModel()
{
    _horizontalHeaderModel.setItem(0, 0, new QStandardItem(tr("Name")));
    _horizontalHeaderModel.setItem(0, 1, new QStandardItem(tr("Star")));
    _horizontalHeaderModel.setItem(0, 2, new QStandardItem(tr("Dist.")));

    static const QVector<QString> products={tr("Food"),tr("Meds"),tr("Alcohol"),tr("Minerals"),
                                            tr("Luxury"),tr("Technics"),tr("Weapons"),tr("Drugs")};

    for(int prod=0; prod<8; prod++)
    {
        QStandardItem* rootItem = new QStandardItem(products.at(prod));
        QList<QStandardItem*> l;

        l.push_back(new QStandardItem("#"));
        rootItem->appendColumn(l);
        l.clear();

        l.push_back(new QStandardItem("S"));
        rootItem->appendColumn(l);
        l.clear();

        l.push_back(new QStandardItem("B"));
        rootItem->appendColumn(l);
        l.clear();

        _horizontalHeaderModel.setItem(0, prod+3, rootItem);
    }
}
Esempio n. 2
0
void MainWindow::buildTableHeaderModel(QStandardItemModel& headerModel)
{
    QStandardItem* rootItem = new QStandardItem("root");
            QList<QStandardItem*> l;

            QStandardItem* rotatedTextCell=new QStandardItem("Rotated text");
            rotatedTextCell->setData(1, Qt::UserRole);
            l.push_back(rotatedTextCell);
            rootItem->appendColumn(l);

            l.clear();

            QStandardItem* cell=new QStandardItem("level 2");
            l.push_back(cell);
            rootItem->appendColumn(l);

            l.clear();

            l.push_back(new QStandardItem("level 3"));
            cell->appendColumn(l);

            l.clear();

            l.push_back(new QStandardItem("level 3"));
            cell->appendColumn(l);

            l.clear();

            l.push_back(new QStandardItem("level 2"));
            rootItem->appendColumn(l);

            headerModel.setItem(0,0,rootItem);
}
Esempio n. 3
0
void tst_QStandardItem::takeChild()
{
    QList<QStandardItem*> itemList;
    for (int i = 0; i < 10; ++i)
        itemList.append(new QStandardItem);
    QStandardItem item;
    item.appendColumn(itemList);

    for (int i = 0; i < item.rowCount(); ++i) {
        QCOMPARE(item.takeChild(i), itemList.at(i));
        QCOMPARE(item.takeChild(0, 0), static_cast<QStandardItem*>(0));
        for (int j = i + 1; j < item.rowCount(); ++j)
            QCOMPARE(item.child(j), itemList.at(j));
    }
    qDeleteAll(itemList);
}