mboximporterinfogui.cpp 2.71 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
   Copyright (C) 2013-2016 Montel Laurent <montel@kde.org>
Laurent Montel's avatar
Laurent Montel committed
3

Laurent Montel's avatar
Laurent Montel committed
4 5 6 7
   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.
Laurent Montel's avatar
Laurent Montel committed
8

Laurent Montel's avatar
Laurent Montel committed
9 10 11 12
   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.
Laurent Montel's avatar
Laurent Montel committed
13

Laurent Montel's avatar
Laurent Montel committed
14 15 16 17
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
Laurent Montel's avatar
Laurent Montel committed
18 19 20 21 22 23 24 25 26 27
*/

#include "mboximporterinfogui.h"
#include "mboximportwidget.h"

#include "mailimporter/importmailswidget.h"

#include <KMessageBox>

#include <QListWidgetItem>
Laurent Montel's avatar
Laurent Montel committed
28
#include <QApplication>
Laurent Montel's avatar
Laurent Montel committed
29

Laurent Montel's avatar
Laurent Montel committed
30
MBoxImporterInfoGui::MBoxImporterInfoGui(MBoxImportWidget *parent)
Laurent Montel's avatar
Laurent Montel committed
31
    : MailImporter::FilterInfoGui(),
Laurent Montel's avatar
Laurent Montel committed
32
      mParent(parent)
Laurent Montel's avatar
Laurent Montel committed
33 34 35 36 37 38 39
{
}

MBoxImporterInfoGui::~MBoxImporterInfoGui()
{
}

Laurent Montel's avatar
Laurent Montel committed
40
void MBoxImporterInfoGui::setStatusMessage(const QString &status)
Laurent Montel's avatar
Laurent Montel committed
41 42 43 44
{
    mParent->mailWidget()->setStatusMessage(status);
}

Laurent Montel's avatar
Laurent Montel committed
45
void MBoxImporterInfoGui::setFrom(const QString &from)
Laurent Montel's avatar
Laurent Montel committed
46 47 48 49
{
    mParent->mailWidget()->setFrom(from);
}

Laurent Montel's avatar
Laurent Montel committed
50
void MBoxImporterInfoGui::setTo(const QString &to)
Laurent Montel's avatar
Laurent Montel committed
51 52 53 54
{
    mParent->mailWidget()->setTo(to);
}

Laurent Montel's avatar
Laurent Montel committed
55
void MBoxImporterInfoGui::setCurrent(const QString &current)
Laurent Montel's avatar
Laurent Montel committed
56 57
{
    mParent->mailWidget()->setCurrent(current);
Laurent Montel's avatar
Laurent Montel committed
58
    qApp->processEvents();
Laurent Montel's avatar
Laurent Montel committed
59 60
}

Laurent Montel's avatar
Laurent Montel committed
61
void  MBoxImporterInfoGui::setCurrent(int percent)
Laurent Montel's avatar
Laurent Montel committed
62 63
{
    mParent->mailWidget()->setCurrent(percent);
Laurent Montel's avatar
Laurent Montel committed
64
    qApp->processEvents(); // Be careful - back & finish buttons disabled, so only user event that can happen is cancel/close button
Laurent Montel's avatar
Laurent Montel committed
65 66
}

Laurent Montel's avatar
Laurent Montel committed
67
void  MBoxImporterInfoGui::setOverall(int percent)
Laurent Montel's avatar
Laurent Montel committed
68 69 70 71
{
    mParent->mailWidget()->setOverall(percent);
}

Laurent Montel's avatar
Laurent Montel committed
72
void MBoxImporterInfoGui::addInfoLogEntry(const QString &log)
Laurent Montel's avatar
Laurent Montel committed
73
{
Laurent Montel's avatar
Laurent Montel committed
74
    QListWidgetItem *item = new QListWidgetItem(log);
Laurent Montel's avatar
Laurent Montel committed
75
    item->setForeground(Qt::blue);
Laurent Montel's avatar
Laurent Montel committed
76
    mParent->mailWidget()->addItem(item);
Laurent Montel's avatar
Laurent Montel committed
77
    mParent->mailWidget()->setLastCurrentItem();
Laurent Montel's avatar
Laurent Montel committed
78
    qApp->processEvents();
Laurent Montel's avatar
Laurent Montel committed
79 80
}

Laurent Montel's avatar
Laurent Montel committed
81
void MBoxImporterInfoGui::addErrorLogEntry(const QString &log)
Laurent Montel's avatar
Laurent Montel committed
82
{
Laurent Montel's avatar
Laurent Montel committed
83
    QListWidgetItem *item = new QListWidgetItem(log);
Laurent Montel's avatar
Laurent Montel committed
84
    item->setForeground(Qt::red);
Laurent Montel's avatar
Laurent Montel committed
85
    mParent->mailWidget()->addItem(item);
Laurent Montel's avatar
Laurent Montel committed
86
    mParent->mailWidget()->setLastCurrentItem();
Laurent Montel's avatar
Laurent Montel committed
87
    qApp->processEvents();
Laurent Montel's avatar
Laurent Montel committed
88 89 90 91 92 93 94
}

void MBoxImporterInfoGui::clear()
{
    mParent->mailWidget()->clear();
}

Laurent Montel's avatar
Laurent Montel committed
95
void MBoxImporterInfoGui::alert(const QString &message)
Laurent Montel's avatar
Laurent Montel committed
96
{
Laurent Montel's avatar
Laurent Montel committed
97
    KMessageBox::information(mParent, message);
Laurent Montel's avatar
Laurent Montel committed
98 99
}

Laurent Montel's avatar
Laurent Montel committed
100
QWidget *MBoxImporterInfoGui::parent() const
Laurent Montel's avatar
Laurent Montel committed
101 102 103 104
{
    return mParent;
}