SVN_SILENT made messages (.desktop file)
[kdegraphics.git] / okular / ui / pagesizelabel.cpp
blob4a8077924cab86ee59bdee86d3266b8bbdad6c2d
1 /***************************************************************************
2 * Copyright (C) 2006 by Albert Astals Cid <aacid@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 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()
27 if (!m_antiWidget)
29 m_antiWidget = new QWidget(qobject_cast<QWidget*>(parent()));
30 m_antiWidget->resize(0, 0);
32 return m_antiWidget;
35 void PageSizeLabel::notifySetup( const QVector< Okular::Page * > & pageVector, int setupFlags )
37 // only process data when document changes
38 if ( !( setupFlags & Okular::DocumentObserver::DocumentChanged ) )
39 return;
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() )
45 hide();
46 if ( m_antiWidget )
47 m_antiWidget->hide();
48 return;
50 else
52 show();
53 if ( m_antiWidget )
54 m_antiWidget->show();
58 void PageSizeLabel::notifyViewportChanged( bool /*smoothMove*/ )
60 if (isVisible())
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 )
69 m_currentPage = page;
70 setText( m_document->pageSizeString(page) );
71 m_antiWidget->setFixedSize(sizeHint());
76 #include "pagesizelabel.moc"