summaryrefslogtreecommitdiffstats
path: root/kmymoney2/widgets/kmymoneydateinput.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-05 06:00:29 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-05 06:00:29 +0000
commitfecb0e67b23e8b83ba7fc881bb57bc48c0852d62 (patch)
tree6b8614802f0d01b353bc9ba78aff2090846c198e /kmymoney2/widgets/kmymoneydateinput.cpp
parentdadc34655c3ab961b0b0b94a10eaaba710f0b5e8 (diff)
downloadkmymoney-fecb0e67b23e8b83ba7fc881bb57bc48c0852d62.tar.gz
kmymoney-fecb0e67b23e8b83ba7fc881bb57bc48c0852d62.zip
TQt4 port kmymoney
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239855 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmymoney2/widgets/kmymoneydateinput.cpp')
-rw-r--r--kmymoney2/widgets/kmymoneydateinput.cpp148
1 files changed, 74 insertions, 74 deletions
diff --git a/kmymoney2/widgets/kmymoneydateinput.cpp b/kmymoney2/widgets/kmymoneydateinput.cpp
index e1b4be8..d0fd547 100644
--- a/kmymoney2/widgets/kmymoneydateinput.cpp
+++ b/kmymoney2/widgets/kmymoneydateinput.cpp
@@ -18,18 +18,18 @@
// ----------------------------------------------------------------------------
// QT Includes
-#include <qpainter.h>
-#include <qdrawutil.h>
-#include <qpoint.h>
-#include <qvalidator.h>
-#include <qtimer.h>
-#include <qstyle.h>
-#include <qlayout.h>
-#include <qapplication.h>
-#include <qdesktopwidget.h>
-#include <qpixmap.h>
-#include <qtimer.h>
-#include <qlabel.h>
+#include <tqpainter.h>
+#include <tqdrawutil.h>
+#include <tqpoint.h>
+#include <tqvalidator.h>
+#include <tqtimer.h>
+#include <tqstyle.h>
+#include <tqlayout.h>
+#include <tqapplication.h>
+#include <tqdesktopwidget.h>
+#include <tqpixmap.h>
+#include <tqtimer.h>
+#include <tqlabel.h>
// ----------------------------------------------------------------------------
// KDE Includes
@@ -50,47 +50,47 @@ namespace {
const int DATE_POPUP_TIMEOUT = 1500;
}
-bool KMyMoneyDateEdit::event(QEvent* e)
+bool KMyMoneyDateEdit::event(TQEvent* e)
{
// make sure that we keep the current date setting of a kMyMoneyDateInput object
- // across the QDateEdit::event(FocusOutEvent)
+ // across the TQDateEdit::event(FocusOutEvent)
bool rc;
- kMyMoneyDateInput* p = dynamic_cast<kMyMoneyDateInput*>(parentWidget());
- if(e->type() == QEvent::FocusOut && p) {
- QDate d = p->date();
- rc = QDateEdit::event(e);
+ kMyMoneyDateInput* p = dynamic_cast<kMyMoneyDateInput*>(tqparentWidget());
+ if(e->type() == TQEvent::FocusOut && p) {
+ TQDate d = p->date();
+ rc = TQDateEdit::event(e);
if(d.isValid())
d = p->date();
p->loadDate(d);
} else {
- rc = QDateEdit::event(e);
+ rc = TQDateEdit::event(e);
}
return rc;
}
-kMyMoneyDateInput::kMyMoneyDateInput(QWidget *parent, const char *name, Qt::AlignmentFlags flags)
- : QHBox(parent,name)
+kMyMoneyDateInput::kMyMoneyDateInput(TQWidget *tqparent, const char *name, TQt::AlignmentFlags flags)
+ : TQHBox(tqparent,name)
{
- m_qtalignment = flags;
- m_date = QDate::currentDate();
+ m_qttqalignment = flags;
+ m_date = TQDate::tqcurrentDate();
dateEdit = new KMyMoneyDateEdit(m_date, this, "dateEdit");
setFocusProxy(dateEdit);
- focusWidget()->installEventFilter(this); // To get dateEdit's FocusIn/Out and some KeyPress events
+ tqfocusWidget()->installEventFilter(this); // To get dateEdit's FocusIn/Out and some KeyPress events
dateEdit->installEventFilter(this); // To get dateEdit's FocusIn/Out and some KeyPress events
m_datePopup = new KPassivePopup(dateEdit, "datePopup");
m_datePopup->setTimeout(DATE_POPUP_TIMEOUT);
- m_datePopup->setView(new QLabel(KGlobal::locale()->formatDate(m_date), m_datePopup, "datePopupLabel"));
+ m_datePopup->setView(new TQLabel(KGlobal::locale()->formatDate(m_date), m_datePopup, "datePopupLabel"));
- m_dateFrame = new QVBox(this, 0, WType_Popup);
- m_dateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
+ m_dateFrame = new TQVBox(this, 0, WType_Popup);
+ m_dateFrame->setFrameStyle(TQFrame::PopupPanel | TQFrame::Raised);
m_dateFrame->setLineWidth(3);
m_dateFrame->hide();
- QString dateFormat = KGlobal::locale()->dateFormatShort().lower();
- QString order, separator;
+ TQString dateFormat = KGlobal::locale()->dateFormatShort().lower();
+ TQString order, separator;
for(unsigned i = 0; i < dateFormat.length(); ++i) {
// DD.MM.YYYY is %d.%m.%y
// dD.mM.YYYY is %e.%n.%y
@@ -110,16 +110,16 @@ kMyMoneyDateInput::kMyMoneyDateInput(QWidget *parent, const char *name, Qt::Alig
// see if we find a known format. If it's unknown, then we use YMD (international)
// set m_focusDatePart to the day position (0-2)
if(order == "mdy") {
- dateEdit->setOrder(QDateEdit::MDY);
+ dateEdit->setOrder(TQDateEdit::MDY);
m_focusDatePart = 1;
} else if(order == "dmy") {
- dateEdit->setOrder(QDateEdit::DMY);
+ dateEdit->setOrder(TQDateEdit::DMY);
m_focusDatePart = 0;
} else if(order == "ydm") {
- dateEdit->setOrder(QDateEdit::YDM);
+ dateEdit->setOrder(TQDateEdit::YDM);
m_focusDatePart = 1;
} else {
- dateEdit->setOrder(QDateEdit::YMD);
+ dateEdit->setOrder(TQDateEdit::YMD);
m_focusDatePart = 2;
separator = '-';
}
@@ -132,46 +132,46 @@ kMyMoneyDateInput::kMyMoneyDateInput(QWidget *parent, const char *name, Qt::Alig
#endif
// the next line is a try to add an icon to the button
- m_dateButton = new KPushButton(QIconSet(QPixmap(KGlobal::iconLoader()->iconPath("date", -KIcon::SizeSmall))), QString(""), this);
+ m_dateButton = new KPushButton(TQIconSet(TQPixmap(KGlobal::iconLoader()->iconPath("date", -KIcon::SizeSmall))), TQString(""), this);
m_dateButton->setMinimumWidth(30);
- connect(m_dateButton,SIGNAL(clicked()),SLOT(toggleDatePicker()));
- connect(dateEdit, SIGNAL(valueChanged(const QDate&)), this, SLOT(slotDateChosenRef(const QDate&)));
- connect(m_datePicker, SIGNAL(dateSelected(QDate)), this, SLOT(slotDateChosen(QDate)));
- connect(m_datePicker, SIGNAL(dateEntered(QDate)), this, SLOT(slotDateChosen(QDate)));
- connect(m_datePicker, SIGNAL(dateSelected(QDate)), m_dateFrame, SLOT(hide()));
+ connect(m_dateButton,TQT_SIGNAL(clicked()),TQT_SLOT(toggleDatePicker()));
+ connect(dateEdit, TQT_SIGNAL(valueChanged(const TQDate&)), this, TQT_SLOT(slotDateChosenRef(const TQDate&)));
+ connect(m_datePicker, TQT_SIGNAL(dateSelected(TQDate)), this, TQT_SLOT(slotDateChosen(TQDate)));
+ connect(m_datePicker, TQT_SIGNAL(dateEntered(TQDate)), this, TQT_SLOT(slotDateChosen(TQDate)));
+ connect(m_datePicker, TQT_SIGNAL(dateSelected(TQDate)), m_dateFrame, TQT_SLOT(hide()));
}
-void kMyMoneyDateInput::markAsBadDate(bool bad, const QColor& color)
+void kMyMoneyDateInput::markAsBadDate(bool bad, const TQColor& color)
{
if(dateEdit->focusProxy()) {
- dateEdit->focusProxy()->setPaletteForegroundColor(paletteForegroundColor());
+ TQT_TQWIDGET(dateEdit->focusProxy())->setPaletteForegroundColor(paletteForegroundColor());
if(bad)
- dateEdit->focusProxy()->setPaletteForegroundColor(color);
+ TQT_TQWIDGET(dateEdit->focusProxy())->setPaletteForegroundColor(color);
}
}
void kMyMoneyDateInput::show(void)
{
// don't forget the standard behaviour ;-)
- QHBox::show();
+ TQHBox::show();
// If the widget is shown, the size must be fixed a little later
// to be appropriate. I saw this in some other places and the only
// way to solve this problem is to postpone the setup of the size
// to the time when the widget is on the screen.
- QTimer::singleShot(50, this, SLOT(fixSize()));
+ TQTimer::singleShot(50, this, TQT_SLOT(fixSize()));
}
void kMyMoneyDateInput::fixSize(void)
{
- // According to a hint in the documentation of KDatePicker::sizeHint()
+ // According to a hint in the documentation of KDatePicker::tqsizeHint()
// 28 pixels should be added in each direction to obtain a better
// display of the month button. I decided, (22,14) is good
// enough and save some space on the screen (ipwizard)
- m_dateFrame->setFixedSize(m_datePicker->sizeHint() + QSize(22, 14));
+ m_dateFrame->setFixedSize(m_datePicker->tqsizeHint() + TQSize(22, 14));
- dateEdit->setMinimumWidth(dateEdit->minimumSizeHint().width() + 6);
+ dateEdit->setMinimumWidth(dateEdit->tqminimumSizeHint().width() + 6);
}
kMyMoneyDateInput::~kMyMoneyDateInput()
@@ -191,16 +191,16 @@ void kMyMoneyDateInput::toggleDatePicker()
}
else
{
- QPoint tmpPoint = mapToGlobal(m_dateButton->geometry().bottomRight());
+ TQPoint tmpPoint = mapToGlobal(m_dateButton->tqgeometry().bottomRight());
// usually, the datepicker widget is shown underneath the dateEdit widget
// if it does not fit on the screen, we show it above this widget
- if(tmpPoint.y() + h > QApplication::desktop()->height()) {
+ if(tmpPoint.y() + h > TQApplication::desktop()->height()) {
tmpPoint.setY(tmpPoint.y() - h - m_dateButton->height());
}
- if((m_qtalignment == Qt::AlignRight && tmpPoint.x()+w <= QApplication::desktop()->width())
+ if((m_qttqalignment == TQt::AlignRight && tmpPoint.x()+w <= TQApplication::desktop()->width())
|| (tmpPoint.x()-w < 0) )
{
m_dateFrame->setGeometry(tmpPoint.x()-width(), tmpPoint.y(), w, h);
@@ -217,14 +217,14 @@ void kMyMoneyDateInput::toggleDatePicker()
}
else
{
- m_datePicker->setDate(QDate::currentDate());
+ m_datePicker->setDate(TQDate::tqcurrentDate());
}
m_dateFrame->show();
}
}
-void kMyMoneyDateInput::resizeEvent(QResizeEvent* ev)
+void kMyMoneyDateInput::resizeEvent(TQResizeEvent* ev)
{
m_dateButton->setMaximumHeight(ev->size().height());
m_dateButton->setMaximumWidth(ev->size().height());
@@ -234,12 +234,12 @@ void kMyMoneyDateInput::resizeEvent(QResizeEvent* ev)
}
-/** Overriding QWidget::keyPressEvent
+/** Overriding TQWidget::keyPressEvent
*
* increments/decrements the date upon +/- or Up/Down key input
* sets the date to current date when the 'T' key is pressed
*/
-void kMyMoneyDateInput::keyPressEvent(QKeyEvent * k)
+void kMyMoneyDateInput::keyPressEvent(TQKeyEvent * k)
{
KShortcut today(i18n("Enter todays date into date input widget", "T"));
@@ -255,31 +255,31 @@ void kMyMoneyDateInput::keyPressEvent(QKeyEvent * k)
default:
if(today.contains(KKey(k)) || k->key() == Key_T) {
- slotDateChosen(QDate::currentDate());
+ slotDateChosen(TQDate::tqcurrentDate());
}
break;
}
}
/**
- * This function receives all events that are sent to focusWidget().
+ * This function receives all events that are sent to tqfocusWidget().
* Some KeyPress events are intercepted and passed to keyPressEvent.
- * Otherwise they would be consumed by QDateEdit.
+ * Otherwise they would be consumed by TQDateEdit.
*/
-bool kMyMoneyDateInput::eventFilter(QObject *, QEvent *e)
+bool kMyMoneyDateInput::eventFilter(TQObject *, TQEvent *e)
{
- if (e->type() == QEvent::FocusIn) {
+ if (e->type() == TQEvent::FocusIn) {
m_datePopup->show();
// The cast to the base class is needed since setFocusSection
- // is protected in QDateEdit. This causes some logic in
- // QDateEdit::setFocusSection not to be executed but this does
+ // is protected in TQDateEdit. This causes some logic in
+ // TQDateEdit::setFocusSection not to be executed but this does
// not hurt here, because the widget just receives focus.
- static_cast<QDateTimeEditBase *>(dateEdit)->setFocusSection(m_focusDatePart);
+ static_cast<TQDateTimeEditBase *>(dateEdit)->setFocusSection(m_focusDatePart);
}
- else if (e->type() == QEvent::FocusOut)
+ else if (e->type() == TQEvent::FocusOut)
m_datePopup->hide();
- else if (e->type() == QEvent::KeyPress) {
- if (QKeyEvent *k = dynamic_cast<QKeyEvent*>(e)) {
+ else if (e->type() == TQEvent::KeyPress) {
+ if (TQKeyEvent *k = dynamic_cast<TQKeyEvent*>(e)) {
if (k->key() == Key_Minus) {
keyPressEvent(k);
return true;
@@ -290,13 +290,13 @@ bool kMyMoneyDateInput::eventFilter(QObject *, QEvent *e)
return false; // Don't filter the event
}
-void kMyMoneyDateInput::slotDateChosenRef(const QDate& date)
+void kMyMoneyDateInput::slotDateChosenRef(const TQDate& date)
{
if(date.isValid()) {
emit dateChanged(date);
m_date = date;
- QLabel *lbl = static_cast<QLabel*>(m_datePopup->view());
+ TQLabel *lbl = static_cast<TQLabel*>(m_datePopup->view());
lbl->setText(KGlobal::locale()->formatDate(date));
lbl->adjustSize();
if(m_datePopup->isVisible() || hasFocus())
@@ -304,7 +304,7 @@ void kMyMoneyDateInput::slotDateChosenRef(const QDate& date)
}
}
-void kMyMoneyDateInput::slotDateChosen(QDate date)
+void kMyMoneyDateInput::slotDateChosen(TQDate date)
{
if(date.isValid()) {
// the next line implies a call to slotDateChosenRef() above
@@ -312,17 +312,17 @@ void kMyMoneyDateInput::slotDateChosen(QDate date)
}
}
-QDate kMyMoneyDateInput::date(void) const
+TQDate kMyMoneyDateInput::date(void) const
{
return dateEdit->date();
}
-void kMyMoneyDateInput::setDate(QDate date)
+void kMyMoneyDateInput::setDate(TQDate date)
{
slotDateChosen(date);
}
-void kMyMoneyDateInput::loadDate(const QDate& date)
+void kMyMoneyDateInput::loadDate(const TQDate& date)
{
m_date = m_prevDate = date;
@@ -337,11 +337,11 @@ void kMyMoneyDateInput::resetDate(void)
setDate(m_prevDate);
}
-QWidget* kMyMoneyDateInput::focusWidget(void) const
+TQWidget* kMyMoneyDateInput::tqfocusWidget(void) const
{
- QWidget* w = dateEdit;
+ TQWidget* w = dateEdit;
while(w->focusProxy())
- w = w->focusProxy();
+ w = TQT_TQWIDGET(w->focusProxy());
return w;
}