src/partdownloader.h

Tue, 13 Feb 2018 14:56:08 +0200

author
Santeri Piippo
date
Tue, 13 Feb 2018 14:56:08 +0200
changeset 1242
725cb1084044
parent 1145
02264bf0108d
child 1326
69a90bd2dba2
permissions
-rw-r--r--

Removed LDConditionalEdge::becomeEdgeLine

/*
 *  LDForge: LDraw parts authoring CAD
 *  Copyright (C) 2013 - 2017 Teemu Piippo
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once
#include <QDialog>
#include "main.h"
#include "basics.h"
#include "lddocument.h"

class LDDocument;
class QFile;
class PartDownloadRequest;
class Ui_PartDownloader;
class QNetworkAccessManager;
class QNetworkRequest;
class QNetworkReply;
class QAbstractButton;
class QTableWidget;

class PartDownloader : public QDialog, public HierarchyElement
{
	Q_OBJECT

public:
	enum SourceType
	{
		PartsTracker,
		CustomURL,
	};

	enum Button
	{
		Download,
		Abort,
		Close
	};

	enum TableColumn
	{
		PartLabelColumn,
		ProgressColumn,
	};

	explicit PartDownloader(QWidget* parent = nullptr);
	virtual ~PartDownloader();

	void addFile(LDDocument* file);
	QAbstractButton *button(Button which);
	void checkValidPath();
	void downloadFile (QString dest, QString url, bool isPrimary);
	void downloadFromPartsTracker (QString file);
	QString downloadPath();
	bool isAborted() const;
	void modifyDestination (QString& dest) const;
	LDDocument* primaryFile() const;
	QTableWidget* progressTable() const;
	void setPrimaryFile (LDDocument* document);
	void setSourceType (SourceType src);
	SourceType sourceType() const;
	QString url();

public slots:
	void buttonClicked (QAbstractButton* btn);
	void checkIfFinished();
	void sourceChanged (int i);


signals:
	void primaryFileDownloaded();

private:
	Ui_PartDownloader& _ui;
	QStringList _filesToDownload;
	QVector<PartDownloadRequest*> _requests;
	QPushButton* _downloadButton;
	SourceType _source;
	QVector<LDDocument*> _files;
	LDDocument* _primaryFile;
	bool _isAborted;
};

mercurial