author | zautrix <zautrix> | 2005-01-26 23:12:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-26 23:12:59 (UTC) |
commit | f20b5e71f9ae61b18f0ced792508b40432ad50b6 (patch) (side-by-side diff) | |
tree | 3dde48c6dcecf2e5c19d3e7a62aba57c385e92df | |
parent | 15351333eff09beadb6e691e9f0aab2aaf0a95a0 (diff) | |
download | kdepimpi-f20b5e71f9ae61b18f0ced792508b40432ad50b6.zip kdepimpi-f20b5e71f9ae61b18f0ced792508b40432ad50b6.tar.gz kdepimpi-f20b5e71f9ae61b18f0ced792508b40432ad50b6.tar.bz2 |
fixes
-rw-r--r-- | korganizer/koagendaview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index b5596d9..05216a7 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -80,274 +80,276 @@ TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : QScrollView(parent,name,f) { mRows = rows; 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 cx = contentsX() + 2; cw = contentsWidth() - 2; // end of workaround int cell = ((int)(cy/mCellHeight)); int y = cell * mCellHeight; QFontMetrics fm = fontMetrics(); QString hour; QString suffix; QString fullTime; int tW = fm.width("24:00i"); while (y < cy + ch) { p->drawLine(cx,y,cx+tW,y); hour.setNum(cell); suffix = "am"; // handle 24h and am/pm time formats if (KGlobal::locale()->use12Clock()) { if (cell > 11) suffix = "pm"; if (cell == 0) hour.setNum(12); if (cell > 12) hour.setNum(cell - 12); } else { suffix = ":00"; } // create string in format of "XX:XX" or "XXpm/am" fullTime = hour + suffix; // center and draw the time label int timeWidth = fm.width(fullTime+"i"); int offset = this->width() - timeWidth; int borderWidth = 5; int timeHeight = fm.height(); timeHeight = timeHeight + 2 - ( timeHeight / 4 ); p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); // increment indices y += mCellHeight; cell++; } } /** Calculates the minimum width. */ int TimeLabels::minimumWidth() const { QFontMetrics fm = fontMetrics(); //TODO: calculate this value int borderWidth = 4; // the maximum width possible int width = fm.width("88:88x") + borderWidth; return width; } /** updates widget's internal state */ void TimeLabels::updateConfig() { // set the font // config->setGroup("Fonts"); // QFont font = config->readFontEntry("TimeBar Font"); setFont(KOPrefs::instance()->mTimeBarFont); // 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 > 18 ) tSize = 18; 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 > 18 ) tSize = 18; 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); if (mLocation == Top) setMaximumHeight(0); else 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/2 -mPixmap.width()/2 : i*cellWidth + cellWidth/2 -mPixmap.width()/2; p->drawPixmap(QPoint(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; } 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; diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index 221b0ea..3cf938f 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -1,207 +1,208 @@ /* 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 KOAGENDAVIEW_H #define KOAGENDAVIEW_H #include <qscrollview.h> #include <qdatetime.h> #include <qlayout.h> #ifndef DESKTOP_VERSION #include <qksplitter.h> #else #include <qsplitter.h> #endif #include <qmemarray.h> #include "koeventview.h" class QHBox; class QFrame; class QLabel; class QPushButton; class CalendarView; class KOAgenda; class KOAgendaItem; class KConfig; class KDGanttMinimizeSplitter; class TimeLabels : public QScrollView { Q_OBJECT public: TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); void setCellHeight(int height); /** Calculates the minimum width */ virtual int minimumWidth() const; /** updates widget's internal state */ void updateConfig(); /** */ void setAgenda(KOAgenda* agenda); /** */ virtual void paintEvent(QPaintEvent* e); void contentsMousePressEvent ( QMouseEvent * ) ; void contentsMouseReleaseEvent ( QMouseEvent * ); void contentsMouseMoveEvent ( QMouseEvent * ); public slots: /** update time label positions */ void positionChanged(); signals: void scaleChanged(); protected: void drawContents(QPainter *p,int cx, int cy, int cw, int ch); private: int mMouseDownY; + QString mOrgCap; int mRows; int mCellHeight; /** */ KOAgenda* mAgenda; }; class EventIndicator : public QFrame { Q_OBJECT public: enum Location { Top, Bottom }; EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); virtual ~EventIndicator(); void changeColumns(int columns); void setPaintWidget( KDGanttMinimizeSplitter* ); void setXOffset( int ); void enableColumn(int column, bool enable); protected: void drawContents(QPainter *); private: int mXOffset; KDGanttMinimizeSplitter* mPaintWidget; int mColumns; QHBox *mTopBox; QBoxLayout *mTopLayout; Location mLocation; QPixmap mPixmap; QMemArray<bool> mEnabled; }; /** KOAgendaView is the agenda-like view used to display events in an one or multi-day view. */ class KOAgendaView : public KOEventView { Q_OBJECT public: KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); virtual ~KOAgendaView(); void setStartHour( int ); void toggleAllDay(); /** Returns maximum number of days supported by the koagendaview */ virtual int maxDatesHint(); /** Returns number of currently shown dates. */ virtual int currentDateCount(); /** returns the currently selected events */ virtual QPtrList<Incidence> selectedIncidences(); /** returns the currently selected events */ virtual DateList selectedDates(); /** Remove all events from view */ void clearView(); KOAgenda *agenda() { return mAgenda;} virtual void printPreview(CalPrinter *calPrinter, const QDate &, const QDate &); /** start-datetime of selection */ QDateTime selectionStart() {return mTimeSpanBegin;} /** end-datetime of selection */ QDateTime selectionEnd() {return mTimeSpanEnd;} /** returns true if selection is for whole day */ bool selectedIsAllDay() {return mTimeSpanInAllDay;} /** make selected start/end invalid */ void deleteSelectedDateTime(); void repaintAgenda(); public slots: virtual void updateView(); virtual void updateConfig(); virtual void showDates(const QDate &start, const QDate &end); virtual void showEvents(QPtrList<Event> eventList); void updateTodo( Todo *, int ); void changeEventDisplay(Event *, int); void clearSelection(); void newEvent(int gx,int gy); void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); void newEventAllDay(int gx, int gy); void startDrag(Event *); void readSettings(); void readSettings(KConfig *); void writeSettings(KConfig *); void setContentsPos(int y); void setExpandedButton( bool expanded ); void scrollOneHourUp(); void scrollOneHourDown(); void addToCalSlot(Incidence *, Incidence *); signals: void toggleExpand(); void todoMoved( Todo *, int ); void incidenceChanged(Incidence * , int ); // void cloneIncidenceSignal(Incidence *); protected: bool mBlockUpdating; int mUpcomingWidth; /** Fill agenda beginning with date startDate */ void fillAgenda(const QDate &startDate); void resizeEvent( QResizeEvent* e ); /** Fill agenda using the current set value for the start date */ void fillAgenda(); /** Create labels for the selected dates. */ void createDayLabels(); /** Set the masks on the agenda widgets indicating, which days are holidays. */ void setHolidayMasks(); protected slots: /** Update event belonging to agenda item */ void updateEventDates(KOAgendaItem *item, int mode = -1); //void updateMovedTodo(); |