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

keduca

fileread.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           fileread.h  -  description
00003                              -------------------
00004     begin                : Wed May 23 2001
00005     copyright            : (C) 2001 by Javier Campos
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 #ifndef FILEREAD_H
00019 #define FILEREAD_H
00020 
00021 #include <kio/job.h>
00022 
00023 #include <qdom.h>
00024 
00025 // forward declarations
00026 class KTempFile;
00027 
00028 class QFile;
00029 
00035 class FileRead : public QObject {
00036     Q_OBJECT
00037 
00038 public:
00039     FileRead( QObject *parent=0, const char *name=0 );
00040     virtual ~FileRead();
00041     enum QuestionField { QF_TEXT, QF_PICTURE, QF_POINTS, QF_TYPE, QF_TIME, QF_TIP, QF_EXPLAIN };
00042     enum AnswerField { AF_TEXT, AF_VALUE, AF_POINT };
00043     enum ResultField { RS_TEXT, RS_MIN, RS_MAX, RS_PICTURE };
00044     
00046     bool openFile( const KURL &url );
00048     void setQuestion( QuestionField field, const QString& text);
00050     void setQuestion( QuestionField field, int value );
00052     void setResult( ResultField field, const QString& text);
00054     void setResult( ResultField field, int value );
00056     void setAnswer( const QString& text, bool value, int points=0);
00058     void recordLast();
00060     void recordFirst();
00062     void recordResultLast();
00064     void recordResultFirst();
00066     void insertQuestion();
00068     void insertResult();
00070     void recordNext();
00072     void recordPrevious();
00074     void recordResultNext();
00076     void recordResultPrevious();
00078     void recordAnswerLast();
00080     void recordAnswerFirst();
00082     void recordAnswerNext();
00084     void recordAnswerPrevious();
00086     void recordAnswerAt( unsigned int index);
00088     unsigned int recordAnswerCount();
00090     QString getQuestion( QuestionField field );
00092     int getQuestionInt( QuestionField field );
00094     QString getAnswer( AnswerField field );
00096     int getAnswerPoints();
00098     bool getAnswerValue();
00100     QString getResult( ResultField field );
00102     int getResultInt( ResultField field );
00104     bool recordBOF();
00106     bool recordEOF();
00108     bool recordResultBOF();
00110     bool recordResultEOF();
00112     bool recordAnswerBOF();
00114     bool recordAnswerEOF();
00116     void clearAnswers();
00118     void recordDelete();
00120     void recordSwap( bool );
00122     bool saveFile( const KURL &url = KURL(), bool copyimages = false, bool saveCompressed = true );
00124     bool saveResults( const KURL &url, const QString &results );
00126     QString getPicture();
00128     QPixmap getPicturePixmap();
00130     void setHeader( const QString field, const QString value);
00132     QString getHeader(const QString &head);
00134     bool isMultiAnswer();
00136     bool isResult();
00137     KURL const &getCurrentURL()const{return _currentURL;}
00139     bool changed() {return _changed;}
00141     void recordAt( uint index );
00143     void refreshData();
00144     /* get total questions */
00145     uint getTotalQuestions();
00146     /* get total Points */
00147     uint getTotalPoints();
00148     /* get total Time */
00149     uint getTotalTime();
00150 private:
00151 
00152     // Private attributes
00153 
00154     bool _changed;
00156     QMap<QString,QString> _header;
00157 
00158     struct Answers
00159     {
00160         QString text;
00161         bool value;
00162         int points;
00163     };
00164 
00165     struct Results
00166     {
00167         QString text;
00168         QString picture;
00169         int min;
00170         int max;
00171     };
00172     
00173     struct Questions
00174     {
00175         QString text;
00176         int type;
00177         QString picture;
00178         int time;
00179         int points;
00180         QString tip;
00181         QString explain;
00182         QValueList<Answers> listAnswers;
00183         QValueListIterator<Answers> recordAnswers;
00184     };
00185 
00187     QValueList<Questions> _listQuestions;
00188     QValueListIterator<Questions> _recordQuestions;
00189 
00190     QValueList<Results> _listResults;
00191     QValueListIterator<Results> _recordResults;
00192     
00194     bool _fileEOF;
00196     bool _fileBOF;
00198     bool _fileAnswerEOF;
00200     bool _fileAnswerBOF;
00202     bool _fileResultEOF;
00204     bool _fileResultBOF;
00206     KURL _currentURL;
00208     KTempFile *_tmpfile;
00210     QString _tmpfileImage;
00212     uint _totalQuestions;
00214     uint _totalTime;
00216     uint _totalPoints;
00217     
00218     // Private methods
00219 
00221     void insertXML( QDomDocument &doc, QDomElement &parent, const QString &tagName, const QString &data);
00223     void insertXML( QDomDocument &doc, QDomElement &parent, const QString &data);
00224 
00225 protected:
00227     bool loadFile( const QString &filename );
00229     bool saveFile( const QString &filename, bool copyimages, bool saveCompressed = true );
00231     bool saveResults( const QString &filename, const QString &results );
00232 
00233 protected slots:
00234     void slotUploadFinished( KIO::Job * job );
00235 
00236 signals:
00237 /* Stolen from kparts */
00238 
00244   void completed();
00245 
00259   void completed( bool pendingAction );
00260 
00264   void canceled( const QString &errMsg );
00265 
00270     void setWindowCaption( const QString & caption );
00271 
00272 };
00273 
00274 #endif

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