summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (side-by-side diff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /korganizer/komonthview.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp218
1 files changed, 115 insertions, 103 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 85e9166..ca55c43 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -8,40 +8,52 @@
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <qpopupmenu.h>
+#include <q3popupmenu.h>
#include <qfont.h>
#include <qfontmetrics.h>
-#include <qkeycode.h>
-#include <qhbox.h>
-#include <qvbox.h>
-#include <qwidgetstack.h>
+#include <qnamespace.h>
+#include <q3hbox.h>
+#include <q3vbox.h>
+#include <q3widgetstack.h>
#include <qpushbutton.h>
#include <qtooltip.h>
#include <qpainter.h>
#include <qtimer.h>
-#include <qwhatsthis.h>
+#include <q3whatsthis.h>
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#else
#include <qapplication.h>
+#include <QDesktopWidget>
+//Added by qt3to4:
+#include <QResizeEvent>
+#include <QLabel>
+#include <QPixmap>
+#include <QFocusEvent>
+#include <QMouseEvent>
+#include <QKeyEvent>
+#include <Q3VBoxLayout>
+#include <Q3Frame>
+#include <Q3PointArray>
+#include <Q3PtrList>
#endif
#include <kdebug.h>
#include <klocale.h>
#include <kglobal.h>
#include <kconfig.h>
#include <kiconloader.h>
#include <kcalendarsystem.h>
#ifndef KORG_NOPRINTER
#include "calprinter.h"
@@ -50,202 +62,202 @@
#ifndef KORG_NOPLUGINS
#include "kocore.h"
#endif
#include "koglobals.h"
#include <libkcal/kincidenceformatter.h>
#include "komonthview.h"
#define PIXMAP_SIZE 5
#ifdef DESKTOP_VERSION
QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
#endif
-class KNOWhatsThis :public QWhatsThis
+class KNOWhatsThis :public Q3WhatsThis
{
public:
- KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
+ KNOWhatsThis( KNoScrollListBox* sbox ) : Q3WhatsThis( sbox ), _wid( sbox) { };
//~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
protected:
virtual QString text( const QPoint& p)
{
return _wid->getWhatsThisText(p) ;
};
private:
KNoScrollListBox* _wid;
};
KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
- : QListBox(parent, name, WRepaintNoErase)
+ : Q3ListBox(parent, name, Qt::WNoAutoErase)
{
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
#endif
mBlockDeselect = false;
mWT = new KNOWhatsThis(this);
resetOnFocusIn = true;
- setVScrollBarMode(QScrollView::AlwaysOff);
- setHScrollBarMode(QScrollView::AlwaysOff);
+ setVScrollBarMode(Q3ScrollView::AlwaysOff);
+ setHScrollBarMode(Q3ScrollView::AlwaysOff);
}
KNoScrollListBox::~KNoScrollListBox()
{
#if QT_VERSION >= 0x030000
#else
delete mWT;
#endif
}
void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
{
- QListBox::focusInEvent ( e );
+ Q3ListBox::focusInEvent ( e );
if ( count() ){
int ci = currentItem();
if ( ci < 0 ) ci = 0;
setCurrentItem( ci );
setSelected ( ci, true );
emit highlighted( item ( ci ) );
resetOnFocusIn = true;
if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
- QListBoxItem *fi = firstItem ();
+ Q3ListBoxItem *fi = firstItem ();
if (fi ) {
int ihei = fi->height( this );
int hei = numRows () * ihei;
if ( hei < height() - horizontalScrollBar()->height () ) {
- setVScrollBarMode(QScrollView::AlwaysOff);
+ setVScrollBarMode(Q3ScrollView::AlwaysOff);
}
else
- setVScrollBarMode(QScrollView::Auto);
+ setVScrollBarMode(Q3ScrollView::Auto);
if ( ihei *3 > height() ) {
- setHScrollBarMode(QScrollView::AlwaysOff);
+ setHScrollBarMode(Q3ScrollView::AlwaysOff);
}
else {
- setHScrollBarMode(QScrollView::Auto);
+ setHScrollBarMode(Q3ScrollView::Auto);
}
} else {
- setVScrollBarMode(QScrollView::Auto);
- setHScrollBarMode(QScrollView::Auto);
+ setVScrollBarMode(Q3ScrollView::Auto);
+ setHScrollBarMode(Q3ScrollView::Auto);
}
}
}
}
void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
{
if ( ! mBlockDeselect ) {
int i = currentItem ();
if ( i >= 0 ) {
setSelected ( i, false );
}
- QListBox::focusOutEvent ( e );
+ Q3ListBox::focusOutEvent ( e );
}
- setVScrollBarMode(QScrollView::AlwaysOff);
- setHScrollBarMode(QScrollView::AlwaysOff);
+ setVScrollBarMode(Q3ScrollView::AlwaysOff);
+ setHScrollBarMode(Q3ScrollView::AlwaysOff);
if ( ! mBlockDeselect )
emit highlightIncidence( 0, (MonthViewCell*)this, 0 );
mBlockDeselect = false;
}
QString KNoScrollListBox::getWhatsThisText(QPoint p)
{
- QListBoxItem* item = itemAt ( p );
+ Q3ListBoxItem* item = itemAt ( p );
if ( ! item ) {
return i18n("Click in the cell\nto add an event!");
}
return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
KOPrefs::instance()->mWTshowDetails,
KOPrefs::instance()->mWTshowCreated,
KOPrefs::instance()->mWTshowChanged);
}
void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
{
//qDebug("KNoScrollListBox::keyPressEvent ");
switch(e->key()) {
- case Key_Right:
+ case Qt::Key_Right:
if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
{
e->ignore();
return;
}
scrollBy(10,0);
break;
- case Key_Left:
+ case Qt::Key_Left:
if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
{
e->ignore();
return;
}
scrollBy(-10,0);
break;
- case Key_Up:
+ case Qt::Key_Up:
if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
e->ignore();
break;
}
if ( count() ) {
if ( currentItem() == 0 ) {
emit prevCell();
} else {
setCurrentItem((currentItem()+count()-1)%count());
if(!itemVisible(currentItem())) {
if((unsigned int) currentItem() == (count()-1)) {
setTopItem(currentItem()-numItemsVisible()+1);
} else {
setTopItem(topItem()-1);
}
}
}
}
break;
- case Key_Down:
+ case Qt::Key_Down:
if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
e->ignore();
break;
}
if ( count () ) {
if ( ((uint)currentItem()+1) == count () ) {
emit nextCell();
} else {
setCurrentItem((currentItem()+1)%count());
if(!itemVisible(currentItem())) {
if(currentItem() == 0) {
setTopItem(0);
} else {
setTopItem(topItem()+1);
}
}
}
}
break;
- case Key_I:
+ case Qt::Key_I:
QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
e->ignore();
break;
- case Key_Return:
- case Key_Enter:
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
{
if ( currentItem() >= 0 ) {
emit doubleClicked( item( currentItem() ) );
e->accept();
} else {
e->ignore();
}
}
break;
- case Key_Shift:
+ case Qt::Key_Shift:
emit shiftDown();
break;
default:
e->ignore();
break;
}
}
void KNoScrollListBox::oneDown()
{
if ( count () ) {
if ( ((uint)currentItem()+1) == count () ) {
@@ -257,43 +269,43 @@ void KNoScrollListBox::oneDown()
if(currentItem() == 0) {
setTopItem(0);
} else {
setTopItem(topItem()+1);
}
}
}
}
}
void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
{
switch(e->key()) {
- case Key_Shift:
+ case Qt::Key_Shift:
emit shiftUp();
break;
default:
break;
}
}
void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
{
- QListBox::mousePressEvent(e);
+ Q3ListBox::mousePressEvent(e);
- if(e->button() == RightButton) {
+ if(e->button() == Qt::RightButton) {
emit rightClick();
}
}
MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s)
- : QListBoxItem()
+ : Q3ListBoxItem()
{
mblockRepaint = true;
isWeekItem = KOPrefs::instance()->mMonthViewWeek;
recycle( incidence, s );
}
void MonthViewItem::recycle( Incidence *incidence, const QString & s)
{
mDisplayHighlighted = false;
setText( s );
mMultiday = 0;
mIncidence = incidence;
mRecur = false;
@@ -386,32 +398,32 @@ void MonthViewItem::paint(QPainter *p)
p->setPen( palette().color( QPalette::Normal, sel ? \
QColorGroup::HighlightedText : QColorGroup::Foreground ) );
#endif
QColor textColor = p->pen().color();
if ( mMultiday ) {
int yyy = y+(size/2);
int sizeM = size+2;
p->setBrush( QBrush( textColor ) );
p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
if ( mMultiday == 2 || mMultiday == 3 ) {
- QPointArray pa ( 3 );
+ Q3PointArray pa ( 3 );
pa.setPoint (0, x, yyy );
pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
p->drawPolygon( pa );
}
if ( mMultiday == 2 || mMultiday == 1 ) {
- QPointArray pa ( 3 );
+ Q3PointArray pa ( 3 );
pa.setPoint (0, x+sizeM +sizeM/2, yyy );
pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
p->drawPolygon( pa );
}
if ( mMultiday == 1 ) {
// p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
}
if ( mMultiday == 3 ) {
// p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
@@ -453,33 +465,33 @@ void MonthViewItem::paint(QPainter *p)
} else {
QString pText = text();
if( pText.mid(2,1) == ":" )
pText = pText.mid( 6 );
p->drawText( x, yPos, pText );
if ( mIncidence->cancelled() ) {
int wid = fm.width( pText );
p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
}
}
}
-int MonthViewItem::height(const QListBox *lb) const
+int MonthViewItem::height(const Q3ListBox *lb) const
{
int ret = 10;
if ( lb )
ret = lb->fontMetrics().lineSpacing()+1;
return ret;
}
-int MonthViewItem::width(const QListBox *lb) const
+int MonthViewItem::width(const Q3ListBox *lb) const
{
if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
int size = PIXMAP_SIZE;
if ( QApplication::desktop()->width() < 300 )
size = 3;
int x = 1;
if ( KOPrefs::instance()->mMonthShowIcons ) {
if ( mInfo ) {
x += size + 1;
}
if( mRecur ) {
x += size+1;
@@ -505,56 +517,56 @@ int MonthViewItem::width(const QListBox *lb) const
MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
: KNoScrollListBox( par ),
mMonthView( parent )
{
//QVBoxLayout *topLayout = new QVBoxLayout( this );
currentPalette = 0;
// mLabel = new QLabel( this );QPushButton
mLabel = new QPushButton( this );
//mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
//mLabel->setLineWidth( 1 );
//mLabel->setAlignment( AlignCenter );
mLabel->setFlat( true );
- mLabel->setFocusPolicy(NoFocus);
+ mLabel->setFocusPolicy(Qt::NoFocus);
//mItemList = new KNoScrollListBox( this );
setMinimumSize( 10, 10 );
- setFrameStyle( QFrame::Panel | QFrame::Plain );
+ setFrameStyle( Q3Frame::Panel | Q3Frame::Plain );
setLineWidth( 1 );
//topLayout->addWidget( mItemList );
mLabel->raise();
// QColor( 0,0,255 ) QColor( 160,1600,255 )
mStandardPalette = palette();
mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
enableScrollBars( false );
updateConfig();
//connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
- connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
- SLOT( defaultAction( QListBoxItem * ) ) );
- connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
+ connect( this , SIGNAL( doubleClicked( Q3ListBoxItem *) ),
+ SLOT( defaultAction( Q3ListBoxItem * ) ) );
+ connect( this, SIGNAL( rightButtonPressed( Q3ListBoxItem *,
const QPoint &) ),
- SLOT( contextMenu( QListBoxItem * ) ) );
- connect( this, SIGNAL( highlighted( QListBoxItem *) ),
- SLOT( selection( QListBoxItem * ) ) );
+ SLOT( contextMenu( Q3ListBoxItem * ) ) );
+ connect( this, SIGNAL( highlighted( Q3ListBoxItem *) ),
+ SLOT( selection( Q3ListBoxItem * ) ) );
/*
connect( this, SIGNAL( clicked( QListBoxItem * ) ),
SLOT( selection( QListBoxItem * ) ) );
*/
}
#ifdef DESKTOP_VERSION
QToolTipGroup *MonthViewCell::toolTipGroup()
{
- if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
+ /* TODO:hacker: if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); */
return mToolTipGroup;
}
#endif
void MonthViewCell::setDate( const QDate &date )
{
// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
mDate = date;
//resizeEvent( 0 );
@@ -628,25 +640,25 @@ void MonthViewCell::setHoliday( const QString &holiday )
{
mHolidayString = holiday;
if ( !holiday.isEmpty() ) {
setHoliday( true );
}
}
void MonthViewCell::startUpdateCell()
{
blockSignals( true );
mdayCount = 0;
- setFocusPolicy(NoFocus);
+ setFocusPolicy(Qt::NoFocus);
if ( !mMonthView->isUpdatePossible() )
return;
MonthViewItem *mitem = (MonthViewItem*) firstItem ();
while ( mitem ) {
mitem->setBlockRepaint( true );
mitem = (MonthViewItem *)mitem->next();
}
if ( mAvailItemList.count() > 20 ) {
mAvailItemList.setAutoDelete( true );
mAvailItemList.clear();
mAvailItemList.setAutoDelete( false );
clear();
@@ -683,25 +695,25 @@ void MonthViewCell::startUpdateCell()
mToolTip.append ( mHolidayString );
}
#endif
}
int MonthViewCell::insertEvent(Event *event)
{
bool useToolTips = true;
#ifndef DESKTOP_VERSION
useToolTips = false;
#endif
QString mToolTipText;
- setFocusPolicy(WheelFocus);
+ setFocusPolicy(Qt::WheelFocus);
if ( !(event->doesRecur() == Recurrence::rNone) ) {
if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
return mdayCount;
else
if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
return mdayCount;
}
if ( event->isHoliday()) {
setHoliday( true );
if ( mDate.dayOfWeek() == 7 )
setLineWidth( 3 );
@@ -825,41 +837,41 @@ int MonthViewCell::insertEvent(Event *event)
insertItem( item ,mdayCount);
++mdayCount;
} else {
uint i = mdayCount;
uint pos = mdayCount;
uint itcount = count();
if ( itcount > 1000 ) {
qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount);
itcount = 0;
}
for ( i = pos; i < itcount;++i ) {
// qDebug("i %d mday %u count %d ",i,itcount,mdayCount );
- QListBoxItem* it = this->item ( i );
+ Q3ListBoxItem* it = this->item ( i );
if ( it && text < it->text() ) {
pos = i;
break;
}
++pos;
}
insertItem( item ,pos);
}
if ( useToolTips ) {
mToolTip.append( mToolTipText );
}
return mdayCount;
}
void MonthViewCell::insertTodo(Todo *todo)
{
- setFocusPolicy(WheelFocus);
+ setFocusPolicy(Qt::WheelFocus);
QString text;
if (todo->hasDueDate()) {
if (!todo->doesFloat()) {
text += KGlobal::locale()->formatTime(todo->dtDue().time());
text += " ";
}
}
text += todo->summary();
MonthViewItem *item ;
if ( mAvailItemList.count() ) {
item = mAvailItemList.first();
mAvailItemList.remove( item );
@@ -913,47 +925,47 @@ void MonthViewCell::repaintfinishUpdateCell()
mitem = (MonthViewItem *)mitem->next();
}
blockSignals( false );
}
void MonthViewCell::finishUpdateCell()
{
#ifdef DESKTOP_VERSION
if (mToolTip.count() > 0 ) {
mToolTip.sort();
- QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
+ /* TODO: hacker: QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); */
}
#endif
//sort();
//setMyPalette();
setMyPalette();
resizeEvent( 0 );
}
void MonthViewCell::updateCell()
{
if ( !mMonthView->isUpdatePossible() )
return;
startUpdateCell();
//mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
- QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
+ Q3PtrList<Event> events = mMonthView->calendar()->events( mDate, true );
Event *event;
for( event = events.first(); event; event = events.next() ) { // for event
insertEvent(event);
}
// insert due todos
- QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
+ Q3PtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
Todo *todo;
for(todo = todos.first(); todo; todo = todos.next()) {
insertTodo( todo );
}
finishUpdateCell();
// if ( isVisible())
//qApp->processEvents();
}
void MonthViewCell::updateConfig( bool bigFont ) // = false
{
@@ -983,46 +995,46 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
}
//updateCell();
}
void MonthViewCell::enableScrollBars( bool enabled )
{
return;
if ( enabled ) {
- QListBoxItem *fi = firstItem ();
+ Q3ListBoxItem *fi = firstItem ();
if (fi ) {
int ihei = fi->height( this );
int hei = numRows () * ihei;
if ( hei < height() - horizontalScrollBar()->height () ) {
- setVScrollBarMode(QScrollView::AlwaysOff);
+ setVScrollBarMode(Q3ScrollView::AlwaysOff);
}
else
- setVScrollBarMode(QScrollView::Auto);
+ setVScrollBarMode(Q3ScrollView::Auto);
if ( ihei *3 > height() ) {
- setHScrollBarMode(QScrollView::AlwaysOff);
+ setHScrollBarMode(Q3ScrollView::AlwaysOff);
}
else {
- setHScrollBarMode(QScrollView::Auto);
+ setHScrollBarMode(Q3ScrollView::Auto);
}
} else {
- setVScrollBarMode(QScrollView::Auto);
- setHScrollBarMode(QScrollView::Auto);
+ setVScrollBarMode(Q3ScrollView::Auto);
+ setHScrollBarMode(Q3ScrollView::Auto);
}
} else {
- setVScrollBarMode(QScrollView::AlwaysOff);
- setHScrollBarMode(QScrollView::AlwaysOff);
+ setVScrollBarMode(Q3ScrollView::AlwaysOff);
+ setHScrollBarMode(Q3ScrollView::AlwaysOff);
}
}
Incidence *MonthViewCell::selectedIncidence()
{
int index = currentItem();
if ( index < 0 ) return 0;
MonthViewItem *mitem =
static_cast<MonthViewItem *>( item( index ) );
if ( !mitem ) return 0;
@@ -1074,75 +1086,75 @@ void MonthViewCell::resizeEvent ( QResizeEvent * e )
if ( size > 0 )
verticalScrollBar()->setMaximumHeight( size );
size = width() - mLabel->width() -lineWidth()-1;
if ( size > 0 )
horizontalScrollBar()->setMaximumWidth( size );
mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
//mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
// mItemList->resize ( width(), height () );
if ( e )
KNoScrollListBox::resizeEvent ( e );
}
-void MonthViewCell::defaultAction( QListBoxItem *item )
+void MonthViewCell::defaultAction( Q3ListBoxItem *item )
{
if ( !item ) {
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
return;
}
MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
Incidence *incidence = eventItem->incidence();
if ( incidence ) mMonthView->defaultAction( incidence );
}
void MonthViewCell::showDay()
{
emit showDaySignal( date() );
}
void MonthViewCell::newEvent()
{
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
}
-void MonthViewCell::cellClicked( QListBoxItem *item )
+void MonthViewCell::cellClicked( Q3ListBoxItem *item )
{
mMonthView->setSelectedCell( this );
if ( item == 0 ) {
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
return;
}
}
-void MonthViewCell::contextMenu( QListBoxItem *item )
+void MonthViewCell::contextMenu( Q3ListBoxItem *item )
{
mMonthView->setPopupCell( this );
if ( !item ) {
mMonthView->showContextMenu( 0 );
return;
}
//selection( item );
//qApp->processEvents();
MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
Incidence *incidence = eventItem->incidence();
if ( incidence ) {
mBlockDeselect = true;
mMonthView->showContextMenu( incidence );
}
}
-void MonthViewCell::selection( QListBoxItem *item )
+void MonthViewCell::selection( Q3ListBoxItem *item )
{
if ( !item ) {
emit highlightIncidence( 0 , this, 0 );
return;
}
MonthViewItem * it = (static_cast<MonthViewItem *>( item ));
emit highlightIncidence( it->incidence(), this, it->multiDay() );
mMonthView->setSelectedCell( this );
}
void MonthViewCell::deHighLight()
{
@@ -1176,26 +1188,26 @@ bool MonthViewCell::doHighLight( Incidence * inc )
KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
: KOEventView( calendar, parent, name ),
mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
{
mFlagKeyPressed = false;
mShortDayLabelsM = false;
mShortDayLabelsW = false;
skipResize = false;
clPending = true;
mPopupCell = 0;
mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
- mWidStack = new QWidgetStack( this );
- QVBoxLayout* hb = new QVBoxLayout( this );
+ mWidStack = new Q3WidgetStack( this );
+ Q3VBoxLayout* hb = new Q3VBoxLayout( this );
mMonthView = new QWidget( mWidStack );
mWeekView = new QWidget( mWidStack );
#if QT_VERSION >= 0x030000
mWidStack->addWidget(mMonthView );
mWidStack->addWidget(mWeekView );
#else
mWidStack->addWidget( mMonthView, 1 );
mWidStack->addWidget( mWeekView , 1 );
#endif
hb->addWidget( mNavigatorBar );
hb->addWidget( mWidStack );
mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
@@ -1206,69 +1218,69 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
mDayLabels.resize( mDaysPerWeek );
mDayLabelsW.resize( mDaysPerWeek );
QFont bfont = font();
if ( QApplication::desktop()->width() < 650 ) {
bfont.setPointSize( bfont.pointSize() - 2 );
}
bfont.setBold( true );
int i;
for( i = 0; i < mDaysPerWeek; i++ ) {
QLabel *label = new QLabel( mMonthView );
label->setFont(bfont);
- label->setFrameStyle(QFrame::Panel|QFrame::Raised);
+ label->setFrameStyle(Q3Frame::Panel|Q3Frame::Raised);
label->setLineWidth(1);
- label->setAlignment(AlignCenter);
+ label->setAlignment(Qt::AlignCenter);
mDayLabels.insert( i, label );
label = new QLabel( mWeekView );
label->setFont(bfont);
- label->setFrameStyle(QFrame::Panel|QFrame::Raised);
+ label->setFrameStyle(Q3Frame::Panel|Q3Frame::Raised);
label->setLineWidth(1);
- label->setAlignment(AlignCenter);
+ label->setAlignment(Qt::AlignCenter);
mDayLabelsW.insert( i, label );
}
bfont.setBold( false );
mWeekLabels.resize( mNumWeeks+1 );
mWeekLabelsW.resize( 2 );
for( i = 0; i < mNumWeeks+1; i++ ) {
KOWeekButton *label = new KOWeekButton( mMonthView );
- label->setFocusPolicy(NoFocus);
+ label->setFocusPolicy(Qt::NoFocus);
label->setFont(bfont);
connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
label->setFlat(true);
- QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
+ Q3WhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
//label->setFrameStyle(QFrame::Panel|QFrame::Raised);
//label->setLineWidth(1);
//label->setAlignment(AlignCenter);
mWeekLabels.insert( i, label );
}
mWeekLabels[mNumWeeks]->setText( i18n("W"));
- mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
- QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
+ mWeekLabels[mNumWeeks]->setFocusPolicy(Qt::WheelFocus);
+ Q3WhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
for( i = 0; i < 1+1; i++ ) {
KOWeekButton *label = new KOWeekButton( mWeekView );
- label->setFocusPolicy(NoFocus);
+ label->setFocusPolicy(Qt::NoFocus);
label->setFont(bfont);
connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
label->setFlat(true);
- QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
+ Q3WhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
//label->setFrameStyle(QFrame::Panel|QFrame::Raised);
//label->setLineWidth(1);
//label->setAlignment(AlignCenter);
mWeekLabelsW.insert( i, label );
}
mWeekLabelsW[1]->setText( i18n("W"));
- mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
+ mWeekLabelsW[1]->setFocusPolicy(Qt::WheelFocus);
int row, col;
mCells.resize( mNumCells );
for( row = 0; row < mNumWeeks; ++row ) {
for( col = 0; col < mDaysPerWeek; ++col ) {
MonthViewCell *cell = new MonthViewCell( this, mMonthView );
mCells.insert( row * mDaysPerWeek + col, cell );
connect( cell, SIGNAL( defaultAction( Incidence * ) ),
SLOT( defaultAction( Incidence * ) ) );
connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
@@ -1296,45 +1308,45 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
SIGNAL( showDaySignal( QDate ) ) );
connect( cell, SIGNAL( nextCell() ),
SLOT( nextCell() ) );
connect( cell, SIGNAL( prevCell() ),
SLOT( prevCell() ) );
connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ),
SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
}
//connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
mContextMenu = eventPopup();
- mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
+ mContextMenu->addAdditionalItem(QIcon(QPixmap()),
i18n("New Event..."),this,
SLOT(slotNewEvent()),false);
- mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
+ mContextMenu->addAdditionalItem(QIcon(QPixmap()),
i18n("New Todo..."),this,
SLOT(slotNewTodo()),false);
- mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
+ mContextMenu->addAdditionalItem(QIcon(QPixmap()),
i18n("Journal"),this,
SLOT(slotEditJournal()),false);
connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this,
SLOT( catChanged( Incidence * ) ));
QString pathString = "";
if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
if ( QApplication::desktop()->width() < 480 )
pathString += "icons16/";
} else
pathString += "iconsmini/";
- mNewItemMenu = new QPopupMenu( this );
+ mNewItemMenu = new Q3PopupMenu( this );
mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
// updateConfig(); //useless here...
// ... but we need mWidthLongDayLabel computed
QFontMetrics fontmetric(mDayLabels[0]->font());
mWidthLongDayLabel = 0;
for (int i = 0; i < 7; i++) {
int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
}
@@ -1388,25 +1400,25 @@ void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int
lastCell = mc;
//qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
bool weekview = false;
uint index = 0;
for (uint i = 0; i < mCellsW.count(); ++i) {
if ( mCellsW[i] == mc ) {
weekview = true;
index = i;
break;
}
}
- QPtrVector<MonthViewCell> *cells;
+ Q3PtrVector<MonthViewCell> *cells;
if ( weekview )
cells = &mCellsW;
else {
for (uint i = 0; i < mCells.count(); ++i) {
if ( mCells[i] == mc ) {
index = i;
break;
}
}
cells = &mCells;
}
for (uint i = 0; i < (*cells).count(); ++i) {
@@ -1486,27 +1498,27 @@ void KOMonthView::switchView()
}
int KOMonthView::maxDatesHint()
{
return mNumCells;
}
int KOMonthView::currentDateCount()
{
return mNumCells;
}
-QPtrList<Incidence> KOMonthView::selectedIncidences()
+Q3PtrList<Incidence> KOMonthView::selectedIncidences()
{
- QPtrList<Incidence> selected;
+ Q3PtrList<Incidence> selected;
if ( mSelectedCell ) {
Incidence *incidence = mSelectedCell->selectedIncidence();
if ( incidence ) selected.append( incidence );
}
return selected;
}
DateList KOMonthView::selectedDates()
{
DateList selected;
@@ -1552,33 +1564,33 @@ void KOMonthView::updateConfig()
updateDayLabels();
//qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
//int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
//resizeEvent( 0 );
for (uint i = 0; i < mCells.count(); ++i) {
mCells[i]->updateConfig();
}
for (uint i = 0; i < mCellsW.count(); ++i) {
mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
}
#ifdef DESKTOP_VERSION
- MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
+ /* TODO:hacker: MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); */
#endif
updateView();
}
void KOMonthView::updateDayLabels()
{
- QPtrVector<QLabel> *mDayLabelsT;
+ Q3PtrVector<QLabel> *mDayLabelsT;
mDayLabelsT = &mDayLabelsW;
for (int i = 0; i < 7; i++) {
{
bool show = mShortDayLabelsW;
if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
show = true;
(*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
}
}
mDayLabelsT = &mDayLabels;
for (int i = 0; i < 7; i++) {
@@ -1601,27 +1613,27 @@ void KOMonthView::clearList()
unsigned int i;
for( i = 0; i < mCells.size(); ++i ) {
mCells[i]->clear();
}
for( i = 0; i < mCellsW.size(); ++i ) {
mCellsW[i]->clear();
}
}
void KOMonthView::showDates(const QDate &start, const QDate &)
{
// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
- QPtrVector<MonthViewCell> *cells;
- QPtrVector<QLabel> *dayLabels;
- QPtrVector<KOWeekButton> *weekLabels;
+ Q3PtrVector<MonthViewCell> *cells;
+ Q3PtrVector<QLabel> *dayLabels;
+ Q3PtrVector<KOWeekButton> *weekLabels;
uint weekNum = 6;
mStartDate = start;
if ( mShowWeekView ) {
weekNum = 1;
cells = &mCellsW;
dayLabels = &mDayLabelsW;
weekLabels = &mWeekLabelsW;
if ( !KGlobal::locale()->weekStartsMonday() ) {
mStartDate = mStartDate.addDays( 1 );
}
} else {
cells = &mCells;
@@ -1659,62 +1671,62 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
// not just 1.
int dayOfYear = date.dayOfYear();
if (dayOfYear % 7 != 0)
wno = dayOfYear / 7 + 1;
else
wno =dayOfYear / 7;
(*weekLabels)[i]->setWeekNum( wno );
date = date.addDays( 7 );
}
updateView();
}
-void KOMonthView::showEvents(QPtrList<Event>)
+void KOMonthView::showEvents(Q3PtrList<Event>)
{
qDebug("KOMonthView::selectEvents is not implemented yet. ");
}
void KOMonthView::changeEventDisplay(Event *, int)
{
// this should be re-written to be much more efficient, but this
// quick-and-dirty-hack gets the job done for right now.
//qDebug("KOMonthView::changeEventDisplay ");
updateView();
}
void KOMonthView::updateView()
{
if ( !updatePossible )
return;
//qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
//QTime ti;
//ti.start();
clearSelection();
- QPtrVector<MonthViewCell> *cells;
+ Q3PtrVector<MonthViewCell> *cells;
if ( mShowWeekView ) {
cells = &mCellsW;
} else {
cells = &mCells;
}
#if 1
int i;
int timeSpan = (*cells).size()-1;
if ( KOPrefs::instance()->mMonthViewWeek )
timeSpan = 6;
for( i = 0; i < timeSpan + 1; ++i ) {
(*cells)[i]->startUpdateCell();
}
- QPtrList<Event> events = calendar()->events();
+ Q3PtrList<Event> events = calendar()->events();
Event *event;
QDateTime dt;
QDate endDate = mStartDate.addDays( timeSpan );
for( event = events.first(); event; event = events.next() ) { // for event
if ( event->doesRecur() ) {
bool last;
QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
QDateTime incidenceEnd;
int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
bool invalid = false;
while( true ) {
if ( incidenceStart.isValid() ) {
@@ -1760,25 +1772,25 @@ void KOMonthView::updateView()
//normalize
st = timeSpan - st;
if ( st < 0 ) st = 0;
if ( end > timeSpan ) end = timeSpan;
int iii;
for ( iii = st;iii<= end;++iii)
(*cells)[iii]->insertEvent( event );
}
}
}
}
// insert due todos
- QPtrList<Todo> todos = calendar()->todos( );
+ Q3PtrList<Todo> todos = calendar()->todos( );
Todo *todo;
for(todo = todos.first(); todo; todo = todos.next()) {
//insertTodo( todo );
if ( todo->hasDueDate() ) {
int day = mStartDate.daysTo( todo->dtDue().date() );
if ( day >= 0 && day < timeSpan + 1) {
(*cells)[day]->insertTodo( todo );
}
}
}
for( i = 0; i < timeSpan+1; ++i ) {
@@ -2216,25 +2228,25 @@ void KOMonthView::setSelectedCell( MonthViewCell *cell )
} else
mSelectedCell = cell;
// if ( mSelectedCell )
// mSelectedCell->select();
if ( !mSelectedCell )
emit incidenceSelected( 0 );
else
emit incidenceSelected( mSelectedCell->selectedIncidence() );
}
void KOMonthView::processSelectionChange()
{
- QPtrList<Incidence> incidences = selectedIncidences();
+ Q3PtrList<Incidence> incidences = selectedIncidences();
if (incidences.count() > 0) {
emit incidenceSelected( incidences.first() );
} else {
emit incidenceSelected( 0 );
clearSelection();
}
}
void KOMonthView::clearSelection()
{
if ( mSelectedCell ) {
mSelectedCell->deselect();
@@ -2252,55 +2264,55 @@ void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
void KOMonthView::keyPressEvent ( QKeyEvent * e )
{
qApp->processEvents();
if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
//e->ignore();
e->accept();
return;
}
if (! e->isAutoRepeat() )
mFlagKeyPressed = true;
switch(e->key()) {
- case Key_Up:
+ case Qt::Key_Up:
{
if ( mShowWeekView ) {
emit selectWeekNum ( currentWeek() - 1 );
}
else {
emit prevMonth();
}
}
e->accept();
break;
- case Key_Down:
+ case Qt::Key_Down:
{
if ( mShowWeekView ) {
emit selectWeekNum ( currentWeek() +1);
}
else {
emit nextMonth();
}
}
e->accept();
break;
- case Key_Return:
- case Key_Enter:
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
{
selectInternalWeekNum ( currentWeek() );
}
e->accept();
break;
- case Key_D:
+ case Qt::Key_D:
if ( mSelectedCell ) {
mSelectedCell->showDay();
e->accept();
} else {
e->ignore();
}
break;
default:
e->ignore();
break;
}
}