• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

keduca

kquestion.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           kquestion.cpp  -  description
00003                              -------------------
00004     begin                : Tue May 22 2001
00005     copyright            : (C) 2001 by Javier Campos Morales
00006     email                : javi@asyris.org
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 #include "kquestion.h"
00020 #include "kquestion.moc"
00021 
00022 #include <qlayout.h>
00023 #include <qpixmap.h>
00024 #include <qvbox.h>
00025 #include <qtimer.h>
00026 
00027 #include <kprogress.h>
00028 #include <klocale.h>
00029 
00030 KQuestion::KQuestion( QWidget *parent, const char *name )
00031   : QHBox( parent, name ), _countdownTimer( 0 )
00032 {
00033   initGUI();
00034 }
00035 
00036 KQuestion::~KQuestion()
00037 {
00038 }
00039 
00041 void KQuestion::initGUI()
00042 {
00043   setFrameShape( QFrame::Box );
00044   setFrameShadow( QFrame::Plain );
00045   setPalette( QPalette( Qt::white ) );
00046 
00047   QVBox *picBox = new QVBox( this );
00048 
00049   _picture = new QLabel( picBox, "PixmapLabel1" );
00050   _picture->setScaledContents( FALSE );
00051   _picture->setPalette( QPalette( Qt::white ) );
00052 
00053   _countdownWidget = new KProgress( picBox );
00054   _countdownWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,
00055                                                 QSizePolicy::Preferred ) );
00056   _countdownWidget->setFormat( i18n( "%v seconds left" ) );
00057 
00058     _view = new QTextEdit( this, "TextView1" );
00059     _view->setReadOnly( true );
00060     _view->setFrameShape( QTextEdit::NoFrame );
00061     _view->setHScrollBarMode( QTextEdit::AlwaysOff );
00062     _view->setTextFormat( QTextEdit::RichText );
00063     _view->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, true ) );
00064 }
00065 
00067 void KQuestion::setText( const QString &text)
00068 {
00069     _view->setText( text );
00070 }
00071 
00073 void KQuestion::setPixmap( const QPixmap pixmap)
00074 {
00075     _picture->setPixmap( pixmap );
00076 }
00077 
00078 void KQuestion::countdown(int starttime)
00079 {
00080   _totalCount = starttime;
00081   _currentCount = starttime;
00082   if (starttime > 0)
00083   {
00084     if (!_countdownTimer)
00085     {
00086       _countdownTimer = new QTimer(this);
00087       connect(_countdownTimer, SIGNAL(timeout()),
00088               this, SLOT(countDownOne()));
00089     }
00090     _countdownTimer->start(1000);
00091     // make one step less than time passes by in seconds
00092     // so that the user will see when time is up
00093     _countdownWidget->setTotalSteps(starttime);
00094     _countdownWidget->setProgress(starttime);
00095   }else{
00096     _countdownTimer->stop();
00097     _countdownWidget->reset();
00098   }
00099 }
00100 
00101 void KQuestion::countDownOne()
00102 {
00103   _currentCount--;
00104   //_countdownWidget->setProgress(_totalCount - _currentCount);
00105   _countdownWidget->advance(-1);
00106 
00107   if (_currentCount == 0)
00108     _countdownTimer->stop();
00109 }
00110 
00111 void KQuestion::countdownVisible(bool visible)
00112 {
00113   if (visible)
00114     _countdownWidget->show();
00115   else
00116     _countdownWidget->hide();
00117 }
00118 
00120 int KQuestion::getCurrentTime()
00121 {
00122   return _totalCount - _currentCount;
00123 }

keduca

Skip menu "keduca"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal