forked from openscad/openscad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLibraryInfoDialog.cc
59 lines (49 loc) · 1.46 KB
/
LibraryInfoDialog.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "LibraryInfoDialog.h"
#include <QString>
#include <QStringRef>
#include <QTextEdit>
#include "LibraryInfo.h"
LibraryInfoDialog::LibraryInfoDialog(const QString& rendererInfo)
{
setupUi(this);
connect(this->okButton, SIGNAL(clicked()), this, SLOT(accept()));
update_library_info(rendererInfo);
}
LibraryInfoDialog::~LibraryInfoDialog()
{
}
void LibraryInfoDialog::update_library_info(const QString& rendererInfo)
{
//Get library infos
QString info(LibraryInfo::info().c_str());
info += rendererInfo;
//Parse infos and make it html
info = info.replace("\n", "<br/>");
bool end = false;
int startIndex = 0;
while(!end)
{
int endIndex = info.indexOf(":", startIndex);
if(endIndex != -1)
{
//add bold to property name
info = info.insert(startIndex, "<b>");
endIndex += 3;
info = info.replace(endIndex, 1, ":</b>");
startIndex = info.indexOf("<br/>", endIndex);
//handle property with multiple lines
int endInd = info.indexOf(":", startIndex);
if(endInd != -1)
{
QStringRef lines(&info, startIndex, endInd - startIndex);
int lastIndex = lines.lastIndexOf("<br/>");
startIndex = lastIndex != -1 ? lastIndex+startIndex : startIndex;
}
}
else
{
end = true;
}
}
this->infoTextBox->setHtml(info);
}