File indexing completed on 2024-05-19 05:24:00
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "mboximporterinfogui.h" 0008 #include "mboximportwidget.h" 0009 0010 #include <MailImporter/ImportMailsWidget> 0011 0012 #include <KMessageBox> 0013 0014 #include <QApplication> 0015 #include <QListWidgetItem> 0016 0017 MBoxImporterInfoGui::MBoxImporterInfoGui(MBoxImportWidget *parent) 0018 : MailImporter::FilterInfoGui() 0019 , mParent(parent) 0020 { 0021 } 0022 0023 MBoxImporterInfoGui::~MBoxImporterInfoGui() = default; 0024 0025 void MBoxImporterInfoGui::setStatusMessage(const QString &status) 0026 { 0027 mParent->mailWidget()->setStatusMessage(status); 0028 } 0029 0030 void MBoxImporterInfoGui::setFrom(const QString &from) 0031 { 0032 mParent->mailWidget()->setFrom(from); 0033 } 0034 0035 void MBoxImporterInfoGui::setTo(const QString &to) 0036 { 0037 mParent->mailWidget()->setTo(to); 0038 } 0039 0040 void MBoxImporterInfoGui::setCurrent(const QString ¤t) 0041 { 0042 mParent->mailWidget()->setCurrent(current); 0043 qApp->processEvents(); 0044 } 0045 0046 void MBoxImporterInfoGui::setCurrent(int percent) 0047 { 0048 mParent->mailWidget()->setCurrent(percent); 0049 qApp->processEvents(); // Be careful - back & finish buttons disabled, so only user event that can happen is cancel/close button 0050 } 0051 0052 void MBoxImporterInfoGui::setOverall(int percent) 0053 { 0054 mParent->mailWidget()->setOverall(percent); 0055 } 0056 0057 void MBoxImporterInfoGui::addInfoLogEntry(const QString &log) 0058 { 0059 auto item = new QListWidgetItem(log); 0060 item->setForeground(Qt::blue); 0061 mParent->mailWidget()->addItem(item); 0062 mParent->mailWidget()->setLastCurrentItem(); 0063 qApp->processEvents(); 0064 } 0065 0066 void MBoxImporterInfoGui::addErrorLogEntry(const QString &log) 0067 { 0068 auto item = new QListWidgetItem(log); 0069 item->setForeground(Qt::red); 0070 mParent->mailWidget()->addItem(item); 0071 mParent->mailWidget()->setLastCurrentItem(); 0072 qApp->processEvents(); 0073 } 0074 0075 void MBoxImporterInfoGui::clear() 0076 { 0077 mParent->mailWidget()->clear(); 0078 } 0079 0080 void MBoxImporterInfoGui::alert(const QString &message) 0081 { 0082 KMessageBox::information(mParent, message); 0083 } 0084 0085 QWidget *MBoxImporterInfoGui::parent() const 0086 { 0087 return mParent; 0088 }