void HeaderViewWidget::showEvent(QShowEvent *event) { setSectionsClickable(true); setSortIndicatorShown(true); setSortIndicator(-1, Qt::AscendingOrder); QHeaderView::showEvent(event); }
QtlCheckableHeaderView::QtlCheckableHeaderView(QWidget *parent) : QHeaderView(Qt::Horizontal, parent), _checkState(Qt::Unchecked), _forceCheck(false) { // Make sure the header is clickable. setSectionsClickable(true); }
FixHeaderView::FixHeaderView(QWidget * parent): QHeaderView(Qt::Horizontal,parent) { _model = (QStandardItemModel *) model(); filterPixmap = QPixmap(":/images/filter.png").scaled(20,20); styleOption = new QStyleOptionHeader(); initStyleOption(styleOption); setSectionsClickable(true); }
EditableHeaderView::EditableHeaderView (Qt::Orientation orientation, QWidget * parent) : QHeaderView(orientation, parent) , m_lineEdit(0) , m_idx(0) { setSectionsMovable(true); setSectionsClickable(true); m_lineEdit = new QLineEdit(viewport()); m_lineEdit->setAlignment(Qt::AlignTop); m_lineEdit->setHidden(1); m_lineEdit->blockSignals(1); connect(this, SIGNAL(sectionDoubleClicked(int)), this, SLOT(onEditHeader(int))); connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(onEditingFinished())); }
TupExposureHeader::TupExposureHeader(QWidget * parent) : QHeaderView(Qt::Horizontal, parent), m_editedSection(-1), m_sectionOnMotion(false) { setSectionsClickable(true); setSectionsMovable(true); TCONFIG->beginGroup("General"); themeName = TCONFIG->value("Theme", "Light").toString(); connect(this, SIGNAL(sectionDoubleClicked(int)), this, SLOT(showTitleEditor(int))); m_editor = new QLineEdit(this); m_editor->setFocusPolicy(Qt::ClickFocus); m_editor->setInputMask(""); connect(m_editor, SIGNAL(editingFinished()), this, SLOT(hideTitleEditor())); m_editor->hide(); }
FilterTableHeader::FilterTableHeader(QTableView* parent) : QHeaderView(Qt::Horizontal, parent) { // Activate the click signals to allow sorting #if QT_VERSION >= 0x050000 setSectionsClickable(true); #else setClickable(true); #endif setSortIndicatorShown(true); // Do some connects: Basically just resize and reposition the input widgets whenever anything changes connect(this, SIGNAL(sectionResized(int,int,int)), this, SLOT(adjustPositions())); connect(parent->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(adjustPositions())); connect(parent->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(adjustPositions())); }
FilterHorizontalHeaderView::FilterHorizontalHeaderView(SortMultiFilterProxyModel *model, QTableView *parent): QHeaderView(Qt::Horizontal,parent) { //setModel(parent->model()); _model=model; setSectionsMovable(parent->horizontalHeader()->sectionsMovable()); setSectionsClickable(parent->horizontalHeader()->sectionsClickable()); insertColumns(0,model->columnCount()-1); updateWidgetPositions(); contextMenu.addAction(&saveAct); contextMenu.addAction(&clearAct); contextMenu.addSeparator(); connect(&saveAct,&QAction::triggered,this,&FilterHorizontalHeaderView::savePreset); connect(&clearAct,&QAction::triggered,this,&FilterHorizontalHeaderView::clearAllFilters); connect(parent->horizontalScrollBar(),SIGNAL(valueChanged(int)), this,SLOT(updateWidgetPositions()) ); connect(this,SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this,SLOT(setSortIndicator(int,Qt::SortOrder))); connect(this,SIGNAL(sectionResized(int,int,int)), this,SLOT(updateWidgetPositions())); connect(model,&QAbstractItemModel::columnsInserted, [=](const QModelIndex&, int logicalFirst, int logicalLast) { insertColumns(logicalFirst,logicalLast); }); timer.setInterval(300); timer.setSingleShot(true); connect(&timer,SIGNAL(timeout()),this,SLOT(applyFilters())); //TODO: add header data update //TODO: add sections removal }
ColorListWidget::ColorListWidget(Map* map, MainWindow* window, QWidget* parent) : QWidget(parent) , map(map) , window(window) { react_to_changes = true; setWhatsThis(Util::makeWhatThis("color_dock_widget.html")); // Color table color_table = new QTableWidget(map->getNumColors(), 7); color_table->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::AnyKeyPressed); color_table->setSelectionMode(QAbstractItemView::SingleSelection); color_table->setSelectionBehavior(QAbstractItemView::SelectRows); color_table->verticalHeader()->setVisible(false); color_table->setHorizontalHeaderLabels(QStringList() << QString{} << tr("Name") << tr("Spot color") << tr("CMYK") << tr("RGB") << tr("K.o.") << tr("Opacity") ); color_table->setItemDelegateForColumn(0, new ColorItemDelegate(this)); color_table->setItemDelegateForColumn(6, new PercentageDelegate(this)); color_table->setColumnHidden(6, true); auto new_button_menu = new QMenu(this); (void) new_button_menu->addAction(tr("New"), this, SLOT(newColor())); duplicate_action = new_button_menu->addAction(tr("Duplicate"), this, SLOT(duplicateColor())); duplicate_action->setIcon(QIcon(QString::fromLatin1(":/images/tool-duplicate.png"))); // Buttons auto new_button = newToolButton(QIcon(QString::fromLatin1(":/images/plus.png")), tr("New")); new_button->setPopupMode(QToolButton::DelayedPopup); // or MenuButtonPopup new_button->setMenu(new_button_menu); delete_button = newToolButton(QIcon(QString::fromLatin1(":/images/minus.png")), tr("Delete")); auto add_remove_layout = new SegmentedButtonLayout(); add_remove_layout->addWidget(new_button); add_remove_layout->addWidget(delete_button); move_up_button = newToolButton(QIcon(QString::fromLatin1(":/images/arrow-up.png")), tr("Move Up")); move_up_button->setAutoRepeat(true); move_down_button = newToolButton(QIcon(QString::fromLatin1(":/images/arrow-down.png")), tr("Move Down")); move_down_button->setAutoRepeat(true); auto up_down_layout = new SegmentedButtonLayout(); up_down_layout->addWidget(move_up_button); up_down_layout->addWidget(move_down_button); // TODO: In Mapper >= 0.6, switch to ColorWidget (or generic) translation context. edit_button = newToolButton(QIcon(QString::fromLatin1(":/images/settings.png")), QApplication::translate("OpenOrienteering::MapEditorController", "&Edit").remove(QLatin1Char('&'))); edit_button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); auto help_button = newToolButton(QIcon(QString::fromLatin1(":/images/help.png")), tr("Help")); help_button->setAutoRaise(true); // The buttons row layout auto buttons_group_layout = new QHBoxLayout(); buttons_group_layout->addLayout(add_remove_layout); buttons_group_layout->addLayout(up_down_layout); buttons_group_layout->addWidget(edit_button); buttons_group_layout->addWidget(new QLabel(QString::fromLatin1(" ")), 1); buttons_group_layout->addWidget(help_button); // The layout of all components below the table auto bottom_layout = new QVBoxLayout(); QStyleOption style_option(QStyleOption::Version, QStyleOption::SO_DockWidget); bottom_layout->setContentsMargins( style()->pixelMetric(QStyle::PM_LayoutLeftMargin, &style_option) / 2, 0, // Covered by the main layout's spacing. style()->pixelMetric(QStyle::PM_LayoutRightMargin, &style_option) / 2, style()->pixelMetric(QStyle::PM_LayoutBottomMargin, &style_option) / 2 ); bottom_layout->addLayout(buttons_group_layout); bottom_layout->addWidget(new QLabel(tr("Double-click a color value to open a dialog."))); // The main layout auto layout = new QVBoxLayout(); layout->setContentsMargins(QMargins()); layout->addWidget(color_table, 1); layout->addLayout(bottom_layout); setLayout(layout); for (int i = 0; i < map->getNumColors(); ++i) addRow(i); auto header_view = color_table->horizontalHeader(); header_view->setSectionResizeMode(QHeaderView::Interactive); header_view->resizeSections(QHeaderView::ResizeToContents); header_view->setSectionResizeMode(0, QHeaderView::Fixed); // Color header_view->resizeSection(0, 32); header_view->setSectionResizeMode(1, QHeaderView::Stretch); // Name header_view->setSectionResizeMode(1, QHeaderView::Interactive); // Spot colors header_view->setSectionResizeMode(5, QHeaderView::Fixed); // Knockout header_view->resizeSection(5, 32); header_view->setSectionsClickable(false); currentCellChange(color_table->currentRow(), 0, 0, 0); // enable / disable move color buttons // Connections connect(color_table, &QTableWidget::cellChanged, this, &ColorListWidget::cellChange); connect(color_table, &QTableWidget::currentCellChanged, this, &ColorListWidget::currentCellChange); connect(color_table, &QTableWidget::cellDoubleClicked, this, &ColorListWidget::editCurrentColor); connect(new_button, &QAbstractButton::clicked, this, &ColorListWidget::newColor); connect(delete_button, &QAbstractButton::clicked, this, &ColorListWidget::deleteColor); connect(move_up_button, &QAbstractButton::clicked, this, &ColorListWidget::moveColorUp); connect(move_down_button, &QAbstractButton::clicked, this, &ColorListWidget::moveColorDown); connect(edit_button, &QAbstractButton::clicked, this, &ColorListWidget::editCurrentColor); connect(help_button, &QAbstractButton::clicked, this, &ColorListWidget::showHelp); connect(map, &Map::colorAdded, this, &ColorListWidget::colorAdded); connect(map, &Map::colorChanged, this, &ColorListWidget::colorChanged); connect(map, &Map::colorDeleted, this, &ColorListWidget::colorDeleted); }
CheckBoxHeader::CheckBoxHeader(int checkableColumn, Qt::Orientation orientation, QWidget* parent) : QHeaderView(orientation, parent), m_column(checkableColumn), m_checked(false) { setSectionsClickable(true); connect(this, SIGNAL(sectionPressed(int)), this, SLOT(onSectionPressed(int))); }