Browse Source

fix typo and use pre-compiled regex

master
Brad Parker 10 years ago
parent
commit
b7e05ee6ee
  1. 2
      interface.cpp
  2. 7
      wireless.cpp
  3. 1
      wireless.h

2
interface.cpp

@ -535,7 +535,7 @@ QStringList Interface::list() {
nl_socket_free(sock);
// workaround for libnl issue: https://github.com/tgraf/libnl/issues/49
// find any interfaces libnl doesn't know about (e.g. USB wireless adapters after they're been unplugged and replugged)
// find any interfaces libnl doesn't know about (e.g. USB wireless adapters after they've been unplugged and replugged)
QDir dir("/sys/class/net");
QStringList interfaces = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);

7
wireless.cpp

@ -103,6 +103,7 @@ QObject(0),
m_interface(interface),
m_interfaceType(),
m_bands(),
m_noDigitRegex("[^\\d]"),
m_isValid(false),
m_isNL80211(false),
m_iftype(NL80211_IFTYPE_UNSPECIFIED)
@ -405,8 +406,7 @@ int Wireless::ChanToFreq(int channel) {
*/
QString Wireless::ChanToFreq(QString channel, QString outputFormat) {
QString freq;
QRegularExpression re("[^\\d]");
channel = channel.replace(re, "");
channel = channel.replace(m_noDigitRegex, "");
if(outputFormat.isEmpty()) {
bool ok = false;
@ -442,8 +442,7 @@ int Wireless::FreqToChan(int frequency) {
*/
QString Wireless::FreqToChan(QString frequency, QString outputFormat) {
QString chan;
QRegularExpression re("[^\\d]");
frequency = frequency.replace(re, "");
frequency = frequency.replace(m_noDigitRegex, "");
if(frequency.length() < 4) {
for(int i = frequency.length() + 1; i <= 4; ++i) {

1
wireless.h

@ -97,6 +97,7 @@ private:
QString m_interface;
QString m_interfaceType;
QList<BandInfo> m_bands;
QRegularExpression m_noDigitRegex;
bool m_isValid;
bool m_isNL80211;
nl80211_iftype m_iftype;

Loading…
Cancel
Save