Example #1
0
void MsgView::messageRead(ICQMessage *msg)
{
    QString pat;
    pat.sprintf("<p><a name=\"%lu.%lu\"></a></p>", msg->Uin(), msg->Id);
    QString res;
    QString t = text();
    int pos = t.find(pat);
    if (pos < 0) return;
    bool isUpdates = viewport()->isUpdatesEnabled();
    viewport()->setUpdatesEnabled(false);
    res = t.left(pos);
    if (msg){
        bool bSaveBack = bBack;
        bBack = false;
        res += makeMessage(msg, false);
        bBack = bSaveBack;
    }
    t = t.mid(pos+1);
    pos = t.find("<p><a name=");
    if (pos >= 0) res += t.mid(pos);
    setText(res);
    curAnchor = QString::number(msg->Uin()) + "." + QString::number(msg->Id);
    scrollToAnchor(curAnchor);
    if (!isUpdates) return;
    viewport()->setUpdatesEnabled(true);
    viewport()->repaint();
}
Example #2
0
void MsgView::setMessage(unsigned long uin, unsigned long msgId)
{
    QString pat;
    pat.sprintf("<p><a name=\"%lu.%lu\"></a>", uin, msgId);
    if (text().find(pat) < 0) return;
    curAnchor = QString::number(uin) + "." + QString::number(msgId);
    scrollToAnchor(curAnchor);
}
Example #3
0
void MyTextBrowser::tbScrollToAnchor(QString &text)
{
#ifdef NO_WEBKIT
  scrollToAnchor(text);
#else
  QWebPage *pageptr = page();
  if(pageptr != NULL)
  {
    pageptr->currentFrame()->scrollToAnchor(text);
  }
#endif
}
Example #4
0
void MsgView::addMessage(ICQMessage *msg, bool bUnread)
{
    if (msg->Id >= MSG_PROCESS_ID) return;
    bool bUpdates = viewport()->isUpdatesEnabled();
    viewport()->setUpdatesEnabled(false);
    QString s(makeMessage(msg, bUnread));
    if (bBack){
        setText(s + text());
    }else{
        setText(text() + s);
    }
    scrollToAnchor(curAnchor);
    if (!bUpdates) return;
    viewport()->setUpdatesEnabled(true);
    viewport()->repaint();
}
Example #5
0
void WordView::htmlUpdated(ContentType type)
{
	setText(html());

	switch (type)
	{
	case Content_Upcoming:
		scrollToAnchor("top");
		break;

	case Content_Solutions:
		QTextCursor cursor = textCursor();
		cursor.movePosition(QTextCursor::End);
		setTextCursor(cursor);
		ensureCursorVisible();
		break;
	}
}
Example #6
0
void MsgView::colorsChanged()
{
    char FONT_SEND[] = "<##FontSend##>";
    char FONT_RECEIVE[] = "<##FontReceive##>";
    viewport()->setUpdatesEnabled(false);
    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);
    scrollToAnchor(curAnchor);
    viewport()->setUpdatesEnabled(true);
    viewport()->repaint();
}
Example #7
0
void TextShow::resizeEvent(QResizeEvent *e)
{
    QTextBrowser::resizeEvent(e);
    scrollToAnchor(curAnchor);
}
Example #8
0
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);
}
Example #9
0
/*!\reimp
 */
void QTextBrowser::showEvent( QShowEvent* e )
{
    QTextView::showEvent( e );
    scrollToAnchor( d->curmark );
}
Example #10
0
/*!
  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 &lt;qt \c type=detail&gt;, 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
}
Example #11
0
void TextShow::resizeEvent(QResizeEvent *e)
{
    QTextBrowser::resizeEvent(e);
    if (!curAnchor.isEmpty()) scrollToAnchor(curAnchor);
}