1 /***************************************************************************
2 * Copyright (C) 2006 by Albert Astals Cid <aacid@kde.org> *
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 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #include "pagesizelabel.h"
12 #include "core/document.h"
14 PageSizeLabel::PageSizeLabel( QWidget
* parent
, Okular::Document
* document
)
15 : QLabel( parent
), m_document( document
),
16 m_currentPage( -1 ), m_antiWidget( NULL
)
20 PageSizeLabel::~PageSizeLabel()
22 m_document
->removeObserver( this );
25 QWidget
*PageSizeLabel::antiWidget()
29 m_antiWidget
= new QWidget(qobject_cast
<QWidget
*>(parent()));
30 m_antiWidget
->resize(0, 0);
35 void PageSizeLabel::notifySetup( const QVector
< Okular::Page
* > & pageVector
, int setupFlags
)
37 // only process data when document changes
38 if ( !( setupFlags
& Okular::DocumentObserver::DocumentChanged
) )
41 // if document is closed or all pages have size hide widget
42 int pages
= pageVector
.count();
43 if ( pages
< 1 || m_document
->allPagesSize().isValid() )
58 void PageSizeLabel::notifyViewportChanged( bool /*smoothMove*/ )
62 // get current page number
63 int page
= m_document
->viewport().pageNumber
;
64 int pages
= m_document
->pages();
66 // if the document is opened and page is changed
67 if ( page
!= m_currentPage
&& pages
> 0 )
70 setText( m_document
->pageSizeString(page
) );
71 m_antiWidget
->setFixedSize(sizeHint());
76 #include "pagesizelabel.moc"