Source Code (Use browser search to find items of interest.)

Class Index

kppp'ConWindow (./kdenetwork/kppp/conwindow.h:39)

class ConWindow : public QWidget {
Q_OBJECT

public:
  ConWindow(QWidget *parent, const char *name,QWidget *main, PPPStats *st);
  ~ConWindow();

protected:
  void closeEvent( QCloseEvent *e );

private slots:
  void timeclick();
  void dock();

public:
  void setConnectionSpeed(const QString&);
  void startClock();
  void stopClock();
  void accounting(bool); // show/ hide accounting info

public slots:
  void slotAccounting(QString, QString);

private:
  QLabel *info1;
  QLabel *info2;
  QPushButton *cancelbutton;
  QPushButton *statsbutton;

  int minutes;
  int seconds;
  int hours;
  int days;
  QFrame *fline;
  QLabel *timelabel1;
  QLabel *timelabel2;
  QLabel *total_bill, *total_bill_l;
  QLabel *session_bill, *session_bill_l;
  QString caption_string;
  QString time_string2;
  QString time_string;
  QTimer *clocktimer;
  QVBoxLayout *tl1;
  QLabel *vollabel;
  QLabel *volinfo;
  PPPStats *stats;
};


kppp'ConWindow::ConWindow() (./kdenetwork/kppp/conwindow.cpp:35)

ConWindow::ConWindow(QWidget *parent, const char *name,QWidget *mainwidget,
		     PPPStats *st)
  : QWidget(parent, name, 0),
    minutes(0),
    seconds(0),
    hours(0),
    days(0),
    tl1(0),
    stats(st)
{
  info1 = new QLabel(i18n("Connected at:"), this);
  info2 = new QLabel("", this);

  timelabel1 = new QLabel(i18n("Time connected:"), this);
  timelabel2 = new QLabel("000:00:00", this);

  vollabel = new QLabel(i18n("Volume:"), this);
  volinfo  = new QLabel("", this);

  // now the stuff for accounting
  session_bill_l = new QLabel(i18n("Session Bill:"), this);
  session_bill = new QLabel("", this);
  total_bill_l = new QLabel(i18n("Total Bill:"), this);
  total_bill = new QLabel("", this);

  this->setCaption("kppp");

  cancelbutton = new QPushButton(this);
  cancelbutton->setText(i18n("Disconnect"));
  connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect()));

  statsbutton = new QPushButton(this);
  statsbutton->setText(i18n("Details"));
  statsbutton->setFocus();
  connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats()));

  clocktimer = new QTimer(this);
  connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick()));
}


kppp'ConWindow::~ConWindow() (./kdenetwork/kppp/conwindow.cpp:75)

ConWindow::~ConWindow() {
  stopClock();
}



kppp'ConWindow::accounting() (./kdenetwork/kppp/conwindow.cpp:80)

void ConWindow::accounting(bool on) {
  // delete old layout
  if(tl1 != 0)
    delete tl1;

  // add layout now
  tl1 = new QVBoxLayout(this, 10, 10);
  tl1->addSpacing(5);
  QHBoxLayout *tl = new QHBoxLayout;
  tl1->addLayout(tl);
  tl->addSpacing(20);
  QGridLayout *l1;

  int vol_lines = 0;
  if(gpppdata.VolAcctEnabled())
    vol_lines = 1;

  if(on)
    l1 = new QGridLayout(4 + vol_lines, 2, 5);
  else
    l1 = new QGridLayout(2 + vol_lines, 2, 5);
  tl->addLayout(l1);
  l1->setColStretch(0, 0);
  l1->setColStretch(1, 1);

  info2->setAlignment(AlignRight|AlignVCenter);
  timelabel2->setAlignment(AlignRight|AlignVCenter);
  session_bill->setAlignment(AlignRight|AlignVCenter);
  total_bill->setAlignment(AlignRight|AlignVCenter);
  volinfo->setAlignment(AlignRight|AlignVCenter);
  // make sure that there's enough space for the bills
  QString s1 = session_bill->text();
  QString s2 = total_bill->text();
  QString s3 = volinfo->text();

  session_bill->setText("888888.88 XXX");
  total_bill->setText("888888.88 XXX");
  volinfo->setText("8888.8 MB");
  session_bill->setFixedSize(session_bill->sizeHint());
  total_bill->setFixedSize(total_bill->sizeHint());
  volinfo->setFixedSize(volinfo->sizeHint());
  session_bill->setText(s1);
  total_bill->setText(s2);
  volinfo->setText(s3);

  l1->addWidget(info1, 0, 0);
  l1->addWidget(info2, 0, 1);
  l1->addWidget(timelabel1, 1, 0);
  l1->addWidget(timelabel2, 1, 1);
  if(on) {
    session_bill_l->show();
    session_bill->show();
    total_bill_l->show();
    total_bill->show();
    l1->addWidget(session_bill_l, 2, 0);
    l1->addWidget(session_bill, 2, 1);
    l1->addWidget(total_bill_l, 3, 0);
    l1->addWidget(total_bill, 3, 1);

    if(gpppdata.VolAcctEnabled()) {
      vollabel->show();
      volinfo->show();
      l1->addWidget(vollabel, 4, 0);
      l1->addWidget(volinfo, 4, 1);
    } else {
      vollabel->hide();
      volinfo->hide();
    }

  } else {
    session_bill_l->hide();
    session_bill->hide();
    total_bill_l->hide();
    total_bill->hide();

    if(gpppdata.VolAcctEnabled()) {
      vollabel->show();
      volinfo->show();
      l1->addWidget(vollabel, 2, 0);
      l1->addWidget(volinfo, 2, 1);
    } else {
      vollabel->hide();
      volinfo->hide();
    }
  }

  tl->addSpacing(10);
  QVBoxLayout *l2 = new QVBoxLayout(5);
  tl->addLayout(l2);
  l2->addStretch(1);
  l2->addWidget(statsbutton);
  l2->addWidget(cancelbutton);

  l2->addStretch(1);

  tl1->addSpacing(5);

  setFixedSize(sizeHint());
  setGeometry((QApplication::desktop()->width() - width()) / 2,
	      (QApplication::desktop()->height() - height())/2,
	      width(),
	      height());
}



