Skip to content

Commit

Permalink
first upload of the entire project
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertKrajewski committed Nov 25, 2011
1 parent 0514c02 commit d89f089
Show file tree
Hide file tree
Showing 40 changed files with 3,981 additions and 0 deletions.
Binary file added 25_folder.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions Icons.qrc
@@ -0,0 +1,22 @@
<RCC>
<qresource prefix="/icons">
<file>block.png</file>
<file>cupboard.png</file>
<file>download.png</file>
<file>gear.png</file>
<file>gears.png</file>
<file>lock.png</file>
<file>magnifier.png</file>
<file>refresh.png</file>
<file>tick.png</file>
<file alias="directory">advanced_directory.png</file>
<file>file.png</file>
<file>filetype_pdf.png</file>
<file>filetype_rar.png</file>
<file>filetype_zip.png</file>
<file>25_folder.png</file>
<file>library.png</file>
<file>library_32x32.ico</file>
<file alias="drive">drive.png</file>
</qresource>
</RCC>
Binary file added Sync-my-L2P.icns
Binary file not shown.
89 changes: 89 additions & 0 deletions Sync-my-L2P.pro
@@ -0,0 +1,89 @@
QT += gui core network
SOURCES += \
main.cpp \
hauptfenster.cpp \
strukturelement.cpp \
datei.cpp \
logintester.cpp \
dateidownloader.cpp \
mysortfilterproxymodel.cpp

HEADERS += \
hauptfenster.h \
strukturelement.h \
datei.h \
logintester.h \
dateidownloader.h \
mysortfilterproxymodel.h

FORMS += \
hauptfenster.ui \
logintester.ui \
dateidownloader.ui \
syncfinisheddialog.ui

RESOURCES += \
Icons.qrc

RC_FILE += \
../Sync-my-L2P/icon.rc

ICON = Sync-my-L2P.icns


























































Binary file added advanced_directory.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cupboard.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions datei.cpp
@@ -0,0 +1,24 @@
#include "datei.h"

Datei::Datei(QString name, QUrl url, QDateTime zeit, qint32 groesse)
:Strukturelement(name, url, fileItem), zeit(zeit)
{
this->size = groesse;
}

Datei::Datei(QString name, QUrl url, QString zeit, qint32 groesse)
: Strukturelement(name, url, fileItem), zeit(QDateTime::fromString(zeit, Qt::ISODate))
{
this->size = groesse;
}

QDateTime Datei::GetZeit() const
{
return zeit;
}


qint32 Datei::getSize() const
{
return size;
}
18 changes: 18 additions & 0 deletions datei.h
@@ -0,0 +1,18 @@
#ifndef DATEI_H
#define DATEI_H
#include <strukturelement.h>


class Datei : public Strukturelement
{
public:
Datei(QString name, QUrl url, QDateTime zeit, qint32 size);
Datei(QString name, QUrl url, QString zeit, qint32 size);
QDateTime GetZeit() const;
qint32 getSize() const;

private:
QDateTime zeit;
};

#endif // DATEI_H
133 changes: 133 additions & 0 deletions dateidownloader.cpp
@@ -0,0 +1,133 @@
#include "dateidownloader.h"
#include "ui_dateidownloader.h"

DateiDownloader::DateiDownloader(QString benutzername,
QString passwort,
int anzahlItems,
QWidget *parent) :
QDialog(parent, Qt::FramelessWindowHint),
ui(new Ui::DateiDownloader),
benutzername(benutzername),
passwort(passwort),
anzahlItems(anzahlItems)
{
ui->setupUi(this);
manager = new QNetworkAccessManager(this);

QObject::connect(manager, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*))
, this, SLOT(authenticate(QNetworkReply*, QAuthenticator*)));
this->show();

// Zentrieren des Fensters
QRect desktopRect = parentWidget()->frameGeometry();
QRect windowRect = this->frameGeometry();
move((desktopRect.width()-windowRect.width())/2+desktopRect.x(), (desktopRect.height()-windowRect.height())/2+desktopRect.y());
}

