void SessionListWidget::parseQstat(QString const& qstat) { QStringList lines = qstat.split('\n'); JobDefinition *job = NULL; QMap<QString, QString> jobSpec, jobVars; QRegExp rxJobId("[0-9]+\\.pbs01"); QRegExp rxKey("[A-Za-z_\\.]+"); QString key(""), value(""); for(QStringList::const_iterator line = lines.begin(); line != lines.end(); line++) { if(line->isEmpty()) { /* empty */ } else if(line->startsWith("Job Id:")) { if(job != NULL) { job->update(jobSpec); sessions.append(*job); delete job; job = NULL; jobSpec.clear(); jobVars.clear(); } rxJobId.indexIn(*line); job = new JobDefinition(rxJobId.cap()); } else if(line->startsWith(" ")) { /* keys start with 4 spaces */ if(key == "Variable_List") { QStringList vars(jobSpec[key].split(",")); for(QStringList::const_iterator i = vars.begin(); i != vars.end(); i++) { int eq = i->indexOf('='); jobVars.insert(i->left(eq), i->mid(eq + 1)); } } rxKey.indexIn(*line); key = rxKey.cap(0); value = line->mid(line->indexOf('=') + 2); jobSpec.insert(key, value); } else if(line->at(0) == '\t') { /* append to the previous key */ jobSpec[key].append(line->mid(1)); } } if(job) { job->update(jobSpec); sessions.append(*job); } qDebug() << sessions; }
parseResult * ChannelParser::parseSSFEStatus(QString string) { string.remove(0, 12); // strip off the first 12 characters "<junk> [sirc] " if(string.length() == 0) return new parseError("", i18n("Unable to parse status string")); //kdDebug(5008) << "String: " << string << endl; QRegExp rx("(\\S+).*\\(*([+-]*[+-\\w\\d]*)\\)*.*on (\\S+) \\((\\S+)\\)"); if(rx.search(string) == -1){ return new parseError("", i18n("Unable to parse status (no known format) string")); } QString nick = rx.cap(1); QString modes = rx.cap(2); QString chan = rx.cap(3); QString chanmode = rx.cap(4); /* * fix up modes which may have gotten the (away) part */ if(modes.contains("away")){ modes = ""; } bool away = false; if(string.contains("(away)")) away = true; if(away){ chan.prepend(i18n("Away-")); } nickListItem *nickItem = top->nicks->item( top->nicks->findNick( nick ) ); if ( nickItem ) { if(nickItem->away() != away){ nickItem->setAway( away ); top->nicks->viewport()->repaint( top->nicks->itemRect( nickItem ), false ); } nickItem->forceColour(&ksopts->ownNickColor); } top->ksircProcess()->setNick(nick); if (chanmode.findRev("t") != -1) top->channelButtons->setProtectMode(true); else top->channelButtons->setProtectMode(false); if (chanmode.findRev("m") != -1) top->channelButtons->setModerateMode(true); else top->channelButtons->setModerateMode(false); if (chanmode.findRev("n") != -1) top->channelButtons->setNooutsideMode(true); else top->channelButtons->setNooutsideMode(false); if (chanmode.findRev("i") != -1) top->channelButtons->setMenuItemMode(0, true); else top->channelButtons->setMenuItemMode(0, false); if (chanmode.findRev("s") != -1) top->channelButtons->setMenuItemMode(3, true); else top->channelButtons->setMenuItemMode(3, false); if (modes.findRev("i") != -1) top->channelButtons->setMenuItemMode(4, true); else top->channelButtons->setMenuItemMode(4, false); if (modes.findRev("w") != -1) top->channelButtons->setMenuItemMode(5, true); else top->channelButtons->setMenuItemMode(5, false); if (modes.findRev("s") != -1) top->channelButtons->setMenuItemMode(6, true); else top->channelButtons->setMenuItemMode(6, false); QString status_line = QString("%1 (%2) %3 (%4) ").arg(chan).arg(chanmode).arg(nick).arg(modes); /* * Go srearching for key and limit messages */ QRegExp rxKey("<key: (\\S+)>"); if(rxKey.search(string) >= 0){ top->channelButtons->setMenuItemMode(2, true); status_line += QString("<key: %1>").arg(rxKey.cap(1)); } else { top->channelButtons->setMenuItemMode(2, false); } QRegExp rxLimit("<limit: (\\S+)>"); if(rxLimit.search(string) >= 0){ top->channelButtons->setMenuItemMode(1, true); status_line += QString("<limit: %1>").arg(rxLimit.cap(1)); } else { top->channelButtons->setMenuItemMode(1, false); } if(ksopts->displayTopic){ if(top->topic().length() > 0) status_line += "T: " + top->topic(); else status_line += "T: " + i18n("<No Topic Set>"); } if(top->caption != status_line){ if(nick[0] == '@' || (nick[0] == '*' && nick[1] == '@')) { // If we're an op,, // update the nicks popup menu top->channelButtons->setButtonsEnabled(true); // set the buttons enabled if were an op top->opami = TRUE; } // opami = true sets us to an op else { top->channelButtons->setButtonsEnabled(false); // set the buttons enabled if were an op top->opami = FALSE; } // FALSE, were not an ops top->UserUpdateMenu(); // update the menu top->setCaption(status_line); top->setIconText(status_line); if(top->ticker) { top->ticker->setCaption(status_line); } top->caption = status_line; // Make copy so we're not // constantly changing the title bar } return new parseSucc(QString::null); // Null string, don't display anything }