Legend:
- Unmodified
- Added
- Removed
-
trunk/src/globals.h
r107 r108 32 32 #include <QtCore> 33 33 #include <QtGui> 34 #include <QtSvg> 34 35 35 36 // Version info -
trunk/src/main.cpp
r99 r108 34 34 35 35 #ifdef STATIC_BUILD 36 //Q_IMPORT_PLUGIN(qjpeg)37 //Q_IMPORT_PLUGIN(qsvg)36 Q_IMPORT_PLUGIN(qjpeg) 37 Q_IMPORT_PLUGIN(qsvg) 38 38 #endif 39 39 -
trunk/src/mainwindow.cpp
r107 r108 218 218 } 219 219 #endif 220 if (selectedFile.endsWith(".htm", Qt::CaseInsensitive) || selectedFile.endsWith(".html", Qt::CaseInsensitive)) { 221 QFile file(selectedFile); 222 if (!file.open(QFile::WriteOnly)) { 223 QApplication::restoreOverrideCursor(); 224 QMessageBox::critical(this, tr("Solution Save"), tr("Unable to save the solution.\nError: %1").arg(file.errorString())); 225 return; 226 } 227 QFileInfo fi(selectedFile); 228 QString html = solutionText->document()->toHtml("UTF-8"), 229 img = fi.completeBaseName() + ".svg"; 230 html.replace(QRegExp("<img\\s+src=\"tspsg://graph.pic\""), QString("<img src=\"%1\" width=\"%2\" height=\"%3\" alt=\"%4\"").arg(img).arg(graph.width() + 1).arg(graph.height() + 1).arg(tr("Solution Graph"))); 231 // Saving solution text as HTML 232 QTextStream ts(&file); 233 ts.setCodec(QTextCodec::codecForName("UTF-8")); 234 ts << html; 235 file.close(); 236 // Saving solution graph as SVG 237 QSvgGenerator svg; 238 svg.setFileName(fi.path() + "/" + img); 239 svg.setTitle(tr("Solution Graph")); 240 QPainter p; 241 p.begin(&svg); 242 graph.play(&p); 243 p.end(); 244 245 // Qt < 4.5 has no QTextDocumentWriter class 220 246 #if QT_VERSION >= 0x040500 247 } else { 221 248 QTextDocumentWriter dw(selectedFile); 222 if (!(selectedFile.endsWith(".htm",Qt::CaseInsensitive) || selectedFile.endsWith(".html",Qt::CaseInsensitive) || selectedFile.endsWith(".odt",Qt::CaseInsensitive) || selectedFile.endsWith(".txt",Qt::CaseInsensitive))) 223 dw.setFormat("plaintext"); 224 if (!dw.write(solutionText->document())) 225 QMessageBox::critical(this, tr("Solution Save"), tr("Unable to save the solution.\nError: %1").arg(dw.device()->errorString())); 226 #else // QT_VERSION >= 0x040500 227 // Qt < 4.5 has no QTextDocumentWriter class 228 QFile file(selectedFile); 229 if (!file.open(QFile::WriteOnly)) { 230 QApplication::restoreOverrideCursor(); 231 QMessageBox::critical(this, tr("Solution Save"), tr("Unable to save the solution.\nError: %1").arg(file->errorString())); 232 return; 233 } 234 QTextStream ts(&file); 235 ts.setCodec(QTextCodec::codecForName("UTF-8")); 236 ts << solutionText->document()->toHtml("UTF-8"); 237 file.close(); 249 if (!selectedFile.endsWith(".odt",Qt::CaseInsensitive)) 250 dw.setFormat("plaintext"); 251 if (!dw.write(solutionText->document())) 252 QMessageBox::critical(this, tr("Solution Save"), tr("Unable to save the solution.\nError: %1").arg(dw.device()->errorString())); 238 253 #endif // QT_VERSION >= 0x040500 254 } 239 255 QApplication::restoreOverrideCursor(); 240 256 }
Note: See TracChangeset
for help on using the changeset viewer.