void servers_widget::displayHeaderMenu(const QPoint&) { QMenu hideshowColumn(this); hideshowColumn.setTitle(tr("Column visibility")); QList<QAction*> actions; for (int i=0; i < m_smodel->columnCount(); ++i) { QAction *myAct = hideshowColumn.addAction( m_smodel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString()); myAct->setCheckable(true); myAct->setChecked(!tableServers->isColumnHidden(i)); actions.append(myAct); } // Call menu QAction *act = hideshowColumn.exec(QCursor::pos()); if (act) { int col = actions.indexOf(act); Q_ASSERT(col >= 0); tableServers->setColumnHidden(col, !tableServers->isColumnHidden(col)); if (!tableServers->isColumnHidden(col) && tableServers->columnWidth(col) <= 5) tableServers->setColumnWidth(col, 100); } }
/************************************************************************** Displays menu on header by right clicking **************************************************************************/ void plr_widget::display_header_menu(const QPoint &) { struct player_dlg_column *pcol; QMenu hideshowColumn(this); hideshowColumn.setTitle(_("Column visibility")); QList<QAction *> actions; for (int i = 0; i < list_model->columnCount(); ++i) { QAction *myAct = hideshowColumn.addAction( list_model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString()); myAct->setCheckable(true); myAct->setChecked(!isColumnHidden(i)); actions.append(myAct); } QAction *act = hideshowColumn.exec(QCursor::pos()); if (act) { int col = actions.indexOf(act); Q_ASSERT(col >= 0); pcol = &player_dlg_columns[col]; pcol->show = !pcol->show; setColumnHidden(col, !isColumnHidden(col)); if (!isColumnHidden(col) && columnWidth(col) <= 5) setColumnWidth(col, 100); } }