void ReceiveCoinsDialog::setModel(WalletModel *_model) { this->model = _model; if(_model && _model->getOptionsModel()) { _model->getRecentRequestsTableModel()->sort(RecentRequestsTableModel::Date, Qt::DescendingOrder); connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); updateDisplayUnit(); QTableView* tableView = ui->recentRequestsView; tableView->verticalHeader()->hide(); tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); tableView->setModel(_model->getRecentRequestsTableModel()); // tableView->setAlternatingRowColors(true); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setSelectionMode(QAbstractItemView::ContiguousSelection); tableView->setColumnWidth(RecentRequestsTableModel::Date, DATE_COLUMN_WIDTH); tableView->setColumnWidth(RecentRequestsTableModel::Label, LABEL_COLUMN_WIDTH); tableView->setColumnWidth(RecentRequestsTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH); tableView->setGridStyle(Qt::NoPen); QHeaderView * verticalHeader = tableView->verticalHeader(); verticalHeader->setDefaultSectionSize(57); tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter); connect(tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(recentRequestsView_selectionChanged(QItemSelection, QItemSelection))); // Last 2 columns are set by the columnResizingFixer, when the table geometry is ready. columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this); }
void ConvolveMatrixEffectConfigWidget::editKernel() { if (!m_effect) { return; } QVector<qreal> oldKernel = m_effect->kernel(); QPoint kernelSize = m_effect->order(); m_matrixModel->setMatrix(oldKernel, kernelSize.y(), kernelSize.x()); connect(m_matrixModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(kernelChanged())); QPointer<QDialog> dlg = new QDialog(this); QTableView *table = new QTableView(dlg); table->setModel(m_matrixModel); table->horizontalHeader()->hide(); table->horizontalHeader()->setResizeMode(QHeaderView::Stretch); table->verticalHeader()->hide(); table->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); QVBoxLayout *mainLayout = new QVBoxLayout; dlg->setLayout(mainLayout); mainLayout->addWidget(table); if (dlg->exec() == QDialog::Accepted) { m_effect->setKernel(m_matrixModel->matrix()); emit filterChanged(); } else { m_effect->setKernel(oldKernel); } delete dlg; disconnect(m_matrixModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(kernelChanged())); }
void MainWindow::createSongsTable(int size) { QTableView * songs = ui->tvSongs; delete songs->model(); delete songs->selectionModel(); QStandardItemModel *model = new QStandardItemModel(size, 3, songs); QItemSelectionModel *selections = new QItemSelectionModel(model); songs->setModel(model); songs->setSelectionModel(selections); songs->horizontalHeader()->setSectionsMovable(true); songs->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); songs->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); songs->verticalHeader()->setSectionsMovable(false); songs->verticalHeader()->setVisible(false); songs->setSelectionBehavior( QAbstractItemView::SelectRows ); songs->setSelectionMode( QAbstractItemView::SingleSelection ); songs->setContextMenuPolicy(Qt::CustomContextMenu); // Set StaticContents to enable minimal repaints on resizes. songs->viewport()->setAttribute(Qt::WA_StaticContents); model->setHorizontalHeaderItem(0, new QStandardItem(tr("Artist"))); model->setHorizontalHeaderItem(1, new QStandardItem(tr("Title"))); model->setHorizontalHeaderItem(2, new QStandardItem(tr("Length"))); }
ColorMatrixEffectConfigWidget::ColorMatrixEffectConfigWidget(QWidget *parent) : KFilterEffectConfigWidgetBase(parent), m_effect(0) { QGridLayout * g = new QGridLayout(this); m_type = new KComboBox(this); m_type->addItem(i18n("Apply color matrix")); m_type->addItem(i18n("Saturate colors")); m_type->addItem(i18n("Rotate hue")); m_type->addItem(i18n("Luminance to alpha")); g->addWidget(m_type, 0, 0); m_stack = new QStackedWidget(this); m_stack->setContentsMargins(0, 0, 0, 0); g->addWidget(m_stack, 1, 0); m_matrixModel = new MatrixDataModel(this); QTableView * matrixWidget = new QTableView(m_stack); matrixWidget->setModel(m_matrixModel); matrixWidget->horizontalHeader()->hide(); matrixWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch); matrixWidget->verticalHeader()->hide(); matrixWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); m_stack->addWidget(matrixWidget); QWidget * saturateWidget = new QWidget(m_stack); QGridLayout * saturateLayout = new QGridLayout(saturateWidget); saturateLayout->addWidget(new QLabel(i18n("Saturate value"), saturateWidget), 0, 0); m_saturate = new KDoubleNumInput(saturateWidget); m_saturate->setRange(0.0, 1.0, 0.05, false); saturateLayout->addWidget(m_saturate, 0, 1); saturateLayout->addItem(new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 1, 0); saturateWidget->setLayout(saturateLayout); m_stack->addWidget(saturateWidget); QWidget * hueRotateWidget = new QWidget(m_stack); QGridLayout * hueRotateLayout = new QGridLayout(hueRotateWidget); hueRotateLayout->addWidget(new QLabel(i18n("Angle"), hueRotateWidget), 0, 0); m_hueRotate = new KDoubleNumInput(hueRotateWidget); m_hueRotate->setRange(0.0, 360.0, 1.0, false); hueRotateLayout->addWidget(m_hueRotate, 0, 1); hueRotateLayout->addItem(new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 1, 0); hueRotateWidget->setLayout(hueRotateLayout); m_stack->addWidget(hueRotateWidget); QWidget * luminanceWidget = new QWidget(m_stack); m_stack->addWidget(luminanceWidget); setLayout(g); connect(m_type, SIGNAL(currentIndexChanged(int)), m_stack, SLOT(setCurrentIndex(int))); connect(m_type, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged(int))); connect(m_saturate, SIGNAL(valueChanged(double)), this, SLOT(saturateChanged(double))); connect(m_hueRotate, SIGNAL(valueChanged(double)), this, SLOT(hueRotateChanged(double))); connect(m_matrixModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(matrixChanged())); }
// Table factory QTableView* MakeTableView(QAbstractItemModel* model, bool sortingEnabled = true, uint32_t modelSortColumn = 0) { class MyTable : public QTableView { public: QStyleOptionViewItem viewOptions() const override { QStyleOptionViewItem option = QTableView::viewOptions(); option.decorationAlignment = Qt::AlignHCenter | Qt::AlignCenter; option.decorationPosition = QStyleOptionViewItem::Top; return option; } void mouseMoveEvent(QMouseEvent* event) override { QModelIndex index = indexAt(event->pos()); if (index.isValid()) { QVariant data = model()->data(index, PlayerTableModel::CursorRole); Qt::CursorShape shape = Qt::ArrowCursor; if (!data.isNull()) { shape = Qt::CursorShape(data.toInt()); } setCursor(shape); } QTableView::mouseMoveEvent(event); } }; QTableView* tableView = new MyTable(); tableView->setModel(model); tableView->setSortingEnabled(sortingEnabled); if (sortingEnabled) { tableView->sortByColumn(FindColumn(model, modelSortColumn)); } tableView->verticalHeader()->hide(); tableView->setAlternatingRowColors(true); tableView->verticalHeader()->setDefaultSectionSize(15); tableView->resizeColumnsToContents(); tableView->horizontalHeader()->setStretchLastSection(true); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setSelectionMode(QAbstractItemView::SingleSelection); tableView->setFocusPolicy(Qt::StrongFocus); // enable mouse tracking tableView->setMouseTracking(true); tableView->viewport()->setMouseTracking(true); tableView->installEventFilter(this); tableView->viewport()->installEventFilter(this); return tableView; }
ErrorListView::ErrorListView(QWidget* parent) : QWidget(parent), m_model(0) { m_model = new ErrorListModel(this); QTableView* tableView = new QTableView; tableView->setItemDelegate(new ItemDelegate); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setAlternatingRowColors(true); tableView->setShowGrid(false); tableView->verticalHeader()->hide(); tableView->setModel(m_model); #ifdef STROMX_STUDIO_QT4 tableView->horizontalHeader()->setResizeMode(ErrorListModel::TIME, QHeaderView::Interactive); tableView->horizontalHeader()->setResizeMode(ErrorListModel::DESCRIPTION, QHeaderView::Stretch); #else tableView->horizontalHeader()->setSectionResizeMode(ErrorListModel::TIME, QHeaderView::Interactive); tableView->horizontalHeader()->setSectionResizeMode(ErrorListModel::DESCRIPTION, QHeaderView::Stretch); #endif // STROMX_STUDIO_QT4 QPushButton* clearButton = new QPushButton(tr("Clear error log")); connect(clearButton, SIGNAL(clicked()), m_model, SLOT(clear())); QHBoxLayout* buttonLayout = new QHBoxLayout; buttonLayout->addWidget(clearButton); buttonLayout->addStretch(); QVBoxLayout* mainLayout = new QVBoxLayout; mainLayout->addWidget(tableView); mainLayout->addLayout(buttonLayout); setLayout(mainLayout); }
void availableRoomsWindow::initializeTable() { qDebug() << Q_FUNC_INFO; QTableView* tableView = ui->tableView; tableView->setModel(parameters->availableRoomsMdl); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setAlternatingRowColors(true); tableView->setSelectionMode(QAbstractItemView::SingleSelection); tableView->horizontalHeader()->setHighlightSections(false); tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); tableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setSectionResizeMode(5, QHeaderView::ResizeToContents); tableView->hideColumn(1); tableView->hideColumn(6); tableView->hideColumn(7); tableView->hideColumn(8); tableView->hideColumn(9); tableView->hideColumn(10); tableView->hideColumn(11); tableView->hideColumn(12); tableView->hideColumn(13); tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); ui->tableView->verticalHeader()->setDefaultSectionSize(23); }
void ReceiveCoinsDialog::setModel(WalletModel *model) { this->model = model; if(model && model->getOptionsModel()) { model->getRecentRequestsTableModel()->sort(RecentRequestsTableModel::Date, Qt::DescendingOrder); connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); connect(ui->recentRequestsView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(on_recentRequestsView_selectionChanged(QItemSelection, QItemSelection))); updateDisplayUnit(); QTableView* tableView = ui->recentRequestsView; tableView->verticalHeader()->hide(); tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); tableView->setModel(model->getRecentRequestsTableModel()); tableView->setAlternatingRowColors(true); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setSelectionMode(QAbstractItemView::ContiguousSelection); tableView->setColumnWidth(RecentRequestsTableModel::Date, DATE_COLUMN_WIDTH); tableView->setColumnWidth(RecentRequestsTableModel::Label, LABEL_COLUMN_WIDTH); //(last 2 columns are set when the table geometry is ready) by the columnResizingFixer. columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH); }
void AddressWidget::setupTabs() { QStringList groups; groups << "ABC" << "DEF" << "GHI" << "JKL" << "MNO" << "PQR" << "STU" << "VW" << "XYZ"; for (int i = 0; i < groups.size(); ++i) { QString str = groups.at(i); proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(table); proxyModel->setDynamicSortFilter(true); QTableView *tableView = new QTableView; tableView->setModel(proxyModel); tableView->setSortingEnabled(true); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->horizontalHeader()->setStretchLastSection(true); tableView->verticalHeader()->hide(); tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); tableView->setSelectionMode(QAbstractItemView::SingleSelection); QString newStr = QString("^[%1].*").arg(str); proxyModel->setFilterRegExp(QRegExp(newStr, Qt::CaseInsensitive)); proxyModel->setFilterKeyColumn(0); proxyModel->sort(0, Qt::AscendingOrder); connect(tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SIGNAL(selectionChanged(QItemSelection))); addTab(tableView, str); } }
CPropertiesDialog::CPropertiesDialog( QWidget *pwidgetParent, HODBCINSTPROPERTY hFirstProperty ) : QDialog( pwidgetParent ) { QVBoxLayout * playout = new QVBoxLayout; QTableView * ptableview = new QTableView; QFrame * pframe = new QFrame; QDialogButtonBox * pdialogbuttonbox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok | QDialogButtonBox::Help ); pframe->setFrameStyle( QFrame::HLine ); ppropertiesmodel = new CPropertiesModel( 0, hFirstProperty ); ppropertiesdelegate = new CPropertiesDelegate; ptableview->setModel( ppropertiesmodel ); ptableview->setItemDelegateForColumn ( 1, ppropertiesdelegate ); ptableview->verticalHeader()->hide(); connect( pdialogbuttonbox, SIGNAL(accepted()), this, SLOT(accept()) ); connect( pdialogbuttonbox, SIGNAL(rejected()), this, SLOT(reject()) ); playout->addWidget( ptableview, 10 ); playout->addWidget( pframe ); playout->addWidget( pdialogbuttonbox ); setWindowIcon( QPixmap( xpmODBC ) ); setLayout( playout ); doLoadState(); }
void KinectCalibration::init(QTableView &kinectCalibrationTableView) { if (mongo_helper_->is_connected() == false) { return; } if (ros::master::check()) { initialising_ = true; CheckBoxDelegate *checkbox_delegate = new CheckBoxDelegate(&kinectCalibrationTableView); kinectCalibrationTableView.setItemDelegateForColumn(0, checkbox_delegate); std::vector<struct NodeRowData> gridData; Query query; query.sort("node.row"); std::unique_ptr<DBClientCursor> cursor = mongo_helper_->find("KinectCalibrationFunction", query); while (cursor->more()) { BSONElement node = cursor->next()["node"]; NodeRowData nodeRowData; if (node["selected"].ok()) node["selected"].Val(nodeRowData.selected); else nodeRowData.selected = false; if (node["friendlyName"].ok()) node["friendlyName"].Val(nodeRowData.friendlyName); if (node["nodePath"].ok()) node["nodePath"].Val(nodeRowData.nodePath); nodeRowData.running = false; gridData.push_back(nodeRowData); } kinect_calibration_table_model_ = std::make_shared<NodeTableModel>(this, mongo_helper_, &gridData); kinectCalibrationTableView.setModel(kinect_calibration_table_model_.get()); kinectCalibrationTableView.setColumnWidth(0, 100); kinectCalibrationTableView.setColumnWidth(1, 300); kinectCalibrationTableView.horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); //kinectCalibrationTableView.setSelectionBehavior(QAbstractItemView::SelectRows); //kinectCalibrationTableView.setAutoFillBackground(true); kinectCalibrationTableView.verticalHeader()->setMovable(true); kinectCalibrationTableView.show(); initialising_ = false; } }
AboutPluginsDialog::AboutPluginsDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) { QLayout *layout = nullptr; QVBoxLayout *vbox = new QVBoxLayout(this); { QTableView *toolView = new QTableView(this); toolView->setShowGrid(false); toolView->setSelectionBehavior(QAbstractItemView::SelectRows); toolView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); toolView->verticalHeader()->hide(); toolView->setModel(ObjectBroker::model(QStringLiteral("com.kdab.GammaRay.ToolPluginModel"))); QGroupBox *toolBox = new QGroupBox(tr("Loaded Plugins"), this); layout = new QHBoxLayout(toolBox); layout->addWidget(toolView); vbox->addWidget(toolBox); } { QTableView *errorView = new QTableView(this); errorView->setShowGrid(false); errorView->setSelectionBehavior(QAbstractItemView::SelectRows); errorView->setModel(ObjectBroker::model(QStringLiteral( "com.kdab.GammaRay.ToolPluginErrorModel"))); errorView->verticalHeader()->hide(); errorView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); QGroupBox *errorBox = new QGroupBox(tr("Failed Plugins"), this); layout = new QHBoxLayout(errorBox); layout->addWidget(errorView); vbox->addWidget(errorBox); } setWindowTitle(tr("GammaRay: Plugin Info")); }
void MainWindow::setRightView() { QTableView *view = ui->m_rightTableInfo; view->setModel(m_dirsContentsModel); view->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); view->horizontalHeader()->resizeSection(0, 280); // 'Name' section. User can resize view->horizontalHeader()->resizeSection(3, 130); // 'Type' section connect(view, SIGNAL(activated(QModelIndex)), view, SLOT(clearSelection())); // NOTE: must be the first connection connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(slotSetLeftViewCurrentIndex(QModelIndex))); connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(slotActivatedOnlyDirs(QModelIndex))); connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(slotUpdateSelection(QItemSelection,QItemSelection))); }
int main(int argc, char *argv[]) { Q_INIT_RESOURCE(interview); QApplication app(argc, argv); QSplitter page; QAbstractItemModel *data = new Model(1000, 10, &page); QItemSelectionModel *selections = new QItemSelectionModel(data); QTableView *table = new QTableView; table->setModel(data); table->setSelectionModel(selections); table->horizontalHeader()->setMovable(true); table->verticalHeader()->setMovable(true); // Set StaticContents to enable minimal repaints on resizes. table->viewport()->setAttribute(Qt::WA_StaticContents); page.addWidget(table); QTreeView *tree = new QTreeView; tree->setModel(data); tree->setSelectionModel(selections); tree->setUniformRowHeights(true); tree->header()->setStretchLastSection(false); tree->viewport()->setAttribute(Qt::WA_StaticContents); // Disable the focus rect to get minimal repaints when scrolling on Mac. tree->setAttribute(Qt::WA_MacShowFocusRect, false); page.addWidget(tree); QListView *list = new QListView; list->setModel(data); list->setSelectionModel(selections); list->setViewMode(QListView::IconMode); list->setSelectionMode(QAbstractItemView::ExtendedSelection); list->setAlternatingRowColors(false); list->viewport()->setAttribute(Qt::WA_StaticContents); list->setAttribute(Qt::WA_MacShowFocusRect, false); page.addWidget(list); page.setWindowIcon(QPixmap(":/images/interview.png")); page.setWindowTitle("Interview"); page.show(); return app.exec(); }
void SettingsDialog::on_pbPosition_clicked() { QScopedPointer< Gui::Dialog > dialog(new Gui::Dialog(Gui::Dialog::CenterOfScreen,this)); PositionModel *model = new PositionModel(dialog.data()); QTableView *view = new QTableView(dialog.data()); QItemSelectionModel *selectionModel = new QItemSelectionModel(model,dialog.data()); dialog->setWindowTitle(tr("Set position")); QVBoxLayout *layout = new QVBoxLayout; QDialogButtonBox *dialogButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal,dialog.data()); connect(dialogButtons,SIGNAL(accepted()),dialog.data(),SLOT(accept())); connect(dialogButtons,SIGNAL(rejected()),dialog.data(),SLOT(reject())); view->setModel(model); view->setItemDelegateForColumn(0,new PositionLabelDelegate); view->setItemDelegateForColumn(1,new PositionDelegate(QApplication::palette())); view->setSelectionBehavior(QAbstractItemView::SelectRows); view->setSelectionMode(QAbstractItemView::SingleSelection); view->setSelectionModel(selectionModel); view->verticalHeader()->setVisible(false); view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); view->setEditTriggers(QAbstractItemView::NoEditTriggers); layout->addWidget(view); layout->addWidget(dialogButtons); dialog->setLayout(layout); dialog->resize(700,500); connect(dialog.data(),SIGNAL(executed()),view,SLOT(resizeColumnsToContents())); connect(dialog.data(),SIGNAL(executed()),view,SLOT(resizeRowsToContents())); selectionModel->select(model->index(pbPosition->property("wallPosition").toInt(),0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); view->scrollTo(model->index(pbPosition->property("wallPosition").toInt(),0)); if (dialog->exec() == QDialog::Accepted) { Wally::Application::Position p = static_cast<Wally::Application::Position> (selectionModel->currentIndex().row()); pbPosition->setProperty("wallPosition",static_cast<int> (p)); pbPosition->setText(positionToString(p).replace("&","&&")); settingsModified(); } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); if(!createConnection(db)) return 1; /* QSqlQueryModel * mode = new QSqlQueryModel; mode->setQuery("select prod_id, vend_name, prod_name, prod_price from products, vendors where products.vend_id = vendors.vend_id", db); mode->setHeaderData(0, Qt::Horizontal, "prod_id"); mode->setHeaderData(1, Qt::Horizontal, "vend_name"); mode->setHeaderData(2, Qt::Horizontal, "prod_name"); mode->setHeaderData(3, Qt::Horizontal, "prod_price"); */ QSqlRelationalTableModel * mode = new QSqlRelationalTableModel; mode->setTable("products"); QSqlRelation relation("vendors", "vend_id", "vend_name"); mode->setRelation(1, relation); mode->select(); mode->setHeaderData(0, Qt::Horizontal, "prod_id"); mode->setHeaderData(1, Qt::Horizontal, "vend_name"); mode->setHeaderData(2, Qt::Horizontal, "prod_name"); mode->setHeaderData(3, Qt::Horizontal, "prod_price"); QTableView * tableview = new QTableView(&w); tableview->verticalHeader()->hide(); tableview->setModel(mode); w.setCentralWidget(tableview); w.resize(600, 400); w.show(); return a.exec(); }
SongView::SongView(QAbstractGallery *gallery, QWidget *parent, Qt::WindowFlags flags) : GalleryView(parent, flags) , model(new QGalleryQueryModel(gallery)) { model->setRootType(QDocumentGallery::Audio); model->addColumn(QDocumentGallery::trackNumber); model->setHeaderData(0, Qt::Horizontal, tr("Track")); model->addColumn(QDocumentGallery::title); model->setHeaderData(1, Qt::Horizontal, tr("Title")); model->addColumn(QDocumentGallery::duration); model->setHeaderData(2, Qt::Horizontal, tr("Duration")); model->addColumn(QDocumentGallery::artist); model->setHeaderData(3, Qt::Horizontal, tr("Artist")); model->addColumn(QDocumentGallery::albumArtist); model->setHeaderData(4, Qt::Horizontal, tr("Album Artist")); model->setSortPropertyNames(QStringList() << QDocumentGallery::artist << QDocumentGallery::albumTitle << QDocumentGallery::trackNumber); QTableView *view = new QTableView; view->setShowGrid(false); view->verticalHeader()->setVisible(false); view->setSelectionBehavior(QAbstractItemView::SelectRows); view->setModel(model.data()); connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); QBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); layout->addWidget(view); setLayout(layout); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); //QListView view; QTableView view; view.setSortingEnabled(false); view.horizontalHeader()->setStretchLastSection(true); view.horizontalHeader()->setVisible(false); view.verticalHeader()->setVisible(false); MillionRows model(Q_NULLPTR); view.setModel(&model); view.setAlternatingRowColors(true); view.setStyleSheet("alternate-background-color: green;background-color: white;"); view.setItemDelegateForColumn(0, new TableStyleDelegate()); view.resizeRowsToContents(); // impact performance - force call sizeHint view.show(); return a.exec(); }
QmitkModulesDialog::QmitkModulesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) { this->setWindowTitle("MITK Modules"); QVBoxLayout* layout = new QVBoxLayout(); this->setLayout(layout); QTableView* tableView = new QTableView(this); QmitkModuleTableModel* tableModel = new QmitkModuleTableModel(tableView); QSortFilterProxyModel* sortProxyModel = new QSortFilterProxyModel(tableView); sortProxyModel->setSourceModel(tableModel); sortProxyModel->setDynamicSortFilter(true); tableView->setModel(sortProxyModel); tableView->verticalHeader()->hide(); tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setSelectionMode(QAbstractItemView::ExtendedSelection); tableView->setTextElideMode(Qt::ElideMiddle); tableView->setSortingEnabled(true); tableView->sortByColumn(0, Qt::AscendingOrder); tableView->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setResizeMode(5, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setStretchLastSection(true); tableView->horizontalHeader()->setCascadingSectionResizes(true); layout->addWidget(tableView); QDialogButtonBox* btnBox = new QDialogButtonBox(QDialogButtonBox::Close); layout->addWidget(btnBox); this->resize(800, 600); connect(btnBox, SIGNAL(rejected()), this, SLOT(reject())); }
void ReceiveCoinsDialog::setModel(WalletModel *_model) { this->model = _model; if(_model && _model->getOptionsModel()) { _model->getRecentRequestsTableModel()->sort(RecentRequestsTableModel::Date, Qt::DescendingOrder); connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); updateDisplayUnit(); QTableView* tableView = ui->recentRequestsView; tableView->verticalHeader()->hide(); tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); tableView->setModel(_model->getRecentRequestsTableModel()); tableView->setAlternatingRowColors(true); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setSelectionMode(QAbstractItemView::ContiguousSelection); tableView->setColumnWidth(RecentRequestsTableModel::Date, DATE_COLUMN_WIDTH); tableView->setColumnWidth(RecentRequestsTableModel::Label, LABEL_COLUMN_WIDTH); tableView->setColumnWidth(RecentRequestsTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH); connect(tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(recentRequestsView_selectionChanged(QItemSelection, QItemSelection))); // Last 2 columns are set by the columnResizingFixer, when the table geometry is ready. columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this); if (model->wallet().getDefaultAddressType() == OutputType::BECH32) { ui->useBech32->setCheckState(Qt::Checked); } else { ui->useBech32->setCheckState(Qt::Unchecked); } // eventually disable the main receive button if private key operations are disabled ui->receiveButton->setEnabled(!model->privateKeysDisabled()); }
void DkFileAssociationsPreference::createLayout() { QStringList fileFilters = Settings::param().app().openFilters; mModel = new QStandardItemModel(this); mModel->setObjectName("fileModel"); for (int rIdx = 1; rIdx < fileFilters.size(); rIdx++) mModel->appendRow(getItems(fileFilters.at(rIdx), checkFilter(fileFilters.at(rIdx), Settings::param().app().browseFilters), checkFilter(fileFilters.at(rIdx), Settings::param().app().registerFilters))); mModel->setHeaderData(0, Qt::Horizontal, tr("Filter")); mModel->setHeaderData(1, Qt::Horizontal, tr("Browse")); mModel->setHeaderData(2, Qt::Horizontal, tr("Register")); QTableView* filterTableView = new QTableView(this); filterTableView->setModel(mModel); filterTableView->setSelectionBehavior(QAbstractItemView::SelectRows); filterTableView->verticalHeader()->hide(); //filterTableView->horizontalHeader()->hide(); filterTableView->setShowGrid(false); filterTableView->resizeColumnsToContents(); filterTableView->resizeRowsToContents(); filterTableView->setWordWrap(false); QPushButton* openDefault = new QPushButton(tr("Set as Default Viewer"), this); openDefault->setObjectName("openDefault"); // now the final widgets QVBoxLayout* layout = new QVBoxLayout(this); layout->addWidget(filterTableView); #ifdef Q_OS_WIN layout->addWidget(openDefault); #else openDefault->hide(); #endif }
QSortFilterProxyModel * GuiTools::ModelToViewWithFilter(QAbstractItemModel *model, QAbstractItemView *view,QLineEdit* lineEdit,QSortFilterProxyModel *proxyModel) { view->reset(); if(!proxyModel) proxyModel = new QSortFilterProxyModel((QObject*)lineEdit); proxyModel->setSourceModel(model); view->setModel(proxyModel); //view->horizontalHeader()->setResizeMode(QHeaderView::Stretch); QTableView* tableView = dynamic_cast<QTableView*>(view); if(tableView) { tableView->horizontalHeader()->setStretchLastSection(true); tableView->resizeColumnsToContents(); tableView->resizeRowsToContents(); tableView->setSortingEnabled(true); tableView->verticalHeader()->hide(); } QTreeView* treeView = dynamic_cast<QTreeView*>(view); if(treeView) { for(int i=0;i<model->columnCount();i++) treeView->resizeColumnToContents(i); treeView->setSortingEnabled(true); } // views' filter proxyModel->setFilterKeyColumn(0); proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); connect(lineEdit,SIGNAL(textChanged(const QString&)), proxyModel,SLOT(setFilterWildcard(const QString&)),Qt::AutoConnection); return proxyModel; }
bool DatabaseHandler::getSpeciesList(QString type, QComboBox * cmb_box) { qDebug() << "Populating species list for " << type; QString qstr = "SELECT name_de, name_lat, euring_id, length FROM taxa LEFT JOIN " "(SELECT id_code, to_char(avg(length), 'FM99.99') as length FROM census WHERE tp='%1' GROUP BY id_code) as lt ON taxa.euring_id = lt.id_code " "WHERE type='%1' ORDER BY seaflag DESC, name_de"; QSqlQueryModel * model = new QSqlQueryModel; model->setQuery(qstr.arg(type)); qDebug() << qstr.arg(type); model->setHeaderData(0, Qt::Horizontal, "Deutscher Name"); model->setHeaderData(1, Qt::Horizontal, "Wissenschaftlicher Name"); model->setHeaderData(2, Qt::Horizontal, "EURING Code"); model->setHeaderData(3, Qt::Horizontal, QString::fromUtf8("Länge")); cmb_box->setModel(model); QTableView * view = new QTableView; cmb_box->setView(view); view->verticalHeader()->hide(); view->hideColumn(2); view->resizeColumnsToContents(); view->setSelectionMode(QAbstractItemView::SingleSelection); view->setSelectionBehavior(QAbstractItemView::SelectRows); view->setMinimumWidth(view->horizontalHeader()->length()); return true; }
void PrintLayout::printTable() { struct dive *dive; int done = 0; // percents done int i, row = 0, progress, total = estimateTotalDives(); if (!total) return; // create and setup a table QTableView table; table.setAttribute(Qt::WA_DontShowOnScreen); table.setSelectionMode(QAbstractItemView::NoSelection); table.setFocusPolicy(Qt::NoFocus); table.horizontalHeader()->setVisible(false); table.verticalHeader()->setVisible(false); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) table.horizontalHeader()->setResizeMode(QHeaderView::Fixed); table.verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); #else table.horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); table.verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); #endif table.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); table.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // fit table to one page initially table.resize(scaledPageW, scaledPageH); // don't show border table.setStyleSheet( "QTableView { border: none }"); // create and fill a table model TablePrintModel model; addTablePrintHeadingRow(&model, row); // add one heading row row++; progress = 0; for_each_dive(i, dive) { if (!dive->selected && printOptions->print_selected) continue; addTablePrintDataRow(&model, row, dive); row++; progress++; emit signalProgress((progress * 10) / total); } done = 10; table.setModel(&model); // set model to table // resize columns to percentages from page width int accW = 0; int cols = model.columns; int tableW = table.width(); for (i = 0; i < model.columns; i++) { int pw = qCeil((qreal)(tablePrintColumnWidths.at(i) * table.width()) / 100.0); accW += pw; if (i == cols - 1 && accW > tableW) /* adjust last column */ pw -= accW - tableW; table.horizontalHeader()->resizeSection(i, pw); } // reset the model at this point model.callReset(); // a list of vertical offsets where pages begin and some helpers QList<unsigned int> pageIndexes; pageIndexes.append(0); /* the algorithm bellow processes the table rows in multiple passes, * compensating for loss of space due to moving rows on a new page instead * of truncating them. * there is a 'passes' array defining how much percents of the total * progress each will take. given, the first and last stage of this function * use 10% each, then the sum of passes[] here should be 80%. * two should be enough! */ const int passes[] = { 70, 10 }; int tableHeight = 0, lastAccIndex = 0, rowH, accH, headings; bool isHeading = false; for (unsigned int pass = 0; pass < sizeof(passes) / sizeof(passes[0]); pass++) { progress = headings = accH = 0; total = model.rows - lastAccIndex; for (i = lastAccIndex; i < model.rows; i++) { rowH = table.rowHeight(i); accH += rowH; if (isHeading) { headings += rowH; isHeading = false; } if (accH > scaledPageH) { lastAccIndex = i; pageIndexes.append(pageIndexes.last() + (accH - rowH)); addTablePrintHeadingRow(&model, i); isHeading = true; accH = 0; i--; } tableHeight += table.rowHeight(i); progress++; emit signalProgress(done + (progress * passes[pass]) / total); } done += passes[pass]; } done = 90; pageIndexes.append(pageIndexes.last() + accH + headings); table.resize(scaledPageW, tableHeight); // attach a painter and render pages by using pageIndexes QPainter painter(printer); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.scale(scaleX, scaleY); total = pageIndexes.size() - 1; progress = 0; for (i = 0; i < total; i++) { if (i > 0) printer->newPage(); QRegion region(0, pageIndexes.at(i) - 1, table.width(), pageIndexes.at(i + 1) - pageIndexes.at(i) + 1); table.render(&painter, QPoint(0, 0), region); progress++; emit signalProgress(done + (progress * 10) / total); } }
int main(int argc, char *argv[]) { QApplication app(argc, argv); // ![0] QStandardItemModel model(0, 1); populateListModel(&model); // ![0] QWidget toplevel; QVBoxLayout *layout = new QVBoxLayout(&toplevel); // ![1] QMaemo5ValueButton *button1 = new QMaemo5ValueButton("Value besides text"); button1->setValueLayout(QMaemo5ValueButton::ValueBesideText); QMaemo5ListPickSelector *selector1 = new QMaemo5ListPickSelector; selector1->setModel(&model); // not setting the current index means that the value is empty. button1->setPickSelector(selector1); // ![1] // ![2] QStandardItemModel tableModel(0, 0); populateTableModel(&tableModel); // ![2] // ![3] QMaemo5ValueButton *button2 = new QMaemo5ValueButton("Value under text"); button2->setValueLayout(QMaemo5ValueButton::ValueUnderText); QMaemo5ListPickSelector *selector2 = new QMaemo5ListPickSelector; selector2->setModel(&tableModel); selector2->setModelColumn(2); selector2->setCurrentIndex(5); button2->setPickSelector(selector2); // ![3] // create a custom view we want a table view instead of a list QTableView *view = new QTableView(); view->setEditTriggers(QAbstractItemView::NoEditTriggers); // try to get a sensible column width and row height view->setModel(&tableModel); // set the model in order to get correct column widths view->resizeColumnsToContents(); view->resizeRowsToContents(); view->horizontalHeader()->setStretchLastSection(true); view->verticalHeader()->setVisible(false); view->horizontalHeader()->setVisible(false); view->setSelectionBehavior(QAbstractItemView::SelectRows); view->setSelectionMode(QAbstractItemView::SingleSelection); // five rows should be visible as a default if (view->verticalHeader()->sectionSize(0)>0) view->setMinimumHeight(view->verticalHeader()->sectionSize(0) * 5); QMaemo5ValueButton *button3 = new QMaemo5ValueButton("Value centered under text"); button3->setValueLayout(QMaemo5ValueButton::ValueUnderTextCentered); QMaemo5ListPickSelector *selector3 = new QMaemo5ListPickSelector; selector3->setModel(&tableModel); selector3->setModelColumn(2); selector3->setView(view); // set our new custom view selector3->setCurrentIndex(0); button3->setPickSelector(selector3); layout->addWidget(button1); layout->addWidget(button2); layout->addWidget(button3); toplevel.show(); return app.exec(); }
void PrintLayout::printTable() { // create and setup a table QTableView table; table.setAttribute(Qt::WA_DontShowOnScreen); table.setSelectionMode(QAbstractItemView::NoSelection); table.setFocusPolicy(Qt::NoFocus); table.horizontalHeader()->setVisible(false); table.horizontalHeader()->setResizeMode(QHeaderView::Fixed); table.verticalHeader()->setVisible(false); table.verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); table.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); table.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // fit table to one page initially table.resize(scaledPageW, scaledPageH); // create and fill a table model TablePrintModel model; struct dive *dive; int i, row = 0; addTablePrintHeadingRow(&model, row); // add one heading row row++; for_each_dive(i, dive) { if (!dive->selected && printOptions->print_selected) continue; addTablePrintDataRow(&model, row, dive); row++; } table.setModel(&model); // set model to table // resize columns to percentages from page width for (int i = 0; i < model.columns; i++) { int pw = qCeil((qreal)(tablePrintColumnWidths.at(i) * table.width()) / 100); table.horizontalHeader()->resizeSection(i, pw); } // reset the model at this point model.callReset(); // a list of vertical offsets where pages begin and some helpers QList<unsigned int> pageIndexes; pageIndexes.append(0); int tableHeight = 0, rowH = 0, accH = 0; // process all rows for (int i = 0; i < model.rows; i++) { rowH = table.rowHeight(i); accH += rowH; if (accH > scaledPageH) { // push a new page index and add a heading pageIndexes.append(pageIndexes.last() + (accH - rowH)); addTablePrintHeadingRow(&model, i); accH = 0; i--; } tableHeight += rowH; } pageIndexes.append(pageIndexes.last() + accH); // resize the whole widget so that it can be rendered table.resize(scaledPageW, tableHeight); // attach a painter and render pages by using pageIndexes QPainter painter(printer); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.scale(scaleX, scaleY); for (int i = 0; i < pageIndexes.size() - 1; i++) { if (i > 0) printer->newPage(); QRegion region(0, pageIndexes.at(i) - 1, table.width(), pageIndexes.at(i + 1) - pageIndexes.at(i) + 2); table.render(&painter, QPoint(0, 0), region); } }
FenetreGraphique::FenetreGraphique(QWidget* parent): QWidget(parent){ //Fentre principale this->setWindowTitle(QString("Project Calendar")); //setFixedSize(1200,800); setFixedSize(900,600); //qApp->setStyleSheet("QTableView{border:1px solid red;}"); //Onglets saisie et affichage onglets = new QTabWidget(this); //onglets->setGeometry(10,10,1180,780); onglets->setGeometry(10,10,980,540); pageSaisie = new QWidget; pageAffichage = new QWidget; pageExport = new QWidget; //Page Saisie////////////////////////////////////////////////////////////////////////////////////////////// layoutPageSaisiePrincipal = new QHBoxLayout; //GroupBox selectionprojet + treeview layoutProjetTV = new QVBoxLayout; gBProjetTV = new QGroupBox(this); gBProjetTV->setTitle("Projets"); gBProjetTV->setFixedWidth(300); //onglets creation projet, tache, event supportOngletsCreation = new QWidget; ongletsNiveau2 = new QTabWidget(supportOngletsCreation); ongletsNiveau2->setGeometry(0,10,540,420); //ongletsNiveau2->setGeometry(0,10,840,720); pageCreationprojet = new QWidget; pageTacheUnitaire = new QWidget; pageTacheComposite = new QWidget; initialisationTabPTUTC(); //Liste des projets bNouveauProjet = new QPushButton("Nouveau projet"); menuDeroulantProjets = new QComboBox; initialisationMenuProjet(); //Treeview modelTreeView = new QStandardItemModel; vueTreeView = new QTreeView; vueTreeView->setModel(modelTreeView); vueTreeView->setHeaderHidden(true); vueTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers); //creation projets layoutCreationProjet1 = new QHBoxLayout; layoutCreationProjet2 = new QHBoxLayout; layoutCreationProjet3 = new QHBoxLayout; layoutCreationProjet4 = new QHBoxLayout; layoutCreationProjet5 = new QHBoxLayout; layoutCreationProjet = new QVBoxLayout; labelNomProjet = new QLabel("Nom du projet :"); nomProjet = new QLabel(""); labelProjetDateDispo = new QLabel("Date de disponibilité : "); projetDateDispo = new QLabel(""); labelProjetEcheance = new QLabel("Echéance du projet :"); projetEcheance = new QLabel(""); bCreerTacheUProjet = new QPushButton("Creer tache unitaire"); bCreerTacheCProjet = new QPushButton("Creer tache composite"); bModifierProjet = new QPushButton("Modifier le projet"); bdetruireProjet = new QPushButton("Supprimer"); //creation tache layoutCreationTache1 = new QHBoxLayout; layoutCreationTache2 = new QHBoxLayout; layoutCreationTache3 = new QHBoxLayout; layoutCreationTache4 = new QHBoxLayout; layoutCreationTache5 = new QHBoxLayout; layoutCreationTache6 = new QHBoxLayout; layoutCreationTache7 = new QHBoxLayout; layoutCreationTache8 = new QHBoxLayout; layoutCreationTache = new QVBoxLayout; //Fenetre TacheUnitaire labelIdentificateurTache = new QLabel("Identificateur de la tache : "); identificateurTache = new QLabel(""); preemptiveTache = new QCheckBox("Preemptive"); preemptiveTache->setDisabled(true); titreTacheLabel = new QLabel("Titre de la tache :"); titreTache = new QLabel(""); labelTacheEtat = new QLabel("Etat :"); tacheEtat = new QLabel(""); labelDisponibiliteTache = new QLabel("Date de disponibilité :"); disponibiliteTache = new QLabel(""); labelTacheEcheance = new QLabel("Date d'écheance :"); tacheEcheance = new QLabel(""); labelTacheDuree = new QLabel("Durée :"); tacheDuree = new QLabel(""); labelPrecedenceTacheU = new QLabel("Tâches précédentes"); modelePrecedenceTacheU = new QStringListModel(QStringList("")); vuePrecedenceTacheU = new QListView; vuePrecedenceTacheU->setModel(modelePrecedenceTacheU); vuePrecedenceTacheU->setEditTriggers(QAbstractItemView::NoEditTriggers); bModifierTacheU = new QPushButton("Modifier"); bSupprimerTacheU = new QPushButton("Supprimer"); //creation Event layoutCreationEvent1 = new QHBoxLayout; layoutCreationEvent2 = new QHBoxLayout; layoutCreationEvent3 = new QHBoxLayout; layoutCreationEvent4 = new QHBoxLayout; layoutCreationEvent5 = new QHBoxLayout; layoutCreationEvent6 = new QHBoxLayout; layoutCreationEvent7 = new QHBoxLayout; layoutCreationEvent8 = new QHBoxLayout; layoutCreationEvent9 = new QHBoxLayout; layoutCreationEvent = new QVBoxLayout; //Fenetre Tache Composite labelIdentificateurTacheC = new QLabel("Identificateur de la tache : "); identificateurTacheC = new QLabel(""); titreTacheLabelC = new QLabel("Titre de la tache"); titreTacheC = new QLabel(""); labelTacheEtatC = new QLabel("Etat :"); tacheEtatC = new QLabel(""); labelDisponibiliteTacheC = new QLabel("Date de disponibilité :"); disponibiliteTacheC = new QLabel(""); labelTacheCEcheance = new QLabel("Date d'écheance :"); tacheCEcheance = new QLabel(""); labelTacheCDuree = new QLabel("Durée totale:"); tacheCDuree = new QLabel(""); labelPrecedenceTacheC = new QLabel("Tâches précédentes"); modelePrecedenceTacheC = new QStringListModel(QStringList("")); vuePrecedenceTacheC = new QListView; vuePrecedenceTacheC->setModel(modelePrecedenceTacheC); vuePrecedenceTacheC->setEditTriggers(QAbstractItemView::NoEditTriggers); bTacheCCreerTacheU = new QPushButton("Creer sous tâche unitaire"); bTacheCCreerTacheC = new QPushButton("Creer sous tâche composite"); bModifierTacheC = new QPushButton("Modifier"); bSupprimerTacheC = new QPushButton("Supprimer"); //Imbrication projets + treeview layoutProjetTV->addWidget(bNouveauProjet); layoutProjetTV->addWidget(menuDeroulantProjets); layoutProjetTV->addWidget(vueTreeView); gBProjetTV->setLayout(layoutProjetTV); //imbrication onglet creation projet layoutCreationProjet1->addWidget(labelNomProjet); layoutCreationProjet1->addWidget(nomProjet); layoutCreationProjet2->addWidget(labelProjetDateDispo); layoutCreationProjet2->addWidget(projetDateDispo); layoutCreationProjet3->addWidget(labelProjetEcheance); layoutCreationProjet3->addWidget(projetEcheance); layoutCreationProjet4->addWidget(bCreerTacheUProjet); layoutCreationProjet4->addWidget(bCreerTacheCProjet); layoutCreationProjet5->addWidget(bModifierProjet); layoutCreationProjet5->addWidget(bdetruireProjet); layoutCreationProjet->addLayout(layoutCreationProjet1); layoutCreationProjet->addLayout(layoutCreationProjet2); layoutCreationProjet->addLayout(layoutCreationProjet3); layoutCreationProjet->addLayout(layoutCreationProjet4); layoutCreationProjet->addLayout(layoutCreationProjet5); pageCreationprojet->setLayout(layoutCreationProjet); //imbrication creation tache layoutCreationTache1->addWidget(labelIdentificateurTache); layoutCreationTache1->addWidget(identificateurTache); layoutCreationTache1->addWidget(preemptiveTache); layoutCreationTache2->addWidget(titreTacheLabel); layoutCreationTache2->addWidget(titreTache); layoutCreationTache3->addWidget(labelTacheEtat); layoutCreationTache3->addWidget(tacheEtat); layoutCreationTache4->addWidget(labelDisponibiliteTache); layoutCreationTache4->addWidget(disponibiliteTache); layoutCreationTache5->addWidget(labelTacheEcheance); layoutCreationTache5->addWidget(tacheEcheance); layoutCreationTache6->addWidget(labelTacheDuree); layoutCreationTache6->addWidget(tacheDuree); layoutCreationTache7->addWidget(labelPrecedenceTacheU); layoutCreationTache7->addWidget(vuePrecedenceTacheU); layoutCreationTache8->addWidget(bModifierTacheU); layoutCreationTache8->addWidget(bSupprimerTacheU); layoutCreationTache->addLayout(layoutCreationTache1); layoutCreationTache->addLayout(layoutCreationTache2); layoutCreationTache->addLayout(layoutCreationTache3); layoutCreationTache->addLayout(layoutCreationTache4); layoutCreationTache->addLayout(layoutCreationTache5); layoutCreationTache->addLayout(layoutCreationTache6); layoutCreationTache->addLayout(layoutCreationTache7); layoutCreationTache->addLayout(layoutCreationTache8); pageTacheUnitaire->setLayout(layoutCreationTache); //imbrication creation Event layoutCreationEvent1->addWidget(labelIdentificateurTacheC); layoutCreationEvent1->addWidget(identificateurTacheC); layoutCreationEvent2->addWidget(titreTacheLabelC); layoutCreationEvent2->addWidget(titreTacheC); layoutCreationEvent3->addWidget(labelTacheEtatC); layoutCreationEvent3->addWidget(tacheEtatC); layoutCreationEvent4->addWidget(labelDisponibiliteTacheC); layoutCreationEvent4->addWidget(disponibiliteTacheC); layoutCreationEvent5->addWidget(labelTacheCEcheance); layoutCreationEvent5->addWidget(tacheCEcheance); layoutCreationEvent6->addWidget(labelTacheCDuree); layoutCreationEvent6->addWidget(tacheCDuree); layoutCreationEvent7->addWidget(labelPrecedenceTacheC); layoutCreationEvent7->addWidget(vuePrecedenceTacheC); layoutCreationEvent8->addWidget(bTacheCCreerTacheU); layoutCreationEvent8->addWidget(bTacheCCreerTacheC); layoutCreationEvent9->addWidget(bModifierTacheC); layoutCreationEvent9->addWidget(bSupprimerTacheC); layoutCreationEvent->addLayout(layoutCreationEvent1); layoutCreationEvent->addLayout(layoutCreationEvent2); layoutCreationEvent->addLayout(layoutCreationEvent3); layoutCreationEvent->addLayout(layoutCreationEvent4); layoutCreationEvent->addLayout(layoutCreationEvent5); layoutCreationEvent->addLayout(layoutCreationEvent6); layoutCreationEvent->addLayout(layoutCreationEvent7); layoutCreationEvent->addLayout(layoutCreationEvent8); layoutCreationEvent->addLayout(layoutCreationEvent9); pageTacheComposite->setLayout(layoutCreationEvent); //imbrication onglets niveau2 + layout principal pageSaisie ongletsNiveau2->addTab(pageCreationprojet, "Projet"); ongletsNiveau2->addTab(pageTacheUnitaire, "Tâche unitaire"); ongletsNiveau2->addTab(pageTacheComposite, "Tâche composite"); layoutPageSaisiePrincipal->addWidget(gBProjetTV); layoutPageSaisiePrincipal->addWidget(supportOngletsCreation); //page Affichage///////////////////////////////////////////////////////////////////////////////////////////////////// layoutPageAffichagePrincipal = new QVBoxLayout; //En tete (gestion semaine suivante/precedente layoutHautAgenda = new QHBoxLayout; dateReferenceAgenda = new QDate(QDate::currentDate()); jourActuel = new QPushButton(constructionMessageSemaineAgenda(dateReferenceAgenda)); jourActuel->setEnabled(false); bSemainePrecedente = new QPushButton("Semaine precedent"); bSemaineSuivante = new QPushButton("Semaine suivant"); layoutHautAgenda->addWidget(bSemainePrecedente); layoutHautAgenda->addWidget(jourActuel); layoutHautAgenda->addWidget(bSemaineSuivante); QStandardItemModel *modelAgenda = new QStandardItemModel(60, 7); QTableView *vueAgenda = new QTableView; vueAgenda->setEditTriggers(QAbstractItemView::NoEditTriggers); vueAgenda->setModel(modelAgenda); vueAgenda->setFixedWidth(1157); vueAgenda->setFixedHeight(625); vueAgenda->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); vueAgenda->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); vueAgenda->setSelectionMode(QAbstractItemView::SingleSelection); //=========== vueAgenda->setGridStyle(Qt::DashDotLine); miseAJourTableau(*modelAgenda); //, *vueAgenda); itemCol0 = new QStandardItem(chaineJoursHeader(1, dateReferenceAgenda->addDays(1-dateReferenceAgenda->dayOfWeek()).day(), dateReferenceAgenda->month())); itemCol1 = new QStandardItem(chaineJoursHeader(2, dateReferenceAgenda->addDays(2-dateReferenceAgenda->dayOfWeek()).day(), dateReferenceAgenda->month())); itemCol2 = new QStandardItem(chaineJoursHeader(3, dateReferenceAgenda->addDays(3-dateReferenceAgenda->dayOfWeek()).day(), dateReferenceAgenda->month())); itemCol3 = new QStandardItem(chaineJoursHeader(4, dateReferenceAgenda->addDays(4-dateReferenceAgenda->dayOfWeek()).day(), dateReferenceAgenda->month())); itemCol4 = new QStandardItem(chaineJoursHeader(5, dateReferenceAgenda->addDays(5-dateReferenceAgenda->dayOfWeek()).day(), dateReferenceAgenda->month())); itemCol5 = new QStandardItem(chaineJoursHeader(6, dateReferenceAgenda->addDays(6-dateReferenceAgenda->dayOfWeek()).day(), dateReferenceAgenda->month())); itemCol6 = new QStandardItem(chaineJoursHeader(7, dateReferenceAgenda->addDays(7-dateReferenceAgenda->dayOfWeek()).day(), dateReferenceAgenda->month())); modelAgenda->setHorizontalHeaderItem(0, itemCol0); modelAgenda->setHorizontalHeaderItem(1, itemCol1); modelAgenda->setHorizontalHeaderItem(2, itemCol2); modelAgenda->setHorizontalHeaderItem(3, itemCol3); modelAgenda->setHorizontalHeaderItem(4, itemCol4); modelAgenda->setHorizontalHeaderItem(5, itemCol5); modelAgenda->setHorizontalHeaderItem(6, itemCol6); QStringList headerVTableau; for(unsigned int i=7; i<22; i++) { headerVTableau << QString::number(i)+"h00"; for(unsigned int j=1; j<4; j++) { headerVTableau << ""; //headerVTableau << QString::number(j*15); } } modelAgenda->setVerticalHeaderLabels(headerVTableau); miseEnFormeLigneColonnes(vueAgenda); //bas de page (programmation) layoutProgrammation = new QHBoxLayout; bProgrammerTache = new QPushButton("Programmer tâche"); bProgrammerEvt = new QPushButton("Programmer Evenement"); bSupprimerProgrammation = new QPushButton("Supprimer programmation"); layoutProgrammation->addWidget(bProgrammerTache); layoutProgrammation->addWidget(bProgrammerEvt); layoutProgrammation->addWidget(bSupprimerProgrammation); //pose des layouts pageAffichage layoutPageAffichagePrincipal->addLayout(layoutHautAgenda); layoutPageAffichagePrincipal->addWidget(vueAgenda); layoutPageAffichagePrincipal->addLayout(layoutProgrammation); //pageExport///////////////////////////////////////////////////////////////////////////////////////////////////// layoutPageExportPrincipal = new QHBoxLayout; widgetSecondairePageExport = new QWidget; widgetSecondairePageExport->setFixedSize(400, 300); layoutPageExportSecondaire = new QVBoxLayout(widgetSecondairePageExport); labelExport = new QLabel("Chosir le type d'export:"); nomFichierExport = new QLineEdit("NomFichier"); bExportImport = new QPushButton("Importer"); bExportImport->setEnabled(false); bExportProgrammationBrut = new QPushButton("Programmation totale (brut)"); bExportProgrammationXml = new QPushButton("Programmation totale (Xml"); bExportSemaineBrut = new QPushButton("Programmation semaine (brut)"); bExportSemaineXml = new QPushButton("Programmation semaine (Xml)"); //pose des layout page export layoutPageExportSecondaire->addWidget(labelExport); layoutPageExportSecondaire->addWidget(nomFichierExport); layoutPageExportSecondaire->addWidget(bExportImport); layoutPageExportSecondaire->addWidget(bExportProgrammationBrut); layoutPageExportSecondaire->addWidget(bExportProgrammationXml); layoutPageExportSecondaire->addWidget(bExportSemaineBrut); layoutPageExportSecondaire->addWidget(bExportSemaineXml); layoutPageExportPrincipal->addWidget(widgetSecondairePageExport); //pose des layouts principaux pageAffichage->setLayout(layoutPageAffichagePrincipal); pageSaisie->setLayout(layoutPageSaisiePrincipal); pageExport->setLayout(layoutPageExportPrincipal); onglets->addTab(pageAffichage, "Agenda"); onglets->addTab(pageSaisie, "Gestionnaire de projet"); onglets->addTab(pageExport, "Exports"); //connections page saisie------------- QObject::connect(vueAgenda, SIGNAL(doubleClicked(const QModelIndex)), this, SLOT(affichageContenuCase(const QModelIndex))); QObject::connect(bSemainePrecedente, SIGNAL(clicked()), this, SLOT(semainePrecedente())); QObject::connect(bSemaineSuivante, SIGNAL(clicked()), this, SLOT(semaineSuivante())); QObject::connect(bProgrammerTache, SIGNAL(clicked()), this, SLOT(nouvelleProgrammationTache())); QObject::connect(bProgrammerEvt, SIGNAL(clicked()), this, SLOT(nouvelleProgrammationEvt())); QObject::connect(bSupprimerProgrammation, SIGNAL(clicked()), this, SLOT(supprimerProgrammation())); //connexions page affichage---------- //tree view QObject::connect(menuDeroulantProjets, SIGNAL(currentIndexChanged(int)), this, SLOT(changerProjetTreeView(int))); QObject::connect(vueTreeView, SIGNAL(clicked(const QModelIndex)), this, SLOT(selectionTreeView(const QModelIndex))); //Creation projet, tache, evenement QObject::connect(bNouveauProjet, SIGNAL(clicked()), this, SLOT(creerProjet())); QObject::connect(bCreerTacheUProjet, SIGNAL(clicked()), this, SLOT(creerTacheUProjet())); QObject::connect(bCreerTacheCProjet, SIGNAL(clicked()), this, SLOT(creerTacheCProjet())); QObject::connect(bModifierProjet, SIGNAL(clicked()), this, SLOT(modifierProjet())); QObject::connect(bdetruireProjet, SIGNAL(clicked()), this, SLOT(detruireProjet())); QObject::connect(bModifierTacheU, SIGNAL(clicked()), this, SLOT(modifierTacheU())); QObject::connect(bSupprimerTacheU, SIGNAL(clicked()), this, SLOT(supprimerTacheU())); QObject::connect(bTacheCCreerTacheU, SIGNAL(clicked()), this, SLOT(creerTacheUTacheC())); QObject::connect(bTacheCCreerTacheC, SIGNAL(clicked()), this, SLOT(creerTacheCTacheC())); QObject::connect(bModifierTacheC, SIGNAL(clicked()), this, SLOT(modifierTacheC())); QObject::connect(bSupprimerTacheC, SIGNAL(clicked()), this, SLOT(supprimerTacheC())); //connexions page export-------------- QObject::connect(nomFichierExport, SIGNAL(textEdited(QString)), this, SLOT(validationNomExport(QString))); QObject::connect(bExportProgrammationBrut, SIGNAL(clicked()), this, SLOT(exportProgrammationBrut())); QObject::connect(bExportProgrammationXml, SIGNAL(clicked()), this, SLOT(exportProgrammationXml())); QObject::connect(bExportSemaineBrut, SIGNAL(clicked()), this, SLOT(exportSemaineBrut())); QObject::connect(bExportSemaineXml, SIGNAL(clicked()), this, SLOT(exportSemaineXml())); }
void KoResourceSelector::setRowHeight( int rowHeight ) { QTableView * tableView = qobject_cast<QTableView*>(view()); if (tableView) tableView->verticalHeader()->setDefaultSectionSize( rowHeight ); }
/* we create a table that has a fixed height, but can stretch to fit certain width */ QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int tableW) { // setup a new table QTableView *table = new QTableView(); QHeaderView *vHeader = table->verticalHeader(); QHeaderView *hHeader = table->horizontalHeader(); table->setAttribute(Qt::WA_DontShowOnScreen); table->setSelectionMode(QAbstractItemView::NoSelection); table->setFocusPolicy(Qt::NoFocus); table->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); table->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); hHeader->setVisible(false); vHeader->setVisible(false); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) hHeader->setResizeMode(QHeaderView::Fixed); vHeader->setResizeMode(QHeaderView::Fixed); #else hHeader->setSectionResizeMode(QHeaderView::Fixed); vHeader->setSectionResizeMode(QHeaderView::Fixed); #endif // set the model table->setModel(model); /* setup cell span for the table using QTableView::setSpan(). * changes made here reflect on ProfilePrintModel::data(). */ const int cols = model->columnCount(); const int rows = model->rowCount(); // info on top table->setSpan(0, 0, 1, 4); table->setSpan(1, 0, 1, 4); // gas used table->setSpan(2, 0, 1, 2); table->setSpan(3, 0, 1, 2); // notes table->setSpan(6, 0, 1, 5); table->setSpan(7, 0, 5, 5); /* resize row heights to the 'profilePrintRowHeights' indexes. * profilePrintTableMaxH will then hold the table height. */ int i; profilePrintTableMaxH = 0; for (i = 0; i < rows; i++) { int h = profilePrintRowHeights.at(i); profilePrintTableMaxH += h; vHeader->resizeSection(i, h); } // resize columns. columns widths are percentages from the table width. int accW = 0; for (i = 0; i < cols; i++) { int pw = qCeil((qreal)(profilePrintColumnWidths.at(i) * tableW) / 100.0); accW += pw; if (i == cols - 1 && accW > tableW) /* adjust last column */ pw -= accW - tableW; hHeader->resizeSection(i, pw); } // resize table->resize(tableW, profilePrintTableMaxH); // hide the grid and set a stylesheet table->setItemDelegate(new ProfilePrintDelegate(this)); table->setShowGrid(false); table->setStyleSheet( "QTableView { border: none }" "QTableView::item { border: 0px; padding-left: 2px; padding-right: 2px; }"); // return return table; }