made it compile on windows/qt5

Sun, 11 Aug 2013 03:47:58 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 11 Aug 2013 03:47:58 +0300
changeset 15
3d3e5f0fc4cc
parent 14
825d9ed1ee01
child 16
a8c78391e414

made it compile on windows/qt5

src/bytestream.cpp file | annotate | diff | comparison | revisions
src/config.cpp file | annotate | diff | comparison | revisions
src/config.h file | annotate | diff | comparison | revisions
src/demo.cpp file | annotate | diff | comparison | revisions
src/src.pro file | annotate | diff | comparison | revisions
--- a/src/bytestream.cpp	Sun Aug 11 03:08:14 2013 +0300
+++ b/src/bytestream.cpp	Sun Aug 11 03:47:58 2013 +0300
@@ -210,8 +210,12 @@
 void Bytestream::writeString (str val) {
 	growToFit (val.length() + 1);
 
-for (qchar c : val)
+	for (qchar c : val)
+#if (QT_VERSION >= QT_VERSION_CHECK (5, 0, 0))
+		doWrite (c.toLatin1());
+#else
 		doWrite (c.toAscii());
+#endif // QT_VERSION
 
 	doWrite ('\0');
 }
--- a/src/config.cpp	Sun Aug 11 03:08:14 2013 +0300
+++ b/src/config.cpp	Sun Aug 11 03:47:58 2013 +0300
@@ -21,10 +21,6 @@
 #include <QFormLayout>
 #include <QProgressBar>
 #include <QMessageBox>
-#include <QUrl>
-#include <QNetworkAccessManager>
-#include <QNetworkRequest>
-#include <QNetworkReply>
 #include "config.h"
 #include "ui_configbox.h"
 #include "misc.h"
@@ -52,8 +48,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-ConfigBox::ConfigBox (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f),
-	m_nam (new QNetworkAccessManager (this)) {
+ConfigBox::ConfigBox (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
 	ui = new Ui_ConfigBox;
 	ui->setupUi (this);
 	ui->updateProgress->hide();
--- a/src/config.h	Sun Aug 11 03:08:14 2013 +0300
+++ b/src/config.h	Sun Aug 11 03:47:58 2013 +0300
@@ -54,8 +54,6 @@
 private:
 	Ui_ConfigBox* ui;
 	list<QLineEdit*> m_zanBinaries;
-	QNetworkAccessManager* m_nam;
-	QNetworkReply* m_reply;
 };
 
 #endif // CONFIG_H
\ No newline at end of file
--- a/src/demo.cpp	Sun Aug 11 03:08:14 2013 +0300
+++ b/src/demo.cpp	Sun Aug 11 03:47:58 2013 +0300
@@ -38,7 +38,12 @@
 		if (skip-- > 0)
 			continue;
 		
-		if (c.toAscii() == '\034') {
+#if (QT_VERSION >= QT_VERSION_CHECK (5, 0, 0))
+		if (c.toLatin1() == '\034')
+#else
+		if (c.toAscii() == '\034')
+#endif // QT_VERSION
+		{
 			skip = 1;
 			continue;
 		}
@@ -101,8 +106,14 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
+#ifdef _WIN32
+# define FILE_FLAGS "rb"
+#else
+# define FILE_FLAGS "r"
+#endif // _WIN32
+
 int launchDemo (str path) {
-	FILE* fp = fopen (path.toStdString().c_str(), "r");
+	FILE* fp = fopen (path.toStdString().c_str(), FILE_FLAGS);
 	
 	if (!fp) {
 		error (fmt (tr ("Couldn't open '%1' for reading: %2"), path, strerror (errno)));
@@ -115,8 +126,9 @@
 	
 	char* buf = new char[fsize];
 	
-	if (fread (buf, 1, fsize, fp) != fsize) {
-		error (tr ("I/O error"));
+	const size_t bytesRead = fread (buf, 1, fsize, fp);
+	if (bytesRead != fsize) {
+		error (fmt (tr ("I/O error: %1 / %2 bytes read"), bytesRead, fsize));
 		delete[] buf;
 		return 2;
 	}
--- a/src/src.pro	Sun Aug 11 03:08:14 2013 +0300
+++ b/src/src.pro	Sun Aug 11 03:47:58 2013 +0300
@@ -9,6 +9,6 @@
 RCC_DIR         = ./build/
 SOURCES         = *.cpp
 HEADERS         = *.h
-QT             += network
+QT             += widgets
 FORMS           = ui/*.ui
 QMAKE_CXXFLAGS += -std=c++0x
\ No newline at end of file

mercurial