diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
commit | 47c8a359c5276062c4bc17f0e82410f29081b502 (patch) | |
tree | 2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /kppp/logview/monthly.cpp | |
parent | 6f82532777a35e0e60bbd2b290b2e93e646f349b (diff) | |
download | tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kppp/logview/monthly.cpp')
-rw-r--r-- | kppp/logview/monthly.cpp | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/kppp/logview/monthly.cpp b/kppp/logview/monthly.cpp index b9aac7d3..904f2800 100644 --- a/kppp/logview/monthly.cpp +++ b/kppp/logview/monthly.cpp @@ -18,10 +18,10 @@ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include <qpainter.h> -#include <qcombobox.h> -#include <qfile.h> -#include <qheader.h> +#include <tqpainter.h> +#include <tqcombobox.h> +#include <tqfile.h> +#include <tqheader.h> #include <kcalendarsystem.h> #include <klocale.h> @@ -32,9 +32,9 @@ #include "monthly.h" #include "export.h" -#include <qstringlist.h> +#include <tqstringlist.h> -static void formatBytes(double bytes, QString &result) { +static void formatBytes(double bytes, TQString &result) { if(bytes < 1024) result.setNum(bytes); else if(bytes < 1024*1024) @@ -43,11 +43,11 @@ static void formatBytes(double bytes, QString &result) { result = i18n("%1 MB").arg(KGlobal::locale()->formatNumber((float)bytes / 1024.0 / 1024.0, 1)); } -static void formatBytesMonth(double bytes, QString &result) { +static void formatBytesMonth(double bytes, TQString &result) { int day, days; - day = QDate::currentDate().day(); - days = QDate::currentDate().daysInMonth(); + day = TQDate::currentDate().day(); + days = TQDate::currentDate().daysInMonth(); bytes = (bytes / day) * days; @@ -59,8 +59,8 @@ static void formatBytesMonth(double bytes, QString &result) { result = i18n("%1 MB").arg(KGlobal::locale()->formatNumber((float)bytes / 1024.0 / 1024.0, 1)); } -static void formatDuration(int seconds, QString &result) { - QString sec; +static void formatDuration(int seconds, TQString &result) { + TQString sec; sec.sprintf("%02d", seconds%60); if(seconds < 60) result = i18n("%1s").arg(sec); @@ -73,15 +73,15 @@ static void formatDuration(int seconds, QString &result) { .arg(sec); } -static void formatDurationMonth(int seconds, QString &result) { +static void formatDurationMonth(int seconds, TQString &result) { int day, days; - day = QDate::currentDate().day(); - days = QDate::currentDate().daysInMonth(); + day = TQDate::currentDate().day(); + days = TQDate::currentDate().daysInMonth(); seconds = (seconds / day) * days; - QString sec; + TQString sec; sec.sprintf("%02d", seconds%60); if(seconds < 60) result = i18n("%1s").arg(sec); @@ -97,37 +97,37 @@ static void formatDurationMonth(int seconds, QString &result) { static void costsMonth(double costs, double &result) { int day, days; - day = QDate::currentDate().day(); - days = QDate::currentDate().daysInMonth(); + day = TQDate::currentDate().day(); + days = TQDate::currentDate().daysInMonth(); result = (costs / day) * days; } -class LogListItem : public QListViewItem { +class LogListItem : public TQListViewItem { public: LogListItem(LogInfo *l, - QListView * parent, - QString s1, QString s2, - QString s3, QString s4, - QString s5, QString s6, - QString s7, QString s8) - : QListViewItem(parent, s1, s2, s3, s4, s5, s6, s7, s8), + TQListView * parent, + TQString s1, TQString s2, + TQString s3, TQString s4, + TQString s5, TQString s6, + TQString s7, TQString s8) + : TQListViewItem(parent, s1, s2, s3, s4, s5, s6, s7, s8), li(l) { } - virtual void paintCell( QPainter *p, const QColorGroup & cg, + virtual void paintCell( TQPainter *p, const TQColorGroup & cg, int column, int width, int alignment ); - virtual QString key(int, bool) const; + virtual TQString key(int, bool) const; LogInfo *li; }; -void LogListItem::paintCell( QPainter *p, const QColorGroup & cg, +void LogListItem::paintCell( TQPainter *p, const TQColorGroup & cg, int column, int width, int alignment ) { - QListViewItem::paintCell(p, cg, column, width, alignment); + TQListViewItem::paintCell(p, cg, column, width, alignment); // double line above sum //if(!li) { @@ -136,12 +136,12 @@ void LogListItem::paintCell( QPainter *p, const QColorGroup & cg, //} } -QString LogListItem::key(int c, bool ascending) const +TQString LogListItem::key(int c, bool ascending) const { if (!li) // we want the sum to be always at the bottom return ascending ? "z" : " "; - QString k; + TQString k; switch (c) { case 0: k = li->connectionName(); @@ -167,8 +167,8 @@ QString LogListItem::key(int c, bool ascending) const return k; } -MonthlyWidget::MonthlyWidget(QWidget *parent) : - QWidget(parent) +MonthlyWidget::MonthlyWidget(TQWidget *parent) : + TQWidget(parent) { tl = 0; @@ -194,9 +194,9 @@ MonthlyWidget::MonthlyWidget(QWidget *parent) : lv->setSorting(1); lv->setMinimumWidth(180); lv->setMinimumHeight(280); - lv->setSelectionMode(QListView::Extended); + lv->setSelectionMode(TQListView::Extended); selectionItem = 0L; - connect(lv, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged())); + connect(lv, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelectionChanged())); lv2 = new KListView(this); lv2->addColumn(i18n("Connection")); @@ -212,21 +212,21 @@ MonthlyWidget::MonthlyWidget(QWidget *parent) : lv2->setSorting(-1); lv2->setItemMargin(2); lv2->setMaximumHeight(100); - lv2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); - lv2->setSelectionMode(QListView::NoSelection); + lv2->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Minimum); + lv2->setSelectionMode(TQListView::NoSelection); - title = new QLabel("X", this); - QFont f = title->font(); + title = new TQLabel("X", this); + TQFont f = title->font(); f.setPointSize(f.pointSize() + 2); f.setBold(TRUE); title->setFont(f); title->setFixedHeight(title->sizeHint().height()*2); - cboConnections = new QComboBox(false, this); // add a combo box to select connections + cboConnections = new TQComboBox(false, this); // add a combo box to select connections cboConnections->setMaximumWidth(200); // a resonable size cboConnections->insertItem(i18n("All Connections")); // default to all connections - connect(cboConnections, SIGNAL(activated(int)), - this, SLOT(slotConnections(int))); + connect(cboConnections, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotConnections(int))); bbox = new KButtonBox(this, Qt::Vertical); prev = bbox->addButton(i18n("&Prev Month")); @@ -236,14 +236,14 @@ MonthlyWidget::MonthlyWidget(QWidget *parent) : bbox->addStretch(1); exportBttn = bbox->addButton(i18n("&Export...")); - connect(prev, SIGNAL(released()), - this, SLOT(prevMonth())); - connect(next, SIGNAL(released()), - this, SLOT(nextMonth())); - connect(today, SIGNAL(released()), - this, SLOT(currentMonth())); - connect(exportBttn, SIGNAL(clicked()), - this, SLOT(exportWizard())); + connect(prev, TQT_SIGNAL(released()), + this, TQT_SLOT(prevMonth())); + connect(next, TQT_SIGNAL(released()), + this, TQT_SLOT(nextMonth())); + connect(today, TQT_SIGNAL(released()), + this, TQT_SLOT(currentMonth())); + connect(exportBttn, TQT_SIGNAL(clicked()), + this, TQT_SLOT(exportWizard())); bbox->addStretch(8); bbox->layout(); @@ -256,12 +256,12 @@ void MonthlyWidget::layoutWidget() { if(tl) delete tl; - tl = new QGridLayout(this, 1, 1, 11, 16, "MainLayout"); + tl = new TQGridLayout(this, 1, 1, 11, 16, "MainLayout"); tl->addWidget(title, 0, 0); tl->addWidget(cboConnections, 0, 1); - QLabel *l = new QLabel(this); + TQLabel *l = new TQLabel(this); l->setText(i18n("Statistics:")); - QFont f2 = l->font(); + TQFont f2 = l->font(); f2.setPointSize(f2.pointSize() + 1); f2.setBold(TRUE); l->setFont(f2); @@ -275,13 +275,13 @@ void MonthlyWidget::layoutWidget() { tl->activate(); } -int bestlen(QWidget *w, const char *s) { +int bestlen(TQWidget *w, const char *s) { return w->fontMetrics().boundingRect(s).width() + 8; } void MonthlyWidget::plotMonth() { // name of the current connection - QString con; + TQString con; // for collecting monthly statistics int count = 0; @@ -293,12 +293,12 @@ void MonthlyWidget::plotMonth() { lv2->clear(); const KCalendarSystem * calendar = KGlobal::locale()->calendar(); - QDate startDate = periodeFirst(); + TQDate startDate = periodeFirst(); for(int i = 0; i < (int)logList.count(); i++) { LogInfo *li = logList.at(i); - QDate logDate = li->from().date(); + TQDate logDate = li->from().date(); if ( periodeFirst() <= logDate && periodeLast() >= logDate ) { // get connection name for this line con = li->connectionName(); @@ -330,7 +330,7 @@ void MonthlyWidget::plotMonth() { duration += li->from().secsTo(li->until()); - QString _bin, _bout, b; + TQString _bin, _bout, b; if(li->bytesIn() >= 0) formatBytes(li->bytesIn(), _bin); else @@ -346,14 +346,14 @@ void MonthlyWidget::plotMonth() { else b = i18n("n/a"); - QString day; + TQString day; day.sprintf("%2d", li->from().date().day()); - QString s_duration; + TQString s_duration; formatDuration(li->from().secsTo(li->until()), s_duration); - QString s_lifrom, s_liuntil, s_costs; + TQString s_lifrom, s_liuntil, s_costs; s_lifrom = KGlobal::locale()->formatTime(li->from().time(), false); s_liuntil = KGlobal::locale()->formatTime(li->until().time(), false); s_costs = KGlobal::locale()->formatMoney(li->sessionCosts()); @@ -363,7 +363,7 @@ void MonthlyWidget::plotMonth() { } if(count) { - QString _bin, _bout, _b; + TQString _bin, _bout, _b; if(bin < 0) _bin = i18n("n/a"); @@ -380,25 +380,25 @@ void MonthlyWidget::plotMonth() { else formatBytes(bout + bin, _b); - QString s_duration; + TQString s_duration; formatDuration(duration, s_duration); - QString s_costs(KGlobal::locale()->formatMoney(costs, QString::null, 2)); + TQString s_costs(KGlobal::locale()->formatMoney(costs, TQString::null, 2)); selectionItem = new LogListItem(0, lv2, i18n("Selection (%n connection)", "Selection (%n connections)", 0), - QString::null, QString::null, QString::null, - QString::null, QString::null, QString::null, QString::null); + TQString::null, TQString::null, TQString::null, + TQString::null, TQString::null, TQString::null, TQString::null); (void) new LogListItem(0, lv2, i18n("%n connection", "%n connections", count), - s_duration, s_costs, _bin, _bout, QString::null, QString::null, QString::null); + s_duration, s_costs, _bin, _bout, TQString::null, TQString::null, TQString::null); const KCalendarSystem * calendar = KGlobal::locale()->calendar(); - if(calendar->month(periodeFirst()) == calendar->month(QDate::currentDate())) { + if(calendar->month(periodeFirst()) == calendar->month(TQDate::currentDate())) { - QString m_bin, m_bout; + TQString m_bin, m_bout; if(bin < 0) _bin = i18n("n/a"); @@ -410,19 +410,19 @@ void MonthlyWidget::plotMonth() { else formatBytesMonth(bout, m_bout); - QString m_duration; + TQString m_duration; formatDurationMonth(duration, m_duration); costsMonth(costs, costs); - QString m_costs(KGlobal::locale()->formatMoney(costs, QString::null, 2)); + TQString m_costs(KGlobal::locale()->formatMoney(costs, TQString::null, 2)); - (void) new QListViewItem(lv2, selectionItem, + (void) new TQListViewItem(lv2, selectionItem, i18n("Monthly estimates"), m_duration, m_costs, m_bin, m_bout, - QString::null, QString::null, QString::null); + TQString::null, TQString::null, TQString::null); } } - QString t; + TQString t; if(lv->childCount() > 0) { exportBttn->setEnabled(true); // export possibility t = i18n("Connection log for %1 %2") @@ -456,7 +456,7 @@ void MonthlyWidget::prevMonth() { void MonthlyWidget::currentMonth() { const KCalendarSystem * calendar = KGlobal::locale()->calendar(); - QDate dt = QDate::currentDate(); + TQDate dt = TQDate::currentDate(); calendar->setYMD(m_periodeFirst, calendar->year(dt), calendar->month(dt), 1); plotMonth(); @@ -464,7 +464,7 @@ void MonthlyWidget::currentMonth() { void MonthlyWidget::exportWizard() { const KCalendarSystem * calendar = KGlobal::locale()->calendar(); - QString date = QString::fromLatin1("%1-%2") // e.g.: June-2001 + TQString date = TQString::fromLatin1("%1-%2") // e.g.: June-2001 .arg(calendar->monthName(periodeFirst())) .arg(calendar->year(periodeFirst())); @@ -473,7 +473,7 @@ void MonthlyWidget::exportWizard() { if (wizard->filename.isEmpty()) { // wizard aborted... return; } - if (QFile::exists(wizard->filename)) { // overwrite? + if (TQFile::exists(wizard->filename)) { // overwrite? if (KMessageBox::Continue!=KMessageBox::warningContinueCancel(0, i18n("A document with this name already exists."), i18n("Overwrite file?"), i18n("&Overwrite") /*, true*/)) { // no return; } @@ -496,7 +496,7 @@ void MonthlyWidget::exportWizard() { i18n("Duration"), i18n("Costs"), i18n("Bytes In"), i18n("Bytes Out") ); // name of the current connection - QString con; + TQString con; // for collecting monthly statistics int count = 0; @@ -507,7 +507,7 @@ void MonthlyWidget::exportWizard() { for(int i = 0; i < (int)logList.count(); i++) { LogInfo *li = logList.at(i); - QDate logDate = li->from().date(); + TQDate logDate = li->from().date(); if (periodeFirst() <= logDate && periodeLast() >= logDate ) { // get connection name for this line con = li->connectionName(); @@ -540,7 +540,7 @@ void MonthlyWidget::exportWizard() { duration += li->from().secsTo(li->until()); - QString _bin, _bout, b; + TQString _bin, _bout, b; if(li->bytesIn() >= 0) formatBytes(li->bytesIn(), _bin); else @@ -556,15 +556,15 @@ void MonthlyWidget::exportWizard() { else b = i18n("n/a"); - QString day; + TQString day; day.sprintf("%2d", li->from().date().day()); - QString con = li->connectionName(); + TQString con = li->connectionName(); - QString s_duration; + TQString s_duration; formatDuration(li->from().secsTo(li->until()), s_duration); - QString s_lifrom, s_liuntil, s_costs; + TQString s_lifrom, s_liuntil, s_costs; s_lifrom = KGlobal::locale()->formatTime(li->from().time(), false); s_liuntil = KGlobal::locale()->formatTime(li->until().time(), false); s_costs = KGlobal::locale()->formatMoney(li->sessionCosts()); @@ -576,9 +576,9 @@ void MonthlyWidget::exportWizard() { } } - if(calendar->month(periodeFirst()) == calendar->month(QDate::currentDate())) { + if(calendar->month(periodeFirst()) == calendar->month(TQDate::currentDate())) { - QString m_bin, m_bout; + TQString m_bin, m_bout; if(bin < 0) m_bin = i18n("n/a"); else @@ -589,21 +589,21 @@ void MonthlyWidget::exportWizard() { else formatBytesMonth(bout, m_bout); - QString m_duration; + TQString m_duration; formatDurationMonth(duration, m_duration); costsMonth(costs, costs); - QString m_costs(KGlobal::locale()->formatMoney(costs, QString::null, 2)); + TQString m_costs(KGlobal::locale()->formatMoney(costs, TQString::null, 2)); - QString datetime = KGlobal::locale()->formatDateTime( QDateTime::currentDateTime(), true); + TQString datetime = KGlobal::locale()->formatDateTime( TQDateTime::currentDateTime(), true); exportIFace->addEmptyLine(); exportIFace->addDataline(i18n("Monthly estimates (%1)").arg(datetime), - QString::null, QString::null, QString::null, m_duration, m_costs, m_bin, m_bout); + TQString::null, TQString::null, TQString::null, m_duration, m_costs, m_bin, m_bout); } if(count) { - QString _bin, _bout, _b; + TQString _bin, _bout, _b; if(bin < 0) _bin = i18n("n/a"); @@ -620,15 +620,15 @@ void MonthlyWidget::exportWizard() { else formatBytes(bout + bin, _b); - QString s_duration; + TQString s_duration; formatDuration(duration, s_duration); - QString s_costs(KGlobal::locale()->formatMoney(costs, QString::null, 2)); + TQString s_costs(KGlobal::locale()->formatMoney(costs, TQString::null, 2)); // call export methods exportIFace->addEmptyLine(); - exportIFace->addDataline(i18n("%n connection", "%n connections", count), QString::null, QString::null, QString::null, s_duration, + exportIFace->addDataline(i18n("%n connection", "%n connections", count), TQString::null, TQString::null, TQString::null, s_duration, s_costs, _bin, _bout); exportIFace->setFinishCode(); @@ -643,12 +643,12 @@ void MonthlyWidget::exportWizard() { delete exportIFace; } -QDate MonthlyWidget::periodeFirst() const +TQDate MonthlyWidget::periodeFirst() const { return m_periodeFirst; } -QDate MonthlyWidget::periodeLast() const +TQDate MonthlyWidget::periodeLast() const { const KCalendarSystem * calendar = KGlobal::locale()->calendar(); @@ -666,7 +666,7 @@ void MonthlyWidget::slotSelectionChanged() int duration = 0; LogListItem *item; LogInfo *li; - QListViewItemIterator it(lv); + TQListViewItemIterator it(lv); while ( it.current() ) { item = dynamic_cast<LogListItem*>(it.current()); @@ -695,7 +695,7 @@ void MonthlyWidget::slotSelectionChanged() } if(count) { - QString _bin, _bout, _b; + TQString _bin, _bout, _b; if(bin < 0) _bin = i18n("n/a"); @@ -712,11 +712,11 @@ void MonthlyWidget::slotSelectionChanged() else formatBytes(bout + bin, _b); - QString s_duration; + TQString s_duration; formatDuration(duration, s_duration); - QString s_costs(KGlobal::locale()->formatMoney(costs, QString::null, 2)); + TQString s_costs(KGlobal::locale()->formatMoney(costs, TQString::null, 2)); selectionItem->setText(0, i18n("Selection (%n connection)", "Selection (%n connections)", count)); selectionItem->setText(1, s_duration); selectionItem->setText(2, s_costs); |