22#include <konq_filetip.h> 
   24#include <tdefileitem.h> 
   25#include <tdeglobalsettings.h> 
   26#include <tdestandarddirs.h> 
   27#include <tdeapplication.h> 
   33#include <tqscrollview.h> 
   39KonqFileTip::KonqFileTip( TQScrollView* parent )
 
   40  : TQFrame( 0, 0, (WFlags)(WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WStyle_StaysOnTop | WX11BypassWM) ),
 
   50    m_iconLabel = 
new TQLabel(
this);
 
   51    m_textLabel = 
new TQLabel(
this);
 
   52    m_textLabel->setAlignment(TQt::AlignAuto | TQt::AlignTop);
 
   54    TQGridLayout* layout = 
new TQGridLayout(
this, 1, 2, 8, 0);
 
   55    layout->addWidget(m_iconLabel, 0, 0);
 
   56    layout->addWidget(m_textLabel, 0, 1);
 
   57    layout->setResizeMode(TQLayout::Fixed);
 
   59    setPalette( TQToolTip::palette() );
 
   61    setFrameStyle( TQFrame::Plain | TQFrame::Box );
 
   63    m_timer = 
new TQTimer(
this);
 
   68KonqFileTip::~KonqFileTip()
 
   76void KonqFileTip::setPreview(
bool on)
 
   85void KonqFileTip::setOptions( 
bool on, 
bool preview, 
int num )
 
   92void KonqFileTip::setItem( KFileItem *item, 
const TQRect &rect, 
const TQPixmap *pixmap )
 
  109              m_iconLabel->setPixmap( *pixmap );
 
  111              m_iconLabel->setPixmap( TQPixmap() );
 
  116        m_timer->disconnect( 
this );
 
  117        connect(m_timer, TQ_SIGNAL(timeout()), 
this, TQ_SLOT(startDelayed()));
 
  118        m_timer->start( 300, 
true );
 
  122void KonqFileTip::reposition()
 
  124    if ( m_rect.isEmpty() || !m_view || !m_view->viewport() ) 
return;
 
  126    TQRect rect = m_rect;
 
  127    TQPoint off = m_view->viewport()->mapToGlobal( m_view->contentsToViewport( rect.topRight() ) );
 
  128    rect.moveTopRight( off );
 
  130    TQPoint pos = rect.center();
 
  139    TQRect desk = TDEGlobalSettings::desktopGeometry(rect.center());
 
  140    if (rect.center().x() + width() > desk.right())
 
  143        if (pos.x() - width() < 0) {
 
  147            pos.setX( pos.x() - width() );
 
  152    if (rect.bottom() + height() > desk.bottom())
 
  155        pos.setY( rect.top() - height() );
 
  158    else pos.setY( rect.bottom() + 1 );
 
  164void KonqFileTip::gotPreview( 
const KFileItem* item, 
const TQPixmap& pixmap )
 
  167    if (item != m_item) 
return;
 
  169    m_iconLabel -> setPixmap(pixmap);
 
  172void KonqFileTip::gotPreviewResult()
 
  177void KonqFileTip::drawContents( TQPainter *p )
 
  179    static const char * 
const names[] = {
 
  187        TQFrame::drawContents( p );
 
  191    if ( m_corners[m_corner].isNull())
 
  192        m_corners[m_corner].load( locate( 
"data", TQString::fromLatin1( 
"konqueror/pics/%1.png" ).arg( names[m_corner] ) ) );
 
  194    TQPixmap &pix = m_corners[m_corner];
 
  199            p->drawPixmap( 3, 3, pix );
 
  202            p->drawPixmap( width() - pix.width() - 3, 3, pix );
 
  205            p->drawPixmap( 3, height() - pix.height() - 3, pix );
 
  208            p->drawPixmap( width() - pix.width() - 3, height() - pix.height() - 3, pix );
 
  212    TQFrame::drawContents( p );
 
  215void KonqFileTip::setFilter( 
bool enable )
 
  217    if ( enable == m_filter ) 
return;
 
  220        tdeApp->installEventFilter( 
this );
 
  221        TQApplication::setGlobalMouseTracking( 
true );
 
  224        TQApplication::setGlobalMouseTracking( 
false );
 
  225        tdeApp->removeEventFilter( 
this );
 
  230void KonqFileTip::showTip()
 
  232    TQString text = m_item->getToolTipText(m_num);
 
  234    if ( text.isEmpty() ) 
return;
 
  236    m_timer->disconnect( 
this );
 
  237    connect(m_timer, TQ_SIGNAL(timeout()), 
this, TQ_SLOT(hideTip()));
 
  238    m_timer->start( 15000, 
true );
 
  240    m_textLabel->setText( text );
 
  248void KonqFileTip::hideTip()
 
  252    if ( isShown() && m_view && m_view->viewport() &&
 
  253         (m_view->horizontalScrollBar()->isShown() || m_view->verticalScrollBar()->isShown()) )
 
  254      m_view->viewport()->update();
 
  257void KonqFileTip::startDelayed()
 
  260        KFileItemList oneItem;
 
  261        oneItem.append( m_item );
 
  263        m_previewJob = TDEIO::filePreview( oneItem, 256, 256, 64, 70, 
true, 
true, 0);
 
  264        connect( m_previewJob, TQ_SIGNAL( gotPreview( 
const KFileItem *, 
const TQPixmap & ) ),
 
  265                 this, TQ_SLOT( gotPreview( 
const KFileItem *, 
const TQPixmap & ) ) );
 
  266        connect( m_previewJob, TQ_SIGNAL( result( TDEIO::Job * ) ),
 
  267                 this, TQ_SLOT( gotPreviewResult() ) );
 
  270    m_timer->disconnect( 
this );
 
  271    connect(m_timer, TQ_SIGNAL(timeout()), 
this, TQ_SLOT(showTip()));
 
  272    m_timer->start( 400, 
true );
 
  275void KonqFileTip::resizeEvent( TQResizeEvent* event )
 
  277    TQFrame::resizeEvent(event);
 
  281bool KonqFileTip::eventFilter( TQObject *, TQEvent *e )
 
  286        case TQEvent::MouseButtonPress:
 
  287        case TQEvent::MouseButtonRelease:
 
  288        case TQEvent::KeyPress:
 
  289        case TQEvent::KeyRelease:
 
  290        case TQEvent::FocusIn:
 
  291        case TQEvent::FocusOut:
 
  300#include "konq_filetip.moc"