Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Егор Галкин
DZ2_xml
Commits
91a75319
Commit
91a75319
authored
4 years ago
by
Егор Галкин
Browse files
Options
Download
Patches
Plain Diff
Add new file
parent
07366e41
master
No related merge requests found
Pipeline
#1158
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addressbookparser.cpp
+98
-0
addressbookparser.cpp
with
98 additions
and
0 deletions
+98
-0
addressbookparser.cpp
0 → 100644
+
98
−
0
View file @
91a75319
#include
"addressbookparser.h"
#include
<QMessageBox>
#include
<QTableView>
#include
<QString>
#include
<QDebug>
AddressBookParser
::
AddressBookParser
(
QTreeWidget
*
tree
,
const
QString
&
title
)
:
treeWidget
(
tree
),
currentItem
(
nullptr
),
parsing_title
(
title
)
{}
bool
AddressBookParser
::
startElement
(
const
QString
&
,
const
QString
&
,
const
QString
&
tagName
,
const
QXmlAttributes
&
)
{
if
(
tagName
==
"catalog"
)
{
currentItem
=
new
QTreeWidgetItem
(
treeWidget
);
currentItem
->
setText
(
0
,
parsing_title
);
}
else
if
(
tagName
==
"LINK"
||
tagName
==
"WebSite"
)
{
currentItem
=
new
QTreeWidgetItem
(
currentItem
);
currentItem
->
setText
(
0
,
tagName
);
}
else
currentItem
=
new
QTreeWidgetItem
(
currentItem
);
currentItem
->
setFont
(
0
,
QFont
(
"Times"
,
8
));
return
true
;
}
bool
AddressBookParser
::
characters
(
const
QString
&
strText
)
{
currentText
=
strText
;
return
true
;
}
bool
AddressBookParser
::
endElement
(
const
QString
&
,
const
QString
&
,
const
QString
&
str
)
{
if
(
str
!=
"array"
&&
str
!=
"catalog"
&&
str
!=
"LINK"
)
{
if
(
str
==
"EDU_NAME"
||
str
==
"FullName"
)
currentItem
->
parent
()
->
setText
(
0
,
currentText
);
if
(
str
==
"EDU_NAME"
||
str
==
"global_id"
||
str
==
"ID"
)
currentItem
->
setHidden
(
true
);
if
(
str
==
"YEAR"
)
{
currentItem
->
setText
(
0
,
"Учебный период"
);
currentItem
->
setText
(
1
,
currentText
);
}
else
if
(
str
==
"District"
)
{
currentItem
->
setText
(
0
,
"Район"
);
currentItem
->
setText
(
1
,
currentText
);
}
else
if
(
str
==
"PASSES_OVER_220"
)
{
currentItem
->
setText
(
0
,
"Кол-во обучающихся, набравших не менее 220 баллов за 3 экзамена"
);
currentItem
->
setText
(
1
,
currentText
);
}
else
if
(
str
==
"PASSER_UNDER_160"
)
{
currentItem
->
setText
(
0
,
"Кол-во обучающихся, набравших больше 160 баллов за 3 экзамена"
);
currentItem
->
setText
(
1
,
currentText
);
}
else
if
(
str
==
"AdmArea"
)
{
currentItem
->
setText
(
0
,
"Административный округ"
);
currentItem
->
setText
(
1
,
currentText
);
}
else
if
(
str
==
"OGE_SCORE"
)
{
currentItem
->
setText
(
0
,
"Кол-во обучающихсяб наюравших не менее 12 баллов за 3 экзамена"
);
currentItem
->
setText
(
1
,
currentText
);
}
else
{
currentItem
->
setText
(
0
,
str
);
currentItem
->
setText
(
1
,
currentText
);
}
currentItem
=
currentItem
->
parent
();
}
else
if
(
str
==
"LINK"
||
str
==
"WebSite"
)
currentItem
=
currentItem
->
parent
();
else
if
(
str
==
"array"
)
currentItem
=
currentItem
->
parent
();
return
true
;
}
bool
AddressBookParser
::
fatalError
(
const
QXmlParseException
&
exception
)
{
qDebug
()
<<
"Line:"
<<
exception
.
lineNumber
()
<<
", Column:"
<<
exception
.
columnNumber
()
<<
", Message:"
<<
exception
.
message
();
return
false
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets