summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-02 12:16:34 (UTC)
committer zautrix <zautrix>2005-04-02 12:16:34 (UTC)
commit997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe (patch) (side-by-side diff)
treef788b37459574b5cea0d2ab874882c6a396c240d /korganizer
parente0d51120d2f0c178115746e0c1357af40f95bc77 (diff)
downloadkdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.zip
kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.gz
kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.bz2
more fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp57
-rw-r--r--korganizer/koagenda.h4
-rw-r--r--korganizer/koagendaview.cpp18
-rw-r--r--korganizer/koagendaview.h4
-rw-r--r--korganizer/kotodoview.cpp49
5 files changed, 97 insertions, 35 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index deadfc9..de964da 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -159,43 +159,44 @@ void MarcusBains::updateLocation(bool recalculate)
////////////////////////////////////////////////////////////////////////////
/*
Create an agenda widget with rows rows and columns columns.
*/
KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
const char *name,WFlags f) :
QScrollView(parent,name,f)
{
-
+ mAllAgendaPopup = 0;
mColumns = columns;
mRows = rows;
mGridSpacingY = rowSize;
mAllDayMode = false;
#ifndef DESKTOP_VERSION
//QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
#endif
mHolidayMask = 0;
init();
}
/*
Create an agenda widget with columns columns and one row. This is used for
all-day events.
*/
KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
QScrollView(parent,name,f)
{
+ mAllAgendaPopup = 0;
blockResize = false;
mColumns = columns;
mRows = 1;
//qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
mGridSpacingY = KOPrefs::instance()->mAllDaySize;
mAllDayMode = true;
#ifndef DESKTOP_VERSION
//QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
#endif
mHolidayMask = 0;
init();
}
@@ -223,25 +224,25 @@ void KOAgenda::init()
{
mPopupTimer = new QTimer(this);
connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
mNewItemPopup = new QPopupMenu( this );
connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
QString pathString = "";
if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
if ( QApplication::desktop()->width() < 480 )
pathString += "icons16/";
} else
pathString += "iconsmini/";
-
+
mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
mNewItemPopup->insertSeparator ( );
mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
#ifndef _WIN32_
int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
viewport()->setWFlags ( wflags);
@@ -378,61 +379,100 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
}
}
void KOAgenda::popupMenu()
{
mPopupTimer->stop();
if ( mPopupKind == 1 ) {
if (mActionItem ) {
endItemAction();
}
mLeftMouseDown = false; // no more leftMouse computation
if (mPopupItem) {
selectItem(mPopupItem);
+ if ( mAllAgendaPopup )
+ mAllAgendaPopup->installEventFilter( this );
emit showIncidencePopupSignal(mPopupItem->incidence());
}
} else if ( mPopupKind == 2 ) {
if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
endSelectAction( false ); // do not emit new event signal
mLeftMouseDown = false; // no more leftMouse computation
}
+ mNewItemPopup->installEventFilter( this );
mNewItemPopup->popup( mPopupPos);
+
}
mLeftMouseDown = false;
mPopupItem = 0;
mPopupKind = 0;
}
bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
{
- //qDebug("KOAgenda::eventFilter_mous ");
+ static int startX = 0;
+ static int startY = 0;
+ static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
+ static bool blockMoving = true;
+
+ //qDebug("KOAgenda::eventFilter_mous ");
+ if ( object == mNewItemPopup ) {
+ //qDebug("mNewItemPopup ");
+ if ( me->type() == QEvent::MouseButtonRelease ) {
+ mNewItemPopup->removeEventFilter( this );
+ int dX = me->globalPos().x() - mPopupPos.x();;
+ if ( dX < 0 )
+ dX = -dX;
+ int dY = me->globalPos().y() - mPopupPos.y();
+ if ( dY < 0 )
+ dY = -dY;
+ if ( dX > blockmoveDist || dY > blockmoveDist ) {
+ mNewItemPopup->hide();
+ }
+ }
+ return true;
+ }
+ if ( object == mAllAgendaPopup ) {
+ //qDebug(" mAllAgendaPopup ");
+ if ( me->type() == QEvent::MouseButtonRelease ) {
+ mAllAgendaPopup->removeEventFilter( this );
+ int dX = me->globalPos().x() - mPopupPos.x();;
+ if ( dX < 0 )
+ dX = -dX;
+ int dY = me->globalPos().y() - mPopupPos.y();
+ if ( dY < 0 )
+ dY = -dY;
+ if ( dX > blockmoveDist || dY > blockmoveDist ) {
+ mAllAgendaPopup->hide();
+ }
+ }
+ return true;
+ }
QPoint viewportPos;
if (object != viewport()) {
viewportPos = ((QWidget *)object)->mapToParent(me->pos());
} else {
viewportPos = me->pos();
}
- static int startX = 0;
- static int startY = 0;
- static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
- static bool blockMoving = true;
+
switch (me->type()) {
case QEvent::MouseButtonPress:
if (me->button() == LeftButton) {
mPopupTimer->start( 600 );
mLeftMouseDown = true;
}
blockMoving = true;
startX = viewportPos.x();
- startY = viewportPos.y();
+ startY = viewportPos.y();
+ mPopupPos = me->globalPos();
if (object != viewport()) {
mPopupItem = (KOAgendaItem *)object;
mPopupKind = 1;
if (me->button() == RightButton) {
popupMenu();
} else if (me->button() == LeftButton) {
mActionItem = (KOAgendaItem *)object;
if (mActionItem) {
if ( mSelectionHeight > 0 ) {
int selectionCellX = mSelectionCellX * mGridSpacingX;
int selectionYTop = mSelectionYTop;
int gridSpacingX = mGridSpacingX;
@@ -446,25 +486,24 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
mActionItem = 0;
} else {
startItemAction(viewportPos);
}
}
}
} else { // ---------- viewport()
mPopupItem = 0;
mPopupKind = 2;
selectItem(0);
mActionItem = 0;
- mPopupPos = viewport()->mapToGlobal( me->pos() );
if (me->button() == RightButton) {
int x,y;
viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
int gx,gy;
contentsToGrid(x,y,gx,gy);
mCurrentCellX = gx;
mCurrentCellY = gy;
mStartCellX = gx;
mStartCellY = gy;
popupMenu();
} else if (me->button() == LeftButton) {
setCursor(arrowCursor);
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 35c08b6..4f1fdb9 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -22,24 +22,25 @@
*/
#ifndef KOAGENDA_H
#define KOAGENDA_H
#include <qscrollview.h>
#include <qtimer.h>
#include <qmemarray.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qguardedptr.h>
#include "koagendaitem.h"
+#include "koeventview.h"
class QPopupMenu;
class QTime;
class KConfig;
class QFrame;
class KOAgenda;
class KCal::Event;
class KCal::Todo;
using namespace KCal;
class MarcusBains : public QFrame {
@@ -114,25 +115,25 @@ class KOAgenda : public QScrollView
void updateConfig();
void checkScrollBoundaries();
void setHolidayMask(QMemArray<bool> *);
void setDateList(const DateList &selectedDates);
DateList dateList() const;
void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
void finishUpdate();
void printSelection();
void storePosition();
void restorePosition();
-
+ void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
public slots:
void popupMenu();
void newItem( int );
void moveChild( QWidget *, int, int );
void scrollUp();
void scrollDown();
void updateTodo( Todo * t, int , bool );
void popupAlarm();
void checkScrollBoundaries(int);
@@ -159,24 +160,25 @@ class KOAgenda : public QScrollView
void itemModified(KOAgendaItem *item, int );
void incidenceSelected(Incidence *);
void lowerYChanged(int);
void upperYChanged(int);
void startDragSignal(Incidence *);
void addToCalSignal(Incidence *, Incidence *);
void resizedSignal();
protected:
+ KOEventPopupMenu * mAllAgendaPopup;
QPainter mPixPainter;
QPixmap mPaintPixmap;
QPixmap mHighlightPixmap;
void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
virtual void resizeEvent ( QResizeEvent * );
/** Handles mouse events. Called from eventFilter */
virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
/** Start selecting time span. */
void startSelectAction(QPoint viewportPos);
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 8d32152..95388ef 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -496,27 +496,25 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
widebut = heibut ;
//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 *)));
+ //mAllDayAgendaPopup = eventPopup();
// 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);
@@ -535,34 +533,38 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
// 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();
+ mAllAgendaPopup = eventPopup();
- mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
+ mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
i18n("Toggle Alarm"),mAgenda,
SLOT(popupAlarm()),true);
connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
- mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
+ mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
+ connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
+ mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
+ mAgenda->setPopup( mAllAgendaPopup );
+ mAllDayAgenda->setPopup( mAllAgendaPopup );
// 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());
@@ -658,26 +660,26 @@ void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
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 mAllAgendaPopup;
+ //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 ) ) {
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 30c9b05..c6e6602 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -262,26 +262,26 @@ class KOAgendaView : public KOEventView {
TimeLabels *mTimeLabels;
QWidget *mDummyAllDayLeft;
KDGanttMinimizeSplitter* mSplitterAgenda;
QPushButton *mExpandButton;
DateList mSelectedDates; // List of dates to be displayed
int mViewType;
bool mWeekStartsMonday;
int mStartHour;
- KOEventPopupMenu *mAgendaPopup;
- KOEventPopupMenu *mAllDayAgendaPopup;
+ KOEventPopupMenu *mAllAgendaPopup;
+ //KOEventPopupMenu *mAllDayAgendaPopup;
EventIndicator *mEventIndicatorTop;
EventIndicator *mEventIndicatorBottom;
QMemArray<int> mMinY;
QMemArray<int> mMaxY;
QMemArray<bool> mHolidayMask;
QPtrList<KOAgendaButton> mDayLabelsList;
QDateTime mTimeSpanBegin;
QDateTime mTimeSpanEnd;
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index ccc4b01..0a315cb 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -198,43 +198,54 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e)
}
}
else {
qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
e->ignore();
}
}
#endif
}
void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
{
+
+ QPoint p(contentsToViewport(e->pos()));
+ QListViewItem *i = itemAt(p);
+ bool rootClicked = true;
+ if (i) {
+ // if the user clicked into the root decoration of the item, don't
+ // try to start a drag!
+ int X = p.x();
+ //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
+ if (X > header()->sectionPos(0) +
+ treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
+ itemMargin() ||
+ X < header()->sectionPos(0)) {
+ rootClicked = false;
+ }
+ }
#ifndef KORG_NODND
- QPoint p(contentsToViewport(e->pos()));
- QListViewItem *i = itemAt(p);
- mMousePressed = false;
- if (i) {
- // if the user clicked into the root decoration of the item, don't
- // try to start a drag!
- if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
- treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
- itemMargin() ||
- p.x() < header()->sectionPos(header()->mapToIndex(0))) {
- if (e->button()==Qt::LeftButton) {
+ mMousePressed = false;
+ if (! rootClicked ) {
mPressPos = e->pos();
mMousePressed = true;
- }
}
- }
#endif
- QListView::contentsMousePressEvent(e);
+ //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
+#ifndef DESKTOP_VERSION
+ if (!( e->button() == RightButton && rootClicked) )
+ QListView::contentsMousePressEvent(e);
+#else
+ QListView::contentsMousePressEvent(e);
+#endif
}
void KOTodoListView::paintEvent(QPaintEvent* e)
{
emit paintNeeded();
QListView::paintEvent( e);
}
void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
{
#ifndef KORG_NODND
//QListView::contentsMouseMoveEvent(e);
if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
@@ -1054,36 +1065,44 @@ void KOTodoView::changedCategories(int index)
mActiveItem->todo()->setCategories (categories);
mActiveItem->construct();
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
}
}
void KOTodoView::itemDoubleClicked(QListViewItem *item)
{
if ( pendingSubtodo != 0 ) {
topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
}
pendingSubtodo = 0;
+ int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
+ //qDebug("ROW %d ", row);
if (!item) {
newTodo();
return;
+ } else {
+ if ( row == 1 ) {
+ mActiveItem = (KOTodoViewItem *) item;
+ newSubTodo();
+ return;
+ }
}
if ( KOPrefs::instance()->mEditOnDoubleClick )
editItem( item );
else
showItem( item , QPoint(), 0 );
}
void KOTodoView::itemClicked(QListViewItem *item)
{
-
+ //qDebug("KOTodoView::itemClicked %d", item);
if (!item) {
if ( pendingSubtodo != 0 ) {
topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
}
pendingSubtodo = 0;
return;
}
KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
if ( pendingSubtodo != 0 ) {
bool allowReparent = true;
QListViewItem *par = item;
while ( par ) {