summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp95
-rw-r--r--korganizer/komonthview.h8
-rw-r--r--korganizer/koprefs.cpp1
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--korganizer/koprefsdialog.cpp4
-rw-r--r--korganizer/koviewmanager.cpp7
6 files changed, 105 insertions, 11 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index b175f9a..2b7e41f 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -397,30 +397,40 @@ void MonthViewItem::paint(QPainter *p)
x += size + 3;
}
}
QFontMetrics fm = p->fontMetrics();
int yPos;
int pmheight = size;
if( pmheight < fm.height() )
yPos = fm.ascent() + fm.leading()/2;
else
yPos = pmheight/2 - fm.height()/2 + fm.ascent();
p->setPen( palette().color( QPalette::Normal, sel ? \
QColorGroup::HighlightedText : QColorGroup::Foreground ) );
- p->drawText( x, yPos, text() );
- if ( mIncidence->cancelled() ) {
- int wid = fm.width( text() );
- p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
- }
-
+ if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
+ p->drawText( x, yPos, text() );
+ if ( mIncidence->cancelled() ) {
+ int wid = fm.width( text() );
+ p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
+ }
+ } else {
+ QString pText = text();
+ if( pText.mid(2,1) == ":" )
+ pText = pText.mid( 6 );
+ p->drawText( x, yPos, pText );
+ if ( mIncidence->cancelled() ) {
+ int wid = fm.width( pText );
+ p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
+ }
+ }
}
int MonthViewItem::height(const QListBox *lb) const
{
int ret = 10;
if ( lb )
ret = lb->fontMetrics().lineSpacing()+1;
return ret;
}
int MonthViewItem::width(const QListBox *lb) const
{
@@ -1033,37 +1043,41 @@ void MonthViewCell::defaultAction( QListBoxItem *item )
}
void MonthViewCell::showDay()
{
emit showDaySignal( date() );
}
void MonthViewCell::newEvent()
{
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
}
void MonthViewCell::cellClicked( QListBoxItem *item )
{
+ mMonthView->setSelectedCell( this );
qDebug("CELL ");
if ( item == 0 ) {
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
return;
}
}
void MonthViewCell::contextMenu( QListBoxItem *item )
{
- if ( !item ) return;
-
+ mMonthView->setPopupCell( this );
+ if ( !item ) {
+ mMonthView->showContextMenu( 0 );
+ return;
+ }
MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
Incidence *incidence = eventItem->incidence();
if ( incidence ) mMonthView->showContextMenu( incidence );
}
void MonthViewCell::selection( QListBoxItem *item )
{
if ( !item ) return;
mMonthView->setSelectedCell( this );
}
@@ -1074,24 +1088,25 @@ void MonthViewCell::selection( QListBoxItem *item )
KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
: KOEventView( calendar, parent, name ),
mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
{
mFlagKeyPressed = false;
mShortDayLabelsM = false;
mShortDayLabelsW = false;
skipResize = false;
clPending = true;
+ mPopupCell = 0;
mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
mWidStack = new QWidgetStack( this );
QVBoxLayout* hb = new QVBoxLayout( this );
mMonthView = new QWidget( mWidStack );
mWeekView = new QWidget( mWidStack );
#if QT_VERSION >= 0x030000
mWidStack->addWidget(mMonthView );
mWidStack->addWidget(mWeekView );
#else
mWidStack->addWidget( mMonthView, 1 );
mWidStack->addWidget( mWeekView , 1 );
#endif
@@ -1191,24 +1206,47 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
SIGNAL( newEventSignal( QDateTime ) ) );
connect( cell, SIGNAL( showDaySignal( QDate ) ),
SIGNAL( showDaySignal( QDate ) ) );
connect( cell, SIGNAL( nextCell() ),
SLOT( nextCell() ) );
connect( cell, SIGNAL( prevCell() ),
SLOT( prevCell() ) );
cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
}
//connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
mContextMenu = eventPopup();
+ mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
+ i18n("New Event..."),this,
+ SLOT(slotNewEvent()),false);
+ mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
+ i18n("New Todo..."),this,
+ SLOT(slotNewTodo()),false);
+ mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
+ i18n("Journal"),this,
+ SLOT(slotEditJournal()),false);
+
+
+
+ QString pathString = "";
+ if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
+ if ( QApplication::desktop()->width() < 480 )
+ pathString += "icons16/";
+ } else
+ pathString += "iconsmini/";
+ mNewItemMenu = new QPopupMenu( this );
+ mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
+ mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
+ mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
+
// updateConfig(); //useless here...
// ... but we need mWidthLongDayLabel computed
QFontMetrics fontmetric(mDayLabels[0]->font());
mWidthLongDayLabel = 0;
for (int i = 0; i < 7; i++) {
int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
}
//mWeekLabels[mNumWeeks]->setText( i18n("W"));
#if 0
@@ -1884,41 +1922,46 @@ void KOMonthView::computeLayout()
mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
// qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
//qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
updateDayLabels();
//bool forceUpdate = !updatePossible;
updatePossible = true;
//mWeekLabels[mNumWeeks]->setText( i18n("W"));
}
void KOMonthView::showContextMenu( Incidence *incidence )
{
- mContextMenu->showIncidencePopup(incidence);
+ if( incidence )
+ mContextMenu->showIncidencePopup(incidence);
+ else {
+ //qDebug("KOMonthView::showContextMenu ");
+ mNewItemMenu->popup(QCursor::pos());
+ }
/*
if( incidence && incidence->type() == "Event" ) {
Event *event = static_cast<Event *>(incidence);
mContextMenu->showEventPopup(event);
} else {
kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
}
*/
}
MonthViewCell * KOMonthView::selectedCell( )
{
return mSelectedCell;
}
void KOMonthView::setSelectedCell( MonthViewCell *cell )
{
- //qDebug("KOMonthView::setSelectedCell ");
+ //qDebug("KOMonthView::setSelectedCell %d", cell);
if ( mSelectedCell && mSelectedCell != cell ) {
MonthViewCell * mvc = mSelectedCell;
mSelectedCell = cell;
mvc->deselect();
} else
mSelectedCell = cell;
// if ( mSelectedCell )
// mSelectedCell->select();
if ( !mSelectedCell )
emit incidenceSelected( 0 );
else
emit incidenceSelected( mSelectedCell->selectedIncidence() );
@@ -2005,12 +2048,44 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e )
break;
}
}
void KOMonthView::nextCell()
{
bool res = focusNextPrevChild ( true );
}
void KOMonthView::prevCell()
{
focusNextPrevChild ( false );
}
+
+void KOMonthView::slotNewTodo()
+{
+ //qDebug("KOMonthView::slotNewTodo() ");
+ if ( mPopupCell ){
+ QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
+ emit newTodoSignal(dt,true);
+ }
+ mPopupCell = 0;
+}
+void KOMonthView::slotNewEvent()
+{
+ if ( mPopupCell ) {
+ QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
+ emit newEventSignal( dt );
+ }
+ //qDebug("KOMonthView::slotNewEvent() ");
+ mPopupCell = 0;
+}
+
+void KOMonthView::slotEditJournal()
+{
+ if ( mPopupCell )
+ emit showJournalSignal( 7, mPopupCell->date() );
+ //qDebug("KOMonthView::slotEditJournal() ");
+ mPopupCell = 0;
+}
+
+void KOMonthView::setPopupCell( MonthViewCell * c)
+{
+ mPopupCell = c;
+}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index c6b6b5e..de5c014 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -262,38 +262,44 @@ class KOMonthView: public KOEventView
virtual void updateView();
virtual void updateConfig();
virtual void showDates(const QDate &start, const QDate &end);
virtual void showEvents(QPtrList<Event> eventList);
void changeEventDisplay(Event *, int);
void clearSelection();
void showContextMenu( Incidence * );
void setSelectedCell( MonthViewCell * );
+ void setPopupCell( MonthViewCell * );
void switchView();
void setKeyBoardFocus();
void setKeyBFocus();
protected slots:
+ void slotNewTodo();
+ void slotNewEvent();
+ void slotEditJournal();
void slotComputeLayout();
void selectInternalWeekNum ( int );
void processSelectionChange();
signals:
void nextMonth();
void prevMonth();
void selectWeekNum ( int );
void selectMonth ();
void showDaySignal( QDate );
+ void newTodoSignal( QDateTime, bool );
+ void showJournalSignal( int,QDate );
protected:
void resizeEvent(QResizeEvent *);
void viewChanged();
void updateDayLabels();
private:
QTimer* mComputeLayoutTimer;
NavigatorBar* mNavigatorBar;
int currentWeek();
bool clPending;
QWidgetStack * mWidStack;
QWidget* mMonthView;
@@ -313,20 +319,22 @@ class KOMonthView: public KOEventView
QPtrVector<KOWeekButton> mWeekLabels;
QPtrVector<MonthViewCell> mCellsW;
QPtrVector<QLabel> mDayLabelsW;
QPtrVector<KOWeekButton> mWeekLabelsW;
bool mShortDayLabelsM;
bool mShortDayLabelsW;
int mWidthLongDayLabel;
QDate mStartDate;
MonthViewCell *mSelectedCell;
+ MonthViewCell *mPopupCell;
bool mFlagKeyPressed;
KOEventPopupMenu *mContextMenu;
+ QPopupMenu *mNewItemMenu;
void keyPressEvent ( QKeyEvent * ) ;
void keyReleaseEvent ( QKeyEvent * ) ;
};
#endif
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index a571ed4..34044ab 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -228,24 +228,25 @@ KOPrefs::KOPrefs() :
KPrefs::setCurrentGroup("Views");
addItemBool("Block Popup Menu",&mBlockPopupMenu,true);
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);
+ addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,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);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 2a0ee64..e06df1c 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -150,24 +150,25 @@ class KOPrefs : public KPimPrefs
QColor mAppColor2;
bool mUseAppColors;
int mDayBegins;
int mHourSize;
int mAllDaySize;
bool mShowFullMenu;
bool mDailyRecur;
bool mWeeklyRecur;
bool mMonthDailyRecur;
bool mMonthWeeklyRecur;
bool mMonthShowIcons;
+ bool mMonthShowTimes;
bool mMonthShowShort;
bool mEnableToolTips;
bool mEnableMonthScroll;
bool mFullViewMonth;
bool mMonthViewUsesCategoryColor;
bool mFullViewTodo;
bool mShowCompletedTodo;
bool mMarcusBainsEnabled;
int mNextXDays;
int mWhatsNextDays;
int mWhatsNextPrios;
bool mEnableQuickTodo;
diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp
index ad3c61c..cb9c272 100644
--- a/korganizer/koprefsdialog.cpp
+++ b/korganizer/koprefsdialog.cpp
@@ -755,25 +755,27 @@ void KOPrefsDialog::setupViewsTab()
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);
-
+ weeklyRecur =
+ addWidBool(i18n("times"),
+ &(KOPrefs::instance()->mMonthShowTimes),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);
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 406e741..f1f2dd2 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -590,24 +590,31 @@ void KOViewManager::showNextXView()
bool KOViewManager::showsNextDays()
{
return mFlagShowNextxDays;
}
void KOViewManager::createMonthView()
{
if (!mMonthView) {
mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
addView(mMonthView);
// mMonthView->show();
// SIGNALS/SLOTS FOR MONTH VIEW
+
+ connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate )));
+
+ connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)),
+ mMainView, SLOT(newTodoDateTime(QDateTime, bool)));
+
+
connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
mMainView, SLOT(newEvent(QDateTime)));
connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
mMainView, SLOT(showIncidence(Incidence *)));
connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
mMainView, SLOT(editIncidence(Incidence *)));
connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
mMainView, SLOT(deleteIncidence(Incidence *)));
connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
mMainView, SLOT( processMainViewSelection( Incidence * ) ) );