Author: mir3x Date: Wed Dec 2 13:11:51 2015 New Revision: 30837 URL: http://svn.gna.org/viewcvs/freeciv?rev=30837&view=rev Log: Qt client network page selection was not updated when switching tabs. Fixed.
See bug #24127 Modified: branches/S2_6/client/gui-qt/fc_client.h branches/S2_6/client/gui-qt/pages.cpp Modified: branches/S2_6/client/gui-qt/fc_client.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/fc_client.h?rev=30837&r1=30836&r2=30837&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/fc_client.h (original) +++ branches/S2_6/client/gui-qt/fc_client.h Wed Dec 2 13:11:51 2015 @@ -256,6 +256,7 @@ void browse_saves(); void browse_scenarios(); void clear_status_bar(); + void network_tab_changed(int index); public slots: void switch_page(int i); Modified: branches/S2_6/client/gui-qt/pages.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/pages.cpp?rev=30837&r1=30836&r2=30837&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/pages.cpp (original) +++ branches/S2_6/client/gui-qt/pages.cpp Wed Dec 2 13:11:51 2015 @@ -284,10 +284,12 @@ lan_widget->setRowCount(0); lan_widget->setColumnCount(servers_list.count()); lan_widget->verticalHeader()->setVisible(false); + lan_widget->setAutoScroll(false); wan_widget->setRowCount(0); wan_widget->setColumnCount(servers_list.count()); wan_widget->verticalHeader()->setVisible(false); + wan_widget->setAutoScroll(false); info_widget->setRowCount(0); info_widget->setColumnCount(server_info.count()); @@ -304,6 +306,10 @@ wan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers); connect(wan_widget->selectionModel(), + SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, + SLOT(slot_selection_changed(const QItemSelection &, const QItemSelection &))); + + connect(lan_widget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(slot_selection_changed(const QItemSelection &, const QItemSelection &))); @@ -367,6 +373,8 @@ page_network_layout->addWidget(connect_tab_widget, 1); connect_tab_widget->addTab(connect_lan, _("LAN")); connect_tab_widget->addTab(connect_metaserver, _("NETWORK")); + connect(connect_tab_widget, SIGNAL(currentChanged(int)), + this, SLOT(network_tab_changed(int))); 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); @@ -711,6 +719,8 @@ QTableWidget* sel = NULL; QString host, portstr; int port; + int row; + int old_row_count; switch (sstype) { case SERVER_SCAN_LOCAL: @@ -734,12 +744,14 @@ host = connect_host_edit->text(); portstr = connect_port_edit->text(); port = portstr.toInt(); + old_row_count = sel->rowCount(); sel->clearContents(); - sel->setRowCount(0); - int row = 0; + row = 0; server_list_iterate(list, pserver) { char buf[20]; - sel->insertRow(row); + if (old_row_count <= row) { + sel->insertRow(row); + } if (pserver->humans >= 0) { fc_snprintf(buf, sizeof(buf), "%d", pserver->humans); @@ -776,7 +788,6 @@ default: break; } - sel->setItem(row, col, item); } @@ -786,8 +797,14 @@ row++; } server_list_iterate_end; -} - + + /* Remove unneeded rows, if there are any */ + while (old_row_count - row > 0) { + sel->removeRow(old_row_count - 1); + old_row_count--; + } + +} /************************************************************************** Callback function for when there's an error in the server scan. @@ -811,6 +828,25 @@ } } +/*************************************************************************** + Tab in network page has been changed. + Force current selection change to emit signal. +***************************************************************************/ +void fc_client::network_tab_changed(int index) +{ + QWidget *w; + QHBoxLayout *l; + QTableWidget *tw; + int i; + + w = connect_tab_widget->currentWidget(); + l = qobject_cast<QHBoxLayout *>(w->layout()); + tw = qobject_cast<QTableWidget *>(l->itemAt(0)->widget()); + i = tw->currentRow(); + tw->clearSelection(); + tw->selectRow(i); +} + /************************************************************************** Free the server scans. **************************************************************************/ @@ -961,6 +997,9 @@ QStringList sl; QModelIndex index; QTableWidgetItem *item; + QWidget *w; + QHBoxLayout *l; + QTableWidget *tw; QVariant qvar; int k, col, n; client_pages i = current_page(); @@ -978,6 +1017,13 @@ index = indexes.at(1); connect_port_edit->setText(index.data().toString()); + w = connect_tab_widget->currentWidget(); + l = qobject_cast<QHBoxLayout *>(w->layout()); + tw = qobject_cast<QTableWidget *>(l->itemAt(0)->widget()); + + if (tw == lan_widget) { + return; + } srvrs = server_scan_get_list(meta_scan); if (!holding_srv_list_mutex) { fc_allocate_mutex(&srvrs->mutex); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits