diff options
Diffstat (limited to 'kmymoney2/widgets/kmymoneycalendar.cpp')
-rw-r--r-- | kmymoney2/widgets/kmymoneycalendar.cpp | 250 |
1 files changed, 125 insertions, 125 deletions
diff --git a/kmymoney2/widgets/kmymoneycalendar.cpp b/kmymoney2/widgets/kmymoneycalendar.cpp index 8f5291f..761cda8 100644 --- a/kmymoney2/widgets/kmymoneycalendar.cpp +++ b/kmymoney2/widgets/kmymoneycalendar.cpp @@ -45,17 +45,17 @@ // ---------------------------------------------------------------------------- // QT Includes -#include <qpainter.h> -#include <qdrawutil.h> -#include <qframe.h> -#include <qpainter.h> -#include <qdialog.h> -#include <qstyle.h> -#include <qtoolbutton.h> -#include <qtooltip.h> -#include <qfont.h> -#include <qvalidator.h> -#include <qpushbutton.h> +#include <tqpainter.h> +#include <tqdrawutil.h> +#include <tqframe.h> +#include <tqpainter.h> +#include <tqdialog.h> +#include <tqstyle.h> +#include <tqtoolbutton.h> +#include <tqtooltip.h> +#include <tqfont.h> +#include <tqvalidator.h> +#include <tqpushbutton.h> // ---------------------------------------------------------------------------- // KDE Includes @@ -85,14 +85,14 @@ public: kMyMoneyCalendarPrivate() : closeButton(0L), selectWeek(0L), userButton1(0), userButton2(0) {} - QToolButton *closeButton; - QToolButton *selectWeek; - QPushButton *userButton1; - QPushButton *userButton2; + TQToolButton *closeButton; + TQToolButton *selectWeek; + TQPushButton *userButton1; + TQPushButton *userButton2; }; -kMyMoneyCalendar::kMyMoneyCalendar(QWidget *parent, const char *name ) : - QFrame(parent,name), +kMyMoneyCalendar::kMyMoneyCalendar(TQWidget *tqparent, const char *name ) : + TQFrame(tqparent,name), table(0), d(new kMyMoneyCalendarPrivate) { @@ -103,83 +103,83 @@ kMyMoneyCalendar::~kMyMoneyCalendar() delete d; } -void kMyMoneyCalendar::init( const QDate &dt ) +void kMyMoneyCalendar::init( const TQDate &dt ) { - styleControl = new QPushButton(i18n("Select Style"), this); - yearForward = new QToolButton(this); - yearBackward = new QToolButton(this); - monthForward = new QToolButton(this); - monthBackward = new QToolButton(this); - selectMonth = new QToolButton(this); - selectYear = new QToolButton(this); + styleControl = new TQPushButton(i18n("Select Style"), this); + yearForward = new TQToolButton(this); + yearBackward = new TQToolButton(this); + monthForward = new TQToolButton(this); + monthBackward = new TQToolButton(this); + selectMonth = new TQToolButton(this); + selectYear = new TQToolButton(this); line = new KLineEdit(this); val = new KDateValidator(this); fontsize = 10; - d->selectWeek = new QToolButton( this ); + d->selectWeek = new TQToolButton( this ); // KIconLoader *kiconloader = KGlobal::iconLoader(); KPopupMenu* kpopupmenuNew = new KPopupMenu(this); - kpopupmenuNew->insertItem(i18n("Week"), this, SLOT(slotSetStyleWeekly())); - kpopupmenuNew->insertItem(i18n("Month"), this, SLOT(slotSetStyleMonthly())); -/* kpopupmenuNew->insertItem(i18n("3 Months"), this, SLOT(slotSetStyleQuarterly())); */ + kpopupmenuNew->insertItem(i18n("Week"), this, TQT_SLOT(slotSetStyleWeekly())); + kpopupmenuNew->insertItem(i18n("Month"), this, TQT_SLOT(slotSetStyleMonthly())); +/* kpopupmenuNew->insertItem(i18n("3 Months"), this, TQT_SLOT(slotSetStyleQuarterly())); */ styleControl->setPopup(kpopupmenuNew); - QToolTip::add(styleControl, i18n("Choose Style")); - QToolTip::add(yearForward, i18n("Next year")); - QToolTip::add(yearBackward, i18n("Previous year")); - QToolTip::add(monthForward, i18n("Next month")); - QToolTip::add(monthBackward, i18n("Previous month")); - QToolTip::add(d->selectWeek, i18n("Select a week")); - QToolTip::add(selectMonth, i18n("Select a month")); - QToolTip::add(selectYear, i18n("Select a year")); + TQToolTip::add(styleControl, i18n("Choose Style")); + TQToolTip::add(yearForward, i18n("Next year")); + TQToolTip::add(yearBackward, i18n("Previous year")); + TQToolTip::add(monthForward, i18n("Next month")); + TQToolTip::add(monthBackward, i18n("Previous month")); + TQToolTip::add(d->selectWeek, i18n("Select a week")); + TQToolTip::add(selectMonth, i18n("Select a month")); + TQToolTip::add(selectYear, i18n("Select a year")); // ----- setFontSize(10); line->setValidator(val); line->installEventFilter( this ); - yearForward->setPixmap(BarIcon(QString::fromLatin1("2rightarrow"))); - yearBackward->setPixmap(BarIcon(QString::fromLatin1("2leftarrow"))); - monthForward->setPixmap(BarIcon(QString::fromLatin1("1rightarrow"))); - monthBackward->setPixmap(BarIcon(QString::fromLatin1("1leftarrow"))); + yearForward->setPixmap(BarIcon(TQString::tqfromLatin1("2rightarrow"))); + yearBackward->setPixmap(BarIcon(TQString::tqfromLatin1("2leftarrow"))); + monthForward->setPixmap(BarIcon(TQString::tqfromLatin1("1rightarrow"))); + monthBackward->setPixmap(BarIcon(TQString::tqfromLatin1("1leftarrow"))); setDate(dt); // set button texts - connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); - connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); - connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); - connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); - connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); - connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); - connect(d->selectWeek, SIGNAL(clicked()), SLOT(selectWeekClicked())); - connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); - connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); - connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); + connect(table, TQT_SIGNAL(dateChanged(TQDate)), TQT_SLOT(dateChangedSlot(TQDate))); + connect(table, TQT_SIGNAL(tableClicked()), TQT_SLOT(tableClickedSlot())); + connect(monthForward, TQT_SIGNAL(clicked()), TQT_SLOT(monthForwardClicked())); + connect(monthBackward, TQT_SIGNAL(clicked()), TQT_SLOT(monthBackwardClicked())); + connect(yearForward, TQT_SIGNAL(clicked()), TQT_SLOT(yearForwardClicked())); + connect(yearBackward, TQT_SIGNAL(clicked()), TQT_SLOT(yearBackwardClicked())); + connect(d->selectWeek, TQT_SIGNAL(clicked()), TQT_SLOT(selectWeekClicked())); + connect(selectMonth, TQT_SIGNAL(clicked()), TQT_SLOT(selectMonthClicked())); + connect(selectYear, TQT_SIGNAL(clicked()), TQT_SLOT(selectYearClicked())); + connect(line, TQT_SIGNAL(returnPressed()), TQT_SLOT(lineEnterPressed())); if (table) table->setFocus(); } bool -kMyMoneyCalendar::eventFilter(QObject *o, QEvent *e ) +kMyMoneyCalendar::eventFilter(TQObject *o, TQEvent *e ) { - if ( e->type() == QEvent::KeyPress ) { - QKeyEvent *k = (QKeyEvent *)e; + if ( e->type() == TQEvent::KeyPress ) { + TQKeyEvent *k = (TQKeyEvent *)e; - if ( (k->key() == Qt::Key_Prior) || - (k->key() == Qt::Key_Next) || - (k->key() == Qt::Key_Up) || - (k->key() == Qt::Key_Down) ) + if ( (k->key() == TQt::Key_Prior) || + (k->key() == TQt::Key_Next) || + (k->key() == TQt::Key_Up) || + (k->key() == TQt::Key_Down) ) { - QApplication::sendEvent( table, e ); + TQApplication::sendEvent( table, e ); table->setFocus(); return TRUE; // eat event } } - return QFrame::eventFilter( o, e ); + return TQFrame::eventFilter( o, e ); } void -kMyMoneyCalendar::resizeEvent(QResizeEvent*) +kMyMoneyCalendar::resizeEvent(TQResizeEvent*) { - QWidget *buttons[] = { + TQWidget *buttons[] = { styleControl, d->userButton1, d->userButton2, @@ -192,7 +192,7 @@ kMyMoneyCalendar::resizeEvent(QResizeEvent*) d->closeButton }; const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); - QSize sizes[NoOfButtons]; + TQSize sizes[NoOfButtons]; int buttonHeight=0; int count; int w; @@ -200,18 +200,18 @@ kMyMoneyCalendar::resizeEvent(QResizeEvent*) // ----- calculate button row height: for(count=0; count<NoOfButtons; ++count) { if ( buttons[count] ) { // closeButton may be 0L - sizes[count]=buttons[count]->sizeHint(); - buttonHeight=QMAX(buttonHeight, sizes[count].height()); + sizes[count]=buttons[count]->tqsizeHint(); + buttonHeight=TQMAX(buttonHeight, sizes[count].height()); } else - sizes[count] = QSize(0,0); // closeButton + sizes[count] = TQSize(0,0); // closeButton } // ----- calculate size of the month button: for(count=0; count<NoOfButtons; ++count) { if(buttons[count]==selectMonth) { - QSize metricBound = style().sizeFromContents(QStyle::CT_ToolButton, selectMonth, maxMonthRect); - sizes[count].setWidth(QMAX(metricBound.width(), maxMonthRect.width()+2*QApplication::style().pixelMetric(QStyle::PM_ButtonMargin))); + TQSize metricBound = tqstyle().tqsizeFromContents(TQStyle::CT_ToolButton, selectMonth, maxMonthRect); + sizes[count].setWidth(TQMAX(metricBound.width(), maxMonthRect.width()+2*TQApplication::tqstyle().tqpixelMetric(TQStyle::PM_ButtonMargin))); } } // ----- place the buttons: @@ -245,7 +245,7 @@ kMyMoneyCalendar::resizeEvent(QResizeEvent*) } // ----- place the line edit for direct input: - sizes[0]=line->sizeHint(); + sizes[0]=line->tqsizeHint(); int week_width=d->selectWeek->fontMetrics().width(i18n("Week XX"))+((d->closeButton != 0L) ? 50 : 20); line->setGeometry(0, height()-sizes[0].height(), width()-week_width, sizes[0].height()); d->selectWeek->setGeometry(width()-week_width, height()-sizes[0].height(), week_width, sizes[0].height()); @@ -257,11 +257,11 @@ kMyMoneyCalendar::resizeEvent(QResizeEvent*) } void -kMyMoneyCalendar::dateChangedSlot(QDate date) +kMyMoneyCalendar::dateChangedSlot(TQDate date) { kdDebug() << "kMyMoneyCalendar::dateChangedSlot: date changed (" << date.year() << "/" << date.month() << "/" << date.day() << ")." << endl; line->setText(KGlobal::locale()->formatDate(date, true)); - d->selectWeek->setText(i18n("Week %1").arg(weekOfYear(date))); + d->selectWeek->setText(i18n("Week %1").tqarg(weekOfYear(date))); selectMonth->setText(MONTH_NAME(date.month(), date.year(), false)); selectYear->setText(date.toString("yyyy")); emit(dateChanged(date)); @@ -275,29 +275,29 @@ kMyMoneyCalendar::tableClickedSlot() emit(tableClicked()); } -const QDate& +const TQDate& kMyMoneyCalendar::getDate() const { return table->getDate(); } -const QDate & +const TQDate & kMyMoneyCalendar::date() const { return table->getDate(); } bool -kMyMoneyCalendar::setDate(const QDate& date) +kMyMoneyCalendar::setDate(const TQDate& date) { if (!table) return true; // hack if(date.isValid()) { - QString temp; + TQString temp; // ----- table->setDate(date); - d->selectWeek->setText(i18n("Week %1").arg(weekOfYear(date))); + d->selectWeek->setText(i18n("Week %1").tqarg(weekOfYear(date))); selectMonth->setText(MONTH_NAME(date.month(), date.year(), false)); temp.setNum(date.year()); selectYear->setText(temp); @@ -341,13 +341,13 @@ kMyMoneyCalendar::selectWeekClicked() KPopupFrame* popup = new KPopupFrame(this); KDateInternalWeekSelector* picker = new KDateInternalWeekSelector(/*fontsize, */popup); // ----- - picker->resize(picker->sizeHint()); + picker->resize(picker->tqsizeHint()); popup->setMainWidget(picker); - connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); + connect(picker, TQT_SIGNAL(closeMe(int)), popup, TQT_SLOT(close(int))); picker->setFocus(); - if(popup->exec(d->selectWeek->mapToGlobal(QPoint(0, d->selectWeek->height())))) + if(popup->exec(d->selectWeek->mapToGlobal(TQPoint(0, d->selectWeek->height())))) { - QDate date; + TQDate date; int year; // ----- week=picker->getWeek(); @@ -380,13 +380,13 @@ kMyMoneyCalendar::selectMonthClicked() KPopupFrame* popup = new KPopupFrame(this); KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(/*fontsize, */popup); // ----- - picker->resize(picker->sizeHint()); + picker->resize(picker->tqsizeHint()); popup->setMainWidget(picker); picker->setFocus(); - connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); - if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) + connect(picker, TQT_SIGNAL(closeMe(int)), popup, TQT_SLOT(close(int))); + if(popup->exec(selectMonth->mapToGlobal(TQPoint(0, selectMonth->height())))) { - QDate date; + TQDate date; int day; // ----- month=picker->getResult(); @@ -394,7 +394,7 @@ kMyMoneyCalendar::selectMonthClicked() day=date.day(); // ----- construct a valid date in this month: date.setYMD(date.year(), month, 1); - date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); + date.setYMD(date.year(), month, TQMIN(day, date.daysInMonth())); // ----- set this month setDate(date); } else { @@ -412,13 +412,13 @@ kMyMoneyCalendar::selectYearClicked() KPopupFrame* popup = new KPopupFrame(this); KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup); // ----- - picker->resize(picker->sizeHint()); + picker->resize(picker->tqsizeHint()); popup->setMainWidget(picker); - connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); + connect(picker, TQT_SIGNAL(closeMe(int)), popup, TQT_SLOT(close(int))); picker->setFocus(); - if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) + if(popup->exec(selectYear->mapToGlobal(TQPoint(0, selectMonth->height())))) { - QDate date; + TQDate date; int day; // ----- year=picker->getYear(); @@ -426,7 +426,7 @@ kMyMoneyCalendar::selectYearClicked() day=date.day(); // ----- construct a valid date in this month: date.setYMD(year, date.month(), 1); - date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); + date.setYMD(year, date.month(), TQMIN(day, date.daysInMonth())); // ----- set this month setDate(date); } else { @@ -439,7 +439,7 @@ kMyMoneyCalendar::selectYearClicked() void kMyMoneyCalendar::setEnabled(bool enable) { - QWidget *widgets[]= { + TQWidget *widgets[]= { styleControl, yearForward, yearBackward, monthForward, monthBackward, selectMonth, selectYear, line, table, d->selectWeek, d->userButton1, d->userButton2 }; @@ -456,9 +456,9 @@ kMyMoneyCalendar::setEnabled(bool enable) void kMyMoneyCalendar::lineEnterPressed() { - QDate temp; + TQDate temp; // ----- - if(val->date(line->text(), temp)==QValidator::Acceptable) + if(val->date(line->text(), temp)==TQValidator::Acceptable) { kdDebug() << "kMyMoneyCalendar::lineEnterPressed: valid date entered." << endl; emit(dateEntered(temp)); @@ -469,11 +469,11 @@ kMyMoneyCalendar::lineEnterPressed() } } -QSize -kMyMoneyCalendar::sizeHint() const +TQSize +kMyMoneyCalendar::tqsizeHint() const { - QSize tableSize=table->sizeHint(); - QWidget *buttons[]={ + TQSize tableSize=table->tqsizeHint(); + TQWidget *buttons[]={ styleControl, yearBackward, monthBackward, @@ -486,30 +486,30 @@ kMyMoneyCalendar::sizeHint() const d->userButton2 }; const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); - QSize sizes[NoOfButtons]; + TQSize sizes[NoOfButtons]; int cx=0, cy=0, count; // ----- store the size hints: for(count=0; count<NoOfButtons; ++count) { if ( buttons[count] ) - sizes[count]=buttons[count]->sizeHint(); + sizes[count]=buttons[count]->tqsizeHint(); else - sizes[count] = QSize(0,0); + sizes[count] = TQSize(0,0); if(buttons[count]==selectMonth) { - QSize metricBound = style().sizeFromContents(QStyle::CT_ToolButton, selectMonth, maxMonthRect); - cx+=QMAX(metricBound.width(), maxMonthRect.width()+2*QApplication::style().pixelMetric(QStyle::PM_ButtonMargin)); + TQSize metricBound = tqstyle().tqsizeFromContents(TQStyle::CT_ToolButton, selectMonth, maxMonthRect); + cx+=TQMAX(metricBound.width(), maxMonthRect.width()+2*TQApplication::tqstyle().tqpixelMetric(TQStyle::PM_ButtonMargin)); } else { cx+=sizes[count].width(); } - cy=QMAX(sizes[count].height(), cy); + cy=TQMAX(sizes[count].height(), cy); } // ----- calculate width hint: - cx=QMAX(cx, tableSize.width()); // line edit ignored + cx=TQMAX(cx, tableSize.width()); // line edit ignored // ----- calculate height hint: - cy+=tableSize.height()+line->sizeHint().height(); - return QSize(cx, cy); + cy+=tableSize.height()+line->tqsizeHint().height(); + return TQSize(cx, cy); } void @@ -517,7 +517,7 @@ kMyMoneyCalendar::setFontSize(int s) { if (table) { - QWidget *buttons[]= { + TQWidget *buttons[]= { // styleControl // yearBackward, // monthBackward, @@ -528,8 +528,8 @@ kMyMoneyCalendar::setFontSize(int s) }; const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); int count; - QFont font; - QRect r; + TQFont font; + TQRect r; // ----- fontsize=s; for(count=0; count<NoOfButtons; ++count) @@ -538,12 +538,12 @@ kMyMoneyCalendar::setFontSize(int s) font.setPointSize(s); buttons[count]->setFont(font); } - QFontMetrics metrics(selectMonth->fontMetrics()); + TQFontMetrics metrics(selectMonth->fontMetrics()); for(int i=1; i <= 12; ++i) - { // maxMonthRect is used by sizeHint() + { // maxMonthRect is used by tqsizeHint() r=metrics.boundingRect(MONTH_NAME(i, 2000, false)); - maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width())); - maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height())); + maxMonthRect.setWidth(TQMAX(r.width(), maxMonthRect.width())); + maxMonthRect.setHeight(TQMAX(r.height(), maxMonthRect.height())); } table->setFontSize(s); } @@ -556,11 +556,11 @@ kMyMoneyCalendar::setCloseButton( bool enable ) return; if ( enable ) { - d->closeButton = new QToolButton( this ); - QToolTip::add(d->closeButton, i18n("Close")); + d->closeButton = new TQToolButton( this ); + TQToolTip::add(d->closeButton, i18n("Close")); d->closeButton->setPixmap( SmallIcon("remove") ); - connect( d->closeButton, SIGNAL( clicked() ), - topLevelWidget(), SLOT( close() ) ); + connect( d->closeButton, TQT_SIGNAL( clicked() ), + tqtopLevelWidget(), TQT_SLOT( close() ) ); } else { delete d->closeButton; @@ -575,23 +575,23 @@ bool kMyMoneyCalendar::hasCloseButton() const return (d->closeButton != 0L); } -int kMyMoneyCalendar::weekOfYear(QDate date) +int kMyMoneyCalendar::weekOfYear(TQDate date) { // Calculate ISO 8601 week number (taken from glibc/Gnumeric) int year, week, wday, jan1wday, nextjan1wday; - QDate jan1date, nextjan1date; + TQDate jan1date, nextjan1date; year=date.year(); wday=date.dayOfWeek(); - jan1date=QDate(year,1,1); + jan1date=TQDate(year,1,1); jan1wday=jan1date.dayOfWeek(); week = (date.dayOfYear()-1 + jan1wday-1)/7 + ((jan1wday-1) == 0 ? 1 : 0); /* Does date belong to last week of previous year? */ if ((week == 0) && (jan1wday > 4 /*THURSDAY*/)) { - QDate tmpdate=QDate(year-1,12,31); + TQDate tmpdate=TQDate(year-1,12,31); return weekOfYear(tmpdate); } @@ -599,7 +599,7 @@ int kMyMoneyCalendar::weekOfYear(QDate date) week++; if (week == 53) { - nextjan1date=QDate(year+1, 1, 1); + nextjan1date=TQDate(year+1, 1, 1); nextjan1wday = nextjan1date.dayOfWeek(); if (nextjan1wday <= 4 /*THURSDAY*/) week = 1; @@ -623,10 +623,10 @@ void kMyMoneyCalendar::slotSetStyleMonthly() void kMyMoneyCalendar::slotSetStyleQuarterly() { - setType(kMyMoneyDateTbl::QUARTERLY); + setType(kMyMoneyDateTbl::TQUARTERLY); } -void kMyMoneyCalendar::setUserButton1(bool enable, QPushButton* pb) +void kMyMoneyCalendar::setUserButton1(bool enable, TQPushButton* pb) { if ( enable == (d->userButton1 != 0L) ) return; @@ -642,7 +642,7 @@ void kMyMoneyCalendar::setUserButton1(bool enable, QPushButton* pb) updateGeometry(); } -void kMyMoneyCalendar::setUserButton2(bool enable, QPushButton* pb) +void kMyMoneyCalendar::setUserButton2(bool enable, TQPushButton* pb) { if ( enable == (d->userButton2 != 0L) ) return; |