Changeset 47 in tspsg-svn
- Timestamp:
- Aug 2, 2009, 9:47:45 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/README
r42 r47 5 5 $URL$ 6 6 7 This software is intended to generate and solve Travelling 8 Salesman Problem (TSP) tasks. It uses Branch and Bound method 9 for solving. An input is a number of cities and a matrix of 10 city-to-city travel prices. The matrix can be populated with 11 random values in a given range (useful for generating tasks). 12 The result is an optimal route, its price, step-by-step matrices 13 of solving and solving graph. The task can be saved in internal 14 binary format and opened later. The result can be printed without 15 the answer (only input matrix) or with it. 7 TSPSG is intended to generate and solve Travelling Salesman Problem 8 (TSP) tasks. It uses Branch and Bound method for solving. An input 9 is number of cities and matrix of city-to-city travel prices. 10 The matrix can be populated with random values in a given range 11 (useful for generating tasks). The result is an optimal route, its 12 price, step-by-step matrices of solving and solving graph. The task 13 can be saved in internal binary format and opened later. The result 14 can be printed without the answer (only input matrix) or with it. 16 15 17 TSPSG may be useful for teachers to generate t asks for testsor18 just for regular users to solve TSPs. It is also may be used as an 19 example ofusing Branch and bound method to solve particular task.16 TSPSG may be useful for teachers to generate test tasks or just for 17 regular users to solve TSPs. Also, it may be used as an example of 18 using Branch and bound method to solve particular task. 20 19 21 20 TSPSG is free software: you can redistribute it and/or modify it -
trunk/i18n/en.ts
r42 r47 33 33 <location filename="../src/tspmodel.cpp" line="152"/> 34 34 <location filename="../src/tspmodel.cpp" line="160"/> 35 <location filename="../src/tspmodel.cpp" line="1 75"/>36 <location filename="../src/tspmodel.cpp" line=" 191"/>37 <location filename="../src/tspmodel.cpp" line="2 04"/>38 <location filename="../src/tspmodel.cpp" line="2 34"/>39 <location filename="../src/tspmodel.cpp" line="2 43"/>35 <location filename="../src/tspmodel.cpp" line="181"/> 36 <location filename="../src/tspmodel.cpp" line="201"/> 37 <location filename="../src/tspmodel.cpp" line="214"/> 38 <location filename="../src/tspmodel.cpp" line="245"/> 39 <location filename="../src/tspmodel.cpp" line="254"/> 40 40 <source>Task Load</source> 41 41 <translation type="unfinished"></translation> … … 43 43 <message> 44 44 <location filename="../src/tspmodel.cpp" line="152"/> 45 <location filename="../src/tspmodel.cpp" line="1 75"/>46 <location filename="../src/tspmodel.cpp" line=" 191"/>47 <location filename="../src/tspmodel.cpp" line="2 04"/>48 <location filename="../src/tspmodel.cpp" line="2 34"/>49 <location filename="../src/tspmodel.cpp" line="2 43"/>45 <location filename="../src/tspmodel.cpp" line="181"/> 46 <location filename="../src/tspmodel.cpp" line="201"/> 47 <location filename="../src/tspmodel.cpp" line="214"/> 48 <location filename="../src/tspmodel.cpp" line="245"/> 49 <location filename="../src/tspmodel.cpp" line="254"/> 50 50 <source>Unable to load task:</source> 51 51 <translation type="unfinished"></translation> … … 58 58 </message> 59 59 <message> 60 <location filename="../src/tspmodel.cpp" line="1 75"/>60 <location filename="../src/tspmodel.cpp" line="181"/> 61 61 <source>Unknown file format or file is corrupted.</source> 62 62 <translation type="unfinished"></translation> 63 63 </message> 64 64 <message> 65 <location filename="../src/tspmodel.cpp" line=" 191"/>66 <location filename="../src/tspmodel.cpp" line="2 34"/>65 <location filename="../src/tspmodel.cpp" line="201"/> 66 <location filename="../src/tspmodel.cpp" line="245"/> 67 67 <source>File version is newer than application supports. 68 68 Please, try to update application.</source> … … 70 70 </message> 71 71 <message> 72 <location filename="../src/tspmodel.cpp" line="2 04"/>73 <location filename="../src/tspmodel.cpp" line="2 43"/>72 <location filename="../src/tspmodel.cpp" line="214"/> 73 <location filename="../src/tspmodel.cpp" line="254"/> 74 74 <source>Unexpected data read. 75 75 File is possibly corrupted.</source> … … 77 77 </message> 78 78 <message> 79 <location filename="../src/tspmodel.cpp" line="2 73"/>80 <location filename="../src/tspmodel.cpp" line="2 79"/>81 <location filename="../src/tspmodel.cpp" line="2 86"/>82 <location filename="../src/tspmodel.cpp" line=" 293"/>83 <location filename="../src/tspmodel.cpp" line="3 00"/>84 <location filename="../src/tspmodel.cpp" line="3 07"/>85 <location filename="../src/tspmodel.cpp" line="3 14"/>86 <location filename="../src/tspmodel.cpp" line="3 24"/>79 <location filename="../src/tspmodel.cpp" line="285"/> 80 <location filename="../src/tspmodel.cpp" line="291"/> 81 <location filename="../src/tspmodel.cpp" line="298"/> 82 <location filename="../src/tspmodel.cpp" line="305"/> 83 <location filename="../src/tspmodel.cpp" line="312"/> 84 <location filename="../src/tspmodel.cpp" line="319"/> 85 <location filename="../src/tspmodel.cpp" line="326"/> 86 <location filename="../src/tspmodel.cpp" line="336"/> 87 87 <source>Task Save</source> 88 88 <translation type="unfinished"></translation> 89 89 </message> 90 90 <message> 91 <location filename="../src/tspmodel.cpp" line="2 73"/>91 <location filename="../src/tspmodel.cpp" line="285"/> 92 92 <source>Unable to create task file. 93 93 Error: %1 … … 96 96 </message> 97 97 <message> 98 <location filename="../src/tspmodel.cpp" line="2 79"/>99 <location filename="../src/tspmodel.cpp" line="2 86"/>100 <location filename="../src/tspmodel.cpp" line=" 293"/>101 <location filename="../src/tspmodel.cpp" line="3 00"/>102 <location filename="../src/tspmodel.cpp" line="3 07"/>103 <location filename="../src/tspmodel.cpp" line="3 14"/>104 <location filename="../src/tspmodel.cpp" line="3 24"/>98 <location filename="../src/tspmodel.cpp" line="291"/> 99 <location filename="../src/tspmodel.cpp" line="298"/> 100 <location filename="../src/tspmodel.cpp" line="305"/> 101 <location filename="../src/tspmodel.cpp" line="312"/> 102 <location filename="../src/tspmodel.cpp" line="319"/> 103 <location filename="../src/tspmodel.cpp" line="326"/> 104 <location filename="../src/tspmodel.cpp" line="336"/> 105 105 <source>Unable to save task. 106 106 Error: %1</source> … … 139 139 <name>MainWindow</name> 140 140 <message> 141 <location filename="../src/mainwindow.cpp" line="14 1"/>142 <location filename="../src/mainwindow.cpp" line="4 39"/>143 <location filename="../src/mainwindow.cpp" line=" 448"/>141 <location filename="../src/mainwindow.cpp" line="146"/> 142 <location filename="../src/mainwindow.cpp" line="492"/> 143 <location filename="../src/mainwindow.cpp" line="501"/> 144 144 <source>Language change</source> 145 145 <translation type="unfinished"></translation> 146 146 </message> 147 147 <message> 148 <location filename="../src/mainwindow.cpp" line="14 1"/>148 <location filename="../src/mainwindow.cpp" line="146"/> 149 149 <source>Unable to load translation language.</source> 150 150 <translation type="unfinished"></translation> 151 151 </message> 152 152 <message> 153 <location filename="../src/mainwindow.cpp" line="181"/> 154 <source>New Task</source> 155 <translation type="unfinished"></translation> 156 </message> 157 <message> 158 <location filename="../src/mainwindow.cpp" line="181"/> 159 <location filename="../src/mainwindow.cpp" line="195"/> 160 <location filename="../src/mainwindow.cpp" line="462"/> 153 <location filename="../src/mainwindow.cpp" line="192"/> 161 154 <source>Would you like to save changes in current task?</source> 162 155 <translation type="unfinished"></translation> 163 156 </message> 164 157 <message> 165 <location filename="../src/mainwindow.cpp" line="195"/> 166 <source>Task Open</source> 167 <translation type="unfinished"></translation> 168 </message> 169 <message> 170 <location filename="../src/mainwindow.cpp" line="202"/> 158 <location filename="../src/mainwindow.cpp" line="170"/> 159 <source>Travelling Salesman Problem</source> 160 <translation type="unfinished"></translation> 161 </message> 162 <message> 163 <location filename="../src/mainwindow.cpp" line="192"/> 164 <source>Unsaved Changes</source> 165 <translation type="unfinished"></translation> 166 </message> 167 <message> 168 <location filename="../src/mainwindow.cpp" line="224"/> 171 169 <source>All Supported Formats</source> 172 170 <translation type="unfinished"></translation> 173 171 </message> 174 172 <message> 175 <location filename="../src/mainwindow.cpp" line="2 03"/>176 <location filename="../src/mainwindow.cpp" line="2 04"/>173 <location filename="../src/mainwindow.cpp" line="225"/> 174 <location filename="../src/mainwindow.cpp" line="226"/> 177 175 <source>%1 Task Files</source> 178 176 <translation type="unfinished"></translation> 179 177 </message> 180 178 <message> 181 <location filename="../src/mainwindow.cpp" line="2 05"/>182 <location filename="../src/mainwindow.cpp" line="2 32"/>183 <location filename="../src/mainwindow.cpp" line="2 51"/>179 <location filename="../src/mainwindow.cpp" line="227"/> 180 <location filename="../src/mainwindow.cpp" line="267"/> 181 <location filename="../src/mainwindow.cpp" line="296"/> 184 182 <source>All Files</source> 185 183 <translation type="unfinished"></translation> 186 184 </message> 187 185 <message> 188 <location filename="../src/mainwindow.cpp" line="2 30"/>186 <location filename="../src/mainwindow.cpp" line="263"/> 189 187 <source>HTML Files</source> 190 188 <translation type="unfinished"></translation> 191 189 </message> 192 190 <message> 193 <location filename="../src/mainwindow.cpp" line="2 31"/>191 <location filename="../src/mainwindow.cpp" line="265"/> 194 192 <source>OpenDocument Files</source> 195 193 <translation type="unfinished"></translation> 196 194 </message> 197 195 <message> 198 <location filename="../src/mainwindow.cpp" line="2 50"/>196 <location filename="../src/mainwindow.cpp" line="295"/> 199 197 <source>%1 Task File</source> 200 198 <translation type="unfinished"></translation> 201 199 </message> 202 200 <message> 203 <location filename="../src/mainwindow.cpp" line=" 273"/>201 <location filename="../src/mainwindow.cpp" line="326"/> 204 202 <source>Settings Changed</source> 205 203 <translation type="unfinished"></translation> 206 204 </message> 207 205 <message> 208 <location filename="../src/mainwindow.cpp" line=" 273"/>206 <location filename="../src/mainwindow.cpp" line="326"/> 209 207 <source>You have changed color settings. 210 208 Do you wish to apply them to current solution text?</source> … … 212 210 </message> 213 211 <message> 214 <location filename="../src/mainwindow.cpp" line="3 37"/>212 <location filename="../src/mainwindow.cpp" line="390"/> 215 213 <source>Data error</source> 216 214 <translation type="unfinished"></translation> 217 215 </message> 218 216 <message> 219 <location filename="../src/mainwindow.cpp" line="3 37"/>217 <location filename="../src/mainwindow.cpp" line="390"/> 220 218 <source>Error in cell [Row %1; Column %2]: Invalid data format.</source> 221 219 <translation type="unfinished"></translation> 222 220 </message> 223 221 <message> 224 <location filename="../src/mainwindow.cpp" line=" 350"/>222 <location filename="../src/mainwindow.cpp" line="403"/> 225 223 <source>Variant #%1</source> 226 224 <translation type="unfinished"></translation> 227 225 </message> 228 226 <message> 229 <location filename="../src/mainwindow.cpp" line=" 351"/>227 <location filename="../src/mainwindow.cpp" line="404"/> 230 228 <source>Task:</source> 231 229 <translation type="unfinished"></translation> 232 230 </message> 233 231 <message> 234 <location filename="../src/mainwindow.cpp" line=" 354"/>235 <location filename="../src/mainwindow.cpp" line=" 380"/>232 <location filename="../src/mainwindow.cpp" line="407"/> 233 <location filename="../src/mainwindow.cpp" line="433"/> 236 234 <source>Solution of Variant #%1 task</source> 237 235 <translation type="unfinished"></translation> 238 236 </message> 239 237 <message> 240 <location filename="../src/mainwindow.cpp" line=" 361"/>238 <location filename="../src/mainwindow.cpp" line="414"/> 241 239 <source>Step #%1</source> 242 240 <translation type="unfinished"></translation> 243 241 </message> 244 242 <message> 245 <location filename="../src/mainwindow.cpp" line=" 364"/>243 <location filename="../src/mainwindow.cpp" line="417"/> 246 244 <source>This step has alternate candidates for branching.</source> 247 245 <translation type="unfinished"></translation> 248 246 </message> 249 247 <message> 250 <location filename="../src/mainwindow.cpp" line=" 376"/>248 <location filename="../src/mainwindow.cpp" line="429"/> 251 249 <source>Optimal path:</source> 252 250 <translation type="unfinished"></translation> 253 251 </message> 254 252 <message> 255 <location filename="../src/mainwindow.cpp" line=" 378"/>253 <location filename="../src/mainwindow.cpp" line="431"/> 256 254 <source>The price is <b>%1</b> units.</source> 257 255 <translation type="unfinished"></translation> 258 256 </message> 259 257 <message> 260 <location filename="../src/mainwindow.cpp" line="4 39"/>258 <location filename="../src/mainwindow.cpp" line="492"/> 261 259 <source>Language will be autodetected on next application start.</source> 262 260 <translation type="unfinished"></translation> 263 261 </message> 264 262 <message> 265 <location filename="../src/mainwindow.cpp" line=" 448"/>263 <location filename="../src/mainwindow.cpp" line="501"/> 266 264 <source>You have language autodetection turned on. 267 265 It needs to be off. … … 270 268 </message> 271 269 <message> 272 <location filename="../src/mainwindow.cpp" line="462"/> 273 <source>Application Close</source> 270 <location filename="../src/mainwindow.cpp" line="506"/> 271 <location filename="../src/mainwindow.h" line="76"/> 272 <source>Untitled</source> 274 273 <translation type="unfinished"></translation> 275 274 </message> -
trunk/i18n/ru.ts
r42 r47 34 34 <location filename="../src/tspmodel.cpp" line="152"/> 35 35 <location filename="../src/tspmodel.cpp" line="160"/> 36 <location filename="../src/tspmodel.cpp" line="1 75"/>37 <location filename="../src/tspmodel.cpp" line=" 191"/>38 <location filename="../src/tspmodel.cpp" line="2 04"/>39 <location filename="../src/tspmodel.cpp" line="2 34"/>40 <location filename="../src/tspmodel.cpp" line="2 43"/>36 <location filename="../src/tspmodel.cpp" line="181"/> 37 <location filename="../src/tspmodel.cpp" line="201"/> 38 <location filename="../src/tspmodel.cpp" line="214"/> 39 <location filename="../src/tspmodel.cpp" line="245"/> 40 <location filename="../src/tspmodel.cpp" line="254"/> 41 41 <source>Task Load</source> 42 42 <translation>Загрузка условия</translation> … … 44 44 <message> 45 45 <location filename="../src/tspmodel.cpp" line="152"/> 46 <location filename="../src/tspmodel.cpp" line="1 75"/>47 <location filename="../src/tspmodel.cpp" line=" 191"/>48 <location filename="../src/tspmodel.cpp" line="2 04"/>49 <location filename="../src/tspmodel.cpp" line="2 34"/>50 <location filename="../src/tspmodel.cpp" line="2 43"/>46 <location filename="../src/tspmodel.cpp" line="181"/> 47 <location filename="../src/tspmodel.cpp" line="201"/> 48 <location filename="../src/tspmodel.cpp" line="214"/> 49 <location filename="../src/tspmodel.cpp" line="245"/> 50 <location filename="../src/tspmodel.cpp" line="254"/> 51 51 <source>Unable to load task:</source> 52 52 <translation>Невозможно загрузить условие:</translation> … … 60 60 </message> 61 61 <message> 62 <location filename="../src/tspmodel.cpp" line="1 75"/>62 <location filename="../src/tspmodel.cpp" line="181"/> 63 63 <source>Unknown file format or file is corrupted.</source> 64 64 <translation>Неизвестный формат файла или файл поврежден.</translation> 65 65 </message> 66 66 <message> 67 <location filename="../src/tspmodel.cpp" line=" 191"/>68 <location filename="../src/tspmodel.cpp" line="2 34"/>67 <location filename="../src/tspmodel.cpp" line="201"/> 68 <location filename="../src/tspmodel.cpp" line="245"/> 69 69 <source>File version is newer than application supports. 70 70 Please, try to update application.</source> … … 73 73 </message> 74 74 <message> 75 <location filename="../src/tspmodel.cpp" line="2 04"/>76 <location filename="../src/tspmodel.cpp" line="2 43"/>75 <location filename="../src/tspmodel.cpp" line="214"/> 76 <location filename="../src/tspmodel.cpp" line="254"/> 77 77 <source>Unexpected data read. 78 78 File is possibly corrupted.</source> … … 81 81 </message> 82 82 <message> 83 <location filename="../src/tspmodel.cpp" line="2 73"/>84 <location filename="../src/tspmodel.cpp" line="2 79"/>85 <location filename="../src/tspmodel.cpp" line="2 86"/>86 <location filename="../src/tspmodel.cpp" line=" 293"/>87 <location filename="../src/tspmodel.cpp" line="3 00"/>88 <location filename="../src/tspmodel.cpp" line="3 07"/>89 <location filename="../src/tspmodel.cpp" line="3 14"/>90 <location filename="../src/tspmodel.cpp" line="3 24"/>83 <location filename="../src/tspmodel.cpp" line="285"/> 84 <location filename="../src/tspmodel.cpp" line="291"/> 85 <location filename="../src/tspmodel.cpp" line="298"/> 86 <location filename="../src/tspmodel.cpp" line="305"/> 87 <location filename="../src/tspmodel.cpp" line="312"/> 88 <location filename="../src/tspmodel.cpp" line="319"/> 89 <location filename="../src/tspmodel.cpp" line="326"/> 90 <location filename="../src/tspmodel.cpp" line="336"/> 91 91 <source>Task Save</source> 92 92 <translation>Сохранение условия</translation> 93 93 </message> 94 94 <message> 95 <location filename="../src/tspmodel.cpp" line="2 73"/>95 <location filename="../src/tspmodel.cpp" line="285"/> 96 96 <source>Unable to create task file. 97 97 Error: %1 … … 102 102 </message> 103 103 <message> 104 <location filename="../src/tspmodel.cpp" line="2 79"/>105 <location filename="../src/tspmodel.cpp" line="2 86"/>106 <location filename="../src/tspmodel.cpp" line=" 293"/>107 <location filename="../src/tspmodel.cpp" line="3 00"/>108 <location filename="../src/tspmodel.cpp" line="3 07"/>109 <location filename="../src/tspmodel.cpp" line="3 14"/>110 <location filename="../src/tspmodel.cpp" line="3 24"/>104 <location filename="../src/tspmodel.cpp" line="291"/> 105 <location filename="../src/tspmodel.cpp" line="298"/> 106 <location filename="../src/tspmodel.cpp" line="305"/> 107 <location filename="../src/tspmodel.cpp" line="312"/> 108 <location filename="../src/tspmodel.cpp" line="319"/> 109 <location filename="../src/tspmodel.cpp" line="326"/> 110 <location filename="../src/tspmodel.cpp" line="336"/> 111 111 <source>Unable to save task. 112 112 Error: %1</source> … … 146 146 <name>MainWindow</name> 147 147 <message> 148 <location filename="../src/mainwindow.cpp" line="14 1"/>149 <location filename="../src/mainwindow.cpp" line="4 39"/>150 <location filename="../src/mainwindow.cpp" line=" 448"/>148 <location filename="../src/mainwindow.cpp" line="146"/> 149 <location filename="../src/mainwindow.cpp" line="492"/> 150 <location filename="../src/mainwindow.cpp" line="501"/> 151 151 <source>Language change</source> 152 152 <translation>Смена языка</translation> 153 153 </message> 154 154 <message> 155 <location filename="../src/mainwindow.cpp" line="14 1"/>155 <location filename="../src/mainwindow.cpp" line="146"/> 156 156 <source>Unable to load translation language.</source> 157 157 <translation>Невозможно загрузить перевод.</translation> 158 158 </message> 159 159 <message> 160 <location filename="../src/mainwindow.cpp" line="202"/> 160 <location filename="../src/mainwindow.cpp" line="170"/> 161 <source>Travelling Salesman Problem</source> 162 <translation>Задача коммивояжера</translation> 163 </message> 164 <message> 165 <location filename="../src/mainwindow.cpp" line="192"/> 166 <source>Unsaved Changes</source> 167 <translation>Несохраненные изменения</translation> 168 </message> 169 <message> 170 <location filename="../src/mainwindow.cpp" line="224"/> 161 171 <source>All Supported Formats</source> 162 172 <translation>Все поддерживаемые форматы</translation> 163 173 </message> 164 174 <message> 165 <location filename="../src/mainwindow.cpp" line="2 05"/>166 <location filename="../src/mainwindow.cpp" line="2 32"/>167 <location filename="../src/mainwindow.cpp" line="2 51"/>175 <location filename="../src/mainwindow.cpp" line="227"/> 176 <location filename="../src/mainwindow.cpp" line="267"/> 177 <location filename="../src/mainwindow.cpp" line="296"/> 168 178 <source>All Files</source> 169 179 <translation>Все файлы</translation> 170 180 </message> 171 181 <message> 172 <location filename="../src/mainwindow.cpp" line="2 03"/>173 <location filename="../src/mainwindow.cpp" line="2 04"/>182 <location filename="../src/mainwindow.cpp" line="225"/> 183 <location filename="../src/mainwindow.cpp" line="226"/> 174 184 <source>%1 Task Files</source> 175 185 <translation>Файлы условий %1</translation> 176 186 </message> 177 187 <message> 178 <location filename="../src/mainwindow.cpp" line="181"/> 179 <source>New Task</source> 180 <translation>Создать задачу</translation> 181 </message> 182 <message> 183 <location filename="../src/mainwindow.cpp" line="181"/> 184 <location filename="../src/mainwindow.cpp" line="195"/> 185 <location filename="../src/mainwindow.cpp" line="462"/> 188 <location filename="../src/mainwindow.cpp" line="192"/> 186 189 <source>Would you like to save changes in current task?</source> 187 190 <translation>Желаете сохранить изменения в текущей задаче?</translation> 188 191 </message> 189 192 <message> 190 <location filename="../src/mainwindow.cpp" line="195"/> 191 <source>Task Open</source> 192 <translation>Открытие задания</translation> 193 </message> 194 <message> 195 <location filename="../src/mainwindow.cpp" line="230"/> 193 <location filename="../src/mainwindow.cpp" line="263"/> 196 194 <source>HTML Files</source> 197 195 <translation>Файлы HTML</translation> 198 196 </message> 199 197 <message> 200 <location filename="../src/mainwindow.cpp" line="2 31"/>198 <location filename="../src/mainwindow.cpp" line="265"/> 201 199 <source>OpenDocument Files</source> 202 200 <translation>Файлы OpenDocument</translation> 203 201 </message> 204 202 <message> 205 <location filename="../src/mainwindow.cpp" line="2 50"/>203 <location filename="../src/mainwindow.cpp" line="295"/> 206 204 <source>%1 Task File</source> 207 205 <translation>Файл условия %1</translation> 208 206 </message> 209 207 <message> 210 <location filename="../src/mainwindow.cpp" line=" 273"/>208 <location filename="../src/mainwindow.cpp" line="326"/> 211 209 <source>Settings Changed</source> 212 210 <translation>Параметры изменены</translation> 213 211 </message> 214 212 <message> 215 <location filename="../src/mainwindow.cpp" line=" 273"/>213 <location filename="../src/mainwindow.cpp" line="326"/> 216 214 <source>You have changed color settings. 217 215 Do you wish to apply them to current solution text?</source> … … 220 218 </message> 221 219 <message> 222 <location filename="../src/mainwindow.cpp" line="3 37"/>220 <location filename="../src/mainwindow.cpp" line="390"/> 223 221 <source>Data error</source> 224 222 <translation>Ошибка в данных</translation> 225 223 </message> 226 224 <message> 227 <location filename="../src/mainwindow.cpp" line="3 37"/>225 <location filename="../src/mainwindow.cpp" line="390"/> 228 226 <source>Error in cell [Row %1; Column %2]: Invalid data format.</source> 229 227 <translation>Ошибка в ячейке [Строка %1; Колонка %2]: Неверный формат данных.</translation> 230 228 </message> 231 229 <message> 232 <location filename="../src/mainwindow.cpp" line=" 350"/>230 <location filename="../src/mainwindow.cpp" line="403"/> 233 231 <source>Variant #%1</source> 234 232 <translation>Вариант №%1</translation> 235 233 </message> 236 234 <message> 237 <location filename="../src/mainwindow.cpp" line=" 351"/>235 <location filename="../src/mainwindow.cpp" line="404"/> 238 236 <source>Task:</source> 239 237 <translation>Условие:</translation> 240 238 </message> 241 239 <message> 242 <location filename="../src/mainwindow.cpp" line=" 354"/>243 <location filename="../src/mainwindow.cpp" line=" 380"/>240 <location filename="../src/mainwindow.cpp" line="407"/> 241 <location filename="../src/mainwindow.cpp" line="433"/> 244 242 <source>Solution of Variant #%1 task</source> 245 243 <translation>Решение варианта №%1</translation> 246 244 </message> 247 245 <message> 248 <location filename="../src/mainwindow.cpp" line=" 361"/>246 <location filename="../src/mainwindow.cpp" line="414"/> 249 247 <source>Step #%1</source> 250 248 <translation>Шаг №%1</translation> 251 249 </message> 252 250 <message> 253 <location filename="../src/mainwindow.cpp" line=" 364"/>251 <location filename="../src/mainwindow.cpp" line="417"/> 254 252 <source>This step has alternate candidates for branching.</source> 255 253 <translation>У этого шага есть альтернативные кандидаты на ветвление.</translation> 256 254 </message> 257 255 <message> 258 <location filename="../src/mainwindow.cpp" line=" 376"/>256 <location filename="../src/mainwindow.cpp" line="429"/> 259 257 <source>Optimal path:</source> 260 258 <translation>Оптимальный путь:</translation> 261 259 </message> 262 260 <message> 263 <location filename="../src/mainwindow.cpp" line=" 378"/>261 <location filename="../src/mainwindow.cpp" line="431"/> 264 262 <source>The price is <b>%1</b> units.</source> 265 263 <translation>Стоимость - <b>%1</b> единиц.</translation> 266 264 </message> 267 265 <message> 268 <location filename="../src/mainwindow.cpp" line="4 39"/>266 <location filename="../src/mainwindow.cpp" line="492"/> 269 267 <source>Language will be autodetected on next application start.</source> 270 268 <translation>Язык будет автоматически определен при следующем запуске приложения.</translation> 271 269 </message> 272 270 <message> 273 <location filename="../src/mainwindow.cpp" line=" 448"/>271 <location filename="../src/mainwindow.cpp" line="501"/> 274 272 <source>You have language autodetection turned on. 275 273 It needs to be off. … … 280 278 </message> 281 279 <message> 282 <location filename="../src/mainwindow.cpp" line="462"/> 283 <source>Application Close</source> 284 <translation>Закрытие приложения</translation> 280 <location filename="../src/mainwindow.cpp" line="506"/> 281 <location filename="../src/mainwindow.h" line="76"/> 282 <source>Untitled</source> 283 <translation>Без имени</translation> 285 284 </message> 286 285 <message> -
trunk/i18n/uk.ts
r42 r47 34 34 <location filename="../src/tspmodel.cpp" line="152"/> 35 35 <location filename="../src/tspmodel.cpp" line="160"/> 36 <location filename="../src/tspmodel.cpp" line="1 75"/>37 <location filename="../src/tspmodel.cpp" line=" 191"/>38 <location filename="../src/tspmodel.cpp" line="2 04"/>39 <location filename="../src/tspmodel.cpp" line="2 34"/>40 <location filename="../src/tspmodel.cpp" line="2 43"/>36 <location filename="../src/tspmodel.cpp" line="181"/> 37 <location filename="../src/tspmodel.cpp" line="201"/> 38 <location filename="../src/tspmodel.cpp" line="214"/> 39 <location filename="../src/tspmodel.cpp" line="245"/> 40 <location filename="../src/tspmodel.cpp" line="254"/> 41 41 <source>Task Load</source> 42 42 <translation>Завантаження умови</translation> … … 44 44 <message> 45 45 <location filename="../src/tspmodel.cpp" line="152"/> 46 <location filename="../src/tspmodel.cpp" line="1 75"/>47 <location filename="../src/tspmodel.cpp" line=" 191"/>48 <location filename="../src/tspmodel.cpp" line="2 04"/>49 <location filename="../src/tspmodel.cpp" line="2 34"/>50 <location filename="../src/tspmodel.cpp" line="2 43"/>46 <location filename="../src/tspmodel.cpp" line="181"/> 47 <location filename="../src/tspmodel.cpp" line="201"/> 48 <location filename="../src/tspmodel.cpp" line="214"/> 49 <location filename="../src/tspmodel.cpp" line="245"/> 50 <location filename="../src/tspmodel.cpp" line="254"/> 51 51 <source>Unable to load task:</source> 52 52 <translation>Неможливо завантажити умову:</translation> … … 60 60 </message> 61 61 <message> 62 <location filename="../src/tspmodel.cpp" line="1 75"/>62 <location filename="../src/tspmodel.cpp" line="181"/> 63 63 <source>Unknown file format or file is corrupted.</source> 64 64 <translation>Невідомий формат файлу або файл пошкоджено.</translation> 65 65 </message> 66 66 <message> 67 <location filename="../src/tspmodel.cpp" line=" 191"/>68 <location filename="../src/tspmodel.cpp" line="2 34"/>67 <location filename="../src/tspmodel.cpp" line="201"/> 68 <location filename="../src/tspmodel.cpp" line="245"/> 69 69 <source>File version is newer than application supports. 70 70 Please, try to update application.</source> … … 73 73 </message> 74 74 <message> 75 <location filename="../src/tspmodel.cpp" line="2 04"/>76 <location filename="../src/tspmodel.cpp" line="2 43"/>75 <location filename="../src/tspmodel.cpp" line="214"/> 76 <location filename="../src/tspmodel.cpp" line="254"/> 77 77 <source>Unexpected data read. 78 78 File is possibly corrupted.</source> … … 81 81 </message> 82 82 <message> 83 <location filename="../src/tspmodel.cpp" line="2 73"/>84 <location filename="../src/tspmodel.cpp" line="2 79"/>85 <location filename="../src/tspmodel.cpp" line="2 86"/>86 <location filename="../src/tspmodel.cpp" line=" 293"/>87 <location filename="../src/tspmodel.cpp" line="3 00"/>88 <location filename="../src/tspmodel.cpp" line="3 07"/>89 <location filename="../src/tspmodel.cpp" line="3 14"/>90 <location filename="../src/tspmodel.cpp" line="3 24"/>83 <location filename="../src/tspmodel.cpp" line="285"/> 84 <location filename="../src/tspmodel.cpp" line="291"/> 85 <location filename="../src/tspmodel.cpp" line="298"/> 86 <location filename="../src/tspmodel.cpp" line="305"/> 87 <location filename="../src/tspmodel.cpp" line="312"/> 88 <location filename="../src/tspmodel.cpp" line="319"/> 89 <location filename="../src/tspmodel.cpp" line="326"/> 90 <location filename="../src/tspmodel.cpp" line="336"/> 91 91 <source>Task Save</source> 92 92 <translation>Збереження умови</translation> 93 93 </message> 94 94 <message> 95 <location filename="../src/tspmodel.cpp" line="2 73"/>95 <location filename="../src/tspmodel.cpp" line="285"/> 96 96 <source>Unable to create task file. 97 97 Error: %1 … … 102 102 </message> 103 103 <message> 104 <location filename="../src/tspmodel.cpp" line="2 79"/>105 <location filename="../src/tspmodel.cpp" line="2 86"/>106 <location filename="../src/tspmodel.cpp" line=" 293"/>107 <location filename="../src/tspmodel.cpp" line="3 00"/>108 <location filename="../src/tspmodel.cpp" line="3 07"/>109 <location filename="../src/tspmodel.cpp" line="3 14"/>110 <location filename="../src/tspmodel.cpp" line="3 24"/>104 <location filename="../src/tspmodel.cpp" line="291"/> 105 <location filename="../src/tspmodel.cpp" line="298"/> 106 <location filename="../src/tspmodel.cpp" line="305"/> 107 <location filename="../src/tspmodel.cpp" line="312"/> 108 <location filename="../src/tspmodel.cpp" line="319"/> 109 <location filename="../src/tspmodel.cpp" line="326"/> 110 <location filename="../src/tspmodel.cpp" line="336"/> 111 111 <source>Unable to save task. 112 112 Error: %1</source> … … 578 578 </message> 579 579 <message> 580 <location filename="../src/mainwindow.cpp" line="14 1"/>581 <location filename="../src/mainwindow.cpp" line="4 39"/>582 <location filename="../src/mainwindow.cpp" line=" 448"/>580 <location filename="../src/mainwindow.cpp" line="146"/> 581 <location filename="../src/mainwindow.cpp" line="492"/> 582 <location filename="../src/mainwindow.cpp" line="501"/> 583 583 <source>Language change</source> 584 584 <translation>Зміна мови</translation> 585 585 </message> 586 586 <message> 587 <location filename="../src/mainwindow.cpp" line="14 1"/>587 <location filename="../src/mainwindow.cpp" line="146"/> 588 588 <source>Unable to load translation language.</source> 589 589 <translation>Неможливо завантажити переклад.</translation> 590 590 </message> 591 591 <message> 592 <location filename="../src/mainwindow.cpp" line="202"/> 592 <location filename="../src/mainwindow.cpp" line="170"/> 593 <source>Travelling Salesman Problem</source> 594 <translation>Задача комівояжера</translation> 595 </message> 596 <message> 597 <location filename="../src/mainwindow.cpp" line="192"/> 598 <source>Unsaved Changes</source> 599 <translation>Незбережені зміни</translation> 600 </message> 601 <message> 602 <location filename="../src/mainwindow.cpp" line="224"/> 593 603 <source>All Supported Formats</source> 594 604 <translation>Усі підтримувані формати</translation> 595 605 </message> 596 606 <message> 597 <location filename="../src/mainwindow.cpp" line="2 05"/>598 <location filename="../src/mainwindow.cpp" line="2 32"/>599 <location filename="../src/mainwindow.cpp" line="2 51"/>607 <location filename="../src/mainwindow.cpp" line="227"/> 608 <location filename="../src/mainwindow.cpp" line="267"/> 609 <location filename="../src/mainwindow.cpp" line="296"/> 600 610 <source>All Files</source> 601 611 <translation>Усі файли</translation> 602 612 </message> 603 613 <message> 604 <location filename="../src/mainwindow.cpp" line="2 03"/>605 <location filename="../src/mainwindow.cpp" line="2 04"/>614 <location filename="../src/mainwindow.cpp" line="225"/> 615 <location filename="../src/mainwindow.cpp" line="226"/> 606 616 <source>%1 Task Files</source> 607 617 <translation>Файли умов %1</translation> 608 618 </message> 609 619 <message> 610 <location filename="../src/mainwindow.cpp" line="181"/> 611 <source>New Task</source> 612 <translation>Нова задача</translation> 613 </message> 614 <message> 615 <location filename="../src/mainwindow.cpp" line="181"/> 616 <location filename="../src/mainwindow.cpp" line="195"/> 617 <location filename="../src/mainwindow.cpp" line="462"/> 620 <location filename="../src/mainwindow.cpp" line="192"/> 618 621 <source>Would you like to save changes in current task?</source> 619 622 <translation>Бажаете зберегти зміни у поточній задачі?</translation> 620 623 </message> 621 624 <message> 622 <location filename="../src/mainwindow.cpp" line="195"/> 623 <source>Task Open</source> 624 <translation>Відкриття завдання</translation> 625 </message> 626 <message> 627 <location filename="../src/mainwindow.cpp" line="230"/> 625 <location filename="../src/mainwindow.cpp" line="263"/> 628 626 <source>HTML Files</source> 629 627 <translation>Файли HTML</translation> 630 628 </message> 631 629 <message> 632 <location filename="../src/mainwindow.cpp" line="2 31"/>630 <location filename="../src/mainwindow.cpp" line="265"/> 633 631 <source>OpenDocument Files</source> 634 632 <translation>Файли OpenDocument</translation> 635 633 </message> 636 634 <message> 637 <location filename="../src/mainwindow.cpp" line="2 50"/>635 <location filename="../src/mainwindow.cpp" line="295"/> 638 636 <source>%1 Task File</source> 639 637 <translation>Файл умови %1</translation> 640 638 </message> 641 639 <message> 642 <location filename="../src/mainwindow.cpp" line=" 273"/>640 <location filename="../src/mainwindow.cpp" line="326"/> 643 641 <source>Settings Changed</source> 644 642 <translation>Параметри змінено</translation> 645 643 </message> 646 644 <message> 647 <location filename="../src/mainwindow.cpp" line=" 273"/>645 <location filename="../src/mainwindow.cpp" line="326"/> 648 646 <source>You have changed color settings. 649 647 Do you wish to apply them to current solution text?</source> … … 652 650 </message> 653 651 <message> 654 <location filename="../src/mainwindow.cpp" line="3 37"/>652 <location filename="../src/mainwindow.cpp" line="390"/> 655 653 <source>Data error</source> 656 654 <translation>Помилка у даних</translation> 657 655 </message> 658 656 <message> 659 <location filename="../src/mainwindow.cpp" line="3 37"/>657 <location filename="../src/mainwindow.cpp" line="390"/> 660 658 <source>Error in cell [Row %1; Column %2]: Invalid data format.</source> 661 659 <translation>Помилка у комірці [Рядок %1; Колонка %2]: Невірний формат даних.</translation> 662 660 </message> 663 661 <message> 664 <location filename="../src/mainwindow.cpp" line=" 350"/>662 <location filename="../src/mainwindow.cpp" line="403"/> 665 663 <source>Variant #%1</source> 666 664 <translation>Варіант №%1</translation> 667 665 </message> 668 666 <message> 669 <location filename="../src/mainwindow.cpp" line=" 351"/>667 <location filename="../src/mainwindow.cpp" line="404"/> 670 668 <source>Task:</source> 671 669 <translation>Умова:</translation> 672 670 </message> 673 671 <message> 674 <location filename="../src/mainwindow.cpp" line=" 354"/>675 <location filename="../src/mainwindow.cpp" line=" 380"/>672 <location filename="../src/mainwindow.cpp" line="407"/> 673 <location filename="../src/mainwindow.cpp" line="433"/> 676 674 <source>Solution of Variant #%1 task</source> 677 675 <translation>Розв'язок варіанту №%1</translation> 678 676 </message> 679 677 <message> 680 <location filename="../src/mainwindow.cpp" line=" 361"/>678 <location filename="../src/mainwindow.cpp" line="414"/> 681 679 <source>Step #%1</source> 682 680 <translation>Крок №%1</translation> 683 681 </message> 684 682 <message> 685 <location filename="../src/mainwindow.cpp" line=" 364"/>683 <location filename="../src/mainwindow.cpp" line="417"/> 686 684 <source>This step has alternate candidates for branching.</source> 687 685 <translation>У цьому кроці є альтернативні кандидати на розгалудження.</translation> 688 686 </message> 689 687 <message> 690 <location filename="../src/mainwindow.cpp" line=" 376"/>688 <location filename="../src/mainwindow.cpp" line="429"/> 691 689 <source>Optimal path:</source> 692 690 <translation>Оптимальний шлях:</translation> 693 691 </message> 694 692 <message> 695 <location filename="../src/mainwindow.cpp" line=" 378"/>693 <location filename="../src/mainwindow.cpp" line="431"/> 696 694 <source>The price is <b>%1</b> units.</source> 697 695 <translation>Вартість - <b>%1</b> одиниць.</translation> 698 696 </message> 699 697 <message> 700 <location filename="../src/mainwindow.cpp" line="4 39"/>698 <location filename="../src/mainwindow.cpp" line="492"/> 701 699 <source>Language will be autodetected on next application start.</source> 702 700 <translation>Мову буде автоматично визначено при наступному запуску додатку.</translation> 703 701 </message> 704 702 <message> 705 <location filename="../src/mainwindow.cpp" line=" 448"/>703 <location filename="../src/mainwindow.cpp" line="501"/> 706 704 <source>You have language autodetection turned on. 707 705 It needs to be off. … … 712 710 </message> 713 711 <message> 714 <location filename="../src/mainwindow.cpp" line="462"/> 715 <source>Application Close</source> 716 <translation>Закриття додатку</translation> 712 <location filename="../src/mainwindow.cpp" line="506"/> 713 <location filename="../src/mainwindow.h" line="76"/> 714 <source>Untitled</source> 715 <translation>Без імені</translation> 717 716 </message> 718 717 </context> -
trunk/src/mainwindow.cpp
r45 r47 87 87 connect(tspmodel,SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),this,SLOT(dataChanged())); 88 88 connect(tspmodel,SIGNAL(layoutChanged()),this,SLOT(dataChanged())); 89 if ( QCoreApplication::arguments().count() > 1) {90 tspmodel->loadTask(QCoreApplication::arguments().at(1));89 if ((QCoreApplication::arguments().count() > 1) && (tspmodel->loadTask(QCoreApplication::arguments().at(1)))) { 90 setFileName(QCoreApplication::arguments().at(1)); 91 91 setWindowModified(false); 92 } 92 } else 93 setFileName(); 93 94 #ifdef Q_OS_WINCE 94 95 taskView->resizeColumnsToContents(); … … 164 165 } 165 166 167 void MainWindow::setFileName(QString fileName) 168 { 169 this->fileName = fileName; 170 setWindowTitle(QString("%1[*] - %2").arg(QFileInfo(fileName).completeBaseName()).arg(trUtf8("Travelling Salesman Problem"))); 171 } 172 166 173 void MainWindow::spinCitiesValueChanged(int n) 167 174 { … … 179 186 } 180 187 188 bool MainWindow::maybeSave() 189 { 190 if (!isWindowModified()) 191 return true; 192 int res = QMessageBox(QMessageBox::Warning,trUtf8("Unsaved Changes"),trUtf8("Would you like to save changes in current task?"),QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,this).exec(); 193 if (res == QMessageBox::Save) 194 return saveTask(); 195 else if (res == QMessageBox::Cancel) 196 return false; 197 else 198 return true; 199 } 181 200 182 201 void MainWindow::actionFileNewTriggered() 183 202 { 184 if (isWindowModified()) { 185 int res = QMessageBox(QMessageBox::Warning,trUtf8("New Task"),trUtf8("Would you like to save changes in current task?"),QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,this).exec(); 186 if ((res == QMessageBox::Cancel) || ((res == QMessageBox::Yes) && !saveTask())) 187 return; 188 } 203 if (!maybeSave()) 204 return; 189 205 tspmodel->clear(); 206 #ifdef Q_OS_WINCE 207 taskView->resizeColumnsToContents(); 208 taskView->resizeRowsToContents(); 209 #endif 210 setFileName(); 190 211 setWindowModified(false); 191 212 tabWidget->setCurrentIndex(0); … … 196 217 void MainWindow::actionFileOpenTriggered() 197 218 { 198 if (isWindowModified()) { 199 int res = QMessageBox(QMessageBox::Warning,trUtf8("Task Open"),trUtf8("Would you like to save changes in current task?"),QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,this).exec(); 200 if ((res == QMessageBox::Cancel) || ((res == QMessageBox::Yes) && !saveTask())) 201 return; 202 } 219 if (!maybeSave()) 220 return; 203 221 QFileDialog od(this); 204 222 od.setAcceptMode(QFileDialog::AcceptOpen); 205 223 od.setFileMode(QFileDialog::ExistingFile); 206 224 QStringList filters(trUtf8("All Supported Formats") + " (*.tspt *.zkt)"); 207 filters.append( QString(trUtf8("%1 Task Files")).arg("TSPSG") + " (*.tspt)");208 filters.append( QString(trUtf8("%1 Task Files")).arg("ZKomModRd") + " (*.zkt)");225 filters.append(trUtf8("%1 Task Files").arg("TSPSG") + " (*.tspt)"); 226 filters.append(trUtf8("%1 Task Files").arg("ZKomModRd") + " (*.zkt)"); 209 227 filters.append(trUtf8("All Files") + " (*)"); 210 228 od.setNameFilters(filters); … … 212 230 return; 213 231 QStringList files = od.selectedFiles(); 214 if (files.size() < 1) 215 return; 216 tspmodel->loadTask(files.first()); 232 if (files.empty()) 233 return; 234 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 235 if (!tspmodel->loadTask(files.first())) { 236 QApplication::restoreOverrideCursor(); 237 return; 238 } 239 setFileName(files.first()); 240 #ifdef Q_OS_WINCE 241 taskView->resizeColumnsToContents(); 242 taskView->resizeRowsToContents(); 243 #endif 244 tabWidget->setCurrentIndex(0); 217 245 setWindowModified(false); 218 246 solutionText->clear(); 219 247 enableSolutionActions(false); 248 QApplication::restoreOverrideCursor(); 220 249 } 221 250 … … 264 293 QFileDialog sd(this); 265 294 sd.setAcceptMode(QFileDialog::AcceptSave); 266 QStringList filters( QString(trUtf8("%1 Task File")).arg("TSPSG") + " (*.tspt)");295 QStringList filters(trUtf8("%1 Task File").arg("TSPSG") + " (*.tspt)"); 267 296 filters.append(trUtf8("All Files") + " (*)"); 268 297 sd.setNameFilters(filters); 269 298 sd.setDefaultSuffix("tspt"); 299 if (fileName.endsWith(".tspt",Qt::CaseInsensitive)) 300 sd.selectFile(fileName); 301 else 302 sd.selectFile(QFileInfo(fileName).canonicalPath() + "/" + QFileInfo(fileName).completeBaseName() + ".tspt"); 270 303 if (sd.exec() != QDialog::Accepted) 271 304 return false; 272 305 QStringList files = sd.selectedFiles(); 273 if (files. size() < 1)306 if (files.empty()) 274 307 return false; 308 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 275 309 if (tspmodel->saveTask(files.first())) { 310 setFileName(files.first()); 276 311 setWindowModified(false); 312 QApplication::restoreOverrideCursor(); 277 313 return true; 278 } else 279 return false; 314 } 315 QApplication::restoreOverrideCursor(); 316 return false; 280 317 } 281 318 … … 351 388 row.append(tspmodel->index(r,c).data(Qt::UserRole).toDouble(&ok)); 352 389 if (!ok) { 353 QMessageBox(QMessageBox::Critical,trUtf8("Data error"), QString(trUtf8("Error in cell [Row %1; Column %2]: Invalid data format.")).arg(r + 1).arg(c + 1),QMessageBox::Ok,this).exec();390 QMessageBox(QMessageBox::Critical,trUtf8("Data error"),trUtf8("Error in cell [Row %1; Column %2]: Invalid data format.").arg(r + 1).arg(c + 1),QMessageBox::Ok,this).exec(); 354 391 return; 355 392 } … … 467 504 return; 468 505 } 506 bool untitled = (fileName == trUtf8("Untitled") + ".tspt"); 469 507 if (loadLanguage(action->data().toString())) { 470 508 settings->setValue("Language",action->data().toString()); 471 509 retranslateUi(this); 510 if (untitled) 511 setFileName(); 472 512 } 473 513 } … … 475 515 void MainWindow::closeEvent(QCloseEvent *event) 476 516 { 477 if (isWindowModified()) { 478 int res = QMessageBox(QMessageBox::Warning,trUtf8("Application Close"),trUtf8("Would you like to save changes in current task?"),QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,this).exec(); 479 if ((res == QMessageBox::Cancel) || ((res == QMessageBox::Yes) && !saveTask())) { 480 event->ignore(); 481 return; 482 } 517 if (!maybeSave()) { 518 event->ignore(); 519 return; 483 520 } 484 521 settings->setValue("NumCities",spinCities->value()); -
trunk/src/mainwindow.h
r42 r47 38 38 { 39 39 Q_OBJECT 40 40 41 public: 41 42 MainWindow(QWidget *parent = 0); 42 43 void closeEvent(QCloseEvent *); 44 43 45 private slots: 44 46 void actionFileNewTriggered(); … … 58 60 void spinCitiesValueChanged(int); 59 61 void numCitiesChanged(int); 62 60 63 private: 61 64 QSettings *settings; 62 65 QPrinter *printer; 63 66 CTSPModel *tspmodel; 67 QString fileName; 64 68 QActionGroup *groupSettingsLanguageList; 65 69 QStringList output; 70 void enableSolutionActions(bool enable = true); 71 void initDocStyleSheet(); 66 72 bool loadLanguage(QString lang = ""); 67 73 void loadLangList(); 68 void initDocStyleSheet(); 74 bool maybeSave(); 75 void outputMatrix(tMatrix, QStringList &, int nRow = -1, int nCol = -1); 76 void setFileName(QString fileName = trUtf8("Untitled") + ".tspt"); 69 77 bool saveTask(); 70 void outputMatrix(tMatrix, QStringList &, int nRow = -1, int nCol = -1);71 void enableSolutionActions(bool enable = true);72 78 }; 73 79 -
trunk/src/tspmodel.cpp
r42 r47 154 154 } 155 155 156 voidCTSPModel::loadTask(QString fname)156 bool CTSPModel::loadTask(QString fname) 157 157 { 158 158 QFile f(fname); 159 159 if (!f.open(QIODevice::ReadOnly)) { 160 160 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),QString(trUtf8("Unable to open task file.\nError: %1")).arg(f.errorString()),QMessageBox::Ok).exec(); 161 return ;161 return false; 162 162 } 163 163 QDataStream ds(&f); … … 166 166 ds >> sig; 167 167 if (loadError(ds.status())) 168 return ;168 return false; 169 169 ds.device()->reset(); 170 170 if (sig == TSPT) 171 loadTSPT(&ds); 171 if (!loadTSPT(&ds)) { 172 f.close(); 173 return false; 174 } 172 175 else if ((sig >> 16) == ZKT) 173 loadZKT(&ds); 174 else 176 if (!loadZKT(&ds)) { 177 f.close(); 178 return false; 179 } 180 else { 175 181 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("Unknown file format or file is corrupted."),QMessageBox::Ok).exec(); 182 f.close(); 183 return false; 184 } 176 185 f.close(); 177 } 178 179 void CTSPModel::loadTSPT(QDataStream *ds) 186 return true; 187 } 188 189 bool CTSPModel::loadTSPT(QDataStream *ds) 180 190 { 181 191 // Skipping signature 182 192 ds->skipRawData(sizeof(TSPT)); 183 193 if (loadError(ds->status())) 184 return ;194 return false; 185 195 // File version 186 196 quint8 version; 187 197 *ds >> version; 188 198 if (loadError(ds->status())) 189 return ;199 return false; 190 200 if (version > TSPT_VERSION) { 191 201 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("File version is newer than application supports.\nPlease, try to update application."),QMessageBox::Ok).exec(); 192 return ;202 return false; 193 203 } 194 204 // Skipping metadata 195 205 ds->skipRawData(TSPT_META_SIZE); 196 206 if (loadError(ds->status())) 197 return ;207 return false; 198 208 // Cities number 199 209 quint16 size; 200 210 *ds >> size; 201 211 if (loadError(ds->status())) 202 return ;212 return false; 203 213 if (size < 3) { 204 214 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("Unexpected data read.\nFile is possibly corrupted."),QMessageBox::Ok).exec(); 205 return ;215 return false; 206 216 } 207 217 if (nCities != size) … … 214 224 if (loadError(ds->status())) { 215 225 clear(); 216 return ;226 return false; 217 227 } 218 228 } 219 229 emit dataChanged(index(0,0),index(nCities - 1,nCities - 1)); 220 } 221 222 void CTSPModel::loadZKT(QDataStream *ds) 230 return true; 231 } 232 233 bool CTSPModel::loadZKT(QDataStream *ds) 223 234 { 224 235 // Skipping signature 225 236 ds->skipRawData(sizeof(ZKT)); 226 237 if (loadError(ds->status())) 227 return ;238 return false; 228 239 // File version 229 240 quint16 version; 230 241 ds->readRawData(reinterpret_cast<char *>(&version),2); 231 242 if (loadError(ds->status())) 232 return ;243 return false; 233 244 if (version > ZKT_VERSION) { 234 245 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("File version is newer than application supports.\nPlease, try to update application."),QMessageBox::Ok).exec(); 235 return ;246 return false; 236 247 } 237 248 // Cities number … … 239 250 ds->readRawData(reinterpret_cast<char *>(&size),1); 240 251 if (loadError(ds->status())) 241 return ;252 return false; 242 253 if ((size < 3) || (size > 5)) { 243 254 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("Unexpected data read.\nFile is possibly corrupted."),QMessageBox::Ok).exec(); 244 return ;255 return false; 245 256 } 246 257 if (nCities != size) … … 254 265 if (loadError(ds->status())) { 255 266 clear(); 256 return ;267 return false; 257 268 } 258 269 table[r][c] = val; … … 261 272 if (loadError(ds->status())) { 262 273 clear(); 263 return ;274 return false; 264 275 } 265 276 } 266 277 emit dataChanged(index(0,0),index(nCities - 1,nCities - 1)); 278 return true; 267 279 } 268 280 -
trunk/src/tspmodel.h
r46 r47 30 30 { 31 31 Q_OBJECT 32 32 33 public: 33 34 CTSPModel(QObject *parent = 0); 35 void clear(); 36 int columnCount(const QModelIndex &) const; 37 QVariant data(const QModelIndex &, int) const; 38 Qt::ItemFlags flags(const QModelIndex &) const; 39 QVariant headerData(int, Qt::Orientation, int) const; 40 bool loadTask(QString); 41 quint16 numCities() const; 42 void randomize(); 34 43 int rowCount(const QModelIndex &) const; 35 int columnCount(const QModelIndex &) const; 36 QVariant headerData(int, Qt::Orientation, int) const; 37 QVariant data(const QModelIndex &, int) const; 44 bool saveTask(QString); 38 45 bool setData(const QModelIndex &, const QVariant &, int); 39 Qt::ItemFlags flags(const QModelIndex &) const;40 quint16 numCities() const;41 46 void setNumCities(int); 42 void clear(); 43 void loadTask(QString); 44 bool saveTask(QString); 45 void randomize(); 47 46 48 signals: 47 49 void numCitiesChanged(int); 50 48 51 private: 49 52 QSettings *settings; 50 53 QVector<QVector<double> > table; 51 54 quint16 nCities; 55 bool loadError(QDataStream::Status); 56 bool loadZKT(QDataStream *); 57 bool loadTSPT(QDataStream *); 52 58 int rand(int, int) const; 53 bool loadError(QDataStream::Status);54 void loadZKT(QDataStream *);55 void loadTSPT(QDataStream *);56 59 }; 57 60 -
trunk/ui/mainwindow.ce.ui
r42 r47 15 15 </property> 16 16 <property name="windowTitle"> 17 <string>Travelling salesman problem[*]</string>17 <string>Travelling Salesman Problem[*]</string> 18 18 </property> 19 19 <property name="windowIcon"> 20 20 <iconset resource="../resources/tspsg.qrc"> 21 <normaloff>:/images/ Icon.png</normaloff>:/images/Icon.png</iconset>21 <normaloff>:/images/icon.png</normaloff>:/images/icon.png</iconset> 22 22 </property> 23 23 <widget class="QWidget" name="centralwidget"> -
trunk/ui/mainwindow.ui
r42 r47 12 12 </property> 13 13 <property name="windowTitle"> 14 <string>Travelling salesman problem[*]</string>14 <string>Travelling Salesman Problem</string> 15 15 </property> 16 16 <property name="windowIcon"> 17 17 <iconset resource="../resources/tspsg.qrc"> 18 <normaloff>:/images/ Icon.png</normaloff>:/images/Icon.png</iconset>18 <normaloff>:/images/icon.png</normaloff>:/images/icon.png</iconset> 19 19 </property> 20 20 <widget class="QWidget" name="centralwidget">
Note: See TracChangeset
for help on using the changeset viewer.