equal
deleted
inserted
replaced
123 QStringList HWNamegen::dictContents(const QString filename) |
123 QStringList HWNamegen::dictContents(const QString filename) |
124 { |
124 { |
125 QStringList list; |
125 QStringList list; |
126 |
126 |
127 // find .txt to load the names from |
127 // find .txt to load the names from |
128 QFile * file = new QFile(QString("physfs://Names/%1.txt").arg(filename)); |
128 QFile file(QString("physfs://Names/%1.txt").arg(filename)); |
129 |
129 |
130 if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) |
130 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
131 { |
131 { |
132 QTextStream in(file); |
132 QTextStream in(&file); |
133 while (!in.atEnd()) |
133 QString line; |
134 { |
134 do |
135 QString line = in.readLine(); |
135 { |
|
136 line = in.readLine(); |
|
137 |
136 if(!line.isEmpty()) |
138 if(!line.isEmpty()) |
137 list.append(line); |
139 list.append(line); |
138 } |
140 } while (!line.isNull()); |
139 } |
141 } |
140 |
|
141 // this QFile isn't needed any further |
|
142 delete file; |
|
143 |
142 |
144 if (list.size() == 0) |
143 if (list.size() == 0) |
145 list.append(filename); |
144 list.append(filename); |
146 |
145 |
147 return list; |
146 return list; |
151 QStringList HWNamegen::dictsForHat(const QString hatname) |
150 QStringList HWNamegen::dictsForHat(const QString hatname) |
152 { |
151 { |
153 QStringList list; |
152 QStringList list; |
154 |
153 |
155 // find .cfg to load the dicts from |
154 // find .cfg to load the dicts from |
156 QFile * file = new QFile(QString("physfs://Names/%1.cfg").arg(hatname)); |
155 QFile file(QString("physfs://Names/%1.cfg").arg(hatname)); |
157 |
156 |
158 if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) |
157 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
159 { |
158 { |
160 QTextStream in(file); |
159 QTextStream in(&file); |
161 while (!in.atEnd()) |
160 QString line; |
162 { |
161 do |
163 QString line = in.readLine(); |
162 { |
|
163 line = in.readLine(); |
|
164 |
164 if(!line.isEmpty()) |
165 if(!line.isEmpty()) |
165 list.append(line); |
166 list.append(line); |
166 } |
167 } while (!line.isNull()); |
167 } |
168 } |
168 |
|
169 // this QFile isn't needed any further |
|
170 delete file; |
|
171 |
169 |
172 if (list.size() == 0) |
170 if (list.size() == 0) |
173 list.append(QString("generic")); |
171 list.append(QString("generic")); |
174 |
172 |
175 return list; |
173 return list; |