summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-17 14:27:55 (UTC)
committer zautrix <zautrix>2005-04-17 14:27:55 (UTC)
commitb411ec2d8961d07c3e2e9aefc9e04322b7851859 (patch) (side-by-side diff)
tree79e2a70f1ad32562456b0bfa03aa2b916095fbb0 /korganizer
parent2d81c75c4ffb8f144ae58e90e68496500d07a19e (diff)
downloadkdepimpi-b411ec2d8961d07c3e2e9aefc9e04322b7851859.zip
kdepimpi-b411ec2d8961d07c3e2e9aefc9e04322b7851859.tar.gz
kdepimpi-b411ec2d8961d07c3e2e9aefc9e04322b7851859.tar.bz2
qdebugcleanup
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kdatenavigator.cpp4
-rw-r--r--korganizer/koagendaview.cpp6
-rw-r--r--korganizer/kodaymatrix.cpp1
-rw-r--r--korganizer/koeditorgeneral.cpp2
-rw-r--r--korganizer/koeditorrecurrence.cpp10
-rw-r--r--korganizer/koeventviewer.cpp4
-rw-r--r--korganizer/koglobals.cpp31
-rw-r--r--korganizer/koglobals.h5
-rw-r--r--korganizer/koincidenceeditor.cpp1
-rw-r--r--korganizer/kolistview.cpp9
-rw-r--r--korganizer/kolistview.h2
-rw-r--r--korganizer/komonthview.cpp14
-rw-r--r--korganizer/korganizer.pro2
-rw-r--r--korganizer/korganizerE.pro2
-rw-r--r--korganizer/kotodoview.cpp31
-rw-r--r--korganizer/koviewmanager.cpp10
-rw-r--r--korganizer/kowhatsnextview.cpp2
-rw-r--r--korganizer/ktimeedit.cpp2
-rw-r--r--korganizer/mainwindow.cpp6
-rw-r--r--korganizer/mainwindow.h9
-rw-r--r--korganizer/searchdialog.cpp3
21 files changed, 29 insertions, 127 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 5aa1c9b..6697602 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -52,197 +52,195 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
setFrameStyle(QFrame::NoFrame);
QDate startDate = QDate::currentDate();
QGridLayout *topLayout = new QGridLayout(this,8,8);
if (! startDate.isValid()) {
qDebug("KDateNavigator::invalid startdate ");
startDate = QDate::currentDate();
}
mMonthSignalOffset = 0;
mSelectedDates.append(startDate);
m_MthYr = startDate;
m_bShowWeekNums = true;
setFont( KOPrefs::instance()->mDateNavigatorFont );
mNavigatorBar = new NavigatorBar( startDate, this );
topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
//mNavigatorBar->resize( 1,1);
connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
// get the day of the week on the first day
QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
m_fstDayOfWk = dayone.dayOfWeek();
int i;
// Set up the heading fields.
for( i = 0; i < 7; i++ ) {
headings[i] = new QLabel("",this);
//headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
headings[i]->setAlignment(AlignCenter);
headings[i]->installEventFilter(this);
topLayout->addWidget(headings[i],1,i+1);
}
// Create the weeknumber labels
for( i = 0; i < 6; i++ ) {
weeknos[i] = new QLabel(this);
weeknos[i]->setAlignment(AlignCenter );
//weeknos[i]->setFont(QFont("Arial", 10));
if(!m_bShowWeekNums) {
weeknos[i]->hide();
}
weeknos[i]->installEventFilter(this);
topLayout->addWidget(weeknos[i],i+2,0);
}
daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
daymatrix->setLineWidth(1);
connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
SIGNAL( datesSelected( const KCal::DateList & ) ) );
connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
SIGNAL( eventDropped( Event * ) ) );
topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
// read settings from configuration file.
updateConfig();
enableRollover(FollowMonth);
mySizeHint = sizeHintTwoButtons();
myFullSizeHint = sizeHintTwoButtons( 4 );
mFontChanged = false;
//resize ( 3,3 );
}
void KDateNavigator::changeFont ( QFont fo )
{
setFont( fo );
mNavigatorBar->resetFont( fo );
}
QFont KDateNavigator::yourFontHint( QSize si , bool *b)
{
QFont fo = KOPrefs::instance()->mDateNavigatorFont;
*b = false;
int fontPoint = fo.pointSize();
while ( fontPoint > 5 ) {
--fontPoint;
fo.setPointSize( fontPoint );
setFont( fo );
mFontChanged = true;
mNavigatorBar->resetFont( fo );
QSize sh = sizeHintTwoButtons( 2 );
//qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
if ( si.width() > sh.width() && si.height() > sh.height()) {
if ( si.width() / sh.width() == 1 ) {
if ( si.width() < sizeHintTwoButtons( 4 ).width())
continue;
}
*b = true;
- //qDebug("fooooooooooooooooooooooouuuuund ");
break;
}
}
- //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
return fo;
}
QSize KDateNavigator::sizeHint() const
{
QFontMetrics fm ( font() );
QSize day = daymatrix->sizeHint();
QSize nav = mNavigatorBar->sizeHint();
int wid = fm.width( "30") + day.width()+3;
int hei = fm.height() +day.height()+nav.height()+2;
if ( wid < nav.width() )
wid = nav.width() ;
//qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
return QSize ( wid, hei );
}
QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const
{
QFontMetrics fm ( font() );
QSize day = daymatrix->sizeHint();
QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum );
int wid = fm.width( "30") + day.width()+3;
int hei = fm.height() +day.height()+nav.height()+2;
if ( wid < nav.width() )
wid = nav.width() ;
//qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
return QSize ( wid, hei );
}
void KDateNavigator::slotMonthSelected( int m )
{
if ( m_MthYr.month() <= mMonthSignalOffset)
m += 12;
//qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset);
emit monthSelected( m - mMonthSignalOffset );
}
void KDateNavigator::setCalendar( Calendar *cal )
{
daymatrix->setCalendar( cal );
}
void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
{
m_MthYr = date;
//qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1());
updateDates();
updateView();
KCal::DateList dates;
dates.append( date );
mNavigatorBar->selectDates( dates );
daymatrix->clearSelection();
if ( doRepaint )
daymatrix->repaint( false );
}
void KDateNavigator::enableRollover(RolloverType r)
{
switch(r)
{
case None :
if (updateTimer)
{
updateTimer->stop();
delete updateTimer;
updateTimer=0L;
}
break;
case FollowDay :
case FollowMonth :
if (!updateTimer)
{
updateTimer = new QTimer(this);
QObject::connect(updateTimer,SIGNAL(timeout()),
this,SLOT(possiblyPastMidnight()));
}
updateTimer->start(0,true);
lastDayChecked = QDate::currentDate();
}
updateRollover=r;
}
KDateNavigator::~KDateNavigator()
{
}
void KDateNavigator::passedMidnight()
{
QDate today = QDate::currentDate();
bool emitMonth = false;
if (today.month() != lastDayChecked.month())
{
if (updateRollover==FollowMonth &&
@@ -275,193 +273,193 @@ void KDateNavigator::passedMidnight()
// qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
// .arg(now.toString()).arg(midnight.toString()));
updateTimer->stop();
updateTimer->start(msecsWait,true);
}
}
void KDateNavigator::updateDates()
{
// Find the first day of the week of the current month.
//int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
//int di = d1 - d2 + 1;
dayone = dayone.addDays( -d2 + 1 );
int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
// If month begins on Monday and Monday is first day of week,
// month should begin on second line. Sunday doesn't have this problem.
int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
// update the matrix dates
int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
daymatrix->updateView(dayone.addDays(index));
//each updateDates is followed by an updateView -> repaint is issued there !
// daymatrix->repaint();
}
void KDateNavigator::updateDayMatrix()
{
daymatrix->updateView();
//daymatrix->repaint();
}
void KDateNavigator::updateView()
{
setUpdatesEnabled( false );
int i;
// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
daymatrix->updateView();
int sub = 4;
if ( ! KGlobal::locale()->weekStartsMonday() )
--sub;
// set the week numbers.
for(i = 0; i < 6; i++) {
// remember, according to ISO 8601, the first week of the year is the
// first week that contains a thursday. Thus we must subtract off 4,
// not just 1.
//ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub)));
int weekNo;
if (dayOfYear % 7 != 0)
weekNo = (dayOfYear / 7 + 1);
else
weekNo = (dayOfYear / 7);
weeknos[i]->setText(QString::number( weekNo ));
}
setUpdatesEnabled( true );
// kdDebug() << "updateView() -> repaint()" << endl;
repaint();
// daymatrix->repaint();
}
void KDateNavigator::updateConfig()
{
int day;
for(int i=0; i<7; i++) {
// take the first letter of the day name to be the abbreviation
if (KGlobal::locale()->weekStartsMonday()) {
day = i+1;
} else {
if (i==0) day = 7;
else day = i;
}
QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
true );
if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
headings[i]->setText( dayName );
}
updateDates();
updateView();
}
void KDateNavigator::setShowWeekNums(bool enabled)
{
- qDebug("KDateNavigator::setShowWeekNums***************************** ");
+
m_bShowWeekNums = enabled;
for(int i=0; i<6; i++) {
if(enabled)
weeknos[i]->show();
else
weeknos[i]->hide();
}
resize(size());
}
void KDateNavigator::selectDates(const DateList& dateList)
{
if (dateList.count() > 0) {
mNavigatorBar->selectDates( dateList );
mSelectedDates = dateList;
// set our record of the month and year that this datetbl is
// displaying.
m_MthYr = mSelectedDates.first();
// set our record of the first day of the week of the current
// month. This needs to be done before calling dayToIndex, since it
// relies on this information being up to date.
QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
m_fstDayOfWk = dayone.dayOfWeek();
updateDates();
daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
updateView();
}
}
int KDateNavigator::dayNum(int row, int col)
{
return 7 * (row - 1) + (col + 1) - m_fstDayOfWk;
}
int KDateNavigator::dayToIndex(int dayNum)
{
int row, col;
row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7;
if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1))
row++;
col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7;
return row * 7 + col;
}
void KDateNavigator::wheelEvent (QWheelEvent *e)
{
if(e->delta()>0) emit goPrevious();
else emit goNext();
e->accept();
}
bool KDateNavigator::eventFilter (QObject *o,QEvent *e)
{
if (e->type() == QEvent::MouseButtonPress) {
int i;
for(i=0;i<6;++i) {
if (o == weeknos[i]) {
QDate weekstart = daymatrix->getDate(i*7);
emit weekClicked(weekstart);
break;
}
}
for(i=0;i<7;++i) {
if (o == headings[i]) {
KCal::DateList selDays;
QDate date = daymatrix->getDate(14);
emit showMonth(date );
#if 0
int dio = date.daysInMonth();
int j;
int ye = date.year();
int mo = date.month();
for ( j = 1; j <= dio; ++j ) {
selDays.append( QDate( ye, mo, j ) );
}
emit datesSelected( selDays );
#endif
break;
}
}
return true;
} else {
return false;
}
}
//#include "kdatenavigator.moc"
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index b43c40e..b5a4199 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -823,193 +823,193 @@ void KOAgendaView::createDayLabels()
dayLayout->addWidget(wid);
}
}
#endif
}
if ( ! appendLabels ) {
dayLabel = mDayLabelsList.next();
if ( !dayLabel )
appendLabels = true;
}
if ( appendLabels ) {
dayLabel = getNewDaylabel();
}
//dayLabel->hide();//test only
dayLabel->setText(">");
dayLabel->setFont( dlf );
dayLabel->setAutoRepeat( true );
dayLabel->show();
dayLabel->setNum( -2 );
dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
//mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
if ( !appendLabels ) {
dayLabel = mDayLabelsList.next();
while ( dayLabel ) {
//qDebug("!dayLabel %d",dayLabel );
dayLabel->hide();
dayLabel = mDayLabelsList.next();
}
}
mDayLabelsFrame->setFixedHeight( newHight + 4 );
}
int KOAgendaView::maxDatesHint()
{
// Not sure about the max number of events, so return 0 for now.
return 0;
}
int KOAgendaView::currentDateCount()
{
return mSelectedDates.count();
}
QPtrList<Incidence> KOAgendaView::selectedIncidences()
{
QPtrList<Incidence> selected;
Incidence *incidence;
incidence = mAgenda->selectedIncidence();
if (incidence) selected.append(incidence);
incidence = mAllDayAgenda->selectedIncidence();
if (incidence) selected.append(incidence);
return selected;
}
DateList KOAgendaView::selectedDates()
{
DateList selected;
QDate qd;
qd = mAgenda->selectedIncidenceDate();
if (qd.isValid()) selected.append(qd);
qd = mAllDayAgenda->selectedIncidenceDate();
if (qd.isValid()) selected.append(qd);
return selected;
}
void KOAgendaView::updateView()
{
if ( mBlockUpdating )
return;
// kdDebug() << "KOAgendaView::updateView()" << endl;
fillAgenda();
}
/*
Update configuration settings for the agenda view. This method is not
complete.
*/
void KOAgendaView::updateConfig()
{
if ( mBlockUpdating )
return;
if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
int old = KOPrefs::instance()->mHourSize;
KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
- qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
+ //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
}
// update config for children
mTimeLabels->updateConfig();
mAgenda->storePosition();
mAgenda->updateConfig();
mAllDayAgenda->updateConfig();
// widget synchronization
//TODO: find a better way, maybe signal/slot
mTimeLabels->positionChanged();
// for some reason, this needs to be called explicitly
mTimeLabels->repaint();
mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
// ToolTips displaying summary of events
KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
->mEnableToolTips);
//setHolidayMasks();
//createDayLabels(); called by via updateView();
mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
updateView();
mAgenda->restorePosition();
}
void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
{
int xxx = item->cellX();
//qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() );
if ( mMinY.at(xxx) > item->cellYTop() )
mMinY.at(xxx) = item->cellYTop();
if ( mMaxY.at(xxx) < item->cellYBottom() )
mMaxY.at(xxx) = item->cellYBottom();
QDateTime startDt,endDt;
QDate startDate;
int lenInSecs;
// if ( type == KOAgenda::RESIZETOP )
// qDebug("RESIZETOP ");
// if ( type == KOAgenda::RESIZEBOTTOM )
// qDebug("RESIZEBOTTOM ");
// if ( type == KOAgenda::MOVE )
// qDebug("MOVE ");
if ( item->incidence()->type() == "Event" ) {
startDt =item->incidence()->dtStart();
endDt = item->incidence()->dtEnd();
lenInSecs = startDt.secsTo( endDt );
}
// emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
startDate = mSelectedDates[item->mLastMoveXPos];
} else {
if (item->cellX() < 0) {
startDate = (mSelectedDates.first()).addDays(item->cellX());
} else {
startDate = mSelectedDates[item->cellX()];
}
}
startDt.setDate(startDate);
if (item->incidence()->doesFloat()) {
endDt.setDate(startDate.addDays(item->cellWidth() - 1));
} else {
if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
if ( item->incidence()->type() == "Event" ) {
if ( type == KOAgenda::MOVE ) {
endDt = startDt.addSecs(lenInSecs);
} else if ( type == KOAgenda::RESIZEBOTTOM ) {
if (item->lastMultiItem()) {
endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
endDt.setDate(startDate.
addDays(item->lastMultiItem()->cellX() - item->cellX()));
} else {
endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
endDt.setDate(startDate);
}
}
} else {
// todo
if (item->lastMultiItem()) {
endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
endDt.setDate(startDate.
addDays(item->lastMultiItem()->cellX() - item->cellX()));
} else {
//qDebug("tem->cellYBottom() %d",item->cellYBottom() );
@@ -1071,196 +1071,196 @@ void KOAgendaView::showEvents(QPtrList<Event>)
void KOAgendaView::changeEventDisplay(Event *, int)
{
// qDebug("KOAgendaView::changeEventDisplay ");
// kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
// this should be re-written to be MUCH smarter. Right now we
// are just playing dumb.
fillAgenda();
}
void KOAgendaView::fillAgenda(const QDate &)
{
// qDebug("KOAgendaView::fillAgenda ");
fillAgenda();
}
void KOAgendaView::fillAgenda()
{
if ( globalFlagBlockStartup )
return;
if ( globalFlagBlockAgenda == 1 )
return;
static bool onlyOne = false;
if ( onlyOne )
return;
onlyOne = true;
//if ( globalFlagBlockAgenda == 2 )
//globalFlagBlockAgenda = 0;
// globalFlagBlockPainting = false;
if ( globalFlagBlockAgenda == 0 )
globalFlagBlockAgenda = 1;
// clearView();
//qDebug("fillAgenda()++++ ");
globalFlagBlockAgendaItemPaint = 1;
mAllDayAgenda->changeColumns(mSelectedDates.count());
mAgenda->changeColumns(mSelectedDates.count());
qApp->processEvents();
mEventIndicatorTop->changeColumns(mSelectedDates.count());
mEventIndicatorBottom->changeColumns(mSelectedDates.count());
setHolidayMasks();
//mAgenda->hideUnused();
//mAllDayAgenda->hideUnused();
// mAgenda->blockNextRepaint( false );
// mAgenda->viewport()->repaint();
// mAgenda->blockNextRepaint( true );
mMinY.resize(mSelectedDates.count());
mMaxY.resize(mSelectedDates.count());
QPtrList<Event> dayEvents;
// ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
// Therefore, gtodoset all of them.
QPtrList<Todo> todos = calendar()->todos();
mAgenda->setDateList(mSelectedDates);
QDate today = QDate::currentDate();
DateList::ConstIterator dit;
int curCol = 0;
for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
QDate currentDate = *dit;
// kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
// << endl;
dayEvents = calendar()->events(currentDate,true);
// Default values, which can never be reached
mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
unsigned int numEvent;
for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
Event *event = dayEvents.at(numEvent);
if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
if ( event->uid().left(15) == QString("last-syncEvent-") )
continue;
// kdDebug() << " Event: " << event->summary() << endl;
int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
// kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
if (event->doesFloat()) {
if (event->recurrence()->doesRecur()) {
if (event->isMultiDay() ) {
endX = endX - beginX;// endX is now number of days
if ( event->recursOn( currentDate ) ) {
endX += curCol;
beginX = curCol;
mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
} else {
- qDebug("days %d %s",endX , currentDate.toString().latin1());
+ //qDebug("days %d %s",endX , currentDate.toString().latin1());
QDate dateit = currentDate.addDays( -endX );
if ( event->recursOn( dateit ) ) {
- qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
+ //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
if ( curCol-endX < 0 ) {
mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
}
}
}
} else {
mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
}
} else {
if (beginX <= 0 && curCol == 0) {
mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
} else if (beginX == curCol) {
mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
}
}
} else if (event->isMultiDay()) {
if ( event->doesRecur () ) {
QDate dateit = currentDate;
int count = 0;
int max = event->dtStart().daysTo( event->dtEnd() ) +2;
while (! event->recursOn( dateit ) && count <= max ) {
++count;
dateit = dateit.addDays( -1 );
}
bool ok;
QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
if ( ok )
{
int secs = event->dtStart().secsTo( event->dtEnd() );
QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
endX = currentDate.daysTo(nextOcend.date()) + curCol;
}
}
int startY = mAgenda->timeToY(event->dtStart().time());
int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
//qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
//qDebug("insert!!! ");
mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
}
if (beginX == curCol) {
mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
if (startY < mMinY[curCol]) mMinY[curCol] = startY;
} else if (endX == curCol) {
mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
} else {
mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
}
} else {
int startY = mAgenda->timeToY(event->dtStart().time());
int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
if (endY < startY) endY = startY;
mAgenda->insertItem(event,currentDate,curCol,startY,endY);
if (startY < mMinY[curCol]) mMinY[curCol] = startY;
if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
}
}
// ---------- [display Todos --------------
unsigned int numTodo;
for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
Todo *todo = todos.at(numTodo);
if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
// ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
// Already completed items can be displayed on their original due date
//if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
bool fillIn = false;
if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
fillIn = true;
if ( ! fillIn && !todo->hasCompletedDate() )
fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
if ( fillIn ) {
if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
if ( KOPrefs::instance()->mShowTodoInAgenda )
mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
}
else {
QDateTime dt;
if ( todo->hasCompletedDate() )
dt = todo->completed();
else
dt = todo->dtDue();;
int endY = mAgenda->timeToY(dt.time()) - 1;
int hi = (18/KOPrefs::instance()->mHourSize);
//qDebug("hei %d ",KOPrefs::instance()->mHourSize);
int startY = endY -hi;
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index ecca374..17a1d13 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -404,193 +404,192 @@ void KODayMatrix::updateViewTimed()
for( event = events.first(); event; event = events.next() ) { // for event
ushort recurType = event->recurrence()->doesRecur();
if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
(recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
continue;
}
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() ) {
incidenceEnd = incidenceStart.addDays( eventlen );
int st = incidenceStart.date().daysTo( endDate );
if ( st >= 0 ) { // start before timeend
int end = mStartDate.daysTo( incidenceEnd.date() );
if ( end >= 0 ) { // end after timestart --- got one!
//normalize
st = timeSpan - st;
if ( st < 0 ) st = 0;
if ( end > timeSpan ) end = timeSpan;
int iii;
//qDebug("found %s %d %d ",event->summary().latin1(), st, end );
for ( iii = st;iii<= end;++iii) {
computeEvent( event, iii );
}
}
}
} else {
if ( invalid )
break;
invalid = true;
//qDebug("invalid %s", event->summary().latin1());
incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
}
if ( last )
break;
bool ok;
incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
if ( ! ok )
break;
if ( incidenceStart.date() > endDate )
break;
}
} else { // no recur
int st = event->dtStart().date().daysTo( endDate );
if ( st >= 0 ) { // start before timeend
int end = mStartDate.daysTo( event->dtEnd().date() );
if ( end >= 0 ) { // end after timestart --- got one!
//normalize
st = timeSpan - st;
if ( st < 0 ) st = 0;
if ( end > timeSpan ) end = timeSpan;
int iii;
for ( iii = st;iii<= end;++iii)
computeEvent( event, iii );
}
}
}
}
int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
for(i = 0; i < NUMDAYS; i++) {
if ( ( (i+startDay) % 7 == 0 ) ) {
pDays.setBit(i);
}
}
#if 0
// insert due todos
QPtrList<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 );
}
}
}
#endif
#else
//qDebug("KODayMatrix::updateViewTimed ");
for(int i = 0; i < NUMDAYS; i++) {
// if events are set for the day then remember to draw it bold
QPtrList<Event> eventlist = mCalendar->events(days[i]);
Event *event;
int numEvents = eventlist.count();
QString holiStr = "";
bDays.clearBit(i);
hDays.clearBit(i);
eDays.clearBit(i);
for(event=eventlist.first();event != 0;event=eventlist.next()) {
- qDebug("FFFFFFFFFFFFFFFFFFFFFFFFF ");
ushort recurType = event->recurrence()->doesRecur();
if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
(recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
numEvents--;
}
if ( event->isHoliday()) {
hDays.setBit(i);
if ( !holiStr.isEmpty() )
holiStr += "\n";
holiStr += event->summary();
if ( !event->location().isEmpty() )
holiStr += " (" + event->location() + ")";
}
if ( event->isBirthday()) {
if ( !holiStr.isEmpty() )
holiStr += "\n";
holiStr += i18n("Birthday") + ": "+event->summary();
if ( !event->location().isEmpty() )
holiStr += " (" + event->location() + ")";
bDays.setBit(i);
}
}
if ( numEvents )
eDays.setBit(i);
//if it is a holy day then draw it red. Sundays are consider holidays, too
if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
!holiStr.isEmpty()) {
mHolidays[i] = holiStr;
} else {
mHolidays[i] = QString::null;
}
}
#endif
mRedrawNeeded = true;
if ( ! mPendingUpdateBeforeRepaint )
repaint(false);
}
void KODayMatrix::updateView(QDate actdate)
{
if ( ! actdate.isValid() ) {
//qDebug("date not valid ");
return;
}
mDayChanged = false;
//flag to indicate if the starting day of the matrix has changed by this call
//mDayChanged = false;
// if a new startdate is to be set then apply Cornelius's calculation
// of the first day to be shown
if (actdate != startdate) {
// reset index of selection according to shift of starting date from startdate to actdate
if (mSelStart != NOSELECTION) {
int tmp = actdate.daysTo(startdate);
//kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
// shift selection if new one would be visible at least partly !
if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
// nested if is required for next X display pushed from a different month - correction required
// otherwise, for month forward and backward, it must be avoided
if( mSelStart > NUMDAYS || mSelStart < 0 )
mSelStart = mSelStart + tmp;
if( mSelEnd > NUMDAYS || mSelEnd < 0 )
mSelEnd = mSelEnd + tmp;
}
}
startdate = actdate;
mDayChanged = true;
recalculateToday();
mRedrawNeeded = true;
}
//qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
if ( !isVisible() ) {
mPendingUpdateBeforeRepaint = true;
} else {
#ifdef DESKTOP_VERSION
//mRepaintTimer->start( 100 );
//updateViewTimed();
mUpdateTimer->start( 50 );
#else
mRepaintTimer->start( 350 );
mUpdateTimer->start( 800 );
#endif
}
}
void KODayMatrix::updateEvents()
{
if ( !mCalendar ) return;
for( int i = 0; i < NUMDAYS; i++ ) {
// if events are set for the day then remember to draw it bold
QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
int numEvents = eventlist.count();
Event *event;
for( event = eventlist.first(); event != 0;event=eventlist.next()) {
ushort recurType = event->doesRecur();
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 9df76e7..0045b7f 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -139,193 +139,193 @@ void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
mCategoriesButton = new QPushButton(parent);
mCategoriesButton->setText(i18n("Categories..."));
connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
categoriesLayout->addWidget(mCategoriesButton);
mCategoriesLabel = new QLabel(parent);
mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
categoriesLayout->addWidget(mCategoriesLabel,1);
}
void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
{
QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
secrecyLayout->addWidget(mCancelBox);
secrecyLayout->addWidget(secrecyLabel);
mSecrecyCombo = new QComboBox(parent);
mSecrecyCombo->insertStringList(Incidence::secrecyList());
secrecyLayout->addWidget(mSecrecyCombo);
}
void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
{
mDescriptionEdit = new KTextEdit(parent);
mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
mDescriptionEdit->append("");
mDescriptionEdit->setReadOnly(false);
mDescriptionEdit->setOverwriteMode(false);
mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
topLayout->addWidget(mDescriptionEdit);
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
#endif
}
void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
{
QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
//mAlarmBell = new QLabel(parent);
//mAlarmBell->setPixmap(SmallIcon("bell"));
//alarmLayout->addWidget(mAlarmBell);
if ( QApplication::desktop()->width() < 320 )
mAlarmButton = new QCheckBox(i18n("Rem."),parent);
else
mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
alarmLayout->addWidget(mAlarmButton);
mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
alarmLayout->addWidget(mAlarmTimeEdit);
mAlarmIncrCombo = new QComboBox(false, parent);
if ( QApplication::desktop()->width() < 320 ) {
mAlarmIncrCombo->insertItem(i18n("min"));
mAlarmIncrCombo->insertItem(i18n("hou"));
mAlarmIncrCombo->insertItem(i18n("day"));
mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
} else {
mAlarmIncrCombo->insertItem(i18n("minute(s)"));
mAlarmIncrCombo->insertItem(i18n("hour(s)"));
mAlarmIncrCombo->insertItem(i18n("day(s)"));
}
// mAlarmIncrCombo->setMinimumHeight(20);
alarmLayout->addWidget(mAlarmIncrCombo);
mAlarmSoundButton = new QPushButton(parent);
mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
mAlarmSoundButton->setToggleButton(true);
QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
alarmLayout->addWidget(mAlarmSoundButton);
mAlarmProgramButton = new QPushButton(parent);
mAlarmProgramButton->setPixmap(SmallIcon("run"));
mAlarmProgramButton->setToggleButton(true);
QToolTip::add(mAlarmProgramButton, i18n("No program set"));
connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
alarmLayout->addWidget(mAlarmProgramButton);
mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
// if ( KOPrefs::instance()->mCompactDialogs ) {
// mAlarmSoundButton->hide();
// mAlarmProgramButton->hide();
// }
}
void KOEditorGeneral::pickAlarmSound()
{
- qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
+ //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
bool oldState = mAlarmSoundButton->isOn();
QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
i18n("*.wav|Wav Files"), 0));
if (!fileName.isEmpty()) {
mAlarmSound = fileName;
QToolTip::remove(mAlarmSoundButton);
QString dispStr = i18n("Playing '%1'").arg(fileName);
QToolTip::add(mAlarmSoundButton, dispStr);
mAlarmProgramButton->setOn(false);
mAlarmSoundButton->setOn(true);
QToolTip::add(mAlarmProgramButton, i18n("No program set"));
} else {
mAlarmProgramButton->setOn(oldState);
mAlarmSoundButton->setOn(!oldState);
}
if (mAlarmProgramButton->isOn())
((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
if ( mAlarmSoundButton->isOn())
((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
}
void KOEditorGeneral::pickAlarmProgram()
{
bool oldState = mAlarmProgramButton->isOn();
QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
if (!fileName.isEmpty()) {
mAlarmProgram = fileName;
QToolTip::remove(mAlarmProgramButton);
QString dispStr = i18n("Running '%1'").arg(fileName);
QToolTip::add(mAlarmProgramButton, dispStr);
mAlarmSoundButton->setOn(false);
mAlarmProgramButton->setOn(true);
QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
} else {
mAlarmProgramButton->setOn(!oldState);
mAlarmSoundButton->setOn(oldState);
}
if (mAlarmProgramButton->isOn())
((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
if ( mAlarmSoundButton->isOn())
((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
}
QString KOEditorGeneral::getFittingPath( const QString s )
{
int maxlen = 50;
if ( QApplication::desktop()->width() < 640 ) {
if ( QApplication::desktop()->width() < 320 )
maxlen = 22;
else
maxlen = 35;
}
if ( s.length() > maxlen ) {
return "..."+s.right(maxlen -3);
}
return s;
}
void KOEditorGeneral::enableAlarmEdit(bool enable)
{
if ( enable ) {
if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
mAlarmSoundButton->setOn( true );
if ( mAlarmSound.isEmpty() )
mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
else {
if ( ! QFile::exists( mAlarmSound ) )
mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
}
}
}
((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
mAlarmTimeEdit->setEnabled(enable);
mAlarmSoundButton->setEnabled(enable);
mAlarmProgramButton->setEnabled(enable);
mAlarmIncrCombo->setEnabled(enable);
}
void KOEditorGeneral::disableAlarmEdit(bool disable)
{
enableAlarmEdit( !disable );
}
void KOEditorGeneral::enableAlarm( bool enable )
{
enableAlarmEdit( enable );
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp
index 01c5773..47e73dd 100644
--- a/korganizer/koeditorrecurrence.cpp
+++ b/korganizer/koeditorrecurrence.cpp
@@ -846,263 +846,263 @@ void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool )
mEnabledCheck->setChecked( enabled );
setEnabled( enabled );
mExceptions->setDefaults( to );
mRecurrenceRange->setDefaults( to );
mRecurrenceChooser->setType( RecurrenceChooser::Weekly );
showCurrentRule( mRecurrenceChooser->type() );
mDaily->setFrequency( 1 );
mWeekly->setFrequency( 1 );
QBitArray days( 7 );
days.fill( 0 );
days.setBit( from.date().dayOfWeek()- 1);
mWeekly->setDays( days );
mMonthly->setFrequency( 1 );
mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 );
mMonthly->setByDay( from.date().day()-1 );
mYearly->setFrequency( 1 );
mYearly->setByDay( from.date().dayOfYear() );
mYearly->setByMonth( from.date().month(), from.date().day() );
}
void KOEditorRecurrence::readEvent(Incidence *event)
{
QDateTime dtEnd;
if ( event->type() == "Event" )
dtEnd = ((Event*)event)->dtEnd();
else
dtEnd = ((Todo*)event)->dtDue();
setDefaults( event->dtStart(), dtEnd, true );
QBitArray rDays( 7 );
QPtrList<Recurrence::rMonthPos> rmp;
QPtrList<int> rmd;
int day = 0;
int count = 0;
int month = 0;
setDateTimes( event->dtStart(), dtEnd );
Recurrence *r = event->recurrence();
int f = r->frequency();
int recurs = r->doesRecur();
mEnabledCheck->setChecked( recurs );
setEnabled( recurs );
int recurrenceType = RecurrenceChooser::Weekly;
switch ( recurs ) {
case Recurrence::rNone:
setDefaults( event->dtStart(), dtEnd, true );
break;
case Recurrence::rDaily:
recurrenceType = RecurrenceChooser::Daily;
mDaily->setFrequency( f );
break;
case Recurrence::rWeekly:
recurrenceType = RecurrenceChooser::Weekly;
mWeekly->setFrequency( f );
mWeekly->setDays( r->days() );
break;
case Recurrence::rMonthlyPos:
// we only handle one possibility in the list right now,
// so I have hardcoded calls with first(). If we make the GUI
// more extended, this can be changed.
recurrenceType = RecurrenceChooser::Monthly;
rmp = r->monthPositions();
if ( rmp.first()->negative )
count = 5 - rmp.first()->rPos - 1;
else
count = rmp.first()->rPos - 1;
day = 0;
while ( !rmp.first()->rDays.testBit( day ) ) ++day;
mMonthly->setByPos( count, day );
mMonthly->setFrequency( f );
break;
case Recurrence::rMonthlyDay:
recurrenceType = RecurrenceChooser::Monthly;
rmd = r->monthDays();
day = *rmd.first() - 1;
mMonthly->setByDay( day );
mMonthly->setFrequency( f );
break;
case Recurrence::rYearlyMonth:
{
recurrenceType = RecurrenceChooser::Yearly;
- qDebug("Recurrence::rYearlyMonth: ");
+ //qDebug("Recurrence::rYearlyMonth: ");
day = event->dtStart().date().day();
rmd = r->yearNums();
if ( rmd.count() > 0 )
month = *rmd.first();
else
month = event->dtStart().date().month() ;
mYearly->setByMonth( month, day );
#if 0
- qDebug("2day = %d ",day );
+ //qDebug("2day = %d ",day );
QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions();
int month;
if ( !monthlist.isEmpty() ) {
month = monthlist.first()->rPos ;
} else {
month = event->dtStart().date().month() ;
}
mYearly->setByMonth( day, month );
#endif
mYearly->setFrequency( f );
}
break;
case Recurrence::rYearlyDay:
- qDebug("Recurrence::rYearlyDay: ");
+ //qDebug("Recurrence::rYearlyDay: ");
recurrenceType = RecurrenceChooser::Yearly;
mYearly->setByDay( event->dtStart().date().dayOfYear() );
mYearly->setFrequency( f );
break;
default:
setDefaults( event->dtStart(), dtEnd, true );
break;
}
mRecurrenceChooser->setType( recurrenceType );
showCurrentRule( recurrenceType );
mRecurrenceRange->setDateTimes( event->dtStart() );
if ( r->doesRecur() ) {
mRecurrenceRange->setDuration( r->duration() );
if ( r->duration() == 0 )
{
if ( r->endDate() < event->dtStart().date() )
mRecurrenceRange->setEndDate( event->dtStart().date() );
else
mRecurrenceRange->setEndDate( r->endDate() );
} else
mRecurrenceRange->setEndDate( event->dtStart().date() );
}
mExceptions->setDates( event->exDates() );
}
void KOEditorRecurrence::writeEvent( Incidence *event )
{
Recurrence *r = event->recurrence();
// clear out any old settings;
r->unsetRecurs();
if ( mEnabledCheck->isChecked() ) {
int duration = mRecurrenceRange->duration();
QDate endDate;
if ( duration == 0 ) endDate = mRecurrenceRange->endDate();
int recurrenceType = mRecurrenceChooser->type();
if ( recurrenceType == RecurrenceChooser::Daily ) {
int freq = mDaily->frequency();
if ( duration != 0 ) r->setDaily( freq, duration );
else r->setDaily( freq, endDate );
} else if ( recurrenceType == RecurrenceChooser::Weekly ) {
int freq = mWeekly->frequency();
QBitArray days = mWeekly->days();
int j;
bool found = false;
for (j = 0; j < 7 ; ++j ) {
found |=days.at(j);
}
if ( !found ) {
days.setBit( event->dtStart().date().dayOfWeek()-1);
- qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1);
+ //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1);
}
if ( duration != 0 ) r->setWeekly( freq, days, duration );
else r->setWeekly( freq, days, endDate );
} else if ( recurrenceType == RecurrenceChooser::Monthly ) {
int freq = mMonthly->frequency();
if ( mMonthly->byPos() ) {
int pos = mMonthly->count();
QBitArray days( 7 );
days.fill( false );
days.setBit( mMonthly->weekday() );
if ( duration != 0 )
r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
else
r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
r->addMonthlyPos( pos, days );
} else {
// it's by day
int day = mMonthly->day();
if ( duration != 0 ) {
r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
} else {
r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
}
r->addMonthlyDay( day );
}
} else if ( recurrenceType == RecurrenceChooser::Yearly ) {
- qDebug("RecurrenceChooser::Yearly ");
+ //qDebug("RecurrenceChooser::Yearly ");
int freq = mYearly->frequency();
if ( mYearly->byDay() ) {
if ( duration != 0 ) {
r->setYearly( Recurrence::rYearlyDay, freq, duration );
} else {
r->setYearly( Recurrence::rYearlyDay, freq, endDate );
}
r->addYearlyNum( event->dtStart().date().dayOfYear() );
} else {
if ( duration != 0 ) {
r->setYearly( Recurrence::rYearlyMonth, freq, duration );
} else {
r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
}
r->addYearlyNum( mYearly->month() );
}
}
event->setExDates( mExceptions->dates() );
}
}
void KOEditorRecurrence::setDateTimeStr( const QString &str )
{
mDateTimeLabel->setText( str );
}
bool KOEditorRecurrence::validateInput()
{
// Check input here
return true;
}
void KOEditorRecurrence::showExceptionsDialog()
{
DateList dates = mExceptions->dates();
int result = mExceptionsDialog->exec();
if ( result == QDialog::Rejected ) mExceptions->setDates( dates );
}
void KOEditorRecurrence::showRecurrenceRangeDialog()
{
int duration = mRecurrenceRange->duration();
QDate endDate = mRecurrenceRange->endDate();
int result = mRecurrenceRangeDialog->exec();
if ( result == QDialog::Rejected ) {
mRecurrenceRange->setDuration( duration );
mRecurrenceRange->setEndDate( endDate );
}
}
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index fefc778..f39b5e1 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -6,265 +6,261 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(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 <qcstring.h>
#include <qwhatsthis.h>
#include <qdialog.h>
#include <qapplication.h>
#include <qlabel.h>
#include <qlayout.h>
#include <klocale.h>
#include <kapplication.h>
#include <libkcal/event.h>
#include <libkcal/todo.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <krun.h>
#include <kglobal.h>
#include <kprocess.h>
#include "koprefs.h"
#include <kabc/stdaddressbook.h>
#ifndef KORG_NODCOP
#include <dcopclient.h>
#include "korganizer.h"
#include "koprefs.h"
#include "actionmanager.h"
#endif
#include "koeventviewer.h"
//#ifndef KORG_NOKABC
//#include <kabc/stdaddressbook.h>
//#define size count
//#endif
#ifdef DESKTOP_VERSION
#include <kabc/addresseedialog.h>
#include <kabc/addresseeview.h>
#include <qprinter.h>
#include <qpainter.h>
#include <qpaintdevicemetrics.h>
#else //DESKTOP_VERSION
#include <externalapphandler.h>
#include <qtopia/qcopenvelope_qws.h>
#endif //DESKTOP_VERSION
KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
: QTextBrowser(parent,name)
{
mSyncMode = false;
mColorMode = 0;
}
KOEventViewer::~KOEventViewer()
{
}
void KOEventViewer::printMe()
{
#ifdef DESKTOP_VERSION
KOPrintPrefs pp ( this );
if (!pp.exec() )
return;
int scaleval = pp.printMode() ;
QPrinter printer;
if (!printer.setup() )
return;
QPainter p;
p.begin ( &printer );
QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
float dx, dy;
int wid = (m.width() * 9)/10;
dx = (float) wid/(float)contentsWidth ();
dy = (float)(m.height()) / (float)contentsHeight ();
float scale;
// scale to fit the width or height of the paper
if ( dx < dy )
scale = dx;
else
scale = dy;
p.translate( m.width()/10,0 );
- qDebug("Scale: %f ", scale );
if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
- qDebug("SCALE ");
p.scale( scale, scale );
}
drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
p.end();
#endif
}
void KOEventViewer::setSource(const QString& n)
{
if ( n.left(3) == "uid" )
#ifdef DESKTOP_VERSION
{
KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
KABC::AddressBook::Iterator it;
for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
// LR I do not understand, why the uid string is different on zaurus and desktop
QString uid = "uid://"+(*it).uid();
//qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
if (n == uid ) {
//qDebug("found %s ",(*it).mobileHomePhone().latin1() );
QDialog dia( this,"dia123", true );
dia.setCaption( i18n("Details of attendee") );
QVBoxLayout lay ( &dia );
KABC::AddresseeView av ( &dia );
av.setAddressee( (*it) );
lay.addWidget( &av );
if ( QApplication::desktop()->width() < 480 )
dia.resize( 220, 240);
else {
dia.resize( 400,400);
}
dia.exec();
break;
}
}
return;
}
#else
{
if ( "uid:organizer" == n ) {
ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
return;
}
QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
if (attendees.count()) {
Attendee *a;
for(a=attendees.first();a;a=attendees.next()) {
if ( "uid:"+a->uid() == n ) {
bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
return;
}
}
}
return;
}
//requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
// the result should now arrive through method insertAttendees
//QString uid = "uid:"+(*it).uid();
#endif
if ( n.left(6) == "mailto" ) {
// qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
#ifndef DESKTOP_VERSION
if ( n.mid(7,3) == "ALL" ) {
- qDebug("all ");
mailToAttendees( true );
} else if ( n.mid(7,4) == "RSVP" ) {
mailToAttendees( false );
- qDebug("rsvp ");
} else {
QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
e << n.mid(7);
}
#endif
}
#ifndef KORG_NODCOP
kdDebug() << "KOEventViewer::setSource(): " << n << endl;
QString tmpStr;
if (n.startsWith("mailto:")) {
KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
//emit showIncidence(n);
return;
} else if (n.startsWith("uid:")) {
DCOPClient *client = KApplication::kApplication()->dcopClient();
const QByteArray noParamData;
const QByteArray paramData;
QByteArray replyData;
QCString replyTypeStr;
#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
bool foundAbbrowser = PING_ABBROWSER;
if (foundAbbrowser) {
//KAddressbook is already running, so just DCOP to it to bring up the contact editor
//client->send("kaddressbook","KAddressBookIface",
QDataStream arg(paramData, IO_WriteOnly);
arg << n.mid(6);
client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
return;
} else {
/*
KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
We start it without its main interface
*/
KIconLoader* iconLoader = new KIconLoader();
QString iconPath = iconLoader->iconPath("go",KIcon::Small);
ActionManager::setStartedKAddressBook(true);
tmpStr = "kaddressbook --editor-only --uid ";
tmpStr += KProcess::quote(n.mid(6));
KRun::runCommand(tmpStr,"KAddressBook",iconPath);
return;
}
} else {
//QTextBrowser::setSource(n);
}
#endif
}
void KOEventViewer::mailToAttendees( bool all )
{
QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
if (attendees.count() == 0) return;
QStringList nameList;
QStringList emailList;
QStringList uidList;
Attendee* a;
for(a=attendees.first();a;a=attendees.next()) {
if ( !all && !a->RSVP() ) continue;
if (!a->email().isEmpty()) {
nameList.append (a->name() );
emailList.append (a->email() );
uidList.append (a->uid() );
}
}
QString uid = "ComposeMailUIpick2"+mMailSubject;
#ifndef DESKTOP_VERSION
bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
#endif
}
void KOEventViewer::addTag(const QString & tag,const QString & text)
{
int number=text.contains("\n");
QString str = "<" + tag + ">";
QString tmpText=text;
QString tmpStr=str;
if(number !=-1)
{
if (number > 0) {
int pos=0;
QString tmp;
for(int i=0;i<=number;i++) {
pos=tmpText.find("\n");
tmp=tmpText.left(pos);
tmpText=tmpText.right(tmpText.length()-pos-1);
tmpStr+=tmp+"<br>";
}
}
else tmpStr += tmpText;
tmpStr+="</" + tag + ">";
mText.append(tmpStr);
}
else
{
diff --git a/korganizer/koglobals.cpp b/korganizer/koglobals.cpp
index 8016034..9ece77f 100644
--- a/korganizer/koglobals.cpp
+++ b/korganizer/koglobals.cpp
@@ -1,143 +1,114 @@
/*
This file is part of KOrganizer.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(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.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qapplication.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kconfig.h>
#include <kstandarddirs.h>
#include <kglobalsettings.h>
#include <klocale.h>
#include <kcalendarsystem.h>
-#ifndef KORG_NOKALARMD
-#include "kalarmdclient.h"
-#endif
-#include "simplealarmclient.h"
#include "koglobals.h"
#include "koprefs.h"
-class NopAlarmClient : public AlarmClient
-{
- public:
- void startDaemon() {}
- bool setCalendars( const QStringList & ) { return false; }
- bool addCalendar( const QString & ) { return false; }
- bool removeCalendar( const QString & ) { return false; }
- bool reloadCalendar( const QString & ) { return false; }
-};
KOGlobals *KOGlobals::mSelf = 0;
KOGlobals *KOGlobals::self()
{
if (!mSelf) {
mSelf = new KOGlobals;
}
return mSelf;
}
KOGlobals::KOGlobals()
{
KConfig *cfg = KOGlobals::config();
cfg->setGroup("General");
mCalendarSystem = KGlobal::locale()->calendar();
- cfg->setGroup("AlarmDaemon");
- QString alarmClient = cfg->readEntry( "Daemon", "kalarmd" );
- if ( alarmClient == "simple" ) {
- mAlarmClient = new SimpleAlarmClient;
-#ifndef KORG_NOKALARMD
- } else if ( alarmClient == "kalarmd" ) {
- mAlarmClient = new KalarmdClient;
-#endif
- } else {
- mAlarmClient = new NopAlarmClient;
- }
}
KConfig* KOGlobals::config()
{
static KConfig *mConfig = 0;
if (!mConfig) {
KOPrefs *p = KOPrefs::instance();
mConfig = p->getConfig();
//mConfig = new KConfig( locateLocal( "config", "korganizerrc" ) );
}
return mConfig;
}
KOGlobals::~KOGlobals()
{
- delete mAlarmClient;
+
}
const KCalendarSystem *KOGlobals::calendarSystem() const
{
return mCalendarSystem;
}
-AlarmClient *KOGlobals::alarmClient() const
-{
- return mAlarmClient;
-}
-
void KOGlobals::fitDialogToScreen( QWidget *wid, bool force )
{
bool resized = false;
int w = wid->frameSize().width();
int h = wid->frameSize().height();
QRect desk = KGlobalSettings::desktopGeometry(wid);
if ( w > desk.width() ) {
w = desk.width();
resized = true;
}
// Yuck this hack is ugly. Is the -30 really to circumvent the size of
// kicker?!
if ( h > desk.height() - 30 ) {
h = desk.height() - 30;
resized = true;
}
if ( resized || force ) {
wid->resize( w, h );
wid->move( desk.x(), desk.y()+15 );
if ( force ) wid->setFixedSize( w, h );
}
}
bool KOGlobals::reverseLayout()
{
#if QT_VERSION >= 0x030000
return QApplication::reverseLayout();
#else
return false;
#endif
}
diff --git a/korganizer/koglobals.h b/korganizer/koglobals.h
index 357ff5f..b3ff67b 100644
--- a/korganizer/koglobals.h
+++ b/korganizer/koglobals.h
@@ -1,59 +1,56 @@
/*
This file is part of KOrganizer.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(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.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KORG_GLOBALS_H
#define KORG_GLOBALS_H
class KCalendarSystem;
class AlarmClient;
class KConfig;
class KOGlobals
{
public:
static KOGlobals *self();
enum { EVENTADDED, EVENTEDITED, EVENTDELETED };
enum { PRIORITY_MODIFIED, COMPLETION_MODIFIED, CATEGORY_MODIFIED, UNKNOWN_MODIFIED };
static void fitDialogToScreen( QWidget *widget, bool force=false );
static KConfig *config();
static bool reverseLayout();
const KCalendarSystem *calendarSystem() const;
- AlarmClient *alarmClient() const;
-
protected:
KOGlobals();
~KOGlobals();
private:
static KOGlobals *mSelf;
- const KCalendarSystem *mCalendarSystem;
- AlarmClient *mAlarmClient;
+ const KCalendarSystem *mCalendarSystem;
};
#endif
diff --git a/korganizer/koincidenceeditor.cpp b/korganizer/koincidenceeditor.cpp
index 51df123..9813a80 100644
--- a/korganizer/koincidenceeditor.cpp
+++ b/korganizer/koincidenceeditor.cpp
@@ -1,141 +1,140 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(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.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qtooltip.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qlayout.h>
#include <qwidgetstack.h>
#include <qdatetime.h>
#include <qdir.h>
#include <kdebug.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <kfiledialog.h>
#include <libkdepim/categoryselectdialog.h>
#include <libkdepim/kinputdialog.h>
#include <libkcal/calendarlocal.h>
#include <libkcal/icalformat.h>
#include "koprefs.h"
-#include "koglobals.h"
#include "koincidenceeditor.h"
KOIncidenceEditor::KOIncidenceEditor( const QString &caption,
Calendar *calendar, QWidget *parent ) :
KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok,
parent, caption, true, false ),
mSaveTemplateDialog( 0 )
{
mCalendar = calendar;
setButtonText( Default, i18n("Template...") );
QString saveTemplateText;
// if ( KOPrefs::instance()->mCompactDialogs ) {
// showButton( User1, false );
// showButton( Apply, false );
// } else {
showButton( Apply, false );
saveTemplateText = i18n("Ok+Agenda");
// }
setButtonText( User1, saveTemplateText );
//mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this );
// KOGlobals::fitDialogToScreen( mCategoryDialog );
//connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories()));
//connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) );
// connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) );
connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) );
}
KOIncidenceEditor::~KOIncidenceEditor()
{
//delete mCategoryDialog;
}
void KOIncidenceEditor::setupAttendeesTab()
{
QFrame *topFrame = addPage(i18n("Attendees"));
QBoxLayout *topLayout = new QVBoxLayout(topFrame);
mDetails = new KOEditorDetails(spacingHint(),topFrame);
topLayout->addWidget(mDetails);
}
void KOIncidenceEditor::slotApply()
{
processInput( false );
}
void KOIncidenceEditor::accept()
{
slotOk();
}
void KOIncidenceEditor::slotOk()
{
if ( processInput( false ) ) QDialog::accept();
}
void KOIncidenceEditor::updateCategoryConfig()
{
qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! ");
//mCategoryDialog->updateCategoryConfig();
}
void KOIncidenceEditor::slotCancel()
{
reject();
}
void KOIncidenceEditor::slotLoadTemplate()
{
kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl;
}
void KOIncidenceEditor::slotShowIncidence()
{
if ( processInput(true ) ) {
accept();
}
}
void KOIncidenceEditor::slotSaveTemplate()
{
kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl;
}
void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type )
{
if ( !mSaveTemplateDialog ) {
mSaveTemplateDialog = new SaveTemplateDialog( type, this );
connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ),
SLOT( saveTemplate( const QString & ) ) );
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 341f473..e1b393d 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -238,336 +238,339 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent,
mListView->addColumn(i18n("Recurs")); // recurs?
mListView->addColumn(i18n("Due Date"));
mListView->addColumn(i18n("Due Time"));
mListView->addColumn(i18n("Cancelled"));
mListView->addColumn(i18n("Categories"));
mListView->setColumnAlignment(0,AlignLeft);
mListView->setColumnAlignment(1,AlignLeft);
mListView->setColumnAlignment(2,AlignHCenter);
mListView->setColumnAlignment(3,AlignLeft);
mListView->setColumnAlignment(4,AlignHCenter);
mListView->setColumnAlignment(5,AlignLeft);
mListView->setColumnAlignment(6,AlignLeft);
mListView->setColumnAlignment(7,AlignLeft);
mListView->setColumnAlignment(8,AlignLeft);
mListView->setColumnAlignment(9,AlignLeft);
mListView->setColumnAlignment(10,AlignLeft);
mListView->setColumnWidthMode(10, QListView::Manual);
new KOListViewWhatsThis(mListView->viewport(),this);
int iii = 0;
for ( iii = 0; iii< 10 ; ++iii )
mListView->setColumnWidthMode( iii, QListView::Manual );
QBoxLayout *layoutTop = new QVBoxLayout(this);
layoutTop->addWidget(mListView);
mListView->setFont ( KOPrefs::instance()->mListViewFont );
mPopupMenu = eventPopup();
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Select all"),this,
SLOT(allSelection()),true);
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Deselect all"),this,
SLOT(clearSelection()),true);
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Delete all selected"),this,
SLOT(deleteAll()),true);
mPopupMenu->insertSeparator();
QPopupMenu * exportPO = new QPopupMenu ( this );
mPopupMenu->insertItem( i18n("Export selected"), exportPO );
exportPO->insertItem( i18n("As iCal (ics) file..."),this,
SLOT(saveToFile()));
exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
SLOT(saveToFileVCS()));
exportPO->insertItem( i18n("Journal/Details..."),this,
SLOT(saveDescriptionToFile()));
// mPopupMenu->insertSeparator();
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Add Categ. to selected..."),this,
SLOT(addCat()),true);
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Set Categ. for selected..."),this,
SLOT(setCat()),true);
//mPopupMenu->insertSeparator();
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Set alarm for selected..."),this,
SLOT(setAlarm()),true);
#ifndef DESKTOP_VERSION
mPopupMenu->insertSeparator();
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Beam selected via IR"),this,
SLOT(beamSelected()),true);
#endif
/*
mPopupMenu = new QPopupMenu;
mPopupMenu->insertItem(i18n("Edit Event"), this,
SLOT (editEvent()));
mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
SLOT (deleteEvent()));
mPopupMenu->insertSeparator();
mPopupMenu->insertItem(i18n("Show Dates"), this,
SLOT(showDates()));
mPopupMenu->insertItem(i18n("Hide Dates"), this,
SLOT(hideDates()));
*/
QObject::connect(mListView,SIGNAL( newEvent()),
this,SIGNAL(signalNewEvent()));
QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
this,SLOT(defaultItemAction(QListViewItem *)));
QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
const QPoint &, int )),
this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
SLOT(processSelectionChange(QListViewItem *)));
QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
SIGNAL(showIncidenceSignal(Incidence *)) );
readSettings(KOGlobals::config(),"KOListView Layout");
}
KOListView::~KOListView()
{
delete mPopupMenu;
}
+
QString KOListView::getWhatsThisText(QPoint p)
{
KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
if ( item )
return KIncidenceFormatter::instance()->getFormattedText( item->data(),
KOPrefs::instance()->mWTshowDetails,
KOPrefs::instance()->mWTshowCreated,
KOPrefs::instance()->mWTshowChanged);
return i18n("That is the list view" );
}
void KOListView::updateList()
{
// qDebug(" KOListView::updateList() ");
}
void KOListView::addCat( )
{
setCategories( false );
}
void KOListView::setCat()
{
setCategories( true );
}
void KOListView::setAlarm()
{
KOAlarmPrefs kap( this);
if ( !kap.exec() )
return;
QStringList itemList;
QPtrList<KOListViewItem> sel ;
QListViewItem *qitem = mListView->firstChild ();
while ( qitem ) {
if ( qitem->isSelected() ) {
Incidence* inc = ((KOListViewItem *) qitem)->data();
if ( inc->type() != "Journal" ) {
if ( inc->type() == "Todo" ) {
if ( ((Todo*)inc)->hasDueDate() )
sel.append(((KOListViewItem *)qitem));
} else
sel.append(((KOListViewItem *)qitem));
}
}
qitem = qitem->nextSibling();
}
int count = 0;
KOListViewItem * item, *temp;
item = sel.first();
Incidence* inc;
while ( item ) {
inc = item->data();
++count;
if (kap.mAlarmButton->isChecked()) {
if (inc->alarms().count() == 0)
inc->newAlarm();
QPtrList<Alarm> alarms = inc->alarms();
Alarm *alarm;
for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
alarm->setEnabled(true);
int j = kap.mAlarmTimeEdit->value()* -60;
if (kap.mAlarmIncrCombo->currentItem() == 1)
j = j * 60;
else if (kap.mAlarmIncrCombo->currentItem() == 2)
j = j * (60 * 24);
alarm->setStartOffset( j );
if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
alarm->setProcedureAlarm(kap.mAlarmProgram);
}
else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
alarm->setAudioAlarm(kap.mAlarmSound);
else
alarm->setType(Alarm::Invalid);
//alarm->setAudioAlarm("default");
// TODO: Deal with multiple alarms
break; // For now, stop after the first alarm
}
} else {
Alarm* alarm = inc->alarms().first();
if ( alarm ) {
alarm->setEnabled(false);
alarm->setType(Alarm::Invalid);
}
}
temp = item;
item = sel.next();
mUidDict.remove( inc->uid() );
delete temp;;
addIncidence( inc );
}
topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) );
qDebug("KO: Set alarm for %d items", count);
calendar()->reInitAlarmSettings();
+ QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
}
void KOListView::setCategories( bool removeOld )
{
KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
if (! csd->exec()) {
delete csd;
return;
}
QStringList catList = csd->selectedCategories();
delete csd;
// if ( catList.count() == 0 )
// return;
catList.sort();
QString categoriesStr = catList.join(",");
int i;
QStringList itemList;
QPtrList<KOListViewItem> sel ;
QListViewItem *qitem = mListView->firstChild ();
while ( qitem ) {
if ( qitem->isSelected() ) {
sel.append(((KOListViewItem *)qitem));
}
qitem = qitem->nextSibling();
}
KOListViewItem * item, *temp;
item = sel.first();
Incidence* inc;
while ( item ) {
inc = item->data();
if ( removeOld ) {
inc->setCategories( categoriesStr );
} else {
itemList = QStringList::split (",", inc->categoriesStr() );
for( i = 0; i< catList.count(); ++i ) {
if ( !itemList.contains (catList[i]))
itemList.append( catList[i] );
}
itemList.sort();
inc->setCategories( itemList.join(",") );
}
temp = item;
item = sel.next();
mUidDict.remove( inc->uid() );
delete temp;;
addIncidence( inc );
}
+ QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
}
void KOListView::beamSelected()
{
int icount = 0;
QPtrList<Incidence> delSel ;
QListViewItem *item = mListView->firstChild ();
while ( item ) {
if ( item->isSelected() ) {
delSel.append(((KOListViewItem *)item)->data());
++icount;
}
item = item->nextSibling();
}
if ( icount ) {
emit beamIncidenceList( delSel );
return;
QString fn ;
fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
QString mes;
bool createbup = true;
if ( createbup ) {
QString description = "\n";
CalendarLocal* cal = new CalendarLocal();
cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
Incidence *incidence = delSel.first();
while ( incidence ) {
Incidence *in = incidence->clone();
description += in->summary() + "\n";
cal->addIncidence( in );
incidence = delSel.next();
}
FileStorage storage( cal, fn, new VCalFormat );
storage.save();
delete cal;
mes = i18n("KO/Pi: Ready for beaming");
topLevelWidget()->setCaption(mes);
#ifndef DESKTOP_VERSION
Ir *ir = new Ir( this );
connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
ir->send( fn, description, "text/x-vCalendar" );
#endif
}
}
}
void KOListView::beamDone( Ir *ir )
{
#ifndef DESKTOP_VERSION
delete ir;
#endif
topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
}
void KOListView::saveDescriptionToFile()
{
int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
i18n("Continue"), i18n("Cancel"), 0,
0, 1 );
if ( result != 0 ) {
return;
}
int icount = 0;
QPtrList<Incidence> delSel ;
QListViewItem *item = mListView->firstChild ();
while ( item ) {
if ( item->isSelected() ) {
delSel.append(((KOListViewItem *)item)->data());
++icount;
}
item = item->nextSibling();
}
if ( icount ) {
QString fn = KOPrefs::instance()->mLastSaveFile;
fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
if ( fn == "" )
return;
QFileInfo info;
info.setFile( fn );
QString mes;
bool createbup = true;
if ( info. exists() ) {
mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
i18n("Overwrite!"), i18n("Cancel"), 0,
0, 1 );
if ( result != 0 ) {
createbup = false;
}
}
if ( createbup ) {
@@ -606,324 +609,328 @@ void KOListView::saveDescriptionToFile()
topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
return;
}
QTextStream ts( &file );
ts << text;
file.close();
//qDebug("%s ", text.latin1());
mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
KOPrefs::instance()->mLastSaveFile = fn;
topLevelWidget()->setCaption(mes);
}
}
}
void KOListView::saveToFileVCS()
{
writeToFile( false );
}
void KOListView::saveToFile()
{
writeToFile( true );
}
void KOListView::writeToFile( bool iCal )
{
int icount = 0;
QPtrList<Incidence> delSel ;
QListViewItem *item = mListView->firstChild ();
bool journal = iCal; // warn only for vCal
while ( item ) {
if ( item->isSelected() ) {
if ( !journal )
if ( ((KOListViewItem *)item)->data()->type() == "Journal")
journal = true;
delSel.append(((KOListViewItem *)item)->data());
++icount;
}
item = item->nextSibling();
}
if ( !iCal && journal ) {
int result = KMessageBox::warningContinueCancel(this,
i18n("The journal entries can not be\nexported to a vCalendar file."),
i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
true);
if (result != KMessageBox::Continue) return;
}
if ( icount ) {
QString fn = KOPrefs::instance()->mLastSaveFile;
QString extension;
if ( iCal ) {
if ( fn.right( 4 ).lower() == ".vcs" ) {
fn = fn.left( fn.length() -3) + "ics";
}
} else {
if ( fn.right( 4 ).lower() == ".ics" ) {
fn = fn.left( fn.length() -3) + "vcs";
}
}
fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
if ( fn == "" )
return;
QFileInfo info;
info.setFile( fn );
QString mes;
bool createbup = true;
if ( info. exists() ) {
mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
i18n("Overwrite!"), i18n("Cancel"), 0,
0, 1 );
if ( result != 0 ) {
createbup = false;
}
}
if ( createbup ) {
CalendarLocal cal;
cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
Incidence *incidence = delSel.first();
while ( incidence ) {
cal.addIncidence( incidence->clone() );
incidence = delSel.next();
}
if ( iCal ) {
ICalFormat format;
format.save( &cal, fn );
} else {
VCalFormat format;
format.save( &cal, fn );
}
mes = i18n("KO/Pi:Saved %1").arg(fn );
KOPrefs::instance()->mLastSaveFile = fn;
topLevelWidget()->setCaption(mes);
}
}
+ QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
}
void KOListView::deleteAll()
{
int icount = 0;
QPtrList<Incidence> delSel ;
QListViewItem *item = mListView->firstChild ();
while ( item ) {
if ( item->isSelected() ) {
delSel.append(((KOListViewItem *)item)->data());
++icount;
}
item = item->nextSibling();
}
if ( icount ) {
Incidence *incidence = delSel.first();
Incidence *toDelete;
KOPrefs *p = KOPrefs::instance();
bool confirm = p->mConfirm;
QString mess;
mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
p->mConfirm = false;
int delCounter = 0;
QDialog dia ( this, "p-dialog", true );
QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
QVBoxLayout lay( &dia );
lay.setMargin(7);
lay.setSpacing(7);
lay.addWidget( &lab);
QProgressBar bar( icount, &dia );
lay.addWidget( &bar);
int w = 220;
int h = 50;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
//dia.resize( 240,50 );
dia.show();
while ( incidence ) {
bar.setProgress( delCounter );
mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
dia.setCaption( mess );
qApp->processEvents();
toDelete = (incidence);
incidence = delSel.next();
emit deleteIncidenceSignal(toDelete );
if ( dia.result() != 0 )
break;
}
mess = mess.sprintf( i18n("%d items remaining in list."), count() );
topLevelWidget ()->setCaption( mess );
p->mConfirm = confirm;
}
}
}
int KOListView::maxDatesHint()
{
return 0;
}
int KOListView::currentDateCount()
{
return 0;
}
QPtrList<Incidence> KOListView::selectedIncidences()
{
QPtrList<Incidence> eventList;
QListViewItem *item = mListView->firstChild ();
while ( item ) {
if ( item->isSelected() ) {
eventList.append(((KOListViewItem *)item)->data());
}
item = item->nextSibling();
}
// // QListViewItem *item = mListView->selectedItem();
//if (item) eventList.append(((KOListViewItem *)item)->data());
return eventList;
}
DateList KOListView::selectedDates()
{
DateList eventList;
return eventList;
}
void KOListView::showDates(bool show)
{
// Shouldn't we set it to a value greater 0? When showDates is called with
// show == true at first, then the columnwidths are set to zero.
static int oldColWidth1 = 0;
static int oldColWidth3 = 0;
if (!show) {
oldColWidth1 = mListView->columnWidth(1);
oldColWidth3 = mListView->columnWidth(3);
mListView->setColumnWidth(1, 0);
mListView->setColumnWidth(3, 0);
} else {
mListView->setColumnWidth(1, oldColWidth1);
mListView->setColumnWidth(3, oldColWidth3);
}
mListView->repaint();
}
void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
const QDate &td)
{
#ifndef KORG_NOPRINTER
calPrinter->preview(CalPrinter::Day, fd, td);
#endif
}
void KOListView::showDates()
{
showDates(true);
}
void KOListView::hideDates()
{
showDates(false);
}
+
void KOListView::resetFocus()
-{
+{
+ topLevelWidget()->setActiveWindow();
+ topLevelWidget()->raise();
mListView->setFocus();
}
void KOListView::updateView()
{
mListView->setFocus();
if ( mListView->firstChild () )
mListView->setCurrentItem( mListView->firstChild () );
}
void KOListView::updateConfig()
{
mListView->setFont ( KOPrefs::instance()->mListViewFont );
updateView();
}
void KOListView::setStartDate(const QDate &start)
{
mStartDate = start;
}
void KOListView::showDates(const QDate &start, const QDate &end)
{
clear();
mStartDate = start;
QDate date = start;
QPtrList<Journal> j_list;
while( date <= end ) {
addEvents(calendar()->events(date));
addTodos(calendar()->todos(date));
Journal* jo = calendar()->journal(date);
if ( jo )
j_list.append( jo );
date = date.addDays( 1 );
}
addJournals(j_list);
emit incidenceSelected( 0 );
updateView();
}
void KOListView::addEvents(QPtrList<Event> eventList)
{
Event *ev;
for(ev = eventList.first(); ev; ev = eventList.next()) {
addIncidence(ev);
}
if ( !mListView->currentItem() ){
updateView();
}
}
void KOListView::addTodos(QPtrList<Todo> eventList)
{
Todo *ev;
for(ev = eventList.first(); ev; ev = eventList.next()) {
addIncidence(ev);
}
if ( !mListView->currentItem() ){
updateView();
}
}
void KOListView::addJournals(QPtrList<Journal> eventList)
{
Journal *ev;
for(ev = eventList.first(); ev; ev = eventList.next()) {
addIncidence(ev);
}
if ( !mListView->currentItem() ){
updateView();
}
}
void KOListView::addIncidence(Incidence *incidence)
{
if ( mUidDict.find( incidence->uid() ) ) return;
// mListView->setFont ( KOPrefs::instance()->mListViewFont );
mUidDict.insert( incidence->uid(), incidence );
KOListViewItem *item = new KOListViewItem( incidence, mListView );
ListItemVisitor v(item, mStartDate );
if (incidence->accept(v)) return;
else delete item;
//qDebug("delete item ");
}
void KOListView::showEvents(QPtrList<Event> eventList)
{
clear();
addEvents(eventList);
// After new creation of list view no events are selected.
emit incidenceSelected( 0 );
}
int KOListView::count()
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index bb0e23e..eb5bb6e 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -166,146 +166,146 @@ void pickAlarmProgram()
mAlarmProgramButton->setOn(false);
mAlarmSoundButton->setOn(true);
}
}
};
};
typedef CustomListViewItem<Incidence *> KOListViewItem;
/**
This class provides the initialisation of a KOListViewItem for calendar
components using the Incidence::Visitor.
*/
class ListItemVisitor : public Incidence::Visitor
{
public:
ListItemVisitor(KOListViewItem *, QDate d);
~ListItemVisitor();
bool visit(Event *);
bool visit(Todo *);
bool visit(Journal *);
private:
KOListViewItem *mItem;
QDate mDate;
};
/**
This class provides a multi-column list view of events. It can
display events from one particular day or several days, it doesn't
matter. To use a view that only handles one day at a time, use
KODayListView.
@short multi-column list view of various events.
@author Preston Brown <pbrown@kde.org>
@see KOBaseView, KODayListView
*/
class KOListView;
class KOListViewListView : public KListView
{
Q_OBJECT
public:
KOListViewListView(KOListView * lv );
signals:
void newEvent();
void showIncidence( Incidence* );
public slots:
void popupMenu();
private:
QPoint mEventPos;
QPoint mEventGlobalPos;
QTimer* mPopupTimer;
int mYMousePos;
void keyPressEvent ( QKeyEvent * ) ;
void contentsMouseDoubleClickEvent(QMouseEvent *e);
void contentsMousePressEvent(QMouseEvent *e);
void contentsMouseReleaseEvent(QMouseEvent *e);
void contentsMouseMoveEvent(QMouseEvent *e);
bool mMouseDown;
};
class KOListView : public KOEventView
{
Q_OBJECT
public:
KOListView(Calendar *calendar, QWidget *parent = 0,
const char *name = 0);
~KOListView();
virtual int maxDatesHint();
virtual int currentDateCount();
virtual QPtrList<Incidence> selectedIncidences();
virtual DateList selectedDates();
void showDates(bool show);
Incidence* currentItem();
void addTodos(QPtrList<Todo> eventList);
void addJournals(QPtrList<Journal> eventList);
virtual void printPreview(CalPrinter *calPrinter,
const QDate &, const QDate &);
void readSettings(KConfig *config, QString setting = "KOListView Layout");
void writeSettings(KConfig *config, QString setting = "KOListView Layout");
void updateList();
void setStartDate(const QDate &start);
int count();
QString getWhatsThisText(QPoint p);
- void resetFocus();
signals:
void signalNewEvent();
void beamIncidenceList(QPtrList<Incidence>);
public slots:
+ void resetFocus();
virtual void updateView();
virtual void showDates(const QDate &start, const QDate &end);
virtual void showEvents(QPtrList<Event> eventList);
void clearSelection();
void allSelection();
void clear();
void beamDone( Ir *ir );
void showDates();
void hideDates();
void deleteAll();
void saveToFile();
void saveToFileVCS();
void saveDescriptionToFile();
void beamSelected();
void updateConfig();
void addCat();
void setCat();
void setAlarm();
void setCategories( bool removeOld );
void changeEventDisplay(Event *, int);
void defaultItemAction(QListViewItem *item);
void popupMenu(QListViewItem *item,const QPoint &,int);
protected slots:
void processSelectionChange(QListViewItem *);
protected:
void writeToFile( bool iCal );
void addEvents(QPtrList<Event> eventList);
void addIncidence(Incidence *);
KOListViewItem *getItemForEvent(Event *event);
private:
KOListViewListView *mListView;
KOEventPopupMenu *mPopupMenu;
KOListViewItem *mActiveItem;
QDict<Incidence> mUidDict;
QDate mStartDate;
void keyPressEvent ( QKeyEvent * ) ;
};
#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 2b7e41f..843526d 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -194,523 +194,513 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
case Key_Down:
if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
e->ignore();
break;
}
if ( count () ) {
if ( 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:
QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
e->ignore();
break;
case Key_Return:
case Key_Enter:
{
if ( currentItem() >= 0 ) {
emit doubleClicked( item( currentItem() ) );
e->accept();
} else {
e->ignore();
}
}
break;
case Key_Shift:
emit shiftDown();
break;
default:
e->ignore();
break;
}
}
void KNoScrollListBox::oneDown()
{
if ( count () ) {
if ( currentItem()+1 == count () ) {
emit nextCell();
} else {
resetOnFocusIn = false;
setCurrentItem((currentItem()+1)%count());
if(!itemVisible(currentItem())) {
if(currentItem() == 0) {
setTopItem(0);
} else {
setTopItem(topItem()+1);
}
}
}
}
}
void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
{
switch(e->key()) {
case Key_Shift:
emit shiftUp();
break;
default:
break;
}
}
void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
{
QListBox::mousePressEvent(e);
if(e->button() == RightButton) {
emit rightClick();
}
}
MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
: QListBoxItem()
{
mblockRepaint = true;
setText( s );
mMultiday = 0;
mIncidence = incidence;
mDate = qd;
mRecur = false;
mAlarm = false;
mReply = false;
mInfo = false;
mdayPos = 0;
isWeekItem = KOPrefs::instance()->mMonthViewWeek;
- //qDebug("NEWWWWWWWWWWWWW ");
}
void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
{
setText( s );
mMultiday = 0;
mIncidence = incidence;
mDate = qd;
mRecur = false;
mAlarm = false;
mReply = false;
mInfo = false;
mdayPos = 0;
- //qDebug("recucleeeeeeeeeeeeeeeee ");
}
void MonthViewItem::paint(QPainter *p)
{
if ( mblockRepaint ) {
- //qDebug("block ");
return;
}
- //qDebug("NON block ");
#if QT_VERSION >= 0x030000
bool sel = isSelected();
#else
bool sel = selected();
#endif
if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
{
p->setBackgroundColor( palette().color( QPalette::Normal, \
sel ? QColorGroup::Highlight : QColorGroup::Background ) );
p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
}
int x = 1;
//int y = 3;//(height() - mRecurPixmap.height()) /2;
int size = PIXMAP_SIZE;
if ( QApplication::desktop()->width() < 300 )
size = 3;
int heihei = height( listBox () );
int y = (heihei - size -1 ) /2;
if ( KOPrefs::instance()->mMonthShowIcons ) {
if ( mInfo ) {
p->fillRect ( x, y,size,size, Qt::darkGreen );
x += size + 1;
}
if ( mRecur ) {
p->fillRect ( x, y,size,size, Qt::blue );
x += size + 1;
}
if ( mAlarm ) {
p->fillRect ( x, y,size,size, Qt::red );
x += size + 1;
}
if ( mReply ) {
p->fillRect ( x, y,size,size, Qt::yellow );
x += size + 1;
}
}
if ( mMultiday ) {
int yyy = y+(size/2);
int sizeM = size+2;
p->setBrush( QBrush::SolidPattern );
p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
if ( mMultiday == 2 || mMultiday == 3 ) {
QPointArray 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 );
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 );
}
x += sizeM/2 + 1;
x += sizeM + 1;
}
if ( mIncidence->type() == "Todo" ){
Todo* td = ( Todo* ) mIncidence;
if ( td->isCompleted() ) {
int half = size/2;
p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
x += half+half + 4;
} else {
int val = td->percentComplete()/20;
p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
p->drawRect ( x, y-2,7,size+4);
x += size + 3;
}
}
QFontMetrics fm = p->fontMetrics();
int yPos;
int pmheight = size;
if( pmheight < fm.height() )
yPos = fm.ascent() + fm.leading()/2;
else
yPos = pmheight/2 - fm.height()/2 + fm.ascent();
p->setPen( palette().color( QPalette::Normal, sel ? \
QColorGroup::HighlightedText : QColorGroup::Foreground ) );
if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
p->drawText( x, yPos, text() );
if ( mIncidence->cancelled() ) {
int wid = fm.width( text() );
p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
}
} 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 ret = 10;
if ( lb )
ret = lb->fontMetrics().lineSpacing()+1;
return ret;
}
int MonthViewItem::width(const QListBox *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;
}
if( mAlarm ) {
x += size+1;
}
if( mReply ) {
x += size+1;
}
}
if( mMultiday ) {
x += size+1+2+size/2;
}
return( x + lb->fontMetrics().width( text() ) + 1 );
}
if ( ! lb )
return 10;
- //qDebug("ret wid %d ", lb->width());
return lb->width();
}
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);
//mItemList = new KNoScrollListBox( this );
setMinimumSize( 10, 10 );
setFrameStyle( QFrame::Panel | QFrame::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 *,
const QPoint &) ),
SLOT( contextMenu( QListBoxItem * ) ) );
connect( this, SIGNAL( highlighted( QListBoxItem *) ),
SLOT( selection( QListBoxItem * ) ) );
/*
connect( this, SIGNAL( clicked( QListBoxItem * ) ),
SLOT( selection( QListBoxItem * ) ) );
*/
}
#ifdef DESKTOP_VERSION
QToolTipGroup *MonthViewCell::toolTipGroup()
{
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 );
}
QDate MonthViewCell::date() const
{
return mDate;
}
void MonthViewCell::setPrimary( bool primary )
{
mPrimary = primary;
//setMyPalette();
}
void MonthViewCell::setMyPalette()
{
if ( mHoliday) {
if ( currentPalette == 1 ) return;
mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
setPalette( mHolidayPalette );
//mLabel->setPalette( mHolidayPalette );
currentPalette = 1;
} else {
if ( mPrimary ) {
if ( currentPalette == 2 ) return;
mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
//mLabel->setPalette( mPrimaryPalette );
setPalette( mPrimaryPalette );
currentPalette = 2;
} else {
if ( currentPalette == 3 ) return;
setPalette( mNonPrimaryPalette );
mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
//mLabel->setPalette( mNonPrimaryPalette );;
currentPalette = 3;
}
}
//QPalette pal = palette();
//mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
}
QPalette MonthViewCell::getPalette ()
{
if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
return mStandardPalette;
if ( mHoliday) {
return mHolidayPalette ;
} else {
if ( mPrimary ) {
return mPrimaryPalette ;
}
}
return mNonPrimaryPalette;
}
bool MonthViewCell::isPrimary() const
{
return mPrimary;
}
void MonthViewCell::setHoliday( bool holiday )
{
mHoliday = holiday;
//setMyPalette();
}
void MonthViewCell::setHoliday( const QString &holiday )
{
mHolidayString = holiday;
if ( !holiday.isEmpty() ) {
setHoliday( true );
}
}
void MonthViewCell::startUpdateCell()
{
mdayCount = 0;
setFocusPolicy(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 );
}
- /*
- if ( !isVisible() ){
- return;
- }
- */
- // qDebug("MonthViewCell::updateCell() ");
+
setPrimary( mDate.month()%2 );
setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
if ( mDate == QDate::currentDate() ) {
setLineWidth( 3 );
} else {
setLineWidth( 1 );
}
MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
//clear();
while ( CurrentAvailItem ) {
MonthViewItem *item = CurrentAvailItem;
CurrentAvailItem = (MonthViewItem *)item->next();
mAvailItemList.append( item );
takeItem ( item );
}
#ifdef DESKTOP_VERSION
QToolTip::remove(this);
#endif
mToolTip.clear();
//qApp->processEvents();
#if 0
if ( !mHolidayString.isEmpty() ) {
MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
item->setPalette( mHolidayPalette );
insertItem( item );
mToolTip.append ( mHolidayString );
}
#endif
}
int MonthViewCell::insertEvent(Event *event)
{
bool useToolTips = true;
#ifndef DESKTOP_VERSION
useToolTips = false;
#endif
QString mToolTipText;
setFocusPolicy(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 );
}
QString text;
int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
if (event->isMultiDay()) {
QString prefix = "<->";multiday = 2;
QString time;
if ( event->doesRecur() ) {
if ( event->recursOn( mDate) ) {
prefix ="->" ;multiday = 1;
}
else {
int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
if ( event->recursOn( mDate.addDays( -days)) ) {
prefix ="<-" ;multiday = 3;
}
}
} else {
if (mDate == event->dtStart().date()) {
prefix ="->" ;multiday = 1;
} else if (mDate == event->dtEnd().date()) {
prefix ="<-" ;multiday = 3;
}
}
if ( !event->doesFloat() ) {
if ( mDate == event->dtStart().date () )
time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
else if ( mDate == event->dtEnd().date () )
time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
}
text = time + event->summary();
if ( useToolTips )
mToolTipText += prefix + text;
} else {
if (event->doesFloat()) {
text = event->summary();
if ( useToolTips )
mToolTipText += text;
}
else {
text = KGlobal::locale()->formatTime(event->dtStart().time());
text += " " + event->summary();
if ( useToolTips )
mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
@@ -778,375 +768,373 @@ int MonthViewCell::insertEvent(Event *event)
QListBoxItem* it = this->item ( i );
if ( text < it->text() ) {
pos = i;
break;
}
++pos;
}
insertItem( item ,pos);
}
if ( useToolTips ) {
mToolTip.append( mToolTipText );
}
return mdayCount;
}
void MonthViewCell::insertTodo(Todo *todo)
{
setFocusPolicy(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 );
item->recycle( todo, mDate, text );
} else {
item = new MonthViewItem( todo, mDate, text );
}
//MonthViewItem *item = new MonthViewItem( todo, mDate, text );
//item->setPalette( mStandardPalette );
QPalette pal;
if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
QStringList categories = todo->categories();
QString cat = categories.first();
if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
pal = getPalette();
if (cat.isEmpty()) {
pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
} else {
pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
}
} else {
if (cat.isEmpty()) {
pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
} else {
pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
}
}
} else {
pal = mStandardPalette ;
}
item->setPalette( pal );
item->setRecur( todo->recurrence()->doesRecur() );
item->setAlarm( todo->isAlarmEnabled() );
item->setMoreInfo( todo->description().length() > 0 );
insertItem( item , count());
#ifdef DESKTOP_VERSION
mToolTip.append( text );
#endif
}
void MonthViewCell::repaintfinishUpdateCell()
{
MonthViewItem *mitem = (MonthViewItem*) firstItem ();
while ( mitem ) {
mitem->setBlockRepaint( false );
updateItem ( mitem );
mitem = (MonthViewItem *)mitem->next();
}
}
void MonthViewCell::finishUpdateCell()
{
#ifdef DESKTOP_VERSION
if (mToolTip.count() > 0 ) {
mToolTip.sort();
QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
}
#endif
//sort();
//setMyPalette();
setMyPalette();
resizeEvent( 0 );
}
void MonthViewCell::updateCell()
{
- //qDebug("MonthViewCell::updateCell() ");
if ( !mMonthView->isUpdatePossible() )
return;
startUpdateCell();
//mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
QPtrList<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 );
Todo *todo;
for(todo = todos.first(); todo; todo = todos.next()) {
insertTodo( todo );
}
finishUpdateCell();
// if ( isVisible())
//qApp->processEvents();
}
void MonthViewCell::updateConfig( bool bigFont ) // = false
{
if ( bigFont ) {
QFont fo = KOPrefs::instance()->mMonthViewFont;
int ps = fo.pointSize() + 2;
if ( ps < 18 )
ps += 2;
fo.setPointSize( ps );
setFont( fo );
} else
setFont( KOPrefs::instance()->mMonthViewFont );
QFontMetrics fm( font() );
mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
mHolidayPalette = mStandardPalette;
mPrimaryPalette = mStandardPalette;
mNonPrimaryPalette = mStandardPalette;
if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
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 ();
if (fi ) {
int ihei = fi->height( this );
int hei = numRows () * ihei;
if ( hei < height() - horizontalScrollBar()->height () ) {
setVScrollBarMode(QScrollView::AlwaysOff);
}
else
setVScrollBarMode(QScrollView::Auto);
if ( ihei *3 > height() ) {
setHScrollBarMode(QScrollView::AlwaysOff);
}
else {
setHScrollBarMode(QScrollView::Auto);
}
} else {
setVScrollBarMode(QScrollView::Auto);
setHScrollBarMode(QScrollView::Auto);
}
} else {
setVScrollBarMode(QScrollView::AlwaysOff);
setHScrollBarMode(QScrollView::AlwaysOff);
}
}
Incidence *MonthViewCell::selectedIncidence()
{
int index = currentItem();
if ( index < 0 ) return 0;
MonthViewItem *mitem =
static_cast<MonthViewItem *>( item( index ) );
if ( !mitem ) return 0;
return mitem->incidence();
}
QDate MonthViewCell::selectedIncidenceDate()
{
QDate qd;
int index = currentItem();
if ( index < 0 ) return qd;
MonthViewItem *mitem =
static_cast<MonthViewItem *>( item( index ) );
if ( !mitem ) return qd;
return mitem->incidenceDate();
}
void MonthViewCell::deselect()
{
clearSelection();
enableScrollBars( false );
// updateCell();
}
void MonthViewCell::select()
{
;// updateCell();
}
void MonthViewCell::resizeEvent ( QResizeEvent * e )
{
if ( !mMonthView->isUpdatePossible() )
return;
//qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
deselect();
mLabel->setMaximumHeight( height() - lineWidth()*2 );
QString text;
mLabel->setText( text );
bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
mLabel->resize( mLabelBigSize );
text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
} else {
mLabel->resize( mLabelSize );
text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
}
mLabel->setText( text );
int size = height() - mLabel->height() - lineWidth()-1;
//qDebug("LW %d ", lineWidth());
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 )
{
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 )
{
mMonthView->setSelectedCell( this );
- qDebug("CELL ");
if ( item == 0 ) {
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
return;
}
}
void MonthViewCell::contextMenu( QListBoxItem *item )
{
mMonthView->setPopupCell( this );
if ( !item ) {
mMonthView->showContextMenu( 0 );
return;
}
MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
Incidence *incidence = eventItem->incidence();
if ( incidence ) mMonthView->showContextMenu( incidence );
}
void MonthViewCell::selection( QListBoxItem *item )
{
if ( !item ) return;
mMonthView->setSelectedCell( this );
}
// *******************************************************************************
// *******************************************************************************
// *******************************************************************************
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 );
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;
updatePossible = false;
//updatePossible = true;
mCells.setAutoDelete( true );
mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
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->setLineWidth(1);
label->setAlignment(AlignCenter);
mDayLabels.insert( i, label );
label = new QLabel( mWeekView );
label->setFont(bfont);
label->setFrameStyle(QFrame::Panel|QFrame::Raised);
label->setLineWidth(1);
label->setAlignment(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->setFont(bfont);
connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
label->setFlat(true);
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro
index 1a81c7d..d88c300 100644
--- a/korganizer/korganizer.pro
+++ b/korganizer/korganizer.pro
@@ -42,169 +42,167 @@ LIBS += ../bin/libmicrokabc.so
#LIBS += -lldap
}
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
RC_FILE = winicons.rc
DEFINES += _WIN32_
LIBS += ../bin/microkdepim.lib
LIBS += ../bin/microkcal.lib
LIBS += ../bin/microkde.lib
LIBS += ../bin/microkabc.lib
LIBS += ../libical/lib/ical.lib
LIBS += ../libical/lib/icalss.lib
#LIBS += atls.lib
QMAKE_LINK += /NODEFAULTLIB:LIBC
#QMAKE_LINK += /NODEFAULTLIB:MSVCRT
#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
#olimport section
#blabla: {
LIBS += mfc71u.lib
DEFINES += _OL_IMPORT_
HEADERS += ../outport/msoutl9.h \
koimportoldialog.h
SOURCES += ../outport/msoutl9.cpp \
koimportoldialog.cpp
#}
#olimport section end
}
INTERFACES = kofilterview_base.ui
#filteredit_base.ui
# kdateedit.h \
HEADERS += datenavigatorcontainer.h \
filteredit_base.h \
alarmclient.h \
calendarview.h \
customlistviewitem.h \
datenavigator.h \
docprefs.h \
filtereditdialog.h \
incomingdialog.h \
incomingdialog_base.h \
interfaces/korganizer/baseview.h \
interfaces/korganizer/calendarviewbase.h \
journalentry.h \
kdatenavigator.h \
koagenda.h \
koagendaitem.h \
koagendaview.h \
kocounterdialog.h \
kodaymatrix.h \
kodialogmanager.h \
koeditordetails.h \
koeditorgeneral.h \
koeditorgeneralevent.h \
koeditorgeneraltodo.h \
koeditorrecurrence.h \
koeventeditor.h \
koeventpopupmenu.h \
koeventview.h \
koeventviewer.h \
koeventviewerdialog.h \
kofilterview.h \
koglobals.h \
koincidenceeditor.h \
kojournalview.h \
kolistview.h \
kolocationbox.h \
komonthview.h \
koprefs.h \
koprefsdialog.h \
kotimespanview.h \
kotodoeditor.h \
kotodoview.h \
kotodoviewitem.h \
koviewmanager.h \
kowhatsnextview.h \
ktimeedit.h \
lineview.h \
mainwindow.h \
navigatorbar.h \
outgoingdialog.h \
outgoingdialog_base.h \
publishdialog.h \
publishdialog_base.h \
savetemplatedialog.h \
searchdialog.h \
- simplealarmclient.h \
statusdialog.h \
timeline.h \
timespanview.h \
version.h \
../kalarmd/alarmdialog.h \
SOURCES += datenavigatorcontainer.cpp \
filteredit_base.cpp \
calendarview.cpp \
datenavigator.cpp \
docprefs.cpp \
filtereditdialog.cpp \
incomingdialog.cpp \
incomingdialog_base.cpp \
journalentry.cpp \
kdatenavigator.cpp \
koagenda.cpp \
koagendaitem.cpp \
koagendaview.cpp \
kocounterdialog.cpp \
kodaymatrix.cpp \
kodialogmanager.cpp \
koeditordetails.cpp \
koeditorgeneral.cpp \
koeditorgeneralevent.cpp \
koeditorgeneraltodo.cpp \
koeditorrecurrence.cpp \
koeventeditor.cpp \
koeventpopupmenu.cpp \
koeventview.cpp \
koeventviewer.cpp \
koeventviewerdialog.cpp \
kofilterview.cpp \
koglobals.cpp \
koincidenceeditor.cpp \
kojournalview.cpp \
kolistview.cpp \
kolocationbox.cpp \
komonthview.cpp \
koprefs.cpp \
koprefsdialog.cpp \
kotimespanview.cpp \
kotodoeditor.cpp \
kotodoview.cpp \
kotodoviewitem.cpp \
koviewmanager.cpp \
kowhatsnextview.cpp \
ktimeedit.cpp \
lineview.cpp \
main.cpp \
mainwindow.cpp \
navigatorbar.cpp \
outgoingdialog.cpp \
outgoingdialog_base.cpp \
publishdialog.cpp \
publishdialog_base.cpp \
savetemplatedialog.cpp \
searchdialog.cpp \
- simplealarmclient.cpp \
statusdialog.cpp \
timeline.cpp \
timespanview.cpp \
../kalarmd/alarmdialog.cpp
HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h
INTERFACES += calprintdayconfig_base.ui \
calprintmonthconfig_base.ui \
calprinttodoconfig_base.ui \
calprintweekconfig_base.ui
SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp
diff --git a/korganizer/korganizerE.pro b/korganizer/korganizerE.pro
index 91b5a01..553c265 100644
--- a/korganizer/korganizerE.pro
+++ b/korganizer/korganizerE.pro
@@ -1,152 +1,150 @@
TEMPLATE = app
CONFIG += qt warn_on
TARGET = kopi
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
DESTDIR=$(QPEDIR)/bin
INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/libkdepim interfaces $(KDEPIMDIR)/kabc $(QPEDIR)/include
DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
DEFINES += KORG_NOLVALTERNATION
#KORG_NOKABC
LIBS += -lmicrokdepim
LIBS += -lmicrokcal
LIBS += -lmicrokde
LIBS += -lmicroqtcompat
LIBS += $(GCC3EXTRALIB1)
LIBS += $(GCC3EXTRALIB2)
LIBS += -lqpe
LIBS += -ljpeg
LIBS += $(QTOPIALIB)
LIBS += -L$(QPEDIR)/lib
INTERFACES = kofilterview_base.ui
#filteredit_base.ui
HEADERS = datenavigatorcontainer.h \
wordsgerman.h \
filteredit_base.h \
alarmclient.h \
calendarview.h \
customlistviewitem.h \
datenavigator.h \
docprefs.h \
filtereditdialog.h \
incomingdialog.h \
incomingdialog_base.h \
interfaces/korganizer/baseview.h \
interfaces/korganizer/calendarviewbase.h \
journalentry.h \
kdateedit.h \
kdatenavigator.h \
koagenda.h \
koagendaitem.h \
koagendaview.h \
kocounterdialog.h \
kodaymatrix.h \
kodialogmanager.h \
koeditordetails.h \
koeditorgeneral.h \
koeditorgeneralevent.h \
koeditorgeneraltodo.h \
koeditorrecurrence.h \
koeventeditor.h \
koeventpopupmenu.h \
koeventview.h \
koeventviewer.h \
koeventviewerdialog.h \
kofilterview.h \
koglobals.h \
koincidenceeditor.h \
kojournalview.h \
kolistview.h \
kolocationbox.h \
komonthview.h \
koprefs.h \
koprefsdialog.h \
kotimespanview.h \
kotodoeditor.h \
kotodoview.h \
kotodoviewitem.h \
koviewmanager.h \
kowhatsnextview.h \
ktimeedit.h \
lineview.h \
mainwindow.h \
navigatorbar.h \
outgoingdialog.h \
outgoingdialog_base.h \
publishdialog.h \
publishdialog_base.h \
savetemplatedialog.h \
searchdialog.h \
- simplealarmclient.h \
statusdialog.h \
timeline.h \
timespanview.h \
version.h \
../kalarmd/alarmdialog.h
SOURCES = datenavigatorcontainer.cpp \
filteredit_base.cpp \
calendarview.cpp \
datenavigator.cpp \
docprefs.cpp \
filtereditdialog.cpp \
incomingdialog.cpp \
incomingdialog_base.cpp \
journalentry.cpp \
kdatenavigator.cpp \
koagenda.cpp \
koagendaitem.cpp \
koagendaview.cpp \
kocounterdialog.cpp \
kodaymatrix.cpp \
kodialogmanager.cpp \
koeditordetails.cpp \
koeditorgeneral.cpp \
koeditorgeneralevent.cpp \
koeditorgeneraltodo.cpp \
koeditorrecurrence.cpp \
koeventeditor.cpp \
koeventpopupmenu.cpp \
koeventview.cpp \
koeventviewer.cpp \
koeventviewerdialog.cpp \
kofilterview.cpp \
koglobals.cpp \
koincidenceeditor.cpp \
kojournalview.cpp \
kolistview.cpp \
kolocationbox.cpp \
komonthview.cpp \
koprefs.cpp \
koprefsdialog.cpp \
kotimespanview.cpp \
kotodoeditor.cpp \
kotodoview.cpp \
kotodoviewitem.cpp \
koviewmanager.cpp \
kowhatsnextview.cpp \
ktimeedit.cpp \
lineview.cpp \
main.cpp \
mainwindow.cpp \
navigatorbar.cpp \
outgoingdialog.cpp \
outgoingdialog_base.cpp \
publishdialog.cpp \
publishdialog_base.cpp \
savetemplatedialog.cpp \
searchdialog.cpp \
- simplealarmclient.cpp \
statusdialog.cpp \
timeline.cpp \
timespanview.cpp \
../kalarmd/alarmdialog.cpp
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index dd2c081..0a608dc 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -615,673 +615,648 @@ void KOTodoView::paintNeeded()
}
}
void KOTodoView::paintEvent(QPaintEvent * pevent)
{
if ( mPendingUpdateBeforeRepaint ) {
updateView();
mPendingUpdateBeforeRepaint = false;
}
KOrg::BaseView::paintEvent( pevent);
}
void KOTodoView::updateView()
{
pendingSubtodo = 0;
if ( mBlockUpdate ) {
return;
}
if ( !isVisible() ) {
mPendingUpdateBeforeRepaint = true;
return;
}
storeCurrentItem();
//qDebug("KOTodoView::updateView() %x", this);
if ( isFlatDisplay ) {
displayAllFlat();
resetCurrentItem();
return;
}
//qDebug("update ");
// kdDebug() << "KOTodoView::updateView()" << endl;
QFont fo = KOPrefs::instance()->mTodoViewFont;
mTodoListView->clear();
if ( mName == "todolistsmall" ) {
if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
int ps = fo.pointSize() -2;
if ( ps > 12 )
ps -= 2;
fo.setPointSize( ps );
}
}
mTodoListView->setFont( fo );
// QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
//mTodoListView->header()->setMaximumHeight(fm.height());
QPtrList<Todo> todoList = calendar()->todos();
/*
kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
Event *t;
for(t = todoList.first(); t; t = todoList.next()) {
kdDebug() << " " << t->getSummary() << endl;
if (t->getRelatedTo()) {
kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
}
QPtrList<Event> l = t->getRelations();
Event *c;
for(c=l.first();c;c=l.next()) {
kdDebug() << " - relation: " << c->getSummary() << endl;
}
}
*/
// Put for each Event a KOTodoViewItem in the list view. Don't rely on a
// specific order of events. That means that we have to generate parent items
// recursively for proper hierarchical display of Todos.
mTodoMap.clear();
Todo *todo;
todo = todoList.first();// todo; todo = todoList.next()) {
while ( todo ) {
bool next = true;
// qDebug("todo %s ", todo->summary().latin1());
Incidence *incidence = todo->relatedTo();
while ( incidence ) {
if ( incidence->type() == "Todo") {
//qDebug("related %s ",incidence->summary().latin1() );
if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
//qDebug("related not found ");
todoList.remove( );
todo = todoList.current();
next = false;
incidence = 0;
} else {
//qDebug("related found ");
incidence = incidence->relatedTo();
}
} else
incidence = 0;
}
if ( next )
todo = todoList.next();
}
-// qDebug("again .... ");
-// for(todo = todoList.first(); todo; todo = todoList.next()) {
-
-// qDebug("yytodo %s ", todo->summary().latin1());
-// }
- //qDebug("for ");
+
for(todo = todoList.first(); todo; todo = todoList.next()) {
if (!mTodoMap.contains(todo) && checkTodo( todo ) )
{
insertTodoItem(todo);
}
}
- //qDebug("for end ");
// Restore opened/closed state
mTodoListView->blockSignals( true );
if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
mTodoListView->blockSignals( false );
resetCurrentItem();
processSelectionChange();
}
void KOTodoView::storeCurrentItem()
{
mCurItem = 0;
mCurItemRootParent = 0;
mCurItemParent = 0;
mCurItemAbove = 0;
mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
if (mActiveItem) {
mCurItem = mActiveItem->todo();
KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
if ( activeItemAbove )
mCurItemAbove = activeItemAbove->todo();
mCurItemRootParent = mCurItem;
mCurItemParent = mCurItemRootParent->relatedTo();
while ( mCurItemRootParent->relatedTo() != 0 )
mCurItemRootParent = mCurItemRootParent->relatedTo();
}
mActiveItem = 0;
}
void KOTodoView::resetCurrentItem()
{
mTodoListView->setFocus();
KOTodoViewItem* foundItem = 0;
KOTodoViewItem* foundItemRoot = 0;
KOTodoViewItem* foundItemParent = 0;
KOTodoViewItem* foundItemAbove = 0;
if ( mTodoListView->firstChild () ) {
if ( mCurItem ) {
KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
while ( item ) {
if ( item->todo() == mCurItem ) {
foundItem = item;
break;
} else if ( item->todo() == mCurItemAbove ) {
foundItemAbove = item;
}
if ( item->todo() == mCurItemRootParent ) {
foundItemRoot = item;
}
if ( item->todo() == mCurItemParent ) {
foundItemParent = item;
}
item = (KOTodoViewItem*)item->itemBelow();
}
if ( ! foundItem ) {
if ( foundItemParent ) {
foundItem = foundItemParent;
} else {
if ( foundItemRoot )
foundItem = foundItemRoot;
else
foundItem = foundItemAbove;
}
}
}
if ( foundItem ) {
mTodoListView->setCurrentItem( foundItem );
mTodoListView->ensureItemVisible( foundItem );
} else {
mTodoListView->setCurrentItem( mTodoListView->firstChild () );
}
}
mTodoListView->setFocus();
}
//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
bool KOTodoView::checkTodo( Todo * todo )
{
if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
return false;
if ( !todo->isCompleted() ) {
if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
return true;
}
if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
if ( todo->hasStartDate() )
if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
return false;
if ( todo->hasDueDate() )
if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
return false;
}
return true;
}
void KOTodoView::restoreItemState( QListViewItem *item )
{
pendingSubtodo = 0;
while( item ) {
KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
item = item->nextSibling();
}
}
QMap<Todo *,KOTodoViewItem *>::ConstIterator
KOTodoView::insertTodoItem(Todo *todo)
{
// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
// TODO: Check, if dynmaic cast is necessary
pendingSubtodo = 0;
Incidence *incidence = todo->relatedTo();
if (incidence && incidence->type() == "Todo") {
Todo *relatedTodo = static_cast<Todo *>(incidence);
// kdDebug() << " has Related" << endl;
QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
itemIterator = mTodoMap.find(relatedTodo);
if (itemIterator == mTodoMap.end()) {
// kdDebug() << " related not yet in list" << endl;
itemIterator = insertTodoItem (relatedTodo);
}
// isn't this pretty stupid? We give one Todo to the KOTodoViewItem
// and one into the map. Sure finding is more easy but why? -zecke
KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
return mTodoMap.insert(todo,todoItem);
} else {
// kdDebug() << " no Related" << endl;
// see above -zecke
KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
return mTodoMap.insert(todo,todoItem);
}
}
void KOTodoView::updateConfig()
{
updateView();
mTodoListView->repaintContents();
}
QPtrList<Incidence> KOTodoView::selectedIncidences()
{
QPtrList<Incidence> selected;
KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
// if (!item) item = mActiveItem;
if (item) selected.append(item->todo());
return selected;
}
QPtrList<Todo> KOTodoView::selectedTodos()
{
QPtrList<Todo> selected;
KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
// if (!item) item = mActiveItem;
if (item) selected.append(item->todo());
return selected;
}
void KOTodoView::changeEventDisplay(Event *, int)
{
updateView();
}
void KOTodoView::showDates(const QDate &, const QDate &)
{
}
void KOTodoView::showEvents(QPtrList<Event>)
{
kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
}
void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
const QDate &td)
{
#ifndef KORG_NOPRINTER
calPrinter->preview(CalPrinter::Todolist, fd, td);
#endif
}
void KOTodoView::editItem(QListViewItem *item )
{
- // qDebug("editItem(QListViewItem *item ) ");
emit editTodoSignal(((KOTodoViewItem *)item)->todo());
}
void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
{
emit showTodoSignal(((KOTodoViewItem *)item)->todo());
}
void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
{
pendingSubtodo = 0;
mActiveItem = (KOTodoViewItem *)item;
if (item) {
switch (column){
case 1:
mPriorityPopupMenu->popup(QCursor::pos ()); break;
case 2:
mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
case 3:
moveTodo();
break;
case 8:
getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
default:
mItemPopupMenu->popup(QCursor::pos());
}
} else mPopupMenu->popup(QCursor::pos());
}
void KOTodoView::newTodo()
{
emit newTodoSignal();
}
void KOTodoView::newSubTodo()
{
if (mActiveItem) {
emit newSubTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::unparentTodo()
{
if (mActiveItem) {
emit unparentTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::reparentTodo()
{
if (mActiveItem) {
topLevelWidget()->setCaption(i18n("Click on new parent item"));
pendingSubtodo = mActiveItem;
}
}
void KOTodoView::editTodo()
{
if (mActiveItem) {
emit editTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::cloneTodo()
{
if (mActiveItem) {
emit cloneTodoSignal((Incidence*)mActiveItem->todo());
}
}
void KOTodoView::cancelTodo()
{
if (mActiveItem) {
emit cancelTodoSignal((Incidence*)mActiveItem->todo());
}
}
void KOTodoView::moveTodo()
{
if (mActiveItem) {
emit moveTodoSignal((Incidence*)mActiveItem->todo());
}
}
void KOTodoView::beamTodo()
{
if (mActiveItem) {
emit beamTodoSignal((Incidence*)mActiveItem->todo());
}
}
void KOTodoView::showTodo()
{
if (mActiveItem) {
emit showTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::deleteTodo()
{
if (mActiveItem) {
emit deleteTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::setNewPriority(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
mActiveItem->todo()->setPriority(mPriority[index]);
mActiveItem->construct();
todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
}
}
void KOTodoView::setNewPercentage(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
mActiveItem->setOn( true );
return;
} else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
if ( par && par->isOn() )
par->setOn( false );
}
if (mPercentage[index] == 100) {
mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
} else {
mActiveItem->todo()->setCompleted(false);
}
mActiveItem->todo()->setPercentComplete(mPercentage[index]);
mActiveItem->construct();
todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
}
}
QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
{
QPopupMenu* tempMenu = new QPopupMenu (this);
QStringList checkedCategories = todoItem->todo()->categories ();
tempMenu->setCheckable (true);
for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
it != KOPrefs::instance()->mCustomCategories.end ();
++it) {
int index = tempMenu->insertItem (*it);
mCategory[index] = *it;
if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
}
connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
return tempMenu;
}
void KOTodoView::changedCategories(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
QStringList categories = mActiveItem->todo()->categories ();
QString colcat = categories.first();
if (categories.find (mCategory[index]) != categories.end ())
categories.remove (mCategory[index]);
else
categories.insert (categories.end(), mCategory[index]);
categories.sort ();
if ( !colcat.isEmpty() ) {
if ( categories.find ( colcat ) != categories.end () ) {
categories.remove( colcat );
categories.prepend( colcat );
}
}
mActiveItem->todo()->setCategories (categories);
mActiveItem->construct();
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
}
}
void KOTodoView::itemDoubleClicked(QListViewItem *item)
{
if ( pendingSubtodo != 0 ) {
topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
}
pendingSubtodo = 0;
//int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
- qDebug("ROW %d ", row);
+ //qDebug("ROW %d ", row);
if (!item) {
newTodo();
return;
} else {
if ( row == 2 || row == 1 ) {
mActiveItem = (KOTodoViewItem *) item;
newSubTodo();
return;
}
if ( row == 5 || row == 6 ) {
mActiveItem = (KOTodoViewItem *) item;
toggleRunningItem();
return;
}
}
if ( KOPrefs::instance()->mEditOnDoubleClick )
editItem( item );
else
showItem( item , QPoint(), 0 );
}
void KOTodoView::toggleRunningItem()
{
// qDebug("KOTodoView::toggleRunning() ");
if ( ! mActiveItem )
return;
Todo * t = mActiveItem->todo();
if ( t->isRunning() ) {
int result = KMessageBox::warningContinueCancel(this,
i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true);
if (result != KMessageBox::Continue) return;
t->setRunning( false );
mActiveItem->construct();
} else {
int result = KMessageBox::warningContinueCancel(this,
i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true);
if (result != KMessageBox::Continue) return;
t->setRunning( true );
mActiveItem->construct();
}
}
void KOTodoView::itemClicked(QListViewItem *item)
{
//qDebug("KOTodoView::itemClicked %d", item);
if (!item) {
if ( pendingSubtodo != 0 ) {
topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
}
pendingSubtodo = 0;
return;
}
KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
if ( pendingSubtodo != 0 ) {
bool allowReparent = true;
QListViewItem *par = item;
while ( par ) {
if ( par == pendingSubtodo ) {
allowReparent = false;
break;
}
par = par->parent();
}
if ( !allowReparent ) {
topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
pendingSubtodo = 0;
} else {
Todo* newParent = todoItem->todo();
Todo* newSub = pendingSubtodo->todo();
pendingSubtodo = 0;
emit reparentTodoSignal( newParent,newSub );
return;
}
}
-#if 0
- // handled by the item itself
- bool completed = todoItem->todo()->isCompleted(); // Completed or not?
- qDebug("com %d ",completed );
- qDebug("itemclicked ");
- if (todoItem->isOn()) {
- qDebug("on ");
- if (!completed) {
- qDebug("set true ");
- todoItem->todo()->setCompleted(QDateTime::currentDateTime());
- }
- } else {
- qDebug("not on ");
- if (completed) {
- qDebug("set false ");
- todoItem->todo()->setCompleted(false);
- }
- }
-#endif
+
}
void KOTodoView::setDocumentId( const QString &id )
{
mDocPrefs->setDoc( id );
}
void KOTodoView::itemStateChanged( QListViewItem *item )
{
if (!item) return;
KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
}
void KOTodoView::saveLayout(KConfig *config, const QString &group) const
{
mTodoListView->saveLayout(config,group);
}
void KOTodoView::restoreLayout(KConfig *config, const QString &group)
{
mTodoListView->restoreLayout(config,group);
}
void KOTodoView::processSelectionChange()
{
// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
KOTodoViewItem *item =
static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
if ( !item ) {
emit incidenceSelected( 0 );
} else {
emit incidenceSelected( item->todo() );
}
}
void KOTodoView::modified(bool b)
{
emit isModified(b);
}
void KOTodoView::setTodoModified( Todo* todo )
{
todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
}
void KOTodoView::clearSelection()
{
mTodoListView->selectAll( false );
}
void KOTodoView::setAllOpen()
{
if ( isFlatDisplay ) {
isFlatDisplay = false;
mPopupMenu->setItemChecked( 8,false );
updateView();
} else {
storeCurrentItem();
}
setOpen(mTodoListView->firstChild(), true);
resetCurrentItem();
}
void KOTodoView::setAllClose()
{
if ( isFlatDisplay ) {
isFlatDisplay = false;
mPopupMenu->setItemChecked( 8,false );
updateView();
} else {
storeCurrentItem();
}
setOpen(mTodoListView->firstChild(), false);
resetCurrentItem();
}
void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
{
while ( item ) {
setOpen( item->firstChild(), setOpenI );
item->setOpen( setOpenI );
item = item->nextSibling();
}
}
void KOTodoView::displayAllFlat()
{
pendingSubtodo = 0;
if ( mBlockUpdate ) {
return;
}
mPopupMenu->setItemChecked( 8,true );
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index f1f2dd2..3aa9b6c 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -457,201 +457,193 @@ void KOViewManager::showAgendaView( bool fullScreen )
full = fullScreen;
if (!mAgendaView) {
full = false;
mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
addView(mAgendaView);
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
#endif
connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
// SIGNALS/SLOTS FOR DAY/WEEK VIEW
connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
mMainView, SLOT(newEvent(QDateTime)));
connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
mMainView, SLOT(newEvent(QDateTime,QDateTime)));
connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
mMainView, SLOT(newEvent(QDate)));
connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
mMainView, SLOT(editIncidence(Incidence *)));
connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
mMainView, SLOT(showIncidence(Incidence *)));
connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
mMainView, SLOT(deleteIncidence(Incidence *)));
connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
connect(mAgendaView, SIGNAL( toggleExpand() ),
mMainView, SLOT( toggleExpand() ) );
connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
SLOT( updateTodo( Todo *, int ) ) );
connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
mMainView, SIGNAL( todoModified( Todo *, int )));
connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
mMainView, SLOT ( moveIncidence( Incidence * ) ) );
connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
mMainView, SLOT ( beamIncidence( Incidence * ) ) );
connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
mAgendaView->readSettings();
mAgendaView->updateConfig();
}
showView( mAgendaView, full);
KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
}
void KOViewManager::showDayView()
{
mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
mFlagShowNextxDays = false;
globalFlagBlockLabel = 1;
globalFlagBlockAgenda = 1;
if ( mCurrentAgendaView != 1 )
mCurrentAgendaView = -1;
showAgendaView();
qApp->processEvents();
globalFlagBlockAgenda = 2;
globalFlagBlockLabel = 0;
mMainView->dateNavigator()->selectDates( 1 );
mCurrentAgendaView = 1 ;
}
void KOViewManager::showWorkWeekView()
{
mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
mFlagShowNextxDays = false;
globalFlagBlockAgenda = 1;
globalFlagBlockLabel = 1;
if ( mCurrentAgendaView != 5 )
mCurrentAgendaView = -1;
showAgendaView();
qApp->processEvents();
globalFlagBlockAgenda = 2;
globalFlagBlockLabel = 0;
mMainView->dateNavigator()->selectWorkWeek();
mCurrentAgendaView = 5 ;
}
void KOViewManager::showWeekView()
{
- /*
- globalFlagBlockAgenda = 2;
- qDebug("4globalFlagBlockAgenda = 2; ");
- //globalFlagBlockPainting = true;
- mMainView->dateNavigator()->selectWeek();
- showAgendaView();
- */
-
-
+
mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
mFlagShowNextxDays = false;
globalFlagBlockAgenda = 1;
globalFlagBlockLabel = 1;
if ( mCurrentAgendaView != 7 )
mCurrentAgendaView = -1;
showAgendaView();
qApp->processEvents();
globalFlagBlockAgenda = 2;
globalFlagBlockLabel = 0;
mMainView->dateNavigator()->selectWeek();
mCurrentAgendaView = 7 ;
}
void KOViewManager::showNextXView()
{
globalFlagBlockAgenda = 1;
if ( mCurrentAgendaView != 3 )
mCurrentAgendaView = -1;
showAgendaView(KOPrefs::instance()->mFullViewMonth);
globalFlagBlockAgenda = 2;
mMainView->dateNavigator()->selectDates( QDate::currentDate(),
KOPrefs::instance()->mNextXDays );
mFlagShowNextxDays = true;
mCurrentAgendaView = 3 ;
KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
}
bool KOViewManager::showsNextDays()
{
return mFlagShowNextxDays;
}
void KOViewManager::createMonthView()
{
if (!mMonthView) {
mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
addView(mMonthView);
// mMonthView->show();
// SIGNALS/SLOTS FOR MONTH VIEW
connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate )));
connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)),
mMainView, SLOT(newTodoDateTime(QDateTime, bool)));
connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
mMainView, SLOT(newEvent(QDateTime)));
connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
mMainView, SLOT(showIncidence(Incidence *)));
connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
mMainView, SLOT(editIncidence(Incidence *)));
connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
mMainView, SLOT(deleteIncidence(Incidence *)));
connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
mMainView, SLOT ( moveIncidence( Incidence * ) ) );
connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
mMainView, SLOT ( beamIncidence( Incidence * ) ) );
connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
connect( mMonthView, SIGNAL( selectMonth() ),
mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
mMainView, SLOT ( showDay( QDate ) ) );
connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
connect( mMonthView, SIGNAL(nextMonth() ),
mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
connect( mMonthView, SIGNAL(prevMonth() ),
mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
mMainView->dateNavigator(), SLOT( selectNextYear() ) );
connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 8473db9..65d8ac3 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -1,185 +1,183 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(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 <qlayout.h>
#include <qtextbrowser.h>
#include <qtextcodec.h>
#include <qfileinfo.h>
#include <qlabel.h>
#include <qapplication.h>
#ifdef DESKTOP_VERSION
#include <qpaintdevicemetrics.h>
#endif
#include <kglobal.h>
#include <klocale.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <kmessagebox.h>
#include <libkcal/calendar.h>
#ifndef KORG_NOPRINTER
#include "calprinter.h"
#endif
#include "koglobals.h"
#include "koprefs.h"
#include "koeventviewerdialog.h"
#include "koeventviewer.h"
#include <qstylesheet.h>
#include "kowhatsnextview.h"
using namespace KOrg;
void WhatsNextTextBrowser::setSource(const QString& n)
{
if (n.startsWith("event:")) {
emit showIncidence(n);
return;
} else if (n.startsWith("todo:")) {
emit showIncidence(n);
return;
} else {
QTextBrowser::setSource(n);
}
}
void WhatsNextTextBrowser::printMe()
{
#ifdef DESKTOP_VERSION
KOPrintPrefs pp ( this );
if (!pp.exec() )
return;
int scaleval = pp.printMode() ;
QPrinter printer;
if (!printer.setup() )
return;
QPainter p;
p.begin ( &printer );
QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
float dx, dy;
int wid = (m.width() * 9)/10;
dx = (float) wid/(float)contentsWidth ();
dy = (float)(m.height()) / (float)contentsHeight ();
float scale;
// scale to fit the width or height of the paper
if ( dx < dy )
scale = dx;
else
scale = dy;
p.translate( m.width()/10,0 );
- qDebug("Scale: %f ", scale );
if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
- qDebug("SCALE ");
p.scale( scale, scale );
}
drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
p.end();
#endif
}
KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
const char *name)
: KOrg::BaseView(calendar, parent, name)
{
// mDateLabel =
// new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
// mDateLabel->setMargin(2);
// mDateLabel->setAlignment(AlignCenter);
setFont( KOPrefs::instance()->mWhatsNextFont );
mView = new WhatsNextTextBrowser(this);
connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
QStyleSheet* stsh = mView->styleSheet();
QStyleSheetItem * style ;
style = stsh->item ("h2" );
if ( style ) {
style->setMargin(QStyleSheetItem::MarginAll,0);
}
style = stsh->item ("h3" );
if ( style ) {
style->setMargin(QStyleSheetItem::MarginAll,0);
}
mEventViewer = 0;
QBoxLayout *topLayout = new QVBoxLayout(this);
// topLayout->addWidget(mDateLabel);
topLayout->addWidget(mView);
mTimer = new QTimer( this );
connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView()));
connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
}
KOWhatsNextView::~KOWhatsNextView()
{
}
int KOWhatsNextView::maxDatesHint()
{
return 0;
}
int KOWhatsNextView::currentDateCount()
{
return 0;
}
QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
{
QPtrList<Incidence> eventList;
return eventList;
}
void KOWhatsNextView::printMe()
{
#ifdef DESKTOP_VERSION
mView->printMe();
#endif
}
void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
const QDate &td)
{
#ifndef KORG_NOPRINTER
calPrinter->preview(CalPrinter::Day, fd, td);
#endif
}
void KOWhatsNextView::updateConfig()
{
setFont( KOPrefs::instance()->mWhatsNextFont );
updateView();
}
void KOWhatsNextView::showEvent ( QShowEvent * e )
{
//qDebug("KOWhatsNextView::showEvent ");
restartTimer();
QWidget::showEvent ( e );
}
void KOWhatsNextView::hideEvent ( QHideEvent * e)
{
//qDebug(" KOWhatsNextView::hideEvent");
mTimer->stop();
QWidget::hideEvent ( e );
}
void KOWhatsNextView::restartTimer()
{
//qDebug("KOWhatsNextView::restartTimer() ");
mTimer->start( 300000 );
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
index 61a0931..df9b2fc 100644
--- a/korganizer/ktimeedit.cpp
+++ b/korganizer/ktimeedit.cpp
@@ -244,204 +244,202 @@ void KOTimeEdit::keyPressEvent(QKeyEvent *e)
case 6:
case 5:
if(!hour12Format) {
lineEdit()->setCursorPosition(cpos = 4);
} else {
addTime(QTime(12,0,0), false );
setSelect ( 5 , 2 );
break;
}
case 4:
addTime(QTime(0,1,0), false );
setSelect ( cpos , 1 );
break;
case 3:
addTime(QTime(0,10,0), false );
setSelect ( cpos , 1 );
break;
case 2:
lineEdit()->setCursorPosition(--cpos);
case 1:
case 0:
addTime(QTime(1,0,0), false );
setSelect ( 0, 2 );
break;
}
break;
case Key_Down:
if ( e->state () == Qt::ControlButton ) {
subTime(QTime(0,15,0), false );
lineEdit()->setCursorPosition(3);
setSelect( 3 , 2 );
}
else
if ( e->state () == Qt::ShiftButton ) {
subTime(QTime(1,0,0), false );
lineEdit()->setCursorPosition(0);
setSelect( 0 , 2 );
}
else
// switch time down, cursor location depend
switch (cpos) {
case 7:
case 6:
case 5:
if(!hour12Format) {
lineEdit()->setCursorPosition(cpos = 4);
} else {
subTime(QTime(12,0,0), false );
setSelect ( 5 , 2 );
break;
}
case 4:
subTime(QTime(0,1,0), false );
setSelect ( cpos , 1 );
break;
case 3:
subTime(QTime(0,10,0), false );
setSelect ( cpos , 1 );
break;
case 2:
lineEdit()->setCursorPosition(--cpos);
case 1:
case 0:
subTime(QTime(1,0,0), false );
setSelect ( 0 , 2 );
break;
}
break;
// set cursor to correct place
case Key_Left:
if ( cpos == 3 )
--cpos;
if ( cpos > 0) {
lineEdit()->setCursorPosition(--cpos);
setSelect ( cpos , 1 );
}
else
setSelect ( 0 , 1 );
break;
// set cursor to correct place
case Key_Right:
if ( cpos == 1 )
++cpos;
if ( cpos < maxpos ) {
lineEdit()->setCursorPosition(++cpos);
setSelect ( cpos , 1 );
}
break;
// rest
case Key_Prior:
subTime(QTime(1,0,0));
break;
case Key_Next:
addTime(QTime(1,0,0));
break;
case Key_Backspace:
- qDebug("+++++++++++back ");
if ( cpos > 0) {
if ( cpos == 3 )
--cpos;
if ( cpos > 5)
cpos = 5;
text.at( cpos-1 ) = '0';
lineEdit()->setText( text );
lineEdit()->setCursorPosition(--cpos);
setSelect ( cpos , 1 );
changedText();
- qDebug("---------back ");
}
break;
} // switch arrows
// if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos
if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) {
lineEdit()->deselect();
cpos = 0;
lineEdit()->setCursorPosition(cpos);
setSelect(cpos , 1);
}
if ( cpos == 2 ) {
lineEdit()->setCursorPosition(++cpos);
}
// num keys when cursorPos preEnd
if ( cpos < 5 ) {
// switch another keys
switch(e->key()) {
case Key_Delete:
text.at( cpos ) = '0';
lineEdit()->setText( text );
lineEdit()->setCursorPosition(cpos);
setSelect ( cpos , 1 );
changedText();
break;
case Key_9:
case Key_8:
case Key_7:
case Key_6:
if ( !(cpos == 1 || cpos == 4) )
return;
if ( cpos == 1 && text.at( 0 ) > '1')
text.at( 0 ) = '1';
case Key_5:
case Key_4:
case Key_3:
if ( cpos < 1 )
return;
if ( hour12Format && cpos == 1 )
return;
case Key_2:
if ( hour12Format && cpos == 0 )
return;
if ( cpos == 0 && text.at( 1 ) > '3')
text.at( 1 ) = '3';
case Key_1:
case Key_0:
if ( hour12Format ) {
if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' )
return;
if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' )
text.at( 1 ) = '1';
}
text.at( cpos ) = QChar ( e->key() );
lineEdit()->setText( text );
if ( cpos == 1 )
++cpos;
if ( cpos < 5)
lineEdit()->setCursorPosition(++cpos);
setSelect( cpos , 1 );
changedText();
break;
case Key_Home:
lineEdit()->setCursorPosition(0);
setSelect( cpos , 1 );
break;
case Key_End:
lineEdit()->setCursorPosition(5);
lineEdit()->deselect();
break;
default:
// QComboBox::keyPressEvent(e);
break;
} // switch num keys
} else if ( cpos == 5 ) {// if cpos < 5
if ( hour12Format ) {
if ( e->key() == Key_A ) {
text.at( 5 ) = 'a';
lineEdit()->setText( text );
lineEdit()->setCursorPosition(5);
} else if ( e->key() == Key_P ) {
text.at( 5 ) = 'p';
lineEdit()->setText( text );
lineEdit()->setCursorPosition(5);
}
}
}
}
void KOTimeEdit::updateText()
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 8e5d108..95bef66 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,159 +1,158 @@
#include <stdlib.h>
#include <qaction.h>
#include <qpopupmenu.h>
#include <qpainter.h>
#include <qwhatsthis.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qtextcodec.h>
#include <qfile.h>
#include <qdir.h>
#include <qapp.h>
#include <qfileinfo.h>
#include <qlabel.h>
#include <qspinbox.h>
#include <qcheckbox.h>
#include <qmap.h>
#include <qwmatrix.h>
#include <qtextbrowser.h>
#include <qtextstream.h>
#ifndef DESKTOP_VERSION
#include <qpe/global.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qtopia/alarmserver.h>
#include <qtopia/qcopenvelope_qws.h>
#include <unistd.h> // for sleep
#else
#include <qmenubar.h>
#include <qtoolbar.h>
#include <qapplication.h>
//#include <resource.h>
#endif
#include <libkcal/calendarlocal.h>
#include <libkcal/todo.h>
#include <libkcal/phoneformat.h>
#include <libkdepim/ksyncprofile.h>
#include <libkdepim/phoneaccess.h>
#include <libkcal/kincidenceformatter.h>
#include <libkdepim/kpimglobalprefs.h>
#include "calendarview.h"
#include "koviewmanager.h"
#include "datenavigator.h"
#include "koagendaview.h"
#include "koagenda.h"
#include "kodialogmanager.h"
#include "kdialogbase.h"
#include "kapplication.h"
#include "kofilterview.h"
#include "kstandarddirs.h"
#include "koprefs.h"
#include "kfiledialog.h"
#include "koglobals.h"
#include "kglobal.h"
#include "ktoolbar.h"
#include "klocale.h"
#include "kconfig.h"
-#include "simplealarmclient.h"
#include "externalapphandler.h"
using namespace KCal;
#ifndef _WIN32_
#include <unistd.h>
#else
#ifdef _OL_IMPORT_
#include "koimportoldialog.h"
#endif
#endif
#include "mainwindow.h"
class KOex2phonePrefs : public QDialog
{
public:
KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
QDialog( parent, name, true )
{
setCaption( i18n("Export to phone options") );
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setSpacing( 3 );
lay->setMargin( 3 );
QLabel *lab;
lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
lab->setAlignment (AlignHCenter );
QHBox* temphb;
temphb = new QHBox( this );
new QLabel( i18n("I/O device: "), temphb );
mPhoneDevice = new QLineEdit( temphb);
lay->addWidget( temphb );
temphb = new QHBox( this );
new QLabel( i18n("Connection: "), temphb );
mPhoneConnection = new QLineEdit( temphb);
lay->addWidget( temphb );
temphb = new QHBox( this );
new QLabel( i18n("Model(opt.): "), temphb );
mPhoneModel = new QLineEdit( temphb);
lay->addWidget( temphb );
mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
mWriteBackFuture->setChecked( true );
lay->addWidget( mWriteBackFuture );
temphb = new QHBox( this );
new QLabel( i18n("Max. weeks in future: ") , temphb );
mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
mWriteBackFutureWeeks->setValue( 8 );
lay->addWidget( temphb );
lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
lab->setAlignment (AlignHCenter );
QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
lay->addWidget( ok );
QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
lay->addWidget( cancel );
connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
resize( 220, 240 );
qApp->processEvents();
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
move( (dw-width())/2, (dh - height() )/2 );
}
public:
QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
QCheckBox* mWriteBackFuture;
QSpinBox* mWriteBackFutureWeeks;
};
int globalFlagBlockStartup;
MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
QMainWindow( parent, name )
{
mClosed = false;
//QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
QString confFile = locateLocal("config","korganizerrc");
QFileInfo finf ( confFile );
bool showWarning = !finf.exists();
setIcon(SmallIcon( "ko24" ) );
mBlockAtStartup = true;
mFlagKeyPressed = false;
setCaption("KO/Pi");
KOPrefs *p = KOPrefs::instance();
KPimGlobalPrefs::instance()->setGlobalConfig();
p->mCurrentDisplayedView = 0;
if ( p->mHourSize > 22 )
p->mHourSize = 22;
QMainWindow::ToolBarDock tbd;
if ( p->mToolBarHor ) {
if ( p->mToolBarUp )
tbd = Bottom;
else
tbd = Top;
}
else {
if ( p->mToolBarUp )
@@ -192,332 +191,331 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
filterPopupMenu = new QPopupMenu( this );
filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
QString addTest = "Ax";
#ifdef DESKTOP_VERSION
addTest = "AAAx";
#endif
filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) );
addToolBar (filterToolBar , tbd );
connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
filterToolBar->hide();
} else {
filterToolBar = 0;
filterMenubar = 0;
filterPopupMenu = 0;
}
if ( p->mShowIconOnetoolbar ) {
viewToolBar = iconToolBar ;
navigatorToolBar = iconToolBar ;
} else {
#ifndef DESKTOP_VERSION
setToolBarsMovable( false );
#endif
if ( p->mToolBarHorV ) {
if ( p->mToolBarUpV )
tbd = Bottom;
else
tbd = Top;
}
else {
if ( p->mToolBarUpV )
tbd = Right;
else
tbd = Left;
}
viewToolBar = new QPEToolBar( this );
addToolBar (viewToolBar , tbd );
if ( p->mToolBarHorN ) {
if ( p->mToolBarUpN )
tbd = Bottom;
else
tbd = Top;
}
else {
if ( p->mToolBarUpN )
tbd = Right;
else
tbd = Left;
}
navigatorToolBar = new QPEToolBar( this );
addToolBar (navigatorToolBar , tbd );
}
mCalendarModifiedFlag = false;
QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
splash->setAlignment ( AlignCenter );
setCentralWidget( splash );
#ifndef DESKTOP_VERSION
showMaximized();
#endif
//qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
setDefaultPreferences();
mCalendar = new CalendarLocal();
mView = new CalendarView( mCalendar, this,"mCalendar " );
mView->hide();
//mView->resize(splash->size() );
initActions();
mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
mSyncManager->setBlockSave(false);
mView->setSyncManager(mSyncManager);
#ifndef DESKTOP_VERSION
iconToolBar->show();
qApp->processEvents();
#endif
//qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
int vh = height() ;
int vw = width();
//qDebug("Toolbar hei %d ",iconToolBar->height() );
if ( iconToolBar->orientation () == Qt:: Horizontal ) {
vh -= iconToolBar->height();
} else {
vw -= iconToolBar->height();
}
//mView->setMaximumSize( splash->size() );
//mView->resize( splash->size() );
//qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
mView->readSettings();
bool newFile = false;
if( !QFile::exists( defaultFileName() ) ) {
QFileInfo finfo ( defaultFileName() );
QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
- qDebug("oldfile %s ", oldFile.latin1());
QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
finfo.setFile( oldFile );
if (finfo.exists() ) {
KMessageBox::information( this, message);
mView->openCalendar( oldFile );
qApp->processEvents();
} else {
oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
finfo.setFile( oldFile );
if (finfo.exists() ) {
KMessageBox::information( this, message);
mView->openCalendar( oldFile );
qApp->processEvents();
}
}
mView->saveCalendar( defaultFileName() );
newFile = true;
}
QTime neededSaveTime = QDateTime::currentDateTime().time();
mView->openCalendar( defaultFileName() );
int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
qDebug("KO: Calendar loading time: %d ms",msNeeded );
if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
KOPrefs::instance()->setAllDefaults();
int count = mView->addCategories();
}
processIncidenceSelection( 0 );
connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
SLOT( processIncidenceSelection( Incidence * ) ) );
connect( mView, SIGNAL( modifiedChanged( bool ) ),
SLOT( slotModifiedChanged( bool ) ) );
connect( mView, SIGNAL( tempDisableBR(bool) ),
SLOT( disableBR(bool) ) );
connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
mView->setModified( false );
mBlockAtStartup = false;
mView->setModified( false );
setCentralWidget( mView );
globalFlagBlockStartup = 0;
mView->show();
delete splash;
if ( newFile )
mView->updateConfig();
// qApp->processEvents();
//qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
//fillSyncMenu();
connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
mSyncManager->setDefaultFileName( sentSyncFile());
connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
mSyncManager->fillSyncMenu();
mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
if ( showWarning ) {
KMessageBox::information( this,
"You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
qApp->processEvents();
mView->dialogManager()->showSyncOptions();
}
//US listen for result adressed from Ka/Pi
#ifndef DESKTOP_VERSION
connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
#endif
#ifndef DESKTOP_VERSION
infrared = 0;
#endif
updateFilterToolbar();
updateWeek( mView->startDate() );
connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
SLOT( updateWeekNum( const KCal::DateList & ) ) );
mBRdisabled = false;
//toggleBeamReceive();
}
MainWindow::~MainWindow()
{
//qDebug("MainWindow::~MainWindow() ");
//save toolbar location
delete mCalendar;
delete mSyncManager;
#ifndef DESKTOP_VERSION
if ( infrared )
delete infrared;
#endif
}
void MainWindow::disableBR(bool b)
{
#ifndef DESKTOP_VERSION
if ( b ) {
if ( infrared ) {
toggleBeamReceive();
mBRdisabled = true;
}
mBRdisabled = true;
} else {
if ( mBRdisabled ) {
mBRdisabled = false;
//makes no sense,because other cal ap is probably running
// toggleBeamReceive();
}
}
#endif
}
bool MainWindow::beamReceiveEnabled()
{
#ifndef DESKTOP_VERSION
return ( infrared != 0 );
#endif
return false;
}
void MainWindow::toggleBeamReceive()
{
if ( mBRdisabled )
return;
#ifndef DESKTOP_VERSION
if ( infrared ) {
- qDebug("disable BeamReceive ");
+ qDebug("KO: Disable BeamReceive ");
delete infrared;
infrared = 0;
brAction->setOn(false);
return;
}
- qDebug("enable BeamReceive ");
+ qDebug("KO: Enable BeamReceive ");
brAction->setOn(true);
infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
#endif
}
void MainWindow::showMaximized ()
{
#ifndef DESKTOP_VERSION
if ( ! globalFlagBlockStartup )
if ( mClosed )
mView->goToday();
#endif
QWidget::showMaximized () ;
mClosed = false;
}
void MainWindow::closeEvent( QCloseEvent* ce )
{
if ( ! KOPrefs::instance()->mAskForQuit ) {
saveOnClose();
mClosed = true;
ce->accept();
return;
}
switch( QMessageBox::information( this, "KO/Pi",
i18n("Do you really want\nto close KO/Pi?"),
i18n("Close"), i18n("No"),
0, 0 ) ) {
case 0:
saveOnClose();
mClosed = true;
ce->accept();
break;
case 1:
ce->ignore();
break;
case 2:
default:
break;
}
}
void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
{
QDataStream stream( data, IO_ReadOnly );
// QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
//QString datamess;
//qDebug("message ");
qDebug("KO: QCOP message received: %s ", cmsg.data() );
if ( cmsg == "setDocument(QString)" ) {
QDataStream stream( data, IO_ReadOnly );
QString fileName;
stream >> fileName;
//qDebug("filename %s ", fileName.latin1());
showMaximized();
raise();
KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
mSyncManager->slotSyncMenu( 1002 );
return;
}
if ( cmsg == "-writeFile" ) {
// I made from the "-writeFile" an "-writeAlarm"
mView->viewManager()->showWhatsNextView();
mCalendar->checkAlarmForIncidence( 0, true);
showMaximized();
raise();
return;
}
if ( cmsg == "-writeFileSilent" ) {
// I made from the "-writeFile" an "-writeAlarm"
// mView->viewManager()->showWhatsNextView();
mCalendar->checkAlarmForIncidence( 0, true);
//showMaximized();
//raise();
hide();
return;
}
if ( cmsg == "-newCountdown" ) {
qDebug("newCountdown ");
}
QString msg ;
QString allmsg = cmsg;
while ( allmsg.length() > 0 ) {
int nextC = allmsg.find( "-", 1 );
if ( nextC == -1 ) {
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index f2a6c60..45ed04d 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,175 +1,166 @@
#ifndef KORGE_MAINWINDOW_H
#define KORGE_MAINWINDOW_H
#include <qmainwindow.h>
#include <qtimer.h>
#include <qdict.h>
#include <qfile.h>
#include <qmenubar.h>
#include <qtextstream.h>
#include <qregexp.h>
#include <libkcal/incidence.h>
-#include "simplealarmclient.h"
#include <ksyncmanager.h>
#ifndef DESKTOP_VERSION
#include <qcopchannel_qws.h>
#endif
class QAction;
class CalendarView;
class KSyncProfile;
#ifdef DESKTOP_VERSION
#define QPEToolBar QToolBar
#define QPEMenuBar QMenuBar
#endif
class QPEToolBar;
class QPEMenuBar;
namespace KCal {
class CalendarLocal;
}
-class KOMenuBar : public QMenuBar
-{
- public:
- KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;}
- QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );}
-};
-
using namespace KCal;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
~MainWindow();
bool beamReceiveEnabled();
static QString defaultFileName();
static QString syncFileName();
static QString resourcePath();
public slots:
void setCaption ( const QString & );
void updateWeekNum(const KCal::DateList &);
void updateWeek(QDate);
void updateFilterToolbar();
virtual void showMaximized ();
void configureAgenda( int );
void recieve( const QCString& msg, const QByteArray& data );
protected slots:
void setCaptionToDates();
void weekAction();
void about();
void licence();
void faq();
void usertrans();
void features();
void synchowto();
void storagehowto();
void timetrackinghowto();
void kdesynchowto();
void multisynchowto();
void whatsNew();
void keyBindings();
void aboutAutoSaving();;
void aboutKnownBugs();
void processIncidenceSelection( Incidence * );
void importQtopia();
void importBday();
void importOL();
void importIcal();
void importFile( QString, bool );
void quickImportIcal();
void slotModifiedChanged( bool );
void save();
void saveStopTimer();
void configureToolBar( int );
void printSel();
void printCal();
void saveCalendar();
void loadCalendar();
void exportVCalendar();
void fillFilterMenu();
void fillFilterMenuTB();
void selectFilter( int );
void fillFilterMenuPopup();
void selectFilterPopup( int );
void exportToPhone( int );
void toggleBeamReceive();
void disableBR(bool);
signals:
void selectWeek ( int );
private slots:
void showConfigureAgenda();
void getFile( bool );
void syncFileRequest();
protected:
void hideEvent ( QHideEvent * );
QString sentSyncFile();
void displayText( QString, QString);
void enableIncidenceActions( bool );
private:
bool mBRdisabled;
#ifndef DESKTOP_VERSION
QCopChannel* infrared;
#endif
QAction* brAction;
KSyncManager* mSyncManager;
bool mClosed;
void saveOnClose();
bool mFlagKeyPressed;
bool mBlockAtStartup;
QPEToolBar *iconToolBar;
QPEToolBar *viewToolBar;
QPEToolBar *navigatorToolBar;
QPEToolBar *filterToolBar;
QPEMenuBar *filterMenubar;
QPopupMenu * filterPopupMenu;
void initActions();
void setDefaultPreferences();
void resizeEvent( QResizeEvent* e);
void keyPressEvent ( QKeyEvent * ) ;
void keyReleaseEvent ( QKeyEvent * ) ;
QPopupMenu *configureToolBarMenu;
QPopupMenu *selectFilterMenu;
QPopupMenu *selectFilterMenuTB;
QPopupMenu *configureAgendaMenu, *syncMenu;
CalendarLocal *mCalendar;
CalendarView *mView;
QAction *mNewSubTodoAction;
QAction *mWeekAction;
QFont mWeekFont;
QPixmap mWeekPixmap;
QColor mWeekBgColor;
QAction *mShowAction;
QAction *mEditAction;
QAction *mDeleteAction;
QAction *mCloneAction;
QAction *mMoveAction;
QAction *mBeamAction;
QAction *mCancelAction;
QAction *mToggleNav;
QAction *mToggleFilter;
QAction *mToggleAllday;
QAction *actionFilterMenuTB;
void closeEvent( QCloseEvent* ce );
- SimpleAlarmClient mAlarmClient;
QTimer mSaveTimer;
//bool mBlockSaveFlag;
bool mCalendarModifiedFlag;
QPixmap loadPixmap( QString );
};
#endif
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 7a945e3..de65b53 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -352,115 +352,114 @@ void SearchDialog::search(const QRegExp &re)
}
QPtrList<Todo> todos = mCalendar->todos( );
mMatchedTodos.clear();
if ( mSearchTodo->isChecked() ) {
Todo *tod;
for(tod=todos.first();tod;tod=todos.next()) {
if (mSummaryCheck->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(tod->summary()) != -1)
#else
if (re.match(tod->summary()) != -1)
#endif
{
mMatchedTodos.append(tod);
continue;
}
}
if (mDescriptionCheck->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(tod->description()) != -1)
#else
if (re.match(tod->description()) != -1)
#endif
{
mMatchedTodos.append(tod);
continue;
}
}
if (mCategoryCheck->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(tod->categoriesStr()) != -1)
#else
if (re.match(tod->categoriesStr()) != -1)
#endif
{
mMatchedTodos.append(tod);
continue;
}
}
if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
QPtrList<Attendee> tmpAList = tod->attendees();
Attendee *a;
for (a = tmpAList.first(); a; a = tmpAList.next()) {
if (mSearchAName->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(a->name()) != -1)
#else
if (re.match(a->name()) != -1)
#endif
{
mMatchedTodos.append(tod);
break;
}
}
if (mSearchAEmail->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(a->email()) != -1)
#else
if (re.match(a->email()) != -1)
#endif
{
mMatchedTodos.append(tod);
break;
}
}
}
}
}
}
mMatchedJournals.clear();
if (mSearchJournal->isChecked() ) {
QPtrList<Journal> journals = mCalendar->journals( );
Journal* journ;
for(journ=journals.first();journ;journ=journals.next()) {
if ( journ->dtStart().date() <= mEndDate->date()
&&journ->dtStart().date() >= mStartDate->date()) {
#if QT_VERSION >= 0x030000
if (re.search(journ->description()) != -1)
#else
if (re.match(journ->description()) != -1)
#endif
{
mMatchedJournals.append(journ);
continue;
}
}
}
}
}
void SearchDialog::keyPressEvent ( QKeyEvent *e)
{
switch ( e->key() ) {
case Qt::Key_Escape:
- hide();
+ close();
break;
case Qt::Key_F:
if ( e->state() == Qt::ControlButton ) {
- qDebug("full ");
}
break;
case Qt::Key_Return:
case Qt::Key_Enter:
doSearch();
break;
default:
e->ignore();
}
}
//mMatchedJournals;