- fixed compilation on windows systems

Mon, 28 Jul 2014 03:34:05 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 28 Jul 2014 03:34:05 +0300
changeset 855
e16f1587ef44
parent 854
403affd33c6e
child 856
6bdc03091441

- fixed compilation on windows systems

CMakeLists.txt file | annotate | diff | comparison | revisions
codegen/CMakeLists.txt file | annotate | diff | comparison | revisions
src/colorSelector.cc file | annotate | diff | comparison | revisions
src/configDialog.cc file | annotate | diff | comparison | revisions
src/configuration.cc file | annotate | diff | comparison | revisions
src/configuration.h file | annotate | diff | comparison | revisions
src/crashCatcher.cc file | annotate | diff | comparison | revisions
src/extPrograms.cc file | annotate | diff | comparison | revisions
src/glCompiler.cc file | annotate | diff | comparison | revisions
src/glCompiler.h file | annotate | diff | comparison | revisions
src/glRenderer.cc file | annotate | diff | comparison | revisions
src/glRenderer.h file | annotate | diff | comparison | revisions
src/glShared.h file | annotate | diff | comparison | revisions
src/ldDocument.cc file | annotate | diff | comparison | revisions
src/ldObject.h file | annotate | diff | comparison | revisions
src/macros.h file | annotate | diff | comparison | revisions
src/partDownloader.cc file | annotate | diff | comparison | revisions
src/partDownloader.h file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Sun Jul 27 15:13:42 2014 +0300
+++ b/CMakeLists.txt	Mon Jul 28 03:34:05 2014 +0300
@@ -9,10 +9,21 @@
 add_subdirectory (updaterevision)
 add_subdirectory (codegen)
 cmake_minimum_required (VERSION 2.6)
-find_package (Qt4 REQUIRED)
-find_package (OpenGL REQUIRED)
 
 option (TRANSPARENT_DIRECT_COLORS "Enables non-standard transparent direct colors" OFF)
+option (USE_QT5 "Use Qt5 instead of Qt4" OFF)
+
+if (USE_QT5)
+	find_package (Qt5Widgets REQUIRED)
+	find_package (Qt5Core REQUIRED)
+	find_package (Qt5OpenGL REQUIRED)
+	find_package (Qt5Network REQUIRED)
+	set (CMAKE_AUTOMOC ON)
+else()
+	find_package (Qt4 REQUIRED)
+endif()
+
+find_package (OpenGL REQUIRED)
 
 get_target_property (UPDATEREVISION_EXE updaterevision LOCATION)
 get_target_property (CODEGEN_EXE codegen LOCATION)
@@ -126,8 +137,11 @@
 	DEPENDS codegen)
 
 set (LDFORGE_RESOURCES ldforge.qrc)
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -W -Wall")
-set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lGLU")
+# set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lGLU")
+
+if (NOT MSVC)
+	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -W -Wall")
+endif()
 
 if (TRANSPARENT_DIRECT_COLORS)
 	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTRANSPARENT_DIRECT_COLORS")
@@ -145,28 +159,35 @@
 include_directories ("${PROJECT_BINARY_DIR}/src")
 include_directories ("${PROJECT_BINARY_DIR}/src/misc")
 
-if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
-	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG")
+if (NOT MSVC)
+	if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
+		set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG")
+	endif()
 endif()
 
-qt4_wrap_cpp (LDFORGE_MOC ${LDFORGE_HEADERS})
-qt4_wrap_ui (LDFORGE_FORMS_HEADERS ${LDFORGE_FORMS})
-qt4_add_resources (LDFORGE_RCC ${LDFORGE_RESOURCES})
+if (USE_QT5)
+	qt5_generate_moc (LDFORGE_MOC ${LDFORGE_HEADERS})
+	qt5_add_resources (LDFORGE_QRC ${LDFORGE_RESOURCES})
+	qt5_wrap_ui (LDFORGE_FORMS_HEADERS ${LDFORGE_FORMS})
+	add_executable (ldforge ${LDFORGE_SOURCES} ${LDFORGE_MOC} ${LDFORGE_QRC} ${LDFORGE_FORMS_HEADERS})
+else()
+	qt4_wrap_cpp (LDFORGE_MOC ${LDFORGE_HEADERS})
+	qt4_wrap_ui (LDFORGE_FORMS_HEADERS ${LDFORGE_FORMS})
+	qt4_add_resources (LDFORGE_RCC ${LDFORGE_RESOURCES})
+	add_executable (ldforge ${LDFORGE_SOURCES} ${LDFORGE_RCC} ${LDFORGE_FORMS_HEADERS} ${LDFORGE_MOC})
+endif()
 
