kpresenter
KPrGotoPage.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "KPrGotoPage.h"
00022
00023 #include <qlabel.h>
00024 #include <qlistbox.h>
00025 #include <qlayout.h>
00026 #include <qpushbutton.h>
00027
00028 #include <klocale.h>
00029 #include <kdialog.h>
00030
00031 #include "KPrDocument.h"
00032 #include "KPrPage.h"
00033
00034 KPrGotoPage::KPrGotoPage( const KPrDocument *doc,
00035 const QValueList<int> &slides, int start,
00036 QWidget *parent, const char *name )
00037 : KDialogBase( parent, name, true, i18n("Goto Slide..."), Ok|Cancel),
00038 oldPage(start)
00039 {
00040
00041 QWidget *page = new QWidget( this );
00042 setMainWidget(page);
00043 QVBoxLayout *ml = new QVBoxLayout( page, KDialog::marginHint(),
00044 KDialog::spacingHint());
00045 QLabel *label = new QLabel( i18n( "Go to slide:" ), page );
00046 ml->addWidget( label );
00047 spinbox = new QListBox( page );
00048 connect( spinbox, SIGNAL(doubleClicked( QListBoxItem* )),
00049 this, SLOT(accept()) );
00050 connect( spinbox, SIGNAL(returnPressed( QListBoxItem* )),
00051 this, SLOT(accept()) );
00052 ml->addWidget( spinbox );
00053
00054 QPtrList<KPrPage> pageList = doc->getPageList();
00055 QValueList<int>::ConstIterator it = slides.begin();
00056 for ( ; it != slides.end(); ++it ) {
00057 QString t( pageList.at( (*it) - 1 )->pageTitle() );
00058
00059 if(t.length() > 30) {
00060 t.truncate(30);
00061 t+="...";
00062 }
00063 spinbox->insertItem( QString( "%1 - %2" ).arg( *it ).arg( t ), -1 );
00064 if ( *it == start )
00065 spinbox->setCurrentItem( spinbox->count()-1 );
00066 }
00067
00068 if ( parent )
00069 parent->setCursor( Qt::forbiddenCursor );
00070 }
00071
00072 int KPrGotoPage::gotoPage( const KPrDocument *doc,
00073 const QValueList<int> &slides, int start,
00074 QWidget *parent)
00075 {
00076 KPrGotoPage dia( doc, slides, start,parent, 0L );
00077 dia.exec();
00078 dia.resetCursor();
00079 return dia.page();
00080 }
00081
00082 int KPrGotoPage::page() const {
00083 if(result()==QDialog::Accepted)
00084 return spinbox->currentText().left( spinbox->currentText().find( "-" ) - 1 ).toInt();
00085 return oldPage;
00086 }
00087
00088 void KPrGotoPage::resetCursor() {
00089 if ( parentWidget() )
00090 parentWidget()->setCursor( Qt::blankCursor );
00091 }
|