"Fossies" - the Fresh Open Source Software Archive

Member "poppler-0.82.0/qt5/demos/optcontent.cpp" (25 Oct 2019, 1782 Bytes) of package /linux/misc/poppler-0.82.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * Copyright (C) 2008, Pino Toscano <pino@kde.org>
    3  *
    4  * This program is free software; you can redistribute it and/or modify
    5  * it under the terms of the GNU General Public License as published by
    6  * the Free Software Foundation; either version 2, or (at your option)
    7  * any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12  * GNU General Public License for more details.
   13  *
   14  * You should have received a copy of the GNU General Public License
   15  * along with this program; if not, write to the Free Software
   16  * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
   17  */
   18 
   19 #include "optcontent.h"
   20 
   21 #include <poppler-qt5.h>
   22 
   23 #include <QtWidgets/QTreeView>
   24 
   25 OptContentDock::OptContentDock(QWidget *parent)
   26     : AbstractInfoDock(parent)
   27 {
   28     m_view = new QTreeView(this);
   29     setWidget(m_view);
   30     setWindowTitle(tr("Optional content"));
   31     m_view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
   32 }
   33 
   34 OptContentDock::~OptContentDock()
   35 {
   36 }
   37 
   38 
   39 void OptContentDock::documentLoaded()
   40 {
   41     AbstractInfoDock::documentLoaded();
   42     if ( document()->pageMode() == Poppler::Document::UseOC ) {
   43         show();
   44     }  
   45 }
   46 
   47 void OptContentDock::fillInfo()
   48 {
   49     if (!document()->hasOptionalContent()) {
   50         return;
   51     }
   52 
   53     m_view->setModel(document()->optionalContentModel());
   54     connect(m_view->model(), &QAbstractItemModel::dataChanged, this, &OptContentDock::reloadImage);
   55     m_view->expandToDepth(1);
   56 }
   57 
   58 void OptContentDock::documentClosed()
   59 {
   60     m_view->setModel(nullptr);
   61     AbstractInfoDock::documentClosed();
   62 }
   63 
   64 void OptContentDock::reloadImage()
   65 {
   66     reloadPage();
   67 }
   68