1 /***************************************************************************
2 ksfilereader.cpp - description
4 begin : Tue Jan 28 2003
5 copyright : (C) 2003 by Heiko Evermann
6 email : heiko@evermann.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
21 #include "ksfilereader.h"
23 KSFileReader::KSFileReader(QFile
& file
) {
24 // read the whole file at once. This works well at least for the smaller files.
25 QByteArray data
= file
.readAll();
26 QString sAll
= QString::fromUtf8( data
.data(), data
.size() );
27 // split into list of lines
28 lines
= QStringList::split( "\n", sAll
);
29 // how many lines did we get?
30 numLines
= lines
.size();
33 // we do not need the file any more
37 KSFileReader::~KSFileReader(){
40 bool KSFileReader::hasMoreLines() {
41 return (curLine
< numLines
);
44 QString
& KSFileReader::readLine(){
45 // hint: use curLine as index, after that increment curLine
46 // This means that the programming language c++ should better be renamed to ++c,
47 // otherwise the name means: improve the c programming language, but use it the
48 // way it was before the improvements...
49 return lines
[curLine
++];
52 bool KSFileReader::setLine(int i
) {
61 #include "ksfilereader.moc"