-add_executable (ldforge
-	${LDFORGE_SOURCES}
-	${LDFORGE_RCC}
-	${LDFORGE_FORMS_HEADERS}
-	${LDFORGE_MOC}
-)
-
-target_link_libraries (ldforge
-	${QT_QTCORE_LIBRARY}
-	${QT_QTGUI_LIBRARY}
-	${QT_QTNETWORK_LIBRARY}
-	${QT_QTOPENGL_LIBRARY}
-	${OPENGL_LIBRARIES}
-)
+if (USE_QT5)
+	target_link_libraries (ldforge Qt5::Widgets Qt5::Network Qt5::OpenGL ${OPENGL_LIBRARIES})
+else()
+	target_link_libraries (ldforge
+		${QT_QTCORE_LIBRARY}
+		${QT_QTGUI_LIBRARY}
+		${QT_QTNETWORK_LIBRARY}
+		${QT_QTOPENGL_LIBRARY}
+		${OPENGL_LIBRARIES}
+	)
+endif()
 
 add_dependencies (ldforge revision_check codegeneration)
 install (TARGETS ldforge RUNTIME DESTINATION bin)
--- a/codegen/CMakeLists.txt	Sun Jul 27 15:13:42 2014 +0300
+++ b/codegen/CMakeLists.txt	Mon Jul 28 03:34:05 2014 +0300
@@ -1,2 +1,10 @@
 cmake_minimum_required (VERSION 2.4)
 add_executable (codegen codegen.cpp)
+
+# 
+# LDForge uses alternative operators. GCC and Clang use these by default but MSVC does not.
+# So we'll have to tell MSVC to use these alternative operators
+# 
+if (MSVC)
+	set_target_properties (codegen PROPERTIES COMPILE_FLAGS "/Za")
+endif()
--- a/src/colorSelector.cc	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/colorSelector.cc	Mon Jul 28 03:34:05 2014 +0300
@@ -148,7 +148,7 @@
 	if (selection() == null)
 	{
 		ui->colorLabel->setText ("---");
-		ui->iconLabel->setPixmap (null);
+		ui->iconLabel->setPixmap (QPixmap());
 		ui->transparentDirectColor->setChecked (false);
 		return;
 	}
--- a/src/configDialog.cc	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/configDialog.cc	Mon Jul 28 03:34:05 2014 +0300
@@ -294,6 +294,7 @@
 			print ("Unknown widget of type %1\n", wdg->metaObject()->className());
 
 		conf->loadFromVariant (value);
+		print ("Value of %1: %2\n", conf->name(), conf->toVariant().toString());
 	});
 
 	// Rebuild the quick color toolbar
@@ -509,6 +510,7 @@
 		return;
 	}
 
+	print ("Color of %1 is %2\n", button, _buttonColors[button].name());
 	QColor col = QColorDialog::getColor (_buttonColors[button]);
 
 	if (col.isValid())
@@ -532,6 +534,7 @@
 	button->setAutoFillBackground (true);
 	button->setStyleSheet (format ("background-color: %1", value));
 	_buttonColors[button] = QColor (value);
+	print ("Color of %1 set to %2\n", button, value);
 }
 
 //
--- a/src/configuration.cc	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/configuration.cc	Mon Jul 28 03:34:05 2014 +0300
@@ -193,3 +193,38 @@
 IMPLEMENT_CONFIG (List)
 IMPLEMENT_CONFIG (KeySequence)
 IMPLEMENT_CONFIG (Vertex)
+
+void IntConfigEntry::loadFromVariant (const QVariant& val)
+{
+	*m_valueptr = val.toInt();
+}
+
+void StringConfigEntry::loadFromVariant (const QVariant& val)
+{
+	*m_valueptr = val.toString();
+}
+
+void BoolConfigEntry::loadFromVariant (const QVariant& val)
+{
+	*m_valueptr = val.toBool();
+}
+
+void ListConfigEntry::loadFromVariant (const QVariant& val)
+{
+	*m_valueptr = val.toList();
+}
+
+void KeySequenceConfigEntry::loadFromVariant (const QVariant& val)
+{
+	*m_valueptr = val.toString();
+}
+
+void FloatConfigEntry::loadFromVariant (const QVariant& val)
+{
+	*m_valueptr = val.toDouble();
+}
+
+void VertexConfigEntry::loadFromVariant (const QVariant& val)
+{
+	*m_valueptr = val.value<Vertex>();
+}
--- a/src/configuration.h	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/configuration.h	Mon Jul 28 03:34:05 2014 +0300
@@ -118,10 +118,7 @@
 		return *m_valueptr == m_default;											\
 	}																				\
 																					\
