26 #include <tqdragobject.h>
30 #include <tqpainter.h>
32 #include <kiconloader.h>
35 using namespace Kontact;
37 Summary::Summary( TQWidget *parent,
const char *name )
38 : TQWidget( parent, name )
40 setAcceptDrops(
true );
49 TQHBox* hbox =
new TQHBox( parent );
53 boldFont.setBold(
true );
54 boldFont.setPointSize( boldFont.pointSize() + 2 );
56 TQLabel *label =
new TQLabel( hbox );
57 label->setPixmap( icon );
58 label->setFixedSize( label->sizeHint() );
59 label->setPaletteBackgroundColor( colorGroup().mid() );
60 label->setAcceptDrops(
true );
62 label =
new TQLabel( heading, hbox );
63 label->setAlignment( AlignLeft|AlignVCenter );
64 label->setIndent( KDialog::spacingHint() );
65 label->setFont( boldFont );
66 label->setPaletteForegroundColor( colorGroup().light() );
67 label->setPaletteBackgroundColor( colorGroup().mid() );
69 hbox->setPaletteBackgroundColor( colorGroup().mid() );
71 hbox->setMaximumHeight( hbox->minimumSizeHint().height() );
76 void Summary::mousePressEvent( TQMouseEvent *event )
78 mDragStartPoint =
event->pos();
80 TQWidget::mousePressEvent( event );
83 void Summary::mouseMoveEvent( TQMouseEvent *event )
85 if ( (event->state() & TQt::LeftButton) &&
86 (event->pos() - mDragStartPoint).manhattanLength() > 4 ) {
88 TQDragObject *drag =
new TQTextDrag(
"",
this,
"SummaryWidgetDrag" );
90 TQPixmap pm = TQPixmap::grabWidget(
this );
91 if ( pm.width() > 300 )
92 pm = pm.convertToImage().smoothScale( 300, 300, TQImage::ScaleMin );
96 painter.setPen( TQt::gray );
97 painter.drawRect( 0, 0, pm.width(), pm.height() );
99 drag->setPixmap( pm );
102 TQWidget::mouseMoveEvent( event );
105 void Summary::dragEnterEvent( TQDragEnterEvent *event )
107 event->accept( TQTextDrag::canDecode( event ) );
110 void Summary::dropEvent( TQDropEvent *event )
112 int alignment = (
event->pos().y() < (height() / 2) ? TQt::AlignTop : TQt::AlignBottom);
113 emit summaryWidgetDropped(
this, event->source(), alignment );
116 #include "summary.moc"
TQWidget * createHeader(TQWidget *parent, const TQPixmap &icon, const TQString &heading)
Creates a heading for a typical summary view with an icon and a heading.