00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "summary.h"
00024
00025 #include <tqimage.h>
00026 #include <tqdragobject.h>
00027 #include <tqhbox.h>
00028 #include <tqfont.h>
00029 #include <tqlabel.h>
00030 #include <tqpainter.h>
00031
00032 #include <kiconloader.h>
00033 #include <kdialog.h>
00034
00035 using namespace Kontact;
00036
00037 Summary::Summary( TQWidget *parent, const char *name )
00038 : TQWidget( parent, name )
00039 {
00040 setAcceptDrops( true );
00041 }
00042
00043 Summary::~Summary()
00044 {
00045 }
00046
00047 TQWidget* Summary::createHeader(TQWidget *parent, const TQPixmap& icon, const TQString& heading)
00048 {
00049 TQHBox* hbox = new TQHBox( parent );
00050 hbox->setMargin( 2 );
00051
00052 TQFont boldFont;
00053 boldFont.setBold( true );
00054 boldFont.setPointSize( boldFont.pointSize() + 2 );
00055
00056 TQLabel *label = new TQLabel( hbox );
00057 label->setPixmap( icon );
00058 label->setFixedSize( label->sizeHint() );
00059 label->setPaletteBackgroundColor( colorGroup().mid() );
00060 label->setAcceptDrops( true );
00061
00062 label = new TQLabel( heading, hbox );
00063 label->setAlignment( AlignLeft|AlignVCenter );
00064 label->setIndent( KDialog::spacingHint() );
00065 label->setFont( boldFont );
00066 label->setPaletteForegroundColor( colorGroup().light() );
00067 label->setPaletteBackgroundColor( colorGroup().mid() );
00068
00069 hbox->setPaletteBackgroundColor( colorGroup().mid() );
00070
00071 hbox->setMaximumHeight( hbox->minimumSizeHint().height() );
00072
00073 return hbox;
00074 }
00075
00076 void Summary::mousePressEvent( TQMouseEvent *event )
00077 {
00078 mDragStartPoint = event->pos();
00079
00080 TQWidget::mousePressEvent( event );
00081 }
00082
00083 void Summary::mouseMoveEvent( TQMouseEvent *event )
00084 {
00085 if ( (event->state() & Qt::LeftButton) &&
00086 (event->pos() - mDragStartPoint).manhattanLength() > 4 ) {
00087
00088 TQDragObject *drag = new TQTextDrag( "", this, "SummaryWidgetDrag" );
00089
00090 TQPixmap pm = TQPixmap::grabWidget( this );
00091 if ( pm.width() > 300 )
00092 pm = pm.convertToImage().smoothScale( 300, 300, TQ_ScaleMin );
00093
00094 TQPainter painter;
00095 painter.begin( &pm );
00096 painter.setPen( TQt::gray );
00097 painter.drawRect( 0, 0, pm.width(), pm.height() );
00098 painter.end();
00099 drag->setPixmap( pm );
00100 drag->dragMove();
00101 } else
00102 TQWidget::mouseMoveEvent( event );
00103 }
00104
00105 void Summary::dragEnterEvent( TQDragEnterEvent *event )
00106 {
00107 event->accept( TQTextDrag::canDecode( event ) );
00108 }
00109
00110 void Summary::dropEvent( TQDropEvent *event )
00111 {
00112 int alignment = (event->pos().y() < (height() / 2) ? TQt::AlignTop : TQt::AlignBottom);
00113 emit summaryWidgetDropped( this, event->source(), alignment );
00114 }
00115
00116 #include "summary.moc"