cb2bib  2.0.1
About: cb2Bib is a multiplatform application for rapidly extracting unformatted, or unstandardized bibliographic references from email alerts, journal Web pages, and PDF files.
  Fossies Dox: cb2bib-2.0.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

c2bTextBrowser.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2021 by Pere Constans
3  * constans@molspaces.com
4  * cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
5  * See the LICENSE file that comes with this distribution.
6  ***************************************************************************/
7 #include "c2bTextBrowser.h"
8 
9 #include <QAction>
10 #include <QContextMenuEvent>
11 #include <QMenu>
12 #include <QScrollBar>
13 
14 
15 c2bTextBrowser::c2bTextBrowser(QWidget* parentw) : QTextBrowser(parentw)
16 {
17  setFrameShape(QTextBrowser::StyledPanel);
18  setFrameShadow(QTextBrowser::Raised);
19 }
20 
22 
23 
24 void c2bTextBrowser::setSource(const QUrl& /* dummy_name */) {}
25 
26 void c2bTextBrowser::contextMenuEvent(QContextMenuEvent* qevent)
27 {
28  QMenu* edit_menu = createStandardContextMenu();
29  edit_menu->setTitle(tr("Edit..."));
30  QMenu* menu = new QMenu(this);
31  menu->addMenu(edit_menu);
32  QList<QAction*> acts = actions();
33  for (int i = 0; i < acts.count(); ++i)
34  menu->addAction(acts.at(i));
35  menu->exec(qevent->globalPos());
36  delete edit_menu;
37  delete menu;
38 }
39 
40 void c2bTextBrowser::updateHtml(const QString& newHtml)
41 {
42  const int scrollPosition(verticalScrollBar()->value());
43  setHtml(newHtml);
44  verticalScrollBar()->setValue(scrollPosition);
45 }
virtual void contextMenuEvent(QContextMenuEvent *qevent)
void updateHtml(const QString &newHtml)
virtual void setSource(const QUrl &name)
c2bTextBrowser(QWidget *parentw=0)