summaryrefslogtreecommitdiffstats
path: root/kmymoney2/widgets/kmymoneydatetbl.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/kmymoneydatetbl.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/kmymoneydatetbl.cpp')
-rw-r--r--kmymoney2/widgets/kmymoneydatetbl.cpp212
1 files changed, 79 insertions, 133 deletions
diff --git a/kmymoney2/widgets/kmymoneydatetbl.cpp b/kmymoney2/widgets/kmymoneydatetbl.cpp
index e48e01e..08a44e6 100644
--- a/kmymoney2/widgets/kmymoneydatetbl.cpp
+++ b/kmymoney2/widgets/kmymoneydatetbl.cpp
@@ -44,12 +44,12 @@
// ----------------------------------------------------------------------------
// QT Includes
-#include <qglobal.h>
-#include <qdatetime.h>
-#include <qstring.h>
-#include <qpen.h>
-#include <qpainter.h>
-#include <qdialog.h>
+#include <tqglobal.h>
+#include <tqdatetime.h>
+#include <tqstring.h>
+#include <tqpen.h>
+#include <tqpainter.h>
+#include <tqdialog.h>
// ----------------------------------------------------------------------------
// KDE Includes
@@ -69,8 +69,8 @@
// Project Includes
#include "kmymoneydatetbl.h"
-kMyMoneyDateTbl::kMyMoneyDateTbl(QWidget *parent, QDate date_, const char* name, WFlags f)
- : QGridView(parent, name, f)
+kMyMoneyDateTbl::kMyMoneyDateTbl(TQWidget *tqparent, TQDate date_, const char* name, WFlags f)
+ : TQGridView(tqparent, name, f)
{
// call this first to make sure that member variables are initialized
setType(MONTHLY);
@@ -80,9 +80,9 @@ kMyMoneyDateTbl::kMyMoneyDateTbl(QWidget *parent, QDate date_, const char* name,
if(!date_.isValid())
{
kdDebug() << "kMyMoneyDateTbl ctor: WARNING: Given date is invalid, using current date." << endl;
- date_=QDate::currentDate();
+ date_=TQDate::tqcurrentDate();
}
- setFocusPolicy( QWidget::StrongFocus );
+ setFocusPolicy( TQ_StrongFocus );
viewport()->setEraseColor(KGlobalSettings::baseColor());
@@ -90,21 +90,21 @@ kMyMoneyDateTbl::kMyMoneyDateTbl(QWidget *parent, QDate date_, const char* name,
setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth
// So we can emit hoverDate
-// QApplication::setGlobalMouseTracking(true);
+// TQApplication::setGlobalMouseTracking(true);
viewport()->setMouseTracking(true);
}
void
-kMyMoneyDateTbl::paintCell(QPainter *painter, int row, int col)
+kMyMoneyDateTbl::paintCell(TQPainter *painter, int row, int col)
{
- QRect rect;
- QString text;
- QPen pen;
+ TQRect rect;
+ TQString text;
+ TQPen pen;
int w=cellWidth();
int h=cellHeight();
- QBrush brushBlue(KGlobalSettings::activeTitleColor());
- QBrush brushLightblue(KGlobalSettings::baseColor());
- QFont font=KGlobalSettings::generalFont();
+ TQBrush brushBlue(KGlobalSettings::activeTitleColor());
+ TQBrush brushLightblue(KGlobalSettings::baseColor());
+ TQFont font=KGlobalSettings::generalFont();
// -----
font.setPointSize(fontsize);
@@ -122,7 +122,7 @@ kMyMoneyDateTbl::paintCell(QPainter *painter, int row, int col)
font.setBold(true);
painter->setFont(font);
bool normalday = true;
- QString daystr;
+ TQString daystr;
if ( col+firstWeekDay < 8 )
daystr = WEEK_DAY_NAME(col+firstWeekDay, true);
else
@@ -163,22 +163,13 @@ kMyMoneyDateTbl::paintCell(QPainter *painter, int row, int col)
painter->setPen(KGlobalSettings::activeTextColor());
int year=date.year();
- QString headerText;
-#if QT_VERSION > 0x030005
+ TQString headerText;
// FIXME: Shouldn't that be i18n()'ed as well
- QString weekStr = QString::number(date.weekNumber(&year));
- QString yearStr = QString::number(year);
+ TQString weekStr = TQString::number(date.weekNumber(&year));
+ TQString yearStr = TQString::number(year);
headerText = i18n("Week %1 for year %2.")
- .arg(weekStr)
- .arg(yearStr);
-#else
- // FIXME: include code to display the same as for KDE >= 3.0.5
- QString weekStr = QString::number(weekNumber(date, &year));
- QString yearStr = QString::number(year);
- headerText = i18n("Week %1 for year %2.")
- .arg(weekStr)
- .arg(yearStr);
-#endif
+ .tqarg(weekStr)
+ .tqarg(yearStr);
painter->drawText(0, 0, w, h-1, AlignCenter, headerText, -1, &rect);
@@ -187,7 +178,7 @@ kMyMoneyDateTbl::paintCell(QPainter *painter, int row, int col)
if(rect.height()>maxCell.height())
maxCell.setHeight(rect.height());
}
- else if (m_type == QUARTERLY)
+ else if (m_type == TQUARTERLY)
{
int athird = width()/3;
@@ -212,7 +203,7 @@ kMyMoneyDateTbl::paintCell(QPainter *painter, int row, int col)
{
int pos;
- QDate drawDate(date);
+ TQDate drawDate(date);
if (m_type == MONTHLY)
{
@@ -245,7 +236,7 @@ kMyMoneyDateTbl::paintCell(QPainter *painter, int row, int col)
else if (m_type == WEEKLY)
{
// TODO: Handle other start weekdays than Monday
- text = QDate::shortDayName(row);
+ text = TQDate::shortDayName(row);
text += " ";
int dayOfWeek = date.dayOfWeek();
@@ -262,7 +253,7 @@ kMyMoneyDateTbl::paintCell(QPainter *painter, int row, int col)
drawDate = date.addDays(diff);
}
- else if (m_type == QUARTERLY)
+ else if (m_type == TQUARTERLY)
{
}
@@ -271,52 +262,52 @@ kMyMoneyDateTbl::paintCell(QPainter *painter, int row, int col)
}
void
-kMyMoneyDateTbl::keyPressEvent( QKeyEvent *e )
+kMyMoneyDateTbl::keyPressEvent( TQKeyEvent *e )
{
- if ( e->key() == Qt::Key_Prior ) {
+ if ( e->key() == TQt::Key_Prior ) {
setDate(date.addMonths(-1));
return;
}
- if ( e->key() == Qt::Key_Next ) {
+ if ( e->key() == TQt::Key_Next ) {
setDate(date.addMonths(1));
return;
}
- if ( e->key() == Qt::Key_Up ) {
+ if ( e->key() == TQt::Key_Up ) {
if ( date.day() > 7 ) {
setDate(date.addDays(-7));
return;
}
}
- if ( e->key() == Qt::Key_Down ) {
+ if ( e->key() == TQt::Key_Down ) {
if ( date.day() <= date.daysInMonth()-7 ) {
setDate(date.addDays(7));
return;
}
}
- if ( e->key() == Qt::Key_Left ) {
+ if ( e->key() == TQt::Key_Left ) {
if ( date.day() > 1 ) {
setDate(date.addDays(-1));
return;
}
}
- if ( e->key() == Qt::Key_Right ) {
+ if ( e->key() == TQt::Key_Right ) {
if ( date.day() < date.daysInMonth() ) {
setDate(date.addDays(1));
return;
}
}
- if ( e->key() == Qt::Key_Minus ) {
+ if ( e->key() == TQt::Key_Minus ) {
setDate(date.addDays(-1));
return;
}
- if ( e->key() == Qt::Key_Plus ) {
+ if ( e->key() == TQt::Key_Plus ) {
setDate(date.addDays(1));
return;
}
- if ( e->key() == Qt::Key_N ) {
- setDate(QDate::currentDate());
+ if ( e->key() == TQt::Key_N ) {
+ setDate(TQDate::tqcurrentDate());
return;
}
@@ -324,10 +315,10 @@ kMyMoneyDateTbl::keyPressEvent( QKeyEvent *e )
}
void
-kMyMoneyDateTbl::viewportResizeEvent(QResizeEvent * e)
+kMyMoneyDateTbl::viewportResizeEvent(TQResizeEvent * e)
{
if (e)
- QGridView::viewportResizeEvent(e);
+ TQGridView::viewportResizeEvent(e);
setCellWidth(viewport()->width()/m_colCount);
setCellHeight(viewport()->height()/m_rowCount);
@@ -337,8 +328,8 @@ void
kMyMoneyDateTbl::setFontSize(int size)
{
int count;
- QFontMetrics metrics(fontMetrics());
- QRect rect;
+ TQFontMetrics metrics(fontMetrics());
+ TQRect rect;
// ----- store rectangles:
fontsize=size;
@@ -350,8 +341,8 @@ kMyMoneyDateTbl::setFontSize(int size)
for(count=0; count<m_colCount; ++count)
{
rect=metrics.boundingRect(WEEK_DAY_NAME(count+1, true));
- maxCell.setWidth(QMAX(maxCell.width(), rect.width()));
- maxCell.setHeight(QMAX(maxCell.height(), rect.height()));
+ maxCell.setWidth(TQMAX(maxCell.width(), rect.width()));
+ maxCell.setHeight(TQMAX(maxCell.height(), rect.height()));
}
if (m_type == WEEKLY)
@@ -361,22 +352,22 @@ kMyMoneyDateTbl::setFontSize(int size)
}
// ----- compare with a real wide number and add some space:
- rect=metrics.boundingRect(QString::fromLatin1("88"));
- maxCell.setWidth(QMAX(maxCell.width()+2, rect.width()));
- maxCell.setHeight(QMAX(maxCell.height()+4, rect.height()));
+ rect=metrics.boundingRect(TQString::tqfromLatin1("88"));
+ maxCell.setWidth(TQMAX(maxCell.width()+2, rect.width()));
+ maxCell.setHeight(TQMAX(maxCell.height()+4, rect.height()));
}
void
-kMyMoneyDateTbl::wheelEvent ( QWheelEvent * e )
+kMyMoneyDateTbl::wheelEvent ( TQWheelEvent * e )
{
setDate(date.addMonths( -(int)(e->delta()/120)) );
e->accept();
}
void
-kMyMoneyDateTbl::contentsMouseReleaseEvent(QMouseEvent *e)
+kMyMoneyDateTbl::contentsMouseReleaseEvent(TQMouseEvent *e)
{
- if (e->type()!=QEvent::MouseButtonRelease)
+ if (e->type()!=TQEvent::MouseButtonRelease)
{ // the KDatePicker only reacts on mouse press events:
return;
}
@@ -395,7 +386,7 @@ kMyMoneyDateTbl::contentsMouseReleaseEvent(QMouseEvent *e)
// -----
int row, col, pos, temp;
- QPoint mouseCoord;
+ TQPoint mouseCoord;
// -----
mouseCoord = e->pos();
@@ -432,7 +423,7 @@ kMyMoneyDateTbl::contentsMouseReleaseEvent(QMouseEvent *e)
}
temp = firstday + date.day() - dayoff % 7 - 1;
- setDate(QDate(date.year(), date.month(), pos - firstday + dayoff % 7));
+ setDate(TQDate(date.year(), date.month(), pos - firstday + dayoff % 7));
updateCell(temp/7+1, temp%7); // Update the previously selected cell
}
@@ -453,7 +444,7 @@ kMyMoneyDateTbl::contentsMouseReleaseEvent(QMouseEvent *e)
setDate(date.addDays(diff));
updateCell(dayOfWeek, 0);
}
- else if (m_type == QUARTERLY)
+ else if (m_type == TQUARTERLY)
{
}
@@ -463,10 +454,10 @@ kMyMoneyDateTbl::contentsMouseReleaseEvent(QMouseEvent *e)
}
bool
-kMyMoneyDateTbl::setDate(const QDate& date_)
+kMyMoneyDateTbl::setDate(const TQDate& date_)
{
bool changed=false;
- QDate temp;
+ TQDate temp;
// -----
if(!date_.isValid())
{
@@ -499,42 +490,42 @@ kMyMoneyDateTbl::setDate(const QDate& date_)
if (changed)
{
- repaintContents(false);
+ tqrepaintContents(false);
}
emit(dateChanged(date));
return true;
}
-const QDate&
+const TQDate&
kMyMoneyDateTbl::getDate() const
{
return date;
}
-// what are those repaintContents() good for? (pfeiffer)
-void kMyMoneyDateTbl::focusInEvent( QFocusEvent *e )
+// what are those tqrepaintContents() good for? (pfeiffer)
+void kMyMoneyDateTbl::focusInEvent( TQFocusEvent *e )
{
-// repaintContents(false);
- QGridView::focusInEvent( e );
+// tqrepaintContents(false);
+ TQGridView::focusInEvent( e );
}
-void kMyMoneyDateTbl::focusOutEvent( QFocusEvent *e )
+void kMyMoneyDateTbl::focusOutEvent( TQFocusEvent *e )
{
-// repaintContents(false);
- QGridView::focusOutEvent( e );
+// tqrepaintContents(false);
+ TQGridView::focusOutEvent( e );
}
-QSize
-kMyMoneyDateTbl::sizeHint() const
+TQSize
+kMyMoneyDateTbl::tqsizeHint() const
{
if (maxCell.height()>0 && maxCell.width()>0)
{
- return QSize(maxCell.width()*numCols()+2*frameWidth(),
+ return TQSize(maxCell.width()*numCols()+2*frameWidth(),
(maxCell.height()+2)*numRows()+2*frameWidth());
} else {
- kdDebug() << "kMyMoneyDateTbl::sizeHint: obscure failure - " << endl;
- return QSize(-1, -1);
+ kdDebug() << "kMyMoneyDateTbl::tqsizeHint: obscure failure - " << endl;
+ return TQSize(-1, -1);
}
}
@@ -547,11 +538,11 @@ void kMyMoneyDateTbl::setType(calendarType type)
m_colCount = 1;
m_type = WEEKLY;
}
- else if (type == QUARTERLY)
+ else if (type == TQUARTERLY)
{
m_rowCount = 7;
m_colCount = 21;
- m_type = QUARTERLY;
+ m_type = TQUARTERLY;
}
else // default to monthly
{
@@ -567,10 +558,10 @@ void kMyMoneyDateTbl::setType(calendarType type)
viewportResizeEvent(NULL);
}
-void kMyMoneyDateTbl::contentsMouseMoveEvent(QMouseEvent* e)
+void kMyMoneyDateTbl::contentsMouseMoveEvent(TQMouseEvent* e)
{
int row, col, pos;
- QPoint mouseCoord;
+ TQPoint mouseCoord;
mouseCoord = e->pos();
row = rowAt(mouseCoord.y());
@@ -586,8 +577,8 @@ void kMyMoneyDateTbl::contentsMouseMoveEvent(QMouseEvent* e)
int firstWeekDay = KGlobal::locale()->weekStartDay();
#endif
- QDate drawDate(date);
- QString text;
+ TQDate drawDate(date);
+ TQString text;
if (m_type == MONTHLY)
{
@@ -620,7 +611,7 @@ void kMyMoneyDateTbl::contentsMouseMoveEvent(QMouseEvent* e)
else if (m_type == WEEKLY)
{
// TODO: Handle other start weekdays than Monday
- text = QDate::shortDayName(row);
+ text = TQDate::shortDayName(row);
text += " ";
int dayOfWeek = date.dayOfWeek();
@@ -637,7 +628,7 @@ void kMyMoneyDateTbl::contentsMouseMoveEvent(QMouseEvent* e)
drawDate = date.addDays(diff);
}
- else if (m_type == QUARTERLY)
+ else if (m_type == TQUARTERLY)
{
}
@@ -647,52 +638,7 @@ void kMyMoneyDateTbl::contentsMouseMoveEvent(QMouseEvent* e)
emit hoverDate(drawDate);
}
- QGridView::contentsMouseMoveEvent(e);
-}
-
-#if QT_VERSION <= 0x030005
-// The following code is borrowed from QT 3.2 QDate::weekNumber()
-// and slightly modified
-int kMyMoneyDateTbl::weekNumber(const QDate& date, int *yearNumber) const
-{
- if ( !date.isValid() )
- return 0;
-
- int dow = date.dayOfWeek();
- int doy = date.dayOfYear();
- int currYear = date.year();
- int jan1WeekDay = QDate( currYear, 1, 1 ).dayOfWeek();
- int yearNum;
- int weekNum;
-
- if ( doy <= (8 - jan1WeekDay) && jan1WeekDay > 4 ) {
- yearNum = currYear - 1;
- weekNum = 52;
- if ( jan1WeekDay == 5 ||
- (jan1WeekDay == 6 && QDate::leapYear(yearNum)) )
- weekNum++;
- } else {
- int totalDays = 365;
- if ( QDate::leapYear(currYear) )
- totalDays++;
-
- if ( (totalDays - doy < 4 - dow)
- || (jan1WeekDay == 7 && totalDays - doy < 3) ) {
- yearNum = currYear + 1;
- weekNum = 1;
- } else {
- int j = doy + ( 7 - dow ) + ( jan1WeekDay - 1 );
- yearNum = currYear;
- weekNum = j / 7;
- if ( jan1WeekDay > 4 )
- weekNum--;
- }
- }
- if ( yearNumber )
- *yearNumber = yearNum;
- return weekNum;
-
+ TQGridView::contentsMouseMoveEvent(e);
}
-#endif
#include "kmymoneydatetbl.moc"