DateiDownloader::~DateiDownloader()
{
delete ui;
}

void DateiDownloader::authenticate(QNetworkReply* , QAuthenticator* authenticator)
{
authenticator->setUser(benutzername);
authenticator->setPassword(passwort);
}

int DateiDownloader::startNextDownload(QString dateiname, QString veranstaltung, QString verzeichnisPfad, QUrl url, int itemNummer)
{
// Anpassen der Labels
ui->progressLabel->setText(QString("Datei %1/%2").arg(itemNummer).arg(anzahlItems));
ui->veranstaltungLabel->setText(veranstaltung);
ui->dateinameLabel->setText(dateiname);

// Erstellen des Outputstreams
output.setFileName(verzeichnisPfad);

// Öffnen des Outputstreams
if(!output.open(QIODevice::WriteOnly))
{
QMessageBox messageBox;
messageBox.setText("Fehler beim Öffnen mit Schreibberechtigung.");
messageBox.setInformativeText(dateiname);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
return 0;
}

// Start des Requests
reply = manager->get(QNetworkRequest(url));
QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgressSlot(qint64,qint64)));
QObject::connect(reply, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
QObject::connect(reply, SIGNAL(finished()), this, SLOT(finishedSlot()));

// Schleife, die läuft, bis der Download abgeschlossen ist
return(loop.exec());
}

void DateiDownloader::downloadProgressSlot(qint64 bytesReceived, qint64 bytesTotal)
{
if(bytesTotal)
{
ui->progressBar->setMaximum(bytesTotal);
ui->progressBar->setValue(bytesReceived);

}
else
{
ui->progressBar->setMaximum(0);
ui->progressBar->setValue(0);
}
}

void DateiDownloader::readyReadSlot()
{
if (output.write(reply->readAll()) == -1)
{
QMessageBox messageBox;
messageBox.setText("Beim Schreiben einer Datei auf die Fesplatte ist ein Fehler aufgetreten.");
messageBox.setInformativeText(ui->dateinameLabel->text());
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
reply->abort();
}
}

void DateiDownloader::finishedSlot()
{
output.flush();
output.close();

QObject::disconnect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgressSlot(qint64,qint64)));
QObject::disconnect(reply, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
QObject::disconnect(reply, SIGNAL(finished()), this, SLOT(finishedSlot()));

reply->deleteLater();

if(reply->error())
{
QMessageBox messageBox;
messageBox.setText("Beim Download einer Datei ist ein Fehler aufgetreten.");
messageBox.setInformativeText(ui->dateinameLabel->text());
messageBox.setDetailedText(reply->errorString());
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
output.remove();
loop.exit(0);
}
else
loop.exit(1);
}

void DateiDownloader::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_Escape)
{
event->accept();
reply->abort();
}
else
event->ignore();
}

56 changes: 56 additions & 0 deletions dateidownloader.h
@@ -0,0 +1,56 @@
#ifndef DATEIDOWNLOADER_H
#define DATEIDOWNLOADER_H

#include <QDialog>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QUrl>
#include <QAuthenticator>
#include <QTimer>
#include <QEventLoop>
#include <QStringBuilder>
#include <QFile>
#include <QMessageBox>
#include <QCloseEvent>

namespace Ui {
class DateiDownloader;
}

class DateiDownloader : public QDialog
{
Q_OBJECT

public:
explicit DateiDownloader(QString benutzername,
QString passwort,
int anzahlItems,
QWidget *parent= 0);
~DateiDownloader();
int startNextDownload(QString, QString, QString, QUrl, int);

private:

void keyPressEvent(QKeyEvent *);
Ui::DateiDownloader *ui;
QNetworkAccessManager* manager;
QNetworkReply* reply;

QEventLoop loop;

QString benutzername;
QString passwort;

int anzahlItems;

QFile output;

private slots:
void authenticate(QNetworkReply*, QAuthenticator*);
void downloadProgressSlot(qint64,qint64);
void readyReadSlot();
void finishedSlot();
};

#endif // DATEIDOWNLOADER_H

0 comments on commit d89f089

Please sign in to comment.