kppp'ConWindow::dock() (./kdenetwork/kppp/conwindow.cpp:185)

void ConWindow::dock() {
  DockWidget::dock_widget->show();
  this->hide();
}



kppp'ConWindow::startClock() (./kdenetwork/kppp/conwindow.cpp:191)

void ConWindow::startClock() {
  minutes = 0;
  seconds = 0;
  hours = 0;
  QString title ;

  title = gpppdata.accname();

  if(gpppdata.get_show_clock_on_caption()){
    title += " 00:00" ;
  }
  this->setCaption(title);

  timelabel2->setText("00:00:00");
  clocktimer->start(1000);
}



kppp'ConWindow::setConnectionSpeed() (./kdenetwork/kppp/conwindow.cpp:209)

void ConWindow::setConnectionSpeed(const QString &speed) {
  info2->setText(speed);
}



kppp'ConWindow::stopClock() (./kdenetwork/kppp/conwindow.cpp:214)

void ConWindow::stopClock() {
  clocktimer->stop();
}



kppp'ConWindow::timeclick() (./kdenetwork/kppp/conwindow.cpp:219)

void ConWindow::timeclick() {
  // volume accounting
  if(gpppdata.VolAcctEnabled()) {
    QString s;
    if(stats->totalbytes < 1024*10)
      s = i18n("%1 Byte").arg(stats->totalbytes);
    else if(stats->totalbytes < 1024*1024)
      s = i18n("%1 KB").arg(KGlobal::locale()->formatNumber(((float)stats->totalbytes)/1024.0, 1));
    else
      s = i18n("%1 MB").arg(KGlobal::locale()->formatNumber(((float)stats->totalbytes)/(1024.0*1024.0), 1));

    volinfo->setText(s);
  }

  seconds++;

  if(seconds >= 60 ) {
    minutes ++;
    seconds = 0;
  }

  if (minutes >= 60){
    minutes = 0;
    hours ++;
  }

  if( hours >= 24){
    days ++;
    hours = 0;
  }

  time_string.sprintf("%02d:%02d",hours,minutes);
  time_string2 = "";
  if (days)
      time_string2.sprintf("%d d %02d:%02d:%02d",
			   days,hours,minutes,seconds);

  else
    time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds);  

  caption_string = gpppdata.accname();
  caption_string += " ";
  caption_string += time_string;


  timelabel2->setText(time_string2);

  if(gpppdata.get_show_clock_on_caption() && (seconds == 1)){
    // we update the Caption only once per minute not every second
    // otherwise I get a flickering icon
    this->setCaption(caption_string);
  }
}



kppp'ConWindow::closeEvent() (./kdenetwork/kppp/conwindow.cpp:274)

void ConWindow::closeEvent( QCloseEvent *e ){
  // we don't want to lose the
  // conwindow since this is our last connection kppp.
  // if we lost it we could only kill the program by hand to get on with life.
  e->ignore();

  if(gpppdata.get_dock_into_panel())
    dock();
}



kppp'ConWindow::slotAccounting() (./kdenetwork/kppp/conwindow.cpp:285)

void ConWindow::slotAccounting(QString total, QString session) {
  total_bill->setText(total);
  session_bill->setText(session);
}