summaryrefslogtreecommitdiffstats
path: root/kdeui/kdatepicker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kdeui/kdatepicker.cpp')
-rw-r--r--kdeui/kdatepicker.cpp218
1 files changed, 109 insertions, 109 deletions
diff --git a/kdeui/kdatepicker.cpp b/kdeui/kdatepicker.cpp
index ae9f97cb7..af9dede01 100644
--- a/kdeui/kdatepicker.cpp
+++ b/kdeui/kdatepicker.cpp
@@ -18,18 +18,18 @@
Boston, MA 02110-1301, USA.
*/
-#include <qlayout.h>
-#include <qframe.h>
-#include <qpainter.h>
-#include <qdialog.h>
-#include <qstyle.h>
-#include <qtoolbutton.h>
-#include <qcombobox.h>
-#include <qtooltip.h>
-#include <qfont.h>
-#include <qvalidator.h>
-#include <qpopupmenu.h>
-#include <qtimer.h>
+#include <tqlayout.h>
+#include <tqframe.h>
+#include <tqpainter.h>
+#include <tqdialog.h>
+#include <tqstyle.h>
+#include <tqtoolbutton.h>
+#include <tqcombobox.h>
+#include <tqtooltip.h>
+#include <tqfont.h>
+#include <tqvalidator.h>
+#include <tqpopupmenu.h>
+#include <tqtimer.h>
#include "kdatepicker.h"
#include <kglobal.h>
@@ -54,15 +54,15 @@ class KDatePicker::KDatePickerPrivate
public:
KDatePickerPrivate() : closeButton(0L), selectWeek(0L), todayButton(0), navigationLayout(0) {}
- void fillWeeksCombo(const QDate &date);
+ void fillWeeksCombo(const TQDate &date);
- QToolButton *closeButton;
- QComboBox *selectWeek;
- QToolButton *todayButton;
- QBoxLayout *navigationLayout;
+ TQToolButton *closeButton;
+ TQComboBox *selectWeek;
+ TQToolButton *todayButton;
+ TQBoxLayout *navigationLayout;
};
-void KDatePicker::fillWeeksCombo(const QDate &date)
+void KDatePicker::fillWeeksCombo(const TQDate &date)
{
// every year can have a different number of weeks
const KCalendarSystem * calendar = KGlobal::locale()->calendar();
@@ -75,17 +75,17 @@ void KDatePicker::fillWeeksCombo(const QDate &date)
// We show all week numbers for all weeks between first day of year to last day of year
// This of course can be a list like 53,1,2..52
- QDate day;
+ TQDate day;
int year = calendar->year(date);
calendar->setYMD(day, year, 1, 1);
int lastMonth = calendar->monthsInYear(day);
- QDate lastDay, firstDayOfLastMonth;
+ TQDate lastDay, firstDayOfLastMonth;
calendar->setYMD(firstDayOfLastMonth, year, lastMonth, 1);
calendar->setYMD(lastDay, year, lastMonth, calendar->daysInMonth(firstDayOfLastMonth));
for (; day <= lastDay ; day = calendar->addDays(day, 7 /*calendar->daysOfWeek()*/) )
{
- QString week = i18n("Week %1").arg(calendar->weekNumber(day, &year));
+ TQString week = i18n("Week %1").arg(calendar->weekNumber(day, &year));
if ( year != calendar->year(day) ) week += "*"; // show that this is a week from a different year
d->selectWeek->insertItem(week);
@@ -96,53 +96,53 @@ void KDatePicker::fillWeeksCombo(const QDate &date)
}
}
-KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name)
- : QFrame(parent,name)
+KDatePicker::KDatePicker(TQWidget *parent, TQDate dt, const char *name)
+ : TQFrame(parent,name)
{
init( dt );
}
-KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name, WFlags f)
- : QFrame(parent,name, f)
+KDatePicker::KDatePicker(TQWidget *parent, TQDate dt, const char *name, WFlags f)
+ : TQFrame(parent,name, f)
{
init( dt );
}
-KDatePicker::KDatePicker( QWidget *parent, const char *name )
- : QFrame(parent,name)
+KDatePicker::KDatePicker( TQWidget *parent, const char *name )
+ : TQFrame(parent,name)
{
- init( QDate::currentDate() );
+ init( TQDate::currentDate() );
}
-void KDatePicker::init( const QDate &dt )
+void KDatePicker::init( const TQDate &dt )
{
d = new KDatePickerPrivate();
- QBoxLayout * topLayout = new QVBoxLayout(this);
+ TQBoxLayout * topLayout = new TQVBoxLayout(this);
- d->navigationLayout = new QHBoxLayout(topLayout);
+ d->navigationLayout = new TQHBoxLayout(topLayout);
d->navigationLayout->addStretch();
- yearBackward = new QToolButton(this);
+ yearBackward = new TQToolButton(this);
yearBackward->setAutoRaise(true);
d->navigationLayout->addWidget(yearBackward);
- monthBackward = new QToolButton(this);
+ monthBackward = new TQToolButton(this);
monthBackward ->setAutoRaise(true);
d->navigationLayout->addWidget(monthBackward);
d->navigationLayout->addSpacing(KDialog::spacingHint());
- selectMonth = new QToolButton(this);
+ selectMonth = new TQToolButton(this);
selectMonth ->setAutoRaise(true);
d->navigationLayout->addWidget(selectMonth);
- selectYear = new QToolButton(this);
+ selectYear = new TQToolButton(this);
selectYear->setToggleButton(true);
selectYear->setAutoRaise(true);
d->navigationLayout->addWidget(selectYear);
d->navigationLayout->addSpacing(KDialog::spacingHint());
- monthForward = new QToolButton(this);
+ monthForward = new TQToolButton(this);
monthForward ->setAutoRaise(true);
d->navigationLayout->addWidget(monthForward);
- yearForward = new QToolButton(this);
+ yearForward = new TQToolButton(this);
yearForward ->setAutoRaise(true);
d->navigationLayout->addWidget(yearForward);
d->navigationLayout->addStretch();
@@ -152,58 +152,58 @@ void KDatePicker::init( const QDate &dt )
table = new KDateTable(this);
fontsize = KGlobalSettings::generalFont().pointSize();
if (fontsize == -1)
- fontsize = QFontInfo(KGlobalSettings::generalFont()).pointSize();
+ fontsize = TQFontInfo(KGlobalSettings::generalFont()).pointSize();
fontsize++; // Make a little bigger
- d->selectWeek = new QComboBox(false, this); // read only week selection
- d->todayButton = new QToolButton(this);
+ d->selectWeek = new TQComboBox(false, this); // read only week selection
+ d->todayButton = new TQToolButton(this);
d->todayButton->setIconSet(SmallIconSet("today"));
- 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"));
- QToolTip::add(d->todayButton, i18n("Select the current day"));
+ 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"));
+ TQToolTip::add(d->todayButton, i18n("Select the current day"));
// -----
setFontSize(fontsize);
line->setValidator(val);
line->installEventFilter( this );
- if ( QApplication::reverseLayout() )
+ if ( TQApplication::reverseLayout() )
{
- yearForward->setIconSet(BarIconSet(QString::fromLatin1("2leftarrow")));
- yearBackward->setIconSet(BarIconSet(QString::fromLatin1("2rightarrow")));
- monthForward->setIconSet(BarIconSet(QString::fromLatin1("1leftarrow")));
- monthBackward->setIconSet(BarIconSet(QString::fromLatin1("1rightarrow")));
+ yearForward->setIconSet(BarIconSet(TQString::fromLatin1("2leftarrow")));
+ yearBackward->setIconSet(BarIconSet(TQString::fromLatin1("2rightarrow")));
+ monthForward->setIconSet(BarIconSet(TQString::fromLatin1("1leftarrow")));
+ monthBackward->setIconSet(BarIconSet(TQString::fromLatin1("1rightarrow")));
}
else
{
- yearForward->setIconSet(BarIconSet(QString::fromLatin1("2rightarrow")));
- yearBackward->setIconSet(BarIconSet(QString::fromLatin1("2leftarrow")));
- monthForward->setIconSet(BarIconSet(QString::fromLatin1("1rightarrow")));
- monthBackward->setIconSet(BarIconSet(QString::fromLatin1("1leftarrow")));
+ yearForward->setIconSet(BarIconSet(TQString::fromLatin1("2rightarrow")));
+ yearBackward->setIconSet(BarIconSet(TQString::fromLatin1("2leftarrow")));
+ monthForward->setIconSet(BarIconSet(TQString::fromLatin1("1rightarrow")));
+ monthBackward->setIconSet(BarIconSet(TQString::fromLatin1("1leftarrow")));
}
- 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(activated(int)), SLOT(weekSelected(int)));
- connect(d->todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked()));
- connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked()));
- connect(selectYear, SIGNAL(toggled(bool)), 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(activated(int)), TQT_SLOT(weekSelected(int)));
+ connect(d->todayButton, TQT_SIGNAL(clicked()), TQT_SLOT(todayButtonClicked()));
+ connect(selectMonth, TQT_SIGNAL(clicked()), TQT_SLOT(selectMonthClicked()));
+ connect(selectYear, TQT_SIGNAL(toggled(bool)), TQT_SLOT(selectYearClicked()));
+ connect(line, TQT_SIGNAL(returnPressed()), TQT_SLOT(lineEnterPressed()));
table->setFocus();
topLayout->addWidget(table);
- QBoxLayout * bottomLayout = new QHBoxLayout(topLayout);
+ TQBoxLayout * bottomLayout = new TQHBoxLayout(topLayout);
bottomLayout->addWidget(d->todayButton);
bottomLayout->addWidget(line);
bottomLayout->addWidget(d->selectWeek);
@@ -218,32 +218,32 @@ KDatePicker::~KDatePicker()
}
bool
-KDatePicker::eventFilter(QObject *o, QEvent *e )
+KDatePicker::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) )
{
- 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
-KDatePicker::resizeEvent(QResizeEvent* e)
+KDatePicker::resizeEvent(TQResizeEvent* e)
{
- QWidget::resizeEvent(e);
+ TQWidget::resizeEvent(e);
}
void
-KDatePicker::dateChangedSlot(QDate date)
+KDatePicker::dateChangedSlot(TQDate date)
{
kdDebug(298) << "KDatePicker::dateChangedSlot: date changed (" << date.year() << "/" << date.month() << "/" << date.day() << ")." << endl;
@@ -254,7 +254,7 @@ KDatePicker::dateChangedSlot(QDate date)
fillWeeksCombo(date);
// calculate the item num in the week combo box; normalize selected day so as if 1.1. is the first day of the week
- QDate firstDay;
+ TQDate firstDay;
calendar->setYMD(firstDay, calendar->year(date), 1, 1);
d->selectWeek->setCurrentItem((calendar->dayOfYear(date) + calendar->dayOfWeek(firstDay) - 2) / 7/*calendar->daysInWeek()*/);
selectYear->setText(calendar->yearString(date, false));
@@ -270,20 +270,20 @@ KDatePicker::tableClickedSlot()
emit(tableClicked());
}
-const QDate&
+const TQDate&
KDatePicker::getDate() const
{
return table->getDate();
}
-const QDate &
+const TQDate &
KDatePicker::date() const
{
return table->getDate();
}
bool
-KDatePicker::setDate(const QDate& date)
+KDatePicker::setDate(const TQDate& date)
{
if(date.isValid())
{
@@ -300,7 +300,7 @@ KDatePicker::setDate(const QDate& date)
void
KDatePicker::monthForwardClicked()
{
- QDate temp;
+ TQDate temp;
temp = KGlobal::locale()->calendar()->addMonths( table->getDate(), 1 );
setDate( temp );
@@ -309,7 +309,7 @@ KDatePicker::monthForwardClicked()
void
KDatePicker::monthBackwardClicked()
{
- QDate temp;
+ TQDate temp;
temp = KGlobal::locale()->calendar()->addMonths( table->getDate(), -1 );
setDate( temp );
@@ -318,7 +318,7 @@ KDatePicker::monthBackwardClicked()
void
KDatePicker::yearForwardClicked()
{
- QDate temp;
+ TQDate temp;
temp = KGlobal::locale()->calendar()->addYears( table->getDate(), 1 );
setDate( temp );
@@ -327,7 +327,7 @@ KDatePicker::yearForwardClicked()
void
KDatePicker::yearBackwardClicked()
{
- QDate temp;
+ TQDate temp;
temp = KGlobal::locale()->calendar()->addYears( table->getDate(), -1 );
setDate( temp );
@@ -340,7 +340,7 @@ KDatePicker::weekSelected(int week)
{
const KCalendarSystem * calendar = KGlobal::locale()->calendar();
- QDate date = table->getDate();
+ TQDate date = table->getDate();
int year = calendar->year(date);
calendar->setYMD(date, year, 1, 1); // first day of selected year
@@ -356,17 +356,17 @@ KDatePicker::selectMonthClicked()
{
// every year can have different month names (in some calendar systems)
const KCalendarSystem * calendar = KGlobal::locale()->calendar();
- QDate date = table->getDate();
+ TQDate date = table->getDate();
int i, month, months = calendar->monthsInYear(date);
- QPopupMenu popup(selectMonth);
+ TQPopupMenu popup(selectMonth);
for (i = 1; i <= months; i++)
popup.insertItem(calendar->monthName(i, calendar->year(date)), i);
popup.setActiveItem(calendar->month(date) - 1);
- if ( (month = popup.exec(selectMonth->mapToGlobal(QPoint(0, 0)), calendar->month(date) - 1)) == -1 ) return; // canceled
+ if ( (month = popup.exec(selectMonth->mapToGlobal(TQPoint(0, 0)), calendar->month(date) - 1)) == -1 ) return; // canceled
int day = calendar->day(date);
// ----- construct a valid date in this month:
@@ -381,7 +381,7 @@ KDatePicker::selectYearClicked()
{
const KCalendarSystem * calendar = KGlobal::locale()->calendar();
- if (selectYear->state() == QButton::Off)
+ if (selectYear->state() == TQButton::Off)
{
return;
}
@@ -394,11 +394,11 @@ KDatePicker::selectYearClicked()
picker->setYear( table->getDate().year() );
picker->selectAll();
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();
@@ -416,7 +416,7 @@ KDatePicker::selectYearClicked()
}
delete popup;
- QTimer::singleShot(0, this, SLOT(ensureSelectYearIsUp()));
+ TQTimer::singleShot(0, this, TQT_SLOT(ensureSelectYearIsUp()));
}
void
@@ -431,7 +431,7 @@ KDatePicker::ensureSelectYearIsUp()
void
KDatePicker::setEnabled(bool enable)
{
- QWidget *widgets[]= {
+ TQWidget *widgets[]= {
yearForward, yearBackward, monthForward, monthBackward,
selectMonth, selectYear,
line, table, d->selectWeek, d->todayButton };
@@ -447,9 +447,9 @@ KDatePicker::setEnabled(bool enable)
void
KDatePicker::lineEnterPressed()
{
- QDate temp;
+ TQDate temp;
// -----
- if(val->date(line->text(), temp)==QValidator::Acceptable)
+ if(val->date(line->text(), temp)==TQValidator::Acceptable)
{
kdDebug(298) << "KDatePicker::lineEnterPressed: valid date entered." << endl;
emit(dateEntered(temp));
@@ -463,19 +463,19 @@ KDatePicker::lineEnterPressed()
void
KDatePicker::todayButtonClicked()
{
- setDate(QDate::currentDate());
+ setDate(TQDate::currentDate());
}
QSize
KDatePicker::sizeHint() const
{
- return QWidget::sizeHint();
+ return TQWidget::sizeHint();
}
void
KDatePicker::setFontSize(int s)
{
- QWidget *buttons[]= {
+ TQWidget *buttons[]= {
// yearBackward,
// monthBackward,
selectMonth,
@@ -485,8 +485,8 @@ KDatePicker::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)
@@ -495,11 +495,11 @@ KDatePicker::setFontSize(int s)
font.setPointSize(s);
buttons[count]->setFont(font);
}
- QFontMetrics metrics(selectMonth->fontMetrics());
+ TQFontMetrics metrics(selectMonth->fontMetrics());
for (int i = 1; ; ++i)
{
- QString str = KGlobal::locale()->calendar()->monthName(i,
+ TQString str = KGlobal::locale()->calendar()->monthName(i,
KGlobal::locale()->calendar()->year(table->getDate()), false);
if (str.isNull()) break;
r=metrics.boundingRect(str);
@@ -507,7 +507,7 @@ KDatePicker::setFontSize(int s)
maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height()));
}
- QSize metricBound = style().sizeFromContents(QStyle::CT_ToolButton,
+ TQSize metricBound = style().sizeFromContents(TQStyle::CT_ToolButton,
selectMonth,
maxMonthRect);
selectMonth->setMinimumSize(metricBound);
@@ -522,14 +522,14 @@ KDatePicker::setCloseButton( bool enable )
return;
if ( enable ) {
- d->closeButton = new QToolButton( this );
+ d->closeButton = new TQToolButton( this );
d->closeButton->setAutoRaise(true);
d->navigationLayout->addSpacing(KDialog::spacingHint());
d->navigationLayout->addWidget(d->closeButton);
- QToolTip::add(d->closeButton, i18n("Close"));
+ 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() ),
+ topLevelWidget(), TQT_SLOT( close() ) );
}
else {
delete d->closeButton;