author | paule <paule> | 2007-07-08 08:37:52 (UTC) |
---|---|---|
committer | paule <paule> | 2007-07-08 08:37:52 (UTC) |
commit | b07e25cd398620dafb9ce01982267588645d99a9 (patch) (unidiff) | |
tree | 41e01245b65ff07efce13743a45eefac7923fdcf | |
parent | 4fb748a55cdd77f4bab8dc692ab8ebae62609abe (diff) | |
download | opie-b07e25cd398620dafb9ce01982267588645d99a9.zip opie-b07e25cd398620dafb9ce01982267588645d99a9.tar.gz opie-b07e25cd398620dafb9ce01982267588645d99a9.tar.bz2 |
Fix copying unicode block to clipboard. See bug #1766. Patch from polyonymous.
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index b985094..4f0f0a1 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -2177,769 +2177,769 @@ void QTReaderApp::showprefs() | |||
2177 | reader->bpeanut = true; | 2177 | reader->bpeanut = true; |
2178 | break; | 2178 | break; |
2179 | default: | 2179 | default: |
2180 | qDebug("Format out of range"); | 2180 | qDebug("Format out of range"); |
2181 | } | 2181 | } |
2182 | reader->bdepluck = prefwin->Depluck(); | 2182 | reader->bdepluck = prefwin->Depluck(); |
2183 | reader->bdejpluck = prefwin->Dejpluck(); | 2183 | reader->bdejpluck = prefwin->Dejpluck(); |
2184 | reader->setContinuous(prefwin->Continuous()); | 2184 | reader->setContinuous(prefwin->Continuous()); |
2185 | reader->setDoubleBuffer(prefwin->DoubleBuffer()); | 2185 | reader->setDoubleBuffer(prefwin->DoubleBuffer()); |
2186 | 2186 | ||
2187 | /* | 2187 | /* |
2188 | m_leftScroll = prefwin->leftScroll(); | 2188 | m_leftScroll = prefwin->leftScroll(); |
2189 | m_rightScroll = prefwin->rightScroll(); | 2189 | m_rightScroll = prefwin->rightScroll(); |
2190 | m_upScroll = prefwin->upScroll(); | 2190 | m_upScroll = prefwin->upScroll(); |
2191 | m_downScroll = prefwin->downScroll(); | 2191 | m_downScroll = prefwin->downScroll(); |
2192 | */ | 2192 | */ |
2193 | m_targetapp = prefwin->dictApplication(); | 2193 | m_targetapp = prefwin->dictApplication(); |
2194 | m_targetmsg = prefwin->dictMessage(); | 2194 | m_targetmsg = prefwin->dictMessage(); |
2195 | 2195 | ||
2196 | m_doAnnotation = prefwin->miscannotation(); | 2196 | m_doAnnotation = prefwin->miscannotation(); |
2197 | m_doDictionary = prefwin->miscdictionary(); | 2197 | m_doDictionary = prefwin->miscdictionary(); |
2198 | m_doClipboard = prefwin->miscclipboard(); | 2198 | m_doClipboard = prefwin->miscclipboard(); |
2199 | m_doOutput = prefwin->miscoutput(); | 2199 | m_doOutput = prefwin->miscoutput(); |
2200 | reader->m_swapmouse = prefwin->SwapMouse(); | 2200 | reader->m_swapmouse = prefwin->SwapMouse(); |
2201 | reader->setBaseSize(prefwin->gfxsize()); | 2201 | reader->setBaseSize(prefwin->gfxsize()); |
2202 | reader->m_overlap = prefwin->pageoverlap(); | 2202 | reader->m_overlap = prefwin->pageoverlap(); |
2203 | reader->m_bMonoSpaced = prefwin->ideogram(); | 2203 | reader->m_bMonoSpaced = prefwin->ideogram(); |
2204 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 2204 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
2205 | reader->m_encd = prefwin->encoding(); | 2205 | reader->m_encd = prefwin->encoding(); |
2206 | reader->m_charpc = prefwin->ideogramwidth(); | 2206 | reader->m_charpc = prefwin->ideogramwidth(); |
2207 | 2207 | ||
2208 | if ( | 2208 | if ( |
2209 | reader->m_fontname != prefwin->Font() | 2209 | reader->m_fontname != prefwin->Font() |
2210 | || | 2210 | || |
2211 | m_propogatefontchange != prefwin->propfontchange()) | 2211 | m_propogatefontchange != prefwin->propfontchange()) |
2212 | { | 2212 | { |
2213 | m_propogatefontchange = prefwin->propfontchange(); | 2213 | m_propogatefontchange = prefwin->propfontchange(); |
2214 | setfontHelper(prefwin->Font()); | 2214 | setfontHelper(prefwin->Font()); |
2215 | } | 2215 | } |
2216 | if (m_bgtype != (bground)prefwin->bgtype()) | 2216 | if (m_bgtype != (bground)prefwin->bgtype()) |
2217 | { | 2217 | { |
2218 | m_bgtype = (bground)prefwin->bgtype(); | 2218 | m_bgtype = (bground)prefwin->bgtype(); |
2219 | setBackgroundBitmap(); | 2219 | setBackgroundBitmap(); |
2220 | } | 2220 | } |
2221 | qDebug("OutCodec:%s", (const char*)prefwin->outcodec()); | 2221 | qDebug("OutCodec:%s", (const char*)prefwin->outcodec()); |
2222 | if (reader->m_outputName != prefwin->outcodec()) | 2222 | if (reader->m_outputName != prefwin->outcodec()) |
2223 | { | 2223 | { |
2224 | if (reader->m_output != NULL) | 2224 | if (reader->m_output != NULL) |
2225 | { | 2225 | { |
2226 | QMessageBox::warning(this, PROGNAME, "Change of output codec\nrequires a restart"); | 2226 | QMessageBox::warning(this, PROGNAME, "Change of output codec\nrequires a restart"); |
2227 | } | 2227 | } |
2228 | reader->m_outputName = prefwin->outcodec(); | 2228 | reader->m_outputName = prefwin->outcodec(); |
2229 | } | 2229 | } |
2230 | delete prefwin; | 2230 | delete prefwin; |
2231 | reader->setfilter(reader->getfilter()); | 2231 | reader->setfilter(reader->getfilter()); |
2232 | reader->refresh(); | 2232 | reader->refresh(); |
2233 | } | 2233 | } |
2234 | else | 2234 | else |
2235 | { | 2235 | { |
2236 | delete prefwin; | 2236 | delete prefwin; |
2237 | } | 2237 | } |
2238 | } | 2238 | } |
2239 | 2239 | ||
2240 | void QTReaderApp::showtoolbarprefs() | 2240 | void QTReaderApp::showtoolbarprefs() |
2241 | { | 2241 | { |
2242 | #ifdef USEQPE | 2242 | #ifdef USEQPE |
2243 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); | 2243 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); |
2244 | #else | 2244 | #else |
2245 | QFileInfo fi; | 2245 | QFileInfo fi; |
2246 | QDir d = QDir::home(); // "/" | 2246 | QDir d = QDir::home(); // "/" |
2247 | if ( !d.cd(APPDIR) ) | 2247 | if ( !d.cd(APPDIR) ) |
2248 | { // "/tmp" | 2248 | { // "/tmp" |
2249 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 2249 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
2250 | d = QDir::home(); | 2250 | d = QDir::home(); |
2251 | d.mkdir(APPDIR); | 2251 | d.mkdir(APPDIR); |
2252 | d.cd(APPDIR); | 2252 | d.cd(APPDIR); |
2253 | } | 2253 | } |
2254 | fi.setFile(d, INIFILE); | 2254 | fi.setFile(d, INIFILE); |
2255 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); | 2255 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); |
2256 | #endif | 2256 | #endif |
2257 | prefwin->tbpolicy(m_tbpolsave); | 2257 | prefwin->tbpolicy(m_tbpolsave); |
2258 | prefwin->tbposition(m_tbposition-2); | 2258 | prefwin->tbposition(m_tbposition-2); |
2259 | prefwin->tbmovable(m_tbmovesave); | 2259 | prefwin->tbmovable(m_tbmovesave); |
2260 | prefwin->floating(m_bFloatingDialog); | 2260 | prefwin->floating(m_bFloatingDialog); |
2261 | prefwin->qtscroll(m_qtscroll); | 2261 | prefwin->qtscroll(m_qtscroll); |
2262 | prefwin->localscroll(m_localscroll); | 2262 | prefwin->localscroll(m_localscroll); |
2263 | if (prefwin->exec()) | 2263 | if (prefwin->exec()) |
2264 | { | 2264 | { |
2265 | m_bFloatingDialog = prefwin->floating(); | 2265 | m_bFloatingDialog = prefwin->floating(); |
2266 | if ( | 2266 | if ( |
2267 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() | 2267 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() |
2268 | || | 2268 | || |
2269 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) | 2269 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) |
2270 | || | 2270 | || |
2271 | m_tbmovesave != prefwin->tbmovable() | 2271 | m_tbmovesave != prefwin->tbmovable() |
2272 | || | 2272 | || |
2273 | m_qtscroll != prefwin->qtscroll() | 2273 | m_qtscroll != prefwin->qtscroll() |
2274 | // || | 2274 | // || |
2275 | // m_localscrollbar != prefwin->scrollonleft() | 2275 | // m_localscrollbar != prefwin->scrollonleft() |
2276 | ) | 2276 | ) |
2277 | { | 2277 | { |
2278 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); | 2278 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); |
2279 | } | 2279 | } |
2280 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); | 2280 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); |
2281 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); | 2281 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); |
2282 | m_tbmovesave = prefwin->tbmovable(); | 2282 | m_tbmovesave = prefwin->tbmovable(); |
2283 | reader->m_scrollpos = m_localscroll = prefwin->localscroll(); | 2283 | reader->m_scrollpos = m_localscroll = prefwin->localscroll(); |
2284 | if (m_qtscroll != prefwin->qtscroll()) | 2284 | if (m_qtscroll != prefwin->qtscroll()) |
2285 | { | 2285 | { |
2286 | m_qtscroll = prefwin->qtscroll(); | 2286 | m_qtscroll = prefwin->qtscroll(); |
2287 | setrotated(reader->m_rotated); | 2287 | setrotated(reader->m_rotated); |
2288 | } | 2288 | } |
2289 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) | 2289 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) |
2290 | { | 2290 | { |
2291 | reader->m_scrollpos = m_localscroll; | 2291 | reader->m_scrollpos = m_localscroll; |
2292 | } | 2292 | } |
2293 | else | 2293 | else |
2294 | { | 2294 | { |
2295 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; | 2295 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
2296 | } | 2296 | } |
2297 | bool isChanged = prefwin->isChanged(); | 2297 | bool isChanged = prefwin->isChanged(); |
2298 | delete prefwin; | 2298 | delete prefwin; |
2299 | #ifdef USEQPE | 2299 | #ifdef USEQPE |
2300 | Config config( APPDIR ); | 2300 | Config config( APPDIR ); |
2301 | #else | 2301 | #else |
2302 | QFileInfo fi; | 2302 | QFileInfo fi; |
2303 | QDir d = QDir::home(); // "/" | 2303 | QDir d = QDir::home(); // "/" |
2304 | if ( !d.cd(APPDIR) ) | 2304 | if ( !d.cd(APPDIR) ) |
2305 | { // "/tmp" | 2305 | { // "/tmp" |
2306 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 2306 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
2307 | d = QDir::home(); | 2307 | d = QDir::home(); |
2308 | d.mkdir(APPDIR); | 2308 | d.mkdir(APPDIR); |
2309 | d.cd(APPDIR); | 2309 | d.cd(APPDIR); |
2310 | } | 2310 | } |
2311 | fi.setFile(d, INIFILE); | 2311 | fi.setFile(d, INIFILE); |
2312 | Config config( fi.absFilePath() ); | 2312 | Config config( fi.absFilePath() ); |
2313 | #endif | 2313 | #endif |
2314 | if (isChanged) addtoolbars(&config); | 2314 | if (isChanged) addtoolbars(&config); |
2315 | } | 2315 | } |
2316 | else | 2316 | else |
2317 | { | 2317 | { |
2318 | delete prefwin; | 2318 | delete prefwin; |
2319 | } | 2319 | } |
2320 | } | 2320 | } |
2321 | 2321 | ||
2322 | void QTReaderApp::showinfo() | 2322 | void QTReaderApp::showinfo() |
2323 | { | 2323 | { |
2324 | unsigned long ds, fs, ts, pl, dl; | 2324 | unsigned long ds, fs, ts, pl, dl; |
2325 | if (reader->empty()) | 2325 | if (reader->empty()) |
2326 | { | 2326 | { |
2327 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2327 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2328 | } | 2328 | } |
2329 | else | 2329 | else |
2330 | { | 2330 | { |
2331 | reader->sizes(fs,ts); | 2331 | reader->sizes(fs,ts); |
2332 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); | 2332 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); |
2333 | pl = reader->pagelocate(); | 2333 | pl = reader->pagelocate(); |
2334 | dl = pl - reader->buffdoc.startSection(); | 2334 | dl = pl - reader->buffdoc.startSection(); |
2335 | m_infoWin->setFileSize(fs); | 2335 | m_infoWin->setFileSize(fs); |
2336 | m_infoWin->setTextSize(ts); | 2336 | m_infoWin->setTextSize(ts); |
2337 | if (fs > UINT_MAX/100) | 2337 | if (fs > UINT_MAX/100) |
2338 | { | 2338 | { |
2339 | unsigned long t1 = (ts+50)/100; | 2339 | unsigned long t1 = (ts+50)/100; |
2340 | m_infoWin->setRatio(100-(fs + (t1 >> 1))/t1); | 2340 | m_infoWin->setRatio(100-(fs + (t1 >> 1))/t1); |
2341 | } | 2341 | } |
2342 | else | 2342 | else |
2343 | { | 2343 | { |
2344 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 2344 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); |
2345 | } | 2345 | } |
2346 | m_infoWin->setLocation(pl); | 2346 | m_infoWin->setLocation(pl); |
2347 | if (pl > UINT_MAX/100) | 2347 | if (pl > UINT_MAX/100) |
2348 | { | 2348 | { |
2349 | unsigned long t1 = (ts+50)/100; | 2349 | unsigned long t1 = (ts+50)/100; |
2350 | m_infoWin->setRead((pl + (t1 >> 1))/t1); | 2350 | m_infoWin->setRead((pl + (t1 >> 1))/t1); |
2351 | } | 2351 | } |
2352 | else | 2352 | else |
2353 | { | 2353 | { |
2354 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 2354 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); |
2355 | } | 2355 | } |
2356 | m_infoWin->setDocSize(ds); | 2356 | m_infoWin->setDocSize(ds); |
2357 | m_infoWin->setDocLocation(dl); | 2357 | m_infoWin->setDocLocation(dl); |
2358 | if (dl > UINT_MAX/100) | 2358 | if (dl > UINT_MAX/100) |
2359 | { | 2359 | { |
2360 | unsigned long d1 = (ds+50)/100; | 2360 | unsigned long d1 = (ds+50)/100; |
2361 | m_infoWin->setDocRead((dl + (d1 >> 1))/d1); | 2361 | m_infoWin->setDocRead((dl + (d1 >> 1))/d1); |
2362 | } | 2362 | } |
2363 | else | 2363 | else |
2364 | { | 2364 | { |
2365 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); | 2365 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); |
2366 | } | 2366 | } |
2367 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); | 2367 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); |
2368 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); | 2368 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); |
2369 | editorStack->raiseWidget( m_infoWin ); | 2369 | editorStack->raiseWidget( m_infoWin ); |
2370 | hidetoolbars(); | 2370 | hidetoolbars(); |
2371 | m_infoWin->setFocus(); | 2371 | m_infoWin->setFocus(); |
2372 | } | 2372 | } |
2373 | } | 2373 | } |
2374 | 2374 | ||
2375 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) | 2375 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) |
2376 | { | 2376 | { |
2377 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; | 2377 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
2378 | #ifdef _UNICODE | 2378 | #ifdef _UNICODE |
2379 | CBuffer buff(name.length()+1); | 2379 | CBuffer buff(name.length()+1); |
2380 | int i; | 2380 | int i; |
2381 | for (i = 0; i < name.length(); i++) | 2381 | for (i = 0; i < name.length(); i++) |
2382 | { | 2382 | { |
2383 | buff[i] = name[i].unicode(); | 2383 | buff[i] = name[i].unicode(); |
2384 | } | 2384 | } |
2385 | buff[i] = 0; | 2385 | buff[i] = 0; |
2386 | CBuffer buff2(text.length()+1); | 2386 | CBuffer buff2(text.length()+1); |
2387 | for (i = 0; i < text.length(); i++) | 2387 | for (i = 0; i < text.length(); i++) |
2388 | { | 2388 | { |
2389 | buff2[i] = text[i].unicode(); | 2389 | buff2[i] = text[i].unicode(); |
2390 | } | 2390 | } |
2391 | buff2[i] = 0; | 2391 | buff2[i] = 0; |
2392 | Bkmk b(buff.data(), buff2.data(), posn, posn2); | 2392 | Bkmk b(buff.data(), buff2.data(), posn, posn2); |
2393 | QColor c = m_annoWin->getColor(); | 2393 | QColor c = m_annoWin->getColor(); |
2394 | int red,green,blue; | 2394 | int red,green,blue; |
2395 | c.rgb(&red, &green, &blue); | 2395 | c.rgb(&red, &green, &blue); |
2396 | b.red(red); | 2396 | b.red(red); |
2397 | b.green(green); | 2397 | b.green(green); |
2398 | b.blue(blue); | 2398 | b.blue(blue); |
2399 | pBkmklist->push_front(b); | 2399 | pBkmklist->push_front(b); |
2400 | #else | 2400 | #else |
2401 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); | 2401 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); |
2402 | #endif | 2402 | #endif |
2403 | m_fBkmksChanged = true; | 2403 | m_fBkmksChanged = true; |
2404 | pBkmklist->sort(); | 2404 | pBkmklist->sort(); |
2405 | } | 2405 | } |
2406 | 2406 | ||
2407 | void QTReaderApp::addAnno(const QString& name, const QString& text) | 2407 | void QTReaderApp::addAnno(const QString& name, const QString& text) |
2408 | { | 2408 | { |
2409 | if (m_annoIsEditing) | 2409 | if (m_annoIsEditing) |
2410 | { | 2410 | { |
2411 | if (name.isEmpty()) | 2411 | if (name.isEmpty()) |
2412 | { | 2412 | { |
2413 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); | 2413 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); |
2414 | } | 2414 | } |
2415 | else | 2415 | else |
2416 | { | 2416 | { |
2417 | addAnno(name, text, m_annoWin->getPosn(), m_annoWin->getPosn2()); | 2417 | addAnno(name, text, m_annoWin->getPosn(), m_annoWin->getPosn2()); |
2418 | } | 2418 | } |
2419 | showEditTools(); | 2419 | showEditTools(); |
2420 | } | 2420 | } |
2421 | else | 2421 | else |
2422 | { | 2422 | { |
2423 | if (m_annoWin->edited()) | 2423 | if (m_annoWin->edited()) |
2424 | { | 2424 | { |
2425 | CBuffer buff(text.length()+1); | 2425 | CBuffer buff(text.length()+1); |
2426 | int i; | 2426 | int i; |
2427 | for (i = 0; i < text.length(); i++) | 2427 | for (i = 0; i < text.length(); i++) |
2428 | { | 2428 | { |
2429 | buff[i] = text[i].unicode(); | 2429 | buff[i] = text[i].unicode(); |
2430 | } | 2430 | } |
2431 | buff[i] = 0; | 2431 | buff[i] = 0; |
2432 | m_fBkmksChanged = true; | 2432 | m_fBkmksChanged = true; |
2433 | m_anno->setAnno(buff.data()); | 2433 | m_anno->setAnno(buff.data()); |
2434 | } | 2434 | } |
2435 | QColor c = m_annoWin->getColor(); | 2435 | QColor c = m_annoWin->getColor(); |
2436 | int red,green,blue; | 2436 | int red,green,blue; |
2437 | c.rgb(&red, &green, &blue); | 2437 | c.rgb(&red, &green, &blue); |
2438 | m_anno->red(red); | 2438 | m_anno->red(red); |
2439 | m_anno->green(green); | 2439 | m_anno->green(green); |
2440 | m_anno->blue(blue); | 2440 | m_anno->blue(blue); |
2441 | bool found = findNextBookmark(m_anno->value()+1); | 2441 | bool found = findNextBookmark(m_anno->value()+1); |
2442 | if (found) | 2442 | if (found) |
2443 | { | 2443 | { |
2444 | m_annoWin->setName(toQString(m_anno->name())); | 2444 | m_annoWin->setName(toQString(m_anno->name())); |
2445 | m_annoWin->setAnno(toQString(m_anno->anno())); | 2445 | m_annoWin->setAnno(toQString(m_anno->anno())); |
2446 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); | 2446 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); |
2447 | } | 2447 | } |
2448 | else | 2448 | else |
2449 | { | 2449 | { |
2450 | showEditTools(); | 2450 | showEditTools(); |
2451 | } | 2451 | } |
2452 | } | 2452 | } |
2453 | } | 2453 | } |
2454 | 2454 | ||
2455 | bool QTReaderApp::findNextBookmark(size_t start) | 2455 | bool QTReaderApp::findNextBookmark(size_t start) |
2456 | { | 2456 | { |
2457 | bool found = false; | 2457 | bool found = false; |
2458 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) | 2458 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) |
2459 | { | 2459 | { |
2460 | if (iter->value() >= start) | 2460 | if (iter->value() >= start) |
2461 | { | 2461 | { |
2462 | if (iter->value() < reader->locate()) | 2462 | if (iter->value() < reader->locate()) |
2463 | { | 2463 | { |
2464 | found = true; | 2464 | found = true; |
2465 | m_anno = iter.pContent(); | 2465 | m_anno = iter.pContent(); |
2466 | } | 2466 | } |
2467 | break; | 2467 | break; |
2468 | } | 2468 | } |
2469 | } | 2469 | } |
2470 | return found; | 2470 | return found; |
2471 | } | 2471 | } |
2472 | 2472 | ||
2473 | void QTReaderApp::addanno() | 2473 | void QTReaderApp::addanno() |
2474 | { | 2474 | { |
2475 | if (reader->empty()) | 2475 | if (reader->empty()) |
2476 | { | 2476 | { |
2477 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2477 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2478 | } | 2478 | } |
2479 | else | 2479 | else |
2480 | { | 2480 | { |
2481 | m_annoWin->setName(""); | 2481 | m_annoWin->setName(""); |
2482 | m_annoWin->setAnno(""); | 2482 | m_annoWin->setAnno(""); |
2483 | m_annoWin->setPosn(reader->pagelocate()); | 2483 | m_annoWin->setPosn(reader->pagelocate()); |
2484 | m_annoIsEditing = true; | 2484 | m_annoIsEditing = true; |
2485 | editorStack->raiseWidget( m_annoWin ); | 2485 | editorStack->raiseWidget( m_annoWin ); |
2486 | hidetoolbars(); | 2486 | hidetoolbars(); |
2487 | #ifdef USEQPE | 2487 | #ifdef USEQPE |
2488 | Global::showInputMethod(); | 2488 | Global::showInputMethod(); |
2489 | #endif | 2489 | #endif |
2490 | m_annoWin->setFocus(); | 2490 | m_annoWin->setFocus(); |
2491 | } | 2491 | } |
2492 | } | 2492 | } |
2493 | 2493 | ||
2494 | void QTReaderApp::infoClose() | 2494 | void QTReaderApp::infoClose() |
2495 | { | 2495 | { |
2496 | m_debounce = m_buttonprefs->Debounce(); | 2496 | m_debounce = m_buttonprefs->Debounce(); |
2497 | if (m_kmapchanged) | 2497 | if (m_kmapchanged) |
2498 | { | 2498 | { |
2499 | m_kmapchanged = false; | 2499 | m_kmapchanged = false; |
2500 | #ifndef USEQPE | 2500 | #ifndef USEQPE |
2501 | QDir d = QDir::home(); // "/" | 2501 | QDir d = QDir::home(); // "/" |
2502 | d.cd(APPDIR); | 2502 | d.cd(APPDIR); |
2503 | QFileInfo fi(d, ".keymap"); | 2503 | QFileInfo fi(d, ".keymap"); |
2504 | FILE* f = fopen((const char *)fi.absFilePath(), "w"); | 2504 | FILE* f = fopen((const char *)fi.absFilePath(), "w"); |
2505 | #else /* USEQPE */ | 2505 | #else /* USEQPE */ |
2506 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "w"); | 2506 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "w"); |
2507 | #endif /* USEQPE */ | 2507 | #endif /* USEQPE */ |
2508 | if (f != NULL) | 2508 | if (f != NULL) |
2509 | { | 2509 | { |
2510 | uint cnt = KEYMAPVERSION; | 2510 | uint cnt = KEYMAPVERSION; |
2511 | fwrite(&cnt, sizeof(cnt), 1, f); | 2511 | fwrite(&cnt, sizeof(cnt), 1, f); |
2512 | cnt = kmap.count(); | 2512 | cnt = kmap.count(); |
2513 | fwrite(&cnt, sizeof(cnt), 1, f); | 2513 | fwrite(&cnt, sizeof(cnt), 1, f); |
2514 | for (QMap<orKey,int>::Iterator i = kmap.begin(); i != kmap.end(); i++) | 2514 | for (QMap<orKey,int>::Iterator i = kmap.begin(); i != kmap.end(); i++) |
2515 | { | 2515 | { |
2516 | orKey key = i.key(); | 2516 | orKey key = i.key(); |
2517 | int data = i.data(); | 2517 | int data = i.data(); |
2518 | fwrite(&key, sizeof(key), 1, f); | 2518 | fwrite(&key, sizeof(key), 1, f); |
2519 | fwrite(&data, sizeof(data), 1, f); | 2519 | fwrite(&data, sizeof(data), 1, f); |
2520 | qDebug("Saved %s as %u", (const char*)key.text(), data); | 2520 | qDebug("Saved %s as %u", (const char*)key.text(), data); |
2521 | } | 2521 | } |
2522 | fclose(f); | 2522 | fclose(f); |
2523 | } | 2523 | } |
2524 | } | 2524 | } |
2525 | showEditTools(); | 2525 | showEditTools(); |
2526 | } | 2526 | } |
2527 | 2527 | ||
2528 | /* | 2528 | /* |
2529 | void QTReaderApp::fileRevert() | 2529 | void QTReaderApp::fileRevert() |
2530 | { | 2530 | { |
2531 | clear(); | 2531 | clear(); |
2532 | fileOpen(); | 2532 | fileOpen(); |
2533 | } | 2533 | } |
2534 | 2534 | ||
2535 | void QTReaderApp::editCut() | 2535 | void QTReaderApp::editCut() |
2536 | { | 2536 | { |
2537 | #ifndef QT_NO_CLIPBOARD | 2537 | #ifndef QT_NO_CLIPBOARD |
2538 | editor->cut(); | 2538 | editor->cut(); |
2539 | #endif | 2539 | #endif |
2540 | } | 2540 | } |
2541 | */ | 2541 | */ |
2542 | void QTReaderApp::editMark() | 2542 | void QTReaderApp::editMark() |
2543 | { | 2543 | { |
2544 | m_savedpos = reader->pagelocate(); | 2544 | m_savedpos = reader->pagelocate(); |
2545 | } | 2545 | } |
2546 | 2546 | ||
2547 | void QTReaderApp::editCopy() | 2547 | void QTReaderApp::editCopy() |
2548 | { | 2548 | { |
2549 | QClipboard* cb = QApplication::clipboard(); | 2549 | QClipboard* cb = QApplication::clipboard(); |
2550 | QString text; | 2550 | QString text; |
2551 | int ch; | 2551 | int ch; |
2552 | unsigned long currentpos = reader->pagelocate(); | 2552 | unsigned long currentpos = reader->pagelocate(); |
2553 | unsigned long endpos = reader->locate(); | 2553 | unsigned long endpos = reader->locate(); |
2554 | if (m_savedpos == 0xffffffff) | 2554 | if (m_savedpos == 0xffffffff) |
2555 | { | 2555 | { |
2556 | m_savedpos = currentpos; | 2556 | m_savedpos = currentpos; |
2557 | } | 2557 | } |
2558 | reader->jumpto(m_savedpos); | 2558 | reader->jumpto(m_savedpos); |
2559 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) | 2559 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
2560 | { | 2560 | { |
2561 | text += ch; | 2561 | text += QChar(ch); |
2562 | } | 2562 | } |
2563 | cb->setText(text); | 2563 | cb->setText(text); |
2564 | reader->locate(currentpos); | 2564 | reader->locate(currentpos); |
2565 | m_savedpos = 0xffffffff; | 2565 | m_savedpos = 0xffffffff; |
2566 | } | 2566 | } |
2567 | 2567 | ||
2568 | void QTReaderApp::gotoStart() | 2568 | void QTReaderApp::gotoStart() |
2569 | { | 2569 | { |
2570 | reader->locate(reader->buffdoc.startSection()); | 2570 | reader->locate(reader->buffdoc.startSection()); |
2571 | } | 2571 | } |
2572 | 2572 | ||
2573 | void QTReaderApp::gotoEnd() | 2573 | void QTReaderApp::gotoEnd() |
2574 | { | 2574 | { |
2575 | reader->dopageup(reader->buffdoc.endSection()); | 2575 | reader->dopageup(reader->buffdoc.endSection()); |
2576 | } | 2576 | } |
2577 | 2577 | ||
2578 | void QTReaderApp::pageup() | 2578 | void QTReaderApp::pageup() |
2579 | { | 2579 | { |
2580 | reader->NavUp(); | 2580 | reader->NavUp(); |
2581 | } | 2581 | } |
2582 | 2582 | ||
2583 | void QTReaderApp::pagedn() | 2583 | void QTReaderApp::pagedn() |
2584 | { | 2584 | { |
2585 | reader->NavDown(); | 2585 | reader->NavDown(); |
2586 | } | 2586 | } |
2587 | 2587 | ||
2588 | void QTReaderApp::pagemode(bool _b) | 2588 | void QTReaderApp::pagemode(bool _b) |
2589 | { | 2589 | { |
2590 | reader->setpagemode(_b); | 2590 | reader->setpagemode(_b); |
2591 | } | 2591 | } |
2592 | 2592 | ||
2593 | /* | 2593 | /* |
2594 | void QTReaderApp::setspacing() | 2594 | void QTReaderApp::setspacing() |
2595 | { | 2595 | { |
2596 | m_nRegAction = cMonoSpace; | 2596 | m_nRegAction = cMonoSpace; |
2597 | char lcn[20]; | 2597 | char lcn[20]; |
2598 | sprintf(lcn, "%lu", reader->m_charpc); | 2598 | sprintf(lcn, "%lu", reader->m_charpc); |
2599 | regEdit->setText(lcn); | 2599 | regEdit->setText(lcn); |
2600 | do_regedit(); | 2600 | do_regedit(); |
2601 | } | 2601 | } |
2602 | */ | 2602 | */ |
2603 | void QTReaderApp::settarget() | 2603 | void QTReaderApp::settarget() |
2604 | { | 2604 | { |
2605 | m_nRegAction = cSetTarget; | 2605 | m_nRegAction = cSetTarget; |
2606 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) | 2606 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) |
2607 | + "/" | 2607 | + "/" |
2608 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); | 2608 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); |
2609 | regEdit->setText(text); | 2609 | regEdit->setText(text); |
2610 | do_regedit(); | 2610 | do_regedit(); |
2611 | } | 2611 | } |
2612 | 2612 | ||
2613 | /* | 2613 | /* |
2614 | void QTReaderApp::do_mono(const QString& lcn) | 2614 | void QTReaderApp::do_mono(const QString& lcn) |
2615 | { | 2615 | { |
2616 | bool ok; | 2616 | bool ok; |
2617 | unsigned long ulcn = lcn.toULong(&ok); | 2617 | unsigned long ulcn = lcn.toULong(&ok); |
2618 | if (ok) | 2618 | if (ok) |
2619 | { | 2619 | { |
2620 | reader->m_charpc = ulcn; | 2620 | reader->m_charpc = ulcn; |
2621 | reader->setfont(); | 2621 | reader->setfont(); |
2622 | reader->refresh(); | 2622 | reader->refresh(); |
2623 | //reader->setmono(true); | 2623 | //reader->setmono(true); |
2624 | } | 2624 | } |
2625 | else | 2625 | else |
2626 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2626 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2627 | } | 2627 | } |
2628 | */ | 2628 | */ |
2629 | /* | 2629 | /* |
2630 | void QTReaderApp::editPaste() | 2630 | void QTReaderApp::editPaste() |
2631 | { | 2631 | { |
2632 | #ifndef QT_NO_CLIPBOARD | 2632 | #ifndef QT_NO_CLIPBOARD |
2633 | editor->paste(); | 2633 | editor->paste(); |
2634 | #endif | 2634 | #endif |
2635 | } | 2635 | } |
2636 | */ | 2636 | */ |
2637 | 2637 | ||
2638 | void QTReaderApp::editFind() | 2638 | void QTReaderApp::editFind() |
2639 | { | 2639 | { |
2640 | searchStart = reader->pagelocate(); | 2640 | searchStart = reader->pagelocate(); |
2641 | #ifdef __ISEARCH | 2641 | #ifdef __ISEARCH |
2642 | searchStack = new QStack<searchrecord>; | 2642 | searchStack = new QStack<searchrecord>; |
2643 | #endif | 2643 | #endif |
2644 | #ifdef USEQPE | 2644 | #ifdef USEQPE |
2645 | Global::showInputMethod(); | 2645 | Global::showInputMethod(); |
2646 | #endif | 2646 | #endif |
2647 | searchBar->show(); | 2647 | searchBar->show(); |
2648 | searchVisible = TRUE; | 2648 | searchVisible = TRUE; |
2649 | searchEdit->setFocus(); | 2649 | searchEdit->setFocus(); |
2650 | #ifdef __ISEARCH | 2650 | #ifdef __ISEARCH |
2651 | searchStack->push(new searchrecord("",reader->pagelocate())); | 2651 | searchStack->push(new searchrecord("",reader->pagelocate())); |
2652 | #endif | 2652 | #endif |
2653 | } | 2653 | } |
2654 | 2654 | ||
2655 | void QTReaderApp::findNext() | 2655 | void QTReaderApp::findNext() |
2656 | { | 2656 | { |
2657 | // // qDebug("findNext called\n"); | 2657 | // // qDebug("findNext called\n"); |
2658 | #ifdef __ISEARCH | 2658 | #ifdef __ISEARCH |
2659 | QString arg = searchEdit->text(); | 2659 | QString arg = searchEdit->text(); |
2660 | #else | 2660 | #else |
2661 | QRegExp arg = searchEdit->text(); | 2661 | QRegExp arg = searchEdit->text(); |
2662 | #endif | 2662 | #endif |
2663 | CDrawBuffer test(&(reader->m_fontControl)); | 2663 | CDrawBuffer test(&(reader->m_fontControl)); |
2664 | size_t start = reader->pagelocate(); | 2664 | size_t start = reader->pagelocate(); |
2665 | reader->jumpto(start); | 2665 | reader->jumpto(start); |
2666 | reader->getline(&test); | 2666 | reader->getline(&test); |
2667 | dosearch(start, test, arg); | 2667 | dosearch(start, test, arg); |
2668 | } | 2668 | } |
2669 | 2669 | ||
2670 | void QTReaderApp::findClose() | 2670 | void QTReaderApp::findClose() |
2671 | { | 2671 | { |
2672 | searchVisible = FALSE; | 2672 | searchVisible = FALSE; |
2673 | searchEdit->setText(""); | 2673 | searchEdit->setText(""); |
2674 | #ifdef USEQPE | 2674 | #ifdef USEQPE |
2675 | Global::hideInputMethod(); | 2675 | Global::hideInputMethod(); |
2676 | #endif | 2676 | #endif |
2677 | searchBar->hide(); | 2677 | searchBar->hide(); |
2678 | #ifdef __ISEARCH | 2678 | #ifdef __ISEARCH |
2679 | // searchStack = new QStack<searchrecord>; | 2679 | // searchStack = new QStack<searchrecord>; |
2680 | while (!searchStack->isEmpty()) | 2680 | while (!searchStack->isEmpty()) |
2681 | { | 2681 | { |
2682 | delete searchStack->pop(); | 2682 | delete searchStack->pop(); |
2683 | } | 2683 | } |
2684 | delete searchStack; | 2684 | delete searchStack; |
2685 | #endif | 2685 | #endif |
2686 | reader->setFocus(); | 2686 | reader->setFocus(); |
2687 | } | 2687 | } |
2688 | 2688 | ||
2689 | void QTReaderApp::regClose() | 2689 | void QTReaderApp::regClose() |
2690 | { | 2690 | { |
2691 | regVisible = FALSE; | 2691 | regVisible = FALSE; |
2692 | regEdit->setText(""); | 2692 | regEdit->setText(""); |
2693 | regBar->hide(); | 2693 | regBar->hide(); |
2694 | #ifdef USEQPE | 2694 | #ifdef USEQPE |
2695 | Global::hideInputMethod(); | 2695 | Global::hideInputMethod(); |
2696 | #endif | 2696 | #endif |
2697 | reader->setFocus(); | 2697 | reader->setFocus(); |
2698 | } | 2698 | } |
2699 | 2699 | ||
2700 | #ifdef __ISEARCH | 2700 | #ifdef __ISEARCH |
2701 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) | 2701 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) |
2702 | #else | 2702 | #else |
2703 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | 2703 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) |
2704 | #endif | 2704 | #endif |
2705 | { | 2705 | { |
2706 | bool ret = true; | 2706 | bool ret = true; |
2707 | unsigned long fs, ts; | 2707 | unsigned long fs, ts; |
2708 | reader->sizes(fs,ts); | 2708 | reader->sizes(fs,ts); |
2709 | size_t pos = reader->locate(); | 2709 | size_t pos = reader->locate(); |
2710 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); | 2710 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); |
2711 | pbar->show(); | 2711 | pbar->show(); |
2712 | pbar->raise(); | 2712 | pbar->raise(); |
2713 | pbar->reset(); | 2713 | pbar->reset(); |
2714 | int offset; | 2714 | int offset; |
2715 | int lastpc = (100*pos)/ts; | 2715 | int lastpc = (100*pos)/ts; |
2716 | pbar->setProgress(lastpc); | 2716 | pbar->setProgress(lastpc); |
2717 | // qApp->processEvents(); | 2717 | // qApp->processEvents(); |
2718 | if (reader->buffdoc.getpara(test) >= 0) | 2718 | if (reader->buffdoc.getpara(test) >= 0) |
2719 | { | 2719 | { |
2720 | reader->setFocus(); | 2720 | reader->setFocus(); |
2721 | #ifdef __ISEARCH | 2721 | #ifdef __ISEARCH |
2722 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 2722 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
2723 | #else | 2723 | #else |
2724 | #ifdef _UNICODE | 2724 | #ifdef _UNICODE |
2725 | while ((offset = arg.match(toQString(test.data()))) == -1) | 2725 | while ((offset = arg.match(toQString(test.data()))) == -1) |
2726 | #else | 2726 | #else |
2727 | while (arg.match(test.data()) == -1) | 2727 | while (arg.match(test.data()) == -1) |
2728 | #endif | 2728 | #endif |
2729 | #endif | 2729 | #endif |
2730 | { | 2730 | { |
2731 | pos = reader->locate(); | 2731 | pos = reader->locate(); |
2732 | int pc = (100*pos)/ts; | 2732 | int pc = (100*pos)/ts; |
2733 | if (pc != lastpc) | 2733 | if (pc != lastpc) |
2734 | { | 2734 | { |
2735 | pbar->setProgress(pc); | 2735 | pbar->setProgress(pc); |
2736 | qApp->processEvents(); | 2736 | qApp->processEvents(); |
2737 | reader->setFocus(); | 2737 | reader->setFocus(); |
2738 | lastpc = pc; | 2738 | lastpc = pc; |
2739 | } | 2739 | } |
2740 | 2740 | ||
2741 | if (reader->buffdoc.getpara(test) < 0) | 2741 | if (reader->buffdoc.getpara(test) < 0) |
2742 | { | 2742 | { |
2743 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2743 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2744 | pos = searchStart; | 2744 | pos = searchStart; |
2745 | else | 2745 | else |
2746 | pos = start; | 2746 | pos = start; |
2747 | findClose(); | 2747 | findClose(); |
2748 | pbar->hide(); | 2748 | pbar->hide(); |
2749 | reader->locate(pos); | 2749 | reader->locate(pos); |
2750 | return false; | 2750 | return false; |
2751 | } | 2751 | } |
2752 | } | 2752 | } |
2753 | // qDebug("Found it at %u:%u", pos, offset); | 2753 | // qDebug("Found it at %u:%u", pos, offset); |
2754 | pbar->hide(); | 2754 | pbar->hide(); |
2755 | // qDebug("Hid"); | 2755 | // qDebug("Hid"); |
2756 | reader->locate(pos+offset); | 2756 | reader->locate(pos+offset); |
2757 | // qDebug("Loacted"); | 2757 | // qDebug("Loacted"); |
2758 | // qDebug("page up"); | 2758 | // qDebug("page up"); |
2759 | ret = true; | 2759 | ret = true; |
2760 | } | 2760 | } |
2761 | else | 2761 | else |
2762 | { | 2762 | { |
2763 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2763 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2764 | pos = searchStart; | 2764 | pos = searchStart; |
2765 | else | 2765 | else |
2766 | pos = start; | 2766 | pos = start; |
2767 | ret = false; | 2767 | ret = false; |
2768 | findClose(); | 2768 | findClose(); |
2769 | } | 2769 | } |
2770 | return ret; | 2770 | return ret; |
2771 | } | 2771 | } |
2772 | 2772 | ||
2773 | #ifdef __ISEARCH | 2773 | #ifdef __ISEARCH |
2774 | void QTReaderApp::search(const QString & arg) | 2774 | void QTReaderApp::search(const QString & arg) |
2775 | { | 2775 | { |
2776 | searchrecord* ss = searchStack->top(); | 2776 | searchrecord* ss = searchStack->top(); |
2777 | CBuffer test; | 2777 | CBuffer test; |
2778 | size_t start = reader->pagelocate(); | 2778 | size_t start = reader->pagelocate(); |
2779 | bool haspopped = false; | 2779 | bool haspopped = false; |
2780 | while (arg.left(ss->s.length()) != ss->s) | 2780 | while (arg.left(ss->s.length()) != ss->s) |
2781 | { | 2781 | { |
2782 | haspopped = true; | 2782 | haspopped = true; |
2783 | start = ss->pos; | 2783 | start = ss->pos; |
2784 | // reader->locate(start); | 2784 | // reader->locate(start); |
2785 | searchStack->pop(); | 2785 | searchStack->pop(); |
2786 | delete ss; | 2786 | delete ss; |
2787 | } | 2787 | } |
2788 | if (haspopped) reader->locate(start); | 2788 | if (haspopped) reader->locate(start); |
2789 | /* | 2789 | /* |
2790 | if (arg.length() < ss->len) | 2790 | if (arg.length() < ss->len) |
2791 | { | 2791 | { |
2792 | start = ss->pos; | 2792 | start = ss->pos; |
2793 | reader->locate(start); | 2793 | reader->locate(start); |
2794 | searchStack->pop(); | 2794 | searchStack->pop(); |
2795 | delete ss; | 2795 | delete ss; |
2796 | } | 2796 | } |
2797 | */ | 2797 | */ |
2798 | else | 2798 | else |
2799 | { | 2799 | { |
2800 | start = reader->pagelocate(); | 2800 | start = reader->pagelocate(); |
2801 | reader->jumpto(start); | 2801 | reader->jumpto(start); |
2802 | searchStack->push(new searchrecord(arg,start)); | 2802 | searchStack->push(new searchrecord(arg,start)); |
2803 | } | 2803 | } |
2804 | dosearch(start, test, arg); | 2804 | dosearch(start, test, arg); |
2805 | } | 2805 | } |
2806 | #else | 2806 | #else |
2807 | void QTReaderApp::search() | 2807 | void QTReaderApp::search() |
2808 | { | 2808 | { |
2809 | findNext(); | 2809 | findNext(); |
2810 | } | 2810 | } |
2811 | #endif | 2811 | #endif |
2812 | 2812 | ||
2813 | void QTReaderApp::openFile( const QString &f, unsigned int loc ) | 2813 | void QTReaderApp::openFile( const QString &f, unsigned int loc ) |
2814 | { | 2814 | { |
2815 | // qDebug("File:%s", (const char*)f); | 2815 | // qDebug("File:%s", (const char*)f); |
2816 | // openFile(DocLnk(f)); | 2816 | // openFile(DocLnk(f)); |
2817 | //} | 2817 | //} |
2818 | // | 2818 | // |
2819 | //void QTReaderApp::openFile( const DocLnk &f ) | 2819 | //void QTReaderApp::openFile( const DocLnk &f ) |
2820 | //{ | 2820 | //{ |
2821 | clear(); | 2821 | clear(); |
2822 | QFileInfo fm(f); | 2822 | QFileInfo fm(f); |
2823 | if ( fm.exists() ) | 2823 | if ( fm.exists() ) |
2824 | { | 2824 | { |
2825 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 2825 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
2826 | #ifdef USEQPE | 2826 | #ifdef USEQPE |
2827 | if (fm.extension( FALSE ) == "desktop") | 2827 | if (fm.extension( FALSE ) == "desktop") |
2828 | { | 2828 | { |
2829 | DocLnk d(f); | 2829 | DocLnk d(f); |
2830 | QFileInfo fnew(d.file()); | 2830 | QFileInfo fnew(d.file()); |
2831 | fm = fnew; | 2831 | fm = fnew; |
2832 | if (!fm.exists()) return; | 2832 | if (!fm.exists()) return; |
2833 | } | 2833 | } |
2834 | #endif | 2834 | #endif |
2835 | clear(); | 2835 | clear(); |
2836 | reader->setText(fm.baseName(), fm.absFilePath(), loc); | 2836 | reader->setText(fm.baseName(), fm.absFilePath(), loc); |
2837 | m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); | 2837 | m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); |
2838 | qDebug("Showing tools"); | 2838 | qDebug("Showing tools"); |
2839 | showEditTools(); | 2839 | showEditTools(); |
2840 | qDebug("Shown tools"); | 2840 | qDebug("Shown tools"); |
2841 | readbkmks(); | 2841 | readbkmks(); |
2842 | qDebug("read markss"); | 2842 | qDebug("read markss"); |
2843 | m_savedpos = 0xffffffff; | 2843 | m_savedpos = 0xffffffff; |
2844 | } | 2844 | } |
2845 | else | 2845 | else |
2846 | { | 2846 | { |
2847 | QString msg = f; | 2847 | QString msg = f; |
2848 | msg += "\nFile does not exist"; | 2848 | msg += "\nFile does not exist"; |
2849 | QMessageBox::information(this, PROGNAME, msg); | 2849 | QMessageBox::information(this, PROGNAME, msg); |
2850 | reader->m_lastfile = QString::null; | 2850 | reader->m_lastfile = QString::null; |
2851 | } | 2851 | } |
2852 | 2852 | ||
2853 | } | 2853 | } |
2854 | /* | 2854 | /* |
2855 | void QTReaderApp::resizeEvent(QResizeEvent* e) | 2855 | void QTReaderApp::resizeEvent(QResizeEvent* e) |
2856 | { | 2856 | { |
2857 | if (m_fullscreen) | 2857 | if (m_fullscreen) |
2858 | { | 2858 | { |
2859 | showNormal(); | 2859 | showNormal(); |
2860 | showFullScreen(); | 2860 | showFullScreen(); |
2861 | } | 2861 | } |
2862 | } | 2862 | } |
2863 | */ | 2863 | */ |
2864 | void QTReaderApp::handlekey(QKeyEvent* e) | 2864 | void QTReaderApp::handlekey(QKeyEvent* e) |
2865 | { | 2865 | { |
2866 | // qDebug("Keypress event"); | 2866 | // qDebug("Keypress event"); |
2867 | timeb now; | 2867 | timeb now; |
2868 | ftime(&now); | 2868 | ftime(&now); |
2869 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; | 2869 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; |
2870 | if (etime < m_debounce) | 2870 | if (etime < m_debounce) |
2871 | { | 2871 | { |
2872 | return; | 2872 | return; |
2873 | } | 2873 | } |
2874 | switch(e->key()) | 2874 | switch(e->key()) |
2875 | { | 2875 | { |
2876 | case Key_Escape: | 2876 | case Key_Escape: |
2877 | qDebug("escape event"); | 2877 | qDebug("escape event"); |
2878 | if (m_disableesckey) | 2878 | if (m_disableesckey) |
2879 | { | 2879 | { |
2880 | m_disableesckey = false; | 2880 | m_disableesckey = false; |
2881 | } | 2881 | } |
2882 | else | 2882 | else |
2883 | { | 2883 | { |
2884 | m_bcloseDisabled = true; | 2884 | m_bcloseDisabled = true; |
2885 | if (m_fullscreen) | 2885 | if (m_fullscreen) |
2886 | { | 2886 | { |
2887 | m_actFullscreen->setOn(false); | 2887 | m_actFullscreen->setOn(false); |
2888 | e->accept(); | 2888 | e->accept(); |
2889 | } | 2889 | } |
2890 | else | 2890 | else |
2891 | { | 2891 | { |
2892 | // qDebug("escape action"); | 2892 | // qDebug("escape action"); |
2893 | doAction(e); | 2893 | doAction(e); |
2894 | } | 2894 | } |
2895 | } | 2895 | } |
2896 | break; | 2896 | break; |
2897 | /* | 2897 | /* |
2898 | case Key_Left: | 2898 | case Key_Left: |
2899 | { | 2899 | { |
2900 | if (reader->m_autoScroll) | 2900 | if (reader->m_autoScroll) |
2901 | { | 2901 | { |
2902 | reader->reduceScroll(); | 2902 | reader->reduceScroll(); |
2903 | } | 2903 | } |
2904 | else | 2904 | else |
2905 | { | 2905 | { |
2906 | doAction(e); | 2906 | doAction(e); |
2907 | } | 2907 | } |
2908 | } | 2908 | } |
2909 | break; | 2909 | break; |
2910 | case Key_Right: | 2910 | case Key_Right: |
2911 | { | 2911 | { |
2912 | if (reader->m_autoScroll) | 2912 | if (reader->m_autoScroll) |
2913 | { | 2913 | { |
2914 | reader->increaseScroll(); | 2914 | reader->increaseScroll(); |
2915 | } | 2915 | } |
2916 | else | 2916 | else |
2917 | { | 2917 | { |
2918 | doAction(e); | 2918 | doAction(e); |
2919 | } | 2919 | } |
2920 | } | 2920 | } |
2921 | break; | 2921 | break; |
2922 | case Key_Up: | 2922 | case Key_Up: |
2923 | { | 2923 | { |
2924 | if (reader->m_autoScroll) | 2924 | if (reader->m_autoScroll) |
2925 | { | 2925 | { |
2926 | reader->increaseScroll(); | 2926 | reader->increaseScroll(); |
2927 | } | 2927 | } |
2928 | else | 2928 | else |
2929 | { | 2929 | { |
2930 | doAction(e); | 2930 | doAction(e); |
2931 | } | 2931 | } |
2932 | } | 2932 | } |
2933 | break; | 2933 | break; |
2934 | case Key_Down: | 2934 | case Key_Down: |
2935 | { | 2935 | { |
2936 | if (reader->m_autoScroll) | 2936 | if (reader->m_autoScroll) |
2937 | { | 2937 | { |
2938 | reader->reduceScroll(); | 2938 | reader->reduceScroll(); |
2939 | } | 2939 | } |
2940 | else | 2940 | else |
2941 | { | 2941 | { |
2942 | doAction(e); | 2942 | doAction(e); |
2943 | } | 2943 | } |
2944 | } | 2944 | } |
2945 | break; | 2945 | break; |