summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 6428757..b5596d9 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -157,96 +157,131 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
}
}
/**
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();
+}
+
+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 )
+{
+ 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;
@@ -365,96 +400,98 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
mAllDayFrame = new QHBox(mSplitterAgenda);
mAllDayFrame->setFocusPolicy(NoFocus);
QWidget *agendaFrame = new QWidget(mSplitterAgenda);
agendaFrame->setFocusPolicy(NoFocus);
#endif
// Create all-day agenda widget
mDummyAllDayLeft = new QVBox( mAllDayFrame );
mExpandButton = new QPushButton(mDummyAllDayLeft);
mExpandButton->setPixmap( mNotExpandedPixmap );
int widebut = mExpandButton->sizeHint().width();
if ( QApplication::desktop()->width() < 480 )
widebut = widebut*2;
else
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);
QWidget *dummyAllDayRight = new QWidget(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,3,3);
// QHBox *agendaFrame = new QHBox(splitterAgenda);
// create event indicator bars
mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
agendaLayout->addWidget(mEventIndicatorTop,0,1);
mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
agendaFrame);
agendaLayout->addWidget(mEventIndicatorBottom,2,1);
QWidget *dummyAgendaRight = new QWidget(agendaFrame);
agendaLayout->addWidget(dummyAgendaRight,0,2);
// Create time labels
mTimeLabels = new TimeLabels(24,agendaFrame);
agendaLayout->addWidget(mTimeLabels,1,0);
+ connect(mTimeLabels,SIGNAL( scaleChanged()),
+ this,SLOT(updateConfig()));
// Create agenda
mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
agendaLayout->addMultiCellWidget(mAgenda,1,1,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)));
// Create/Show/Edit/Delete Event
connect(mAgenda,SIGNAL(newEventSignal(int,int)),
SLOT(newEvent(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(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)),