void MainWindow::TrafficUpdate() { QString tempt_QT; QSettings *GlobalSettings = new QSettings("/root/.WiFiHostapdAP/WiFi_Hostapd_AP.conf",QSettings::NativeFormat); QString line; QStringList Input; QStringList Elements; int i = 0; tempt_QT = GlobalSettings->value("AP/Iface", "wlan0").toString().toLocal8Bit(); ui->TrafficTable->horizontalHeader()->setVisible(true); QFile file_to_open("/proc/net/dev"); file_to_open.open(QIODevice::ReadOnly); if(file_to_open.isOpen()) { QTextStream in(&file_to_open); line = in.read(102400); line.replace(" ", " "); line.replace(" ", " "); line.replace(" ", " "); line.replace(" ", " "); line.replace(" ", " "); line.replace(" ", " "); line.replace(" ", " "); line.replace(" ", " "); Input = line.split("\n"); line.clear(); for(i=0;i<Input.count();i++) { // Проверяем, чтобы строка не начиналась с пробела if(Input.at(i).startsWith(" ")) line = Input.at(i).mid(1, Input.at(i).length()-1); else line = Input.at(i); // проверяем, относится ли данная строка к нашему интерфейсу if(line.startsWith(tempt_QT)) { // Да, относится Elements = line.split(" "); // Меняем местами траффик GlobalTrafficInOld = GlobalTrafficIn; GlobalTrafficOutOld = GlobalTrafficOut; // Устанавливаем новый траффик GlobalTrafficIn = Elements.at(9).toLongLong(); GlobalTrafficOut = Elements.at(1).toLongLong(); } } } else { qDebug() <<"error!"; } file_to_open.close(); SetTrafficInformation(); delete GlobalSettings; }
/** * Methode qui verifie si "texte" est de la forme "Groupe" et se trouve au début de la chaine * @param texte : la chaine à vérifier * @return un Groupe construit par string */ Groupe * ChargementFormeCORGroupe::chargeExpertise(const string texte) const{ string string_to_extract; int pos = texte.find("groupe"); if ((pos == string::npos) || (pos>0)) { return NULL; } else { ifstream file_to_open(texte, ios::in); if (!file_to_open) { return NULL; } getline(file_to_open, string_to_extract); return new Groupe(string_to_extract); } }