//: Added two new class for transmission visualisation.

svn path=/trunk/kdenetwork/kmail/; revision=5244
wilder-work
Markus Wuebben 29 years ago
parent 48c9aa32b4
commit 221a057607
  1. 84
      kmnewiostatus.cpp
  2. 70
      kmnewiostatus.h
  3. 90
      kmnewiostatuswdg.cpp
  4. 48
      kmnewiostatuswdg.h

@ -0,0 +1,84 @@
// KMIOStatus: base class impl. to show transmission state
// Author: Markus Wuebben <markus.wuebben@kde.org>
// This code is published under the GPL.
#include <iostream.h>
#include "kmnewiostatus.h"
#include "kmnewiostatus.moc"
KMIOStatus::KMIOStatus(QWidget *parent, const char *name)
:QWidget(parent, name) {
initMetaObject();
}
void KMIOStatus::setHost(QString host) {
_host = host;
update();
}
QString KMIOStatus::host() {
return _host;
}
void KMIOStatus::setTask(task type) {
_task = type;
update(); // new task new text. Specified in update()
}
// Reimplement for your impl.
void KMIOStatus::update() {
}
KMIOStatus::task KMIOStatus::Task() {
return _task;
}
void KMIOStatus::transmissionCompleted() {
}
KMIOStatus::~KMIOStatus() {
}
void KMIOStatus::updateProgressBar(int,int) {
}
bool KMIOStatus::abortRequested() {
return abortPressed;
}
void KMIOStatus::abortPressed() {
cout << "Abort requested...\n";
abortPressedBool = true;
emit abort();
}

@ -0,0 +1,70 @@
// KMIOStatus: base class to show transmission state
// Author: Markus Wuebben <markus.wuebben@kde.org>
// This code is published under the GPL.
#ifndef KMIO_H
#define KMIO_H
#include <qwidget.h>
#include <qstring.h>
#include <qlabel.h>
#include <qpushbt.h>
class KMIOStatus : public QWidget
{
Q_OBJECT
public:
/** Which kind of widget you want **/
enum task { SEND, RETRIEVE } ;
KMIOStatus(QWidget *parent = 0, const char *name = 0);
~KMIOStatus();
public slots:
/** Check if abort was pressed **/
bool abortRequested();
/**update the ProgressBar. index is current message, message is
number of all messages **/
virtual void updateProgressBar(int index, int messages );
/** Set host to download or send to **/
void setHost(QString);
/** Get host to download from or send to **/
QString host();
/** Set widget's task **/
void setTask(task);
/** Get widget`s task **/
task Task();
/** Tell widget that the tranmission has been completed **/
virtual void transmissionCompleted();
private slots:
virtual void abortPressed();
/** update the widget as you need to e.g setCaption **/
virtual void update();
signals:
/** Emitted when abort was pressed **/
void abort();
protected:
bool abortPressedBool;
QString _host;
task _task;
};
#endif

@ -0,0 +1,90 @@
#include <iostream.h>
#include "kmnewiostatuswdg.h"
#include "kmnewiostatuswdg.moc"
KMIOStatusWdg::KMIOStatusWdg(QWidget *parent, const char *name,
task type , QString host)
:KMIOStatus(parent,name) {
initMetaObject();
abortPressedBool = false;
setTask(type);
setHost(host);
progressBar = new KProgress(this);
progressBar->setGeometry(35,45,200,30);
abortBt = new QPushButton("Abort",this);
abortBt->resize(abortBt->sizeHint());
abortBt->move(110,90);
connect(abortBt,SIGNAL(clicked()),this,SLOT(abortPressed()));
msgLbl = new QLabel(this);
msgLbl->setGeometry(45,15,200,25);
msgLbl->setText("Preparing transmission...");
setMaximumSize(270,140);
setMinimumSize(270,140);
update();
}
void KMIOStatusWdg::update() {
if(Task() == SEND)
setCaption("Sending messages to " + host());
else
if(Task() == RETRIEVE)
setCaption("Retrieving messages from " + host());
QWidget::update();
}
void KMIOStatusWdg::transmissionCompleted() {
msgLbl->setText("Transmission completed...");
}
KMIOStatusWdg::~KMIOStatusWdg() {
}
void KMIOStatusWdg::updateProgressBar(int index ,int of) {
float value;
QString tmp;
value = ((float)index/(float)of)*100;
if(Task() == RETRIEVE)
tmp.sprintf("Downloading message %i of %i",index,of);
else
if(Task() == SEND)
tmp.sprintf("Sending message %i of %i",index,of);
msgLbl->setText(tmp);
progressBar->setValue((int)value);
}
void KMIOStatusWdg::abortPressed() {
cout << "Abort requested...\n";
msgLbl->setText("Aborting transmission...\n");
abortPressedBool = true;
emit abort();
}

@ -0,0 +1,48 @@
// KMIOStatusWdg: class to show transmission state
// Author: Markus Wuebben <markus.wuebben@kde.org>
// This code is published under the GPL.
#ifndef KMIOWDG_H
#define KMIOWDG_H
#include <qwidget.h>
#include <qstring.h>
#include <qlabel.h>
#include <qpushbt.h>
#include <kprogress.h>
#include "kmnewiostatus.h"
class KMIOStatusWdg : public KMIOStatus
{
Q_OBJECT
public:
KMIOStatusWdg(QWidget *parent = 0, const char * name = 0,
task = 0, QString host = 0 );
~KMIOStatusWdg();
public slots:
/**update the ProgressBar. index is current message, message is
number of all messages **/
void updateProgressBar(int index, int messages );
/** Tell widget that the tranmission has been completed **/
void transmissionCompleted();
private slots:
void abortPressed();
void update();
private:
KProgress *progressBar;
QPushButton *abortBt;
QLabel *msgLbl;
};
#endif
Loading…
Cancel
Save