#include "mainwindow.h"

#include <QApplication>
#include <QDir>
#include <QIODevice>
#include <kzip.h>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QString file = "c:/temp/datlog01.zip";
    KZip archive(file);

    // Open the archive
    if (!archive.open(QIODevice::ReadOnly)) {
        qWarning("Cannot open " + file.toLatin1());
        qWarning("Is it a valid zip file?");
        return 1;
    }

    // Take the root folder from the archive and create a KArchiveDirectory object.
    // KArchiveDirectory represents a directory in a KArchive.
    const KArchiveDirectory *root = archive.directory();

    // We can extract all contents from a KArchiveDirectory to a destination.
    // recursive true will also extract subdirectories.
    QString destination = QDir::currentPath();
    bool recursive = true;
    root->copyTo(destination, recursive);

    archive.close();

    MainWindow w;
    w.show();
    return a.exec();
}
