author | llornkcor <llornkcor> | 2002-07-08 23:23:40 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-08 23:23:40 (UTC) |
commit | 647a6c7ec282ea9b0b45baf8935b8eefc3ff8269 (patch) (side-by-side diff) | |
tree | a3b5b8f5d0f53b1adcb52623c34152472911f3f9 | |
parent | 40a1b5f7519c70b5335937573e3425bbc9d0f690 (diff) | |
download | opie-647a6c7ec282ea9b0b45baf8935b8eefc3ff8269.zip opie-647a6c7ec282ea9b0b45baf8935b8eefc3ff8269.tar.gz opie-647a6c7ec282ea9b0b45baf8935b8eefc3ff8269.tar.bz2 |
fixed by patch sent by Tim. Also fixed version in control file
-rw-r--r-- | noncore/apps/opie-reader/QTReader.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/opie-reader.control | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index 6251812..fc9cffb 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp @@ -454,513 +454,513 @@ void QTReader::drawFonts( QPainter *p ) getline(nta[i]); } mylastpos = locate(); delete [] textarray; delete [] locnarray; textarray = nta; locnarray = nla; numlines = sl; } int ypos = (btight) ? 0 : m_ascent-m_linespacing; // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; for (int i = 0; i < numlines; i++) { drawText( *p, 0, ypos += m_linespacing, textarray[i]->data()); } /* int nlines = height()/(fontmetric.ascent()+fontmetric.descent()); tchar buffer[1024]; for (int i = 0; i < nlines; i++) { y += fontmetric.ascent(); sprintf(buffer, "%d:%d:%s[%d]:Lines %d:%s", i+1, m_textfont, fonts[m_textfont], m_fs, nlines, (const tchar*)m_string); drawText( *p, 0, y, buffer ); y += fontmetric.descent(); } */ } m_scrolldy = 0; } QString QTReader::firstword() { if (m_bMonoSpaced) { return toQString(textarray[0]->data()); } else { int start, end, len, j; for (j = 0; j < numlines; j++) { len = textarray[j]->length(); for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++); if (start < len) break; } if (j < numlines) { QString ret = ""; for (end = start; end < len && isalpha((*textarray[j])[end]); end++) ret += (*textarray[j])[end]; if (ret.isEmpty()) ret = "Current position"; return ret; } else return "Current position"; } } // // Construct the QTReader with buttons. // void QTReader::ChangeFont(int tgt) { QValueList<int>::Iterator it; // QValueList<int> sizes = QFontDatabase::pointSizes(m_fontname, (m_bBold) ? QFont::Bold : QFont::Normal); QFontDatabase fdb; /* QStringList styles = fdb.styles(m_fontname); for ( QStringList::Iterator it = styles.begin(); it != styles.end(); ++it ) { printf( "%s \n", (*it).latin1() ); } */ QValueList<int> sizes = fdb.pointSizes(m_fontname, (m_bBold) ? QString("Bold") : QString::null); uint n = sizes.count(); if (fontsizes != NULL) delete [] fontsizes; fontsizes = new unsigned int[n+1]; uint i = 0; uint best = 0; for (it = sizes.begin(); it != sizes.end(); it++) { fontsizes[i] = (*it)/10; if (abs(tgt-fontsizes[i]) < abs(tgt-fontsizes[best])) { best = i; } i++; } m_textsize = best; fontsizes[i] = 0; setfont(NULL); QFont font(m_fontname, fontsizes[m_textsize], (m_bBold) ? QFont::Bold : QFont::Normal ); if (m_fm == NULL) { m_fm = new QFontMetrics(font); buffdoc.setfm(m_fm); } } void QTReader::init() { // setCaption( "Qt Draw Demo Application" ); setBackgroundColor( white ); // QPainter p(this); // p.setBackgroundMode( Qt::OpaqueMode ); buffdoc.setfilter(getfilter()); ChangeFont(m_textsize); // setFocusPolicy(QWidget::StrongFocus); // resize( 240, 320 ); //setFocus(); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); // QMessageBox::information(this, "init", m_lastfile, 1); m_lastwidth = width(); if (!m_lastfile.isEmpty()) { m_string = DocLnk(m_lastfile).name(); load_file(m_lastfile); } } // // Clean up // QTReader::~QTReader() { if (fontsizes != NULL) delete [] fontsizes; #ifndef QT_NO_PRINTER // delete printer; #endif } // // Calls the drawing function as specified by the radio buttons. // void QTReader::drawIt( QPainter *p ) { drawFonts(p); } // // Called when the print button is clicked. // /* void QTReader::printIt() { #ifndef QT_NO_PRINTER if ( printer->setup( this ) ) { QPainter paint; if ( !paint.begin( printer ) ) return; drawIt( &paint ); } #endif } */ // // Called when the widget needs to be updated. // void QTReader::paintEvent( QPaintEvent * ) { QPainter paint( this ); drawIt( &paint ); } // // Called when the widget has been resized. // Moves the button group to the upper right corner // of the widget. /* void QTReader::resizeEvent( QResizeEvent * ) { // qDebug("resize:(%u,%u)", width(), height()); // bgroup->move( width()-bgroup->width(), 0 ); } */ // // Create and display our widget. // /* int main( int argc, tchar **argv ) { QApplication app( argc, argv ); QTReader draw; app.setMainWidget( &draw ); draw.setCaption("Qt Example - Drawdemo"); draw.show(); return app.exec(); } */ bool QTReader::locate(unsigned long n) { //printf("Locate\n"); buffdoc.locate(n); // qDebug("&buffdoc.located"); fillbuffer(); // qDebug("&Buffer filled"); update(); // qDebug("&Located"); return true; } unsigned int QTReader::screenlines() { // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; // return (height()-m_descent)/(m_linespacing); return (height()-2)/(m_linespacing); }; bool QTReader::fillbuffer() { //printf("Fillbuffer\n"); m_scrolldy = 0; int ch; bool ret = false; int delta = screenlines(); // qDebug("fillbuffer:%u-%u",delta,numlines); if (delta != numlines) { if (textarray != NULL) { for (int i = 0; i < numlines; i++) delete textarray[i]; delete [] textarray; delete [] locnarray; } numlines = delta; textarray = new CBuffer*[numlines]; locnarray = new size_t[numlines]; for (int i = 0; i < numlines; i++) textarray[i] = new CBuffer; } // qDebug("fillbuffer:pagepos:%u",pagepos); unsigned int oldpagepos = pagepos; // if (textarray != NULL) // pagepos = locnarray[0]; // else pagepos = locate(); for (int i = 0; i < delta; i++) { locnarray[i] = locate(); ch = getline(textarray[i]); // if (ch == EOF) { if (!ch) { if (i == 0) { - pagepos = oldpagepos; + locate(oldpagepos); return false; } else { ret = true; for (int j = i+1; j < delta; j++) { locnarray[j] = locnarray[j-1]; (*(textarray[j]))[0] = '\0'; } break; } } if (ch == '\012') ret = true; } mylastpos = locate(); // qDebug("fillbuffer:lastpos:%u",mylastpos); return true; } void QTReader::dopagedn() { if (m_overlap == 0) { if (locate() != mylastpos) jumpto(mylastpos); } else { if (m_overlap >= screenlines()) m_overlap = screenlines()/2; jumpto(locnarray[screenlines()-m_overlap]); } if (fillbuffer()) { update(); } } void QTReader::dopageup() { CBuffer** buff = textarray; unsigned int *loc = new unsigned int[numlines]; int cbptr = 0; if (locate() != mylastpos) jumpto(mylastpos); if (m_overlap >= screenlines()) m_overlap = screenlines()/2; unsigned int target = locnarray[m_overlap]; if (buffdoc.hasrandomaccess()) { unsigned int delta = locate()-pagelocate(); if (delta < 64) delta = 64; if (delta % 2 != 0) delta++; if (target % 2 != 0) target++; do { delta <<= 1; if (delta >= target) { delta = target; jumpto(0); for (int i = 0; i < numlines; i++) { loc[i] = locate(); getline(buff[i]); } break; } jumpto(target-delta); do { getline(buff[0]); #ifdef WS //printf("Trying:%s\n",buff[0]); #endif if (locate() > target) continue; } while (!buffdoc.iseol()); for (int i = 0; i < numlines; i++) { loc[i] = locate(); getline(buff[i]); #ifdef WS //printf("Filling:%s\n",buff[i]); #endif } } while (locate() >= target && delta < 4096); #ifdef WS //printf("Delta:%u\n",delta); #endif } else { jumpto(0); for (int i = 0; i < numlines; i++) { loc[i] = locate(); getline(buff[i]); } } cbptr = 0; while (locate() < target) { loc[cbptr] = locate(); getline(buff[cbptr]); #ifdef WS //printf("Adding:%s\n",buff[cbptr]->data()); #endif cbptr = (cbptr+1) % numlines; } pagepos = loc[cbptr]; textarray = new CBuffer*[numlines]; for (int i = 0; i < numlines; i++) { int j = (cbptr+i)%numlines; textarray[i] = buff[j]; locnarray[i] = loc[j]; } delete [] buff; delete [] loc; mylastpos = locate(); update(); } bool QTReader::load_file(const char *newfile, unsigned int _lcn) { // QMessageBox::information(this, "Name", name, 1); // QMessageBox::information(this, "load_file", newfile, 1); bool bRC = false; unsigned int lcn = _lcn; if (m_lastfile == newfile) { lcn = m_lastposn; } m_lastfile = newfile; // QMessageBox::information(0, "Opening...", newfile); if (buffdoc.openfile(this,newfile) == 0) { bRC = true; // qDebug("buffdoc.openfile done"); locate(lcn); // qDebug("buffdoc.locate done"); } update(); // qDebug("Updated"); return bRC; } void QTReader::lineDown() { pagepos = locnarray[1]; CBuffer* buff = textarray[0]; for (int i = 1; i < numlines; i++) { textarray[i-1] = textarray[i]; locnarray[i-1] = locnarray[i]; } locnarray[numlines-1] = locate(); if (getline(buff)) { textarray[numlines-1] = buff; mylastpos = locate(); } else { textarray[numlines-1] = buff; } update(); } /* void QTReader::lineUp() { CBuffer** buff = textarray; unsigned int *loc = new unsigned int[numlines]; int cbptr = 0; if (locate() != mylastpos) jumpto(mylastpos); unsigned int target = locnarray[numlines-1]; if (buffdoc.hasrandomaccess()) { unsigned int delta = locate()-pagelocate(); if (delta < 64) delta = 64; do { delta <<= 1; if (delta >= target) { delta = target; jumpto(0); for (int i = 0; i < numlines; i++) { loc[i] = locate(); getline(buff[i]); } break; } jumpto(target-delta); do { buffdoc.getline(buff[0],width()); #ifdef WS //printf("Trying:%s\n",buff[0]); #endif if (locate() > target) continue; } while (!buffdoc.iseol()); for (int i = 0; i < numlines; i++) { loc[i] = locate(); buffdoc.getline(buff[i],width()); #ifdef WS //printf("Filling:%s\n",buff[i]); #endif } } while (locate() >= target && delta < 4096); #ifdef WS //printf("Delta:%u\n",delta); #endif } else { jumpto(0); for (int i = 0; i < numlines; i++) { loc[i] = locate(); buffdoc.getline(buff[i],width()); } } cbptr = 0; while (locate() < target) { loc[cbptr] = locate(); buffdoc.getline(buff[cbptr], width()); #ifdef WS //printf("Adding:%s\n",buff[cbptr]->data()); #endif cbptr = (cbptr+1) % numlines; } pagepos = loc[cbptr]; textarray = new CBuffer*[numlines]; for (int i = 0; i < numlines; i++) { int j = (cbptr+i)%numlines; textarray[i] = buff[j]; locnarray[i] = loc[j]; } delete [] buff; delete [] loc; mylastpos = locate(); update(); } */ void QTReader::lineUp() { CBuffer* buff = textarray[numlines-1]; unsigned int loc; diff --git a/noncore/apps/opie-reader/opie-reader.control b/noncore/apps/opie-reader/opie-reader.control index e8c98bb..1c28648 100644 --- a/noncore/apps/opie-reader/opie-reader.control +++ b/noncore/apps/opie-reader/opie-reader.control @@ -1,9 +1,9 @@ Files: bin/uqtreader apps/Applications/uqtreader.desktop pics/uqtreader.png pics/panel-arrow-down.png Priority: optional Section: applications Maintainer: Tim Wentford <timwentford@hotmail.com> Architecture: arm -Version: 0_3r_beta_UTF8 -Depends: +Version: $QPE_VERSION-$SUB_VERSION +Depends: zlib License: GPL Description: E-Book reader |