1 /***************************************************************************
2 wqlwriter.cpp - description
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 ***************************************************************************/
16 #include "wqlwriter.h"
18 #define winendl "\r\n"
20 WqlWriter::WqlWriter(QFile
*file
)
23 if(outputFile
->open(IO_WriteOnly
))
25 outputStream
.setDevice(outputFile
);
26 outputStream
.setEncoding(QTextStream::Latin1
);
28 outputStream
<< "WordQuiz" << winendl
;
29 outputStream
<< "5.9.0" << winendl
<< winendl
;
33 void WqlWriter::writeFont( const QFont
& font
)
35 outputStream
<< "[Font Info]" << winendl
;
36 outputStream
<< "FontName1=\"" << font
.family() << "\"" << winendl
;
37 outputStream
<< "FontSize1=" << QString::number(font
.pointSize()) << winendl
;
38 outputStream
<< QString("FontBold1=%1").arg(font
.bold() ? "1" : "0") <<winendl
;
39 outputStream
<< QString("FontItalic1=%1").arg(font
.italic() ? "1" : "0") <<winendl
;
40 outputStream
<< "FontColor1=0" << winendl
;
41 outputStream
<< "CharSet1=0" << winendl
;
42 outputStream
<< "Layout1=0" << winendl
;
44 outputStream
<< "FontName2=\"" << font
.family() << "\"" << winendl
;
45 outputStream
<< "FontSize2=" << QString::number(font
.pointSize()) << winendl
;
46 outputStream
<< QString("FontBold2=%1").arg(font
.bold() ? "1" : "0") <<winendl
;
47 outputStream
<< QString("FontItalic2=%1").arg(font
.italic() ? "1" : "0") <<winendl
;
48 outputStream
<< "FontColor2=0" << winendl
;
49 outputStream
<< "CharSet2=0" << winendl
;
50 outputStream
<< "Layout2=0" << winendl
<< winendl
;
53 void WqlWriter::writeCharacters( const QString
& s
)
55 outputStream
<< "[Character Info]" << winendl
;
56 outputStream
<< "Characters1=" << s
<< winendl
;
57 outputStream
<< "Characters2=" << s
<< winendl
<< winendl
;
60 void WqlWriter::writeGridInfo( int col0
, int col1
, int col2
, int numRows
)
62 outputStream
<< "[Grid Info]" << winendl
;
63 outputStream
<< "ColWidth0=" << QString::number(col0
) << winendl
;
64 outputStream
<< "ColWidth1=" << QString::number(col1
) << winendl
;
65 outputStream
<< "ColWidth2=" << QString::number(col2
) << winendl
;
66 outputStream
<< "RowCount=" << QString::number(numRows
+ 1) << winendl
; //Add one for the header
69 void WqlWriter::writeSelection( int lc
, int tr
, int rc
, int br
) //part of [Grid Info]
71 outputStream
<< "SelLeft=" << QString::number(lc
+ 1) << winendl
;
72 outputStream
<< "SelTop=" << QString::number(tr
+ 1) << winendl
;
73 outputStream
<< "SelRight=" << QString::number(rc
+ 1) << winendl
;
74 outputStream
<< "SelBottom=" << QString::number(br
+ 1) << winendl
<< winendl
;
77 void WqlWriter::writeFirstItem( const QString
& ll
, const QString
& rl
)
79 outputStream
<< "[Vocabulary]" << winendl
;
80 outputStream
<< ll
<< " [0000000300]" << winendl
;
81 outputStream
<< rl
<< winendl
;
84 void WqlWriter::writeItem( const QString
& left
, const QString
& right
, int rh
)
86 outputStream
<< left
<< QString( " [%1]").arg(rh
* 15, 10, 10 ) << winendl
;
87 outputStream
<< right
<< winendl
;
90 WqlWriter::~WqlWriter()