void DocumentWidget::mousePressEvent ( QMouseEvent * e ) { #ifdef DEBUG_DOCUMENTWIDGET kdDebug(1223) << "DocumentWidget::mousePressEvent(...) called" << endl; #endif // Make sure the event is passed on to the higher-level widget; // otherwise QT gets the coordinated in the mouse move events wrong e->ignore(); // pageNr == 0 indicated an invalid page (e.g. page number not yet // set) if (pageNr == 0) return; // Get a pointer to the page contents RenderedDocumentPage *pageData = documentCache->getPage(pageNr); if (pageData == 0) { kdDebug(1223) << "DocumentWidget::selectAll() pageData for page #" << pageNr << " is empty" << endl; return; } // Check if the mouse is pressed on a regular hyperlink if (e->button() == LeftButton) { if (pageData->hyperLinkList.size() > 0) for(unsigned int i = 0; i < pageData->hyperLinkList.size(); i++) { if (pageData->hyperLinkList[i].box.contains(e->pos())) { emit(localLink(pageData->hyperLinkList[i].linkText)); return; } } if (moveTool) setCursor(Qt::SizeAllCursor); else setCursor(Qt::IbeamCursor); } if (e->button() == RightButton || (!moveTool && e->button() == LeftButton)) { setCursor(Qt::IbeamCursor); // If Shift is not pressed clear the current selection, // otherwise modify the existing selection. if (!(e->state() & ShiftButton)) { firstSelectedPoint = e->pos(); selectedRectangle = QRect(); selectedRegion = QRegion(); emit clearSelection(); } } }
void TextLine::Flush() { const int32 n = fSegments.CountItems(); if (n == 0) return; // build the text in the line BString line; for (int32 i = 0; i < n; i ++) { line << fSegments.ItemAt(i)->Text(); } const char* c = line.String(); if (!fWriter->MakesPDF()) { if (fWriter->fCreateXRefs) fWriter->RecordDests(c); } else { // simple link handling for now WebLink webLink(fWriter, &line); if (fWriter->fCreateWebLinks) webLink.Do(); // local links LocalLink localLink(fWriter->fXRefs, fWriter->fXRefDests, fWriter, &line, fWriter->fPage); if (fWriter->fCreateXRefs) localLink.Do(); // simple bookmark adding if (fWriter->fCreateBookmarks) { TextSegment* s = fSegments.ItemAt(0); BFont* f = s->Font(); PDFSystem* system = s->System(); BPoint start(system->tx(s->Start().x), system->ty(s->Start().y)); font_height height; f->GetHeight(&height); float h = system->scale(height.ascent); fWriter->fBookmark->AddBookmark(start, h, c, f); } } fSegments.MakeEmpty(); }