|
24 | 24 |
|
25 | 25 | #include "connectdlg.h" |
26 | 26 |
|
| 27 | +#if QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 ) |
| 28 | +# include <QAccessible> |
| 29 | +# include <QAccessibleAnnouncementEvent> |
| 30 | +#endif |
| 31 | + |
27 | 32 | /* Implementation *************************************************************/ |
28 | 33 |
|
29 | 34 | // mapVersionStr - converts a version number to a sortable string |
@@ -75,22 +80,22 @@ static QString mapVersionStr ( const QString& versionStr ) |
75 | 80 | // Subclass of QTreeWidgetItem that allows LVC_VERSION to sort by the UserRole data value |
76 | 81 | CMappedTreeWidgetItem::CMappedTreeWidgetItem ( QTreeWidget* owner ) : QTreeWidgetItem ( owner ), owner ( owner ) {} |
77 | 82 |
|
78 | | -bool CMappedTreeWidgetItem::operator<( const QTreeWidgetItem& other ) const |
| 83 | +bool CMappedTreeWidgetItem::operator< ( const QTreeWidgetItem& other ) const |
79 | 84 | { |
80 | 85 | if ( !owner ) |
81 | | - return QTreeWidgetItem::operator<( other ); |
| 86 | + return QTreeWidgetItem::operator< ( other ); |
82 | 87 |
|
83 | 88 | int column = owner->sortColumn(); |
84 | 89 |
|
85 | 90 | // we only need this override for comparing server versions |
86 | 91 | if ( column != CConnectDlg::LVC_VERSION ) |
87 | | - return QTreeWidgetItem::operator<( other ); |
| 92 | + return QTreeWidgetItem::operator< ( other ); |
88 | 93 |
|
89 | 94 | QVariant lhs = data ( column, Qt::UserRole ); |
90 | 95 | QVariant rhs = other.data ( column, Qt::UserRole ); |
91 | 96 |
|
92 | 97 | if ( !lhs.isValid() || !rhs.isValid() ) |
93 | | - return QTreeWidgetItem::operator<( other ); |
| 98 | + return QTreeWidgetItem::operator< ( other ); |
94 | 99 |
|
95 | 100 | return lhs.toString() < rhs.toString(); |
96 | 101 | } |
@@ -243,6 +248,7 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR |
243 | 248 |
|
244 | 249 | // to get default return key behaviour working |
245 | 250 | QObject::connect ( lvwServers, &QTreeWidget::activated, this, &CConnectDlg::OnConnectClicked ); |
| 251 | + QObject::connect ( lvwServers, &QTreeWidget::currentItemChanged, this, &CConnectDlg::OnCurrentServerItemChanged ); |
246 | 252 |
|
247 | 253 | // line edit |
248 | 254 | QObject::connect ( edtFilter, &QLineEdit::textEdited, this, &CConnectDlg::OnFilterTextEdited ); |
@@ -567,6 +573,7 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, const CVect |
567 | 573 |
|
568 | 574 | if ( vecChanInfo[i].eCountry != QLocale::AnyCountry ) |
569 | 575 | { |
| 576 | + pNewChildListViewItem->setData ( LVC_NAME, Qt::UserRole, QLocale::countryToString ( vecChanInfo[i].eCountry ) ); |
570 | 577 | // try to load the country flag icon |
571 | 578 | QPixmap CountryFlagPixmap ( CLocale::GetCountryFlagIconsResourceReference ( vecChanInfo[i].eCountry ) ); |
572 | 579 |
|
@@ -1106,3 +1113,30 @@ void CConnectDlg::UpdateDirectoryComboBox() |
1106 | 1113 | } |
1107 | 1114 | } |
1108 | 1115 | } |
| 1116 | + |
| 1117 | +void CConnectDlg::OnCurrentServerItemChanged ( QTreeWidgetItem* current, QTreeWidgetItem* ) |
| 1118 | +{ |
| 1119 | +#if QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 ) |
| 1120 | + if ( !current ) |
| 1121 | + return; |
| 1122 | + |
| 1123 | + QString announcement; |
| 1124 | + if ( current->parent() ) |
| 1125 | + { |
| 1126 | + // It's a client |
| 1127 | + announcement = current->text ( LVC_NAME ); |
| 1128 | + QVariant countryData = current->data ( LVC_NAME, Qt::UserRole ); |
| 1129 | + if ( countryData.isValid() ) |
| 1130 | + { |
| 1131 | + announcement += ", " + countryData.toString(); |
| 1132 | + } |
| 1133 | + } |
| 1134 | + else |
| 1135 | + { |
| 1136 | + // It's a server |
| 1137 | + announcement = current->text ( LVC_NAME ) + ", " + current->text ( LVC_CLIENTS ) + ", " + current->text ( LVC_LOCATION ) + ", " + |
| 1138 | + tr ( "Ping" ) + " " + current->text ( LVC_PING ); |
| 1139 | + } |
| 1140 | + QAccessible::updateAccessibility ( new QAccessibleAnnouncementEvent ( lvwServers, announcement ) ); |
| 1141 | +#endif |
| 1142 | +} |
0 commit comments