⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 q3textbrowser.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    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);}/*!    \fn void Q3TextBrowser::backwardAvailable(bool available)    This signal is emitted when the availability of backward()    changes. \a available is false when the user is at home();    otherwise it is true.*//*!    \fn void Q3TextBrowser::forwardAvailable(bool available)    This signal is emitted when the availability of forward() changes.    \a available is true after the user navigates backward() and false    when the user navigates or goes forward().*//*!    \fn void Q3TextBrowser::sourceChanged(const QString& src)    This signal is emitted when the mime source has changed, \a src    being the new source.    Source changes happen both programmatically when calling    setSource(), forward(), backword() or home() or when the user    clicks on links or presses the equivalent key sequences.*//*!  \fn void Q3TextBrowser::highlighted (const QString &link)    This signal is emitted when the user has selected but not    activated a link in the document. \a link is the value of the \c    href i.e. the name of the target document.*//*!    \fn void Q3TextBrowser::linkClicked(const QString& link)    This signal is emitted when the user clicks a link. The \a link is    the value of the \c href i.e. the name of the target document.    The \a link will be the absolute location of the document, based    on the value of the anchor's href tag and the current context of    the document.    \sa anchorClicked()*//*!    \fn void Q3TextBrowser::anchorClicked(const QString& name, const QString &link)    This signal is emitted when the user clicks an anchor. The \a link is    the value of the \c href i.e. the name of the target document.  The \a name    is the name of the anchor.    \sa linkClicked()*//*!    Changes the document displayed to the previous document in the    list of documents built by navigating links. Does nothing if there    is no previous document.    \sa forward(), backwardAvailable()*/void Q3TextBrowser::backward(){    if (d->stack.count() <= 1)        return;    d->forwardStack.push(d->stack.pop());    setSource(d->stack.pop());    emit forwardAvailable(true);}/*!    Changes the document displayed to the next document in the list of    documents built by navigating links. Does nothing if there is no    next document.    \sa backward(), forwardAvailable()*/void Q3TextBrowser::forward(){    if (d->forwardStack.isEmpty())        return;    setSource(d->forwardStack.pop());    emit forwardAvailable(!d->forwardStack.isEmpty());}/*!    Changes the document displayed to be the first document the    browser displayed.*/void Q3TextBrowser::home(){    if (!d->home.isNull())        setSource(d->home);}/*!    The event \a e is used to provide the following keyboard shortcuts:    \table    \header \i Keypress            \i Action    \row \i Alt+Left Arrow  \i \l backward()    \row \i Alt+Right Arrow \i \l forward()    \row \i Alt+Up Arrow    \i \l home()    \endtable*/void Q3TextBrowser::keyPressEvent(QKeyEvent * e){    if (e->state() & Qt::AltButton) {        switch (e->key()) {        case Qt::Key_Right:            forward();            return;        case Qt::Key_Left:            backward();            return;        case Qt::Key_Up:            home();            return;        }    }    Q3TextEdit::keyPressEvent(e);}class QTextDetailPopup : public QWidget{public:    QTextDetailPopup()        : QWidget (0, "automatic QText detail widget", Qt::WType_Popup)    {	setAttribute(Qt::WA_DeleteOnClose, true);    }protected:    void mousePressEvent(QMouseEvent *)    {        close();    }};void Q3TextBrowser::popupDetail(const QString& contents, const QPoint& pos){    const int shadowWidth = 6;   // also used as '5' and '6' and even '8' below    const int vMargin = 8;    const int hMargin = 12;    QWidget* popup = new QTextDetailPopup;    popup->setAttribute(Qt::WA_NoSystemBackground, true);    Q3SimpleRichText* doc = new Q3SimpleRichText(contents, popup->font());    doc->adjustSize();    QRect r(0, 0, doc->width(), doc->height());    int w = r.width() + 2*hMargin;    int h = r.height() + 2*vMargin;    popup->resize(w + shadowWidth, h + shadowWidth);    // okay, now to find a suitable location    //###### we need a global fancy popup positioning somewhere    popup->move(pos - popup->rect().center());    if (popup->geometry().right() > QApplication::desktop()->width())        popup->move(QApplication::desktop()->width() - popup->width(),                     popup->y());    if (popup->geometry().bottom() > QApplication::desktop()->height())        popup->move(popup->x(),                     QApplication::desktop()->height() - popup->height());    if (popup->x() < 0)        popup->move(0, popup->y());    if (popup->y() < 0)        popup->move(popup->x(), 0);    popup->show();    // now for super-clever shadow stuff.  super-clever mostly in    // how many window system problems it skirts around.    QPainter p(popup);    p.setPen(QApplication::palette().color(QPalette::Active, QPalette::WindowText));    p.drawRect(0, 0, w, h);    p.setPen(QApplication::palette().color(QPalette::Active, QPalette::Mid));    p.setBrush(QColor(255, 255, 240));    p.drawRect(1, 1, w-2, h-2);    p.setPen(Qt::black);    doc->draw(&p, hMargin, vMargin, r, popup->palette(), 0);    delete doc;    p.drawPoint(w + 5, 6);    p.drawLine(w + 3, 6,                w + 5, 8);    p.drawLine(w + 1, 6,                w + 5, 10);    int i;    for(i=7; i < h; i += 2)        p.drawLine(w, i,                    w + 5, i + 5);    for(i = w - i + h; i > 6; i -= 2)        p.drawLine(i, h,                    i + 5, h + 5);    for(; i > 0 ; i -= 2)        p.drawLine(6, h + 6 - i,                    i + 5, h + 5);}/*!    \fn void Q3TextBrowser::setText(const QString &txt)    \overload    Sets the text to \a txt.*//*!    \reimp*/void Q3TextBrowser::setText(const QString &txt, const QString &context){    d->textOrSourceChanged = true;    d->curmark = QLatin1String("");    d->curmain = QLatin1String("");    Q3TextEdit::setText(txt, context);}void Q3TextBrowser::emitHighlighted(const QString &s){    emit highlighted(s);}void Q3TextBrowser::emitLinkClicked(const QString &s){    d->textOrSourceChanged = false;    emit linkClicked(s);    if (!d->textOrSourceChanged)        setSource(s);}#endif  // QT_NO_TEXTBROWSER

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -