1 /***************************************************************************
4 copyright : (C) 2004 by Peter Hedlund
5 email : peter@peterandlinda.com
6 ***************************************************************************/
8 /***************************************************************************
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 ***************************************************************************/
17 #include <qtextstream.h>
20 #include <kmessagebox.h>
23 #include "wqlreader.h"
25 KWqlDataItem::KWqlDataItem()
30 KWqlDataItem::KWqlDataItem(const QString
&front
, const QString
&back
, int height
)
37 KWqlDataItem::~KWqlDataItem()
43 \fn WqlReader::WqlReader
45 WqlReader::WqlReader()
50 KWqlDataItemList
WqlReader::parse(const QString
&fileName
)
52 KWqlDataItemList list
;
54 file
.open(IO_ReadOnly
);
55 QTextStream
ts(&file
);
56 ts
.setEncoding(QTextStream::Latin1
);
62 KMessageBox::error(0, i18n("This does not appear to be a (K)WordQuiz file") + s
);
71 KMessageBox::error(0, i18n("KWordQuiz can only open files created by WordQuiz 5.x"));
76 while (ts
.readLine() != "[Font Info]");
78 int p
= s
.find("=", 0);
79 QString fam
= s
.right(s
.length() - (p
+ 1));
80 fam
= fam
.mid(1, fam
.length() - 2);
81 //g->font().setFamily(s);
85 s
= s
.right(s
.length() - (p
+ 1));
90 s
= s
.right(s
.length() - (p
+ 1));
99 s
= s
.right(s
.length() - (p
+ 1));
100 bool it
= (s
== "1");
102 QFont
m_font(fam
, ps
, b
, it
);
104 while (ts
.readLine() != "[Character Info]");
107 m_specialCharacters
= s
.right(s
.length() - (p
+ 1));
109 while (ts
.readLine() != "[Grid Info]");
110 ts
.readLine(); //skip value for width of row headers
114 s
= s
.right(s
.length() - (p
+ 1));
115 m_colWidth1
= s
.toInt(0, 10);
119 s
= s
.right(s
.length() - (p
+ 1));
120 m_colWidth2
= s
.toInt(0, 10);
124 s
= s
.right(s
.length() - (p
+ 1));
125 m_numRows
= (s
.toInt(0, 10) - 1); //We need to reduce by one since the header is not included
130 s
= s
.right(s
.length() - (p
+ 1));
131 m_topLeft
=s
.toInt(0, 10) - 1;
135 s
= s
.right(s
.length() - (p
+ 1));
136 m_topRight
=s
.toInt(0, 10) - 1;
140 s
= s
.right(s
.length() - (p
+ 1));
141 m_bottomLeft
=s
.toInt(0, 10) - 1;
145 s
= s
.right(s
.length() - (p
+ 1));
146 m_bottomRight
=s
.toInt(0, 10) - 1 ;
148 while (ts
.readLine() != "[Vocabulary]");
153 s
= s
.stripWhiteSpace();
155 m_language2
= ts
.readLine();
161 QString r
= s
.mid(p
+ 1, 10);
162 int h
= r
.toInt(0, 10);
164 s
= s
.stripWhiteSpace();
169 KWqlDataItem
item(s
, b
, h
/15);
178 \fn WqlReader::colWidth(int col)
180 int WqlReader::colWidth(int col
)
190 \fn WqlReader::language(int col)
192 QString
WqlReader::language(int col
)