Changeset 45 in tspsg-svn for trunk/src/mainwindow.cpp
- Timestamp:
- Aug 2, 2009, 1:50:14 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mainwindow.cpp
r42 r45 1 1 /* 2 2 * TSPSG: TSP Solver and Generator 3 3 * Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name> … … 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)); 91 setWindowModified(false); 92 } 89 93 #ifdef Q_OS_WINCE 90 94 taskView->resizeColumnsToContents(); … … 229 233 sd.setAcceptMode(QFileDialog::AcceptSave); 230 234 QStringList filters(trUtf8("HTML Files") + " (*.html *.htm)"); 235 #if QT_VERSION >= 0x040500 231 236 filters.append(trUtf8("OpenDocument Files") + " (*.odt)"); 237 #endif // QT_VERSION >= 0x040500 232 238 filters.append(trUtf8("All Files") + " (*)"); 233 239 sd.setNameFilters(filters); … … 239 245 return; 240 246 selectedFile = files.first(); 247 #if QT_VERSION >= 0x040500 241 248 QTextDocumentWriter dw(selectedFile); 242 249 if (!(selectedFile.endsWith(".htm",Qt::CaseInsensitive) || selectedFile.endsWith(".html",Qt::CaseInsensitive) || selectedFile.endsWith(".odt",Qt::CaseInsensitive) || selectedFile.endsWith(".txt",Qt::CaseInsensitive))) 243 250 dw.setFormat("plaintext"); 244 251 dw.write(solutionText->document()); 252 #else 253 // Qt < 4.5 has no QTextDocumentWriter class 254 QFile file(selectedFile); 255 if (!file.open(QFile::WriteOnly)) 256 return; 257 QTextStream ts(&file); 258 ts.setCodec(QTextCodec::codecForName("UTF-8")); 259 ts << solutionText->document()->toHtml("UTF-8"); 260 #endif // QT_VERSION >= 0x040500 245 261 } 246 262 … … 388 404 // TODO: Normal about window :-) 389 405 QString about = QString::fromUtf8("TSPSG - TSP Solver and Generator\n"); 390 about += QString::fromUtf8(" Version: "BUILD_VERSION" ("BUILD_STATUS")\n");406 about += QString::fromUtf8(" Version: "BUILD_VERSION"\n"); 391 407 about += QString::fromUtf8(" Copyright (C) 2007-%1 Lёppa <contacts[at]oleksii[dot]name>\n").arg(QDate::currentDate().toString("yyyy")); 392 408 about += QString::fromUtf8("Target OS: %1\n").arg(OS);
Note: See TracChangeset
for help on using the changeset viewer.