forked from peterkvt80/vbit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
specialpages.cpp
77 lines (64 loc) · 1.39 KB
/
specialpages.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
#include "specialpages.h"
using namespace vbit;
SpecialPages::SpecialPages()
{
ResetIter();
}
SpecialPages::~SpecialPages()
{
}
void SpecialPages::addPage(TTXPageStream* p)
{
_specialPagesList.push_front(p);
}
void SpecialPages::deletePage(TTXPageStream* p)
{
_specialPagesList.remove(p);
ResetIter();
}
TTXPageStream* SpecialPages::NextPage()
{
if (_page == nullptr)
{
++_iter;
_page = *_iter;
}
else
{
if (_page->IsCarousel())
{
_page->StepNextSubpageNoLoop();
if (_page->GetCarouselPage() != NULL)
{
return _page;
}
}
++_iter;
_page = *_iter;
}
if (_iter == _specialPagesList.end())
{
_page = nullptr;
}
else if (_page->IsCarousel() && _page->GetCarouselPage() == NULL)
{
_page->StepNextSubpageNoLoop(); // ensure we don't point at a null subpage
}
if (_page)
{
if (_page->GetStatusFlag()==TTXPageStream::MARKED)
{
std::cerr << "[SpecialPages::NextPage] Deleted " << _page->GetSourcePage() << std::endl;
_page->SetState(TTXPageStream::GONE);
_specialPagesList.remove(_page);
ResetIter();
return nullptr;
}
}
return _page;
}
void SpecialPages::ResetIter()
{
_iter=_specialPagesList.begin();
_page=nullptr;
}