-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform_BookWork.cpp
executable file
·125 lines (104 loc) · 4.36 KB
/
form_BookWork.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* File: form_BookWork.cpp
* Author: f10-kafedra
*
* Created on 16 Ноябрь 2011 г., 15:33
*/
//#include <QtWebKit/qwebframe.h>
#include "form_BookWork.h"
//#include "threads.h"
QString patterns[] = {
"\"FoundTextFrag\">([0-9,-]*)<",
"<b>(.*)</b>.*<b>(.*)</b>.*-\\s(.*):\\s(.*),\\s(\\d{4}).*-\\s(\\d{2,4})",
"<b>(.*)</b>.*<b>(.*)</b>.*:\\s(.*),\\s(\\d{4}).*-\\s(\\d{2,4})",
"<b>(.*)</b>.*\\[(.*)\\].*-\\s(.*):\\s(.*),\\s(\\d{4}).*-\\s(\\d{2,4})"
};
QString patterns_MGOUNB[] = {
"<entry><Авторский\\sзнак:>\\s(.*)</entry>",
"<entry><Основное\\sзаглавие:>\\s(.*)</entry>",
"<entry><Дата\\0sиздания:>\\s(.*)</entry>",
"<entry><Объем:>\\s(.*)\\sс.</entry>",
"<entry><Наименование\\sтемы\\sкак\\sпредмет>:\\s(.*)</entry>",
"<entry>(.*)</entry>"
};
form_BookWork::form_BookWork() {
formBookSearch.setupUi(this);
QIcon icon;
icon.addFile(QString::fromUtf8("images/isbn.png"), QSize(), QIcon::Normal, QIcon::Off);
this->setWindowIcon(icon);
timer = new QTimer(this);
timer->setInterval(200);
isbn = new isbnWork();
connect(formBookSearch.pbSearchByISBN, SIGNAL(clicked()), this, SLOT(slotSearchByISBN()));
connect(timer, SIGNAL(timeout()), this, SLOT(slotViewBooks()));
}
form_BookWork::~form_BookWork() {
delete isbn;
}
void form_BookWork::checkSearchStage()
{
curSearchStage stage = Stopped;
while (isbn->curStage != Stopped)
{
switch (isbn->curStage)
{
case GetInitPage:
{
// if (isbn->curStage != stage)
// {
formBookSearch.lblCurrentStage->setText("Получение начальной страницы");
// formBookSearch.pbCurrentStage->setValue(formBookSearch.pbCurrentStage->value() + 25);
// stage = isbn->curStage;
// }
break;
}
case GetManyResults:
{
// if (isbn->curStage != stage)
// {
formBookSearch.lblCurrentStage->setText("Получение результатов поиска");
// formBookSearch.pbCurrentStage->setValue(formBookSearch.pbCurrentStage->value() + 25);
// stage = isbn->curStage;
// }
break;
}
case GetFullBookInfo:
{
//int valuePlus = 50 / isbn->books.size() * 2;
formBookSearch.lblCurrentStage->setText("Получение книги");
//formBookSearch.pbCurrentStage->setValue(formBookSearch.pbCurrentStage->value() + 25);
break;
}
case GetAdditionalBookInfo:
{
//int valuePlus = 50 / isbn->books.size() * 2;
formBookSearch.lblCurrentStage->setText("Получение авторского знака");
//formBookSearch.pbCurrentStage->setValue(formBookSearch.pbCurrentStage->value() +25);
break;
}
}
}
formBookSearch.lblCurrentStage->setText("Поиск выполнен");
Thread.join();
}
void form_BookWork::slotSearchByISBN()
{
// 978-5-9518-0362-7
if (formBookSearch.leISBN->text().length() > 0)
{
formBookSearch.pbCurrentStage->setValue(0);
timer->start();
isbn->isbn = formBookSearch.leISBN->text().toStdString();
isbn->run(ISBN_SOURCE_BD_RFBookChamber);
Thread = boost::thread (boost::bind(&form_BookWork::checkSearchStage, this));
}
}
void form_BookWork::slotViewBooks()
{
if (isbn->curStage == Stopped)
{
timer->stop();
if (isbn->books.size() > 0)
formManyBooks.loadBooks(&isbn->books);
}
}