-
Notifications
You must be signed in to change notification settings - Fork 0
/
unicodesubrange.cpp
52 lines (47 loc) · 1.41 KB
/
unicodesubrange.cpp
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
#include "unicodesubrange.h"
#include "ui_unicodesubrange.h"
#include <QCheckBox>
#include <QDebug>
#include <QFile>
#include <QTextStream>
UnicodeSubrange::UnicodeSubrange(QWidget *parent) :
QDialog(parent),
ui(new Ui::UnicodeSubrange)
{
ui->setupUi(this);
setAttribute(Qt::WA_QuitOnClose, false);
QStringList lines;
QFile f("Subranges.txt");
if(f.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream s(&f);
s.setCodec("UTF-8");
while(!s.atEnd())
lines.append(s.readLine());
}
for(const auto& l:lines)
{
auto cb = new QCheckBox();
cb->setText(l);
connect(cb, &QCheckBox::clicked, [this,l,cb]{
QStringList parts = l.split("\t");
parts = parts[0].split("-");
int begin, end;
begin = parts[0].toUInt(nullptr, 16);
end = parts[1].toUInt(nullptr, 16);
//qDebug() << begin <<" - " << end;
for(int i=begin; i<=end;i++)
if(cb->isChecked())
this->chars->insert(i);
else this->chars->erase(i);
QString r = "";
for(QChar c: *this->chars) r+=c;
this->lineEdit->setPlainText(r);
});
ui->scrollAreaWidgetContents->layout()->addWidget(cb);
}
}
UnicodeSubrange::~UnicodeSubrange()
{
delete ui;
}