summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp45
-rw-r--r--korganizer/koagendaview.h33
2 files changed, 50 insertions, 28 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index d3db89a..c8cef44 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -73,12 +73,14 @@ 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)
{
mRows = rows;
setMinimumHeight( 20 );
@@ -606,40 +608,35 @@ void KOAgendaView::resizeEvent( QResizeEvent* e )
//qDebug("KOAgendaView::Updating now possible ");
} else
createDayLabels();
//qDebug("resizeEvent end ");
}
-void KOAgendaView::slotDaylabelClicked()
+void KOAgendaView::slotDaylabelClicked( int num )
{
- QString cap = ((QPushButton*) sender() )->caption();
-
+
QDate firstDate = mSelectedDates.first();
- if ( cap == "0" )
+ if ( num == -1 )
emit showDateView( 6, firstDate );
- else if ( cap != "last" ) {
+ else if (num >= 0 ) {
if ( mSelectedDates.count() == 1)
- emit showDateView( 9, firstDate.addDays( cap.toInt()-1 ) );
+ emit showDateView( 9, firstDate.addDays( num ) );
else
- emit showDateView( 3, firstDate.addDays( cap.toInt()-1 ) );
+ emit showDateView( 3, firstDate.addDays( num ) );
}
else
showDateView( 10, firstDate.addDays(1) );
}
-QPushButton* KOAgendaView::getNewDaylabel()
+KOAgendaButton* KOAgendaView::getNewDaylabel()
{
- QPushButton * dayLabel = new QPushButton(mDayLabels);
- dayLabel->setFlat( true );
- connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) );
- dayLabel->setFocusPolicy(NoFocus);
- dayLabel->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
+ KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
+ connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
mDayLabelsList.append( dayLabel );
mLayoutDayLabels->addWidget(dayLabel);
- //mLayoutDayLabels->setStretchFactor(dayLabel, 100);
return dayLabel ;
}
void KOAgendaView::createDayLabels()
{
@@ -659,37 +656,37 @@ void KOAgendaView::createDayLabels()
if ( maxWid < 0 )
maxWid = 20;
QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
QFontMetrics fm ( dlf );
int selCount = mSelectedDates.count();
- QString dayTest = "Won 20";
+ QString dayTest = "Mon 20";
//QString dayTest = "Mon 20";
int wid = fm.width( dayTest );
//maxWid -= ( selCount * 3 ); //working for QLabels
- maxWid -= ( selCount * 5 ); //working for QPushButton
+ 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 )+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" )+3;
+ wid = f.width( "30" );
needWid = wid * selCount;
if ( needWid < maxWid )
break;
}
maxLen = 2;
}
@@ -700,27 +697,27 @@ void KOAgendaView::createDayLabels()
mDayLabels->setFont( dlf );
// mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
// mLayoutDayLabels->addSpacing(mTimeLabels->width());
//mLayoutDayLabels->addSpacing( 2 );
// QFont lFont = dlf;
bool appendLabels = false;
- QPushButton *dayLabel;
+ KOAgendaButton *dayLabel;
dayLabel = mDayLabelsList.first();
if ( !dayLabel ) {
appendLabels = true;
dayLabel = getNewDaylabel();
}
dayLabel->setFixedWidth( mTimeLabels->width()+2 );
dayLabel->setFont( dlf );
- dayLabel->setCaption("0");
+ 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 = 0;
+ 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();
@@ -728,16 +725,16 @@ void KOAgendaView::createDayLabels()
appendLabels = true;
}
if ( appendLabels ) {
dayLabel = getNewDaylabel();
}
dayLabel->setMinimumWidth( 1 );
- dayLabel->setMaximumWidth( 2048 );
+ dayLabel->setMaximumWidth( 1024 );
dayLabel->setFont( dlf );
dayLabel->show();
- dayLabel->setCaption(QString::number( counter ));
+ 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() );
@@ -821,13 +818,13 @@ void KOAgendaView::createDayLabels()
int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % 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->show();
- dayLabel->setCaption("last");
+ 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 ) {
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index cbe86b6..e9e85cc 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -22,32 +22,57 @@
*/
#ifndef KOAGENDAVIEW_H
#define KOAGENDAVIEW_H
#include <qscrollview.h>
#include <qdatetime.h>
+#include <qpushbutton.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 KOAgendaButton : public QPushButton
+{
+ Q_OBJECT
+ public:
+ KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
+ QPushButton( parent, name )
+ {
+ mNum = -3;
+ setFlat( true );
+ setFocusPolicy(NoFocus);
+ setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
+ connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
+ };
+
+ QSize sizeHint () const { return QSize( 5,5) ;}
+ void setNum( int n) { mNum = n; }
+private slots:
+ void bClicked() {emit numClicked( mNum);}
+signals:
+ void numClicked( int );
+private:
+ int mNum;
+};
+
class TimeLabels : public QScrollView {
Q_OBJECT
public:
TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
void setCellHeight(int height);
@@ -187,13 +212,13 @@ class KOAgendaView : public KOEventView {
void toggleExpand();
void todoMoved( Todo *, int );
void incidenceChanged(Incidence * , int );
// void cloneIncidenceSignal(Incidence *);
protected:
- QPushButton* getNewDaylabel();
+ KOAgendaButton* getNewDaylabel();
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 */
@@ -205,13 +230,13 @@ class KOAgendaView : public KOEventView {
/**
Set the masks on the agenda widgets indicating, which days are holidays.
*/
void setHolidayMasks();
protected slots:
- void slotDaylabelClicked();
+ void slotDaylabelClicked( int );
/** Update event belonging to agenda item */
void updateEventDates(KOAgendaItem *item, int mode = -1);
//void updateMovedTodo();
void updateEventIndicatorTop(int newY);
void updateEventIndicatorBottom(int newY);
@@ -251,13 +276,13 @@ class KOAgendaView : public KOEventView {
QMemArray<int> mMaxY;
QMemArray<bool> mHolidayMask;
QPixmap mExpandedPixmap;
QPixmap mNotExpandedPixmap;
- QPtrList<QPushButton> mDayLabelsList;
+ QPtrList<KOAgendaButton> mDayLabelsList;
QDateTime mTimeSpanBegin;
QDateTime mTimeSpanEnd;
bool mTimeSpanInAllDay;
void keyPressEvent ( QKeyEvent * e );
};