mainwindow.h 3.53 KB
Newer Older
mbriand's avatar
mbriand committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
/*

	UBPT Transfert 2

	Copyright (C) 2005 Julien Etelain. Tous droits réservés..
	Copyright (C) 2011 Mathieu Briand.

    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 2
	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, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "ui_main.h"

#include <QTime>
#include <QDomDocument>

#include "protocol.h"
#include "uploadthread.h"

typedef struct transfertItem
{
	public:

	QString name;
	QString fileName;
	QString contextName;
	int contextId;
	int rights;
	QString group;
    int photographerUserId;
    QString club;
    QString licence;
    QString comment;

	enum itemType { Photo, Video };

	itemType type;

} transfertItem;

class transfertTreeItem : public QTreeWidgetItem
{
	public:
	transfertTreeItem( QString Name, QString FileName, QString ContextName, int ContextId,int Rights, QString Group, int photographerUserId, QString Club, QString Licence, QString comment, QTreeWidget *parent, transfertItem::itemType t = transfertItem::Photo  );
	transfertTreeItem( transfertItem transfert, QTreeWidget *parent );

	transfertItem transfert;

	enum transfertState { ToDo, Encoding, Transfert, Sucess, Error };

	transfertState state;
	int UBPTError;


};

class MainWindow : public QMainWindow
{
	Q_OBJECT

public:
	MainWindow(QWidget *parent = 0);
	UbptSession session;
	void switchMode ( int Mode );

	void addFileToQueue ( const QString & name, const QString & fileName, const QString & contextName, int contextId, int rights, const QString & group, int photographerUserId, QString club, QString licence, QString comment );
	void addVideoFileToQueue ( const QString & name, const QString & fileName, const QString & contextName, int contextId, int rights, const QString & group, int photographerUserId, QString club, QString licence, QString comment );
	Ui::MainWindow ui;

protected:
  void closeEvent(QCloseEvent *event);

public slots:
	void about();
	void openAdd();
	void openConnect();
	void processPhotos();
	void stopPhotos();
  void uploaded(transfertTreeItem *Item);
  void progress(transfertTreeItem *Item, int precent);
	void resetStatesAndRemoveDone();
	void removeAll();
	void removeSelection();

private:
  void createActions();
  void createMenus();
	void createToolBars();
	void writeList();

	void readList();
	void readElement( const QDomElement &element );

    QAction *aboutAct;
    QAction *exitAct;
    QAction *connectAct;
    QAction *addAct;
    QAction *processAct;
    QAction *stopAct;
    QAction *cleanupResetAct;
    QAction *removeAllAct;
    QAction *removeSelectionAct;

    QMenu *fileMenu;
    QMenu *photosMenu;
    QMenu *helpMenu;

    QToolBar *fileToolBar;
    QToolBar *photosToolBar;

    QTreeWidgetItem *rootItem;

	void uploadItem (transfertTreeItem *Item );
	void nextItem ();
	bool stop;

	QTime listTime;
	QTime itemTime;
	int itemsDone;

	void refreshRemaingInfo ();
	int countRemainingItems ();
    UploadThread upthread;
};

#define MODE_CONNECT 0
#define MODE_SELECT 1
#define MODE_TRANSFERT 2


#endif