summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-26 11:03:22 (UTC)
committer zautrix <zautrix>2005-03-26 11:03:22 (UTC)
commitef825f1805452ba2cfb30cd7a41c392d3961f01e (patch) (side-by-side diff)
tree60e896e2867bf3d90f0719f72c50add28bcf1d04 /korganizer
parent6427570041c902840fe0f557415a07bb7aa8c031 (diff)
downloadkdepimpi-ef825f1805452ba2cfb30cd7a41c392d3961f01e.zip
kdepimpi-ef825f1805452ba2cfb30cd7a41c392d3961f01e.tar.gz
kdepimpi-ef825f1805452ba2cfb30cd7a41c392d3961f01e.tar.bz2
next rry
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp195
-rw-r--r--korganizer/koagenda.h6
-rw-r--r--korganizer/koagendaitem.cpp2
-rw-r--r--korganizer/koagendaview.cpp14
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/kolistview.cpp55
-rw-r--r--korganizer/kolistview.h7
7 files changed, 259 insertions, 21 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 66ad4ec..14f52b8 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -49,49 +49,48 @@
#include <libkcal/event.h>
#include <libkcal/todo.h>
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#endif
//extern bool globalFlagBlockPainting;
extern int globalFlagBlockAgenda;
extern int globalFlagBlockAgendaItemPaint;
extern int globalFlagBlockAgendaItemUpdate;
extern int globalFlagBlockStartup;
////////////////////////////////////////////////////////////////////////////
MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
: QFrame(_agenda->viewport(),name), agenda(_agenda)
{
setLineWidth(0);
setMargin(0);
setBackgroundColor(Qt::red);
minutes = new QTimer(this);
connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
minutes->start(0, true);
-
mTimeBox = new QLabel(this);
mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
QPalette pal = mTimeBox->palette();
pal.setColor(QColorGroup::Foreground, Qt::red);
mTimeBox->setPalette(pal);
//mTimeBox->setAutoMask(true);
agenda->addChild(mTimeBox);
oldToday = -1;
}
MarcusBains::~MarcusBains()
{
delete minutes;
}
int MarcusBains::todayColumn()
{
QDate currentDate = QDate::currentDate();
DateList dateList = agenda->dateList();
DateList::ConstIterator it;
int col = 0;
@@ -154,95 +153,98 @@ void MarcusBains::updateLocation(bool recalculate)
mTimeBox->raise();
//mTimeBox->setAutoMask(true);
minutes->start(5000,true);
}
////////////////////////////////////////////////////////////////////////////
/*
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)
{
mColumns = columns;
mRows = rows;
mGridSpacingY = rowSize;
mAllDayMode = false;
#ifndef DESKTOP_VERSION
- QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
+ //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)
{
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 );
+ //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
#endif
mHolidayMask = 0;
init();
}
KOAgenda::~KOAgenda()
{
if(mMarcusBains) delete mMarcusBains;
}
Incidence *KOAgenda::selectedIncidence() const
{
return (mSelectedItem ? mSelectedItem->incidence() : 0);
}
QDate KOAgenda::selectedIncidenceDate() const
{
return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
}
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("Next month"),6 );
mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
#ifndef _WIN32_
int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
viewport()->setWFlags ( wflags);
#endif
mGridSpacingX = 80;
mResizeBorderWidth = 8;
@@ -290,49 +292,51 @@ void KOAgenda::init()
// setMaximumHeight(mGridSpacingY * mRows + 5);
// Disable horizontal scrollbar. This is a hack. The geometry should be
// controlled in a way that the contents horizontally always fits. Then it is
// not necessary to turn off the scrollbar.
setHScrollBarMode(AlwaysOff);
if ( ! mAllDayMode )
setVScrollBarMode(AlwaysOn);
else
setVScrollBarMode(AlwaysOff);
setStartHour(KOPrefs::instance()->mDayBegins);
calculateWorkingHours();
connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
SLOT(checkScrollBoundaries(int)));
// Create the Marcus Bains line.
if(mAllDayMode)
mMarcusBains = 0;
else {
mMarcusBains = new MarcusBains(this);
addChild(mMarcusBains);
- }
+ }
+ mPopupKind = 0;
+ mPopupItem = 0;
}
void KOAgenda::clear()
{
KOAgendaItem *item;
for ( item=mItems.first(); item != 0; item=mItems.next() ) {
mUnusedItems.append( item );
//item->hide();
}
mItems.clear();
mSelectedItem = 0;
clearSelection();
}
void KOAgenda::clearSelection()
{
mSelectionCellX = 0;
mSelectionYTop = 0;
mSelectionHeight = 0;
}
void KOAgenda::marcus_bains()
{
if(mMarcusBains) mMarcusBains->updateLocation(true);
@@ -361,52 +365,232 @@ void KOAgenda::changeColumns(int columns)
/*
This is the eventFilter function, which gets all events from the KOAgendaItems
contained in the agenda. It has to handle moving and resizing for all items.
*/
bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
{
// kdDebug() << "KOAgenda::eventFilter" << endl;
switch(event->type()) {
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
case (QEvent::Leave):
if (!mActionItem)
setCursor(arrowCursor);
return true;
default:
return QScrollView::eventFilter(object,event);
}
}
-
+void KOAgenda::popupMenu()
+{
+ mPopupTimer->stop();
+ if ( mPopupKind == 1 ) {
+ if (mActionItem ) {
+ endItemAction();
+ }
+ mLeftMouseDown = false; // no more leftMouse computation
+ if (mPopupItem) {
+ selectItem(mPopupItem);
+ 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->popup( mPopupPos);
+ }
+ mLeftMouseDown = false;
+ mPopupItem = 0;
+ mPopupKind = 0;
+}
bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
{
+ //qDebug("KOAgenda::eventFilter_mous ");
+ 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();
+ 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;
+ int selectionHeight = mSelectionHeight;
+ clearSelection();
+ repaintContents( selectionCellX, selectionYTop,
+ gridSpacingX, selectionHeight,false );
+ }
+ selectItem(mActionItem);
+ Incidence *incidence = mActionItem->incidence();
+ 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) {
+ popupMenu();
+ } else if (me->button() == LeftButton) {
+ setCursor(arrowCursor);
+ startSelectAction(viewportPos);
+ }
+ }
+ break;
+
+ case QEvent::MouseButtonRelease:
+ if (me->button() == LeftButton ) {
+ mPopupTimer->stop();
+ }
+ if (object != viewport()) {
+ if (me->button() == LeftButton && mLeftMouseDown) {
+ if (mActionItem) {
+ QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
+ //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
+ if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
+ mScrollUpTimer.stop();
+ mScrollDownTimer.stop();
+ mActionItem->resetMove();
+ placeSubCells( mActionItem );
+ // emit startDragSignal( mActionItem->incidence() );
+ setCursor( arrowCursor );
+ mActionItem = 0;
+ mActionType = NOP;
+ mItemMoved = 0;
+ mLeftMouseDown = false;
+ return true;
+ }
+ endItemAction();
+ }
+ }
+
+ } else { // ---------- viewport()
+ if (me->button() == LeftButton && mLeftMouseDown ) { //left click
+ endSelectAction( true ); // emit new event signal
+ }
+ }
+ if (me->button() == LeftButton)
+ mLeftMouseDown = false;
+
+ break;
+
+ case QEvent::MouseMove:
+ if ( !mLeftMouseDown )
+ return true;
+ if ( blockMoving ) {
+ int dX, dY;
+ dX = startX - viewportPos.x();
+ if ( dX < 0 )
+ dX = -dX;
+ dY = viewportPos.y() - startY;
+ if ( dY < 0 )
+ dY = -dY;
+ //qDebug("%d %d %d ", dX, dY , blockmoveDist );
+ if ( dX > blockmoveDist || dY > blockmoveDist ) {
+ blockMoving = false;
+ }
+ }
+ if ( ! blockMoving )
+ mPopupTimer->stop();
+ if (object != viewport()) {
+ KOAgendaItem *moveItem = (KOAgendaItem *)object;
+ if (!moveItem->incidence()->isReadOnly() ) {
+ if (!mActionItem)
+ setNoActionCursor(moveItem,viewportPos);
+ else {
+ if ( !blockMoving )
+ performItemAction(viewportPos);
+ }
+ }
+ } else { // ---------- viewport()
+ mPopupPos = viewport()->mapToGlobal( me->pos() );
+ if ( mActionType == SELECT ) {
+ performSelectAction( viewportPos );
+ }
+ }
+ break;
+
+ case QEvent::MouseButtonDblClick:
+ mPopupTimer->stop();
+ if (object == viewport()) {
+ selectItem(0);
+ int x,y;
+ viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
+ int gx,gy;
+ contentsToGrid(x,y,gx,gy);
+ emit newEventSignal(gx,gy);
+ } else {
+ KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
+ selectItem(doubleClickedItem);
+ if ( KOPrefs::instance()->mEditOnDoubleClick )
+ emit editIncidenceSignal(doubleClickedItem->incidence());
+ else
+ emit showIncidenceSignal(doubleClickedItem->incidence());
+ }
+ break;
+
+ default:
+ break;
+ }
+ return true;
+#if 0
//qDebug("KOAgenda::eventFilter_mous ");
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;
static bool leftMouseDown = false;
bool rightButtonPressed = false;
switch (me->type()) {
case QEvent::MouseButtonPress:
if (me->button() == LeftButton) {
leftMouseDown = true;
}
else if (me->button() == RightButton) {
leftMouseDown = false;
}
blockMoving = true;
startX = viewportPos.x();
startY = viewportPos.y();
@@ -538,48 +722,49 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
case QEvent::MouseButtonDblClick:
blockMoving = false;
leftMouseDown = false;
if (object == viewport()) {
selectItem(0);
int x,y;
viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
int gx,gy;
contentsToGrid(x,y,gx,gy);
emit newEventSignal(gx,gy);
} else {
KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
selectItem(doubleClickedItem);
if ( KOPrefs::instance()->mEditOnDoubleClick )
emit editIncidenceSignal(doubleClickedItem->incidence());
else
emit showIncidenceSignal(doubleClickedItem->incidence());
}
break;
default:
break;
}
return true;
+#endif
}
void KOAgenda::newItem( int item )
{
if ( item == 1 ) { //new event
newEventSignal(mStartCellX ,mStartCellY );
} else
if ( item == 2 ) { //new event
newTodoSignal(mStartCellX ,mStartCellY );
} else
{
QDate day = mSelectedDates[mStartCellX];
emit showDateView( item, day );
// 3Day view
// 4Week view
// 5Month view
// 6Journal view
}
}
void KOAgenda::startSelectAction(QPoint viewportPos)
{
//emit newStartSelectSignal();
mActionType = SELECT;
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index f3f1772..3d33ae5 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -105,48 +105,49 @@ class KOAgenda : public QScrollView
void clear();
void clearSelection();
void hideUnused();
/** Calculates the minimum width */
virtual int minimumWidth() const;
/** Update configuration from preference settings */
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();
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);
/** Deselect selected items. This function does not emit any signals. */
void deselectItem();
/** Select item. If the argument is 0, the currently selected item gets
deselected. This function emits the itemSelected(bool) signal to inform
about selection/deseelction of events. */
void selectItem(KOAgendaItem *);
void finishResize();
signals:
void showDateView( int, QDate );
void newEventSignal();
void newEventSignal(int gx,int gy);
void newTodoSignal(int gx,int gy);
void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
@@ -193,48 +194,53 @@ class KOAgenda : public QScrollView
/** End moving/resizing agenda item */
void endItemAction();
/** Set cursor, when no item action is in progress */
void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
/** Place agenda item in agenda and adjust other cells if necessary */
void placeSubCells(KOAgendaItem *placeItem);
/** Process the keyevent, including the ignored keyevents of eventwidgets.
* Implements pgup/pgdn and cursor key navigation in the view.
*/
void keyPressEvent( QKeyEvent * );
void calculateWorkingHours();
virtual void contentsMousePressEvent ( QMouseEvent * );
private:
void init();
void marcus_bains();
bool mAllDayMode;
bool blockResize;
+ bool mLeftMouseDown;
+ KOAgendaItem *mPopupItem;
+ QTimer* mPopupTimer;
+ int mPopupKind;
+ QPoint mPopupPos;
QTimer mResizeTimer;
double mContentPosition;
// Width and height of agenda cells
int mGridSpacingX;
int mGridSpacingY;
// size of border, where mouse action will resize the KOAgendaItem
int mResizeBorderWidth;
// size of border, where mouse mve will cause a scroll of the agenda
int mScrollBorderWidth;
int mScrollDelay;
int mScrollOffset;
QTimer mScrollUpTimer;
QTimer mScrollDownTimer;
// Number of Columns/Rows of agenda grid
int mColumns;
int mRows;
// Cells to store Move and Resize coordiantes
int mStartCellX;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 905c1bf..b30ad75 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -54,49 +54,49 @@ extern int globalFlagBlockAgendaItemUpdate;
QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
//--------------------------------------------------------------------------
class KOAgendaItemWhatsThis :public QWhatsThis
{
public:
KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
protected:
virtual QString text( const QPoint& )
{
return _view->getWhatsThisText() ;
}
private:
KOAgendaItem * _view;
};
KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
const char *name,WFlags) :
QWidget(parent, name), mIncidence(incidence), mDate(qd)
{
#ifndef DESKTOP_VERSION
- QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
+ //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
#endif
mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
setWFlags ( wflags);
mAllDay = allday;
init ( incidence, qd );
//setMouseTracking(true);
//setAcceptDrops(true);
xPaintCoord = -1;
yPaintCoord = -1;
}
QString KOAgendaItem::getWhatsThisText()
{
if ( mIncidence )
return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
KOPrefs::instance()->mWTshowDetails,
KOPrefs::instance()->mWTshowCreated,
KOPrefs::instance()->mWTshowChanged);
return "KOAgendaItem::getWhatsThisText()::internal error";
}
void KOAgendaItem::init ( Incidence *incidence, QDate qd )
{
mIncidence = incidence;
mDate = qd;
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 957ac52..b9c7dec 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -108,49 +108,49 @@ void TimeLabels::setCellHeight(int height)
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");
int timeHeight = fm.height();
timeHeight -= (timeHeight/4-2);
- int borderWidth = 5;
+ int borderWidth = 2;
QFont nFont = p->font();
QFont sFont = nFont;
sFont.setPointSize( sFont.pointSize()/2+2 );
if (!KGlobal::locale()->use12Clock())
suffix = "00";
QFontMetrics fmS( sFont );
int sHei = fmS.height();
if ( timeHeight > mCellHeight ) {
timeHeight = mCellHeight-1;
sHei -= 2;
}
while (y < cy + ch) {
p->drawLine(cx,y,cx+tW,y);
hour.setNum(cell);
// handle 24h and am/pm time formats
if (KGlobal::locale()->use12Clock()) {
if (cell > 11) suffix = "pm";
else
suffix = "am";
if (cell == 0) hour.setNum(12);
if (cell > 12) hour.setNum(cell - 12);
}
@@ -158,67 +158,59 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
// 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 tw2 = fm.width(suffix);
int offset = this->width() - timeWidth - tw2;
p->setFont( nFont );
p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime);
p->setFont( sFont );
offset += timeWidth;
p->drawText(cx - borderWidth + offset, y+ sHei, suffix);
// 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;
+ return mMiniWidth;
}
/** updates widget's internal state */
void TimeLabels::updateConfig()
{
// set the font
// config->setGroup("Fonts");
// QFont font = config->readFontEntry("TimeBar Font");
setFont(KOPrefs::instance()->mTimeBarFont);
-
+ mMiniWidth = fontMetrics().width("88:88") + 2 ;
// 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();
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 8b8bac0..0cb9310 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -80,48 +80,49 @@ class TimeLabels : public QScrollView {
/** 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 mMiniWidth;
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 *);
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 6b63d7f..09d70f1 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1133,63 +1133,110 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e)
QListViewItem* cn;
cn = currentItem();
if ( cn ) {
KOListViewItem* ci = (KOListViewItem*)( cn );
if ( ci ){
if ( e->state() == ShiftButton )
ci->setSelected( false );
else
ci->setSelected( true );
cn = cn->nextSibling();
if ( cn ) {
setCurrentItem ( cn );
ensureItemVisible ( cn );
}
}
}
e->accept();
}
break;
default:
e->ignore();
}
}
KOListViewListView::KOListViewListView(KOListView * lv )
- : KListView( lv )
-{
+ : KListView( lv, "kolistlistview", false )
+{
+ mPopupTimer = new QTimer(this);
+ connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
#ifndef DESKTOP_VERSION
- QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
+ //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
#endif
setSelectionMode( QListView::Multi );
setMultiSelection( true);
}
void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
{
if (!e) return;
QPoint vp = contentsToViewport(e->pos());
QListViewItem *item = itemAt(vp);
if (!item) {
emit newEvent();
return;
}
KListView::contentsMouseDoubleClickEvent(e);
}
-
+#if 0
void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
{
//qDebug("contentsMousePressEvent++++ ");
KListView::contentsMousePressEvent( e );
if ( e->button() == RightButton ) {
QListViewItem* ci = currentItem();
clearSelection () ;
if ( ci )
ci->setSelected( true );
}
}
void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
{
KListView::contentsMouseReleaseEvent(e);
}
void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
{
KListView::contentsMouseMoveEvent(e);
}
+#endif
+void KOListViewListView::popupMenu()
+{
+ mPopupTimer->stop();
+ //qDebug("HUUUUUUUUUUUUUUUUUUUU ");
+ QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
+ QApplication::postEvent( this->viewport(), e );
+}
+void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
+{
+ //qDebug("contentsMousePressEvent++++ ");
+ mYMousePos = mapToGlobal( (e->pos())).y();
+ if ( e->button() == LeftButton ) {
+ mPopupTimer->start( 600 );
+ mEventPos = e->pos();
+ mEventGlobalPos = e->globalPos();
+ }
+ KListView::contentsMousePressEvent( e );
+ if ( e->button() == RightButton ) {
+ QListViewItem* ci = currentItem();
+ clearSelection();
+ if ( ci )
+ ci->setSelected( true );
+ }
+}
+void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
+{
+ mPopupTimer->stop();
+ KListView::contentsMouseReleaseEvent(e);
+}
+void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
+{
+ // qDebug("contentsMouseMoveEv....... ");
+ // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
+ int diff = mYMousePos - mapToGlobal( (e->pos())).y();
+ if ( diff < 0 ) diff = -diff;
+ if ( diff > 15 )
+ mPopupTimer->stop();
+ else {
+ mEventPos = e->pos();
+ mEventGlobalPos = e->globalPos();
+ }
+ KListView::contentsMouseMoveEvent(e);
+}
+
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index eca71e2..bb0e23e 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -26,48 +26,49 @@
#include <qlistview.h>
#include <qmap.h>
#include <qdict.h>
#include <klistview.h>
#ifndef DESKTOP_VERSION
#include <qtopia/ir.h>
#else
#define Ir char
#endif
#include <libkcal/incidence.h>
#include "koeventview.h"
#include "customlistviewitem.h"
using namespace KCal;
#include <qpushbutton.h>
#include <qlayout.h>
#include <qdialog.h>
+#include <qtimer.h>
#include <qcombobox.h>
#include <qspinbox.h>
#include <qtooltip.h>
#include <qcheckbox.h>
#include <qhbox.h>
#include <qlabel.h>
#include <kiconloader.h>
#include "kfiledialog.h"
#include "koprefs.h"
class KOAlarmPrefs : public QDialog
{
Q_OBJECT
public:
KOAlarmPrefs( QWidget *par=0, const char *name=0 ) :
QDialog( par, name, true )
{
setCaption( i18n("Alarm Options") );
QVBoxLayout* alarmLayout = new QVBoxLayout( this );
alarmLayout->setSpacing( 3 );
alarmLayout->setMargin( 3 );
QWidget *parent = this;
mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent);
alarmLayout->addWidget(mAlarmButton);
mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
@@ -196,49 +197,55 @@ class ListItemVisitor : public Incidence::Visitor
KOListViewItem *mItem;
QDate mDate;
};
/**
This class provides a multi-column list view of events. It can
display events from one particular day or several days, it doesn't
matter. To use a view that only handles one day at a time, use
KODayListView.
@short multi-column list view of various events.
@author Preston Brown <pbrown@kde.org>
@see KOBaseView, KODayListView
*/
class KOListView;
class KOListViewListView : public KListView
{
Q_OBJECT
public:
KOListViewListView(KOListView * lv );
signals:
void newEvent();
void showIncidence( Incidence* );
+ public slots:
+ void popupMenu();
private:
+ QPoint mEventPos;
+ QPoint mEventGlobalPos;
+ QTimer* mPopupTimer;
+ int mYMousePos;
void keyPressEvent ( QKeyEvent * ) ;
void contentsMouseDoubleClickEvent(QMouseEvent *e);
void contentsMousePressEvent(QMouseEvent *e);
void contentsMouseReleaseEvent(QMouseEvent *e);
void contentsMouseMoveEvent(QMouseEvent *e);
bool mMouseDown;
};
class KOListView : public KOEventView
{
Q_OBJECT
public:
KOListView(Calendar *calendar, QWidget *parent = 0,
const char *name = 0);
~KOListView();
virtual int maxDatesHint();
virtual int currentDateCount();
virtual QPtrList<Incidence> selectedIncidences();
virtual DateList selectedDates();
void showDates(bool show);
Incidence* currentItem();
void addTodos(QPtrList<Todo> eventList);