-rw-r--r-- | noncore/apps/opie-reader/Bkmks.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CBuffer.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CDrawBuffer.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/QTReader.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/infowin.cpp | 2 |
6 files changed, 7 insertions, 7 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp index 0cb9ea9..30d2881 100644 --- a/noncore/apps/opie-reader/Bkmks.cpp +++ b/noncore/apps/opie-reader/Bkmks.cpp | |||
@@ -1,190 +1,190 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | 2 | ||
3 | #include "Bkmks.h" | 3 | #include "Bkmks.h" |
4 | 4 | ||
5 | #include "StyleConsts.h" | 5 | #include "StyleConsts.h" |
6 | #include "Markups.h" | 6 | #include "Markups.h" |
7 | #include "my_list.h" | 7 | #include "my_list.h" |
8 | #include "version.h" | 8 | #include "version.h" |
9 | 9 | ||
10 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); | 10 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); |
11 | 11 | ||
12 | 12 | ||
13 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) | 13 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) |
14 | { | 14 | { |
15 | int len = ustrlen(_nm)+1; | 15 | int len = ustrlen(_nm)+1; |
16 | m_name = new tchar[len]; | 16 | m_name = new tchar[len]; |
17 | for (int i = 0; i < len; i++) m_name[i] = _nm[i]; | 17 | for (int i = 0; i < len; i++) m_name[i] = _nm[i]; |
18 | 18 | ||
19 | if (_anno == NULL) | 19 | if (_anno == NULL) |
20 | { | 20 | { |
21 | m_anno = new tchar[1]; | 21 | m_anno = new tchar[1]; |
22 | m_anno[0] = 0; | 22 | m_anno[0] = 0; |
23 | } | 23 | } |
24 | else | 24 | else |
25 | { | 25 | { |
26 | len = ustrlen(_anno)+1; | 26 | len = ustrlen(_anno)+1; |
27 | m_anno = new tchar[len]; | 27 | m_anno = new tchar[len]; |
28 | for (int i = 0; i < len; i++) m_anno[i] = _anno[i]; | 28 | for (int i = 0; i < len; i++) m_anno[i] = _anno[i]; |
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | Bkmk::~Bkmk() | 32 | Bkmk::~Bkmk() |
33 | { | 33 | { |
34 | if (m_name != NULL) delete [] m_name; | 34 | if (m_name != NULL) delete [] m_name; |
35 | m_name = NULL; | 35 | m_name = NULL; |
36 | if (m_anno != NULL) delete [] m_anno; | 36 | if (m_anno != NULL) delete [] m_anno; |
37 | m_anno = NULL; | 37 | m_anno = NULL; |
38 | } | 38 | } |
39 | 39 | ||
40 | Bkmk& Bkmk::operator=(const Bkmk& rhs) | 40 | Bkmk& Bkmk::operator=(const Bkmk& rhs) |
41 | { | 41 | { |
42 | if (m_name != NULL) | 42 | if (m_name != NULL) |
43 | { | 43 | { |
44 | delete [] m_name; | 44 | delete [] m_name; |
45 | m_name = NULL; | 45 | m_name = NULL; |
46 | } | 46 | } |
47 | if (m_anno != NULL) | 47 | if (m_anno != NULL) |
48 | { | 48 | { |
49 | delete [] m_anno; | 49 | delete [] m_anno; |
50 | m_anno = NULL; | 50 | m_anno = NULL; |
51 | } | 51 | } |
52 | if (rhs.m_name != NULL) | 52 | if (rhs.m_name != NULL) |
53 | { | 53 | { |
54 | int len = ustrlen(rhs.m_name)+1; | 54 | int len = ustrlen(rhs.m_name)+1; |
55 | m_name = new tchar[len]; | 55 | m_name = new tchar[len]; |
56 | for (int i = 0; i < len; i++) m_name[i] = rhs.m_name[i]; | 56 | for (int i = 0; i < len; i++) m_name[i] = rhs.m_name[i]; |
57 | } | 57 | } |
58 | else | 58 | else |
59 | m_name = NULL; | 59 | m_name = NULL; |
60 | if (rhs.m_anno != NULL) | 60 | if (rhs.m_anno != NULL) |
61 | { | 61 | { |
62 | int len = ustrlen(rhs.m_anno)+1; | 62 | int len = ustrlen(rhs.m_anno)+1; |
63 | m_anno = new tchar[len]; | 63 | m_anno = new tchar[len]; |
64 | for (int i = 0; i < len; i++) m_anno[i] = rhs.m_anno[i]; | 64 | for (int i = 0; i < len; i++) m_anno[i] = rhs.m_anno[i]; |
65 | } | 65 | } |
66 | else | 66 | else |
67 | m_anno = NULL; | 67 | m_anno = NULL; |
68 | m_position = rhs.m_position; | 68 | m_position = rhs.m_position; |
69 | return *this; | 69 | return *this; |
70 | } | 70 | } |
71 | 71 | ||
72 | bool Bkmk::operator==(const Bkmk& rhs) | 72 | bool Bkmk::operator==(const Bkmk& rhs) |
73 | { | 73 | { |
74 | return (m_position == rhs.m_position && ustrcmp(m_name,rhs.m_name) == 0); | 74 | return (m_position == rhs.m_position && ustrcmp(m_name,rhs.m_name) == 0); |
75 | } | 75 | } |
76 | 76 | ||
77 | void Bkmk::setAnno(tchar* t) | 77 | void Bkmk::setAnno(tchar* t) |
78 | { | 78 | { |
79 | if (m_anno != NULL) | 79 | if (m_anno != NULL) |
80 | { | 80 | { |
81 | delete [] m_anno; | 81 | delete [] m_anno; |
82 | m_anno = NULL; | 82 | m_anno = NULL; |
83 | } | 83 | } |
84 | if (t != NULL) | 84 | if (t != NULL) |
85 | { | 85 | { |
86 | int len = ustrlen(t)+1; | 86 | int len = ustrlen(t)+1; |
87 | m_anno = new tchar[len]; | 87 | m_anno = new tchar[len]; |
88 | for (int i = 0; i < len; i++) m_anno[i] = t[i]; | 88 | for (int i = 0; i < len; i++) m_anno[i] = t[i]; |
89 | } | 89 | } |
90 | else | 90 | else |
91 | m_anno = NULL; | 91 | m_anno = NULL; |
92 | } | 92 | } |
93 | 93 | ||
94 | BkmkFile::BkmkFile(const char *fnm, bool w = false) | 94 | BkmkFile::BkmkFile(const char *fnm, bool w ) |
95 | : | 95 | : |
96 | wt(w), isUpgraded(false) | 96 | wt(w), isUpgraded(false) |
97 | { | 97 | { |
98 | if (w) | 98 | if (w) |
99 | { | 99 | { |
100 | f = fopen(fnm, "wb"); | 100 | f = fopen(fnm, "wb"); |
101 | } | 101 | } |
102 | else | 102 | else |
103 | { | 103 | { |
104 | f = fopen(fnm, "rb"); | 104 | f = fopen(fnm, "rb"); |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | BkmkFile::~BkmkFile() | 108 | BkmkFile::~BkmkFile() |
109 | { | 109 | { |
110 | if (f != NULL) fclose(f); | 110 | if (f != NULL) fclose(f); |
111 | } | 111 | } |
112 | 112 | ||
113 | void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos) | 113 | void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos) |
114 | { | 114 | { |
115 | if (f != NULL) | 115 | if (f != NULL) |
116 | { | 116 | { |
117 | unsigned short ln = ustrlen(nm); | 117 | unsigned short ln = ustrlen(nm); |
118 | fwrite(&ln,sizeof(ln),1,f); | 118 | fwrite(&ln,sizeof(ln),1,f); |
119 | fwrite(nm,sizeof(tchar),ln,f); | 119 | fwrite(nm,sizeof(tchar),ln,f); |
120 | ln = ustrlen(an); | 120 | ln = ustrlen(an); |
121 | fwrite(&ln,sizeof(ln),1,f); | 121 | fwrite(&ln,sizeof(ln),1,f); |
122 | if (ln > 0) fwrite(an,sizeof(tchar),ln,f); | 122 | if (ln > 0) fwrite(an,sizeof(tchar),ln,f); |
123 | fwrite(&pos,sizeof(pos),1,f); | 123 | fwrite(&pos,sizeof(pos),1,f); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | void BkmkFile::write(const Bkmk& b) { write(b.name(), b.anno(), b.value()); } | 127 | void BkmkFile::write(const Bkmk& b) { write(b.name(), b.anno(), b.value()); } |
128 | 128 | ||
129 | void BkmkFile::write(CList<Bkmk>& bl) | 129 | void BkmkFile::write(CList<Bkmk>& bl) |
130 | { | 130 | { |
131 | if (f != NULL) | 131 | if (f != NULL) |
132 | { | 132 | { |
133 | fwrite(&magic, sizeof(magic), 1, f); | 133 | fwrite(&magic, sizeof(magic), 1, f); |
134 | for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) | 134 | for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) |
135 | { | 135 | { |
136 | write(*i); | 136 | write(*i); |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | Bkmk* BkmkFile::read() | 141 | Bkmk* BkmkFile::read() |
142 | { | 142 | { |
143 | Bkmk* b = NULL; | 143 | Bkmk* b = NULL; |
144 | if (f != NULL) | 144 | if (f != NULL) |
145 | { | 145 | { |
146 | unsigned short ln; | 146 | unsigned short ln; |
147 | if (fread(&ln,sizeof(ln),1,f) == 1) | 147 | if (fread(&ln,sizeof(ln),1,f) == 1) |
148 | { | 148 | { |
149 | b = new Bkmk; | 149 | b = new Bkmk; |
150 | b->m_name = new tchar[ln+1]; | 150 | b->m_name = new tchar[ln+1]; |
151 | fread(b->m_name,sizeof(tchar),ln,f); | 151 | fread(b->m_name,sizeof(tchar),ln,f); |
152 | b->m_name[ln] = 0; | 152 | b->m_name[ln] = 0; |
153 | 153 | ||
154 | fread(&ln,sizeof(ln),1,f); | 154 | fread(&ln,sizeof(ln),1,f); |
155 | b->m_anno = new tchar[ln+1]; | 155 | b->m_anno = new tchar[ln+1]; |
156 | if (ln > 0) fread(b->m_anno,sizeof(tchar),ln,f); | 156 | if (ln > 0) fread(b->m_anno,sizeof(tchar),ln,f); |
157 | b->m_anno[ln] = 0; | 157 | b->m_anno[ln] = 0; |
158 | fread(&b->m_position,sizeof(b->m_position),1,f); | 158 | fread(&b->m_position,sizeof(b->m_position),1,f); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | return b; | 161 | return b; |
162 | } | 162 | } |
163 | 163 | ||
164 | CList<Bkmk>* BkmkFile::readall() | 164 | CList<Bkmk>* BkmkFile::readall() |
165 | { | 165 | { |
166 | CList<Bkmk>* bl = NULL; | 166 | CList<Bkmk>* bl = NULL; |
167 | if (f != NULL) | 167 | if (f != NULL) |
168 | { | 168 | { |
169 | unsigned long newmagic; | 169 | unsigned long newmagic; |
170 | fread(&newmagic, sizeof(newmagic), 1, f); | 170 | fread(&newmagic, sizeof(newmagic), 1, f); |
171 | if (newmagic != magic) | 171 | if (newmagic != magic) |
172 | { | 172 | { |
173 | if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of OpieReader\ndid you upgrade from?", "0_4*", "Any other version") == 0) | 173 | if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of OpieReader\ndid you upgrade from?", "0_4*", "Any other version") == 0) |
174 | { | 174 | { |
175 | fseek(f,0,SEEK_SET); | 175 | fseek(f,0,SEEK_SET); |
176 | bl = readall04(); | 176 | bl = readall04(); |
177 | } | 177 | } |
178 | else | 178 | else |
179 | { | 179 | { |
180 | fseek(f,0,SEEK_SET); | 180 | fseek(f,0,SEEK_SET); |
181 | bl = readall03(); | 181 | bl = readall03(); |
182 | } | 182 | } |
183 | isUpgraded = true; | 183 | isUpgraded = true; |
184 | } | 184 | } |
185 | else | 185 | else |
186 | { | 186 | { |
187 | bl = readall04(); | 187 | bl = readall04(); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | return bl; | 190 | return bl; |
diff --git a/noncore/apps/opie-reader/CBuffer.cpp b/noncore/apps/opie-reader/CBuffer.cpp index 526b25f..0780a88 100644 --- a/noncore/apps/opie-reader/CBuffer.cpp +++ b/noncore/apps/opie-reader/CBuffer.cpp | |||
@@ -1,46 +1,46 @@ | |||
1 | #include "CBuffer.h" | 1 | #include "CBuffer.h" |
2 | 2 | ||
3 | CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms) | 3 | CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms) |
4 | { | 4 | { |
5 | if (ms*membersize > len) | 5 | if (ms*membersize > len) |
6 | { | 6 | { |
7 | delete [] buffer; | 7 | delete [] buffer; |
8 | buffer = new unsigned char[len = ms*membersize]; | 8 | buffer = new unsigned char[len = ms*membersize]; |
9 | } | 9 | } |
10 | memcpy(buffer, sztmp, ms*membersize); | 10 | memcpy(buffer, sztmp, ms*membersize); |
11 | return *this; | 11 | return *this; |
12 | } | 12 | } |
13 | 13 | ||
14 | CBufferBase::CBufferBase(size_t ms, size_t n = 16) : len(n), membersize(ms) | 14 | CBufferBase::CBufferBase(size_t ms, size_t n) : len(n), membersize(ms) |
15 | { | 15 | { |
16 | buffer = new unsigned char[len*membersize]; | 16 | buffer = new unsigned char[len*membersize]; |
17 | memset(buffer, 0, len*membersize); | 17 | memset(buffer, 0, len*membersize); |
18 | } | 18 | } |
19 | 19 | ||
20 | void* CBufferBase::operator[](int i) | 20 | void* CBufferBase::operator[](int i) |
21 | { | 21 | { |
22 | if ((i+1)*membersize > len) | 22 | if ((i+1)*membersize > len) |
23 | { | 23 | { |
24 | unsigned char* oldbuffer = buffer; | 24 | unsigned char* oldbuffer = buffer; |
25 | buffer = new unsigned char[(i+1)*membersize]; | 25 | buffer = new unsigned char[(i+1)*membersize]; |
26 | memcpy(buffer, oldbuffer, len); | 26 | memcpy(buffer, oldbuffer, len); |
27 | memset(buffer+len, 0, (i+1)*membersize-len); | 27 | memset(buffer+len, 0, (i+1)*membersize-len); |
28 | len = (i+1)*membersize; | 28 | len = (i+1)*membersize; |
29 | delete [] oldbuffer; | 29 | delete [] oldbuffer; |
30 | } | 30 | } |
31 | return buffer+i*membersize; | 31 | return buffer+i*membersize; |
32 | } | 32 | } |
33 | 33 | ||
34 | size_t CBufferBase::bstrlen(unsigned char* _buffer = NULL) | 34 | size_t CBufferBase::bstrlen(unsigned char* _buffer) |
35 | { | 35 | { |
36 | if (_buffer == NULL) _buffer = buffer; | 36 | if (_buffer == NULL) _buffer = buffer; |
37 | unsigned char* zero = new unsigned char[membersize]; | 37 | unsigned char* zero = new unsigned char[membersize]; |
38 | memset(zero,0,membersize); | 38 | memset(zero,0,membersize); |
39 | unsigned char* element = _buffer; | 39 | unsigned char* element = _buffer; |
40 | while (memcmp(element, zero, membersize) != 0) | 40 | while (memcmp(element, zero, membersize) != 0) |
41 | { | 41 | { |
42 | element += membersize; | 42 | element += membersize; |
43 | } | 43 | } |
44 | delete [] zero; | 44 | delete [] zero; |
45 | return (element - _buffer)/membersize; | 45 | return (element - _buffer)/membersize; |
46 | } | 46 | } |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp index 2ceb2d5..892456f 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.cpp +++ b/noncore/apps/opie-reader/CDrawBuffer.cpp | |||
@@ -12,193 +12,193 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | |||
12 | m_maxstyle = rhs.m_maxstyle; | 12 | m_maxstyle = rhs.m_maxstyle; |
13 | m_ascent = rhs.m_ascent; | 13 | m_ascent = rhs.m_ascent; |
14 | m_descent = rhs.m_descent; | 14 | m_descent = rhs.m_descent; |
15 | m_lineSpacing = rhs.m_lineSpacing; | 15 | m_lineSpacing = rhs.m_lineSpacing; |
16 | while (!segs.isEmpty()) segs.erase(0); | 16 | while (!segs.isEmpty()) segs.erase(0); |
17 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) | 17 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) |
18 | { | 18 | { |
19 | CList<textsegment>::iterator next = iter; | 19 | CList<textsegment>::iterator next = iter; |
20 | iter++; | 20 | iter++; |
21 | if (iter == rhs.segs.end() || iter->start > f) | 21 | if (iter == rhs.segs.end() || iter->start > f) |
22 | { | 22 | { |
23 | int st = next->start-f; | 23 | int st = next->start-f; |
24 | if (st < 0) st = 0; | 24 | if (st < 0) st = 0; |
25 | segs.push_back(textsegment(st,next->style)); | 25 | segs.push_back(textsegment(st,next->style)); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; | 28 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; |
29 | (*this)[i-f] = '\0'; | 29 | (*this)[i-f] = '\0'; |
30 | len = i; | 30 | len = i; |
31 | // qDebug("Tried 1"); | 31 | // qDebug("Tried 1"); |
32 | } | 32 | } |
33 | 33 | ||
34 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) | 34 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) |
35 | { | 35 | { |
36 | int i; | 36 | int i; |
37 | // qDebug("Trying 2"); | 37 | // qDebug("Trying 2"); |
38 | len = rhs.len; | 38 | len = rhs.len; |
39 | m_maxstyle = rhs.m_maxstyle; | 39 | m_maxstyle = rhs.m_maxstyle; |
40 | m_ascent = rhs.m_ascent; | 40 | m_ascent = rhs.m_ascent; |
41 | m_descent = rhs.m_descent; | 41 | m_descent = rhs.m_descent; |
42 | m_lineSpacing = rhs.m_lineSpacing; | 42 | m_lineSpacing = rhs.m_lineSpacing; |
43 | while (!segs.isEmpty()) segs.erase(0); | 43 | while (!segs.isEmpty()) segs.erase(0); |
44 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) | 44 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) |
45 | { | 45 | { |
46 | segs.push_back(*iter); | 46 | segs.push_back(*iter); |
47 | } | 47 | } |
48 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; | 48 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; |
49 | (*this)[i] = '\0'; | 49 | (*this)[i] = '\0'; |
50 | len = i; | 50 | len = i; |
51 | // qDebug("Tried 2"); | 51 | // qDebug("Tried 2"); |
52 | return *this; | 52 | return *this; |
53 | } | 53 | } |
54 | 54 | ||
55 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) | 55 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) |
56 | { | 56 | { |
57 | int i; | 57 | int i; |
58 | while (!segs.isEmpty()) segs.erase(0); | 58 | while (!segs.isEmpty()) segs.erase(0); |
59 | segs.push_back(textsegment(0, CStyle())); | 59 | segs.push_back(textsegment(0, CStyle())); |
60 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; | 60 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; |
61 | (*this)[i] = '\0'; | 61 | (*this)[i] = '\0'; |
62 | len = i; | 62 | len = i; |
63 | return *this; | 63 | return *this; |
64 | } | 64 | } |
65 | 65 | ||
66 | void CDrawBuffer::empty() | 66 | void CDrawBuffer::empty() |
67 | { | 67 | { |
68 | len = 0; | 68 | len = 0; |
69 | (*this)[0] = 0; | 69 | (*this)[0] = 0; |
70 | while (!segs.isEmpty()) segs.erase(0); | 70 | while (!segs.isEmpty()) segs.erase(0); |
71 | segs.push_back(textsegment(0,CStyle())); | 71 | segs.push_back(textsegment(0,CStyle())); |
72 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = 0; | 72 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) | 75 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) |
76 | { | 76 | { |
77 | if (len == 0) | 77 | if (len == 0) |
78 | { | 78 | { |
79 | int thissize = fc->getsize(_style); | 79 | int thissize = fc->getsize(_style); |
80 | m_maxstyle = thissize; | 80 | m_maxstyle = thissize; |
81 | m_ascent = fc->ascent(_style); | 81 | m_ascent = fc->ascent(_style); |
82 | m_descent = fc->descent(_style); | 82 | m_descent = fc->descent(_style); |
83 | m_lineSpacing = fc->lineSpacing(_style); | 83 | m_lineSpacing = fc->lineSpacing(_style); |
84 | segs.first().start = 0; | 84 | segs.first().start = 0; |
85 | segs.first().style = _style; | 85 | segs.first().style = _style; |
86 | } | 86 | } |
87 | else if (_style != segs.last().style) | 87 | else if (_style != segs.last().style) |
88 | { | 88 | { |
89 | int thissize = fc->getsize(_style); | 89 | int thissize = fc->getsize(_style); |
90 | if (thissize > m_maxstyle) | 90 | if (thissize > m_maxstyle) |
91 | { | 91 | { |
92 | m_maxstyle = thissize; | 92 | m_maxstyle = thissize; |
93 | m_ascent = fc->ascent(_style); | 93 | m_ascent = fc->ascent(_style); |
94 | m_descent = fc->descent(_style); | 94 | m_descent = fc->descent(_style); |
95 | m_lineSpacing = fc->lineSpacing(_style); | 95 | m_lineSpacing = fc->lineSpacing(_style); |
96 | } | 96 | } |
97 | segs.push_back(textsegment(len, _style)); | 97 | segs.push_back(textsegment(len, _style)); |
98 | } | 98 | } |
99 | (*this)[len++] = ch; | 99 | (*this)[len++] = ch; |
100 | } | 100 | } |
101 | 101 | ||
102 | void CDrawBuffer::truncate(int n) | 102 | void CDrawBuffer::truncate(int n) |
103 | { | 103 | { |
104 | len = n; | 104 | len = n; |
105 | (*this)[n] = 0; | 105 | (*this)[n] = 0; |
106 | } | 106 | } |
107 | 107 | ||
108 | int CDrawBuffer::width(int numchars = -1) | 108 | int CDrawBuffer::width(int numchars) |
109 | { | 109 | { |
110 | int currentx = 0, end = 0; | 110 | int currentx = 0, end = 0; |
111 | QString text = toQString(data()); | 111 | QString text = toQString(data()); |
112 | CList<textsegment>::iterator textstart = segs.begin(); | 112 | CList<textsegment>::iterator textstart = segs.begin(); |
113 | CList<textsegment>::iterator textend = textstart; | 113 | CList<textsegment>::iterator textend = textstart; |
114 | do | 114 | do |
115 | { | 115 | { |
116 | textend++; | 116 | textend++; |
117 | end = (textend != segs.end()) ? textend->start : length(); | 117 | end = (textend != segs.end()) ? textend->start : length(); |
118 | if (numchars >= 0 && end > numchars) | 118 | if (numchars >= 0 && end > numchars) |
119 | { | 119 | { |
120 | end = numchars; | 120 | end = numchars; |
121 | } | 121 | } |
122 | CStyle currentstyle = textstart->style; | 122 | CStyle currentstyle = textstart->style; |
123 | QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 123 | QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
124 | QString str = text.mid(textstart->start, end-textstart->start); | 124 | QString str = text.mid(textstart->start, end-textstart->start); |
125 | QFontMetrics fm(f); | 125 | QFontMetrics fm(f); |
126 | currentx += fm.width(str); | 126 | currentx += fm.width(str); |
127 | textstart = textend; | 127 | textstart = textend; |
128 | } | 128 | } |
129 | while (textend != segs.end() && end != numchars); | 129 | while (textend != segs.end() && end != numchars); |
130 | return currentx; | 130 | return currentx; |
131 | } | 131 | } |
132 | 132 | ||
133 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth) | 133 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth) |
134 | { | 134 | { |
135 | int currentx = 0; | 135 | int currentx = 0; |
136 | QString text = toQString(data()); | 136 | QString text = toQString(data()); |
137 | CList<textsegment>::iterator textstart = segs.begin(); | 137 | CList<textsegment>::iterator textstart = segs.begin(); |
138 | StyleType align = textstart->style.getJustify(); | 138 | StyleType align = textstart->style.getJustify(); |
139 | switch (align) | 139 | switch (align) |
140 | { | 140 | { |
141 | case CStyle::m_AlignRight: | 141 | case CStyle::m_AlignRight: |
142 | { | 142 | { |
143 | // int linelength = width(); | 143 | // int linelength = width(); |
144 | currentx = scwidth - width(); | 144 | currentx = scwidth - width(); |
145 | } | 145 | } |
146 | break; | 146 | break; |
147 | case CStyle::m_AlignCentre: | 147 | case CStyle::m_AlignCentre: |
148 | { | 148 | { |
149 | // int linelength = width(); | 149 | // int linelength = width(); |
150 | currentx = (scwidth - width())/2; | 150 | currentx = (scwidth - width())/2; |
151 | } | 151 | } |
152 | break; | 152 | break; |
153 | case CStyle::m_AlignJustify: | 153 | case CStyle::m_AlignJustify: |
154 | case CStyle::m_AlignLeft: | 154 | case CStyle::m_AlignLeft: |
155 | break; | 155 | break; |
156 | } | 156 | } |
157 | CList<textsegment>::iterator textend = textstart; | 157 | CList<textsegment>::iterator textend = textstart; |
158 | do | 158 | do |
159 | { | 159 | { |
160 | textend++; | 160 | textend++; |
161 | int end = (textend != segs.end()) ? textend->start : length(); | 161 | int end = (textend != segs.end()) ? textend->start : length(); |
162 | CStyle currentstyle = textstart->style; | 162 | CStyle currentstyle = textstart->style; |
163 | QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 163 | QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
164 | _p->setFont(f); | 164 | _p->setFont(f); |
165 | QString str = text.mid(textstart->start, end-textstart->start); | 165 | QString str = text.mid(textstart->start, end-textstart->start); |
166 | _p->setPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue())); | 166 | _p->setPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue())); |
167 | if (_bMono) | 167 | if (_bMono) |
168 | { | 168 | { |
169 | for (int i = 0; i < str.length(); i++) | 169 | for (int i = 0; i < str.length(); i++) |
170 | { | 170 | { |
171 | _p->drawText( currentx + i*_charWidth, _y, QString(str[i])); | 171 | _p->drawText( currentx + i*_charWidth, _y, QString(str[i])); |
172 | } | 172 | } |
173 | currentx += str.length()*_charWidth; | 173 | currentx += str.length()*_charWidth; |
174 | } | 174 | } |
175 | else | 175 | else |
176 | { | 176 | { |
177 | _p->drawText( currentx, _y, str); | 177 | _p->drawText( currentx, _y, str); |
178 | QFontMetrics fm(f); | 178 | QFontMetrics fm(f); |
179 | currentx += fm.width(str); | 179 | currentx += fm.width(str); |
180 | } | 180 | } |
181 | textstart = textend; | 181 | textstart = textend; |
182 | } | 182 | } |
183 | while (textend != segs.end()); | 183 | while (textend != segs.end()); |
184 | } | 184 | } |
185 | 185 | ||
186 | CStyle CDrawBuffer::laststyle() | 186 | CStyle CDrawBuffer::laststyle() |
187 | { | 187 | { |
188 | return segs.last().style; | 188 | return segs.last().style; |
189 | } | 189 | } |
190 | 190 | ||
191 | bool CDrawBuffer::isLink(int numchars, size_t& tgt) | 191 | bool CDrawBuffer::isLink(int numchars, size_t& tgt) |
192 | { | 192 | { |
193 | int end = 0; | 193 | int end = 0; |
194 | CStyle currentstyle; | 194 | CStyle currentstyle; |
195 | CList<textsegment>::iterator textstart = segs.begin(); | 195 | CList<textsegment>::iterator textstart = segs.begin(); |
196 | CList<textsegment>::iterator textend = textstart; | 196 | CList<textsegment>::iterator textend = textstart; |
197 | do | 197 | do |
198 | { | 198 | { |
199 | textend++; | 199 | textend++; |
200 | end = (textend != segs.end()) ? textend->start : length(); | 200 | end = (textend != segs.end()) ? textend->start : length(); |
201 | if (numchars >= 0 && end > numchars) | 201 | if (numchars >= 0 && end > numchars) |
202 | { | 202 | { |
203 | end = numchars; | 203 | end = numchars; |
204 | } | 204 | } |
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index e7bfc28..7cf08e5 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp | |||
@@ -1,134 +1,134 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of an example program for Qt. This example | 6 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 7 | ** program may be used, distributed and modified without limitation. |
8 | ** | 8 | ** |
9 | *****************************************************************************/ | 9 | *****************************************************************************/ |
10 | 10 | ||
11 | #include <qpainter.h> | 11 | #include <qpainter.h> |
12 | #include "config.h" | 12 | #include "config.h" |
13 | #include "QTReader.h" | 13 | #include "QTReader.h" |
14 | #include "QTReaderApp.h" | 14 | #include "QTReaderApp.h" |
15 | #include "CDrawBuffer.h" | 15 | #include "CDrawBuffer.h" |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | #include <math.h> | 17 | #include <math.h> |
18 | #include <ctype.h> | 18 | #include <ctype.h> |
19 | #include <stdio.h> //for sprintf | 19 | #include <stdio.h> //for sprintf |
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | #include <qpe/applnk.h> | 21 | #include <qpe/applnk.h> |
22 | #include <qfontdatabase.h> | 22 | #include <qfontdatabase.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | 25 | ||
26 | #ifdef _UNICODE | 26 | #ifdef _UNICODE |
27 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; | 27 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; |
28 | #else | 28 | #else |
29 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; | 29 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; |
30 | #endif | 30 | #endif |
31 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; | 31 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; |
32 | 32 | ||
33 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; | 33 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; |
34 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; | 34 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; |
35 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; | 35 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; |
36 | //const int QTReader::fontsizes[] = {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,0}; | 36 | //const int QTReader::fontsizes[] = {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,0}; |
37 | 37 | ||
38 | QTReader::QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0) : | 38 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : |
39 | QWidget(parent, name, f), | 39 | QWidget(parent, name, f), |
40 | m_delay(100), | 40 | m_delay(100), |
41 | m_scrolldy1(0), | 41 | m_scrolldy1(0), |
42 | m_scrolldy2(0), | 42 | m_scrolldy2(0), |
43 | m_autoScroll(false), | 43 | m_autoScroll(false), |
44 | //textarray(NULL), | 44 | //textarray(NULL), |
45 | //locnarray(NULL), | 45 | //locnarray(NULL), |
46 | numlines(0), | 46 | numlines(0), |
47 | m_fontname("unifont"), | 47 | m_fontname("unifont"), |
48 | m_fm(NULL), | 48 | m_fm(NULL), |
49 | mouseUpOn(true), | 49 | mouseUpOn(true), |
50 | m_twotouch(true), | 50 | m_twotouch(true), |
51 | m_touchone(true) | 51 | m_touchone(true) |
52 | { | 52 | { |
53 | m_overlap = 1; | 53 | m_overlap = 1; |
54 | // init(); | 54 | // init(); |
55 | } | 55 | } |
56 | /* | 56 | /* |
57 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : | 57 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : |
58 | QWidget(parent, name, f), | 58 | QWidget(parent, name, f), |
59 | m_textfont(0), | 59 | m_textfont(0), |
60 | m_textsize(1), | 60 | m_textsize(1), |
61 | textarray(NULL), | 61 | textarray(NULL), |
62 | numlines(0), | 62 | numlines(0), |
63 | bstripcr(true), | 63 | bstripcr(true), |
64 | bunindent(false), | 64 | bunindent(false), |
65 | brepara(false), | 65 | brepara(false), |
66 | bdblspce(false), | 66 | bdblspce(false), |
67 | btight(false), | 67 | btight(false), |
68 | bindenter(0), | 68 | bindenter(0), |
69 | m_fm(NULL) | 69 | m_fm(NULL) |
70 | { | 70 | { |
71 | init(); | 71 | init(); |
72 | // qDebug("Load_file(1)"); | 72 | // qDebug("Load_file(1)"); |
73 | load_file((const tchar*)filename); | 73 | load_file((const tchar*)filename); |
74 | } | 74 | } |
75 | */ | 75 | */ |
76 | 76 | ||
77 | long QTReader::real_delay() | 77 | long QTReader::real_delay() |
78 | { | 78 | { |
79 | return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); | 79 | return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); |
80 | } | 80 | } |
81 | 81 | ||
82 | void QTReader::mousePressEvent( QMouseEvent* _e ) | 82 | void QTReader::mousePressEvent( QMouseEvent* _e ) |
83 | { | 83 | { |
84 | if (_e->button() == RightButton) | 84 | if (_e->button() == RightButton) |
85 | { | 85 | { |
86 | mouseUpOn = false; | 86 | mouseUpOn = false; |
87 | if (_e->y() > height()/2) | 87 | if (_e->y() > height()/2) |
88 | { | 88 | { |
89 | goDown(); | 89 | goDown(); |
90 | } | 90 | } |
91 | else | 91 | else |
92 | { | 92 | { |
93 | goUp(); | 93 | goUp(); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | bool QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) | 98 | bool QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) |
99 | { | 99 | { |
100 | int lineno = 0; | 100 | int lineno = 0; |
101 | int ht = textarray[0]->lineSpacing(); | 101 | int ht = textarray[0]->lineSpacing(); |
102 | while ((ht < y) && (lineno < numlines)) | 102 | while ((ht < y) && (lineno < numlines)) |
103 | { | 103 | { |
104 | ht += textarray[++lineno]->lineSpacing(); | 104 | ht += textarray[++lineno]->lineSpacing(); |
105 | } | 105 | } |
106 | start = locnarray[lineno]; | 106 | start = locnarray[lineno]; |
107 | if (m_bMonoSpaced) | 107 | if (m_bMonoSpaced) |
108 | { | 108 | { |
109 | offset = x/m_charWidth; | 109 | offset = x/m_charWidth; |
110 | } | 110 | } |
111 | else | 111 | else |
112 | { | 112 | { |
113 | int i; | 113 | int i; |
114 | CDrawBuffer* t = textarray[lineno]; | 114 | CDrawBuffer* t = textarray[lineno]; |
115 | for (i = t->length(); t->width(i) > x; i--); | 115 | for (i = t->length(); t->width(i) > x; i--); |
116 | offset = i; | 116 | offset = i; |
117 | } | 117 | } |
118 | return textarray[lineno]->isLink(offset, tgt); | 118 | return textarray[lineno]->isLink(offset, tgt); |
119 | } | 119 | } |
120 | 120 | ||
121 | void QTReader::setTwoTouch(bool _b) | 121 | void QTReader::setTwoTouch(bool _b) |
122 | { | 122 | { |
123 | setBackgroundColor( white ); | 123 | setBackgroundColor( white ); |
124 | m_twotouch = m_touchone = _b; | 124 | m_twotouch = m_touchone = _b; |
125 | } | 125 | } |
126 | 126 | ||
127 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | 127 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) |
128 | { | 128 | { |
129 | if (_e->button() == LeftButton) | 129 | if (_e->button() == LeftButton) |
130 | { | 130 | { |
131 | if (mouseUpOn) | 131 | if (mouseUpOn) |
132 | { | 132 | { |
133 | if (textarray[0] != NULL) | 133 | if (textarray[0] != NULL) |
134 | { | 134 | { |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index ef1f4f1..8726df7 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1616,193 +1616,193 @@ void QTReaderApp::gotobkmk(int ind) | |||
1616 | // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | 1616 | // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); |
1617 | pBkmklist->erase(ind); | 1617 | pBkmklist->erase(ind); |
1618 | m_fBkmksChanged = true; | 1618 | m_fBkmksChanged = true; |
1619 | // pBkmklist->sort(); | 1619 | // pBkmklist->sort(); |
1620 | break; | 1620 | break; |
1621 | case cRmBkmkFile: | 1621 | case cRmBkmkFile: |
1622 | unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); | 1622 | unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); |
1623 | break; | 1623 | break; |
1624 | } | 1624 | } |
1625 | showEditTools(); | 1625 | showEditTools(); |
1626 | } | 1626 | } |
1627 | 1627 | ||
1628 | void QTReaderApp::cancelbkmk() | 1628 | void QTReaderApp::cancelbkmk() |
1629 | { | 1629 | { |
1630 | showEditTools(); | 1630 | showEditTools(); |
1631 | } | 1631 | } |
1632 | 1632 | ||
1633 | void QTReaderApp::jump() | 1633 | void QTReaderApp::jump() |
1634 | { | 1634 | { |
1635 | m_nRegAction = cJump; | 1635 | m_nRegAction = cJump; |
1636 | char lcn[20]; | 1636 | char lcn[20]; |
1637 | sprintf(lcn, "%lu", reader->pagelocate()); | 1637 | sprintf(lcn, "%lu", reader->pagelocate()); |
1638 | regEdit->setText(lcn); | 1638 | regEdit->setText(lcn); |
1639 | do_regedit(); | 1639 | do_regedit(); |
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | void QTReaderApp::do_jump(const QString& lcn) | 1642 | void QTReaderApp::do_jump(const QString& lcn) |
1643 | { | 1643 | { |
1644 | bool ok; | 1644 | bool ok; |
1645 | unsigned long ulcn = lcn.toULong(&ok); | 1645 | unsigned long ulcn = lcn.toULong(&ok); |
1646 | if (ok) | 1646 | if (ok) |
1647 | reader->locate(ulcn); | 1647 | reader->locate(ulcn); |
1648 | else | 1648 | else |
1649 | QMessageBox::information(this, "OpieReader", "Must be a number"); | 1649 | QMessageBox::information(this, "OpieReader", "Must be a number"); |
1650 | } | 1650 | } |
1651 | 1651 | ||
1652 | void QTReaderApp::do_regaction() | 1652 | void QTReaderApp::do_regaction() |
1653 | { | 1653 | { |
1654 | regBar->hide(); | 1654 | regBar->hide(); |
1655 | regVisible = false; | 1655 | regVisible = false; |
1656 | switch(m_nRegAction) | 1656 | switch(m_nRegAction) |
1657 | { | 1657 | { |
1658 | case cAutoGen: | 1658 | case cAutoGen: |
1659 | do_autogen(regEdit->text()); | 1659 | do_autogen(regEdit->text()); |
1660 | break; | 1660 | break; |
1661 | case cAddBkmk: | 1661 | case cAddBkmk: |
1662 | do_addbkmk(regEdit->text()); | 1662 | do_addbkmk(regEdit->text()); |
1663 | break; | 1663 | break; |
1664 | case cJump: | 1664 | case cJump: |
1665 | do_jump(regEdit->text()); | 1665 | do_jump(regEdit->text()); |
1666 | break; | 1666 | break; |
1667 | case cMonoSpace: | 1667 | case cMonoSpace: |
1668 | do_mono(regEdit->text()); | 1668 | do_mono(regEdit->text()); |
1669 | break; | 1669 | break; |
1670 | case cOverlap: | 1670 | case cOverlap: |
1671 | do_overlap(regEdit->text()); | 1671 | do_overlap(regEdit->text()); |
1672 | break; | 1672 | break; |
1673 | case cSetTarget: | 1673 | case cSetTarget: |
1674 | do_settarget(regEdit->text()); | 1674 | do_settarget(regEdit->text()); |
1675 | break; | 1675 | break; |
1676 | } | 1676 | } |
1677 | reader->restore(); | 1677 | reader->restore(); |
1678 | // editBar->show(); | 1678 | // editBar->show(); |
1679 | reader->setFocus(); | 1679 | reader->setFocus(); |
1680 | } | 1680 | } |
1681 | 1681 | ||
1682 | void QTReaderApp::do_settarget(const QString& _txt) | 1682 | void QTReaderApp::do_settarget(const QString& _txt) |
1683 | { | 1683 | { |
1684 | int ind = _txt.find('/'); | 1684 | int ind = _txt.find('/'); |
1685 | if (ind == -1) | 1685 | if (ind == -1) |
1686 | { | 1686 | { |
1687 | m_targetapp = ""; | 1687 | m_targetapp = ""; |
1688 | m_targetmsg = ""; | 1688 | m_targetmsg = ""; |
1689 | QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename"); | 1689 | QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename"); |
1690 | } | 1690 | } |
1691 | else | 1691 | else |
1692 | { | 1692 | { |
1693 | m_targetapp = _txt.left(ind); | 1693 | m_targetapp = _txt.left(ind); |
1694 | m_targetmsg = _txt.right(_txt.length()-ind-1); | 1694 | m_targetmsg = _txt.right(_txt.length()-ind-1); |
1695 | } | 1695 | } |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | void QTReaderApp::setfont() | 1698 | void QTReaderApp::setfont() |
1699 | { | 1699 | { |
1700 | for (int i = 1; i <= m_fontSelector->count(); i++) | 1700 | for (int i = 1; i <= m_fontSelector->count(); i++) |
1701 | { | 1701 | { |
1702 | if (m_fontSelector->text(i) == reader->m_fontname) | 1702 | if (m_fontSelector->text(i) == reader->m_fontname) |
1703 | { | 1703 | { |
1704 | m_fontSelector->setCurrentItem(i); | 1704 | m_fontSelector->setCurrentItem(i); |
1705 | break; | 1705 | break; |
1706 | } | 1706 | } |
1707 | } | 1707 | } |
1708 | m_fontBar->show(); | 1708 | m_fontBar->show(); |
1709 | m_fontVisible = true; | 1709 | m_fontVisible = true; |
1710 | } | 1710 | } |
1711 | 1711 | ||
1712 | void QTReaderApp::setfontHelper(const QString& lcn, int size = 0) | 1712 | void QTReaderApp::setfontHelper(const QString& lcn, int size) |
1713 | { | 1713 | { |
1714 | if (size == 0) size = reader->m_fontControl.currentsize(); | 1714 | if (size == 0) size = reader->m_fontControl.currentsize(); |
1715 | QFont f(lcn, 10 /*, QFont::Bold*/); | 1715 | QFont f(lcn, 10 /*, QFont::Bold*/); |
1716 | bkmkselector->setFont( f ); | 1716 | bkmkselector->setFont( f ); |
1717 | regEdit->setFont( f ); | 1717 | regEdit->setFont( f ); |
1718 | searchEdit->setFont( f ); | 1718 | searchEdit->setFont( f ); |
1719 | m_annoWin->setFont( f ); | 1719 | m_annoWin->setFont( f ); |
1720 | reader->m_fontname = lcn; | 1720 | reader->m_fontname = lcn; |
1721 | if (!reader->ChangeFont(size)) | 1721 | if (!reader->ChangeFont(size)) |
1722 | { | 1722 | { |
1723 | reader->ChangeFont(size); | 1723 | reader->ChangeFont(size); |
1724 | } | 1724 | } |
1725 | reader->refresh(); | 1725 | reader->refresh(); |
1726 | m_fontBar->hide(); | 1726 | m_fontBar->hide(); |
1727 | m_fontVisible = false; | 1727 | m_fontVisible = false; |
1728 | showEditTools(); | 1728 | showEditTools(); |
1729 | } | 1729 | } |
1730 | 1730 | ||
1731 | void QTReaderApp::do_setfont(const QString& lcn) | 1731 | void QTReaderApp::do_setfont(const QString& lcn) |
1732 | { | 1732 | { |
1733 | setfontHelper(lcn); | 1733 | setfontHelper(lcn); |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | void QTReaderApp::do_autogen(const QString& regText) | 1736 | void QTReaderApp::do_autogen(const QString& regText) |
1737 | { | 1737 | { |
1738 | unsigned long fs, ts; | 1738 | unsigned long fs, ts; |
1739 | reader->sizes(fs,ts); | 1739 | reader->sizes(fs,ts); |
1740 | // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); | 1740 | // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); |
1741 | m_autogenstr = regText; | 1741 | m_autogenstr = regText; |
1742 | QRegExp re(regText); | 1742 | QRegExp re(regText); |
1743 | CBuffer buff; | 1743 | CBuffer buff; |
1744 | if (pBkmklist != NULL) delete pBkmklist; | 1744 | if (pBkmklist != NULL) delete pBkmklist; |
1745 | pBkmklist = new CList<Bkmk>; | 1745 | pBkmklist = new CList<Bkmk>; |
1746 | m_fBkmksChanged = true; | 1746 | m_fBkmksChanged = true; |
1747 | pbar->show(); | 1747 | pbar->show(); |
1748 | pbar->resize(width(), editBar->height()); | 1748 | pbar->resize(width(), editBar->height()); |
1749 | pbar->reset(); | 1749 | pbar->reset(); |
1750 | qApp->processEvents(); | 1750 | qApp->processEvents(); |
1751 | reader->setFocus(); | 1751 | reader->setFocus(); |
1752 | reader->jumpto(0); | 1752 | reader->jumpto(0); |
1753 | int lastpc = 0; | 1753 | int lastpc = 0; |
1754 | int i = 0; | 1754 | int i = 0; |
1755 | while (i >= 0) | 1755 | while (i >= 0) |
1756 | { | 1756 | { |
1757 | unsigned int lcn = reader->locate(); | 1757 | unsigned int lcn = reader->locate(); |
1758 | int pc = (100*lcn)/ts; | 1758 | int pc = (100*lcn)/ts; |
1759 | if (pc != lastpc) | 1759 | if (pc != lastpc) |
1760 | { | 1760 | { |
1761 | pbar->setProgress(pc); | 1761 | pbar->setProgress(pc); |
1762 | qApp->processEvents(); | 1762 | qApp->processEvents(); |
1763 | if (reader->locate() != lcn) reader->jumpto(lcn); | 1763 | if (reader->locate() != lcn) reader->jumpto(lcn); |
1764 | reader->setFocus(); | 1764 | reader->setFocus(); |
1765 | lastpc = pc; | 1765 | lastpc = pc; |
1766 | } | 1766 | } |
1767 | i = reader->buffdoc.getpara(buff); | 1767 | i = reader->buffdoc.getpara(buff); |
1768 | #ifdef _UNICODE | 1768 | #ifdef _UNICODE |
1769 | if (re.match(toQString(buff.data())) != -1) | 1769 | if (re.match(toQString(buff.data())) != -1) |
1770 | #else | 1770 | #else |
1771 | if (re.match(buff.data()) != -1) | 1771 | if (re.match(buff.data()) != -1) |
1772 | #endif | 1772 | #endif |
1773 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); | 1773 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
1774 | } | 1774 | } |
1775 | pBkmklist->sort(); | 1775 | pBkmklist->sort(); |
1776 | pbar->setProgress(100); | 1776 | pbar->setProgress(100); |
1777 | qApp->processEvents(); | 1777 | qApp->processEvents(); |
1778 | pbar->hide(); | 1778 | pbar->hide(); |
1779 | } | 1779 | } |
1780 | 1780 | ||
1781 | void QTReaderApp::saveprefs() | 1781 | void QTReaderApp::saveprefs() |
1782 | { | 1782 | { |
1783 | // reader->saveprefs("uqtreader"); | 1783 | // reader->saveprefs("uqtreader"); |
1784 | Config config( "uqtreader" ); | 1784 | Config config( "uqtreader" ); |
1785 | config.setGroup( "View" ); | 1785 | config.setGroup( "View" ); |
1786 | 1786 | ||
1787 | reader->m_lastposn = reader->pagelocate(); | 1787 | reader->m_lastposn = reader->pagelocate(); |
1788 | 1788 | ||
1789 | config.writeEntry( "StripCr", reader->bstripcr ); | 1789 | config.writeEntry( "StripCr", reader->bstripcr ); |
1790 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 1790 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
1791 | config.writeEntry( "TextFmt", reader->btextfmt ); | 1791 | config.writeEntry( "TextFmt", reader->btextfmt ); |
1792 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 1792 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
1793 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 1793 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
1794 | config.writeEntry( "Unindent", reader->bunindent ); | 1794 | config.writeEntry( "Unindent", reader->bunindent ); |
1795 | config.writeEntry( "Repara", reader->brepara ); | 1795 | config.writeEntry( "Repara", reader->brepara ); |
1796 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 1796 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
1797 | config.writeEntry( "Indent", reader->bindenter ); | 1797 | config.writeEntry( "Indent", reader->bindenter ); |
1798 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 1798 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
1799 | config.writeEntry( "ScrollDelay", reader->m_delay); | 1799 | config.writeEntry( "ScrollDelay", reader->m_delay); |
1800 | config.writeEntry( "LastFile", reader->m_lastfile ); | 1800 | config.writeEntry( "LastFile", reader->m_lastfile ); |
1801 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 1801 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
1802 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 1802 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
1803 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 1803 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
1804 | config.writeEntry( "Fontname", reader->m_fontname ); | 1804 | config.writeEntry( "Fontname", reader->m_fontname ); |
1805 | config.writeEntry( "Encoding", reader->m_encd ); | 1805 | config.writeEntry( "Encoding", reader->m_encd ); |
1806 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 1806 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
1807 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 1807 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
1808 | config.writeEntry( "TargetApp", m_targetapp ); | 1808 | config.writeEntry( "TargetApp", m_targetapp ); |
diff --git a/noncore/apps/opie-reader/infowin.cpp b/noncore/apps/opie-reader/infowin.cpp index 9637a62..7b8f280 100644 --- a/noncore/apps/opie-reader/infowin.cpp +++ b/noncore/apps/opie-reader/infowin.cpp | |||
@@ -1,42 +1,42 @@ | |||
1 | #include "infowin.h" | 1 | #include "infowin.h" |
2 | #include "version.h" | 2 | #include "version.h" |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | 4 | ||
5 | infowin::infowin( QWidget *parent=0, const char *name=0, WFlags f = 0) : | 5 | infowin::infowin( QWidget *parent, const char *name, WFlags f) : |
6 | QWidget(parent, name, f) | 6 | QWidget(parent, name, f) |
7 | { | 7 | { |
8 | grid = new QGridLayout(this, 6, 2); | 8 | grid = new QGridLayout(this, 6, 2); |
9 | QLabel* l; | 9 | QLabel* l; |
10 | l = new QLabel("Compressed file size", this); | 10 | l = new QLabel("Compressed file size", this); |
11 | grid->addWidget(l, 0, 0); | 11 | grid->addWidget(l, 0, 0); |
12 | fileSize = new QLabel("0", this); | 12 | fileSize = new QLabel("0", this); |
13 | fileSize->setAlignment( AlignVCenter | AlignRight ); | 13 | fileSize->setAlignment( AlignVCenter | AlignRight ); |
14 | grid->addWidget(fileSize, 0, 1); | 14 | grid->addWidget(fileSize, 0, 1); |
15 | l = new QLabel("Original text size", this); | 15 | l = new QLabel("Original text size", this); |
16 | grid->addWidget(l, 1, 0); | 16 | grid->addWidget(l, 1, 0); |
17 | textSize = new QLabel("0", this); | 17 | textSize = new QLabel("0", this); |
18 | textSize->setAlignment( AlignVCenter | AlignRight ); | 18 | textSize->setAlignment( AlignVCenter | AlignRight ); |
19 | grid->addWidget(textSize, 1, 1); | 19 | grid->addWidget(textSize, 1, 1); |
20 | l = new QLabel("Compression Ratio", this); | 20 | l = new QLabel("Compression Ratio", this); |
21 | grid->addWidget(l, 2, 0); | 21 | grid->addWidget(l, 2, 0); |
22 | ratio = new QLabel("0", this); | 22 | ratio = new QLabel("0", this); |
23 | grid->addWidget(ratio, 2, 1); | 23 | grid->addWidget(ratio, 2, 1); |
24 | ratio->setAlignment( AlignVCenter | AlignRight ); | 24 | ratio->setAlignment( AlignVCenter | AlignRight ); |
25 | l = new QLabel("Current location", this); | 25 | l = new QLabel("Current location", this); |
26 | grid->addWidget(l, 3, 0); | 26 | grid->addWidget(l, 3, 0); |
27 | location = new QLabel("0", this); | 27 | location = new QLabel("0", this); |
28 | location->setAlignment( AlignVCenter | AlignRight ); | 28 | location->setAlignment( AlignVCenter | AlignRight ); |
29 | grid->addWidget(location, 3, 1); | 29 | grid->addWidget(location, 3, 1); |
30 | l = new QLabel("Per centage read", this); | 30 | l = new QLabel("Per centage read", this); |
31 | grid->addWidget(l, 4, 0); | 31 | grid->addWidget(l, 4, 0); |
32 | read = new QLabel("0", this); | 32 | read = new QLabel("0", this); |
33 | read->setAlignment( AlignVCenter | AlignRight ); | 33 | read->setAlignment( AlignVCenter | AlignRight ); |
34 | grid->addWidget(read, 4, 1); | 34 | grid->addWidget(read, 4, 1); |
35 | char vstr[128]; | 35 | char vstr[128]; |
36 | sprintf(vstr, "QT Reader v%u.%u%c (%s)\nA small e-text reader", MAJOR, BKMKTYPE, MINOR, RELEASE_TYPE); | 36 | sprintf(vstr, "QT Reader v%u.%u%c (%s)\nA small e-text reader", MAJOR, BKMKTYPE, MINOR, RELEASE_TYPE); |
37 | l = new QLabel(vstr, this); | 37 | l = new QLabel(vstr, this); |
38 | grid->addWidget(l, 5, 0); | 38 | grid->addWidget(l, 5, 0); |
39 | QPushButton* exitbutton = new QPushButton("Cancel", this); | 39 | QPushButton* exitbutton = new QPushButton("Cancel", this); |
40 | connect( exitbutton, SIGNAL( released() ), this, SLOT( infoClose() ) ); | 40 | connect( exitbutton, SIGNAL( released() ), this, SLOT( infoClose() ) ); |
41 | grid->addWidget(exitbutton, 5, 1); | 41 | grid->addWidget(exitbutton, 5, 1); |
42 | } | 42 | } |