-	virtual void loadFromVariant (const QVariant& val)								\
-	{																				\
-		*m_valueptr = val.value<ValueType>();										\
-	}																				\
+	virtual void loadFromVariant (const QVariant& val);								\
 																					\
 	virtual QVariant toVariant() const												\
 	{																				\
--- a/src/crashCatcher.cc	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/crashCatcher.cc	Mon Jul 28 03:34:05 2014 +0300
@@ -16,17 +16,17 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifdef __unix__
-
 #include <QProcess>
 #include <QTemporaryFile>
 #include <unistd.h>
 #include <signal.h>
 #include "crashCatcher.h"
-
-#ifdef Q_OS_LINUX
-# include <sys/prctl.h>
-#endif
+#include "dialogs.h"
+ 
+#ifdef __unix__
+# ifdef Q_OS_LINUX
+#  include <sys/prctl.h>
+# endif
 
 // Is the crash catcher active now?
 static bool IsCrashCatcherActive = false;
--- a/src/extPrograms.cc	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/extPrograms.cc	Mon Jul 28 03:34:05 2014 +0300
@@ -68,7 +68,6 @@
 	&cfg::Edger2Path,
 };
 
-#ifndef _WIN32
 CFGENTRY (Bool, IsecalcUsesWine, false)
 CFGENTRY (Bool, IntersectorUsesWine, false)
 CFGENTRY (Bool, CovererUsesWine, false)
@@ -85,7 +84,6 @@
 	&cfg::RectifierUsesWine,
 	&cfg::Edger2UsesWine,
 };
