author | paule <paule> | 2007-07-08 08:37:52 (UTC) |
---|---|---|
committer | paule <paule> | 2007-07-08 08:37:52 (UTC) |
commit | b07e25cd398620dafb9ce01982267588645d99a9 (patch) (side-by-side diff) | |
tree | 41e01245b65ff07efce13743a45eefac7923fdcf | |
parent | 4fb748a55cdd77f4bab8dc692ab8ebae62609abe (diff) | |
download | opie-b07e25cd398620dafb9ce01982267588645d99a9.zip opie-b07e25cd398620dafb9ce01982267588645d99a9.tar.gz opie-b07e25cd398620dafb9ce01982267588645d99a9.tar.bz2 |
Fix copying unicode block to clipboard. See bug #1766. Patch from polyonymous.
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index b985094..4f0f0a1 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp @@ -2369,385 +2369,385 @@ void QTReaderApp::showinfo() editorStack->raiseWidget( m_infoWin ); hidetoolbars(); m_infoWin->setFocus(); } } void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) { if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; #ifdef _UNICODE CBuffer buff(name.length()+1); int i; for (i = 0; i < name.length(); i++) { buff[i] = name[i].unicode(); } buff[i] = 0; CBuffer buff2(text.length()+1); for (i = 0; i < text.length(); i++) { buff2[i] = text[i].unicode(); } buff2[i] = 0; Bkmk b(buff.data(), buff2.data(), posn, posn2); QColor c = m_annoWin->getColor(); int red,green,blue; c.rgb(&red, &green, &blue); b.red(red); b.green(green); b.blue(blue); pBkmklist->push_front(b); #else pBkmklist->push_front(Bkmk((const tchar*)text,posn)); #endif m_fBkmksChanged = true; pBkmklist->sort(); } void QTReaderApp::addAnno(const QString& name, const QString& text) { if (m_annoIsEditing) { if (name.isEmpty()) { QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); } else { addAnno(name, text, m_annoWin->getPosn(), m_annoWin->getPosn2()); } showEditTools(); } else { if (m_annoWin->edited()) { CBuffer buff(text.length()+1); int i; for (i = 0; i < text.length(); i++) { buff[i] = text[i].unicode(); } buff[i] = 0; m_fBkmksChanged = true; m_anno->setAnno(buff.data()); } QColor c = m_annoWin->getColor(); int red,green,blue; c.rgb(&red, &green, &blue); m_anno->red(red); m_anno->green(green); m_anno->blue(blue); bool found = findNextBookmark(m_anno->value()+1); if (found) { m_annoWin->setName(toQString(m_anno->name())); m_annoWin->setAnno(toQString(m_anno->anno())); m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); } else { showEditTools(); } } } bool QTReaderApp::findNextBookmark(size_t start) { bool found = false; for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) { if (iter->value() >= start) { if (iter->value() < reader->locate()) { found = true; m_anno = iter.pContent(); } break; } } return found; } void QTReaderApp::addanno() { if (reader->empty()) { QMessageBox::information(this, PROGNAME, "No file loaded", 1); } else { m_annoWin->setName(""); m_annoWin->setAnno(""); m_annoWin->setPosn(reader->pagelocate()); m_annoIsEditing = true; editorStack->raiseWidget( m_annoWin ); hidetoolbars(); #ifdef USEQPE Global::showInputMethod(); #endif m_annoWin->setFocus(); } } void QTReaderApp::infoClose() { m_debounce = m_buttonprefs->Debounce(); if (m_kmapchanged) { m_kmapchanged = false; #ifndef USEQPE QDir d = QDir::home(); // "/" d.cd(APPDIR); QFileInfo fi(d, ".keymap"); FILE* f = fopen((const char *)fi.absFilePath(), "w"); #else /* USEQPE */ FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "w"); #endif /* USEQPE */ if (f != NULL) { uint cnt = KEYMAPVERSION; fwrite(&cnt, sizeof(cnt), 1, f); cnt = kmap.count(); fwrite(&cnt, sizeof(cnt), 1, f); for (QMap<orKey,int>::Iterator i = kmap.begin(); i != kmap.end(); i++) { orKey key = i.key(); int data = i.data(); fwrite(&key, sizeof(key), 1, f); fwrite(&data, sizeof(data), 1, f); qDebug("Saved %s as %u", (const char*)key.text(), data); } fclose(f); } } showEditTools(); } /* void QTReaderApp::fileRevert() { clear(); fileOpen(); } void QTReaderApp::editCut() { #ifndef QT_NO_CLIPBOARD editor->cut(); #endif } */ void QTReaderApp::editMark() { m_savedpos = reader->pagelocate(); } void QTReaderApp::editCopy() { QClipboard* cb = QApplication::clipboard(); QString text; int ch; unsigned long currentpos = reader->pagelocate(); unsigned long endpos = reader->locate(); if (m_savedpos == 0xffffffff) { m_savedpos = currentpos; } reader->jumpto(m_savedpos); while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) { - text += ch; + text += QChar(ch); } cb->setText(text); reader->locate(currentpos); m_savedpos = 0xffffffff; } void QTReaderApp::gotoStart() { reader->locate(reader->buffdoc.startSection()); } void QTReaderApp::gotoEnd() { reader->dopageup(reader->buffdoc.endSection()); } void QTReaderApp::pageup() { reader->NavUp(); } void QTReaderApp::pagedn() { reader->NavDown(); } void QTReaderApp::pagemode(bool _b) { reader->setpagemode(_b); } /* void QTReaderApp::setspacing() { m_nRegAction = cMonoSpace; char lcn[20]; sprintf(lcn, "%lu", reader->m_charpc); regEdit->setText(lcn); do_regedit(); } */ void QTReaderApp::settarget() { m_nRegAction = cSetTarget; QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) + "/" + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); regEdit->setText(text); do_regedit(); } /* void QTReaderApp::do_mono(const QString& lcn) { bool ok; unsigned long ulcn = lcn.toULong(&ok); if (ok) { reader->m_charpc = ulcn; reader->setfont(); reader->refresh(); // reader->setmono(true); } else QMessageBox::information(this, PROGNAME, "Must be a number"); } */ /* void QTReaderApp::editPaste() { #ifndef QT_NO_CLIPBOARD editor->paste(); #endif } */ void QTReaderApp::editFind() { searchStart = reader->pagelocate(); #ifdef __ISEARCH searchStack = new QStack<searchrecord>; #endif #ifdef USEQPE Global::showInputMethod(); #endif searchBar->show(); searchVisible = TRUE; searchEdit->setFocus(); #ifdef __ISEARCH searchStack->push(new searchrecord("",reader->pagelocate())); #endif } void QTReaderApp::findNext() { // // qDebug("findNext called\n"); #ifdef __ISEARCH QString arg = searchEdit->text(); #else QRegExp arg = searchEdit->text(); #endif CDrawBuffer test(&(reader->m_fontControl)); size_t start = reader->pagelocate(); reader->jumpto(start); reader->getline(&test); dosearch(start, test, arg); } void QTReaderApp::findClose() { searchVisible = FALSE; searchEdit->setText(""); #ifdef USEQPE Global::hideInputMethod(); #endif searchBar->hide(); #ifdef __ISEARCH // searchStack = new QStack<searchrecord>; while (!searchStack->isEmpty()) { delete searchStack->pop(); } delete searchStack; #endif reader->setFocus(); } void QTReaderApp::regClose() { regVisible = FALSE; regEdit->setText(""); regBar->hide(); #ifdef USEQPE Global::hideInputMethod(); #endif reader->setFocus(); } #ifdef __ISEARCH bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) #else bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) #endif { bool ret = true; unsigned long fs, ts; reader->sizes(fs,ts); size_t pos = reader->locate(); pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); pbar->show(); pbar->raise(); pbar->reset(); int offset; int lastpc = (100*pos)/ts; pbar->setProgress(lastpc); // qApp->processEvents(); if (reader->buffdoc.getpara(test) >= 0) { reader->setFocus(); #ifdef __ISEARCH while (strstr(test.data(),(const tchar*)arg) == NULL) #else #ifdef _UNICODE while ((offset = arg.match(toQString(test.data()))) == -1) #else while (arg.match(test.data()) == -1) #endif #endif { pos = reader->locate(); int pc = (100*pos)/ts; if (pc != lastpc) { pbar->setProgress(pc); qApp->processEvents(); reader->setFocus(); lastpc = pc; } if (reader->buffdoc.getpara(test) < 0) { if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) pos = searchStart; else pos = start; findClose(); pbar->hide(); reader->locate(pos); return false; } } // qDebug("Found it at %u:%u", pos, offset); |