//------------------------------------------------------------------------------------------------- void BachFolderBrowserTreeView::setupColumns( IniConfig & ini, const BachFolderBrowserTreeView::ColumnStructEx columns [] ) { QHeaderView * hdr = header(); int cnt = 0; QStringList labels; for( cnt=0; columns[cnt].name; ++cnt ); QVector<int> indexVec(cnt); for( int i=0; i<cnt; i++ ) { labels << QString::fromLatin1(columns[i].name); indexVec[i] = ini.readInt( columns[i].iniName + QString("Index"), columns[i].defaultPos ); } hdr->setStretchLastSection(false); for( int n=0; n<cnt; n++ ) { for( int i=0; i<cnt; i++ ) if( indexVec[i] == n ) hdr->moveSection( hdr->visualIndex(i), n ); } hdr->resizeSections(QHeaderView::Stretch); for( int n=0; n<cnt; n++ ) { int size = ini.readInt( columns[n].iniName + QString("Size"), columns[n].defaultSize ); hdr->resizeSection( n, size==0?columns[n].defaultSize:size ); } for( int n=0; n<cnt; n++ ) { bool hidden = ini.readBool( columns[n].iniName + QString("Hidden"), columns[n].defaultHidden ); hdr->setSectionHidden( n, hidden ); } hdr->setResizeMode( QHeaderView::Interactive ); }
MapPreview::MapPreview(QWidget *parent) : QDialog(parent) { QHeaderView *header; ignoreEvents = true; setupUi(this); header = twLayers->horizontalHeader(); header->setResizeMode(0, QHeaderView::Fixed); header->setResizeMode(1, QHeaderView::Stretch); header->resizeSections(QHeaderView::ResizeToContents); ignoreEvents = false; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , m_ui(new Ui::MainWindow) , m_ignoreTableSelection(false) { m_fileModel = new FileSystemModel(this); m_model = new QSortFilterProxyModel(m_fileModel); m_model->setSourceModel(m_fileModel); m_ui->setupUi(this); m_ui->m_fileTree->setModel(m_model); for (int i = 1; i < m_model->columnCount(QModelIndex()); ++i) m_ui->m_fileTree->hideColumn(i); m_ui->m_fileTable->setModel(m_model); QAbstractItemDelegate * proxyDelegate = new ProxyItemDelegate(m_ui->m_fileTable->itemDelegate(), m_ui->m_fileTable); m_ui->m_fileTable->setItemDelegate(proxyDelegate); m_ui->m_fileTable->setRootIndex(QModelIndex()); m_ui->m_fileTable->verticalHeader()->setDefaultSectionSize(18); QHeaderView * tableHeader = m_ui->m_fileTable->horizontalHeader(); tableHeader->resizeSections(QHeaderView::Interactive); QAction * resizeToContent = new QAction(QStringLiteral("Resize to content"), tableHeader); VERIFY(QObject::connect(resizeToContent, &QAction::triggered, this, &MainWindow::onResizeColumns)); tableHeader->setContextMenuPolicy(Qt::ActionsContextMenu); tableHeader->addAction(resizeToContent); VERIFY(QObject::connect(m_ui->m_rootEditor, SIGNAL(returnPressed()), this, SLOT(onRootSpecified()))); VERIFY(QObject::connect(m_ui->m_rootDlgButton, SIGNAL(clicked()), this, SLOT(onRootDialogCall()))); VERIFY(QObject::connect(m_ui->m_fileTree->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::onTreeSelectionChanged)); VERIFY(QObject::connect(m_ui->m_fileTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::onTableSelectionChanged)); QAction * regExpAction = new QAction(QStringLiteral("Set filter regexp"), this); m_ui->m_fileTable->addAction(regExpAction); m_ui->m_fileTree->addAction(regExpAction); VERIFY(QObject::connect(regExpAction, &QAction::triggered, this, &MainWindow::onSetRegExp)); LoadState(); }
int HeaderView::resizeSections(lua_State * L) // ( QHeaderView::ResizeMode mode ) { QHeaderView* obj = QtObject<QHeaderView>::check( L, 1); QHeaderView::ResizeMode f; int fInt = Util::toInt( L, 2 ); if( fInt >=0 && fInt <= 3 ) { f = (QHeaderView::ResizeMode) fInt; obj->resizeSections( f ) ; } else Lua::Util::error( L, "expecting a valid QHeaderView::ResizeMode" ); return 0; }
/*************************************************************************** Creates buttons and layouts for load page. ***************************************************************************/ void fc_client::create_load_page() { pages_layout[PAGE_LOAD] = new QGridLayout; QPushButton *but; saves_load = new QTableWidget; QStringList sav; sav << _("Choose Saved Game to Load") << _("Time"); saves_load->setRowCount (0); saves_load->setColumnCount (sav.count()); saves_load->setHorizontalHeaderLabels (sav); saves_load->setProperty("showGrid", "false"); saves_load->setProperty("selectionBehavior", "SelectRows"); saves_load->setEditTriggers(QAbstractItemView::NoEditTriggers); connect(saves_load->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(slot_selection_changed(const QItemSelection &, const QItemSelection &))); QHeaderView *header; header = saves_load->horizontalHeader(); header->resizeSections(QHeaderView::Stretch); pages_layout[PAGE_LOAD]->addWidget(saves_load, 0, 0, 1, 4); but = new QPushButton; but->setText(tr(_("Browse"))); pages_layout[PAGE_LOAD]->addWidget (but, 1, 0); but = new QPushButton; but->setText(tr(_("Cancel"))); connect(but, SIGNAL(clicked()), switch_page_mapper, SLOT(map())); switch_page_mapper->setMapping(but, PAGE_MAIN); pages_layout[PAGE_LOAD]->addWidget(but, 1, 2); but = new QPushButton; but->setText(tr(_("Load"))); pages_layout[PAGE_LOAD]->addWidget(but, 1, 3); }
/*************************************************************************** * Creates buttons and layouts for scenario page. **************************************************************************/ void fc_client::create_scenario_page() { pages_layout[PAGE_SCENARIO] = new QGridLayout; QPushButton *but; scenarios_load = new QTableWidget; scenarios_view = new QTextEdit; QStringList sav; QSpacerItem *free_space = new QSpacerItem(50, 100); sav << tr(_("Choose a Scenario")); scenarios_load->setRowCount(0); scenarios_load->setColumnCount(sav.count()); scenarios_load->setHorizontalHeaderLabels(sav); scenarios_load->setProperty("showGrid", "false"); scenarios_load->setProperty("selectionBehavior", "SelectRows"); scenarios_load->setEditTriggers(QAbstractItemView::NoEditTriggers); pages_layout[PAGE_SCENARIO]->addWidget(scenarios_load, 0, 0, 1, 2); pages_layout[PAGE_SCENARIO]->addWidget(scenarios_view, 0, 3, 1, 2); pages_layout[PAGE_SCENARIO]->addItem(free_space, 1, 0); scenarios_view->setReadOnly(true); QHeaderView *header; header = scenarios_load->horizontalHeader(); header->resizeSections(QHeaderView::ResizeToContents); but = new QPushButton; but->setText(tr(_("Browse"))); pages_layout[PAGE_SCENARIO]->addWidget (but, 2, 0); but = new QPushButton; but->setText(tr(_("Cancel"))); connect(but, SIGNAL(clicked()), switch_page_mapper, SLOT(map())); switch_page_mapper->setMapping(but, PAGE_MAIN); pages_layout[PAGE_SCENARIO]->addWidget(but, 2, 3); but = new QPushButton; but->setText(tr(_("Load"))); pages_layout[PAGE_SCENARIO]->addWidget(but, 2, 4); }
void RemoteMachineMonitorDialogImpl::resizeTreeWidget() { QHeaderView * header = machinesTreeWidget->header(); header->resizeSections( QHeaderView::ResizeToContents ); }
/*************************************************************************** Creates buttons and layouts for network page. ***************************************************************************/ void fc_client::create_network_page(void) { pages_layout[PAGE_NETWORK] = new QGridLayout; QVBoxLayout *page_network_layout = new QVBoxLayout; QGridLayout *page_network_grid_layout = new QGridLayout; QHBoxLayout *page_network_lan_layout = new QHBoxLayout; QHBoxLayout *page_network_wan_layout = new QHBoxLayout; connect_host_edit = new QLineEdit; connect_port_edit = new QLineEdit; connect_login_edit = new QLineEdit; connect_password_edit = new QLineEdit; connect_confirm_password_edit = new QLineEdit; connect_password_edit->setEchoMode(QLineEdit::Password); connect_confirm_password_edit->setEchoMode(QLineEdit::Password); connect_password_edit->setDisabled(true); connect_confirm_password_edit->setDisabled(true); connect_confirm_password_edit->setReadOnly (true); connect_tab_widget = new QTabWidget; connect_lan = new QWidget; connect_metaserver = new QWidget; lan_widget = new QTableWidget; wan_widget = new QTableWidget; info_widget = new QTableWidget; QStringList servers_list; servers_list << _("Server Name") << _("Port") << _("Version") << _("Status") << _("Players") << _("Comment"); QStringList server_info; server_info << _("Name") << _("Type") << _("Host") << _("Nation"); lan_widget->setRowCount(0); lan_widget->setColumnCount(servers_list.count()); lan_widget->verticalHeader()->setVisible(false); wan_widget->setRowCount(0); wan_widget->setColumnCount(servers_list.count()); wan_widget->verticalHeader()->setVisible(false); info_widget->setRowCount(0); info_widget->setColumnCount(server_info.count()); info_widget->verticalHeader()->setVisible(false); lan_widget->setHorizontalHeaderLabels(servers_list); lan_widget->setProperty("showGrid", "false"); lan_widget->setProperty("selectionBehavior", "SelectRows"); lan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers); connect(lan_widget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(slot_selection_changed(const QItemSelection &, const QItemSelection &))); wan_widget->setHorizontalHeaderLabels(servers_list); wan_widget->setProperty("showGrid", "false"); wan_widget->setProperty("selectionBehavior", "SelectRows"); wan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers); connect(wan_widget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(slot_selection_changed(const QItemSelection &, const QItemSelection &))); info_widget->setHorizontalHeaderLabels(server_info); info_widget->setProperty("selectionBehavior", "SelectRows"); info_widget->setEditTriggers(QAbstractItemView::NoEditTriggers); QHeaderView *header; header = lan_widget->horizontalHeader(); header->resizeSections(QHeaderView::Stretch); header = wan_widget->horizontalHeader(); header->resizeSections(QHeaderView::Stretch); QLabel *connect_msg; QStringList label_names; label_names << _("Connect") << _("Port") << _("Login") << _("Password") << _("Confirm Password"); connect_msg = new QLabel; for (int i = 0; i < label_names.count(); i++) { connect_msg = new QLabel; connect_msg->setText(label_names[i]); page_network_grid_layout->addWidget(connect_msg, i, 0, Qt::AlignHCenter); } page_network_grid_layout->addWidget(connect_host_edit, 0, 1); page_network_grid_layout->addWidget(connect_port_edit, 1, 1); page_network_grid_layout->addWidget(connect_login_edit, 2, 1); page_network_grid_layout->addWidget(connect_password_edit, 3, 1); page_network_grid_layout->addWidget(connect_confirm_password_edit, 4, 1); page_network_grid_layout->addWidget(info_widget, 0, 2, 5, 4); QPushButton *network_button = new QPushButton; network_button->setText(tr(_("&Refresh"))); QObject::connect(network_button, SIGNAL(clicked()), this, SLOT(update_network_lists())); page_network_grid_layout->addWidget(network_button, 5, 0); network_button = new QPushButton; network_button->setText(tr(_("&Cancel"))); connect(network_button, SIGNAL(clicked()), switch_page_mapper, SLOT(map())); switch_page_mapper->setMapping(network_button, PAGE_MAIN); page_network_grid_layout->addWidget(network_button, 5, 2, 1, 1); network_button = new QPushButton; network_button->setText(tr(_("&Connect"))); page_network_grid_layout->addWidget(network_button, 5, 5, 1, 1); QObject::connect(network_button, SIGNAL(clicked()), this, SLOT(slot_connect())); connect_lan->setLayout(page_network_lan_layout); connect_metaserver->setLayout(page_network_wan_layout); page_network_lan_layout->addWidget(lan_widget, 1); page_network_wan_layout->addWidget(wan_widget, 1); page_network_layout->addWidget(connect_tab_widget, 1); connect_tab_widget->addTab(connect_lan, _("LAN")); connect_tab_widget->addTab(connect_metaserver, _("NETWORK")); page_network_grid_layout->setColumnStretch(3, 4); pages_layout[PAGE_NETWORK]->addLayout(page_network_layout, 1, 1); pages_layout[PAGE_NETWORK]->addLayout(page_network_grid_layout, 2, 1); }