1 /***************************************************************************
5 maintain list of lines from QMultiLineEdit
7 -----------------------------------------------------------------------
9 begin : Sun Aug 13 10:00:53 MET 2000
11 copyright : (C) 1999-2001 Ewald Arnold
12 (C) 2001 The KDE-EDU team
14 email : kvoctrain@ewald-arnold.de
16 -----------------------------------------------------------------------
18 ***************************************************************************
20 ***************************************************************************
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 ***************************************************************************/
33 LineList::LineList (const QString
&multilines
)
35 setLines (multilines
);
39 void LineList::setLines(const QString
&the_lines
)
42 QString lines
= the_lines
;
44 if ((pos
= lines
.find ('\n')) >= 0) {
46 multilines
.push_back(lines
.left(pos
));
47 lines
.remove (0, pos
+1);
48 pos
= lines
.find ('\n');
52 if (lines
.length() > 0) // empty string at end ==> not an entry!
53 multilines
.push_back(lines
);
59 void LineList::normalizeWS()
61 for (int i
= 0; i
< (int) multilines
.size(); i
++) {
62 multilines
[i
] = multilines
[i
].stripWhiteSpace();
63 // FIXME: more tolerance with WS? 2*SPC = 1*SPC...
68 int LineList::count() const
70 return multilines
.size();
74 QString
LineList::getLine (int index
) const
76 if (index
< (int) multilines
.size())
77 return multilines
[index
];
79 kdError() << "LineList::getLine: index too big";
85 QString
LineList::allLines() const
88 if (multilines
.size() > 0)
91 if (multilines
.size() > 1) {
92 for (int i
= 1; i
< (int) multilines
.size(); i
++)
93 ret
+= "\n" + multilines
[i
];