void CardView::contentsMouseReleaseEvent( QMouseEvent *e ) { Q3ScrollView::contentsMouseReleaseEvent( e ); if ( d->mResizeAnchor && d->mSpan ) { unsetCursor(); // hide rubber bands int newiw = d->mItemWidth - ((d->mResizeAnchor - d->mRubberBandAnchor) / d->mSpan); drawRubberBands( 0 ); // we should move to reflect the new position if we are scrolled. if ( contentsX() ) { int newX = qMax( 0, ( d->mPressed * ( newiw + d->mColspace + d->mSepWidth ) ) - e->x() ); setContentsPos( newX, contentsY() ); } // set new item width setItemWidth( newiw ); // reset anchors d->mResizeAnchor = 0; d->mRubberBandAnchor = 0; return; } // If there are accel keys, we will not emit signals if ( (e->modifiers() & Qt::ShiftModifier) || (e->modifiers() & Qt::ControlModifier) ) return; // Get the item at this position CardViewItem *item = itemAt( e->pos() ); if ( item && KGlobalSettings::singleClick() ) emit executed( item ); }
bool QScrollView::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: resizeContents((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 1: scrollBy((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 2: setContentsPos((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 3: ensureVisible((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 4: ensureVisible((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4)); break; case 5: center((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 6: center((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(float)(*((float*)static_QUType_ptr.get(_o+3))),(float)(*((float*)static_QUType_ptr.get(_o+4)))); break; case 7: updateScrollBars(); break; case 8: setEnabled((bool)static_QUType_bool.get(_o+1)); break; case 9: hslide((int)static_QUType_int.get(_o+1)); break; case 10: vslide((int)static_QUType_int.get(_o+1)); break; case 11: hbarIsPressed(); break; case 12: hbarIsReleased(); break; case 13: vbarIsPressed(); break; case 14: vbarIsReleased(); break; case 15: doDragAutoScroll(); break; case 16: startDragAutoScroll(); break; case 17: stopDragAutoScroll(); break; default: return QFrame::qt_invoke( _id, _o ); } return TRUE; }
void xQGanttListView::contentsMoved(int x, int y) //////////////////////////////////////////// { printf("xQGanttListView::contentsMoved(%d,%d)\n", x, y); setContentsPos( 0, y ); }
void MsgView::addMessage(ICQMessage *msg, bool bUnread, bool bSet) { if (msg->Id >= MSG_PROCESS_ID) return; int x = contentsX(); int y = contentsY(); QString s(makeMessage(msg, bUnread)); if (bSet) curAnchor = QString::number(msg->getUin()) + "." + QString::number(msg->Id); unsigned long foreColor = 0; unsigned long backColor = 0; if (!pMain->UseOwnColors() && (msg->Type() == ICQ_MSGxMSG)){ ICQMsg *m = static_cast<ICQMsg*>(msg); foreColor = m->ForeColor(); backColor = m->BackColor(); } if (bBack){ setText(s + text(), curAnchor); if (foreColor != backColor) setMsgBgColor(msg->getUin(), msg->Id, backColor, 0); }else{ int n = paragraphs(); if (n > 0) n--; append(s); if (foreColor != backColor) setMsgBgColor(msg->getUin(), msg->Id, backColor, n); } if (bSet){ scrollToBottom(); }else{ setContentsPos(x, y); } }
void HistoryView::messageReceived(ICQMessage *msg) { if (msg->getUin() != m_nUin) return; if (msg->Id >= MSG_PROCESS_ID) return; int x = contentsX(); int y = contentsY(); bool bUnread = false; ICQUser *u = pClient->getUser(m_nUin); if (u){ for (list<unsigned long>::iterator it = u->unreadMsgs.begin(); it != u->unreadMsgs.end(); it++){ if ((*it) == msg->Id){ bUnread = true; break; } } } if (bBack){ QString saveText = text(); setText(""); addMessage(msg, bUnread, false); y += contentsHeight(); setText(text() + saveText); }else{ addMessage(msg, bUnread, false); } setContentsPos(x, y); }
void RosegardenScrollView::slotScrollHoriz(int hpos) { QScrollBar* hbar = getMainHorizontalScrollBar(); int currentContentYPos = contentsY(); /* Lots of performance hitting debug RG_DEBUG << "RosegardenScrollView::slotScrollHoriz: hpos is " << hpos << ", contentsX is " << contentsX() << ", visibleWidth is " << visibleWidth() << endl; */ if (hpos == 0) { // returning to zero // hbar->setValue(0); setContentsPos(0, currentContentYPos); //@@@ // possible replacement: ?? //this->widget()->move( 0, currentContentYPos ) } else if (hpos > (contentsX() + visibleWidth() * 1.6) || hpos < (contentsX() - visibleWidth() * 0.7)) { // miles off one side or the other // hbar->setValue(hpos - int(visibleWidth() * 0.4)); setContentsPos(hpos - int(visibleWidth() * 0.4), currentContentYPos); } else if (hpos > (contentsX() + visibleWidth() * 0.9)) { // moving off the right hand side of the view // hbar->setValue(hbar->value() + int(visibleWidth() * 0.6)); setContentsPos(hbar->value() + int(visibleWidth() * 0.6), currentContentYPos); } else if (hpos < (contentsX() + visibleWidth() * 0.1)) { // moving off the left // hbar->setValue(hbar->value() - int(visibleWidth() * 0.6)); setContentsPos(hbar->value() - int(visibleWidth() * 0.6), currentContentYPos); } }
void AppPage::completed( int width, int height, int x, int y ) { width = ( width == 0 ) ? m_splitter->sizeHint().width() : width; height = ( height == 0 ) ? m_splitter->sizeHint().height() : height; resizeContents( width, height+20 ); // must call this to repaint background //viewport()->resize( width, height ); //ensureVisible( x, y, 0, 0 ); setContentsPos( x, y ); }
void RosegardenScrollView::slotScrollHorizSmallSteps(int hpos) { QScrollBar* hbar = getMainHorizontalScrollBar(); int currentContentYPos = contentsY(); int diff = 0; if (hpos == 0) { // returning to zero // hbar->setValue(0); setContentsPos(0, currentContentYPos); } else if ((diff = int(hpos - (contentsX() + visibleWidth() * 0.90))) > 0) { // moving off the right hand side of the view int delta = diff / 6; int diff10 = std::min(diff, (int)m_minDeltaScroll); delta = std::max(delta, diff10); // hbar->setValue(hbar->value() + delta); setContentsPos(hbar->value() + delta, currentContentYPos); } else if ((diff = int(hpos - (contentsX() + visibleWidth() * 0.10))) < 0) { // moving off the left int delta = -diff / 6; int diff10 = std::min( -diff, (int)m_minDeltaScroll); delta = std::max(delta, diff10); // hbar->setValue(hbar->value() - delta); setContentsPos(hbar->value() - delta, currentContentYPos); } }
void PageView::moveViewportToWidget(QWidget* widget, int y) { int verticalPos = 0; int verticalPosTop = 0; if (y != 0) { verticalPosTop = childY(widget) + y - visibleHeight()/2; verticalPos = childY(widget) + y; } else { verticalPos = childY(widget) - distanceBetweenWidgets; verticalPosTop = verticalPos; } if (nrCols == 1) { // In single column viewmodes, we change the vertical position only, to make it // easier to work with high zoomlevels where not the whole pagewidth is visible. // TODO: Smarter algorithm also for continuous facing viewmode. int top = (int)(contentsY() + 0.1 * visibleHeight()); int bottom = (int)(contentsY() + 0.9 * visibleHeight()); // Move the viewport if the target is currently not visible, or lies at the edge // of the viewport. If y = 0 always move the top of the targetpage to the top edge // of the viewport. if (verticalPos < top || verticalPos > bottom || y == 0) { setContentsPos(contentsX(), verticalPosTop); } } else { setContentsPos(childX(widget) - distanceBetweenWidgets, verticalPosTop); } }
bool QIconView::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: arrangeItemsInGrid((const QSize&)*((const QSize*)static_QUType_ptr.get(_o+1))); break; case 1: arrangeItemsInGrid((const QSize&)*((const QSize*)static_QUType_ptr.get(_o+1)),(bool)static_QUType_bool.get(_o+2)); break; case 2: arrangeItemsInGrid(); break; case 3: arrangeItemsInGrid((bool)static_QUType_bool.get(_o+1)); break; case 4: setContentsPos((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 5: updateContents(); break; case 6: doAutoScroll(); break; case 7: adjustItems(); break; case 8: slotUpdate(); break; case 9: movedContents((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; default: return QScrollView::qt_invoke( _id, _o ); } return TRUE; }
void MsgView::colorsChanged() { int x = contentsX(); int y = contentsY(); char FONT_SEND[] = "<##FontSend##>"; char FONT_RECEIVE[] = "<##FontReceive##>"; QString t = text(); QString c; c.sprintf(FONT_FORMAT, oldSendColor); t.replace(QRegExp(c), FONT_SEND); c.sprintf(FONT_FORMAT, oldReceiveColor); t.replace(QRegExp(c), FONT_RECEIVE); c.sprintf(FONT_FORMAT, pMain->ColorSend()); t.replace(QRegExp(FONT_SEND), c); c.sprintf(FONT_FORMAT, pMain->ColorReceive()); t.replace(QRegExp(FONT_RECEIVE), c); setText(t); setContentsPos(x, y); }
// ------------------------------------------------------------------------------- void Editor::activeInformationElementChanged( CInformationElement* pElement ) // ------------------------------------------------------------------------------- { /* QMimeSourceFactory::defaultFactory()->setPixmap("newImg", QPixmap("/home/alex/aufgehoben/bilder/alex.gif")); setText( " Hier ist ein Bild <img source=\"newImg\">." ); return; */ if ( !pElement ) return; //std::cout<<"Editor::activeInformationElementChanged()"<<std::endl; //std::cout<<"\tnew Element: "<<pElement->getDescription()<<std::endl; if ( mpActiveElement ) { disconnect( mpActiveElement, SIGNAL(informationHasChanged()), this, SLOT(rereadInformation()) ); writeCurrentTextToActiveInformationElement(); mpActiveElement->setInformationYPos( contentsY() ); } if ( pElement->getInformationFormat() == &InformationFormat::RTF ) { emit formatRecognized( InformationFormat::RTF ); setTextFormat( Qt::RichText ); } else if ( pElement->getInformationFormat() == &InformationFormat::ASCII ) { emit formatRecognized( InformationFormat::ASCII ); setTextFormat( Qt::PlainText ); } setText( pElement->getInformation() ); sync(); setContentsPos( 0, pElement->getInformationYPos() ); mpActiveElement = pElement; connect( mpActiveElement, SIGNAL(informationHasChanged()), this, SLOT(rereadInformation()) ); }
bool QListView::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: clear(); break; case 1: invertSelection(); break; case 2: selectAll((bool)static_QUType_bool.get(_o+1)); break; case 3: triggerUpdate(); break; case 4: setContentsPos((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 5: adjustColumn((int)static_QUType_int.get(_o+1)); break; case 6: updateContents(); break; case 7: doAutoScroll(); break; case 8: changeSortColumn((int)static_QUType_int.get(_o+1)); break; case 9: handleIndexChange(); break; case 10: updateDirtyItems(); break; case 11: makeVisible(); break; case 12: handleSizeChange((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break; case 13: startRename(); break; case 14: openFocusItem(); break; default: return QScrollView::qt_invoke( _id, _o ); } return TRUE; }
void PolicyViewClass::init() { // delete all childs QObjectList * childs; while((childs = const_cast<QObjectList *>(viewport()->children())) != NULL && !childs->isEmpty()) { delete childs->first(); } //-------------------------// // rebuild the widget list // //-------------------------// QStringList list = document.getPatternNames(); QStringList::Iterator patternIter = list.begin(); while (patternIter !=list.end()) { // generate pattern widget // QString patternName = *patternIter; PatternWidgetClass* patternWidget = new PatternWidgetClass(this, viewport(), patternName); patternWidget->show(); int x = std::max(0, document.getX(patternName)); int y = std::max(0, document.getY(patternName)); addChild(patternWidget, x, y); patternIter++; } QRect r = viewport()->childrenRect(); QPoint s = viewportToContents(r.bottomRight()); resizeContents(s.x(), s.y()); setContentsPos(0, 0); }
void VariablesListView::setVariables(VariablesList_t* vars) { /* saves the position of the viewport * ('cause when the view is repopulated, the scroll goes up) */ int contentX = contentsX(); int contentY = contentsY(); /* backup the current item selected */ QString currentSelected; VariablesListViewItem* item; item = dynamic_cast<VariablesListViewItem*>(selectedItem()); if(item) { currentSelected = item->stringPath(); } clear(); deleteVars(); /* finally, add the new ones */ addVariables(vars); /* expand the new items according to the previous state */ reexpandItems(); /* resets the viewport position */ setContentsPos(contentX, contentY); m_variables = vars; }
/*! Scrolls the browser so that the part of the document named \a name is at the top of the view (or as close to the top as the size of the document allows). */ void QTextBrowser::scrollToAnchor(const QString& name) { if ( name.isEmpty() ) return; d->curmark = name; QRichTextIterator it( richText() ); do { if ( it.format()->anchorName() == name ) { QTextParagraph* b = it.outmostParagraph(); if ( b->dirty ) { // QTextView layouts delayed in the background, so this may happen QRichTextFormatter tc( richText() ); tc.gotoParagraph( 0, &richText() ); tc.updateLayout(); resizeContents( QMAX( richText().flow()->widthUsed-1, visibleWidth() ), richText().flow()->height ); } QRect r = it.lineGeometry(); setContentsPos( contentsX(), r.top() ); return; } } while ( it.right( FALSE ) ); }
/*! Sets the text document with the given \a name to be displayed. The name is looked up in the mimeSourceFactory() of the browser. In addition to the factory lookup, this functions also checks for optional anchors and scrolls the document accordingly. If the first tag in the document is \c <qt \c type=detail>, it is displayed as a popup rather than as new document in the browser window itself. Otherwise, the document is set normally via setText(), with \a name as new context. If you are using the filesystem access capabilities of the mime source factory, you have to ensure that the factory knows about the encoding of specified text files, otherwise no data will be available. The default factory handles a couple of common file extensions such as \c *.html and \c *.txt with reasonable defaults. See QMimeSourceFactory::data() for details. */ void QTextBrowser::setSource(const QString& name) { #ifndef QT_NO_CURSOR if ( isVisible() ) qApp->setOverrideCursor( waitCursor ); #endif QString source = name; QString mark; int hash = name.find('#'); if ( hash != -1) { source = name.left( hash ); mark = name.mid( hash+1 ); } if ( source.left(5) == "file:" ) source = source.mid(6); QString url = mimeSourceFactory()->makeAbsolute( source, context() ); QString txt; bool dosettext = FALSE; if ( !source.isEmpty() && url != d->curmain ) { const QMimeSource* m = mimeSourceFactory()->data( source, context() ); if ( !m ){ qWarning("QTextBrowser: no mimesource for %s", source.latin1() ); } else { if ( !QTextDrag::decode( m, txt ) ) { qWarning("QTextBrowser: cannot decode %s", source.latin1() ); } } if ( isVisible() ) { QString firstTag = txt.left( txt.find('>' )+1 ); QRichText* tmp = new QRichText( firstTag, QApplication::font() ); static QString s_type = QString::fromLatin1("type"); static QString s_detail = QString::fromLatin1("detail"); bool doReturn = FALSE; if ( tmp->attributes().contains(s_type) && tmp->attributes()[s_type] == s_detail ) doReturn = TRUE; QTextFormatCollection* formats = tmp->formats; delete tmp; delete formats; //#### fix inheritance structure in rich text if ( doReturn ) { popupDetail( txt, d->lastClick ); #ifndef QT_NO_CURSOR qApp->restoreOverrideCursor(); #endif return; } } d->curmain = url; dosettext = TRUE; } d->curmark = mark; if ( !mark.isEmpty() ) { url += "#"; url += mark; } if ( !d->home ) d->home = url; if ( d->stack.isEmpty() || d->stack.top() != url) { d->stack.push( url ); } int stackCount = d->stack.count(); if ( d->stack.top() == url ) stackCount--; emit backwardAvailable( stackCount > 0 ); stackCount = d->forwardStack.count(); if ( d->forwardStack.top() == url ) stackCount--; emit forwardAvailable( stackCount > 0 ); if ( dosettext ) setText( txt, url ); if ( isVisible() && !mark.isEmpty() ) scrollToAnchor( mark ); else setContentsPos( 0, 0 ); #ifndef QT_NO_CURSOR if ( isVisible() ) qApp->restoreOverrideCursor(); #endif }
void ScrollView::scrollRectIntoViewRecursively(const IntRect& rect) { setContentsPos(rect.x(), rect.y()); }
int Q3IconView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = Q3ScrollView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: selectionChanged(); break; case 1: selectionChanged((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break; case 2: currentChanged((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break; case 3: clicked((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break; case 4: clicked((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break; case 5: pressed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break; case 6: pressed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break; case 7: doubleClicked((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break; case 8: returnPressed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break; case 9: rightButtonClicked((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break; case 10: rightButtonPressed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break; case 11: mouseButtonPressed((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Q3IconViewItem*(*)>(_a[2])),(*reinterpret_cast< const QPoint(*)>(_a[3]))); break; case 12: mouseButtonClicked((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Q3IconViewItem*(*)>(_a[2])),(*reinterpret_cast< const QPoint(*)>(_a[3]))); break; case 13: contextMenuRequested((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break; case 14: dropped((*reinterpret_cast< QDropEvent*(*)>(_a[1])),(*reinterpret_cast< const Q3ValueList<Q3IconDragItem>(*)>(_a[2]))); break; case 15: moved(); break; case 16: onItem((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break; case 17: onViewport(); break; case 18: itemRenamed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break; case 19: itemRenamed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break; case 20: arrangeItemsInGrid((*reinterpret_cast< const QSize(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break; case 21: arrangeItemsInGrid((*reinterpret_cast< const QSize(*)>(_a[1]))); break; case 22: arrangeItemsInGrid((*reinterpret_cast< bool(*)>(_a[1]))); break; case 23: arrangeItemsInGrid(); break; case 24: setContentsPos((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 25: updateContents(); break; case 26: doAutoScroll(); break; case 27: adjustItems(); break; case 28: slotUpdate(); break; case 29: movedContents((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; } _id -= 30; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = sorting(); break; case 1: *reinterpret_cast< bool*>(_v) = sortDirection(); break; case 2: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break; case 3: *reinterpret_cast< int*>(_v) = gridX(); break; case 4: *reinterpret_cast< int*>(_v) = gridY(); break; case 5: *reinterpret_cast< int*>(_v) = spacing(); break; case 6: *reinterpret_cast< ItemTextPos*>(_v) = itemTextPos(); break; case 7: *reinterpret_cast< QBrush*>(_v) = itemTextBackground(); break; case 8: *reinterpret_cast< Arrangement*>(_v) = arrangement(); break; case 9: *reinterpret_cast< ResizeMode*>(_v) = resizeMode(); break; case 10: *reinterpret_cast< int*>(_v) = maxItemWidth(); break; case 11: *reinterpret_cast< int*>(_v) = maxItemTextLength(); break; case 12: *reinterpret_cast< bool*>(_v) = autoArrange(); break; case 13: *reinterpret_cast< bool*>(_v) = itemsMovable(); break; case 14: *reinterpret_cast< bool*>(_v) = wordWrapIconText(); break; case 15: *reinterpret_cast< bool*>(_v) = showToolTips(); break; case 16: *reinterpret_cast< uint*>(_v) = count(); break; } _id -= 17; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 2: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break; case 3: setGridX(*reinterpret_cast< int*>(_v)); break; case 4: setGridY(*reinterpret_cast< int*>(_v)); break; case 5: setSpacing(*reinterpret_cast< int*>(_v)); break; case 6: setItemTextPos(*reinterpret_cast< ItemTextPos*>(_v)); break; case 7: setItemTextBackground(*reinterpret_cast< QBrush*>(_v)); break; case 8: setArrangement(*reinterpret_cast< Arrangement*>(_v)); break; case 9: setResizeMode(*reinterpret_cast< ResizeMode*>(_v)); break; case 10: setMaxItemWidth(*reinterpret_cast< int*>(_v)); break; case 11: setMaxItemTextLength(*reinterpret_cast< int*>(_v)); break; case 12: setAutoArrange(*reinterpret_cast< bool*>(_v)); break; case 13: setItemsMovable(*reinterpret_cast< bool*>(_v)); break; case 14: setWordWrapIconText(*reinterpret_cast< bool*>(_v)); break; case 15: setShowToolTips(*reinterpret_cast< bool*>(_v)); break; } _id -= 17; } else if (_c == QMetaObject::ResetProperty) { _id -= 17; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 17; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 17; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 17; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 17; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 17; } #endif // QT_NO_PROPERTIES return _id; }
void Q3TextBrowser::setSource(const QString& name) { #ifndef QT_NO_CURSOR if (isVisible()) qApp->setOverrideCursor(Qt::WaitCursor); #endif d->textOrSourceChanged = true; QString source = name; QString mark; int hash = name.indexOf(QLatin1Char('#')); if (hash != -1) { source = name.left(hash); mark = name.mid(hash+1); } if (source.left(5) == QLatin1String("file:")) source = source.mid(6); QString url = mimeSourceFactory()->makeAbsolute(source, context()); QString txt; bool dosettext = false; if (!source.isEmpty() && url != d->curmain) { const QMimeSource* m = mimeSourceFactory()->data(source, context()); if (!m){ qWarning("Q3TextBrowser: no mimesource for %s", source.latin1()); } else { if (!Q3TextDrag::decode(m, txt)) { qWarning("Q3TextBrowser: cannot decode %s", source.latin1()); } } if (isVisible()) { QString firstTag = txt.left(txt.indexOf(QLatin1Char('>')) + 1); if (firstTag.left(3) == QLatin1String("<qt") && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) { popupDetail(txt, QCursor::pos()); #ifndef QT_NO_CURSOR qApp->restoreOverrideCursor(); #endif return; } } d->curmain = url; dosettext = true; } d->curmark = mark; if (!mark.isEmpty()) { url += QLatin1Char('#'); url += mark; } if (d->home.count() == 0) d->home = url; if (d->stack.isEmpty() || d->stack.top() != url) d->stack.push(url); int stackCount = (int)d->stack.count(); if (d->stack.top() == url) stackCount--; emit backwardAvailable(stackCount > 0); stackCount = (int)d->forwardStack.count(); if (d->forwardStack.isEmpty() || d->forwardStack.top() == url) stackCount--; emit forwardAvailable(stackCount > 0); if (dosettext) Q3TextEdit::setText(txt, url); if (!mark.isEmpty()) scrollToAnchor(mark); else setContentsPos(0, 0); #ifndef QT_NO_CURSOR if (isVisible()) qApp->restoreOverrideCursor(); #endif emit sourceChanged(url); }
void MsgViewBase::update() { if (m_updated.empty()) return; unsigned i; for (i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); list<Msg_Id>::iterator it; for (it = m_updated.begin(); it != m_updated.end(); ++it){ if (((*it).id == id) && ((*it).client == client)) break; } if (it != m_updated.end()) break; } m_updated.clear(); if (i >= (unsigned)paragraphs()) return; int x = contentsX(); int y = contentsY(); viewport()->setUpdatesEnabled(false); unsigned start = i; list<Msg_Id> msgs; for (; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); list<Msg_Id>::iterator it; for (it = msgs.begin(); it != msgs.end(); ++it){ if (((*it).id == id) && ((*it).client == client)) break; } if (it != msgs.end()) continue; Msg_Id m_id; m_id.id = id; m_id.client = client; msgs.push_back(m_id); } int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setReadOnly(false); setSelection(start, 0, paragraphs() - 1, 0xFFFF, 0); removeSelectedText(); setReadOnly(true); QString text; for (list<Msg_Id>::iterator it = msgs.begin(); it != msgs.end(); ++it){ Message *msg = History::load((*it).id, (*it).client.c_str(), m_id); if (msg == NULL) continue; bool bUnread = false; for (list<msg_id>::iterator itu = CorePlugin::m_plugin->unread.begin(); itu != CorePlugin::m_plugin->unread.end(); ++itu){ msg_id &m = (*itu); if ((m.contact == msg->contact()) && (m.id == msg->id()) && (m.client == msg->client())){ bUnread = true; break; } } text += messageText(msg, bUnread); } viewport()->setUpdatesEnabled(true); append(text); if (!CorePlugin::m_plugin->getOwnColors()) setBackground(i); if ((paraFrom != paraTo) || (indexFrom != indexTo)) setSelection(paraFrom, indexFrom, paraTo, indexTo, 0); TextShow::sync(); setContentsPos(x, y); viewport()->repaint(); }
void QTodoList::restoreContentsYPos() { setContentsPos(0,preserved_contents_y_pos); }