-#endif // _WIN32
 
 const char* g_extProgNames[] =
 {
@@ -142,6 +140,8 @@
 #ifndef _WIN32
 			if (*g_extProgWine[prog])
 				wineblurb = "make sure Wine is installed and ";
+#else
+			(void) prog;
 #endif
 
 			return format ("Program failed to start, %1check your permissions", wineblurb);
--- a/src/glCompiler.cc	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/glCompiler.cc	Mon Jul 28 03:34:05 2014 +0300
@@ -90,6 +90,7 @@
 //
 void GLCompiler::initialize()
 {
+	initializeOpenGLFunctions();
 	glGenBuffers (g_numVBOs, &m_vbo[0]);
 	checkGLError();
 }
--- a/src/glCompiler.h	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/glCompiler.h	Mon Jul 28 03:34:05 2014 +0300
@@ -24,7 +24,11 @@
 
 // =============================================================================
 //
+#ifdef USE_QT5
+class GLCompiler : protected QOpenGLFunctions
+#else
 class GLCompiler
+#endif
 {
 public:
 	struct ObjectVBOInfo
--- a/src/glRenderer.cc	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/glRenderer.cc	Mon Jul 28 03:34:05 2014 +0300
@@ -97,6 +97,7 @@
 
 static GLuint g_GLAxes_VBO;
 static GLuint g_GLAxes_ColorVBO;
+static bool RendererInitialized (false);
 
 // =============================================================================
 //
@@ -236,6 +237,7 @@
 //
 void GLRenderer::initializeGL()
 {
+	initializeOpenGLFunctions();
 	setBackground();
 	glLineWidth (cfg::LineThickness);
 	glLineStipple (1, 0x6666);
@@ -244,6 +246,7 @@
 	setFocusPolicy (Qt::WheelFocus);
 	compiler()->initialize();
 	initializeAxes();
+	RendererInitialized = true;
 }
 
 // =============================================================================
@@ -319,16 +322,20 @@
 void GLRenderer::refresh()
 {
 	update();
-	swapBuffers();
+
+	if (isVisible())
+		swapBuffers();
 }
 
 // =============================================================================
 //
 void GLRenderer::hardRefresh()
 {
+	if (not RendererInitialized)
+		return;
+
 	compiler()->compileDocument (getCurrentDocument());
 	refresh();
-	glLineWidth (cfg::LineThickness); // TODO: ...?
 }
 
 // =============================================================================
@@ -541,7 +548,7 @@
 // Inverse operation for the above - convert a 3D position to a 2D screen
 // position. Don't ask me how this code manages to work, I don't even know.
 //
-QPoint GLRenderer::coordconv3_2 (const Vertex& pos3d) const
+QPoint GLRenderer::coordconv3_2 (const Vertex& pos3d)
 {
 	GLfloat m[16];
 	const LDFixedCamera* cam = &g_FixedCameras[camera()];
@@ -584,7 +591,7 @@
 //
 void GLRenderer::paintEvent (QPaintEvent*)
 {
-	makeCurrent();
+	doMakeCurrent();
 	m_virtWidth = zoom();
 	m_virtHeight = (m_height * m_virtWidth) / m_width;
 	initGLData();
@@ -841,7 +848,7 @@
 //
 void GLRenderer::wheelEvent (QWheelEvent* ev)
 {
-	makeCurrent();
+	doMakeCurrent();
 
 	zoomNotch (ev->delta() > 0);
 	zoom() = clamp (zoom(), 0.01, 10000.0);
@@ -891,7 +898,7 @@
 //
 void GLRenderer::pick (QRect const& range, bool additive)
 {
-	makeCurrent();
+	doMakeCurrent();
 
 	// Clear the selection if we do not wish to add to it.
 	if (not additive)
@@ -989,7 +996,7 @@
 LDObjectPtr GLRenderer::pickOneObject (int mouseX, int mouseY)
 {
 	uchar pixel[4];
-	makeCurrent();
+	doMakeCurrent();
 	setPicking (true);
 	drawGLScene();
 	glReadPixels (mouseX, m_height - mouseY, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
@@ -1610,3 +1617,12 @@
 {
 	return m_mousePosition;
 }
+
+void GLRenderer::doMakeCurrent()
+{
+	makeCurrent();
+
+#ifdef USE_QT5
+	initializeOpenGLFunctions();
+#endif
+}
--- a/src/glRenderer.h	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/glRenderer.h	Mon Jul 28 03:34:05 2014 +0300
@@ -135,7 +135,11 @@
 // and selection picking. The instance of GLRenderer is accessible as
 // g_win->R()
 //
+#ifdef USE_QT5
+class GLRenderer : public QGLWidget, protected QOpenGLFunctions
+#else
 class GLRenderer : public QGLWidget
+#endif
 {
 public:
 	Q_OBJECT
@@ -155,7 +159,7 @@
 	void					clearOverlay();
 	void					compileObject (LDObjectPtr obj);
 	Vertex					coordconv2_3 (const QPoint& pos2d, bool snap) const;
-	QPoint					coordconv3_2 (const Vertex& pos3d) const;
+	QPoint					coordconv3_2 (const Vertex& pos3d);
 	EditModeType			currentEditModeType() const;
 	void					drawBlip (QPainter& paint, QPoint pos) const;
 	void					drawGLScene();
@@ -238,6 +242,7 @@
 	void					clampAngle (double& angle) const;
 	inline LDGLData&		currentDocumentData() const;
 	void					drawVBOs (EVBOSurface surface, EVBOComplement colors, GLenum type);
+	void					doMakeCurrent();
 	LDOverlayPtr			findOverlayObject (ECamera cam);
 	inline double&			pan (Axis ax);
 	inline const double&	pan (Axis ax) const;
--- a/src/glShared.h	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/glShared.h	Mon Jul 28 03:34:05 2014 +0300
@@ -17,6 +17,7 @@
  */
 
 #pragma once
+#include <QOpenGLFunctions>
 #include "basics.h"
 
 class LDObject;
--- a/src/ldDocument.cc	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/ldDocument.cc	Mon Jul 28 03:34:05 2014 +0300
@@ -1117,7 +1117,7 @@
 		dprint ("Added object #%1 (%2)\n", obj->id(), obj->typeName());
 #endif
 
-	obj->setDocument (this);
+	obj->setDocument (self());
 	g_win->R()->compileObject (obj);
 	return getObjectCount() - 1;
 }
@@ -1139,7 +1139,7 @@
 {
 	history()->add (new AddHistory (pos, obj));
 	m_objects.insert (pos, obj);
-	obj->setDocument (this);
+	obj->setDocument (self());
 	g_win->R()->compileObject (obj);
 	
 
@@ -1212,7 +1212,7 @@
 	_objectVertices.remove (m_objects[idx]);
 	m_objects[idx]->deselect();
 	m_objects[idx]->setDocument (LDDocumentPtr());
-	obj->setDocument (this);
+	obj->setDocument (self());
 	addKnownVertices (obj);
 	g_win->R()->compileObject (obj);
 	m_objects[idx] = obj;
--- a/src/ldObject.h	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/ldObject.h	Mon Jul 28 03:34:05 2014 +0300
@@ -29,13 +29,10 @@
 	{															\
 		return OBJ_##T;											\
 	}															\
-	virtual QString asText() const override;						\
+	virtual QString asText() const override;					\
 	virtual void invert() override;								\
 																\
 	LD##T (LDObjectPtr* selfptr);								\
-																\
-protected:														\
-	friend class QSharedPointer<LD##T>::ExternalRefCount;		\
 
 #define LDOBJ_NAME(N)          public: virtual QString typeName() const override { return #N; }
 #define LDOBJ_VERTICES(V)      public: virtual int numVertices() const override { return V; }
@@ -200,25 +197,18 @@
 	// have to be the friend. Do not call this! Ever!
 	void finalDelete();
 
-protected:
-	// LDObjects are to be deleted with the finalDelete() method, not with
-	// operator delete. This is because it seems virtual functions cannot
-	// be properly called from the destructor, thus a normal method must
-	// be used instead. The destructor also doesn't seem to be able to
-	// be private without causing a truckload of problems so it's protected
-	// instead.
-	virtual ~LDObject();
-	void chooseID();
-
 	// Even though we supply a custom deleter to QSharedPointer, the shared
 	// pointer's base class still calls operator delete directly in one of
 	// its methods. The method should never be called but we need to declare
 	// the class making this delete call a friend anyway.
-	friend class QSharedPointer<LDObject>;
-	friend class QSharedPointer<LDObject>::ExternalRefCount;
+	//
+	// Do not directly delete LDObjects. Ever.
+	virtual ~LDObject();
 
 private:
 	Vertex m_coords[4];
+
+	void chooseID();
 };
 
 //
--- a/src/macros.h	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/macros.h	Mon Jul 28 03:34:05 2014 +0300
@@ -115,6 +115,11 @@
 	inline T operator++ (T& a, int) { T result = a; a = (T) ((int) a + 1); return result; } \
 	inline T operator-- (T& a, int) { T result = a; a = (T) ((int) a - 1); return result; }
 
+#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
+# define USE_QT5
+#endif
+
+
 #define FOR_ENUM_NAME_HELPER(LINE) enum_iterator_ ## LINE
 #define FOR_ENUM_NAME(LINE) FOR_ENUM_NAME_HELPER(LINE)
 
--- a/src/partDownloader.cc	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/partDownloader.cc	Mon Jul 28 03:34:05 2014 +0300
@@ -71,18 +71,23 @@
 //
 PartDownloader::PartDownloader (QWidget* parent) : QDialog (parent)
 {
-	setInterface (new Ui_DownloadFrom);
-	interface()->setupUi (this);
-	interface()->fname->setFocus();
-	interface()->progress->horizontalHeader()->setResizeMode (PartLabelColumn, QHeaderView::Stretch);
+	setForm (new Ui_DownloadFrom);
+	form()->setupUi (this);
+	form()->fname->setFocus();
+
+#ifdef USE_QT5
+	form()->progress->horizontalHeader()->setSectionResizeMode (QHeaderView::Stretch);
+#else
+	form()->progress->horizontalHeader()->setResizeMode (PartLabelColumn, QHeaderView::Stretch);
+#endif
 
 	setDownloadButton (new QPushButton (tr ("Download")));
-	interface()->buttonBox->addButton (downloadButton(), QDialogButtonBox::ActionRole);
+	form()->buttonBox->addButton (downloadButton(), QDialogButtonBox::ActionRole);
 	getButton (Abort)->setEnabled (false);
 
-	connect (interface()->source, SIGNAL (currentIndexChanged (int)),
+	connect (form()->source, SIGNAL (currentIndexChanged (int)),
 		this, SLOT (sourceChanged (int)));
-	connect (interface()->buttonBox, SIGNAL (clicked (QAbstractButton*)),
+	connect (form()->buttonBox, SIGNAL (clicked (QAbstractButton*)),
 		this, SLOT (buttonClicked (QAbstractButton*)));
 }
 
@@ -90,7 +95,7 @@
 //
 PartDownloader::~PartDownloader()
 {
-	delete interface();
+	delete form();
 }
 
 // =============================================================================
@@ -103,13 +108,13 @@
 	switch (src)
 	{
 		case PartsTracker:
-			dest = interface()->fname->text();
+			dest = form()->fname->text();
 			modifyDestination (dest);
-			interface()->fname->setText (dest);
+			form()->fname->setText (dest);
 			return g_unofficialLibraryURL + dest;
 
 		case CustomURL:
-			return interface()->fname->text();
+			return form()->fname->text();
 	}
 
 	// Shouldn't happen
@@ -183,7 +188,7 @@
 //
 PartDownloader::Source PartDownloader::getSource() const
 {
-	return (Source) interface()->source->currentIndex();
+	return (Source) form()->source->currentIndex();
 }
 
 // =============================================================================
@@ -191,9 +196,9 @@
 void PartDownloader::sourceChanged (int i)
 {
 	if (i == CustomURL)
-		interface()->fileNameLabel->setText (tr ("URL:"));
+		form()->fileNameLabel->setText (tr ("URL:"));
 	else
-		interface()->fileNameLabel->setText (tr ("File name:"));
+		form()->fileNameLabel->setText (tr ("File name:"));
 }
 
 // =============================================================================
@@ -213,7 +218,7 @@
 	}
 	elif (btn == getButton (Download))
 	{
-		QString dest = interface()->fname->text();
+		QString dest = form()->fname->text();
 		setPrimaryFile (LDDocumentPtr());
 		setAborted (false);
 
@@ -230,9 +235,9 @@
 		}
 
 		downloadButton()->setEnabled (false);
-		interface()->progress->setEnabled (true);
-		interface()->fname->setEnabled (false);
-		interface()->source->setEnabled (false);
+		form()->progress->setEnabled (true);
+		form()->fname->setEnabled (false);
+		form()->source->setEnabled (false);
 		downloadFile (dest, getURL(), true);
 		getButton (Close)->setEnabled (false);
 		getButton (Abort)->setEnabled (true);
@@ -244,7 +249,7 @@
 //
 void PartDownloader::downloadFile (QString dest, QString url, bool primary)
 {
-	const int row = interface()->progress->rowCount();
+	const int row = form()->progress->rowCount();
 
 	// Don't download files repeadetly.
 	if (filesToDownload().indexOf (dest) != -1)
@@ -254,7 +259,7 @@
 	PartDownloadRequest* req = new PartDownloadRequest (url, dest, primary, this);
 	m_filesToDownload << dest;
 	m_requests << req;
-	interface()->progress->insertRow (row);
+	form()->progress->insertRow (row);
 	req->setTableRow (row);
 	req->updateToTable();
 }
@@ -312,10 +317,10 @@
 			return downloadButton();
 
 		case Abort:
-			return qobject_cast<QPushButton*> (interface()->buttonBox->button (QDialogButtonBox::Abort));
+			return qobject_cast<QPushButton*> (form()->buttonBox->button (QDialogButtonBox::Abort));
 
 		case Close:
-			return qobject_cast<QPushButton*> (interface()->buttonBox->button (QDialogButtonBox::Close));
+			return qobject_cast<QPushButton*> (form()->buttonBox->button (QDialogButtonBox::Close));
 	}
 
 	return null;
@@ -365,7 +370,7 @@
 {
 	int const labelcol = PartDownloader::PartLabelColumn;
 	int const progcol = PartDownloader::ProgressColumn;
-	QTableWidget* table = prompt()->interface()->progress;
+	QTableWidget* table = prompt()->form()->progress;
 	QProgressBar* prog;
 
 	switch (state())
--- a/src/partDownloader.h	Sun Jul 27 15:13:42 2014 +0300
+++ b/src/partDownloader.h	Mon Jul 28 03:34:05 2014 +0300
@@ -60,7 +60,7 @@
 	Q_OBJECT
 	PROPERTY (public,	LDDocumentPtr, 		primaryFile,		setPrimaryFile,		STOCK_WRITE)
 	PROPERTY (public,	bool,				isAborted,			setAborted,			STOCK_WRITE)
-	PROPERTY (private,	Ui_DownloadFrom*,	interface,			setInterface,		STOCK_WRITE)
+	PROPERTY (private,	Ui_DownloadFrom*,	form,				setForm,			STOCK_WRITE)
 	PROPERTY (private,	QStringList,		filesToDownload,	setFilesToDownload,	STOCK_WRITE)
 	PROPERTY (private,	RequestList,		requests,			setRequests,		STOCK_WRITE)
 	PROPERTY (private,	QPushButton*,		downloadButton,		setDownloadButton,	STOCK_WRITE)

mercurial