diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
commit | f008adb5a77e094eaf6abf3fc0f36958e66896a5 (patch) | |
tree | 8e9244c4d4957c36be81e15b566b4aa5ea26c982 /kplato/kptcalendarpanel.cc | |
parent | 1210f27b660efb7b37ff43ec68763e85a403471f (diff) | |
download | koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.tar.gz koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.zip |
TQt4 port koffice
This should enable compilation under both Qt3 and Qt4; fixes for any missed components will be forthcoming
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238284 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kplato/kptcalendarpanel.cc')
-rw-r--r-- | kplato/kptcalendarpanel.cc | 242 |
1 files changed, 121 insertions, 121 deletions
diff --git a/kplato/kptcalendarpanel.cc b/kplato/kptcalendarpanel.cc index 2090699c..6dfba278 100644 --- a/kplato/kptcalendarpanel.cc +++ b/kplato/kptcalendarpanel.cc @@ -31,15 +31,15 @@ #include <klocale.h> #include <kcalendarsystem.h> #include <kiconloader.h> -#include <qframe.h> -#include <qpainter.h> -#include <qdialog.h> -#include <qstyle.h> -#include <qtoolbutton.h> -#include <qtooltip.h> -#include <qfont.h> +#include <tqframe.h> +#include <tqpainter.h> +#include <tqdialog.h> +#include <tqstyle.h> +#include <tqtoolbutton.h> +#include <tqtooltip.h> +#include <tqfont.h> #include <klineedit.h> -#include <qvalidator.h> +#include <tqvalidator.h> #include <kdebug.h> #include <knotifyclient.h> @@ -51,70 +51,70 @@ class CalendarPanel::CalendarPanelPrivate public: CalendarPanelPrivate() : closeButton(0L), selectWeek(0L) {} - QToolButton *closeButton; - QToolButton *selectWeek; + TQToolButton *closeButton; + TQToolButton *selectWeek; }; -CalendarPanel::CalendarPanel(QWidget *parent, QDate dt, const char *name, WFlags f) - : QFrame(parent,name, f) +CalendarPanel::CalendarPanel(TQWidget *tqparent, TQDate dt, const char *name, WFlags f) + : TQFrame(tqparent,name, f) { init( dt ); } -CalendarPanel::CalendarPanel( QWidget *parent, const char *name ) - : QFrame(parent,name) +CalendarPanel::CalendarPanel( TQWidget *tqparent, const char *name ) + : TQFrame(tqparent,name) { - init( QDate::currentDate() ); + init( TQDate::tqcurrentDate() ); } -void CalendarPanel::init( const QDate &dt ) +void CalendarPanel::init( const TQDate &dt ) { - yearForward = new QToolButton(this); - yearBackward = new QToolButton(this); - monthForward = new QToolButton(this); - monthBackward = new QToolButton(this); - selectMonth = new QToolButton(this); - selectYear = new QToolButton(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 DateValidator(this); table = new DateTable(this, dt, "Calendar table", 0); fontsize = 10; d = new CalendarPanelPrivate(); - d->selectWeek = new QToolButton( this ); + d->selectWeek = new TQToolButton( this ); - 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(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, SIGNAL(weekdaySelected(int)), SLOT(slotWeekdaySelected(int))); - connect(table, SIGNAL(weekSelected(int, int)), SLOT(slotWeekSelected(int, int))); - connect(table, SIGNAL(selectionCleared()), SLOT(slotSelectionCleared())); + 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())); + + connect(table, TQT_SIGNAL(weekdaySelected(int)), TQT_SLOT(slotWeekdaySelected(int))); + connect(table, TQT_SIGNAL(weekSelected(int, int)), TQT_SLOT(slotWeekSelected(int, int))); + connect(table, TQT_SIGNAL(selectionCleared()), TQT_SLOT(slotSelectionCleared())); table->setFocus(); } @@ -125,28 +125,28 @@ CalendarPanel::~CalendarPanel() } bool -CalendarPanel::eventFilter(QObject *o, QEvent *e ) +CalendarPanel::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 -CalendarPanel::resizeEvent(QResizeEvent*) +CalendarPanel::resizeEvent(TQResizeEvent*) { - QWidget *buttons[] = { + TQWidget *buttons[] = { yearBackward, monthBackward, selectMonth, @@ -156,7 +156,7 @@ CalendarPanel::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=0; @@ -164,18 +164,18 @@ CalendarPanel::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))); } } // ----- center buttons @@ -184,7 +184,7 @@ CalendarPanel::resizeEvent(QResizeEvent*) { w +=sizes[count].width(); } - x = (QMAX(w, width())-w)/2; + x = (TQMAX(w, width())-w)/2; // ----- place the buttons: for(count=0; count<NoOfButtons; ++count) @@ -195,7 +195,7 @@ CalendarPanel::resizeEvent(QResizeEvent*) x+=w; } // ----- 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()); @@ -205,11 +205,11 @@ CalendarPanel::resizeEvent(QResizeEvent*) } void -CalendarPanel::dateChangedSlot(QDate date) +CalendarPanel::dateChangedSlot(TQDate date) { //kdDebug() << "CalendarPanel::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(KGlobal::locale()->calendar()->monthName(date.month(), false)); selectYear->setText(date.toString("yyyy")); emit(dateChanged(date)); @@ -223,26 +223,26 @@ CalendarPanel::tableClickedSlot() emit(tableClicked()); } -const QDate& +const TQDate& CalendarPanel::getDate() const { return table->getDate(); } -const QDate & +const TQDate & CalendarPanel::date() const { return table->getDate(); } bool -CalendarPanel::setDate(const QDate& date) +CalendarPanel::setDate(const TQDate& date) { 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(KGlobal::locale()->calendar()->monthName(date.month(), false)); temp.setNum(date.year()); selectYear->setText(temp); @@ -285,13 +285,13 @@ CalendarPanel::selectWeekClicked() PopupFrame* popup = new PopupFrame(this); DateInternalWeekSelector* picker = new DateInternalWeekSelector(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(); @@ -322,13 +322,13 @@ CalendarPanel::selectMonthClicked() PopupFrame* popup = new PopupFrame(this); DateInternalMonthPicker* picker = new DateInternalMonthPicker(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(); @@ -336,7 +336,7 @@ CalendarPanel::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 { @@ -352,13 +352,13 @@ CalendarPanel::selectYearClicked() PopupFrame* popup = new PopupFrame(this); DateInternalYearSelector* picker = new DateInternalYearSelector(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(); @@ -366,7 +366,7 @@ CalendarPanel::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 { @@ -378,7 +378,7 @@ CalendarPanel::selectYearClicked() void CalendarPanel::setEnabled(bool enable) { - QWidget *widgets[]= { + TQWidget *widgets[]= { yearForward, yearBackward, monthForward, monthBackward, selectMonth, selectYear, line, table, d->selectWeek }; @@ -395,9 +395,9 @@ CalendarPanel::setEnabled(bool enable) void CalendarPanel::lineEnterPressed() { - QDate temp; + TQDate temp; // ----- - if(val->date(line->text(), temp)==QValidator::Acceptable) + if(val->date(line->text(), temp)==TQValidator::Acceptable) { //kdDebug() << "CalendarPanel::lineEnterPressed: valid date entered." << endl; emit(dateEntered(temp)); @@ -408,11 +408,11 @@ CalendarPanel::lineEnterPressed() } } -QSize -CalendarPanel::sizeHint() const +TQSize +CalendarPanel::tqsizeHint() const { - QSize tableSize=table->sizeHint(); - QWidget *buttons[]={ + TQSize tableSize=table->tqsizeHint(); + TQWidget *buttons[]={ yearBackward, monthBackward, selectMonth, @@ -422,34 +422,34 @@ CalendarPanel::sizeHint() const d->closeButton }; 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 CalendarPanel::setFontSize(int s) { - QWidget *buttons[]= { + TQWidget *buttons[]= { // yearBackward, // monthBackward, selectMonth, @@ -459,8 +459,8 @@ CalendarPanel::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) @@ -469,12 +469,12 @@ CalendarPanel::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(KGlobal::locale()->calendar()->monthName(i, 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); } @@ -486,11 +486,11 @@ CalendarPanel::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; @@ -505,23 +505,23 @@ bool CalendarPanel::hasCloseButton() const return (d->closeButton != 0L); } -int CalendarPanel::weekOfYear(QDate date) +int CalendarPanel::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); } @@ -529,7 +529,7 @@ int CalendarPanel::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; @@ -553,7 +553,7 @@ void CalendarPanel::setCalendar(Calendar *cal) { table->clear(); if (cal) { table->setMarkedWeekdays(cal->weekdaysMap()); - QPtrListIterator<CalendarDay> it = cal->days(); + TQPtrListIterator<CalendarDay> it = cal->days(); //kdDebug()<<k_funcinfo<<"Days="<<it.count()<<endl; for (; it.current(); ++it) { if (it.current()->state() != Map::None) { |