kimporticonview.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <qfontmetrics.h>
00018 #include <qpainter.h>
00019 #include <qrect.h>
00020 #include <qwidget.h>
00021
00022 #include <kglobalsettings.h>
00023 #include <klocale.h>
00024 #include <kwordwrap.h>
00025
00026 #include "kimporticonview.h"
00027
00028
00029 KImportIconView::KImportIconView(const QString& strIntro, QWidget *parent, const char *name)
00030 : KFileDnDIconView(parent, name)
00031 {
00032 m_strIntro = strIntro;
00033 m_bDropped = false;
00034
00035 setAcceptDrops ( true );
00036 }
00037
00038
00039 KImportIconView::~KImportIconView()
00040 {
00041 }
00042
00043 void KImportIconView::drawContents ( QPainter *p, int cx, int cy, int cw, int ch )
00044 {
00045 if ( !m_bDropped)
00046 {
00047 QIconView::drawContents ( p, cx, cy, cw, ch );
00048
00049 p->save();
00050 QFont font ( p->font() );
00051 font.setBold ( true );
00052 font.setFamily ( "Helvetica [Adobe]" );
00053 font.setPointSize ( 10 );
00054 p->setFont ( font );
00055 p->setPen ( QPen ( KGlobalSettings::highlightColor() ) );
00056
00057 QRect rect = frameRect();
00058 QFontMetrics fm ( p->font() );
00059 rect.setLeft ( rect.left() + 30 );
00060 rect.setRight ( rect.right() - 30 );
00061
00062 resizeContents ( contentsWidth(), contentsHeight() );
00063
00064
00065 KWordWrap* wordWrap1 = KWordWrap::formatText( fm, rect, AlignHCenter | WordBreak, m_strIntro );
00066 KWordWrap* wordWrap2 = KWordWrap::formatText( fm, rect, AlignHCenter | WordBreak, "Or just use the buttons!" );
00067
00068 QRect introRect1 = wordWrap1->boundingRect();
00069 QRect introRect2 = wordWrap2->boundingRect();
00070
00071 wordWrap1->drawText ( p, ( ( frameRect().right() - introRect1.right() ) / 2 ), ( ( frameRect().bottom() - introRect1.bottom() ) / 2 ) - 20, AlignHCenter | AlignVCenter );
00072 wordWrap2->drawText ( p, ( ( frameRect().right() - introRect2.right() ) / 2 ), ( ( frameRect().bottom() - introRect2.bottom() ) / 2 ) + introRect1.bottom(), AlignHCenter | AlignVCenter );
00073
00074 p->restore();
00075 }
00076 else
00077 {
00078 QIconView::drawContents ( p, cx, cy, cw, ch );
00079 }
00080 }
00081
00082 void KImportIconView::somethingDropped ( bool dropped )
00083 {
00084 m_bDropped = dropped;
00085 }
00086
00087 #include "kimporticonview.moc"
This file is part of the documentation for KDevelop Version 3.1.2.