TableViewMetallisation::TableViewMetallisation(blocMetallisation *blocMetal, QWidget *parent) : TableView(parent) { MySortFilterProxyModel * proxyModel = new MySortFilterProxyModel(this); proxyModel->setSourceModel(new TableModelMetallisation(blocMetal)); this->setModel(proxyModel); this->setItemDelegateForColumn(TableModelMetallisation::Coord1,new CoordonneeDelegate()); this->setItemDelegateForColumn(TableModelMetallisation::Coord2,new CoordonneeDelegate()); }
TableViewElementLocalise::TableViewElementLocalise(blocElementLocalise *bloc, QWidget *parent) : TableView(parent) { MySortFilterProxyModel * proxyModel = new MySortFilterProxyModel(this); proxyModel->setSourceModel(new TableModelElementLocalise(bloc)); this->setModel(proxyModel); this->setItemDelegateForColumn(TableModelElementLocalise::Type,new ComboxDecaleeDelegate(QStringList() << "Résistance" << "Capacité" << "Self",1)); this->setItemDelegateForColumn(TableModelElementLocalise::Direction,new ComboxDecaleeDelegate(QStringList() << "x" << "y" << "z",1)); this->setItemDelegateForColumn(TableModelElementLocalise::ArriereDroit,new CoordonneeDelegate()); this->setItemDelegateForColumn(TableModelElementLocalise::AvantGauche,new CoordonneeDelegate()); }
void TabbedTableItem::createDataModel() { if (manager!=nullptr) tableAction->setManager(manager); dataModel = (BeanTableDataModel*)tableAction->getTableDataModel(); // dataModel->updateNameList(); // TableSorter sorter = new TableSorter(dataModel); MySortFilterProxyModel* sorter = new MySortFilterProxyModel(); sorter->setSourceModel(dataModel); dataTable = dataModel->makeJTable(dataModel->getMasterClassName() + ":" + getItemString(), dataModel, sorter); tableAction->table = dataTable; //sorter->setSourceModel(dataModel); dataTable->setSortingEnabled(true); //sorter.setTableHeader(dataTable.getTableHeader()); //dataScroll = new JScrollPane(dataTable); // try { // TableSorter tmodel = ((TableSorter)dataTable.getModel()); // tmodel.setColumnComparator(String.class, new jmri.util.SystemNameComparator()); // tmodel.setSortingStatus(BeanTableDataModel.SYSNAMECOL, TableSorter.ASCENDING); // } catch (java.lang.ClassCastException e) {} // happens if not sortable table dataModel->configureTable(dataTable); dataModel->loadTableColumnDetails(dataTable, dataModel->getMasterClassName()+":"+getItemString()); //dataModel->setPersistentButtons(); QSize dataTableSize = dataTable->sizeHint(); // width is right, but if table is empty, it's not high // enough to reserve much space. dataTableSize.setHeight(qMax(dataTableSize.height(), 400)); //dataScroll.getViewport().setPreferredSize(dataTableSize); // set preferred scrolling options // dataScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); //dataScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); //dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS)); dataPanel->resize(600,290); //QGridLayout* dataPanelLayout; // if(dataPanel->layout() != NULL) // dataPanelLayout = (QGridLayout*)dataPanel->layout(); // else //dataPanel->setLayout(dataPanelLayout= new QGridLayout); //dataPanel.add(dataScroll, BorderLayout.CENTER); dataPanelLayout->addWidget(dataTable,0,0); //, 0, Qt::AlignCenter); dataPanelLayout->addWidget(bottomBox,1,0); //, /*BorderLayout.SOUTH*/0, Qt::AlignBottom); if(tableAction->includeAddButton()) { QPushButton* addButton = new QPushButton(tr("Add")); addToBottomBox(addButton); // addButton.addActionListener(new ActionListener() { // /*public*/ void actionPerformed(ActionEvent e) { // tableAction.addPressed(e); // } // }); QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(addButton->sizePolicy().hasHeightForWidth()); addButton->setSizePolicy(sizePolicy); connect(addButton, SIGNAL(clicked()), tableAction, SLOT(addPressed())); } }