summaryrefslogtreecommitdiff
authorpohly <pohly>2005-05-08 16:13:24 (UTC)
committer pohly <pohly>2005-05-08 16:13:24 (UTC)
commitea889d21f3b5bf846ff20a6fad9a756108a28ad7 (patch) (unidiff)
tree3d0462ccf147fb95886657d8bb610caa168e01ea
parent2ccb0ad8b77eb3c62914f5df5b1bba3becb83617 (diff)
downloadopie-ea889d21f3b5bf846ff20a6fad9a756108a28ad7.zip
opie-ea889d21f3b5bf846ff20a6fad9a756108a28ad7.tar.gz
opie-ea889d21f3b5bf846ff20a6fad9a756108a28ad7.tar.bz2
code change by tim: ask the user to confirm the remapping of the ESC key
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 6753698..8ef0674 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -2137,2049 +2137,2054 @@ void QTReaderApp::showprefs()
2137 m_twoTouch = prefwin->twotouch(); 2137 m_twoTouch = prefwin->twotouch();
2138 reader->setTwoTouch(m_twoTouch); 2138 reader->setTwoTouch(m_twoTouch);
2139 m_touch_action->setOn(m_twoTouch); 2139 m_touch_action->setOn(m_twoTouch);
2140 2140
2141 reader->bstripcr = prefwin->StripCR(); 2141 reader->bstripcr = prefwin->StripCR();
2142 reader->bNoInlineTables = !prefwin->InlineTables(); 2142 reader->bNoInlineTables = !prefwin->InlineTables();
2143 reader->bdehyphen = prefwin->Dehyphen(); 2143 reader->bdehyphen = prefwin->Dehyphen();
2144 reader->bonespace = prefwin->SingleSpace(); 2144 reader->bonespace = prefwin->SingleSpace();
2145 reader->bunindent = prefwin->Unindent(); 2145 reader->bunindent = prefwin->Unindent();
2146 reader->brepara = prefwin->Reparagraph(); 2146 reader->brepara = prefwin->Reparagraph();
2147 reader->bdblspce = prefwin->DoubleSpace(); 2147 reader->bdblspce = prefwin->DoubleSpace();
2148 reader->bremap = prefwin->Remap(); 2148 reader->bremap = prefwin->Remap();
2149 reader->bmakebold = prefwin->Embolden(); 2149 reader->bmakebold = prefwin->Embolden();
2150 reader->bfulljust = prefwin->FullJustify(); 2150 reader->bfulljust = prefwin->FullJustify();
2151 //if (reader->bInverse != prefwin->Inverse()) reader->setInverse(prefwin->Inverse()); 2151 //if (reader->bInverse != prefwin->Inverse()) reader->setInverse(prefwin->Inverse());
2152 //if (reader->bNegative != prefwin->Negative()) reader->setNegative(); 2152 //if (reader->bNegative != prefwin->Negative()) reader->setNegative();
2153 reader->m_fontControl.FixGraphics(prefwin->FixGraphics()); 2153 reader->m_fontControl.FixGraphics(prefwin->FixGraphics());
2154 2154
2155 reader->setextraspace(prefwin->ParaLead()); 2155 reader->setextraspace(prefwin->ParaLead());
2156 reader->setlead(prefwin->LineLead()); 2156 reader->setlead(prefwin->LineLead());
2157 reader->m_abstopmargin = prefwin->TopMargin(); 2157 reader->m_abstopmargin = prefwin->TopMargin();
2158 reader->m_absbottommargin = prefwin->BottomMargin(); 2158 reader->m_absbottommargin = prefwin->BottomMargin();
2159 reader->m_absleft_border = prefwin->LeftMargin(); 2159 reader->m_absleft_border = prefwin->LeftMargin();
2160 reader->m_absright_border = prefwin->RightMargin(); 2160 reader->m_absright_border = prefwin->RightMargin();
2161 reader->bindenter = prefwin->Indent(); 2161 reader->bindenter = prefwin->Indent();
2162 reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; 2162 reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false;
2163 switch (prefwin->Markup()) 2163 switch (prefwin->Markup())
2164 { 2164 {
2165 case 0: 2165 case 0:
2166 reader->bautofmt = true; 2166 reader->bautofmt = true;
2167 break; 2167 break;
2168 case 1: 2168 case 1:
2169 break; 2169 break;
2170 case 2: 2170 case 2:
2171 reader->btextfmt = true; 2171 reader->btextfmt = true;
2172 break; 2172 break;
2173 case 3: 2173 case 3:
2174 reader->bstriphtml = true; 2174 reader->bstriphtml = true;
2175 break; 2175 break;
2176 case 4: 2176 case 4:
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
2240void QTReaderApp::showtoolbarprefs() 2240void 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
2322void QTReaderApp::showinfo() 2322void 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
2375void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) 2375void 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
2407void QTReaderApp::addAnno(const QString& name, const QString& text) 2407void 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
2455bool QTReaderApp::findNextBookmark(size_t start) 2455bool 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
2473void QTReaderApp::addanno() 2473void 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
2494void QTReaderApp::infoClose() 2494void 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/*
2529void QTReaderApp::fileRevert() 2529void QTReaderApp::fileRevert()
2530{ 2530{
2531 clear(); 2531 clear();
2532 fileOpen(); 2532 fileOpen();
2533} 2533}
2534 2534
2535void QTReaderApp::editCut() 2535void 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*/
2542void QTReaderApp::editMark() 2542void QTReaderApp::editMark()
2543{ 2543{
2544 m_savedpos = reader->pagelocate(); 2544 m_savedpos = reader->pagelocate();
2545} 2545}
2546 2546
2547void QTReaderApp::editCopy() 2547void 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 += 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
2568void QTReaderApp::gotoStart() 2568void QTReaderApp::gotoStart()
2569{ 2569{
2570 reader->locate(reader->buffdoc.startSection()); 2570 reader->locate(reader->buffdoc.startSection());
2571} 2571}
2572 2572
2573void QTReaderApp::gotoEnd() 2573void QTReaderApp::gotoEnd()
2574{ 2574{
2575 reader->dopageup(reader->buffdoc.endSection()); 2575 reader->dopageup(reader->buffdoc.endSection());
2576} 2576}
2577 2577
2578void QTReaderApp::pageup() 2578void QTReaderApp::pageup()
2579{ 2579{
2580 reader->NavUp(); 2580 reader->NavUp();
2581} 2581}
2582 2582
2583void QTReaderApp::pagedn() 2583void QTReaderApp::pagedn()
2584{ 2584{
2585 reader->NavDown(); 2585 reader->NavDown();
2586} 2586}
2587 2587
2588void QTReaderApp::pagemode(bool _b) 2588void QTReaderApp::pagemode(bool _b)
2589{ 2589{
2590 reader->setpagemode(_b); 2590 reader->setpagemode(_b);
2591} 2591}
2592 2592
2593/* 2593/*
2594void QTReaderApp::setspacing() 2594void 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*/
2603void QTReaderApp::settarget() 2603void 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/*
2614void QTReaderApp::do_mono(const QString& lcn) 2614void 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/*
2630void QTReaderApp::editPaste() 2630void 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
2638void QTReaderApp::editFind() 2638void 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
2655void QTReaderApp::findNext() 2655void 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
2670void QTReaderApp::findClose() 2670void 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
2689void QTReaderApp::regClose() 2689void 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
2701bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) 2701bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg)
2702#else 2702#else
2703bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) 2703bool 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
2774void QTReaderApp::search(const QString & arg) 2774void 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
2807void QTReaderApp::search() 2807void QTReaderApp::search()
2808{ 2808{
2809 findNext(); 2809 findNext();
2810} 2810}
2811#endif 2811#endif
2812 2812
2813void QTReaderApp::openFile( const QString &f, unsigned int loc ) 2813void 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/*
2855void QTReaderApp::resizeEvent(QResizeEvent* e) 2855void 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*/
2864void QTReaderApp::handlekey(QKeyEvent* e) 2864void 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;
2946 */ 2946 */
2947 default: 2947 default:
2948 { 2948 {
2949 doAction(e); 2949 doAction(e);
2950 } 2950 }
2951 2951
2952/* 2952/*
2953 QString msg("Key press was:"); 2953 QString msg("Key press was:");
2954 QString key; 2954 QString key;
2955 msg += key.setNum(e->key()); 2955 msg += key.setNum(e->key());
2956 QMessageBox::information(this, PROGNAME, msg); 2956 QMessageBox::information(this, PROGNAME, msg);
2957*/ 2957*/
2958 } 2958 }
2959 ftime(&m_lastkeytime); 2959 ftime(&m_lastkeytime);
2960} 2960}
2961 2961
2962#if defined(USEQPE) && defined(USENEWFULLSCREEN) 2962#if defined(USEQPE) && defined(USENEWFULLSCREEN)
2963void QTReaderApp::focusInEvent(QFocusEvent *) 2963void QTReaderApp::focusInEvent(QFocusEvent *)
2964{ 2964{
2965 if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader)) 2965 if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader))
2966 { 2966 {
2967 m_usenewfullscreen = false; 2967 m_usenewfullscreen = false;
2968 reader->bDoUpdates = false; 2968 reader->bDoUpdates = false;
2969 showEditTools(); 2969 showEditTools();
2970 reader->bDoUpdates = true; 2970 reader->bDoUpdates = true;
2971 reader->update(); 2971 reader->update();
2972 m_usenewfullscreen = true; 2972 m_usenewfullscreen = true;
2973 } 2973 }
2974} 2974}
2975 2975
2976void QTReaderApp::resizeEvent(QResizeEvent *) 2976void QTReaderApp::resizeEvent(QResizeEvent *)
2977{ 2977{
2978 if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader)) 2978 if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader))
2979 { 2979 {
2980 m_usenewfullscreen = false; 2980 m_usenewfullscreen = false;
2981 reader->bDoUpdates = false; 2981 reader->bDoUpdates = false;
2982 showEditTools(); 2982 showEditTools();
2983 reader->bDoUpdates = true; 2983 reader->bDoUpdates = true;
2984 reader->update(); 2984 reader->update();
2985 m_usenewfullscreen = true; 2985 m_usenewfullscreen = true;
2986 } 2986 }
2987} 2987}
2988#endif 2988#endif
2989 2989
2990void QTReaderApp::showEditTools() 2990void QTReaderApp::showEditTools()
2991{ 2991{
2992// if ( !doc ) 2992// if ( !doc )
2993 //close(); 2993 //close();
2994 if (m_fullscreen) 2994 if (m_fullscreen)
2995 { 2995 {
2996#if defined(USEQPE) 2996#if defined(USEQPE)
2997 if (menubar != NULL) menubar->hide(); 2997 if (menubar != NULL) menubar->hide();
2998#endif 2998#endif
2999 if (fileBar != NULL) fileBar->hide(); 2999 if (fileBar != NULL) fileBar->hide();
3000 if (viewBar != NULL) viewBar->hide(); 3000 if (viewBar != NULL) viewBar->hide();
3001 if (navBar != NULL) navBar->hide(); 3001 if (navBar != NULL) navBar->hide();
3002 if (markBar != NULL) markBar->hide(); 3002 if (markBar != NULL) markBar->hide();
3003 if (m_prog != NULL) 3003 if (m_prog != NULL)
3004 { 3004 {
3005 // qDebug("Hiding status"); 3005 // qDebug("Hiding status");
3006 m_prog->hide(); 3006 m_prog->hide();
3007 } 3007 }
3008 searchBar->hide(); 3008 searchBar->hide();
3009 regBar->hide(); 3009 regBar->hide();
3010#ifdef USEQPE 3010#ifdef USEQPE
3011 Global::hideInputMethod(); 3011 Global::hideInputMethod();
3012#endif 3012#endif
3013 if (m_scrollbar != NULL) m_scrollbar->hide(); 3013 if (m_scrollbar != NULL) m_scrollbar->hide();
3014 m_fontBar->hide(); 3014 m_fontBar->hide();
3015 //showNormal(); 3015 //showNormal();
3016 showFullScreen(); 3016 showFullScreen();
3017 } 3017 }
3018 else 3018 else
3019 { 3019 {
3020 //qDebug("him"); 3020 //qDebug("him");
3021#ifdef USEQPE 3021#ifdef USEQPE
3022 Global::hideInputMethod(); 3022 Global::hideInputMethod();
3023#endif 3023#endif
3024 //qDebug("eb"); 3024 //qDebug("eb");
3025 if (m_scrollbar != NULL) 3025 if (m_scrollbar != NULL)
3026 { 3026 {
3027 if (m_scrollishidden) 3027 if (m_scrollishidden)
3028 { 3028 {
3029 m_scrollbar->hide(); 3029 m_scrollbar->hide();
3030 } 3030 }
3031 else 3031 else
3032 { 3032 {
3033 m_scrollbar->show(); 3033 m_scrollbar->show();
3034 } 3034 }
3035 } 3035 }
3036 if (!m_hidebars) 3036 if (!m_hidebars)
3037 { 3037 {
3038#if defined(USEQPE) 3038#if defined(USEQPE)
3039 menubar->show(); 3039 menubar->show();
3040#endif 3040#endif
3041 if (fileBar != NULL) fileBar->show(); 3041 if (fileBar != NULL) fileBar->show();
3042 if (viewBar != NULL) viewBar->show(); 3042 if (viewBar != NULL) viewBar->show();
3043 if (navBar != NULL) navBar->show(); 3043 if (navBar != NULL) navBar->show();
3044 if (markBar != NULL) markBar->show(); 3044 if (markBar != NULL) markBar->show();
3045 if (m_prog != NULL && !m_statusishidden) 3045 if (m_prog != NULL && !m_statusishidden)
3046 { 3046 {
3047 // qDebug("Showing status"); 3047 // qDebug("Showing status");
3048 m_prog->show(); 3048 m_prog->show();
3049 // qDebug("Shown status"); 3049 // qDebug("Shown status");
3050 } 3050 }
3051 // qDebug("Showing mb"); 3051 // qDebug("Showing mb");
3052 mb->show(); 3052 mb->show();
3053 } 3053 }
3054 if ( searchVisible ) 3054 if ( searchVisible )
3055 { 3055 {
3056#ifdef USEQPE 3056#ifdef USEQPE
3057 Global::showInputMethod(); 3057 Global::showInputMethod();
3058#endif 3058#endif
3059 searchBar->show(); 3059 searchBar->show();
3060 } 3060 }
3061 if ( regVisible ) 3061 if ( regVisible )
3062 { 3062 {
3063#ifdef USEQPE 3063#ifdef USEQPE
3064 Global::showInputMethod(); 3064 Global::showInputMethod();
3065#endif 3065#endif
3066 regBar->show(); 3066 regBar->show();
3067 } 3067 }
3068 if (m_fontVisible) m_fontBar->show(); 3068 if (m_fontVisible) m_fontBar->show();
3069 //qDebug("sn"); 3069 //qDebug("sn");
3070 showNormal(); 3070 showNormal();
3071 //qDebug("sm"); 3071 //qDebug("sm");
3072#if defined(USEQPE) && !defined(SIMPAD) 3072#if defined(USEQPE) && !defined(SIMPAD)
3073 showMaximized(); 3073 showMaximized();
3074#endif 3074#endif
3075 //setCentralWidget(reader); 3075 //setCentralWidget(reader);
3076 } 3076 }
3077 3077
3078 // qDebug("uc"); 3078 // qDebug("uc");
3079 updateCaption(); 3079 updateCaption();
3080 // qDebug("rw"); 3080 // qDebug("rw");
3081 editorStack->raiseWidget( reader ); 3081 editorStack->raiseWidget( reader );
3082 // qDebug("sf"); 3082 // qDebug("sf");
3083 reader->setFocus(); 3083 reader->setFocus();
3084 // qDebug("ref"); 3084 // qDebug("ref");
3085 //reader->refresh(true); 3085 //reader->refresh(true);
3086 // qDebug("done"); 3086 // qDebug("done");
3087} 3087}
3088/* 3088/*
3089void QTReaderApp::save() 3089void QTReaderApp::save()
3090{ 3090{
3091 if ( !doc ) 3091 if ( !doc )
3092 return; 3092 return;
3093 if ( !editor->edited() ) 3093 if ( !editor->edited() )
3094 return; 3094 return;
3095 3095
3096 QString rt = editor->text(); 3096 QString rt = editor->text();
3097 QString pt = rt; 3097 QString pt = rt;
3098 3098
3099 if ( doc->name().isEmpty() ) { 3099 if ( doc->name().isEmpty() ) {
3100 unsigned ispace = pt.find( ' ' ); 3100 unsigned ispace = pt.find( ' ' );
3101 unsigned ienter = pt.find( '\n' ); 3101 unsigned ienter = pt.find( '\n' );
3102 int i = (ispace < ienter) ? ispace : ienter; 3102 int i = (ispace < ienter) ? ispace : ienter;
3103 QString docname; 3103 QString docname;
3104 if ( i == -1 ) { 3104 if ( i == -1 ) {
3105 if ( pt.isEmpty() ) 3105 if ( pt.isEmpty() )
3106 docname = "Empty Text"; 3106 docname = "Empty Text";
3107 else 3107 else
3108 docname = pt; 3108 docname = pt;
3109 } else { 3109 } else {
3110 docname = pt.left( i ); 3110 docname = pt.left( i );
3111 } 3111 }
3112 doc->setName(docname); 3112 doc->setName(docname);
3113 } 3113 }
3114 FileManager fm; 3114 FileManager fm;
3115 fm.saveFile( *doc, rt ); 3115 fm.saveFile( *doc, rt );
3116} 3116}
3117*/ 3117*/
3118 3118
3119void QTReaderApp::clear() 3119void QTReaderApp::clear()
3120{ 3120{
3121// if (doc != 0) 3121// if (doc != 0)
3122// { 3122// {
3123// QMessageBox::information(this, PROGNAME, "Deleting doc", 1); 3123// QMessageBox::information(this, PROGNAME, "Deleting doc", 1);
3124 //delete doc; 3124 //delete doc;
3125// QMessageBox::information(this, PROGNAME, "Deleted doc", 1); 3125// QMessageBox::information(this, PROGNAME, "Deleted doc", 1);
3126 //doc = 0; 3126 //doc = 0;
3127 // } 3127 // }
3128 reader->clear(); 3128 reader->clear();
3129} 3129}
3130 3130
3131void QTReaderApp::updateCaption() 3131void QTReaderApp::updateCaption()
3132{ 3132{
3133// if ( !doc ) 3133// if ( !doc )
3134 //setCaption( tr("QTReader") ); 3134 //setCaption( tr("QTReader") );
3135// else { 3135// else {
3136 //QString s = doc->name(); 3136 //QString s = doc->name();
3137 //if ( s.isEmpty() ) 3137 //if ( s.isEmpty() )
3138 // s = tr( "Unnamed" ); 3138 // s = tr( "Unnamed" );
3139 setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); 3139 setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) );
3140// } 3140// }
3141} 3141}
3142 3142
3143void QTReaderApp::setDocument(const QString& fileref) 3143void QTReaderApp::setDocument(const QString& fileref)
3144{ 3144{
3145//QMessageBox::information(0, "setDocument", fileref); 3145//QMessageBox::information(0, "setDocument", fileref);
3146 openFile(fileref); 3146 openFile(fileref);
3147// showEditTools(); 3147// showEditTools();
3148} 3148}
3149 3149
3150void QTReaderApp::closeEvent( QCloseEvent *e ) 3150void QTReaderApp::closeEvent( QCloseEvent *e )
3151{ 3151{
3152// qDebug("Close event"); 3152// qDebug("Close event");
3153 if (m_fullscreen) 3153 if (m_fullscreen)
3154 { 3154 {
3155 m_fullscreen = false; 3155 m_fullscreen = false;
3156 showEditTools(); 3156 showEditTools();
3157 e->ignore(); 3157 e->ignore();
3158 } 3158 }
3159 else if (editorStack->visibleWidget() == m_buttonprefs) 3159 else if (editorStack->visibleWidget() == m_buttonprefs)
3160 { 3160 {
3161 m_buttonprefs->mapkey(Qt::NoButton, Key_Escape); 3161 int ret = QMessageBox::warning(this, PROGNAME,
3162tr("Do you wish to map this key?\n\nIf you proceed you will map\nthe escape key and you will\nneed to press the close box\ntwice to exit this program\n\nContinue?"), tr("Yes"), tr("No"), QString::null, 0, 1);
3163 if (ret == 0)
3164 {
3165 m_buttonprefs->mapkey(Qt::NoButton, Key_Escape);
3166 }
3162 e->ignore(); 3167 e->ignore();
3163 } 3168 }
3164 else if (m_dontSave) 3169 else if (m_dontSave)
3165 { 3170 {
3166 e->accept(); 3171 e->accept();
3167 } 3172 }
3168 else 3173 else
3169 { 3174 {
3170 if (editorStack->visibleWidget() == reader) 3175 if (editorStack->visibleWidget() == reader)
3171 { 3176 {
3172 if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled) 3177 if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled)
3173 { 3178 {
3174 //qDebug("Close disabled"); 3179 //qDebug("Close disabled");
3175 m_bcloseDisabled = false; 3180 m_bcloseDisabled = false;
3176 e->ignore(); 3181 e->ignore();
3177 } 3182 }
3178 else 3183 else
3179 { 3184 {
3180 if (m_fontVisible) 3185 if (m_fontVisible)
3181 { 3186 {
3182 m_fontBar->hide(); 3187 m_fontBar->hide();
3183 m_fontVisible = false; 3188 m_fontVisible = false;
3184 e->ignore(); 3189 e->ignore();
3185 return; 3190 return;
3186 } 3191 }
3187 if (regVisible) 3192 if (regVisible)
3188 { 3193 {
3189 regBar->hide(); 3194 regBar->hide();
3190#ifdef USEQPE 3195#ifdef USEQPE
3191 Global::hideInputMethod(); 3196 Global::hideInputMethod();
3192#endif 3197#endif
3193 regVisible = false; 3198 regVisible = false;
3194 e->ignore(); 3199 e->ignore();
3195 return; 3200 return;
3196 } 3201 }
3197 if (searchVisible) 3202 if (searchVisible)
3198 { 3203 {
3199 searchBar->hide(); 3204 searchBar->hide();
3200#ifdef USEQPE 3205#ifdef USEQPE
3201 Global::hideInputMethod(); 3206 Global::hideInputMethod();
3202#endif 3207#endif
3203 searchVisible = false; 3208 searchVisible = false;
3204 e->ignore(); 3209 e->ignore();
3205 return; 3210 return;
3206 } 3211 }
3207 if (m_fBkmksChanged && pBkmklist != NULL) 3212 if (m_fBkmksChanged && pBkmklist != NULL)
3208 { 3213 {
3209 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) 3214 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
3210 savebkmks(); 3215 savebkmks();
3211 delete pBkmklist; 3216 delete pBkmklist;
3212 reader->pBkmklist = pBkmklist = NULL; 3217 reader->pBkmklist = pBkmklist = NULL;
3213 m_fBkmksChanged = false; 3218 m_fBkmksChanged = false;
3214 } 3219 }
3215 updatefileinfo(); 3220 updatefileinfo();
3216 saveprefs(); 3221 saveprefs();
3217 e->accept(); 3222 e->accept();
3218 } 3223 }
3219 } 3224 }
3220 else 3225 else
3221 { 3226 {
3222 showEditTools(); 3227 showEditTools();
3223 m_disableesckey = true; 3228 m_disableesckey = true;
3224 } 3229 }
3225 } 3230 }
3226} 3231}
3227 3232
3228void QTReaderApp::do_gotomark() 3233void QTReaderApp::do_gotomark()
3229{ 3234{
3230 m_nBkmkAction = cGotoBkmk; 3235 m_nBkmkAction = cGotoBkmk;
3231 if (!listbkmk(pBkmklist)) 3236 if (!listbkmk(pBkmklist))
3232 QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); 3237 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
3233} 3238}
3234 3239
3235void QTReaderApp::do_delmark() 3240void QTReaderApp::do_delmark()
3236{ 3241{
3237 m_nBkmkAction = cDelBkmk; 3242 m_nBkmkAction = cDelBkmk;
3238 if (!listbkmk(pBkmklist)) 3243 if (!listbkmk(pBkmklist))
3239 QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); 3244 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
3240} 3245}
3241 3246
3242bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel) 3247bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel)
3243{ 3248{
3244 bkmkselector->clear(); 3249 bkmkselector->clear();
3245 if (_lab.isEmpty()) 3250 if (_lab.isEmpty())
3246 bkmkselector->setText("Cancel"); 3251 bkmkselector->setText("Cancel");
3247 else 3252 else
3248 bkmkselector->setText(_lab); 3253 bkmkselector->setText(_lab);
3249 int cnt = 0; 3254 int cnt = 0;
3250 int slt = -1; 3255 int slt = -1;
3251 if (plist != NULL) 3256 if (plist != NULL)
3252 { 3257 {
3253 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) 3258 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++)
3254 { 3259 {
3255 if (presel) 3260 if (presel)
3256 { 3261 {
3257 Bkmk* p = i.pContent(); 3262 Bkmk* p = i.pContent();
3258 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) 3263 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
3259 { 3264 {
3260 slt = cnt; 3265 slt = cnt;
3261 } 3266 }
3262 } 3267 }
3263#ifdef _UNICODE 3268#ifdef _UNICODE
3264 // qDebug("Item:%s", (const char*)toQString(i->name())); 3269 // qDebug("Item:%s", (const char*)toQString(i->name()));
3265 bkmkselector->insertItem(toQString(i->name()), cnt++); 3270 bkmkselector->insertItem(toQString(i->name()), cnt++);
3266#else 3271#else
3267 bkmkselector->insertItem(i->name(), cnt++); 3272 bkmkselector->insertItem(i->name(), cnt++);
3268#endif 3273#endif
3269 3274
3270 } 3275 }
3271 } 3276 }
3272 if (cnt > 0) 3277 if (cnt > 0)
3273 { 3278 {
3274 hidetoolbars(); 3279 hidetoolbars();
3275 editorStack->raiseWidget( bkmkselector ); 3280 editorStack->raiseWidget( bkmkselector );
3276 if (slt != -1) bkmkselector->setCurrentItem(slt); 3281 if (slt != -1) bkmkselector->setCurrentItem(slt);
3277 return true; 3282 return true;
3278 } 3283 }
3279 else 3284 else
3280 return false; 3285 return false;
3281} 3286}
3282 3287
3283void QTReaderApp::do_autogen() 3288void QTReaderApp::do_autogen()
3284{ 3289{
3285 m_nRegAction = cAutoGen; 3290 m_nRegAction = cAutoGen;
3286 regEdit->setText(m_autogenstr); 3291 regEdit->setText(m_autogenstr);
3287 do_regedit(); 3292 do_regedit();
3288} 3293}
3289 3294
3290void QTReaderApp::do_regedit() 3295void QTReaderApp::do_regedit()
3291{ 3296{
3292// fileBar->hide(); 3297// fileBar->hide();
3293 reader->bDoUpdates = false; 3298 reader->bDoUpdates = false;
3294// qDebug("Showing regbar"); 3299// qDebug("Showing regbar");
3295 regBar->show(); 3300 regBar->show();
3296// qDebug("Showing kbd"); 3301// qDebug("Showing kbd");
3297#ifdef USEQPE 3302#ifdef USEQPE
3298 Global::showInputMethod(); 3303 Global::showInputMethod();
3299#endif 3304#endif
3300 regVisible = true; 3305 regVisible = true;
3301 regEdit->setFocus(); 3306 regEdit->setFocus();
3302// qApp->processEvents(); 3307// qApp->processEvents();
3303 reader->bDoUpdates = true; 3308 reader->bDoUpdates = true;
3304 reader->update(); 3309 reader->update();
3305} 3310}
3306 3311
3307bool QTReaderApp::openfrombkmk(Bkmk* bk) 3312bool QTReaderApp::openfrombkmk(Bkmk* bk)
3308{ 3313{
3309 QString fn = toQString( 3314 QString fn = toQString(
3310 CFiledata(bk->anno()).name() 3315 CFiledata(bk->anno()).name()
3311 ); 3316 );
3312 //qDebug("fileinfo"); 3317 //qDebug("fileinfo");
3313 if (!fn.isEmpty() && QFileInfo(fn).isFile()) 3318 if (!fn.isEmpty() && QFileInfo(fn).isFile())
3314 { 3319 {
3315 //qDebug("Opening"); 3320 //qDebug("Opening");
3316 struct stat fnstat; 3321 struct stat fnstat;
3317 stat((const char *)fn, &fnstat); 3322 stat((const char *)fn, &fnstat);
3318 3323
3319 if (CFiledata(bk->anno()).date() 3324 if (CFiledata(bk->anno()).date()
3320 != fnstat.st_mtime) 3325 != fnstat.st_mtime)
3321 { 3326 {
3322 CFiledata fd(bk->anno()); 3327 CFiledata fd(bk->anno());
3323 fd.setdate(fnstat.st_mtime); 3328 fd.setdate(fnstat.st_mtime);
3324 bk->value(0); 3329 bk->value(0);
3325 reader->m_lastposn = 0; 3330 reader->m_lastposn = 0;
3326 openFile(fn); 3331 openFile(fn);
3327 } 3332 }
3328 else 3333 else
3329 { 3334 {
3330 unsigned short svlen = bk->filedatalen(); 3335 unsigned short svlen = bk->filedatalen();
3331 unsigned char* svdata = bk->filedata(); 3336 unsigned char* svdata = bk->filedata();
3332 openFile(fn, bk->value()); 3337 openFile(fn, bk->value());
3333 reader->putSaveData(svdata, svlen); 3338 reader->putSaveData(svdata, svlen);
3334 // setstate(svdata, svlen); 3339 // setstate(svdata, svlen);
3335 if (svlen != 0) 3340 if (svlen != 0)
3336 { 3341 {
3337 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); 3342 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?");
3338 } 3343 }
3339 // qDebug("updating"); 3344 // qDebug("updating");
3340 // showEditTools(); 3345 // showEditTools();
3341 } 3346 }
3342 return true; 3347 return true;
3343 } 3348 }
3344 else 3349 else
3345 { 3350 {
3346 return false; 3351 return false;
3347 } 3352 }
3348} 3353}
3349 3354
3350void QTReaderApp::gotobkmk(int ind) 3355void QTReaderApp::gotobkmk(int ind)
3351{ 3356{
3352 qDebug("gbkmk"); 3357 qDebug("gbkmk");
3353 showEditTools(); 3358 showEditTools();
3354 switch (m_nBkmkAction) 3359 switch (m_nBkmkAction)
3355 { 3360 {
3356 case cOpenFile: 3361 case cOpenFile:
3357 { 3362 {
3358 // qApp->processEvents(); 3363 // qApp->processEvents();
3359 if (!openfrombkmk((*pOpenlist)[ind])) 3364 if (!openfrombkmk((*pOpenlist)[ind]))
3360 { 3365 {
3361 pOpenlist->erase(ind); 3366 pOpenlist->erase(ind);
3362 QMessageBox::information(this, PROGNAME, "Can't find file"); 3367 QMessageBox::information(this, PROGNAME, "Can't find file");
3363 } 3368 }
3364 } 3369 }
3365 break; 3370 break;
3366 case cGotoBkmk: 3371 case cGotoBkmk:
3367 reader->buffdoc.saveposn(reader->m_lastfile, reader->pagelocate()); 3372 reader->buffdoc.saveposn(reader->m_lastfile, reader->pagelocate());
3368 reader->locate((*pBkmklist)[ind]->value()); 3373 reader->locate((*pBkmklist)[ind]->value());
3369 break; 3374 break;
3370 case cDelBkmk: 3375 case cDelBkmk:
3371 //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); 3376 //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name());
3372 pBkmklist->erase(ind); 3377 pBkmklist->erase(ind);
3373 m_fBkmksChanged = true; 3378 m_fBkmksChanged = true;
3374 reader->refresh(true); 3379 reader->refresh(true);
3375 // pBkmklist->sort(); 3380 // pBkmklist->sort();
3376 break; 3381 break;
3377 case cRmBkmkFile: 3382 case cRmBkmkFile:
3378 { 3383 {
3379#ifndef USEQPE 3384#ifndef USEQPE
3380 QDir d = QDir::home(); // "/" 3385 QDir d = QDir::home(); // "/"
3381 d.cd(APPDIR); 3386 d.cd(APPDIR);
3382 d.remove(bkmkselector->text(ind)); 3387 d.remove(bkmkselector->text(ind));
3383#else /* USEQPE */ 3388#else /* USEQPE */
3384 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); 3389 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind)));
3385#endif /* USEQPE */ 3390#endif /* USEQPE */
3386 } 3391 }
3387 break; 3392 break;
3388 case cLdConfig: 3393 case cLdConfig:
3389 readconfig(APPDIR "/configs", bkmkselector->text(ind), false); 3394 readconfig(APPDIR "/configs", bkmkselector->text(ind), false);
3390 break; 3395 break;
3391 case cLdTheme: 3396 case cLdTheme:
3392 m_themename = bkmkselector->text(ind); 3397 m_themename = bkmkselector->text(ind);
3393 readconfig(QString(APPDIR "/Themes/")+m_themename , "config", false); 3398 readconfig(QString(APPDIR "/Themes/")+m_themename , "config", false);
3394 setBackgroundBitmap(); 3399 setBackgroundBitmap();
3395 break; 3400 break;
3396 case cRmConfig: 3401 case cRmConfig:
3397 { 3402 {
3398#ifndef USEQPE 3403#ifndef USEQPE
3399 QDir d = QDir::home(); // "/" 3404 QDir d = QDir::home(); // "/"
3400 d.cd(APPDIR "/configs"); 3405 d.cd(APPDIR "/configs");
3401 d.remove(bkmkselector->text(ind)); 3406 d.remove(bkmkselector->text(ind));
3402#else /* USEQPE */ 3407#else /* USEQPE */
3403 unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); 3408 unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind)));
3404#endif /* USEQPE */ 3409#endif /* USEQPE */
3405 } 3410 }
3406 break; 3411 break;
3407 case cExportLinks: 3412 case cExportLinks:
3408 { 3413 {
3409#ifndef USEQPE 3414#ifndef USEQPE
3410 QDir d = QDir::home(); // "/" 3415 QDir d = QDir::home(); // "/"
3411 d.cd(APPDIR "/urls"); 3416 d.cd(APPDIR "/urls");
3412 QFileInfo fi(d, bkmkselector->text(ind)); 3417 QFileInfo fi(d, bkmkselector->text(ind));
3413 if (fi.exists()) 3418 if (fi.exists())
3414 { 3419 {
3415 QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); 3420 QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) );
3416 if (!outfile.isEmpty()) 3421 if (!outfile.isEmpty())
3417 { 3422 {
3418 FILE* fout = fopen((const char *)outfile, "w"); 3423 FILE* fout = fopen((const char *)outfile, "w");
3419 if (fout != NULL) 3424 if (fout != NULL)
3420 { 3425 {
3421 FILE* fin = fopen((const char *)fi.absFilePath(), "r"); 3426 FILE* fin = fopen((const char *)fi.absFilePath(), "r");
3422 if (fin != NULL) 3427 if (fin != NULL)
3423 { 3428 {
3424 fprintf(fout, "<html><body>\n"); 3429 fprintf(fout, "<html><body>\n");
3425 int ch = 0; 3430 int ch = 0;
3426 while ((ch = fgetc(fin)) != EOF) 3431 while ((ch = fgetc(fin)) != EOF)
3427 { 3432 {
3428 fputc(ch, fout); 3433 fputc(ch, fout);
3429 } 3434 }
3430 fclose(fin); 3435 fclose(fin);
3431 fprintf(fout, "</html></body>\n"); 3436 fprintf(fout, "</html></body>\n");
3432 d.remove(bkmkselector->text(ind)); 3437 d.remove(bkmkselector->text(ind));
3433 } 3438 }
3434 fclose(fout); 3439 fclose(fout);
3435 } 3440 }
3436 else 3441 else
3437 QMessageBox::information(this, PROGNAME, "Couldn't open output"); 3442 QMessageBox::information(this, PROGNAME, "Couldn't open output");
3438 } 3443 }
3439 } 3444 }
3440#else /* USEQPE */ 3445#else /* USEQPE */
3441 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); 3446 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
3442 if (fin != NULL) 3447 if (fin != NULL)
3443 { 3448 {
3444 bool allok = false; 3449 bool allok = false;
3445#if defined(OPIE) && defined(OPIEFILEDIALOG) 3450#if defined(OPIE) && defined(OPIEFILEDIALOG)
3446 QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader"); 3451 QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader");
3447 if (!outfile.isEmpty()) 3452 if (!outfile.isEmpty())
3448 { 3453 {
3449 FILE* fout = fopen((const char *)outfile, "w"); 3454 FILE* fout = fopen((const char *)outfile, "w");
3450 if (fout != NULL) 3455 if (fout != NULL)
3451 { 3456 {
3452 fprintf(fout, "<html><body>\n"); 3457 fprintf(fout, "<html><body>\n");
3453 int ch = 0; 3458 int ch = 0;
3454 while ((ch = fgetc(fin)) != EOF) 3459 while ((ch = fgetc(fin)) != EOF)
3455 { 3460 {
3456 fputc(ch, fout); 3461 fputc(ch, fout);
3457 } 3462 }
3458 fprintf(fout, "</html></body>\n"); 3463 fprintf(fout, "</html></body>\n");
3459 fclose(fout); 3464 fclose(fout);
3460 allok = true; 3465 allok = true;
3461 } 3466 }
3462 else 3467 else
3463 QMessageBox::information(this, PROGNAME, "Couldn't open output"); 3468 QMessageBox::information(this, PROGNAME, "Couldn't open output");
3464 } 3469 }
3465 fclose(fin); 3470 fclose(fin);
3466 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); 3471 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)));
3467#else 3472#else
3468 fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); 3473 fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null);
3469 if (fb->exec()) 3474 if (fb->exec())
3470 { 3475 {
3471 QString outfile = fb->getCurrentFile(); 3476 QString outfile = fb->getCurrentFile();
3472 FILE* fout = fopen((const char *)outfile, "w"); 3477 FILE* fout = fopen((const char *)outfile, "w");
3473 if (fout != NULL) 3478 if (fout != NULL)
3474 { 3479 {
3475 fprintf(fout, "<html><body>\n"); 3480 fprintf(fout, "<html><body>\n");
3476 int ch = 0; 3481 int ch = 0;
3477 while ((ch = fgetc(fin)) != EOF) 3482 while ((ch = fgetc(fin)) != EOF)
3478 { 3483 {
3479 fputc(ch, fout); 3484 fputc(ch, fout);
3480 } 3485 }
3481 fprintf(fout, "</html></body>\n"); 3486 fprintf(fout, "</html></body>\n");
3482 fclose(fout); 3487 fclose(fout);
3483 allok = true; 3488 allok = true;
3484 } 3489 }
3485 else 3490 else
3486 QMessageBox::information(this, PROGNAME, "Couldn't open output"); 3491 QMessageBox::information(this, PROGNAME, "Couldn't open output");
3487 } 3492 }
3488 delete fb; 3493 delete fb;
3489 fclose(fin); 3494 fclose(fin);
3490 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); 3495 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)));
3491#endif 3496#endif
3492 } 3497 }
3493 else 3498 else
3494 { 3499 {
3495 QMessageBox::information(this, PROGNAME, "Couldn't open input"); 3500 QMessageBox::information(this, PROGNAME, "Couldn't open input");
3496 } 3501 }
3497 3502
3498/* 3503/*
3499 CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); 3504 CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE );
3500 int ret = f->exec(); 3505 int ret = f->exec();
3501 qDebug("Return:%d", ret); 3506 qDebug("Return:%d", ret);
3502 DocLnk* doc = f->getDoc(); 3507 DocLnk* doc = f->getDoc();
3503 if (doc != NULL) 3508 if (doc != NULL)
3504 { 3509 {
3505 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); 3510 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
3506 QString rt; 3511 QString rt;
3507 rt = "<html><body>\n"; 3512 rt = "<html><body>\n";
3508 int ch = 0; 3513 int ch = 0;
3509 while ((ch = fgetc(fin)) != EOF) 3514 while ((ch = fgetc(fin)) != EOF)
3510 { 3515 {
3511 rt += (char)ch; 3516 rt += (char)ch;
3512 } 3517 }
3513 fclose(fin); 3518 fclose(fin);
3514 rt += "</html></body>\n"; 3519 rt += "</html></body>\n";
3515 if ( doc->name().isEmpty() ) 3520 if ( doc->name().isEmpty() )
3516 { 3521 {
3517 doc->setName(bkmkselector->text(ind)); 3522 doc->setName(bkmkselector->text(ind));
3518 } 3523 }
3519 FileManager fm; 3524 FileManager fm;
3520 fm.saveFile( *doc, rt ); 3525 fm.saveFile( *doc, rt );
3521 qDebug("YES"); 3526 qDebug("YES");
3522 } 3527 }
3523 else 3528 else
3524 { 3529 {
3525 qDebug("NO"); 3530 qDebug("NO");
3526 } 3531 }
3527 delete f; 3532 delete f;
3528*/ 3533*/
3529 3534
3530#endif /* USEQPE */ 3535#endif /* USEQPE */
3531 } 3536 }
3532 break; 3537 break;
3533 } 3538 }
3534} 3539}
3535 3540
3536void QTReaderApp::cancelbkmk() 3541void QTReaderApp::cancelbkmk()
3537{ 3542{
3538 if (m_nBkmkAction == cOpenFile) 3543 if (m_nBkmkAction == cOpenFile)
3539 { 3544 {
3540 QString fn = usefilebrowser(); 3545 QString fn = usefilebrowser();
3541 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); 3546 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
3542 } 3547 }
3543 showEditTools(); 3548 showEditTools();
3544} 3549}
3545 3550
3546void QTReaderApp::reparastring() 3551void QTReaderApp::reparastring()
3547{ 3552{
3548 m_nRegAction = cRepara; 3553 m_nRegAction = cRepara;
3549 regEdit->setText(reader->m_reparastring); 3554 regEdit->setText(reader->m_reparastring);
3550 do_regedit(); 3555 do_regedit();
3551} 3556}
3552 3557
3553void QTReaderApp::do_reparastring(const QString& _lcn) 3558void QTReaderApp::do_reparastring(const QString& _lcn)
3554{ 3559{
3555 reader->m_reparastring = _lcn; 3560 reader->m_reparastring = _lcn;
3556 if (reader->brepara) 3561 if (reader->brepara)
3557 { 3562 {
3558 reader->bDoUpdates = true; 3563 reader->bDoUpdates = true;
3559 reader->setfilter(reader->getfilter()); 3564 reader->setfilter(reader->getfilter());
3560 } 3565 }
3561} 3566}
3562 3567
3563void QTReaderApp::jump() 3568void QTReaderApp::jump()
3564{ 3569{
3565 m_nRegAction = cJump; 3570 m_nRegAction = cJump;
3566 char lcn[20]; 3571 char lcn[20];
3567 sprintf(lcn, "%lu", reader->pagelocate()); 3572 sprintf(lcn, "%lu", reader->pagelocate());
3568 regEdit->setText(lcn); 3573 regEdit->setText(lcn);
3569 do_regedit(); 3574 do_regedit();
3570} 3575}
3571 3576
3572void QTReaderApp::do_jump(const QString& _lcn) 3577void QTReaderApp::do_jump(const QString& _lcn)
3573{ 3578{
3574 bool ok; 3579 bool ok;
3575 QString lcn = _lcn.stripWhiteSpace(); 3580 QString lcn = _lcn.stripWhiteSpace();
3576 unsigned long ulcn = lcn.toULong(&ok); 3581 unsigned long ulcn = lcn.toULong(&ok);
3577 if (!ok) 3582 if (!ok)
3578 { 3583 {
3579 double pc = 0.0; 3584 double pc = 0.0;
3580#ifdef _WINDOWS 3585#ifdef _WINDOWS
3581 if (lcn.at(lcn.length()-1) == '%') 3586 if (lcn.at(lcn.length()-1) == '%')
3582#else 3587#else
3583 if (lcn[lcn.length()-1] == '%') 3588 if (lcn[lcn.length()-1] == '%')
3584#endif 3589#endif
3585 { 3590 {
3586 lcn = lcn.left(lcn.length()-1); 3591 lcn = lcn.left(lcn.length()-1);
3587 pc = lcn.toDouble(&ok); 3592 pc = lcn.toDouble(&ok);
3588 } 3593 }
3589 else 3594 else
3590 { 3595 {
3591 pc = lcn.toDouble(&ok); 3596 pc = lcn.toDouble(&ok);
3592 } 3597 }
3593 if (ok && 0 <= pc && pc <= 100) 3598 if (ok && 0 <= pc && pc <= 100)
3594 { 3599 {
3595 ulcn = (pc*(reader->buffdoc.endSection()-reader->buffdoc.startSection()))/100 + reader->buffdoc.startSection(); 3600 ulcn = (pc*(reader->buffdoc.endSection()-reader->buffdoc.startSection()))/100 + reader->buffdoc.startSection();
3596 } 3601 }
3597 else 3602 else
3598 { 3603 {
3599 ok = false; 3604 ok = false;
3600 } 3605 }
3601 } 3606 }
3602 if (ok) 3607 if (ok)
3603 reader->locate(ulcn); 3608 reader->locate(ulcn);
3604 else 3609 else
3605 QMessageBox::information(this, PROGNAME, "Must be a number\nor a percentage"); 3610 QMessageBox::information(this, PROGNAME, "Must be a number\nor a percentage");
3606} 3611}
3607 3612
3608void QTReaderApp::do_regaction() 3613void QTReaderApp::do_regaction()
3609{ 3614{
3610 reader->bDoUpdates = false; 3615 reader->bDoUpdates = false;
3611 regBar->hide(); 3616 regBar->hide();
3612#ifdef USEQPE 3617#ifdef USEQPE
3613 Global::hideInputMethod(); 3618 Global::hideInputMethod();
3614#endif 3619#endif
3615 regVisible = false; 3620 regVisible = false;
3616 switch(m_nRegAction) 3621 switch(m_nRegAction)
3617 { 3622 {
3618 case cAutoGen: 3623 case cAutoGen:
3619 do_autogen(regEdit->text()); 3624 do_autogen(regEdit->text());
3620 break; 3625 break;
3621 case cAddBkmk: 3626 case cAddBkmk:
3622 do_addbkmk(regEdit->text()); 3627 do_addbkmk(regEdit->text());
3623 break; 3628 break;
3624 case cRepara: 3629 case cRepara:
3625 do_reparastring(regEdit->text()); 3630 do_reparastring(regEdit->text());
3626 break; 3631 break;
3627 case cJump: 3632 case cJump:
3628 do_jump(regEdit->text()); 3633 do_jump(regEdit->text());
3629 break; 3634 break;
3630/* 3635/*
3631 case cMonoSpace: 3636 case cMonoSpace:
3632 do_mono(regEdit->text()); 3637 do_mono(regEdit->text());
3633 break; 3638 break;
3634*/ 3639*/
3635 case cSetTarget: 3640 case cSetTarget:
3636 do_settarget(regEdit->text()); 3641 do_settarget(regEdit->text());
3637 break; 3642 break;
3638#ifdef _SCROLLPIPE 3643#ifdef _SCROLLPIPE
3639 case cSetPipeTarget: 3644 case cSetPipeTarget:
3640 do_setpipetarget(regEdit->text()); 3645 do_setpipetarget(regEdit->text());
3641 break; 3646 break;
3642#endif 3647#endif
3643 case cSetConfigName: 3648 case cSetConfigName:
3644 // qDebug("Saving config"); 3649 // qDebug("Saving config");
3645 do_saveconfig(regEdit->text(), false); 3650 do_saveconfig(regEdit->text(), false);
3646 break; 3651 break;
3647 } 3652 }
3648// reader->restore(); 3653// reader->restore();
3649// fileBar->show(); 3654// fileBar->show();
3650 reader->setFocus(); 3655 reader->setFocus();
3651// qApp->processEvents(); 3656// qApp->processEvents();
3652 reader->bDoUpdates = true; 3657 reader->bDoUpdates = true;
3653 reader->update(); 3658 reader->update();
3654} 3659}
3655 3660
3656void QTReaderApp::do_settarget(const QString& _txt) 3661void QTReaderApp::do_settarget(const QString& _txt)
3657{ 3662{
3658 int ind = _txt.find('/'); 3663 int ind = _txt.find('/');
3659 if (ind == -1) 3664 if (ind == -1)
3660 { 3665 {
3661 m_targetapp = ""; 3666 m_targetapp = "";
3662 m_targetmsg = ""; 3667 m_targetmsg = "";
3663 QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); 3668 QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename");
3664 } 3669 }
3665 else 3670 else
3666 { 3671 {
3667 m_targetapp = _txt.left(ind); 3672 m_targetapp = _txt.left(ind);
3668 m_targetmsg = _txt.right(_txt.length()-ind-1); 3673 m_targetmsg = _txt.right(_txt.length()-ind-1);
3669 } 3674 }
3670} 3675}
3671 3676
3672void QTReaderApp::chooseencoding() 3677void QTReaderApp::chooseencoding()
3673{ 3678{
3674 m_fontSelector->clear(); 3679 m_fontSelector->clear();
3675 m_fontSelector->insertItem("Ascii"); 3680 m_fontSelector->insertItem("Ascii");
3676 m_fontSelector->insertItem("UTF-8"); 3681 m_fontSelector->insertItem("UTF-8");
3677 m_fontSelector->insertItem("UCS-2(BE)"); 3682 m_fontSelector->insertItem("UCS-2(BE)");
3678 m_fontSelector->insertItem("USC-2(LE)"); 3683 m_fontSelector->insertItem("USC-2(LE)");
3679 m_fontSelector->insertItem("Palm"); 3684 m_fontSelector->insertItem("Palm");
3680 for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) 3685 for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++)
3681 { 3686 {
3682 m_fontSelector->insertItem(iter->mime); 3687 m_fontSelector->insertItem(iter->mime);
3683 } // delete the FontDatabase!!! 3688 } // delete the FontDatabase!!!
3684 m_fontSelector->setCurrentItem (reader->m_encd); 3689 m_fontSelector->setCurrentItem (reader->m_encd);
3685 m_fontAction = cChooseEncoding; 3690 m_fontAction = cChooseEncoding;
3686 m_fontBar->show(); 3691 m_fontBar->show();
3687 m_fontVisible = true; 3692 m_fontVisible = true;
3688} 3693}
3689 3694
3690void QTReaderApp::setfont() 3695void QTReaderApp::setfont()
3691{ 3696{
3692 m_fontSelector->clear(); 3697 m_fontSelector->clear();
3693 { 3698 {
3694 QFontDatabase f; 3699 QFontDatabase f;
3695 QStringList flist = f.families(); 3700 QStringList flist = f.families();
3696 m_fontSelector->insertStringList(flist); 3701 m_fontSelector->insertStringList(flist);
3697 } // delete the FontDatabase!!! 3702 } // delete the FontDatabase!!!
3698 3703
3699 for (int i = 1; i <= m_fontSelector->count(); i++) 3704 for (int i = 1; i <= m_fontSelector->count(); i++)
3700 { 3705 {
3701 if (m_fontSelector->text(i) == reader->m_fontname) 3706 if (m_fontSelector->text(i) == reader->m_fontname)
3702 { 3707 {
3703 m_fontSelector->setCurrentItem(i); 3708 m_fontSelector->setCurrentItem(i);
3704 break; 3709 break;
3705 } 3710 }
3706 } 3711 }
3707 m_fontAction = cChooseFont; 3712 m_fontAction = cChooseFont;
3708 m_fontBar->show(); 3713 m_fontBar->show();
3709 m_fontVisible = true; 3714 m_fontVisible = true;
3710} 3715}
3711 3716
3712void QTReaderApp::setfontHelper(const QString& lcn, int size) 3717void QTReaderApp::setfontHelper(const QString& lcn, int size)
3713{ 3718{
3714 if (size == 0) size = reader->m_fontControl.currentsize(); 3719 if (size == 0) size = reader->m_fontControl.currentsize();
3715 if (m_propogatefontchange) 3720 if (m_propogatefontchange)
3716 { 3721 {
3717 QFont f(lcn, 10); 3722 QFont f(lcn, 10);
3718 bkmkselector->setFont( f ); 3723 bkmkselector->setFont( f );
3719 regEdit->setFont( f ); 3724 regEdit->setFont( f );
3720 searchEdit->setFont( f ); 3725 searchEdit->setFont( f );
3721 m_annoWin->setFont( f ); 3726 m_annoWin->setFont( f );
3722 } 3727 }
3723 reader->m_fontname = lcn; 3728 reader->m_fontname = lcn;
3724 if (!reader->ChangeFont(size)) 3729 if (!reader->ChangeFont(size))
3725 { 3730 {
3726 reader->ChangeFont(size); 3731 reader->ChangeFont(size);
3727 } 3732 }
3728} 3733}
3729 3734
3730void QTReaderApp::do_setencoding(int i) 3735void QTReaderApp::do_setencoding(int i)
3731{ 3736{
3732 qDebug("setencoding:%d", i); 3737 qDebug("setencoding:%d", i);
3733 if (m_fontAction == cChooseEncoding) 3738 if (m_fontAction == cChooseEncoding)
3734 { 3739 {
3735 reader->setencoding(i); 3740 reader->setencoding(i);
3736 } 3741 }
3737 reader->refresh(); 3742 reader->refresh();
3738 m_fontBar->hide(); 3743 m_fontBar->hide();
3739 m_fontVisible = false; 3744 m_fontVisible = false;
3740// qDebug("showedit"); 3745// qDebug("showedit");
3741 if (reader->isVisible()) showEditTools(); 3746 if (reader->isVisible()) showEditTools();
3742// qDebug("showeditdone"); 3747// qDebug("showeditdone");
3743} 3748}
3744 3749
3745void QTReaderApp::do_setfont(const QString& lcn) 3750void QTReaderApp::do_setfont(const QString& lcn)
3746{ 3751{
3747 if (m_fontAction == cChooseFont) 3752 if (m_fontAction == cChooseFont)
3748 { 3753 {
3749 setfontHelper(lcn); 3754 setfontHelper(lcn);
3750 } 3755 }
3751 reader->refresh(); 3756 reader->refresh();
3752 m_fontBar->hide(); 3757 m_fontBar->hide();
3753 m_fontVisible = false; 3758 m_fontVisible = false;
3754 // qDebug("setfont"); 3759 // qDebug("setfont");
3755 //if (reader->isVisible()) 3760 //if (reader->isVisible())
3756 showEditTools(); 3761 showEditTools();
3757// qDebug("showeditdone"); 3762// qDebug("showeditdone");
3758} 3763}
3759 3764
3760void QTReaderApp::do_autogen(const QString& regText) 3765void QTReaderApp::do_autogen(const QString& regText)
3761{ 3766{
3762 unsigned long fs, ts; 3767 unsigned long fs, ts;
3763 reader->sizes(fs,ts); 3768 reader->sizes(fs,ts);
3764// // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); 3769// // qDebug("Reg:%s\n", (const tchar*)(regEdit->text()));
3765 m_autogenstr = regText; 3770 m_autogenstr = regText;
3766 QRegExp re(regText); 3771 QRegExp re(regText);
3767 CBuffer buff; 3772 CBuffer buff;
3768 if (pBkmklist != NULL) delete pBkmklist; 3773 if (pBkmklist != NULL) delete pBkmklist;
3769 reader->pBkmklist = pBkmklist = new CList<Bkmk>; 3774 reader->pBkmklist = pBkmklist = new CList<Bkmk>;
3770 m_fBkmksChanged = true; 3775 m_fBkmksChanged = true;
3771 3776
3772 pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); 3777 pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height());
3773 pbar->show(); 3778 pbar->show();
3774 pbar->raise(); 3779 pbar->raise();
3775 pbar->reset(); 3780 pbar->reset();
3776 reader->update(); 3781 reader->update();
3777 qApp->processEvents(); 3782 qApp->processEvents();
3778 reader->setFocus(); 3783 reader->setFocus();
3779 reader->jumpto(0); 3784 reader->jumpto(0);
3780 int lastpc = 0; 3785 int lastpc = 0;
3781 int i = 0; 3786 int i = 0;
3782 unsigned int llcn = reader->locate(); 3787 unsigned int llcn = reader->locate();
3783 while (i >= 0) 3788 while (i >= 0)
3784 { 3789 {
3785 unsigned int lcn = llcn; 3790 unsigned int lcn = llcn;
3786 int pc = (100*lcn)/ts; 3791 int pc = (100*lcn)/ts;
3787 if (pc != lastpc) 3792 if (pc != lastpc)
3788 { 3793 {
3789 pbar->setProgress(pc); 3794 pbar->setProgress(pc);
3790 qApp->processEvents(); 3795 qApp->processEvents();
3791 if (reader->locate() != lcn) reader->jumpto(lcn); 3796 if (reader->locate() != lcn) reader->jumpto(lcn);
3792 reader->setFocus(); 3797 reader->setFocus();
3793 lastpc = pc; 3798 lastpc = pc;
3794 } 3799 }
3795 i = reader->buffdoc.getpara(buff); 3800 i = reader->buffdoc.getpara(buff);
3796#ifdef _UNICODE 3801#ifdef _UNICODE
3797 if (re.match(toQString(buff.data())) != -1) 3802 if (re.match(toQString(buff.data())) != -1)
3798#else 3803#else
3799 if (re.match(buff.data()) != -1) 3804 if (re.match(buff.data()) != -1)
3800#endif 3805#endif
3801 pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); 3806 pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn));
3802 /* 3807 /*
3803 llcn = reader->locate(); 3808 llcn = reader->locate();
3804 if ((i == 0) && (llcn+1 < ts)) 3809 if ((i == 0) && (llcn+1 < ts))
3805 { 3810 {
3806 reader->jumpto(++llcn); 3811 reader->jumpto(++llcn);
3807 i = 1; 3812 i = 1;
3808 } 3813 }
3809 */ 3814 */
3810 } 3815 }
3811 pBkmklist->sort(); 3816 pBkmklist->sort();
3812 pbar->setProgress(100); 3817 pbar->setProgress(100);
3813 qApp->processEvents(); 3818 qApp->processEvents();
3814 pbar->hide(); 3819 pbar->hide();
3815 reader->refresh(); 3820 reader->refresh();
3816} 3821}
3817 3822
3818void QTReaderApp::saveprefs() 3823void QTReaderApp::saveprefs()
3819{ 3824{
3820 do_saveconfig( APPDIR, true ); 3825 do_saveconfig( APPDIR, true );
3821 savefilelist(); 3826 savefilelist();
3822} 3827}
3823 3828
3824/* 3829/*
3825void QTReaderApp::oldFile() 3830void QTReaderApp::oldFile()
3826{ 3831{
3827// qDebug("oldFile called"); 3832// qDebug("oldFile called");
3828 reader->setText(true); 3833 reader->setText(true);
3829// qDebug("settext called"); 3834// qDebug("settext called");
3830 showEditTools(); 3835 showEditTools();
3831// qDebug("showedit called"); 3836// qDebug("showedit called");
3832} 3837}
3833*/ 3838*/
3834 3839
3835/* 3840/*
3836void info_cb(Fl_Widget* o, void* _data) 3841void info_cb(Fl_Widget* o, void* _data)
3837{ 3842{
3838 3843
3839 if (infowin == NULL) 3844 if (infowin == NULL)
3840 { 3845 {
3841 3846
3842 infowin = new Fl_Window(160,240); 3847 infowin = new Fl_Window(160,240);
3843 filename = new Fl_Output(45,5,110,14,"Filename"); 3848 filename = new Fl_Output(45,5,110,14,"Filename");
3844 filesize = new Fl_Output(45,25,110,14,"Filesize"); 3849 filesize = new Fl_Output(45,25,110,14,"Filesize");
3845 textsize = new Fl_Output(45,45,110,14,"Textsize"); 3850 textsize = new Fl_Output(45,45,110,14,"Textsize");
3846 comprat = new CBar(45,65,110,14,"Ratio %"); 3851 comprat = new CBar(45,65,110,14,"Ratio %");
3847 posn = new Fl_Output(45,85,110,14,"Location"); 3852 posn = new Fl_Output(45,85,110,14,"Location");
3848 frcn = new CBar(45,105,110,14,"% Read"); 3853 frcn = new CBar(45,105,110,14,"% Read");
3849 about = new Fl_Multiline_Output(5,125,150,90); 3854 about = new Fl_Multiline_Output(5,125,150,90);
3850 about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); 3855 about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files");
3851 Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); 3856 Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay");
3852 infowin->set_modal(); 3857 infowin->set_modal();
3853 } 3858 }
3854 if (((reader_ui *)_data)->g_filename[0] != '\0') 3859 if (((reader_ui *)_data)->g_filename[0] != '\0')
3855 { 3860 {
3856 unsigned long fs,ts; 3861 unsigned long fs,ts;
3857 tchar sz[20]; 3862 tchar sz[20];
3858 ((reader_ui *)_data)->input->sizes(fs,ts); 3863 ((reader_ui *)_data)->input->sizes(fs,ts);
3859 unsigned long pl = ((reader_ui *)_data)->input->locate(); 3864 unsigned long pl = ((reader_ui *)_data)->input->locate();
3860 3865
3861 filename->value(((reader_ui *)_data)->g_filename); 3866 filename->value(((reader_ui *)_data)->g_filename);
3862 3867
3863 sprintf(sz,"%u",fs); 3868 sprintf(sz,"%u",fs);
3864 filesize->value(sz); 3869 filesize->value(sz);
3865 3870
3866 sprintf(sz,"%u",ts); 3871 sprintf(sz,"%u",ts);
3867 textsize->value(sz); 3872 textsize->value(sz);
3868 3873
3869 comprat->value(100-(100*fs + (ts >> 1))/ts); 3874 comprat->value(100-(100*fs + (ts >> 1))/ts);
3870 3875
3871 sprintf(sz,"%u",pl); 3876 sprintf(sz,"%u",pl);
3872 posn->value(sz); 3877 posn->value(sz);
3873 3878
3874 frcn->value((100*pl + (ts >> 1))/ts); 3879 frcn->value((100*pl + (ts >> 1))/ts);
3875 } 3880 }
3876 infowin->show(); 3881 infowin->show();
3877} 3882}
3878*/ 3883*/
3879 3884
3880void QTReaderApp::savebkmks() 3885void QTReaderApp::savebkmks()
3881{ 3886{
3882 if (pBkmklist != NULL) 3887 if (pBkmklist != NULL)
3883 { 3888 {
3884#ifndef USEQPE 3889#ifndef USEQPE
3885 QDir d = QDir::home(); // "/" 3890 QDir d = QDir::home(); // "/"
3886 d.cd(APPDIR); 3891 d.cd(APPDIR);
3887 QFileInfo fi(d, reader->m_string); 3892 QFileInfo fi(d, reader->m_string);
3888 BkmkFile bf((const char *)fi.absFilePath(), true, true); 3893 BkmkFile bf((const char *)fi.absFilePath(), true, true);
3889#else /* USEQPE */ 3894#else /* USEQPE */
3890 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true, true); 3895 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true, true);
3891#endif /* USEQPE */ 3896#endif /* USEQPE */
3892 bf.write(*pBkmklist); 3897 bf.write(*pBkmklist);
3893 } 3898 }
3894 m_fBkmksChanged = false; 3899 m_fBkmksChanged = false;
3895} 3900}
3896 3901
3897void QTReaderApp::readfilelist() 3902void QTReaderApp::readfilelist()
3898{ 3903{
3899#ifndef USEQPE 3904#ifndef USEQPE
3900 QDir d = QDir::home(); // "/" 3905 QDir d = QDir::home(); // "/"
3901 d.cd(APPDIR); 3906 d.cd(APPDIR);
3902 QFileInfo fi(d, ".openfiles"); 3907 QFileInfo fi(d, ".openfiles");
3903 BkmkFile bf((const char *)fi.absFilePath(), false, false); 3908 BkmkFile bf((const char *)fi.absFilePath(), false, false);
3904#else /* USEQPE */ 3909#else /* USEQPE */
3905 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), false, false); 3910 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), false, false);
3906#endif /* USEQPE */ 3911#endif /* USEQPE */
3907// qDebug("Reading open files"); 3912// qDebug("Reading open files");
3908 pOpenlist = bf.readall(); 3913 pOpenlist = bf.readall();
3909// if (pOpenlist != NULL) qDebug("...with success"); 3914// if (pOpenlist != NULL) qDebug("...with success");
3910// else qDebug("...without success!"); 3915// else qDebug("...without success!");
3911} 3916}
3912 3917
3913void QTReaderApp::savefilelist() 3918void QTReaderApp::savefilelist()
3914{ 3919{
3915 if (pOpenlist != NULL) 3920 if (pOpenlist != NULL)
3916 { 3921 {
3917#ifndef USEQPE 3922#ifndef USEQPE
3918 QDir d = QDir::home(); // "/" 3923 QDir d = QDir::home(); // "/"
3919 d.cd(APPDIR); 3924 d.cd(APPDIR);
3920 QFileInfo fi(d, ".openfiles"); 3925 QFileInfo fi(d, ".openfiles");
3921 BkmkFile bf((const char *)fi.absFilePath(), true, false); 3926 BkmkFile bf((const char *)fi.absFilePath(), true, false);
3922#else /* USEQPE */ 3927#else /* USEQPE */
3923 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true, false); 3928 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true, false);
3924#endif /* USEQPE */ 3929#endif /* USEQPE */
3925 //qDebug("Writing open files"); 3930 //qDebug("Writing open files");
3926 bf.write(*pOpenlist); 3931 bf.write(*pOpenlist);
3927 } 3932 }
3928} 3933}
3929 3934
3930void QTReaderApp::readbkmks() 3935void QTReaderApp::readbkmks()
3931{ 3936{
3932 if (pBkmklist != NULL) 3937 if (pBkmklist != NULL)
3933 { 3938 {
3934 delete pBkmklist; 3939 delete pBkmklist;
3935 } 3940 }
3936 struct stat fnstat; 3941 struct stat fnstat;
3937 struct stat bkstat; 3942 struct stat bkstat;
3938#ifndef USEQPE 3943#ifndef USEQPE
3939 QDir d = QDir::home(); // "/" 3944 QDir d = QDir::home(); // "/"
3940 d.cd(APPDIR); 3945 d.cd(APPDIR);
3941 QFileInfo fi(d, reader->m_string); 3946 QFileInfo fi(d, reader->m_string);
3942#endif /* ! USEQPE */ 3947#endif /* ! USEQPE */
3943 if ( 3948 if (
3944 stat((const char *)reader->m_lastfile, &fnstat) == 0 3949 stat((const char *)reader->m_lastfile, &fnstat) == 0
3945 && 3950 &&
3946#ifndef USEQPE 3951#ifndef USEQPE
3947 stat((const char *)fi.absFilePath(), &bkstat) == 0 3952 stat((const char *)fi.absFilePath(), &bkstat) == 0
3948#else /* USEQPE */ 3953#else /* USEQPE */
3949 stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 3954 stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0
3950#endif /* USEQPE */ 3955#endif /* USEQPE */
3951 ) 3956 )
3952 { 3957 {
3953 if (bkstat.st_mtime < fnstat.st_mtime) 3958 if (bkstat.st_mtime < fnstat.st_mtime)
3954 { 3959 {
3955#ifndef USEQPE 3960#ifndef USEQPE
3956 unlink((const char *)fi.absFilePath()); 3961 unlink((const char *)fi.absFilePath());
3957#else /* USEQPE */ 3962#else /* USEQPE */
3958 unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); 3963 unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string));
3959#endif /* USEQPE */ 3964#endif /* USEQPE */
3960 } 3965 }
3961 } 3966 }
3962 3967
3963#ifndef USEQPE 3968#ifndef USEQPE
3964 BkmkFile bf((const char *)fi.absFilePath(), false, true); 3969 BkmkFile bf((const char *)fi.absFilePath(), false, true);
3965#else /* USEQPE */ 3970#else /* USEQPE */
3966 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), false, true); 3971 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), false, true);
3967#endif /* USEQPE */ 3972#endif /* USEQPE */
3968 3973
3969 reader->pBkmklist = pBkmklist = bf.readall(); 3974 reader->pBkmklist = pBkmklist = bf.readall();
3970 m_fBkmksChanged = bf.upgraded(); 3975 m_fBkmksChanged = bf.upgraded();
3971 if (pBkmklist == NULL) 3976 if (pBkmklist == NULL)
3972 { 3977 {
3973 reader->pBkmklist = pBkmklist = reader->getbkmklist(); 3978 reader->pBkmklist = pBkmklist = reader->getbkmklist();
3974 } 3979 }
3975 if (pBkmklist != NULL) 3980 if (pBkmklist != NULL)
3976 pBkmklist->sort(); 3981 pBkmklist->sort();
3977} 3982}
3978 3983
3979void QTReaderApp::addbkmk() 3984void QTReaderApp::addbkmk()
3980{ 3985{
3981 m_nRegAction = cAddBkmk; 3986 m_nRegAction = cAddBkmk;
3982 regEdit->setText(reader->firstword()); 3987 regEdit->setText(reader->firstword());
3983 do_regedit(); 3988 do_regedit();
3984} 3989}
3985 3990
3986void QTReaderApp::do_addbkmk(const QString& text) 3991void QTReaderApp::do_addbkmk(const QString& text)
3987{ 3992{
3988 if (text.isEmpty()) 3993 if (text.isEmpty())
3989 { 3994 {
3990 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); 3995 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1);
3991 } 3996 }
3992 else 3997 else
3993 { 3998 {
3994 if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; 3999 if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>;
3995#ifdef _UNICODE 4000#ifdef _UNICODE
3996 CBuffer buff; 4001 CBuffer buff;
3997 int i = 0; 4002 int i = 0;
3998 for (i = 0; i < text.length(); i++) 4003 for (i = 0; i < text.length(); i++)
3999 { 4004 {
4000 buff[i] = text[i].unicode(); 4005 buff[i] = text[i].unicode();
4001 } 4006 }
4002 buff[i] = 0; 4007 buff[i] = 0;
4003 pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); 4008 pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate()));
4004#else 4009#else
4005 pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); 4010 pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate()));
4006#endif 4011#endif
4007 m_fBkmksChanged = true; 4012 m_fBkmksChanged = true;
4008 pBkmklist->sort(); 4013 pBkmklist->sort();
4009 reader->refresh(true); 4014 reader->refresh(true);
4010 } 4015 }
4011} 4016}
4012 4017
4013void QTReaderApp::UpdateStatus() 4018void QTReaderApp::UpdateStatus()
4014{ 4019{
4015 QString status; 4020 QString status;
4016 for (int i = 0; i < m_statusstring.length(); i++) 4021 for (int i = 0; i < m_statusstring.length(); i++)
4017 { 4022 {
4018 if (m_statusstring[i].unicode() == '%') 4023 if (m_statusstring[i].unicode() == '%')
4019 { 4024 {
4020 i++; 4025 i++;
4021 if (i < m_statusstring.length()) 4026 if (i < m_statusstring.length())
4022 { 4027 {
4023 switch (m_statusstring[i].unicode()) 4028 switch (m_statusstring[i].unicode())
4024 { 4029 {
4025 case 'F': 4030 case 'F':
4026 { 4031 {
4027 unsigned long fs,ts; 4032 unsigned long fs,ts;
4028 reader->sizes(fs,ts); 4033 reader->sizes(fs,ts);
4029 status += filesize(ts); 4034 status += filesize(ts);
4030 } 4035 }
4031 break; 4036 break;
4032 case 'f': 4037 case 'f':
4033 { 4038 {
4034 status += filesize(reader->pagelocate()); 4039 status += filesize(reader->pagelocate());
4035 } 4040 }
4036 break; 4041 break;
4037 case 'D': 4042 case 'D':
4038 { 4043 {
4039 status += filesize(reader->buffdoc.endSection()-reader->buffdoc.startSection()); 4044 status += filesize(reader->buffdoc.endSection()-reader->buffdoc.startSection());
4040 } 4045 }
4041 break; 4046 break;
4042 case 'd': 4047 case 'd':
4043 { 4048 {
4044 status += filesize(reader->pagelocate()-reader->buffdoc.startSection()); 4049 status += filesize(reader->pagelocate()-reader->buffdoc.startSection());
4045 } 4050 }
4046 break; 4051 break;
4047 case 'P': 4052 case 'P':
4048 { 4053 {
4049 unsigned long fs,ts; 4054 unsigned long fs,ts;
4050 reader->sizes(fs,ts); 4055 reader->sizes(fs,ts);
4051 status += percent(reader->pagelocate(),ts); 4056 status += percent(reader->pagelocate(),ts);
4052 } 4057 }
4053 break; 4058 break;
4054 case 'p': 4059 case 'p':
4055 { 4060 {
4056 status += percent(reader->pagelocate()-reader->buffdoc.startSection(),reader->buffdoc.endSection()-reader->buffdoc.startSection()); 4061 status += percent(reader->pagelocate()-reader->buffdoc.startSection(),reader->buffdoc.endSection()-reader->buffdoc.startSection());
4057 } 4062 }
4058 break; 4063 break;
4059 case 'z': 4064 case 'z':
4060 { 4065 {
4061 // qDebug("case d"); 4066 // qDebug("case d");
4062 status += QString().setNum(reader->m_fontControl.currentsize()*10); 4067 status += QString().setNum(reader->m_fontControl.currentsize()*10);
4063 } 4068 }
4064 break; 4069 break;
4065 default: 4070 default:
4066 status += m_statusstring[i]; 4071 status += m_statusstring[i];
4067 } 4072 }
4068 } 4073 }
4069 } 4074 }
4070 else 4075 else
4071 { 4076 {
4072 status += m_statusstring[i]; 4077 status += m_statusstring[i];
4073 } 4078 }
4074 } 4079 }
4075 m_prog->setText(status); 4080 m_prog->setText(status);
4076} 4081}
4077 4082
4078void QTReaderApp::OnRedraw() 4083void QTReaderApp::OnRedraw()
4079{ 4084{
4080 if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) 4085 if ((pBkmklist != NULL) && (m_bkmkAvail != NULL))
4081 { 4086 {
4082 bool found = findNextBookmark(reader->pagelocate()); 4087 bool found = findNextBookmark(reader->pagelocate());
4083 m_bkmkAvail->setEnabled(found); 4088 m_bkmkAvail->setEnabled(found);
4084 } 4089 }
4085 if (m_scrollbar != NULL) 4090 if (m_scrollbar != NULL)
4086 { 4091 {
4087 //qDebug("OnRedraw:[%u, %u]", reader->buffdoc.startSection(), reader->buffdoc.endSection()); 4092 //qDebug("OnRedraw:[%u, %u]", reader->buffdoc.startSection(), reader->buffdoc.endSection());
4088 scrollbar->setRange(reader->buffdoc.startSection(), reader->buffdoc.endSection()-1); 4093 scrollbar->setRange(reader->buffdoc.startSection(), reader->buffdoc.endSection()-1);
4089 scrollbar->setPageStep(reader->locate()-reader->pagelocate()); 4094 scrollbar->setPageStep(reader->locate()-reader->pagelocate());
4090 scrollbar->setValue((reader->m_rotated) ? 4095 scrollbar->setValue((reader->m_rotated) ?
4091 (reader->buffdoc.endSection() - reader->locate()+reader->buffdoc.startSection()) : 4096 (reader->buffdoc.endSection() - reader->locate()+reader->buffdoc.startSection()) :
4092 reader->pagelocate()); 4097 reader->pagelocate());
4093 } 4098 }
4094 if (m_prog->isVisible()) 4099 if (m_prog->isVisible())
4095 { 4100 {
4096 // qDebug("updating status"); 4101 // qDebug("updating status");
4097 UpdateStatus(); 4102 UpdateStatus();
4098 // qDebug("updated status"); 4103 // qDebug("updated status");
4099 } 4104 }
4100} 4105}
4101 4106
4102void QTReaderApp::showAnnotation() 4107void QTReaderApp::showAnnotation()
4103{ 4108{
4104 m_annoWin->setName(toQString(m_anno->name())); 4109 m_annoWin->setName(toQString(m_anno->name()));
4105 m_annoWin->setAnno(toQString(m_anno->anno())); 4110 m_annoWin->setAnno(toQString(m_anno->anno()));
4106 m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); 4111 m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue()));
4107 m_annoIsEditing = false; 4112 m_annoIsEditing = false;
4108#ifdef USEQPE 4113#ifdef USEQPE
4109 Global::showInputMethod(); 4114 Global::showInputMethod();
4110#endif 4115#endif
4111 editorStack->raiseWidget( m_annoWin ); 4116 editorStack->raiseWidget( m_annoWin );
4112 hidetoolbars(); 4117 hidetoolbars();
4113 m_annoWin->setFocus(); 4118 m_annoWin->setFocus();
4114} 4119}
4115 4120
4116void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line) 4121void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line)
4117{ 4122{
4118//// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); 4123//// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd);
4119 4124
4120 if (m_doOutput && reader->checkoutput()) 4125 if (m_doOutput && reader->checkoutput())
4121 { 4126 {
4122 reader->doOutput(wrd); 4127 reader->doOutput(wrd);
4123 } 4128 }
4124 if (m_doClipboard) 4129 if (m_doClipboard)
4125 { 4130 {
4126 QClipboard* cb = QApplication::clipboard(); 4131 QClipboard* cb = QApplication::clipboard();
4127 cb->setText(wrd); 4132 cb->setText(wrd);
4128#ifdef USEQPE 4133#ifdef USEQPE
4129 if (wrd.length() > 10) 4134 if (wrd.length() > 10)
4130 { 4135 {
4131 Global::statusMessage(wrd.left(8) + ".."); 4136 Global::statusMessage(wrd.left(8) + "..");
4132 } 4137 }
4133 else 4138 else
4134 { 4139 {
4135 Global::statusMessage(wrd); 4140 Global::statusMessage(wrd);
4136 } 4141 }
4137#endif 4142#endif
4138 } 4143 }
4139 if (m_doAnnotation) 4144 if (m_doAnnotation)
4140 { 4145 {
4141 //addAnno(wrd, "Need to be able to edit this", posn); 4146 //addAnno(wrd, "Need to be able to edit this", posn);
4142 m_annoWin->setName(line); 4147 m_annoWin->setName(line);
4143 m_annoWin->setAnno(""); 4148 m_annoWin->setAnno("");
4144 m_annoWin->setPosn(posn); 4149 m_annoWin->setPosn(posn);
4145 m_annoWin->setPosn2(posn2); 4150 m_annoWin->setPosn2(posn2);
4146 m_annoIsEditing = true; 4151 m_annoIsEditing = true;
4147#ifdef USEQPE 4152#ifdef USEQPE
4148 Global::showInputMethod(); 4153 Global::showInputMethod();
4149#endif 4154#endif
4150 editorStack->raiseWidget( m_annoWin ); 4155 editorStack->raiseWidget( m_annoWin );
4151 hidetoolbars(); 4156 hidetoolbars();
4152 } 4157 }
4153#ifdef USEQPE 4158#ifdef USEQPE
4154 if (m_doDictionary) 4159 if (m_doDictionary)
4155 { 4160 {
4156 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) 4161 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty())
4157 { 4162 {
4158 QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); 4163 QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8());
4159 e << wrd; 4164 e << wrd;
4160 } 4165 }
4161 } 4166 }
4162#endif 4167#endif
4163} 4168}
4164 4169
4165void QTReaderApp::doAction(QKeyEvent* e) 4170void QTReaderApp::doAction(QKeyEvent* e)
4166{ 4171{
4167 QMap<orKey,int>::Iterator f = kmap.end(); 4172 QMap<orKey,int>::Iterator f = kmap.end();
4168 4173
4169 if (reader->m_autoScroll) 4174 if (reader->m_autoScroll)
4170 { 4175 {
4171 f = kmap.find(orKey(e->state(), e->key(), true)); 4176 f = kmap.find(orKey(e->state(), e->key(), true));
4172 } 4177 }
4173 if (f == kmap.end()) 4178 if (f == kmap.end())
4174 { 4179 {
4175 f = kmap.find(orKey(e->state(), e->key(), false)); 4180 f = kmap.find(orKey(e->state(), e->key(), false));
4176 } 4181 }
4177 4182
4178 if (f == kmap.end()) 4183 if (f == kmap.end())
4179 { 4184 {
4180 qDebug("doaction (no action) : %d %d %d", e->key(), e->state(), f.data()); 4185 qDebug("doaction (no action) : %d %d %d", e->key(), e->state(), f.data());
4181 e->ignore(); 4186 e->ignore();
4182 } 4187 }
4183 else 4188 else
4184 { 4189 {
4185 qDebug("doaction (some action) : %d %d %d", e->key(), e->state(), f.data()); 4190 qDebug("doaction (some action) : %d %d %d", e->key(), e->state(), f.data());