summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-21 12:32:52 (UTC)
committer zautrix <zautrix>2005-04-21 12:32:52 (UTC)
commit0a13a3490ec3bf4735e3435f80f58fa7d50b4448 (patch) (side-by-side diff)
treec7f28c49b52e479f47da0dce9f0bfe9189ecdca4
parent4d96d7b681ce99d76746a843c289b75f5e7dba64 (diff)
downloadkdepimpi-0a13a3490ec3bf4735e3435f80f58fa7d50b4448.zip
kdepimpi-0a13a3490ec3bf4735e3435f80f58fa7d50b4448.tar.gz
kdepimpi-0a13a3490ec3bf4735e3435f80f58fa7d50b4448.tar.bz2
rubberband fix
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/komonthview.cpp2
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp21
-rw-r--r--microkde/KDGanttMinimizeSplitter.h5
3 files changed, 22 insertions, 6 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 7927307..8ee1363 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -725,97 +725,97 @@ int MonthViewCell::insertEvent(Event *event)
QPalette pal;
if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
QStringList categories = event->categories();
QString cat = categories.first();
if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
pal = getPalette();
if (cat.isEmpty()) {
pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
} else {
pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
}
} else {
if (cat.isEmpty()) {
pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
} else {
pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
}
}
} else {
pal = mStandardPalette ;
}
item->setPalette( pal );
item->setRecur( event->recurrence()->doesRecur() );
item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
item->setMoreInfo( event->description().length() > 0 );
#ifdef DESKTOP_VERSION
Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
KOPrefs::instance()->email());
if ( me != 0 ) {
if ( me->status() == Attendee::NeedsAction && me->RSVP())
item->setReply(true && multiday < 2);
else
item->setReply(false);
} else
item->setReply(false);
#endif
item->setMultiDay( multiday );
if ( multiday ) {
insertItem( item ,mdayCount);
++mdayCount;
} else {
uint i;
int pos = mdayCount;
for ( i = mdayCount; i < count();++i ) {
QListBoxItem* it = this->item ( i );
- if ( text < it->text() ) {
+ if ( it && text < it->text() ) {
pos = i;
break;
}
++pos;
}
insertItem( item ,pos);
}
if ( useToolTips ) {
mToolTip.append( mToolTipText );
}
return mdayCount;
}
void MonthViewCell::insertTodo(Todo *todo)
{
setFocusPolicy(WheelFocus);
QString text;
if (todo->hasDueDate()) {
if (!todo->doesFloat()) {
text += KGlobal::locale()->formatTime(todo->dtDue().time());
text += " ";
}
}
text += todo->summary();
MonthViewItem *item ;
if ( mAvailItemList.count() ) {
item = mAvailItemList.first();
mAvailItemList.remove( item );
item->recycle( todo, mDate, text );
} else {
item = new MonthViewItem( todo, mDate, text );
}
//MonthViewItem *item = new MonthViewItem( todo, mDate, text );
//item->setPalette( mStandardPalette );
QPalette pal;
if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
QStringList categories = todo->categories();
QString cat = categories.first();
if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
pal = getPalette();
if (cat.isEmpty()) {
pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
} else {
pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
}
} else {
if (cat.isEmpty()) {
pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index fb5d4e3..72c4e60 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -7,108 +7,121 @@
**
** This file is part of the KDGantt library.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid commercial KDGantt licenses may use this file in
** accordance with the KDGantt Commercial License Agreement provided with
** the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
** information about KDGantt Commercial License Agreements.
**
** Contact info@klaralvdalens-datakonsult.se if any conditions of this
** licensing are not clear to you.
**
** As a special exception, permission is given to link this program
** with any edition of Qt, and distribute the resulting executable,
** without including the source code for Qt in the source distribution.
**
**********************************************************************/
#include "KDGanttMinimizeSplitter.h"
#ifndef QT_NO_SPLITTER___
#include "qpainter.h"
#include "qdrawutil.h"
#include "qbitmap.h"
#if QT_VERSION >= 0x030000
#include "qptrlist.h"
#include "qmemarray.h"
#else
#include <qlist.h>
#include <qarray.h>
#define QPtrList QList
#define QMemArray QArray
#endif
#include "qlayoutengine_p.h"
#include "qobjectlist.h"
#include "qstyle.h"
#include "qapplication.h" //sendPostedEvents
#include <qvaluelist.h>
#include <qcursor.h>
+#include <qframe.h>
#ifndef KDGANTT_MASTER_CVS
//#include "KDGanttMinimizeSplitter.moc"
#endif
#ifndef DOXYGEN_SKIP_INTERNAL
#if QT_VERSION >= 232
static int mouseOffset;
static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
+class KDRubberBand: public QFrame
+{
+public:
+ KDRubberBand( QWidget *parent, const char * name, WFlags f ) :QFrame ( parent, name, f ) {;}
+
+protected:
+ virtual void mousePressEvent ( QMouseEvent * )
+ {
+ close();
+ };
+
+};
KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o,
KDGanttMinimizeSplitter *parent, const char * name )
: QWidget( parent, name ), _activeButton( 0 ), _collapsed( false )
{
if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) {
mSizeHint = QSize(7,7);
mUseOffset = true;
} else {
mSizeHint = QSize(6,6);
mUseOffset = false;
}
s = parent;
setOrientation(o);
setMouseTracking( true );
mMouseDown = false;
//setMaximumHeight( 5 ); // test only
}
QSize KDGanttSplitterHandle::sizeHint() const
{
return mSizeHint;
}
void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
{
orient = o;
#ifndef QT_NO_CURSOR
if ( o == KDGanttMinimizeSplitter::Horizontal )
setCursor( splitHCursor );
else
setCursor( splitVCursor );
#endif
}
void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
{
updateCursor( e->pos() );
if ( !(e->state()&LeftButton) )
return;
if ( _activeButton != 0)
return;
QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
- mouseOffset;
@@ -144,98 +157,100 @@ void KDGanttSplitterHandle::updateCursor( const QPoint& p)
else
setCursor( splitVCursor );
}
}
void KDGanttSplitterHandle::toggle()
{
int pos;
int min, max;
if ( !_collapsed ) {
s->expandPos( id(), &min, &max );
if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
|| s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
pos = min;
}
else {
pos = max;
}
_origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
s->moveSplitter( pos, id() );
_collapsed = true;
}
else {
s->moveSplitter( _origPos, id() );
_collapsed = false;
}
repaint();
}
void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
{
mMouseDown = false;
if ( _activeButton != 0 ) {
if ( onButton( e->pos() ) == _activeButton )
{
toggle();
}
_activeButton = 0;
updateCursor( e->pos() );
}
else {
if ( !opaque() && e->button() == LeftButton ) {
QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
- mouseOffset;
s->setRubberband( -1 );
s->moveSplitter( pos, id() );
}
}
- if ( s->rubberBand() )
- s->rubberBand()->hide();
+ if ( s->rubberBand() ) {
+ //qDebug("hide rubberband ");
+ s->rubberBand()->close();
+ }
repaint();
}
int KDGanttSplitterHandle::onButton( const QPoint& p )
{
QValueList<QPointArray> list = buttonRegions();
int index = 1;
int add = 12;
for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
QRect rect = (*it).boundingRect();
rect.setLeft( rect.left()- add );
rect.setRight( rect.right() + add);
rect.setTop( rect.top()- add );
rect.setBottom( rect.bottom() + add);
if ( rect.contains( p ) ) {
return index;
}
index++;
}
return 0;
}
QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
{
QValueList<QPointArray> list;
int sw = 8;
int yyy = 1;
int xxx = 1;
int voffset[] = { (int) -sw*3, (int) sw*3 };
for ( int i = 0; i < 2; i++ ) {
QPointArray arr;
if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ||
_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) {
int mid = height()/2 + voffset[i];
arr.setPoints( 3,
1-xxx, mid - sw + 4,
sw-3-xxx, mid,
1-xxx, mid + sw -4);
}
else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
int mid = height()/2 + voffset[i];
arr.setPoints( 3,
sw-4, mid - sw + 4,
0, mid,
sw-4, mid + sw - 4);
@@ -636,97 +651,97 @@ void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
delete p->wid; //will call childEvent
delete p;
}
recalcId();
doResize();
return;
}
p = s;
s = data->list.next();
}
}
}
/*!
Shows a rubber band at position \a p. If \a p is negative, the
rubber band is removed.
*/
void KDGanttMinimizeSplitter::setRubberband( int p )
{
#ifdef DESKTOP_VERSION
QPainter paint( this );
paint.setPen( gray );
paint.setBrush( gray );
paint.setRasterOp( XorROP );
QRect r = contentsRect();
const int rBord = 3; //Themable????
#if QT_VERSION >= 0x030000
int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
#else
int sw = style().splitterWidth();
#endif
if ( orient == Horizontal ) {
if ( opaqueOldPos >= 0 )
paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
2*rBord, r.height() );
if ( p >= 0 )
paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
} else {
if ( opaqueOldPos >= 0 )
paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
r.width(), 2*rBord );
if ( p >= 0 )
paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
}
opaqueOldPos = p;
#else
if ( !mRubberBand ) {
- mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop);
+ mRubberBand = new KDRubberBand( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop);
mRubberBand->setFrameStyle( Box | Raised );
//mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) );
mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() ));
}
QRect r = contentsRect();
static int rBord = 0; //Themable????
if ( !rBord ) {
if (QApplication::desktop()->width() <= 320 )
rBord = 3;
else
rBord = 4;
}
int sw = style().splitterWidth();
if ( orient == Horizontal ) {
if ( p >= 0 ) {
QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y()));
mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() );
}
} else {
if ( p >= 0 ) {
QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord));
mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord);
}
}
opaqueOldPos = p;
if ( ! mRubberBand->isVisible() ) {
mRubberBand->show();
}
#endif
}
/*! \reimp */
bool KDGanttMinimizeSplitter::event( QEvent *e )
{
if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
recalc( isVisible() );
if ( e->type() == QEvent::Show )
data->firstShow = FALSE;
}
return QWidget::event( e );
}
/*!
\obsolete
Draws the splitter handle in the rectangle described by \a x, \a y,
diff --git a/microkde/KDGanttMinimizeSplitter.h b/microkde/KDGanttMinimizeSplitter.h
index 585298d..3042e0a 100644
--- a/microkde/KDGanttMinimizeSplitter.h
+++ b/microkde/KDGanttMinimizeSplitter.h
@@ -1,151 +1,152 @@
/* -*- Mode: C++ -*-
$Id$
*/
/****************************************************************************
** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved.
**
** This file is part of the KDGantt library.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid commercial KDGantt licenses may use this file in
** accordance with the KDGantt Commercial License Agreement provided with
** the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
** information about KDGantt Commercial License Agreements.
**
** Contact info@klaralvdalens-datakonsult.se if any conditions of this
** licensing are not clear to you.
**
** As a special exception, permission is given to link this program
** with any edition of Qt, and distribute the resulting executable,
** without including the source code for Qt in the source distribution.
**
**********************************************************************/
#ifndef KDGANTTMINIMIZESPLITTER_H
#define KDGANTTMINIMIZESPLITTER_H
#ifndef QT_H
#include "qframe.h"
#include "qvaluelist.h"
#endif // QT_H
#ifndef QT_NO_SPLITTER___
class QSplitterData;
class QSplitterLayoutStruct;
class KDGanttSplitterHandle;
+class KDRubberBand;
class KDGanttMinimizeSplitter : public QFrame
{
Q_OBJECT
// Q_ENUMS( Direction )
// Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
// Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection )
public:
enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
enum Direction { Left, Right, Up, Down };
KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 );
KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 );
~KDGanttMinimizeSplitter();
virtual void setOrientation( Orientation );
Orientation orientation() const { return orient; }
void setMinimizeDirection( Direction );
Direction minimizeDirection() const;
#if QT_VERSION >= 232
virtual void setResizeMode( QWidget *w, ResizeMode );
virtual void setOpaqueResize( bool = TRUE );
bool opaqueResize() const;
void moveToFirst( QWidget * );
void moveToLast( QWidget * );
void refresh() { recalc( TRUE ); }
QSize sizeHint() const;
QSize minimumSizeHint() const;
QValueList<int> sizes() const;
void setSizes( QValueList<int> );
KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;}
void expandPos( int id, int* min, int* max );
- QFrame* rubberBand() { return mRubberBand ;}
+ KDRubberBand* rubberBand() { return mRubberBand ;}
public slots:
void toggle();
protected:
void childEvent( QChildEvent * );
bool event( QEvent * );
void resizeEvent( QResizeEvent * );
int idAfter( QWidget* ) const;
void moveSplitter( QCOORD pos, int id );
virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
QCOORD w, QCOORD h );
void styleChange( QStyle& );
int adjustPos( int , int );
virtual void setRubberband( int );
void getRange( int id, int*, int* );
private:
- QFrame* mRubberBand;
+ KDRubberBand* mRubberBand;
void init();
void recalc( bool update = FALSE );
void doResize();
void storeSizes();
void processChildEvents();
QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE );
void recalcId();
void moveBefore( int pos, int id, bool upLeft );
void moveAfter( int pos, int id, bool upLeft );
void setG( QWidget *w, int p, int s, bool isSplitter = FALSE );
QCOORD pick( const QPoint &p ) const
{ return orient == Horizontal ? p.x() : p.y(); }
QCOORD pick( const QSize &s ) const
{ return orient == Horizontal ? s.width() : s.height(); }
QCOORD trans( const QPoint &p ) const
{ return orient == Vertical ? p.x() : p.y(); }
QCOORD trans( const QSize &s ) const
{ return orient == Vertical ? s.width() : s.height(); }
KDGanttSplitterHandle* mFirstHandle;
QSplitterData *data;
#endif
private:
Orientation orient;
Direction _direction;
#ifndef DOXYGEN_SKIP_INTERNAL
friend class KDGanttSplitterHandle;
#endif
private: // Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & );
KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & );
#endif
};
#ifndef DOXYGEN_SKIP_INTERNAL
// This class was continued from a verbatim copy of the
// QSplitterHandle pertaining to the Qt Enterprise License and the
// GPL. It has only been renamed to KDGanttSplitterHandler in order to
// avoid a symbol clash on some platforms.
class KDGanttSplitterHandle : public QWidget
{
Q_OBJECT
#if QT_VERSION >= 232
public:
KDGanttSplitterHandle( Qt::Orientation o,