author | zautrix <zautrix> | 2005-04-01 18:10:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-01 18:10:09 (UTC) |
commit | edc032c21ae3788d02a632ea8066e4ac5a4feedb (patch) (side-by-side diff) | |
tree | 8e59c8dcf1cc3021694025627d36e152f7adc389 /korganizer | |
parent | 5d88f92b76a760f100384ea5fa6ed143088d19bb (diff) | |
download | kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.zip kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.tar.gz kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.tar.bz2 |
fixes
-rw-r--r-- | korganizer/koagendaview.cpp | 28 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 8 | ||||
-rw-r--r-- | korganizer/koeditordetails.cpp | 5 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 25 | ||||
-rw-r--r-- | korganizer/koprefsdialog.cpp | 98 | ||||
-rw-r--r-- | korganizer/koprefsdialog.h | 2 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 2 |
7 files changed, 91 insertions, 77 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 218396d..072d464 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -1,1216 +1,1216 @@ /* 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 <qhbox.h> #include <qvbox.h> #include <qlabel.h> #include <qframe.h> #include <qlayout.h> #ifndef KORG_NOSPLITTER #include <qsplitter.h> #endif #include <qfont.h> #include <qfontmetrics.h> #include <qpopupmenu.h> #include <qtooltip.h> #include <qpainter.h> #include <qpushbutton.h> #include <qapplication.h> #include <kapplication.h> #include <KDGanttMinimizeSplitter.h> #include <kdebug.h> #include <kstandarddirs.h> #include <kiconloader.h> #include <klocale.h> #include <kconfig.h> #include <kglobal.h> #include "calendarview.h" #include "koviewmanager.h" #include <libkcal/calendar.h> #include <libkcal/icaldrag.h> #include <libkcal/dndfactory.h> #include <kcalendarsystem.h> #include "koglobals.h" #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include "koprefs.h" #include "koagenda.h" #include "koagendaitem.h" #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #include "koagendaview.h" //#include "koagendaview.moc" //extern bool globalFlagBlockPainting; extern int globalFlagBlockAgenda; extern int globalFlagBlockStartup; extern int globalFlagBlockAgendaItemPaint; extern int globalFlagBlockAgendaItemUpdate; extern int globalFlagBlockLabel; using namespace KOrg; TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : QScrollView(parent,name,f) { myPix.resize( 1, 1 ); mRows = rows; mRedrawNeeded = true; setMinimumHeight( 20 ); mCellHeight = KOPrefs::instance()->mHourSize*4; enableClipper(true); setHScrollBarMode(AlwaysOff); setVScrollBarMode(AlwaysOff); resizeContents(50,mRows * mCellHeight); viewport()->setBackgroundMode( PaletteBackground ); } void TimeLabels::setCellHeight(int height) { mCellHeight = height; } /* Optimization so that only the "dirty" portion of the scroll view is redrawn. Unfortunately, this is not called by default paintEvent() method. */ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) { // if ( globalFlagBlockAgenda ) // return; // bug: the parameters cx, cy, cw, ch are the areas that need to be // redrawn, not the area of the widget. unfortunately, this // code assumes the latter... // now, for a workaround... // these two assignments fix the weird redraw bug + mRedrawNeeded = true; if ( mRedrawNeeded ) { - cx = contentsX() + 2; - cw = contentsWidth() - 2; + cx = contentsX() + frameWidth()*2; + cw = contentsWidth() ; // end of workaround int cell = ((int)(cy/mCellHeight)); int y = cell * mCellHeight; QFontMetrics fm = fontMetrics(); QString hour; QString suffix; int tW = fm.width("24:00i"); int timeHeight = fm.height(); //timeHeight -= (timeHeight/4-2); int borderWidth = 0; QFont nFont = p->font(); if (!KGlobal::locale()->use12Clock()) suffix = "00"; else borderWidth = 0; if ( timeHeight > mCellHeight ) { timeHeight = mCellHeight-1; int pointS = nFont.pointSize(); while ( pointS > 4 ) { nFont.setPointSize( pointS ); fm = QFontMetrics( nFont ); if ( fm.height() < mCellHeight ) break; -- pointS; } fm = QFontMetrics( nFont ); borderWidth = 4; timeHeight = fm.height(); } - timeHeight -= (timeHeight/4-2); + //timeHeight -= (timeHeight/4-2); QFont sFont = nFont; sFont.setPointSize( sFont.pointSize()/2+2 ); QFontMetrics fmS( sFont ); int sHei = fmS.height(); - sHei -= (sHei/4-2); - int startW = this->width() - frameWidth(); + //sHei -= (sHei/4-2); + int startW = this->width() - frameWidth()-1; while (y < cy + ch) { p->drawLine(cx,y,cx+tW,y); hour.setNum(cell); // handle 24h and am/pm time formats if (KGlobal::locale()->use12Clock()) { if (cell > 11) suffix = "pm"; else suffix = "am"; if (cell == 0) hour.setNum(12); if (cell > 12) hour.setNum(cell - 12); } // center and draw the time label - int timeWidth = fm.width(hour+"i"); + int timeWidth = fm.width(hour); int tw2 = fm.width(suffix); int offset = startW - timeWidth - tw2 ; p->setFont( nFont ); - p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); + p->drawText( offset, y+ timeHeight, hour); p->setFont( sFont ); - offset = startW - tw2-1; - p->drawText(cx - borderWidth + offset, y+ sHei, suffix); + offset = startW - tw2+1; + p->drawText( offset, y+ sHei, suffix); // increment indices y += mCellHeight; cell++; } } else { //qDebug("NO redraw "); } // double buffer not yet implemented //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); //mRedrawNeeded = false; } /** Calculates the minimum width. */ int TimeLabels::minimumWidth() const { return mMiniWidth; } /** updates widget's internal state */ void TimeLabels::updateConfig() { mRedrawNeeded = true; // set the font // config->setGroup("Fonts"); // QFont font = config->readFontEntry("TimeBar Font"); setFont(KOPrefs::instance()->mTimeBarFont); QString test = "88:88"; if (KGlobal::locale()->use12Clock()) test += "i"; mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; // update geometry restrictions based on new settings setFixedWidth(minimumWidth()); // update HourSize mCellHeight = KOPrefs::instance()->mHourSize*4; resizeContents(50,mRows * mCellHeight); } /** update time label positions */ void TimeLabels::positionChanged() { int adjustment = mAgenda->contentsY(); setContentsPos(0, adjustment); } /** */ void TimeLabels::setAgenda(KOAgenda* agenda) { mAgenda = agenda; } void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) { mMouseDownY = e->pos().y(); mOrgCap = topLevelWidget()->caption(); } void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) { int diff = mMouseDownY - e->pos().y(); if ( diff < 10 && diff > -10 ) return; int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; if ( tSize < 4 ) tSize = 4; if ( tSize > 22 ) tSize = 22; tSize = (tSize-2)/2; topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); } void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) { topLevelWidget()->setCaption( mOrgCap ); int diff = mMouseDownY - e->pos().y(); if ( diff < 10 && diff > -10 ) return; int tSize = KOPrefs::instance()->mHourSize + (diff/10); if ( tSize < 4 ) tSize = 4; if ( tSize > 22 ) tSize = 22; tSize = (tSize/2)*2; if ( tSize == KOPrefs::instance()->mHourSize ) return; KOPrefs::instance()->mHourSize = tSize; emit scaleChanged(); } /** This is called in response to repaint() */ void TimeLabels::paintEvent(QPaintEvent*) { // kdDebug() << "paintevent..." << endl; // this is another hack! // QPainter painter(this); //QString c repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); } //////////////////////////////////////////////////////////////////////////// EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) : QFrame(parent,name) { mColumns = 1; mTopBox = 0; mLocation = loc; mTopLayout = 0; mPaintWidget = 0; mXOffset = 0; if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); else mPixmap = SmallIcon("1downarrow"); mEnabled.resize(mColumns); mEnabled.fill( false ); setMinimumHeight(mPixmap.height()); } EventIndicator::~EventIndicator() { } void EventIndicator::drawContents(QPainter *p) { // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; KDGanttSplitterHandle* han = 0; if ( mPaintWidget ) han = mPaintWidget->firstHandle(); if ( ! han ) { int i; for(i=0;i<mColumns;++i) { if (mEnabled[i]) { int cellWidth = contentsRect().right()/mColumns; int xOffset = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : i*cellWidth + (cellWidth -mPixmap.width()) /2; p->drawPixmap(QPoint(1+xOffset,0),mPixmap); } } } else { han->repaint(); //mPaintWidget->setBackgroundColor( red ); QPainter pa( han ); int i; bool setColor = false; for(i=0;i<mColumns;++i) { if (mEnabled[i]) { setColor = true; int cellWidth = contentsRect().right()/mColumns; int xOffset = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : i*cellWidth + cellWidth/2 -mPixmap.width()/2; pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); //qDebug("222draw pix %d ",xOffset ); } } pa.end(); } } void EventIndicator::setXOffset( int x ) { mXOffset = x; } void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) { mPaintWidget = w; setMaximumHeight(0); setMinimumHeight(0); } void EventIndicator::changeColumns(int columns) { mColumns = columns; mEnabled.resize(mColumns); update(); } void EventIndicator::enableColumn(int column, bool enable) { mEnabled[column] = enable; } //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : KOEventView (cal,parent,name) { mBlockUpdating = true; mStartHour = 8; mSelectedDates.append(QDate::currentDate()); mLayoutDayLabels = 0; mDayLabelsFrame = 0; mDayLabels = 0; bool isRTL = KOGlobals::self()->reverseLayout(); QPixmap expandPix; if ( KOPrefs::instance()->mVerticalScreen ) { expandPix = SmallIcon( "1updownarrow" ); } else { expandPix = SmallIcon("1leftrightarrow" ); } QBoxLayout *topLayout = new QVBoxLayout(this); // Create day name labels for agenda columns // Create agenda splitter mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); topLayout->addWidget( mSplitterAgenda ); mAllDayFrame = new QHBox(mSplitterAgenda); mAllDayFrame->setFocusPolicy(NoFocus); QWidget *agendaFrame = new QWidget(mSplitterAgenda); agendaFrame->setFocusPolicy(NoFocus); // Create all-day agenda widget mDummyAllDayLeft = new QVBox( mAllDayFrame ); mExpandButton = new QPushButton(mDummyAllDayLeft); mExpandButton->setPixmap( expandPix ); int widebut = mExpandButton->sizeHint().width()+4; int heibut = mExpandButton->sizeHint().height()+4; if ( heibut > widebut ) widebut = heibut ; - if ( QApplication::desktop()->width() < 480 ) - widebut = widebut*3/2; + //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, // QSizePolicy::Fixed ) ); mExpandButton->setFixedSize( widebut, widebut); connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); mExpandButton->setFocusPolicy(NoFocus); mAllDayAgenda = new KOAgenda(1,mAllDayFrame); mAllDayAgenda->setFocusPolicy(NoFocus); QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); // Create event context menu for all day agenda mAllDayAgendaPopup = eventPopup(); connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); // Create agenda frame QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); // QHBox *agendaFrame = new QHBox(splitterAgenda); // create event indicator bars mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); #ifndef DESKTOP_VERSION // FIX mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); #endif mDayLabelsFrame = new QHBox(agendaFrame); //topLayout->addWidget(mDayLabelsFrame); mDayLabels = new QFrame (mDayLabelsFrame); mLayoutDayLabels = new QHBoxLayout(mDayLabels); agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); agendaLayout->addWidget(mEventIndicatorTop,1,1); mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, agendaFrame); agendaLayout->addWidget(mEventIndicatorBottom,3,1); QWidget *dummyAgendaRight = new QWidget(agendaFrame); agendaLayout->addWidget(dummyAgendaRight,1,2); // Create time labels mTimeLabels = new TimeLabels(24,agendaFrame); agendaLayout->addWidget(mTimeLabels,2,0); connect(mTimeLabels,SIGNAL( scaleChanged()), this,SLOT(updateConfig())); // Create agenda mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); agendaLayout->setColStretch(1,1); mAgenda->setFocusPolicy(NoFocus); // Create event context menu for agenda mAgendaPopup = eventPopup(); mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), i18n("Toggle Alarm"),mAgenda, SLOT(popupAlarm()),true); connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); // make connections between dependent widgets mTimeLabels->setAgenda(mAgenda); // Update widgets to reflect user preferences // updateConfig(); // createDayLabels(); // these blank widgets make the All Day Event box line up with the agenda dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); // Scrolling connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), mTimeLabels, SLOT(positionChanged())); connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), SLOT(setContentsPos(int))); connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); // Create/Show/Edit/Delete Event connect(mAgenda,SIGNAL(newEventSignal(int,int)), SLOT(newEvent(int,int))); connect(mAgenda,SIGNAL(newTodoSignal(int,int)), SLOT(newTodo(int,int))); connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), SLOT(newEvent(int,int,int,int))); connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), SLOT(newEventAllDay(int,int))); connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), SLOT(newTodoAllDay(int,int))); connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), SLOT(newEventAllDay(int,int))); connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), SLOT(newTimeSpanSelected(int,int,int,int))); connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), SIGNAL(editIncidenceSignal(Incidence *))); connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), SIGNAL(editIncidenceSignal(Incidence *))); connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), SIGNAL(showIncidenceSignal(Incidence *))); connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), SIGNAL(showIncidenceSignal(Incidence *))); connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), SIGNAL(deleteIncidenceSignal(Incidence *))); connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), SIGNAL(deleteIncidenceSignal(Incidence *))); connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), SLOT(updateEventDates(KOAgendaItem *, int ))); connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), SLOT(updateEventDates(KOAgendaItem *, int))); // event indicator update connect(mAgenda,SIGNAL(lowerYChanged(int)), SLOT(updateEventIndicatorTop(int))); connect(mAgenda,SIGNAL(upperYChanged(int)), SLOT(updateEventIndicatorBottom(int))); // drag signals /* connect(mAgenda,SIGNAL(startDragSignal(Event *)), SLOT(startDrag(Event *))); connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), SLOT(startDrag(Event *))); */ // synchronize selections connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), mAllDayAgenda, SLOT( deselectItem() ) ); connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), mAgenda, SLOT( deselectItem() ) ); connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), SIGNAL( incidenceSelected( Incidence * ) ) ); connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), SIGNAL( incidenceSelected( Incidence * ) ) ); connect( mAgenda, SIGNAL( resizedSignal() ), SLOT( updateConfig( ) ) ); connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), SLOT( addToCalSlot(Incidence * , Incidence *) ) ); // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); } void KOAgendaView::toggleAllDay() { if ( mSplitterAgenda->firstHandle() ) mSplitterAgenda->firstHandle()->toggle(); } void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) { calendar()->addIncidence( inc ); if ( incOld ) { if ( incOld->type() == "Todo" ) emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); else emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); } } KOAgendaView::~KOAgendaView() { delete mAgendaPopup; delete mAllDayAgendaPopup; delete KOAgendaItem::paintPix(); delete KOAgendaItem::paintPixSel(); } void KOAgendaView::resizeEvent( QResizeEvent* e ) { //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); bool uc = false; int ow = e->oldSize().width(); int oh = e->oldSize().height(); int w = e->size().width(); int h = e->size().height(); if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) uc = true; //qDebug("view changed %d %d %d %d ", ow, oh , w , h); } mUpcomingWidth = e->size().width() ; if ( mBlockUpdating || uc ) { mBlockUpdating = false; //mAgenda->setMinimumSize(800 , 600 ); //qDebug("mAgenda->resize+++++++++++++++ "); updateConfig(); //qDebug("KOAgendaView::Updating now possible "); } else createDayLabels(); //qDebug("resizeEvent end "); } void KOAgendaView::slotDaylabelClicked( int num ) { QDate firstDate = mSelectedDates.first(); if ( num == -1 ) emit showDateView( 6, firstDate ); else if (num >= 0 ) { if ( mSelectedDates.count() == 1) emit showDateView( 9, firstDate.addDays( num ) ); else emit showDateView( 3, firstDate.addDays( num ) ); } else showDateView( 10, firstDate.addDays(1) ); } KOAgendaButton* KOAgendaView::getNewDaylabel() { KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); mDayLabelsList.append( dayLabel ); mLayoutDayLabels->addWidget(dayLabel); return dayLabel ; } void KOAgendaView::createDayLabels() { if ( mBlockUpdating || globalFlagBlockLabel == 1) { // qDebug(" KOAgendaView::createDayLabels() blocked "); return; } int newHight; // ### Before deleting and recreating we could check if mSelectedDates changed... // It would remove some flickering and gain speed (since this is called by // each updateView() call) int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); if ( maxWid < 0 ) maxWid = 20; QFont dlf = KOPrefs::instance()->mTimeLabelsFont; QFontMetrics fm ( dlf ); int selCount = mSelectedDates.count(); QString dayTest = "Mon 20"; //QString dayTest = "Mon 20"; int wid = fm.width( dayTest ); //maxWid -= ( selCount * 3 ); //working for QLabels maxWid -= ( selCount * 3 ); //working for QPushButton if ( maxWid < 0 ) maxWid = 20; int needWid = wid * selCount; //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); //if ( needWid > maxWid ) // qDebug("DAYLABELS TOOOOOOO BIG "); while ( needWid > maxWid ) { dayTest = dayTest.left( dayTest.length() - 1 ); wid = fm.width( dayTest ); needWid = wid * selCount; } int maxLen = dayTest.length(); int fontPoint = dlf.pointSize(); if ( maxLen < 2 ) { int fontPoint = dlf.pointSize(); while ( fontPoint > 4 ) { --fontPoint; dlf.setPointSize( fontPoint ); QFontMetrics f( dlf ); wid = f.width( "30" ); needWid = wid * selCount; if ( needWid < maxWid ) break; } maxLen = 2; } //qDebug("Max len %d ", dayTest.length() ); QFontMetrics tempF( dlf ); newHight = tempF.height(); mDayLabels->setFont( dlf ); // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; // mLayoutDayLabels->addSpacing(mTimeLabels->width()); //mLayoutDayLabels->addSpacing( 2 ); // QFont lFont = dlf; bool appendLabels = false; KOAgendaButton *dayLabel; dayLabel = mDayLabelsList.first(); if ( !dayLabel ) { appendLabels = true; dayLabel = getNewDaylabel(); } - dayLabel->setFixedWidth( mTimeLabels->width()+2 ); + dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); dayLabel->setFont( dlf ); dayLabel->setNum( -1 ); //dayLabel->setAlignment(QLabel::AlignHCenter); dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); dayLabel->show(); DateList::ConstIterator dit; bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); int counter = -1; for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { ++counter; QDate date = *dit; // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); if ( ! appendLabels ) { dayLabel = mDayLabelsList.next(); if ( !dayLabel ) appendLabels = true; } if ( appendLabels ) { dayLabel = getNewDaylabel(); } dayLabel->setMinimumWidth( 1 ); dayLabel->setMaximumWidth( 10240 ); dayLabel->setFont( dlf ); dayLabel->show(); dayLabel->setAutoRepeat( false ); dayLabel->setNum( counter ); QString str; int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); switch ( maxLen ) { case 2: str = QString::number( date.day() ); break; case 3: str = dayName.left( 1 ) +QString::number( date.day()); break; case 4: str = dayName.left( 1 ) + " " +QString::number( date.day()); break; case 5: str = dayName.left( 2 ) + " " +QString::number( date.day()); break; case 6: str = dayName.left( 3 ) + " " +QString::number( date.day()); break; default: break; } if ( oneday ) { QString addString; if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) addString = i18n("Today"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) addString = i18n("Tomorrow"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) addString = i18n("Yesterday"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) addString = i18n("Day before yesterday"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) addString = i18n("Day after tomorrow"); if ( !addString.isEmpty() ) { str = addString+", " + str; } else { str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); } } dayLabel->setText(str); //dayLabel->setAlignment(QLabel::AlignHCenter); if (date == QDate::currentDate()) { QFont bFont = dlf; bFont.setBold( true ); dayLabel->setFont(bFont); } //dayLayout->addWidget(dayLabel); #ifndef KORG_NOPLUGINS CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); CalendarDecoration *it; for(it = cds.first(); it; it = cds.next()) { QString text = it->shortText( date ); if ( !text.isEmpty() ) { QLabel *label = new QLabel(text,mDayLabels); label->setAlignment(AlignCenter); dayLayout->addWidget(label); } } for(it = cds.first(); it; it = cds.next()) { QWidget *wid = it->smallWidget(mDayLabels,date); if ( wid ) { // wid->setHeight(20); dayLayout->addWidget(wid); } } #endif } if ( ! appendLabels ) { dayLabel = mDayLabelsList.next(); if ( !dayLabel ) appendLabels = true; } if ( appendLabels ) { dayLabel = getNewDaylabel(); } //dayLabel->hide();//test only - - int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; + qDebug("fremwidd %d ", mAgenda->frameWidth()); + int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; if ( offset < 0 ) offset = 0; //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); dayLabel->setFont( dlf ); dayLabel->setAutoRepeat( true ); dayLabel->show(); dayLabel->setNum( -2 ); dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); //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 ); } // 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) { // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; //qDebug("KOAgendaView::updateEventDates "); 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() ); if ( item->cellYBottom() > 0 ) endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); else endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); endDt.setDate(startDate); } } } if ( item->incidence()->type() == "Event" ) { item->incidence()->setDtStart(startDt); (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); } else if ( item->incidence()->type() == "Todo" ) { Todo* to = static_cast<Todo*>(item->incidence()); to->setDtDue(endDt); if ( to->hasStartDate() ) { if (to->dtStart() >= to->dtDue() ) to->setDtStart(to->dtDue().addDays( -2 )); } } //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); item->incidence()->setRevision(item->incidence()->revision()+1); item->setItemDate(startDt.date()); //item->updateItem(); if ( item->incidence()->type() == "Todo" ) { emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); } else emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); item->updateItem(); } void KOAgendaView::showDates( const QDate &start, const QDate &end ) { // kdDebug() << "KOAgendaView::selectDates" << endl; mSelectedDates.clear(); // qDebug("KOAgendaView::showDates "); QDate d = start; while (d <= end) { mSelectedDates.append(d); d = d.addDays( 1 ); } // and update the view fillAgenda(); } void KOAgendaView::showEvents(QPtrList<Event>) { kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; } 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()) { 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 ) diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index dfc6af7..c55f7d7 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -1,942 +1,946 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> Parts of the source code have been copied from kdpdatebutton.cpp 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 ode for Qt in the source distribution. */ #include <qevent.h> #include <qpainter.h> #include <qptrlist.h> #include <qtimer.h> #include <qwhatsthis.h> #include <kglobal.h> #include <kdebug.h> #include <klocale.h> #include <libkcal/vcaldrag.h> #include <libkcal/icaldrag.h> #include <libkcal/dndfactory.h> #include <libkcal/calendarresources.h> #include <libkcal/resourcecalendar.h> #include <kresources/resourceselectdialog.h> #include <kcalendarsystem.h> #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include "koprefs.h" #include "koglobals.h" #include "kodaymatrix.h" // ============================================================================ // D Y N A M I C T I P // ============================================================================ DynamicTip::DynamicTip( QWidget * parent ) : QToolTip( parent ) { matrix = (KODayMatrix*)parent; } class KODaymatrixWhatsThis :public QWhatsThis { public: KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; ~KODaymatrixWhatsThis() { ; }; protected: virtual QString text( const QPoint& p ) { return _view->getWhatsThisText( p ) ; } private: KODayMatrix * _view; }; void DynamicTip::maybeTip( const QPoint &pos ) { //calculate which cell of the matrix the mouse is in QRect sz = matrix->frameRect(); int dheight = sz.height()*7 / 42; int dwidth = sz.width() / 7; int row = pos.y()/dheight; int col = pos.x()/dwidth; QRect rct(col*dwidth, row*dheight, dwidth, dheight); // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << // col << "][" << row << "] => " <<(col+row*7) << endl; //show holiday names only QString str = matrix->getHolidayLabel(col+row*7); if (str.isEmpty()) return; tip(rct, str); } // ============================================================================ // K O D A Y M A T R I X // ============================================================================ const int KODayMatrix::NOSELECTION = -1000; const int KODayMatrix::NUMDAYS = 42; KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) #if 0 KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : QFrame(parent, name) #endif { mRedrawNeeded = true; mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); mPendingUpdateBeforeRepaint = false; mouseDown = false; // initialize dynamic arrays bDays.resize ( NUMDAYS ); hDays.resize ( NUMDAYS );; eDays.resize ( NUMDAYS );; days = new QDate[NUMDAYS]; daylbls = new QString[NUMDAYS]; //events = new int[NUMDAYS]; mToolTip = new DynamicTip(this); // set default values used for drawing the matrix mDefaultBackColor = palette().active().base(); mDefaultTextColor = palette().active().foreground(); mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); mSelectedDaysColor = QColor("white"); mTodayMarginWidth = 2; mSelEnd = mSelStart = NOSELECTION; setAcceptDrops(true); //setFont( QFont("Arial", 10) ); mUpdateTimer = new QTimer( this ); connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); mRepaintTimer = new QTimer( this ); connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); mDayChanged = false; updateView(); } QString KODayMatrix::getWhatsThisText( QPoint p ) { int tmp = getDayIndexFrom(p.x(), p.y()); if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) return QString(); QDate mDate = days[tmp]; QPtrList<Event> eventlist = mCalendar->events(mDate); Event *event; QStringList mToolTip; for(event=eventlist.first();event != 0;event=eventlist.next()) { QString mToolTipText; 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(); mToolTipText += prefix + text; } else { if (event->doesFloat()) { text = event->summary(); mToolTipText += text; } else { text = KGlobal::locale()->formatTime(event->dtStart().time()); text += " " + event->summary(); mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); } } if ( !event->location().isEmpty() ) mToolTipText += " (" + event->location() + ")"; #if QT_VERSION >= 0x030000 mToolTipText.replace( '<' , "<" ); mToolTipText.replace( '>' , ">" ); #else if ( mToolTipText.find ('<') >= 0 ) { mToolTipText.replace( QRegExp("<") , "<" ); } if ( mToolTipText.find ('>') >= 0 ) { mToolTipText.replace( QRegExp(">") , ">" ); } #endif //qDebug("TTT: %s ", mToolTipText.latin1()); mToolTip.append( mToolTipText ); } mToolTip.sort(); return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); } void KODayMatrix::setCalendar( Calendar *cal ) { mCalendar = cal; setAcceptDrops( mCalendar ); updateEvents(); } QColor KODayMatrix::getShadedColor(QColor color) { QColor shaded; int h=0; int s=0; int v=0; color.hsv(&h,&s,&v); s = s/4; v = 192+v/4; shaded.setHsv(h,s,v); return shaded; } KODayMatrix::~KODayMatrix() { // delete mKODaymatrixWhatsThis; delete [] days; delete [] daylbls; //delete [] events; delete mToolTip; } /* void KODayMatrix::setStartDate(QDate start) { updateView(start); } */ void KODayMatrix::addSelectedDaysTo(DateList& selDays) { if (mSelStart == NOSELECTION) { return; } //cope with selection being out of matrix limits at top (< 0) int i0 = mSelStart; if (i0 < 0) { for (int i = i0; i < 0; i++) { selDays.append(days[0].addDays(i)); } i0 = 0; } //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) if (mSelEnd > NUMDAYS-1) { for (int i = i0; i <= NUMDAYS-1; i++) { selDays.append(days[i]); } for (int i = NUMDAYS; i < mSelEnd; i++) { selDays.append(days[0].addDays(i)); } // apply normal routine to selection being entirely within matrix limits } else { for (int i = i0; i <= mSelEnd; i++) { selDays.append(days[i]); } } } bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) -{ +{ + mRedrawNeeded = true; bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); mSelStart = startdate.daysTo(start); if ( mSelStart < 0 ) mSelStart = 0; mSelEnd = startdate.daysTo(end); if ( mSelEnd > NUMDAYS-1 ) mSelEnd = NUMDAYS-1; if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { clearSelection(); if ( noSel ) return false; } return true; } void KODayMatrix::clearSelection() { mSelEnd = mSelStart = NOSELECTION; } void KODayMatrix::recalculateToday() { today = -1; for (int i=0; i<NUMDAYS; i++) { //events[i] = 0; days[i] = startdate.addDays(i); daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); // if today is in the currently displayed month, hilight today if (days[i].year() == QDate::currentDate().year() && days[i].month() == QDate::currentDate().month() && days[i].day() == QDate::currentDate().day()) { today = i; } } // qDebug(QString("Today is visible at %1.").arg(today)); } void KODayMatrix::updateView() { updateView(startdate); } void KODayMatrix::repaintViewTimed() { mRepaintTimer->stop(); repaint(false); } void KODayMatrix::updateViewTimed() { mUpdateTimer->stop(); if ( !mCalendar ) { qDebug("NOT CAL "); return; } //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()) { 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; } } 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( 1200 ); #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(); if ( ( recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur ) || ( recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur ) ) { numEvents--; } } if ( numEvents ) eDays.setBit(i); else eDays.clearBit(i); } } const QDate& KODayMatrix::getDate(int offset) { if (offset < 0 || offset > NUMDAYS-1) { qDebug("Wrong offset2 %d", offset); return days[0]; } return days[offset]; } QString KODayMatrix::getHolidayLabel(int offset) { if (offset < 0 || offset > NUMDAYS-1) { qDebug("Wrong offset1 %d", offset); return QString(); } return mHolidays[offset]; } int KODayMatrix::getDayIndexFrom(int x, int y) { int colModulo = (width()-2) % 7; int rowModulo = (height()-2) % 6; #if 0 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 6 - x/daysize.width() : x/daysize.width()); #endif int xVal = (x-colModulo/2-2)/daysize.width(); int yVal = (y-rowModulo/2-2)/daysize.height(); return 7*(yVal) + xVal; } // ---------------------------------------------------------------------------- // M O U S E E V E N T H A N D L I N G // ---------------------------------------------------------------------------- void KODayMatrix::mousePressEvent (QMouseEvent* e) { if ( e->button() == LeftButton ) mouseDown = true; mSelStart = getDayIndexFrom(e->x(), e->y()); if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; mSelInit = mSelStart; - mSelEnd = mSelStart; + mSelEnd = mSelStart; + mRedrawNeeded = true; repaint(false); } void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) { + mRedrawNeeded = true; if ( e->button() == LeftButton ) if ( ! mouseDown ) { return; } else mouseDown = false; int tmp = getDayIndexFrom(e->x(), e->y()); if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; if (mSelInit > tmp) { mSelEnd = mSelInit; if (tmp != mSelStart) { mSelStart = tmp; repaint(false); } } else { mSelStart = mSelInit; //repaint only if selection has changed if (tmp != mSelEnd) { mSelEnd = tmp; repaint(false); } } DateList daylist; if ( mSelStart < 0 ) mSelStart = 0; for (int i = mSelStart; i <= mSelEnd; i++) { daylist.append(days[i]); } emit selected((const DateList)daylist); } void KODayMatrix::mouseMoveEvent (QMouseEvent* e) { if ( ! mouseDown ) { return; } + mRedrawNeeded = true; int tmp = getDayIndexFrom(e->x(), e->y()); if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; if (mSelInit > tmp) { mSelEnd = mSelInit; if (tmp != mSelStart) { mSelStart = tmp; repaint(false); } } else { mSelStart = mSelInit; //repaint only if selection has changed if (tmp != mSelEnd) { mSelEnd = tmp; repaint(false); } } } // ---------------------------------------------------------------------------- // D R A G ' N D R O P H A N D L I N G // ---------------------------------------------------------------------------- void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) { #ifndef KORG_NODND if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { e->ignore(); return; } // some visual feedback // oldPalette = palette(); // setPalette(my_HilitePalette); // update(); #endif } void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) { #ifndef KORG_NODND if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { e->ignore(); return; } e->accept(); #endif } void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) { #ifndef KORG_NODND // setPalette(oldPalette); // update(); #endif } void KODayMatrix::dropEvent(QDropEvent *e) { #ifndef KORG_NODND // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { e->ignore(); return; } DndFactory factory( mCalendar ); Event *event = factory.createDrop(e); if (event) { e->acceptAction(); Event *existingEvent = mCalendar->event(event->uid()); if(existingEvent) { // uniquify event event->recreate(); /* KMessageBox::sorry(this, i18n("Event already exists in this calendar."), i18n("Drop Event")); delete event; return; */ } // kdDebug() << "Drop new Event" << endl; // Adjust date QDateTime start = event->dtStart(); QDateTime end = event->dtEnd(); int duration = start.daysTo(end); int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); start.setDate(days[idx]); end.setDate(days[idx].addDays(duration)); event->setDtStart(start); event->setDtEnd(end); mCalendar->addEvent(event); emit eventDropped(event); } else { // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; e->ignore(); } #endif } // ---------------------------------------------------------------------------- // P A I N T E V E N T H A N D L I N G // ---------------------------------------------------------------------------- void KODayMatrix::paintEvent(QPaintEvent * pevent) { if ( width() <= 0 || height() <= 0 ) return; if ( mPendingUpdateBeforeRepaint ) { updateViewTimed(); mPendingUpdateBeforeRepaint = false; } if ( myPix.width() != width() || myPix.height()!=height() ) { myPix.resize(size() ); mRedrawNeeded = true; } if ( mRedrawNeeded ) { //qDebug("REDRAW "); QPainter p(&myPix); p.setFont(font()); int dheight = daysize.height(); int dwidth = daysize.width(); int row,col; int selw, selh; int xyOff = frameWidth(); int colModulo = (width()-2) % 7; int rowModulo = (height()-2) % 6; //qDebug("col %d row %d ",colModulo,rowModulo ); bool isRTL = KOGlobals::self()->reverseLayout(); // draw background and topleft frame p.fillRect(0,0,width(),height(), mDefaultBackColor); p.setPen(mDefaultTextColor); p.drawRect(0, 0, width(), height()); int mSelStartT = mSelStart; int mSelEndT = mSelEnd; if ( mSelEndT >= NUMDAYS ) mSelEndT = NUMDAYS-1; // draw selected days with highlighted background color if (mSelStart != NOSELECTION) { bool skip = false; if ( ! mouseDown ) { int mo = days[20].month(); //qDebug("-- %d %d ", mSelStartT, mSelEndT); //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); int startMo = days[mSelStartT].month(); int endMo = days[mSelEndT].month(); if ( startMo == 12 && mo == 1 && endMo <= 2 ) startMo = 1; if ( endMo == 1 && mo == 12 ) endMo = 12; if ( mo == 12 && startMo == 1 ) startMo = 13; if ( (startMo > mo || endMo < mo) ) { skip = true; } else { if ( days[mSelStartT].month() != mo ) { int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); mSelStartT += add +1; } if ( days[mSelEndT].month() != mo ) { int sub = days[mSelEndT].day(); mSelEndT -= sub ; } } } //qDebug("SKIP %d ", skip); if ( ! skip ) { row = mSelStartT/7; col = mSelStartT -row*7; QColor selcol = KOPrefs::instance()->mHighlightColor; int addCol = 0; int addRow = 0; int addRow2 = 0; int addCol2 = 0; if (row == mSelEndT/7) { if ( rowModulo ) { if ( row >= 6 - rowModulo ) addRow = row - 5 + rowModulo; } if ( colModulo ) { int colt1 = mSelEndT%7; //qDebug("colt1 %d ", colt1 ); if ( colt1 >= 7 - colModulo ) addCol = colt1 - 7 + colModulo+1; int colt = mSelStartT%7; if ( colt >= 7 - colModulo ) addCol2 = colt - 7 + colModulo; addCol -= addCol2; //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); } // Single row selection if ( row == 0) addRow = 1; p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); } else { // draw first row to the right if ( colModulo ) { if ( col >= 7 - colModulo ) addCol2 = col - 7 + colModulo; } if ( rowModulo ) { if ( row >= 6 - rowModulo ) addRow = row - 5 + rowModulo; } if ( row == 0) addRow = 1; int drawWid = width()-(col*dwidth+1+addCol2)-1; p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, dheight+1, selcol); // draw full block till last line selh = mSelEndT/7-row; addRow = 0; if ( rowModulo ) { if ( mSelEndT/7 >= 6 - rowModulo ) addRow = mSelEndT/7 - 5 + rowModulo; } if (selh > 1) { p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); } // draw last block from left to mSelEndT selw = mSelEndT-7*(mSelEndT/7)+1; //qDebug("esl %d ",selw ); int add = 0; if ( colModulo ) { add = 7 - colModulo; if ( selw > add ) add = selw - add; else add = 0; } //qDebug("add %d ", add); p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, selw*dwidth+add, dheight+1, selcol); } } } // iterate over all days in the matrix and draw the day label in appropriate colors QColor actcol = mDefaultTextColorShaded; p.setPen(actcol); QPen tmppen; for(int i = 0; i < NUMDAYS; i++) { row = i/7; col = isRTL ? 6-(i-row*7) : i-row*7; // if it is the first day of a month switch color from normal to shaded and vice versa if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { if (actcol == mDefaultTextColorShaded) { actcol = mDefaultTextColor; } else { actcol = mDefaultTextColorShaded; } p.setPen(actcol); } if (actcol == mDefaultTextColorShaded) { if ( ! mouseDown ) { continue; } } //Reset pen color after selected days block if (i == mSelEndT+1) { p.setPen(actcol); } // if today then draw rectangle around day if (today == i) { tmppen = p.pen(); QPen mTodayPen(p.pen()); if ( daysize.width() < 20 ) mTodayPen.setWidth(1); else mTodayPen.setWidth(mTodayMarginWidth); //draw red rectangle for holidays if (!mHolidays[i].isNull()) { if (actcol == mDefaultTextColor) { mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); } else { mTodayPen.setColor(mHolidayColorShaded); } } //draw gray rectangle for today if in selection if (i >= mSelStartT && i <= mSelEndT) { QColor grey("grey"); mTodayPen.setColor(grey); } p.setPen(mTodayPen); int addCol = 0; int addRow = 0; if (rowModulo) { if ( row >= 6 - rowModulo ) addRow = row - 5 + rowModulo; } if ( colModulo ) { if ( col >= 7 - colModulo ) addCol = col - 6 + colModulo-1; } addCol += 1; p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); p.setPen(tmppen); } // if any events are on that day then draw it using a bold font if ( eDays.testBit(i) ) { QFont myFont = font(); myFont.setBold(true); p.setFont(myFont); } // if it is a holiday then use the default holiday color if ( !mHolidays[i].isNull()) { if ( bDays.testBit(i) ) { if ( hDays.testBit(i) ) p.setPen(QColor(Qt::green)); else p.setPen(QColor(Qt::green).dark()); } else { if (actcol == mDefaultTextColor ) { p.setPen(KOPrefs::instance()->mHolidayColor); } else { p.setPen(mHolidayColorShaded); } } } // draw selected days with special color // DO NOT specially highlight holidays in selection ! if (i >= mSelStartT && i <= mSelEndT) { ;//p.setPen(mSelectedDaysColor); } int addCol = 0; int addRow = 0; if ( colModulo ) { if ( col >= 7 - colModulo ) addCol = col - 7 + colModulo; } if ( rowModulo ) { if ( row >= 6 - rowModulo ) addRow = row - 5 + rowModulo; } //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); ++addCol;//++addCol; if ( row == 0) addRow = 1; p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); // reset color to actual color if (!mHolidays[i].isNull()) { p.setPen(actcol); } // reset bold font to plain font if ( eDays.testBit(i)) { QFont myFont = font(); myFont.setBold(false); p.setFont(myFont); } } } else { //qDebug("NO redraw "); } bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); mRedrawNeeded = false; } diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp index 2fd13bd..802261c 100644 --- a/korganizer/koeditordetails.cpp +++ b/korganizer/koeditordetails.cpp @@ -1,453 +1,454 @@ /* 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 thse 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 <qfiledialog.h> #include <qlayout.h> #include <qvbox.h> #include <qbuttongroup.h> #include <qvgroupbox.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <qapp.h> #include <klocale.h> #include <kglobal.h> #include <kiconloader.h> #include <kstandarddirs.h> #include <kmessagebox.h> #ifndef KORG_NOKABC #ifdef DESKTOP_VERSION #include <kabc/addresseedialog.h> #else //DESKTOP_VERSION #include <externalapphandler.h> #endif //DESKTOP_VERSION #endif #include <libkcal/incidence.h> #include "koprefs.h" #include "koeditordetails.h" template <> CustomListViewItem<class Attendee *>::~CustomListViewItem() { delete mData; } template <> void CustomListViewItem<class Attendee *>::updateItem() { setText(0,mData->name()); setText(1,mData->email()); setText(2,mData->roleStr()); setText(3,mData->statusStr()); if (mData->RSVP() && !mData->email().isEmpty()) setPixmap(4,SmallIcon("mailappt")); else setPixmap(4,SmallIcon("nomailappt")); } KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) : QWidget( parent, name), mDisableItemUpdate( false ) { QGridLayout *topLayout = new QGridLayout(this); topLayout->setSpacing(spacing); QString organizer = KOPrefs::instance()->email(); mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this); mListView = new KListView(this,"mListView"); mListView->addColumn(i18n("Name"),180); mListView->addColumn(i18n("Email"),180); mListView->addColumn(i18n("Role"),60); mListView->addColumn(i18n("Status"),100); mListView->addColumn(i18n("RSVP"),35); - if ( KOPrefs::instance()->mCompactDialogs ) { - //mListView->setFixedHeight(78); + if ( QApplication::desktop()->width() <= 320 ) { + //mListView->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding) ); + mListView->setFixedHeight(80); } mListView->setAllColumnsShowFocus (true ); //mListView->setSingleClick( true ); connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), SLOT(updateAttendeeInput())); connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )), SLOT(itemClicked(QListViewItem * ,const QPoint& , int ))); mRsvpButton = new QCheckBox(this); mRsvpButton->setText(i18n("Request response")); mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); QLabel *attendeeLabel = new QLabel(this); attendeeLabel->setText(i18n("Name:")); attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); mNameEdit = new QLineEdit(this); connect(mNameEdit,SIGNAL(textChanged(const QString &)), SLOT(updateAttendeeItem())); mUidEdit = new QLineEdit(0); mUidEdit->setText(""); QLabel *emailLabel = new QLabel(this); emailLabel->setText(i18n("Email:")); mEmailEdit = new QLineEdit(this); connect(mEmailEdit,SIGNAL(textChanged(const QString &)), SLOT(updateAttendeeItem())); QLabel *attendeeRoleLabel = new QLabel(this); attendeeRoleLabel->setText(i18n("Role:")); mRoleCombo = new QComboBox(false,this); mRoleCombo->insertStringList(Attendee::roleList()); connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); QLabel *statusLabel = new QLabel(this); statusLabel->setText( i18n("Status:") ); mStatusCombo = new QComboBox(false,this); mStatusCombo->insertStringList(Attendee::statusList()); connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); QWidget *buttonBox = new QWidget(this); QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); buttonLayout->addWidget(newButton); connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); buttonLayout->addWidget(mRemoveButton); connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); // buttonLayout->addWidget(mAddressBookButton); connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); if (qApp->desktop()->width() < 640 ) { if ( qApp->desktop()->width() < 300 ) topLayout->setSpacing(1); ;//mListView->setFixedHeight(80); topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); topLayout->addMultiCellWidget(mListView,1,1,0,3); topLayout->addWidget(attendeeLabel,3,0); topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); topLayout->addWidget(emailLabel,4,0); topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); topLayout->addWidget(attendeeRoleLabel,5,0); topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3); topLayout->addWidget(statusLabel,6,0); topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3); topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); topLayout->addMultiCellWidget(buttonBox,3,4,3,3); topLayout->setRowStretch(1,2); topLayout->setColStretch(0,0); topLayout->setColStretch(1,2); topLayout->setColStretch(2,1); topLayout->setColStretch(3,1); } else { topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); topLayout->addMultiCellWidget(mListView,1,1,0,5); topLayout->addWidget(attendeeLabel,3,0); topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); topLayout->addWidget(emailLabel,4,0); topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); topLayout->addWidget(attendeeRoleLabel,5,0); topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); topLayout->addWidget(statusLabel,5,3); topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); topLayout->addMultiCellWidget(buttonBox,3,4,5,5); topLayout->setRowStretch(1,5); topLayout->setColStretch(0,0); } // #if 0 // topLayout->setColStretch(2,1); // topLayout->addWidget(statusLabel,3,3); // topLayout->addWidget(mStatusCombo,3,4); // #else // topLayout->addWidget(statusLabel,4,3); // // topLayout->addWidget(mStatusCombo,4,3); // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); // #endif // // topLayout->setRowStretch(5,1); // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); // topLayout->setRowStretch(1,5); // topLayout->setColStretch(0,0); #ifdef KORG_NOKABC mAddressBookButton->hide(); #endif updateAttendeeInput(); #ifndef DESKTOP_VERSION //US listen for arriving address resultsets connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); #endif } KOEditorDetails::~KOEditorDetails() { } void KOEditorDetails::removeAttendee() { AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); if (!aItem) return; Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), aItem->data()->uid()); mdelAttendees.append(delA); delete aItem; updateAttendeeInput(); } void KOEditorDetails::openAddressBook() { #ifndef KORG_NOKABC #ifdef DESKTOP_VERSION KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); uint i=0; for (i=0; i < list.count(); i++) { insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); } #else bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); // the result should now arrive through method insertAttendees #endif #if 0 KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); if (!a.isEmpty()) { insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); } #endif #endif } void KOEditorDetails::addNewAttendee() { #if 0 // this is cool. If they didn't enter an email address, // try to look it up in the address book and fill it in for them. if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { KabAPI addrBook; QString name; std::list<AddressBook::Entry> entries; name = mNameEdit->text(); if (addrBook.init() == AddressBook::NoError) { if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { kdDebug() << "positive match" << endl; // take first email address if (!entries.front().emails.isEmpty() && entries.front().emails.first().length()>0) mEmailEdit->setText(entries.front().emails.first()); } } } #endif Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); insertAttendee(a); } //the map includes name/email pairs, that comes from Ka/Pi void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) { if (uid == this->name()) { for ( int i = 0; i < nameList.count(); i++) { QString _name = nameList[i]; QString _email = emailList[i]; QString _uid = uidList[i]; Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); insertAttendee(a); } } } void KOEditorDetails::insertAttendee(Attendee *a) { AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); while (first) { if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) return; first = (AttendeeListItem*) first->nextSibling(); } AttendeeListItem *item = new AttendeeListItem(a,mListView); mListView->setSelected( item, true ); } void KOEditorDetails::setDefaults() { mRsvpButton->setChecked(true); mListView->clear(); mdelAttendees.clear(); clearAttendeeInput(); mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); mNameEdit->setText(""); mUidEdit->setText(""); mEmailEdit->setText(""); mRoleCombo->setCurrentItem( 0 ); mStatusCombo->setCurrentItem( 0 ); } void KOEditorDetails::readEvent(Incidence *event) { setDefaults(); //mListView->clear(); //mdelAttendees.clear(); QPtrList<Attendee> tmpAList = event->attendees(); Attendee *a; for (a = tmpAList.first(); a; a = tmpAList.next()) insertAttendee(new Attendee(*a)); mListView->setSelected( mListView->firstChild(), true ); mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); } void KOEditorDetails::writeEvent(Incidence *event) { event->clearAttendees(); QListViewItem *item; AttendeeListItem *a; for (item = mListView->firstChild(); item; item = item->nextSibling()) { a = (AttendeeListItem *)item; event->addAttendee(new Attendee(*(a->data()))); } event->setOrganizer(KOPrefs::instance()->email()); } void KOEditorDetails::cancelAttendeeEvent(Incidence *event) { event->clearAttendees(); Attendee * att; for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { event->addAttendee(new Attendee(*att)); } mdelAttendees.clear(); } bool KOEditorDetails::validateInput() { return true; } void KOEditorDetails::updateAttendeeInput() { QListViewItem *item = mListView->selectedItem(); AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); if (aItem) { fillAttendeeInput( aItem ); } else { clearAttendeeInput(); } } void KOEditorDetails::clearAttendeeInput() { mNameEdit->setText(""); mUidEdit->setText(""); mEmailEdit->setText(""); mRoleCombo->setCurrentItem(0); mStatusCombo->setCurrentItem(0); mRsvpButton->setChecked(true); setEnabledAttendeeInput( false ); } void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) { Attendee *a = aItem->data(); mDisableItemUpdate = true; mNameEdit->setText(a->name()); mUidEdit->setText(a->uid()); mEmailEdit->setText(a->email()); mRoleCombo->setCurrentItem(a->role()); mStatusCombo->setCurrentItem(a->status()); mRsvpButton->setChecked(a->RSVP()); mDisableItemUpdate = false; setEnabledAttendeeInput( true ); } void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) { mNameEdit->setEnabled( enabled ); mEmailEdit->setEnabled( enabled ); mRoleCombo->setEnabled( enabled ); mStatusCombo->setEnabled( enabled ); mRsvpButton->setEnabled( enabled ); mRemoveButton->setEnabled( enabled ); } void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c ) { if ( item && c == 4 ) { mRsvpButton->setChecked( !mRsvpButton->isChecked() ); updateAttendeeItem(); } } void KOEditorDetails::updateAttendeeItem() { if (mDisableItemUpdate) return; QListViewItem *item = mListView->selectedItem(); AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); if ( !aItem ) return; Attendee *a = aItem->data(); a->setName( mNameEdit->text() ); a->setUid( mUidEdit->text() ); a->setEmail( mEmailEdit->text() ); a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); a->setRSVP( mRsvpButton->isChecked() ); aItem->updateItem(); } diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 97ab4e8..5879a2d 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -1,510 +1,511 @@ /* 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 <time.h> #ifndef _WIN32_ #include <unistd.h> #endif #include <qdir.h> #include <qtextstream.h> #include <qtextcodec.h> #include <qstring.h> #include <qregexp.h> #include <qfont.h> #include <qcolor.h> #include <qstringlist.h> #include <stdlib.h> #include <kglobal.h> #include <kglobalsettings.h> #include <kconfig.h> #include <klocale.h> #include <kdebug.h> #include <kemailsettings.h> #include <kstaticdeleter.h> #include <libkdepim/kpimglobalprefs.h> #include "koprefs.h" #include "mainwindow.h" KOPrefs *KOPrefs::mInstance = 0; static KStaticDeleter<KOPrefs> insd; KOPrefs::KOPrefs() : KPimPrefs("korganizerrc") { mCategoryColors.setAutoDelete(true); fillMailDefaults(); mDefaultCategoryColor = QColor(175,210,255);//196,196,196); QColor defaultHolidayColor = QColor(255,0,0); QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); QColor defaultTodoDueTodayColor = QColor(255,220,100); QColor defaultTodoOverdueColor = QColor(255,153,125); KPrefs::setCurrentGroup("General"); addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); addItemBool("ShowIconSearch",&mShowIconSearch,true); addItemBool("ShowIconList",&mShowIconList,true); addItemBool("ShowIconDay1",&mShowIconDay1,true); addItemBool("ShowIconDay5",&mShowIconDay5,true); addItemBool("ShowIconDay6",&mShowIconDay6,true); addItemBool("ShowIconDay7",&mShowIconDay7,true); addItemBool("ShowIconMonth",&mShowIconMonth,true); addItemBool("ShowIconTodoview",&mShowIconTodoview,true); addItemBool("ShowIconBackFast",&mShowIconBackFast,true); addItemBool("ShowIconBack",&mShowIconBack,true); addItemBool("ShowIconToday",&mShowIconToday,true); addItemBool("ShowIconForward",&mShowIconForward,true); addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); addItemBool("ShowIconNextDays",&mShowIconNextDays,true); addItemBool("ShowIconNext",&mShowIconNext,true); addItemBool("ShowIconJournal",&mShowIconJournal,true); addItemBool("ShowIconStretch",&mShowIconStretch,true); addItemBool("ShowIconFilter",&mShowIconFilter,false); addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); bool addIcons = false; #ifdef DESKTOP_VERSION addIcons = true; #endif addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); addItemInt("LastLoadedLanguage",&mOldLanguage,0); addItemBool("AskForQuit",&mAskForQuit,false); #ifndef DESKTOP_VERSION addItemBool("ShowFullMenu",&mShowFullMenu,false); #else addItemBool("ShowFullMenu",&mShowFullMenu,true); #endif addItemBool("ToolBarHor",&mToolBarHor, true ); addItemBool("ToolBarUp",&mToolBarUp, false ); addItemBool("ToolBarHorV",&mToolBarHorV, true ); addItemBool("ToolBarUpV",&mToolBarUpV, false ); addItemBool("ToolBarHorN",&mToolBarHorN, true ); addItemBool("ToolBarUpN",&mToolBarUpN, false ); addItemBool("ToolBarHorF",&mToolBarHorF, true ); addItemBool("ToolBarUpF",&mToolBarUpF, false ); addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); addItemInt("Whats Next Days",&mWhatsNextDays,3); addItemInt("Whats Next Prios",&mWhatsNextPrios,1); addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); addItemInt("AllDay Size",&mAllDaySize,28); QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); addItemStringList("LocationDefaults",&mLocationDefaults ); addItemStringList("EventSummary User",&mEventSummaryUser); addItemStringList("TodoSummary User",&mTodoSummaryUser); addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); addItemBool("Enable Project View",&mEnableProjectView,false); addItemBool("Auto Save",&mAutoSave,false); addItemInt("Auto Save Interval",&mAutoSaveInterval,3); addItemBool("Confirm Deletes",&mConfirm,true); addItemString("Archive File",&mArchiveFile); addItemString("Html Export File",&mHtmlExportFile, QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); addItemBool("Html With Save",&mHtmlWithSave,false); KPrefs::setCurrentGroup("Personal Settings"); addItemInt("Mail Client",&mMailClient,MailClientKMail); addItemBool("Use Control Center Email",&mEmailControlCenter,false); addItemBool("Bcc",&mBcc,false); KPrefs::setCurrentGroup("Time & Date"); addItemInt("Default Start Time",&mStartTime,10); addItemInt("Default Duration",&mDefaultDuration,2); addItemInt("Default Alarm Time",&mAlarmTime,3); KPrefs::setCurrentGroup("AlarmSettings"); addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); KPrefs::setCurrentGroup("Calendar"); addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); KPrefs::setCurrentGroup("Fonts"); // qDebug(" KPrefs::setCurrentGroup(Fonts); "); - addItemFont("TimeBar Font",&mTimeBarFont,KGlobalSettings::generalFont() ); - addItemFont("MonthView Font",&mMonthViewFont,KGlobalSettings::generalFont()); - addItemFont("AgendaView Font",&mAgendaViewFont,KGlobalSettings::generalFont()); - addItemFont("MarcusBains Font",&mMarcusBainsFont,KGlobalSettings::generalFont()); - addItemFont("TimeLabels Font",&mTimeLabelsFont,KGlobalSettings::generalFont()); - addItemFont("TodoView Font",&mTodoViewFont,KGlobalSettings::generalFont()); - addItemFont("ListView Font",&mListViewFont,KGlobalSettings::generalFont()); - addItemFont("DateNavigator Font",&mDateNavigatorFont,KGlobalSettings::generalFont()); - addItemFont("EditBox Font",&mEditBoxFont,KGlobalSettings::generalFont()); - addItemFont("JournalView Font",&mJornalViewFont,KGlobalSettings::generalFont()); - addItemFont("WhatsNextView Font",&mWhatsNextFont,KGlobalSettings::generalFont()); - addItemFont("EventView Font",&mEventViewFont,KGlobalSettings::generalFont()); + QFont fon = KGlobalSettings::generalFont(); + addItemFont("TimeBar Font",&mTimeBarFont,fon ); + addItemFont("MonthView Font",&mMonthViewFont,fon); + addItemFont("AgendaView Font",&mAgendaViewFont,fon); + addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); + addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); + addItemFont("TodoView Font",&mTodoViewFont,fon); + addItemFont("ListView Font",&mListViewFont,fon); + addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); + addItemFont("EditBox Font",&mEditBoxFont,fon); + addItemFont("JournalView Font",&mJornalViewFont,fon); + addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); + addItemFont("EventView Font",&mEventViewFont,fon); KPrefs::setCurrentGroup("RemoteSyncing"); addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); addItemBool("ShowSyncEvents",&mShowSyncEvents,false); addItemInt("LastSyncTime",&mLastSyncTime,0); #ifdef _WIN32_ QString hdp= locateLocal("data","korganizer")+"\\\\"; #else QString hdp= locateLocal("data","korganizer")+"/"; #endif KPrefs::setCurrentGroup("LoadSaveFileNames"); addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); KPrefs::setCurrentGroup("Locale"); addItemBool("ShortDateInViewer",&mShortDateInViewer,false); KPrefs::setCurrentGroup("Colors"); addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); addItemBool("MonthViewWeek",&mMonthViewWeek,false); addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); addItemBool("UseAppColors",&mUseAppColors,false); KPrefs::setCurrentGroup("Views"); addItemBool("Show Date Navigator",&mShowDateNavigator,true); addItemInt("Hour Size",&mHourSize,8); addItemBool("Show Daily Recurrences",&mDailyRecur,true); addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); addItemBool("ShowShortMonthName",&mMonthShowShort,false); addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); #ifdef DESKTOP_VERION addItemBool("Enable ToolTips",&mEnableToolTips,true); #else addItemBool("Enable ToolTips",&mEnableToolTips,false); #endif addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); #ifdef DESKTOP_VERSION addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); #else addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); #endif addItemInt("Day Begins",&mDayBegins,7); addItemInt("Working Hours Start",&mWorkingHoursStart,8); addItemInt("Working Hours End",&mWorkingHoursEnd,17); addItemBool("Exclude Holidays",&mExcludeHolidays,true); addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); addItemBool("Full View Month",&mFullViewMonth,true); addItemBool("Full View Todo",&mFullViewTodo,true); addItemBool("Quick Todo",&mEnableQuickTodo,false); addItemInt("Next X Days",&mNextXDays,3); KPrefs::setCurrentGroup("Printer"); KPrefs::setCurrentGroup("Layout"); addItemBool("CompactDialogs",&mCompactDialogs,false); addItemBool("VerticalScreen",&mVerticalScreen,true); KPrefs::setCurrentGroup("KOrganizer Plugins"); addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); KPrefs::setCurrentGroup("Group Scheduling"); addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); addItemStringList("AdditionalMails",&mAdditionalMails,""); addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); KPrefs::setCurrentGroup( "Editors" ); addItemStringList( "EventTemplates", &mEventTemplates ); addItemStringList( "TodoTemplates", &mTodoTemplates ); addItemInt("DestinationPolicy",&mDestination,standardDestination); KPrefs::setCurrentGroup( "ViewOptions" ); addItemBool("EVshowDetails",&mEVshowDetails,true); addItemBool("EVshowCreated",&mEVshowCreated,true); addItemBool("EVshowChanged",&mEVshowChanged,true); addItemBool("WTshowDetails",&mWTshowDetails,false); addItemBool("WTshowCreated",&mWTshowCreated,false); addItemBool("WTshowChanged",&mWTshowChanged,false); } KOPrefs::~KOPrefs() { if (mInstance == this) mInstance = insd.setObject(0); //qDebug("KOPrefs::~KOPrefs() "); } KOPrefs *KOPrefs::instance() { if (!mInstance) { mInstance = insd.setObject(new KOPrefs()); mInstance->readConfig(); } return mInstance; } void KOPrefs::usrSetDefaults() { } void KOPrefs::fillMailDefaults() { if (mName.isEmpty()) mName = i18n("Anonymous"); if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); } void KOPrefs::setTimeZoneIdDefault() { ; } void KOPrefs::setAllDefaults() { setCategoryDefaults(); mEventSummaryUser = getDefaultList() ; mTodoSummaryUser = getDefaultList() ; mLocationDefaults = getLocationDefaultList(); } void KOPrefs::setCategoryDefaults() { mCustomCategories.clear(); mCustomCategories = getDefaultList(); QStringList::Iterator it; for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { setCategoryColor(*it,mDefaultCategoryColor); } } QStringList KOPrefs::getLocationDefaultList() { QStringList retval ; retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") retval.sort(); return retval; } QStringList KOPrefs::getDefaultList() { QStringList retval ; retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; retval.sort(); //qDebug("cat %s ", retval.join("-").latin1()); return retval; } void KOPrefs::usrReadConfig() { config()->setGroup("General"); //qDebug("KOPrefs::usrReadConfig() "); mCustomCategories = config()->readListEntry("Custom Categories"); mOldLoadedLanguage = mOldLanguage ; mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; if (mLocationDefaults.isEmpty()) { mLocationDefaults = getLocationDefaultList(); } if (mEventSummaryUser.isEmpty()) { mEventSummaryUser = getDefaultList() ; } if (mTodoSummaryUser.isEmpty()) { mTodoSummaryUser = getDefaultList() ; } if (mCustomCategories.isEmpty()) setCategoryDefaults(); config()->setGroup("Personal Settings"); mName = config()->readEntry("user_name",""); mEmail = config()->readEntry("user_email",""); fillMailDefaults(); config()->setGroup("Category Colors"); QStringList::Iterator it; for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); } KPimPrefs::usrReadConfig(); } void KOPrefs::usrWriteConfig() { config()->setGroup("General"); config()->writeEntry("Custom Categories",mCustomCategories); config()->setGroup("Personal Settings"); config()->writeEntry("user_name",mName); config()->writeEntry("user_email",mEmail); config()->setGroup("Category Colors"); QDictIterator<QColor> it(mCategoryColors); while (it.current()) { config()->writeEntry(it.currentKey(),*(it.current())); ++it; } KPimPrefs::usrWriteConfig(); } void KOPrefs::setCategoryColor(QString cat,const QColor & color) { mCategoryColors.replace(cat,new QColor(color)); } QColor *KOPrefs::categoryColor(QString cat) { QColor *color = 0; if (!cat.isEmpty()) color = mCategoryColors[cat]; if (color) return color; else return &mDefaultCategoryColor; } void KOPrefs::setFullName(const QString &name) { mName = name; } void KOPrefs::setEmail(const QString &email) { //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); mEmail = email; } QString KOPrefs::fullName() { if (mEmailControlCenter) { KEMailSettings settings; return settings.getSetting(KEMailSettings::RealName); } else { return mName; } } QString KOPrefs::email() { if (mEmailControlCenter) { KEMailSettings settings; return settings.getSetting(KEMailSettings::EmailAddress); } else { return mEmail; } } KConfig* KOPrefs::getConfig() { return config(); } diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp index 74037e6..8439b81 100644 --- a/korganizer/koprefsdialog.cpp +++ b/korganizer/koprefsdialog.cpp @@ -1,1721 +1,1727 @@ /* This file is part of KOrganizer. Copyright (c) 2000,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 <qlayout.h> #include <qlabel.h> #include <qgroupbox.h> #include <qbuttongroup.h> #include <qlineedit.h> #include <qfont.h> #include <qslider.h> #include <qfile.h> #include <qtextstream.h> #include <qcombobox.h> #include <qvbox.h> #include <qhbox.h> #include <qregexp.h> #include <qspinbox.h> #include <qdatetime.h> #include <qcheckbox.h> #include <qradiobutton.h> #include <qpushbutton.h> #include <qstrlist.h> #include <qapplication.h> #include <kcolorbutton.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include <kfontdialog.h> #include <kfiledialog.h> #include <kmessagebox.h> #include <kcolordialog.h> #include <kiconloader.h> #include <kemailsettings.h> #include <kstandarddirs.h> +#include <kglobalsettings.h> #include <kurlrequester.h> #include <klineedit.h> #if defined(USE_SOLARIS) #include <sys/param.h> #define ZONEINFODIR "/usr/share/lib/zoneinfo" #define INITFILE "/etc/default/init" #endif #include "koprefs.h" #include "koprefsdialog.h" #include "kpimglobalprefs.h" KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : KPrefsDialog(KOPrefs::instance(),parent,name,true) { + setFont( KGlobalSettings::generalFont() ); setCaption( i18n("Preferences - some settings need a restart (nr)")); mCategoryDict.setAutoDelete(true); KGlobal::locale()->insertCatalogue("timezones"); + mSpacingHint = spacingHintSmall(); + mMarginHint = marginHintSmall(); +#ifndef DESKTOP_VERSION + if ( QApplication::desktop()->height() == 480 ) + hideButtons(); +#endif setupGlobalTab(); setupMainTab(); // setupLocaleTab(); //setupTimeZoneTab(); setupTimeTab(); //setupLocaleDateTab(); setupFontsTab(); setupColorsTab(); setupViewsTab(); //setupSyncTab(); //setupSyncAlgTab(); //setupPrinterTab(); //setupGroupSchedulingTab(); //setupGroupAutomationTab(); -#ifndef DESKTOP_VERSION - if ( QApplication::desktop()->height() == 480 ) - hideButtons(); -#endif + } KOPrefsDialog::~KOPrefsDialog() { } void KOPrefsDialog::setupGlobalTab() { QFrame *topFrame = addPage(i18n("Global"),0,0); kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), topFrame, "KCMKdeLibConfig" ); QVBoxLayout *topLayout = new QVBoxLayout(topFrame); topLayout->addWidget( kdelibcfg ); } void KOPrefsDialog::setupLocaleDateTab() { #if 0 QFrame *topFrame = addPage(i18n("Date Format"),0,0); QGridLayout *topLayout = new QGridLayout(topFrame,3,2); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); int iii = 0; KPrefsDialogWidRadios *syncPrefsGroup = addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); QString format; if ( QApplication::desktop()->width() < 480 ) format = "(%d.%m.%Y)"; else format = "(%d.%m.%Y|%A %d %B %Y)"; syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); if ( QApplication::desktop()->width() < 480 ) format = "(%m.%d.%Y)"; else format = "(%m.%d.%Y|%A %B %d %Y)"; syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); if ( QApplication::desktop()->width() < 480 ) format = "(%Y-%m-%d)"; else format = "(%Y-%m-%d|%A %Y %B %d)"; syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); syncPrefsGroup->addRadio(i18n("User defined")); topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); ++iii; ++iii; QLabel * lab; mUserDateFormatLong = new QLineEdit(topFrame); lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mUserDateFormatLong,iii,1); ++iii; mUserDateFormatShort = new QLineEdit(topFrame); lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mUserDateFormatShort,iii,1); ++iii; lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); topLayout->addMultiCellWidget(lab ,iii,iii,0,1); ++iii; lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); topLayout->addMultiCellWidget(lab ,iii,iii,0,1); ++iii; lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); topLayout->addMultiCellWidget(lab ,iii,iii,0,1); ++iii; #endif } void KOPrefsDialog::setupLocaleTab() { #if 0 QFrame *topFrame = addPage(i18n("Locale"),0,0); QGridLayout *topLayout = new QGridLayout(topFrame,4,2); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); int iii = 0; KPrefsDialogWidRadios *syncPrefsGroup = addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); syncPrefsGroup->addRadio(i18n("English")); syncPrefsGroup->addRadio(i18n("German")); syncPrefsGroup->addRadio(i18n("French")); syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); if ( QApplication::desktop()->width() < 300 ) ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); ++iii; syncPrefsGroup = addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); if ( QApplication::desktop()->width() > 300 ) syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); syncPrefsGroup->addRadio(i18n("24:00")); syncPrefsGroup->addRadio(i18n("12:00am")); syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); ++iii; KPrefsDialogWidBool *sb; if ( QApplication::desktop()->width() < 300 ) { sb = addWidBool(i18n("Week starts on Sunday"), &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); ++iii; sb = addWidBool(i18n("Use short date in (WN/E) view"), &(KOPrefs::instance()->mShortDateInViewer),topFrame); topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); } else { QWidget * hb = new QWidget( topFrame ); QHBoxLayout *hbLayout = new QHBoxLayout(hb); sb = addWidBool(i18n("Week starts on Sunday"), &(KOPrefs::instance()->mWeekStartsOnSunday),hb); hbLayout->addWidget(sb->checkBox() ); sb = addWidBool(i18n("Use short date in (WN/E) view"), &(KOPrefs::instance()->mShortDateInViewer),hb); hbLayout->addWidget(sb->checkBox() ); topLayout->addMultiCellWidget(hb, iii,iii,0,1); } // KPrefsDialogWidBool *sb; //#ifndef DESKTOP_VERSION #if 0 ++iii; sb = addWidBool(i18n("Quick load/save (w/o Unicode)"), &(KOPrefs::instance()->mUseQuicksave),topFrame); topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); #endif #endif } void KOPrefsDialog::showSyncPage() { showPage ( 0 ) ; kdelibcfg->showTimeZoneTab() ; } void KOPrefsDialog::setupSyncAlgTab() { #if 0 QLabel * lab; QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0); mSetupSyncAlgTab = topFrame; QGridLayout *topLayout = new QGridLayout(topFrame,6,2); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); int iii = 0; KPrefsDialogWidBool *sb = addWidBool(i18n("Ask for preferences before syncing"), &(KOPrefs::instance()->mAskForPreferences),topFrame); topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); ++iii; KPrefsDialogWidRadios *syncPrefsGroup = addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs), topFrame); syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); syncPrefsGroup->addRadio(i18n("Force take local entry always")); syncPrefsGroup->addRadio(i18n("Force take remote entry always")); topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); ++iii; sb = addWidBool(i18n("Show summary after syncing"), &(KOPrefs::instance()->mShowSyncSummary),topFrame); topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); ++iii; #endif } void KOPrefsDialog::setupSyncTab() { #if 0 QLabel * lab; QFrame *topFrame = addPage(i18n("Sync Network"),0,0); QGridLayout *topLayout = new QGridLayout(topFrame,6,2); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame); int iii = 0; topLayout->addMultiCellWidget(lab , iii,iii,0,1); ++iii; mRemoteIPEdit = new QLineEdit(topFrame); lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mRemoteIPEdit,iii,1); ++iii; mRemoteUser = new QLineEdit(topFrame); lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mRemoteUser, iii,1); ++iii; mRemoteFile = new QLineEdit(topFrame); lab = new QLabel(mRemoteFile, i18n("Remote file:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mRemoteFile,iii,1); ++iii; mLocalTempFile = new QLineEdit(topFrame); lab = new QLabel(mLocalTempFile, i18n("Local temp file:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mLocalTempFile,iii,1); ++iii; KPrefsDialogWidBool *wb = addWidBool(i18n("Write back synced file"), &(KOPrefs::instance()->mWriteBackFile),topFrame); topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); ++iii; wb = addWidBool(i18n("Write back existing entries only"), &(KOPrefs::instance()->mWriteBackExistingOnly),topFrame); topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); ++iii; #endif } void KOPrefsDialog::setupMainTab() { QFrame *topFrame = addPage(i18n("General"),0,0); // DesktopIcon("identity",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,5,2); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); // KPrefsDialogWidBool *emailControlCenter = // addWidBool(i18n("&Use email settings from Control Center"), // &(KOPrefs::instance()->mEmailControlCenter),topFrame); // topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), // SLOT(toggleEmailSettings(bool))); mNameEdit = new QLineEdit(topFrame); mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); topLayout->addWidget(mNameLabel,0,0); topLayout->addWidget(mNameEdit,0,1); mEmailEdit = new QLineEdit(topFrame); mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); topLayout->addWidget(mEmailLabel,1,0); topLayout->addWidget(mEmailEdit,1,1); KPrefsDialogWidBool *wb; KPrefsDialogWidBool *widbool = addWidBool(i18n("Full menu bar(nr)"), &(KOPrefs::instance()->mShowFullMenu),topFrame); topLayout->addMultiCellWidget( widbool->checkBox(), 2,2,0,1); widbool = addWidBool(i18n("Mini icons in toolbar(nr)"), &(KOPrefs::instance()->mToolBarMiniIcons),topFrame); topLayout->addMultiCellWidget( widbool->checkBox(), 3,3,0,1); KPrefsDialogWidBool *verticalScreen = addWidBool(i18n("Show vertical screen (Needs restart)"), &(KOPrefs::instance()->mVerticalScreen),topFrame); //topLayout->addWidget(verticalScreen->checkBox(),ii++,0); topLayout->addMultiCellWidget(verticalScreen->checkBox(),4,4,0,1); QHBox *dummy = new QHBox(topFrame); new QLabel(i18n("Days in Next-X-Days:"),dummy); mNextXDaysSpin = new QSpinBox(2,14,1,dummy); topLayout->addMultiCellWidget(dummy,5,5,0,1); // KPrefsDialogWidBool *bcc = // addWidBool(i18n("Send copy to owner when mailing events"), // &(KOPrefs::instance()->mBcc),topFrame); // topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); // addWidBool(i18n("Enable automatic saving of calendar"), // &(KOPrefs::instance()->mAutoSave),autoSaveGroup); QHBox *intervalBox = new QHBox(topFrame); - // intervalBox->setSpacing(spacingHint()); + // intervalBox->setSpacing(mSpacingHint); topLayout->addMultiCellWidget(intervalBox,6,6,0,1); QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox); mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); /* QHBox * agendasize = new QHBox ( topFrame ); new QLabel (i18n("AllDayAgenda Height:"), agendasize ); mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize); topLayout->addMultiCellWidget(agendasize,7,7,0,1); */ KPrefsDialogWidBool *ask = addWidBool(i18n("Ask for quit when closing KO/Pi"), &(KOPrefs::instance()->mAskForQuit),topFrame); topLayout->addMultiCellWidget(ask->checkBox(),7,7,0,1); /* KPrefsDialogWidBool *confirmCheck = addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm), topFrame); topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); mEnableGroupScheduling = addWidBool(i18n("Enable group scheduling"), &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), SLOT(warningGroupScheduling())); mEnableProjectView = addWidBool(i18n("Enable project view"), &(KOPrefs::instance()->mEnableProjectView),topFrame); topLayout->addWidget(mEnableProjectView->checkBox(),9,0); connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), SLOT(warningProjectView())); // Can't be disabled anymore mEnableGroupScheduling->checkBox()->hide(); // Disable setting, because this feature now becomes stable mEnableProjectView->checkBox()->hide(); KPrefsDialogWidRadios *defaultFormatGroup = addWidRadios(i18n("Default Calendar Format"), &(KOPrefs::instance()->mDefaultFormat),topFrame); defaultFormatGroup->addRadio(i18n("vCalendar")); defaultFormatGroup->addRadio(i18n("iCalendar")); topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); // Default format unconditionally is iCalendar defaultFormatGroup->groupBox()->hide(); KPrefsDialogWidRadios *mailClientGroup = addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), topFrame); mailClientGroup->addRadio(i18n("KMail")); mailClientGroup->addRadio(i18n("Sendmail")); topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); KPrefsDialogWidBool *htmlsave = addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave), topFrame); topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1); KPrefsDialogWidRadios *destinationGroup = addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination), topFrame); destinationGroup->addRadio(i18n("be added to the standard resource")); destinationGroup->addRadio(i18n("be asked which resource to use")); topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1); topLayout->setRowStretch(14,1); */ } void KOPrefsDialog::setupTimeTab() { QFrame *topFrame = addPage(i18n("Time"),0,0); // DesktopIcon("clock",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,4,2); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); QHBox *dummy = new QHBox(topFrame); KPrefsDialogWidTime *dayBegins = addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), dummy); //topLayout->addWidget(dayBegins->label(),2,0); //topLayout->addWidget(dayBegins->spinBox(),2,1); topLayout->addMultiCellWidget(dummy,0,0,0,1); topLayout->addWidget(new QLabel(i18n("Default appointment time:"), topFrame),1,0); mStartTimeSpin = new QSpinBox(0,23,1,topFrame); mStartTimeSpin->setSuffix(":00"); topLayout->addWidget(mStartTimeSpin,1,1); topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"), topFrame),2,0); mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame); mDefaultDurationSpin->setSuffix(":00"); topLayout->addWidget(mDefaultDurationSpin,2,1); QStringList alarmList; alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes") << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ; topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame), 3,0); mAlarmTimeCombo = new QComboBox(topFrame); mAlarmTimeCombo->insertStringList(alarmList); topLayout->addWidget(mAlarmTimeCombo,3,1); QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal, i18n("Working Hours"), topFrame); topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1); workingHoursGroup->layout()->setSpacing( 0 ); workingHoursGroup->layout()->setMargin( 4 ); QHBox *workStartBox = new QHBox(workingHoursGroup); // workStartBox->setMargin( 0 ); addWidTime(i18n("Daily starting hour:"), &(KOPrefs::instance()->mWorkingHoursStart),workStartBox); QHBox *workEndBox = new QHBox(workingHoursGroup); //workEndBox->setMargin( 0 ); addWidTime(i18n("Daily ending hour:"), &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox); QVBox *excludeBox = new QVBox(workingHoursGroup); //excludeBox->setMargin( 0 ); addWidBool(i18n("Exclude holidays"), &(KOPrefs::instance()->mExcludeHolidays),excludeBox); addWidBool(i18n("Exclude Saturdays"), &(KOPrefs::instance()->mExcludeSaturdays),excludeBox); // KPrefsDialogWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"), // &(KOPrefs::instance()->mMarcusBainsShowSeconds), // topFrame); // topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0); // topLayout->setRowStretch(6,1); } void KOPrefsDialog::setupViewsTab() { QFrame *topFrame = addPage(i18n("Views"),0,0); // DesktopIcon("viewmag",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,6,1); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); // QBoxLayout *dayBeginsLayout = new QHBoxLayout; // topLayout->addLayout(dayBeginsLayout,0,0); // KPrefsDialogWidTime *dayBegins = // addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), // topFrame); // dayBeginsLayout->addWidget(dayBegins->label()); // dayBeginsLayout->addStretch(1); // dayBeginsLayout->addWidget(dayBegins->spinBox()); // QBoxLayout *nextDaysLayout = new QHBoxLayout; // topLayout->addLayout(nextDaysLayout,1,0); // nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame)); // mNextXDaysSpin = new QSpinBox(2,14,1,topFrame); // nextDaysLayout->addStretch(1); // nextDaysLayout->addWidget(mNextXDaysSpin); int ii = 0; KPrefsDialogWidBool *dummy = addWidBool(i18n("Edit item on doubleclick (if not, show)"), &(KOPrefs::instance()->mEditOnDoubleClick),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); // topLayout->addWidget(hourSizeGroup,ii++,0); // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0); //topLayout->setRowStretch(11,1); #if 0 topFrame = addPage(i18n("ViewChange"),0,0); // DesktopIcon("viewmag",KIcon::SizeMedium)); topLayout = new QGridLayout(topFrame,6,1); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); ii = 0; #endif dummy = addWidBool(i18n("Hold fullscreen on view change"), &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Hold non-fullscreen on view change"), &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); KPrefsDialogWidBool *fullViewMonth = addWidBool(i18n("Next days view uses full window"), &(KOPrefs::instance()->mFullViewMonth),topFrame); topLayout->addWidget(fullViewMonth->checkBox(),ii++,0); KPrefsDialogWidBool *fullViewTodo = addWidBool(i18n("Event list view uses full window"), &(KOPrefs::instance()->mFullViewTodo),topFrame); topLayout->addWidget(fullViewTodo->checkBox(),ii++,0); dummy = addWidBool(i18n("Listview uses monthly timespan"), &(KOPrefs::instance()->mListViewMonthTimespan),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Highlight selection in Time Edit"), &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame); topLayout->addWidget( dummy->checkBox(), ii++,0); KPrefsDialogWidBool *dailyRecur = addWidBool(i18n("Show events that recur daily in date nav."), &(KOPrefs::instance()->mDailyRecur),topFrame); topLayout->addWidget(dailyRecur->checkBox(),ii++,0); KPrefsDialogWidBool *weeklyRecur = addWidBool(i18n("Show ev. that recur weekly in date nav."), &(KOPrefs::instance()->mWeeklyRecur),topFrame); topLayout->addWidget(weeklyRecur->checkBox(),ii++,0); - +#ifdef DESKTOP_VERSION KPrefsDialogWidBool *enableToolTips = addWidBool(i18n("Enable tooltips displaying summary of ev."), &(KOPrefs::instance()->mEnableToolTips),topFrame); topLayout->addWidget(enableToolTips->checkBox(),ii++,0); - +#endif // ********************************************************* topFrame = addPage(i18n("Agenda View"),0,0); // DesktopIcon("viewmag",KIcon::SizeMedium)); topLayout = new QGridLayout(topFrame,5,1); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); ii = 0; dummy = addWidBool(i18n("Show time in agenda items"), &(KOPrefs::instance()->mShowTimeInAgenda),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Highlight current day in agenda"), &(KOPrefs::instance()->mHighlightCurrentDay),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Use light color for highlight current day"), &(KOPrefs::instance()->mUseHighlightLightColor),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); KPrefsDialogWidBool *marcusBainsEnabled = addWidBool(i18n("Show current time"), &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0); dummy = addWidBool(i18n("Set agenda to DayBeginsAt on change"), &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Set agenda to current time on change"), &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); topFrame = addPage(i18n("Month View"),0,0); // DesktopIcon("viewmag",KIcon::SizeMedium)); topLayout = new QGridLayout(topFrame,5,1); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); + qDebug("%d %d ",mSpacingHint, mMarginHint ); ii = 0; QLabel *lab; QHBox *habo = new QHBox( topFrame ); if ( QApplication::desktop()->width() <= 480 ) { lab = new QLabel ( i18n("Show events that recur "), topFrame ); topLayout->addMultiCellWidget(lab,ii, ii,0,1); ii++; } else { new QLabel ( i18n("Show events that recur "), habo ); } dailyRecur = addWidBool(i18n("daily"), &(KOPrefs::instance()->mMonthDailyRecur),habo); // topLayout->addWidget(dailyRecur->checkBox(),ii++,0); weeklyRecur = addWidBool(i18n("weekly"), &(KOPrefs::instance()->mMonthWeeklyRecur),habo); topLayout->addMultiCellWidget(habo,ii, ii,0,1); ii++; habo = new QHBox( topFrame ); if ( QApplication::desktop()->width() <= 480 ) { lab = new QLabel (i18n("Show in every cell ") , topFrame ); topLayout->addMultiCellWidget(lab,ii, ii,0,1); ii++; } else { new QLabel ( i18n("Show in every cell "), habo ); } weeklyRecur = addWidBool(i18n("short month"), &(KOPrefs::instance()->mMonthShowShort),habo); weeklyRecur = addWidBool(i18n("icons"), &(KOPrefs::instance()->mMonthShowIcons),habo); topLayout->addMultiCellWidget(habo,ii, ii,0,1); ii++; #ifdef DESKTOP_VERSION KPrefsDialogWidBool *enableMonthScroll = addWidBool(i18n("Enable scrollbars in month view cells"), &(KOPrefs::instance()->mEnableMonthScroll),topFrame); topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0); #endif dummy = addWidBool(i18n("Week view mode uses bigger font"), &(KOPrefs::instance()->mMonthViewUsesBigFont),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Show Sat/Sun together"), &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); KPrefsDialogWidBool *coloredCategoriesInMonthView = addWidBool(i18n("Month view uses category colors"), &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame); topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); dummy = addWidBool(i18n("Categorie colors are applied to text"), &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); coloredCategoriesInMonthView = addWidBool(i18n("Month view uses day colors"), &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame); topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); KPrefsDialogWidColor *holidayColor = addWidColor(i18n("Day color odd months"), &(KOPrefs::instance()->mMonthViewOddColor),topFrame); topLayout->addWidget(holidayColor->label(),ii,0); topLayout->addWidget(holidayColor->button(),ii++,1); holidayColor = addWidColor(i18n("Day color even months"), &(KOPrefs::instance()->mMonthViewEvenColor),topFrame); topLayout->addWidget(holidayColor->label(),ii,0); topLayout->addWidget(holidayColor->button(),ii++,1); holidayColor = addWidColor(i18n("Color for Sundays + category \"Holiday\""), &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame); topLayout->addWidget(holidayColor->label(),ii,0); topLayout->addWidget(holidayColor->button(),ii++,1); // *********************** What'sNext View topFrame = addPage(i18n("What's Next View"),0,0); // DesktopIcon("viewmag",KIcon::SizeMedium)); topLayout = new QGridLayout(topFrame,4,1); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); ii = 0; QHBox* hdummy = new QHBox(topFrame); new QLabel(i18n("Days in What's Next:"),hdummy); mWhatsNextSpin = new QSpinBox(1,14,1,hdummy); topLayout->addWidget(hdummy,ii++,0); QHBox *prioBox = new QHBox(topFrame); - // intervalBox->setSpacing(spacingHint()); + // intervalBox->setSpacing(mSpacingHint); topLayout->addWidget(prioBox,ii++,0); QString messa = i18n("Show topmost todo prios in What's Next:"); if ( QApplication::desktop()->width() < 300 ) messa = i18n("Show topmost todo prios in What's N.:"); QLabel *prioLabel = new QLabel(messa, prioBox); mPrioSpin = new QSpinBox(0,5,1,prioBox); if ( QApplication::desktop()->width() < 300 ) mPrioSpin->setFixedWidth( 40 ); KPrefsDialogWidBool *passwdk = addWidBool(i18n("Show events, that are done in \nWhat's Next view"), &(KOPrefs::instance()->mWNViewShowsPast),topFrame); topLayout->addWidget(passwdk->checkBox(), ii++,0); passwdk = addWidBool(i18n("Show parent To-Do's in What's Next view"), &(KOPrefs::instance()->mWNViewShowsParents),topFrame); topLayout->addWidget(passwdk->checkBox(), ii++,0); passwdk = addWidBool(i18n("Show location in What's Next view"), &(KOPrefs::instance()->mWNViewShowLocation),topFrame); topLayout->addWidget(passwdk->checkBox(), ii++,0); passwdk = addWidBool(i18n("Show Sync Events in \nWhat's Next/Agenda view"), &(KOPrefs::instance()->mShowSyncEvents),topFrame); topLayout->addWidget(passwdk->checkBox(), ii++,0); passwdk = addWidBool(i18n("Use short date in \nWhat's Next/Event view"), &(KOPrefs::instance()->mShortDateInViewer),topFrame); topLayout->addWidget(passwdk->checkBox(), ii++,0); // *********************** Todo View topFrame = addPage(i18n("Todo View"),0,0); // DesktopIcon("viewmag",KIcon::SizeMedium)); topLayout = new QGridLayout(topFrame,4,1); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); ii = 0; dummy = addWidBool(i18n("Hide not running Todos in To-do view"), &(KOPrefs::instance()->mHideNonStartedTodos),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); KPrefsDialogWidBool *showCompletedTodo = addWidBool(i18n("To-do view shows completed Todos"), &(KOPrefs::instance()->mShowCompletedTodo),topFrame); topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0); dummy = addWidBool(i18n("To-do view shows complete as 'xx %'"), &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Small To-do view uses smaller font"), &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Todo view uses category colors"), &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); QWidget* wid = new QWidget( topFrame ); // Todo due today color KPrefsDialogWidColor *todoDueTodayColor = addWidColor(i18n("Todo due today color:"), &(KOPrefs::instance()->mTodoDueTodayColor),wid); QHBoxLayout *widLayout = new QHBoxLayout(wid); widLayout->addWidget( todoDueTodayColor->label() ); widLayout->addWidget( todoDueTodayColor->button() ); topLayout->addWidget(wid,ii++,0); //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); // Todo overdue color wid = new QWidget( topFrame ); widLayout = new QHBoxLayout(wid); KPrefsDialogWidColor *todoOverdueColor = addWidColor(i18n("Todo overdue color:"), &(KOPrefs::instance()->mTodoOverdueColor),wid); widLayout->addWidget(todoOverdueColor->label()); widLayout->addWidget(todoOverdueColor->button()); topLayout->addWidget(wid,ii++,0); dummy = addWidBool(i18n("Colors are applied to text"), &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Allday Agenda view shows todos"), &(KOPrefs::instance()->mShowTodoInAgenda),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); topFrame = addPage(i18n("View Options"),0,0); topLayout = new QGridLayout(topFrame,4,1); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); ii = 0; lab = new QLabel( i18n("Show in todo/event viewer:"), topFrame); topLayout->addWidget(lab ,ii++,0); dummy = addWidBool(i18n("Details"), &(KOPrefs::instance()->mEVshowDetails),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Created time"), &(KOPrefs::instance()->mEVshowCreated),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Last modified time"), &(KOPrefs::instance()->mEVshowChanged),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); lab = new QLabel( i18n("Show in What'sThis quick overview:"), topFrame); topLayout->addWidget(lab ,ii++,0); dummy = addWidBool(i18n("Details"), &(KOPrefs::instance()->mWTshowDetails),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Created time"), &(KOPrefs::instance()->mWTshowCreated),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); dummy = addWidBool(i18n("Last modified time"), &(KOPrefs::instance()->mWTshowChanged),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); topFrame = addPage(i18n("Alarm"),0,0); // DesktopIcon("viewmag",KIcon::SizeMedium)); topLayout = new QGridLayout(topFrame,2,1); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); int iii = 0; dummy = addWidBool(i18n("Use internal alarm notification"), &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame); topLayout->addWidget(dummy->checkBox(),iii++,0); lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame); topLayout->addWidget(lab ,iii++,0); #ifndef DESKTOP_VERSION lab->setAlignment( AlignLeft|WordBreak|AlignTop); #else lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); #endif QHBox* dummyBox = new QHBox(topFrame); new QLabel(i18n("Play beeps count:"),dummyBox); mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox); topLayout->addWidget(dummyBox,iii++,0); dummyBox = new QHBox(topFrame); new QLabel(i18n("Beeps interval in sec:"),dummyBox); mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox); topLayout->addWidget(dummyBox,iii++,0); dummyBox = new QHBox(topFrame); new QLabel(i18n("Default suspend time in min:"),dummyBox); mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox); topLayout->addWidget(dummyBox,iii++,0); dummyBox = new QHBox(topFrame); new QLabel(i18n("Auto suspend count:"),dummyBox); mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox); topLayout->addWidget(dummyBox,iii++,0); QHBox* hbo = new QHBox ( topFrame ); mDefaultAlarmFile = new QLineEdit(hbo); QPushButton * loadTemplate = new QPushButton(hbo); QPixmap icon; if ( QApplication::desktop()->width() < 321 ) icon = SmallIcon("fileimport16"); else icon = SmallIcon("fileimport"); loadTemplate->setIconSet (icon ) ; connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) ); int size = loadTemplate->sizeHint().height(); loadTemplate->setFixedSize( size, size ); //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame); // topLayout->addWidget(lab ,iii++,0); lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame); topLayout->addWidget(lab ,iii++,0); topLayout->addWidget(hbo,iii++,0); // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame); // topLayout->addWidget(lab ,iii++,0); // #ifndef DESKTOP_VERSION // lab->setAlignment( AlignLeft|WordBreak|AlignTop); // #else // lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); // lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); // #endif } void KOPrefsDialog::selectSoundFile() { QString fileName = mDefaultAlarmFile->text(); fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this ); if ( fileName.length() > 0 ) mDefaultAlarmFile->setText( fileName ); } void KOPrefsDialog::setupFontsTab() { QFrame *topFrame = addPage(i18n("Fonts"),0,0); // DesktopIcon("fonts",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,7,3); topLayout->setSpacing(1); topLayout->setMargin(3); KPrefsDialogWidFont * tVFont; int i = 0; KPrefsDialogWidFont *timeLabelsFont = addWidFont(i18n("23"),i18n("DateNavigator:(nr)"), &(KOPrefs::instance()->mDateNavigatorFont),topFrame); topLayout->addWidget(timeLabelsFont->label(),i,0); topLayout->addWidget(timeLabelsFont->preview(),i,1); topLayout->addWidget(timeLabelsFont->button(),i,2); ++i; timeLabelsFont = addWidFont(i18n("Mon 15"),i18n("Date Labels:"), &(KOPrefs::instance()->mTimeLabelsFont),topFrame); topLayout->addWidget(timeLabelsFont->label(),i,0); topLayout->addWidget(timeLabelsFont->preview(),i,1); topLayout->addWidget(timeLabelsFont->button(),i,2); ++i; KPrefsDialogWidFont *timeBarFont = addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"), &(KOPrefs::instance()->mTimeBarFont),topFrame); topLayout->addWidget(timeBarFont->label(),i,0); topLayout->addWidget(timeBarFont->preview(),i,1); topLayout->addWidget(timeBarFont->button(),i,2); ++i; KPrefsDialogWidFont *marcusBainsFont = addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"), &(KOPrefs::instance()->mMarcusBainsFont),topFrame); topLayout->addWidget(marcusBainsFont->label(),i,0); topLayout->addWidget(marcusBainsFont->preview(),i,1); topLayout->addWidget(marcusBainsFont->button(),i,2); ++i; tVFont = addWidFont(i18n("Summary"),i18n("Event Viewer:"), &(KOPrefs::instance()->mEventViewFont),topFrame); topLayout->addWidget(tVFont->label(),i,0); topLayout->addWidget(tVFont->preview(),i,1); topLayout->addWidget(tVFont->button(),i,2); ++i; tVFont = addWidFont(i18n("Details"),i18n("EditorBox:"), &(KOPrefs::instance()->mEditBoxFont),topFrame); topLayout->addWidget(tVFont->label(),i,0); topLayout->addWidget(tVFont->preview(),i,1); topLayout->addWidget(tVFont->button(),i,2); ++i; topLayout->setColStretch(1,1); topLayout->setRowStretch(4,1); i = 0; topFrame = addPage(i18n("View Fonts"),0, DesktopIcon("fonts",KIcon::SizeMedium)); topLayout = new QGridLayout(topFrame,7,3); topLayout->setSpacing(1); topLayout->setMargin(3); tVFont = addWidFont(i18n("Configure KO"),i18n("What's Next View:"), &(KOPrefs::instance()->mWhatsNextFont),topFrame); topLayout->addWidget(tVFont->label(),i,0); topLayout->addWidget(tVFont->preview(),i,1); topLayout->addWidget(tVFont->button(),i,2); ++i; KPrefsDialogWidFont *agendaViewFont = addWidFont(i18n("Event text"),i18n("Agenda view:"), &(KOPrefs::instance()->mAgendaViewFont),topFrame); topLayout->addWidget(agendaViewFont->label(),i,0); topLayout->addWidget(agendaViewFont->preview(),i,1); topLayout->addWidget(agendaViewFont->button(),i,2); ++i; KPrefsDialogWidFont *monthViewFont = addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"), i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame); topLayout->addWidget(monthViewFont->label(),i,0); topLayout->addWidget(monthViewFont->preview(),i,1); topLayout->addWidget(monthViewFont->button(),i,2); ++i; KPrefsDialogWidFont *lVFont = addWidFont(i18n("Event"),i18n("List View:"), &(KOPrefs::instance()->mListViewFont),topFrame); topLayout->addWidget(lVFont->label(),i,0); topLayout->addWidget(lVFont->preview(),i,1); topLayout->addWidget(lVFont->button(),i,2); ++i; tVFont = addWidFont(i18n("ToDo"),i18n("ToDoView:"), &(KOPrefs::instance()->mTodoViewFont),topFrame); topLayout->addWidget(tVFont->label(),i,0); topLayout->addWidget(tVFont->preview(),i,1); topLayout->addWidget(tVFont->button(),i,2); ++i; tVFont = addWidFont(i18n("Today"),i18n("JournalView:"), &(KOPrefs::instance()->mJornalViewFont),topFrame); topLayout->addWidget(tVFont->label(),i,0); topLayout->addWidget(tVFont->preview(),i,1); topLayout->addWidget(tVFont->button(),i,2); ++i; topLayout->setColStretch(1,1); topLayout->setRowStretch(4,1); } void KOPrefsDialog::setupColorsTab() { QFrame *topFrame = addPage(i18n("Colors"),0,0); // DesktopIcon("colorize",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,5,2); - // topLayout->setSpacing(spacingHint()); - // topLayout->setMargin(marginHint()); + // topLayout->setSpacing(mSpacingHint); + // topLayout->setMargin(mMarginHint); topLayout->setSpacing(2); topLayout->setMargin(3); int ii = 1; QGroupBox *categoryGroup ; categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"), topFrame); topLayout->addMultiCellWidget(categoryGroup,0,0,0,1); mCategoryCombo = new QComboBox(categoryGroup); mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); mCategoryButton = new KColorButton(categoryGroup); connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); updateCategoryColor(); // Holiday Color KPrefsDialogWidColor *holidayColor = addWidColor(i18n("Holiday color:"), &(KOPrefs::instance()->mHolidayColor),topFrame); topLayout->addWidget(holidayColor->label(),ii,0); topLayout->addWidget(holidayColor->button(),ii++,1); // Highlight Color KPrefsDialogWidColor *highlightColor = addWidColor(i18n("Highlight color:"), &(KOPrefs::instance()->mHighlightColor),topFrame); topLayout->addWidget(highlightColor->label(),ii,0); topLayout->addWidget(highlightColor->button(),ii++,1); // Event color KPrefsDialogWidColor *eventColor = addWidColor(i18n("Default event color:"), &(KOPrefs::instance()->mEventColor),topFrame); topLayout->addWidget(eventColor->label(),ii,0); topLayout->addWidget(eventColor->button(),ii++,1); eventColor = addWidColor(i18n("Default todo done color:"), &(KOPrefs::instance()->mTodoDoneColor),topFrame); topLayout->addWidget(eventColor->label(),ii,0); topLayout->addWidget(eventColor->button(),ii++,1); // agenda view background color KPrefsDialogWidColor *agendaBgColor = addWidColor(i18n("Agenda view background color:"), &(KOPrefs::instance()->mAgendaBgColor),topFrame); topLayout->addWidget(agendaBgColor->label(),ii,0); topLayout->addWidget(agendaBgColor->button(),ii++,1); // working hours color KPrefsDialogWidColor *workingHoursColor = addWidColor(i18n("Working hours color:"), &(KOPrefs::instance()->mWorkingHoursColor),topFrame); topLayout->addWidget(workingHoursColor->label(),ii,0); topLayout->addWidget(workingHoursColor->button(),ii++,1); KPrefsDialogWidBool *sb = addWidBool(i18n("Use colors for application:"), &(KOPrefs::instance()->mUseAppColors),topFrame); topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 ); ii++; KPrefsDialogWidColor * workingHoursColor1 = addWidColor(i18n("Buttons, menus, etc.:"), &(KOPrefs::instance()->mAppColor1),topFrame); topLayout->addWidget(workingHoursColor1->label(),ii,0); topLayout->addWidget(workingHoursColor1->button(),ii++,1); KPrefsDialogWidColor * workingHoursColor2 = addWidColor(i18n("Frames, labels, etc.:"), &(KOPrefs::instance()->mAppColor2),topFrame); topLayout->addWidget(workingHoursColor2->label(),ii,0); topLayout->addWidget(workingHoursColor2->button(),ii++,1); } void KOPrefsDialog::setCategoryColor() { mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); } void KOPrefsDialog::updateCategoryColor() { QString cat = mCategoryCombo->currentText(); QColor *color = mCategoryDict.find(cat); if (!color) { color = KOPrefs::instance()->categoryColor(cat); } if (color) { mCategoryButton->setColor(*color); } } void KOPrefsDialog::setupPrinterTab() { mPrinterTab = addPage(i18n("Printing"),0, DesktopIcon("fileprint",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); topLayout->setRowStretch(4,1); } void KOPrefsDialog::setupGroupSchedulingTab() { #if 0 QFrame *topFrame = addPage(i18n("Group Scheduling"),0, DesktopIcon("personal",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,6,2); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); #if 0 KPrefsDialogWidRadios *schedulerGroup = addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler), topFrame); schedulerGroup->addRadio("Dummy"); // Only for debugging schedulerGroup->addRadio(i18n("Mail client")); topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); #endif KPrefsDialogWidRadios *sendGroup = addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend), topFrame); sendGroup->addRadio(i18n("Send to outbox")); sendGroup->addRadio(i18n("Send directly")); topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); mAMails = new QListView(topFrame); mAMails->addColumn(i18n("Email"),300); topLayout->addMultiCellWidget(mAMails,3,3,0,1); topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); aEmailsEdit = new QLineEdit(topFrame); aEmailsEdit->setEnabled(false); topLayout->addWidget(aEmailsEdit,4,1); QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); topLayout->addWidget(add,5,0); QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); topLayout->addWidget(del,5,1); //topLayout->setRowStretch(2,1); connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); #endif } void KOPrefsDialog::setupGroupAutomationTab() { return; QFrame *topFrame = addPage(i18n("Group Automation"),0, DesktopIcon("personal",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,5,1); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); KPrefsDialogWidRadios *autoRefreshGroup = addWidRadios(i18n("Auto Send Refresh"), &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame); autoRefreshGroup->addRadio(i18n("Never")); autoRefreshGroup->addRadio(i18n("If attendee is in addressbook")); //autoRefreshGroup->addRadio(i18n("selected emails")); topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); KPrefsDialogWidRadios *autoInsertGroup = addWidRadios(i18n("Auto Insert IMIP Replies"), &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame); autoInsertGroup->addRadio(i18n("Never")); autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); //autoInsertGroup->addRadio(i18n("selected emails")); topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); KPrefsDialogWidRadios *autoRequestGroup = addWidRadios(i18n("Auto Insert IMIP Requests"), &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame); autoRequestGroup->addRadio(i18n("Never")); autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); //autoInsertGroup->addRadio(i18n("selected emails")); topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); KPrefsDialogWidRadios *autoFreeBusyGroup = addWidRadios(i18n("Auto Send FreeBusy Information"), &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame); autoFreeBusyGroup->addRadio(i18n("Never")); autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); //autoFreeBusyGroup->addRadio(i18n("selected emails")); topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); KPrefsDialogWidRadios *autoFreeBusyReplyGroup = addWidRadios(i18n("Auto Save FreeBusy Replies"), &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame); autoFreeBusyReplyGroup->addRadio(i18n("Never")); autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); //autoFreeBusyGroup->addRadio(i18n("selected emails")); topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); } void KOPrefsDialog::showPrinterTab() { showPage(pageIndex(mPrinterTab)); } void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, const QStringList *tags) { if (tags) { int i = tags->findIndex(text); if (i > 0) combo->setCurrentItem(i); } else { for(int i=0;i<combo->count();++i) { if (combo->text(i) == text) { combo->setCurrentItem(i); break; } } } } void KOPrefsDialog::usrReadConfig() { kdelibcfg->readConfig(); mNameEdit->setText(KOPrefs::instance()->fullName()); mEmailEdit->setText(KOPrefs::instance()->email()); mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); // QDate current ( 2001, 1,1); //mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1)); //mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1)); //setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId)); //mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset); mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); // if (KOPrefs::instance()->mAllDaySize > 47 ) // KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize/2; //mHourSizeSlider->setValue(KOPrefs::instance()->mAllDaySize); mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays); mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios); // mAMails->clear(); // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); // it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { // QListViewItem *item = new QListViewItem(mAMails); // item->setText(0,*it); // mAMails->insertItem(item); // } // mRemoteIPEdit->setText(KOPrefs::instance()->mRemoteIP); //mRemoteUser->setText(KOPrefs::instance()->mRemoteUser); //mRemotePassWd->setText(KOPrefs::instance()->mRemotePassWd); //mRemoteFile->setText(KOPrefs::instance()->mRemoteFile); //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile); mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile); //QString dummy = KOPrefs::instance()->mUserDateFormatLong; //mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); //dummy = KOPrefs::instance()->mUserDateFormatShort; //mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); updateCategories(); mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps ); mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime ); mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount ); mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval ); } void KOPrefsDialog::usrWriteConfig() { kdelibcfg->writeConfig(); // KOPrefs::instance()->mRemoteIP = mRemoteIPEdit->text(); //KOPrefs::instance()->mRemoteUser = mRemoteUser->text(); //KOPrefs::instance()->mRemotePassWd = mRemotePassWd->text(); //KOPrefs::instance()->mRemoteFile= mRemoteFile->text(); //KOPrefs::instance()->mLocalTempFile =mLocalTempFile->text(); KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text(); //KOPrefs::instance()->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); //KOPrefs::instance()->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); KOPrefs::instance()->setFullName(mNameEdit->text()); KOPrefs::instance()->setEmail(mEmailEdit->text()); KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); // KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText(); //QDate date; //date = mStartDateSavingEdit->date(); //int sub = 0; //if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) // sub = 1; // KOPrefs::instance()->mDaylightsavingStart = date.dayOfYear()-sub; // date = mEndDateSavingEdit->date(); // if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) // sub = 1; // else // sub = 0; // KOPrefs::instance()->mDaylightsavingEnd = date.dayOfYear()-sub; // // KOPrefs::instance()->mTimeZoneOffset = mTimezoneOffsetSpin->value(); KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); //KOPrefs::instance()->mAllDaySize = mHourSizeSlider->value(); QDictIterator<QColor> it(mCategoryDict); while (it.current()) { KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); ++it; } KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value(); KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value(); KOPrefs::instance()->mAdditionalMails.clear(); // QListViewItem *item; // item = mAMails->firstChild(); // while (item) // { // KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); // item = item->nextSibling(); // } KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value(); KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ; KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ; KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ; } void KOPrefsDialog::updateCategories() { mCategoryCombo->clear(); mCategoryDict.clear(); mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); updateCategoryColor(); } void KOPrefsDialog::warningGroupScheduling() { warningExperimental(mEnableGroupScheduling->checkBox()->isChecked()); } void KOPrefsDialog::warningProjectView() { warningExperimental(mEnableProjectView->checkBox()->isChecked()); } void KOPrefsDialog::warningExperimental(bool on) { if (on) { KMessageBox::information(this,i18n("This is an experimental feature. " "It may not work, it may do nothing useful and it may cause data loss. " "Use with care.\n" "You have to restart KOrganizer for this setting to take effect.")); } else { KMessageBox::information(this, i18n("You have to restart KOrganizer for this setting to take effect.")); } } void KOPrefsDialog::toggleEmailSettings(bool on) { if (on) { mEmailEdit->setEnabled(false); mNameEdit->setEnabled(false); mEmailLabel->setEnabled(false); mNameLabel->setEnabled(false); KEMailSettings settings; mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); } else { mEmailEdit->setEnabled(true); mNameEdit->setEnabled(true); mEmailLabel->setEnabled(true); mNameLabel->setEnabled(true); } } void KOPrefsDialog::addItem() { // aEmailsEdit->setEnabled(true); // QListViewItem *item = new QListViewItem(mAMails); // mAMails->insertItem(item); // mAMails->setSelected(item,true); // aEmailsEdit->setText(i18n("(EmptyEmail)")); } void KOPrefsDialog::removeItem() { // QListViewItem *item; // item = mAMails->selectedItem(); // if (!item) return; // mAMails->takeItem(item); // item = mAMails->selectedItem(); // if (!item) { // aEmailsEdit->setText(""); // aEmailsEdit->setEnabled(false); // } // if (mAMails->childCount() == 0) { // aEmailsEdit->setEnabled(false); // } } void KOPrefsDialog::updateItem() { // QListViewItem *item; // item = mAMails->selectedItem(); // if (!item) return; // item->setText(0,aEmailsEdit->text()); } void KOPrefsDialog::updateInput() { // QListViewItem *item; // item = mAMails->selectedItem(); // if (!item) return; // aEmailsEdit->setEnabled(true); // aEmailsEdit->setText(item->text(0)); } void KOPrefsDialog::updateTimezoneOffset( int index ) { /* qDebug("updateTimezoneOffset %d ", index); if ( index < 24 ) { mTimezoneOffsetSpin->setEnabled ( false ); mTimezoneOffsetSpin->setValue( ( index-11 ) * 60 ); } else { if ( index == 24 ) { mTimezoneOffsetSpin->setEnabled ( true ); mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset); } else { mTimezoneOffsetSpin->setEnabled ( false ); mTimezoneOffsetSpin->setValue( 0 ); } } */ } void KOPrefsDialog::setupTimeZoneTab() { #if 0 QFrame *topFrame = addPage(i18n("Time Zone"),0,0); // DesktopIcon("clock",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,5,2); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); + topLayout->setSpacing(mSpacingHint); + topLayout->setMargin(mMarginHint); QHBox *timeZoneBox = new QHBox( topFrame ); topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); new QLabel( i18n("Timezone:"), timeZoneBox ); mTimeZoneCombo = new QComboBox( timeZoneBox ); if ( QApplication::desktop()->width() < 300 ) { mTimeZoneCombo->setMaximumWidth(150); } QStringList list; list = KGlobal::locale()->timeZoneList(); mTimeZoneCombo->insertStringList(list); // find the currently set time zone and select it QString sCurrentlySet = KOPrefs::instance()->mTimeZoneId; int nCurrentlySet = 11; for (int i = 0; i < mTimeZoneCombo->count(); i++) { if (mTimeZoneCombo->text(i) == sCurrentlySet) { nCurrentlySet = i; break; } } mTimeZoneCombo->setCurrentItem(nCurrentlySet); int iii = 1; KPrefsDialogWidBool *sb = addWidBool(i18n("Timezone has daylight saving"), &(KOPrefs::instance()->mUseDaylightsaving),topFrame); topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); ++iii; QLabel* lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame ); topLayout->addMultiCellWidget(lab, iii,iii,0,1); ++iii; lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); topLayout->addMultiCellWidget(lab, iii,iii,0,1); ++iii; lab = new QLabel( i18n("Daylight start:"), topFrame ); topLayout->addWidget(lab, iii,0); mStartDateSavingEdit = new KDateEdit(topFrame); topLayout->addWidget(mStartDateSavingEdit, iii,1); ++iii; lab = new QLabel( i18n("Daylight end:"), topFrame ); topLayout->addWidget(lab, iii,0); mEndDateSavingEdit = new KDateEdit(topFrame); topLayout->addWidget(mEndDateSavingEdit, iii,1); ++iii; QDate current ( 2001, 1,1); mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1)); mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1)); #endif } diff --git a/korganizer/koprefsdialog.h b/korganizer/koprefsdialog.h index e20969a..6892028 100644 --- a/korganizer/koprefsdialog.h +++ b/korganizer/koprefsdialog.h @@ -1,164 +1,166 @@ /* This file is part of KOrganizer. Copyright (c) 2000,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. */ #ifndef _KOPREFSDIALOG_H #define _KOPREFSDIALOG_H #include <qframe.h> #include <qdict.h> #include <qcolor.h> #include <qlistview.h> #include <kdialogbase.h> #include <libkdepim/kprefsdialog.h> #include <libkdepim/kdateedit.h> #include <kcmconfigs/kdepimconfigwidget.h> class KColorButton; class QSpinBox; class QSlider; class KURLRequester; class QComboBox; class QLineEdit; class QStringList; /** Dialog to change the korganizer configuration. */ class KOPrefsDialog : public KPrefsDialog { Q_OBJECT public: /** Initialize dialog and pages */ KOPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); ~KOPrefsDialog(); public slots: void showPrinterTab(); /** Update controls for categories */ void updateCategories(); void showSyncPage(); protected slots: void selectSoundFile(); void setCategoryColor(); void updateCategoryColor(); void updateTimezoneOffset( int ); void warningExperimental(bool on); void warningGroupScheduling(); void warningProjectView(); void toggleEmailSettings(bool); //additional emails void addItem(); void removeItem(); void updateItem(); void updateInput(); protected: void usrReadConfig(); void usrWriteConfig(); void setupGlobalTab(); void setupMainTab(); void setupTimeTab(); void setupTimeZoneTab(); void setupLocaleTab(); void setupLocaleDateTab(); void setupFontsTab(); void setupColorsTab(); void setupViewsTab(); void setupDisplayTab(); void setupPrinterTab(); void setupGroupSchedulingTab(); void setupGroupAutomationTab(); void setupSyncTab(); void setupSyncAlgTab(); void setCombo(QComboBox *combo,const QString & text, const QStringList *tags = 0); private: KDEPIMConfigWidget* kdelibcfg; KPrefsDialogWidBool *mEnableGroupScheduling; KPrefsDialogWidBool *mEnableProjectView; QFrame *mPrinterTab; QLineEdit *nameEdit; QLineEdit *emailEdit; QComboBox *timeCombo; QComboBox *tzCombo; // widgets holding preferences data QLineEdit *mNameEdit; QLineEdit *mEmailEdit; QLabel *mNameLabel; QLabel *mEmailLabel; QLineEdit *mAdditionalEdit; QSpinBox *mAutoSaveIntervalSpin; QSpinBox *mPrioSpin; // QListView *mAMails; QLineEdit *aEmailsEdit; QComboBox *mTimeZoneCombo; QStringList tzonenames; QSpinBox *mStartTimeSpin; QSpinBox *mDefaultDurationSpin; QComboBox *mAlarmTimeCombo; QComboBox *mCategoryCombo; KColorButton *mCategoryButton; QDict<QColor> mCategoryDict; QSlider *mHourSizeSlider; QSpinBox *mNextXDaysSpin; QSpinBox *mWhatsNextSpin; QLineEdit * mRemoteIPEdit; QLineEdit * mRemoteUser; QLineEdit * mRemotePassWd; QLineEdit * mRemoteFile; QLineEdit * mLocalTempFile; QWidget* mSetupSyncAlgTab; QLineEdit * mUserDateFormatLong; QLineEdit * mUserDateFormatShort; QSpinBox *mTimezoneOffsetSpin; QSpinBox *mDaylightsavingStart; QSpinBox *mDaylightsavingEnd; KDateEdit* mStartDateSavingEdit; KDateEdit* mEndDateSavingEdit; QSpinBox * mAlarmPlayBeeps; QSpinBox * mAlarmSuspendTime; QSpinBox * mAlarmSuspendCount; QSpinBox * mAlarmBeepInterval; QLineEdit * mDefaultAlarmFile; + int mSpacingHint; + int mMarginHint; }; #endif diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index 0610d55..b03870f 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp @@ -1,279 +1,279 @@ /* This file is part of KOrganizer. Copyright (c) 2003 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 <qstring.h> #include <qtooltip.h> #include <qpushbutton.h> #include <qlayout.h> #include <qframe.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qapplication.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include <kiconloader.h> #include "libkdepim/kdatepicker.h" #include <knotifyclient.h> #include "kdatetbl.h" #include "koglobals.h" #include <kglobalsettings.h> #include "koprefs.h" #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include <kcalendarsystem.h> #include "navigatorbar.h" NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) : QWidget( parent, name ) { QBoxLayout *topLayout = new QHBoxLayout( this ); // Set up the control buttons and date label mCtrlFrame = new QFrame( this ); mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); mCtrlFrame->setLineWidth(1); topLayout->addWidget( mCtrlFrame ); bool isRTL = KOGlobals::self()->reverseLayout(); #ifndef DESKTOP_VERSION bool isDesktop = false; #else bool isDesktop = true; #endif if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) isDesktop = true; // Create backward navigation buttons mPrevYear = new QPushButton( mCtrlFrame ); mPrevYear->setPixmap( SmallIcon( isDesktop ? "3leftarrowB" : "3leftarrow" ) ); QToolTip::add( mPrevYear, i18n("Previous Year") ); mPrevMonth = new QPushButton( mCtrlFrame ); mPrevMonth->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow") ); QToolTip::add( mPrevMonth, i18n("Previous Month") ); // Create forward navigation buttons mNextMonth = new QPushButton( mCtrlFrame ); mNextMonth->setPixmap( SmallIcon( isDesktop ? "2rightarrowB" : "2rightarrow") ); QToolTip::add( mNextMonth, i18n("Next Month") ); mPrevWeek = new QPushButton( mCtrlFrame ); mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); QToolTip::add( mPrevWeek, i18n("Previous Week") ); // Create forward navigation buttons mNextWeek = new QPushButton( mCtrlFrame ); mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); QToolTip::add( mNextWeek, i18n("Next Week") ); mNextYear = new QPushButton( mCtrlFrame ); mNextYear->setPixmap( SmallIcon( isDesktop ? "3rightarrowB": "3rightarrow") ); QToolTip::add( mNextYear, i18n("Next Year") ); mSelectMonth = new QPushButton( mCtrlFrame ); // Create month name label //selectMonth->setFont( tfont ); // selectMonth->setAlignment( AlignCenter ); //mDateLabel = new QLabel( selectMonth ); //mDateLabel->setFont( tfont ); //mDateLabel->setAlignment( AlignCenter ); if ( QString ( name ) == QString("useBigPixmaps") ) { mNextMonth->setFlat( true); mNextWeek->setFlat( true); mNextYear->setFlat( true); mSelectMonth->setFlat( true); mPrevYear->setFlat( true); mPrevMonth->setFlat( true); mPrevWeek->setFlat( true); mPrevYear->setAutoRepeat( true ); mPrevMonth->setAutoRepeat( true ); mNextMonth->setAutoRepeat( true ); mPrevWeek->setAutoRepeat( true ); mNextWeek->setAutoRepeat( true ); mNextYear->setAutoRepeat( true ); } else { mPrevWeek->hide(); mNextWeek->hide(); } resetFont( font() ); // set up control frame layout QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); ctrlLayout->addWidget( mPrevYear, 3 ); ctrlLayout->addWidget( mPrevMonth, 3 ); ctrlLayout->addWidget( mPrevWeek, 3 ); //ctrlLayout->addStretch( 1 ); // ctrlLayout->addSpacing( 1 ); // ctrlLayout->addWidget( mDateLabel ); ctrlLayout->addWidget( mSelectMonth ); // ctrlLayout->addSpacing( 1 ); // ctrlLayout->addStretch( 1 ); ctrlLayout->addWidget( mNextWeek, 3 ); ctrlLayout->addWidget( mNextMonth, 3 ); ctrlLayout->addWidget( mNextYear, 3 ); connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); mPrevYear->setFocusPolicy(NoFocus); mPrevMonth->setFocusPolicy(NoFocus); mNextMonth->setFocusPolicy(NoFocus); mPrevWeek->setFocusPolicy(NoFocus); mNextWeek->setFocusPolicy(NoFocus); mNextYear->setFocusPolicy(NoFocus); mSelectMonth->setFocusPolicy(NoFocus); setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); } NavigatorBar::~NavigatorBar() { } QSize NavigatorBar::sizeHint() const { int wid = mCurrentMinWid ; if ( mPrevYear->isVisible() ) wid += mCurrentButtonMinWid; if ( mPrevMonth->isVisible() ) wid += mCurrentButtonMinWid; if ( mPrevWeek->isVisible() ) wid += mCurrentButtonMinWid; if ( mNextMonth->isVisible() ) wid += mCurrentButtonMinWid; if ( mNextWeek->isVisible() ) wid += mCurrentButtonMinWid; if ( mNextYear->isVisible() ) wid += mCurrentButtonMinWid; //qDebug("ret %d %d ", wid, mCurrentHei); return QSize ( wid, mCurrentHei ); } QSize NavigatorBar::sizeHintTwoButtons( int butNum ) const { return QSize ( mCurrentMinWid + butNum * mCurrentButtonMinWid , mCurrentHei ); } void NavigatorBar::resetFont ( QFont fo ) { QFont tfont = fo; if ( QApplication::desktop()->width() >= 480 ) tfont.setPointSize(tfont.pointSize()+2); tfont.setBold(true); mSelectMonth->setFont( tfont ); // Set minimum width to width of widest month name label int i; int maxwidth = 0; QFontMetrics fm ( mSelectMonth->font() ); int width = fm.width("September '00" ); maxwidth = width+2; int size = fm.height()+2; if ( QApplication::desktop()->width() >= 480 ) { size += 6; maxwidth+= 6; } mSelectMonth->setMinimumWidth( maxwidth ); mSelectMonth->setFixedHeight( size ); mPrevYear->setFixedHeight( size ); mPrevMonth->setFixedHeight( size ); mPrevWeek->setFixedHeight( size ); mNextMonth->setFixedHeight( size ); mNextWeek->setFixedHeight( size ); mNextYear->setFixedHeight ( size ); mCurrentHei = size +2; mCurrentMinWid = maxwidth+2; - mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2; + mCurrentButtonMinWid = mPrevYear->sizeHint().width(); } void NavigatorBar::showButtons( bool left, bool right ) { if ( left ) { mPrevYear->show(); mPrevMonth->show(); } else { mPrevYear->hide(); mPrevMonth->hide(); } if ( right ) { mNextYear->show(); mNextMonth->show(); } else { mNextYear->hide(); mNextMonth->hide(); } if ( !left && !right ) { //mSelectMonth->setMaximumWidth( 1024 ); mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); } } void NavigatorBar::selectMonth() { int month; KPopupFrame* popup = new KPopupFrame(this); KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); // ----- picker->resize(picker->sizeHint()); popup->setMainWidget(picker); picker->setFocus(); connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) { month = picker->getResult(); emit monthSelected ( month ); } else { KNotifyClient::beep(); } delete popup; } void NavigatorBar::selectDates( const KCal::DateList &dateList ) { if (dateList.count() > 0) { QDate date = dateList.first(); const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); // compute the label at the top of the navigator QString dtstr = i18n(calSys->monthName( date )) + " '" + QString::number( calSys->year( date ) ).right(2); mSelectMonth->setText( dtstr ); } } |