Handle conversion to text in Sysinfo::getInfo().

When saving the system info from the progresslogger it shouldn't have knowledge
about the format of the data provided by getInfo(). Instead of relying on the
output being HTML formatted make getInfo() accept a parameter that indicates if
the data is to be formatted as HTML or text.

Change-Id: I733fe1a148e51b70ea1361d8feccffd7cbccd3d7
This commit is contained in:
Dominik Riebeling 2013-11-03 11:35:41 +01:00
parent 646f74937f
commit dd0d52ee0f
3 changed files with 10 additions and 4 deletions

View file

@ -175,8 +175,7 @@ void ProgressLoggerGui::saveErrorLog()
"*********************************************\n"; "*********************************************\n";
file.write(info.toUtf8(), info.size()); file.write(info.toUtf8(), info.size());
info = Sysinfo::getInfo(); info = Sysinfo::getInfo(Sysinfo::InfoText);
info.replace(QRegExp("(<[^>]+>)+"),"\n");
file.write(info.toUtf8(), info.size()); file.write(info.toUtf8(), info.size());
// trace // trace

View file

@ -39,7 +39,7 @@ void Sysinfo::updateSysinfo(void)
ui.textBrowser->setHtml(getInfo()); ui.textBrowser->setHtml(getInfo());
} }
QString Sysinfo::getInfo() QString Sysinfo::getInfo(Sysinfo::InfoType type)
{ {
QString info; QString info;
info += tr("<b>OS</b><br/>") + System::osVersionString() + "<hr/>"; info += tr("<b>OS</b><br/>") + System::osVersionString() + "<hr/>";
@ -76,6 +76,9 @@ QString Sysinfo::getInfo()
} }
info += "</table>"; info += "</table>";
info += "<hr/>"; info += "<hr/>";
if(type == InfoText) {
info.replace(QRegExp("(<[^>]+>)+"),"\n");
}
return info; return info;
} }

View file

@ -30,9 +30,13 @@ class Sysinfo : public QDialog
Q_OBJECT Q_OBJECT
public: public:
enum InfoType {
InfoHtml,
InfoText,
};
Sysinfo(QWidget *parent = 0); Sysinfo(QWidget *parent = 0);
static QString getInfo(); static QString getInfo(InfoType type = InfoHtml);
private: private:
void changeEvent(QEvent *event); void changeEvent(QEvent *event);
Ui::SysinfoFrm ui; Ui::SysinfoFrm ui;