You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
622 lines
18 KiB
622 lines
18 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 1999, 2000, 2001, 2002 David Faure <faure@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
12 years ago
|
#include "tdefileivi.h"
|
||
15 years ago
|
#include "kivdirectoryoverlay.h"
|
||
12 years ago
|
#include "kivfreespaceoverlay.h"
|
||
15 years ago
|
#include "konq_iconviewwidget.h"
|
||
|
#include "konq_operations.h"
|
||
|
#include "konq_settings.h"
|
||
|
|
||
15 years ago
|
#include <tqpainter.h>
|
||
15 years ago
|
|
||
|
#include <kurldrag.h>
|
||
|
#include <kiconeffect.h>
|
||
12 years ago
|
#include <tdefileitem.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
|
#include <krun.h>
|
||
12 years ago
|
#include <kservice.h>
|
||
5 years ago
|
#include <kmimetype.h> // for KDEDesktopMimeType
|
||
|
#include <kstandarddirs.h>
|
||
15 years ago
|
|
||
|
#undef Bool
|
||
|
|
||
|
/**
|
||
|
* Private data for KFileIVI
|
||
|
*/
|
||
|
struct KFileIVI::Private
|
||
|
{
|
||
15 years ago
|
TQIconSet icons; // Icon states (cached to prevent re-applying icon effects
|
||
15 years ago
|
// every time)
|
||
15 years ago
|
TQPixmap thumb; // Raw unprocessed thumbnail
|
||
|
TQString m_animatedIcon; // Name of animation
|
||
15 years ago
|
bool m_animated; // Animation currently running ?
|
||
|
KIVDirectoryOverlay* m_directoryOverlay;
|
||
12 years ago
|
KIVFreeSpaceOverlay* m_freeSpaceOverlay;
|
||
15 years ago
|
TQPixmap m_overlay;
|
||
|
TQString m_overlayName;
|
||
12 years ago
|
int m_progress;
|
||
15 years ago
|
};
|
||
|
|
||
|
KFileIVI::KFileIVI( KonqIconViewWidget *iconview, KFileItem* fileitem, int size )
|
||
12 years ago
|
: TDEIconViewItem( iconview, fileitem->text() ),
|
||
|
m_size( size ), m_state( TDEIcon::DefaultState ),
|
||
15 years ago
|
m_bDisabled( false ), m_bThumbnail( false ), m_fileitem( fileitem )
|
||
|
{
|
||
|
d = new KFileIVI::Private;
|
||
|
|
||
|
updatePixmapSize();
|
||
|
setPixmap( m_fileitem->pixmap( m_size, m_state ) );
|
||
|
setDropEnabled( S_ISDIR( m_fileitem->mode() ) );
|
||
|
|
||
|
// Cache entry for the icon effects
|
||
15 years ago
|
d->icons.reset( *pixmap(), TQIconSet::Large );
|
||
15 years ago
|
d->m_animated = false;
|
||
|
|
||
|
// iconName() requires the mimetype to be known
|
||
|
if ( fileitem->isMimeTypeKnown() )
|
||
|
{
|
||
15 years ago
|
TQString icon = fileitem->iconName();
|
||
15 years ago
|
if ( !icon.isEmpty() )
|
||
|
setMouseOverAnimation( icon );
|
||
|
else
|
||
|
setMouseOverAnimation( "unknown" );
|
||
|
}
|
||
12 years ago
|
d->m_progress = -1;
|
||
15 years ago
|
d->m_directoryOverlay = 0;
|
||
12 years ago
|
d->m_freeSpaceOverlay = 0;
|
||
15 years ago
|
}
|
||
|
|
||
|
KFileIVI::~KFileIVI()
|
||
|
{
|
||
|
delete d->m_directoryOverlay;
|
||
12 years ago
|
delete d->m_freeSpaceOverlay;
|
||
15 years ago
|
delete d;
|
||
|
}
|
||
|
|
||
14 years ago
|
void KFileIVI::invalidateThumb( int state, bool redraw )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQIconSet::Mode mode;
|
||
15 years ago
|
switch( state )
|
||
|
{
|
||
12 years ago
|
case TDEIcon::DisabledState:
|
||
15 years ago
|
mode = TQIconSet::Disabled;
|
||
15 years ago
|
break;
|
||
12 years ago
|
case TDEIcon::ActiveState:
|
||
15 years ago
|
mode = TQIconSet::Active;
|
||
15 years ago
|
break;
|
||
12 years ago
|
case TDEIcon::DefaultState:
|
||
15 years ago
|
default:
|
||
15 years ago
|
mode = TQIconSet::Normal;
|
||
15 years ago
|
break;
|
||
|
}
|
||
15 years ago
|
d->icons = TQIconSet();
|
||
12 years ago
|
d->icons.setPixmap( TDEGlobal::iconLoader()->iconEffect()->
|
||
12 years ago
|
apply( d->thumb, TDEIcon::Desktop, state ),
|
||
15 years ago
|
TQIconSet::Large, mode );
|
||
15 years ago
|
m_state = state;
|
||
|
|
||
15 years ago
|
TQIconViewItem::setPixmap( d->icons.pixmap( TQIconSet::Large, mode ),
|
||
15 years ago
|
false, redraw );
|
||
|
}
|
||
|
|
||
|
void KFileIVI::setIcon( int size, int state, bool recalc, bool redraw )
|
||
|
{
|
||
|
m_size = size;
|
||
|
m_bThumbnail = false;
|
||
|
if ( m_bDisabled )
|
||
12 years ago
|
m_state = TDEIcon::DisabledState;
|
||
15 years ago
|
else
|
||
|
m_state = state;
|
||
|
|
||
|
if ( d->m_overlayName.isNull() )
|
||
15 years ago
|
d->m_overlay = TQPixmap();
|
||
15 years ago
|
else {
|
||
|
int halfSize;
|
||
|
if (m_size == 0) {
|
||
12 years ago
|
halfSize = IconSize(TDEIcon::Desktop) / 2;
|
||
15 years ago
|
} else {
|
||
|
halfSize = m_size / 2;
|
||
|
}
|
||
|
d->m_overlay = DesktopIcon(d->m_overlayName, halfSize);
|
||
|
}
|
||
|
|
||
|
setPixmapDirect(m_fileitem->pixmap( m_size, m_state ) , recalc, redraw );
|
||
|
}
|
||
|
|
||
15 years ago
|
void KFileIVI::setOverlay( const TQString& iconName )
|
||
15 years ago
|
{
|
||
|
d->m_overlayName = iconName;
|
||
|
|
||
|
refreshIcon(true);
|
||
|
}
|
||
|
|
||
12 years ago
|
void KFileIVI::setOverlayProgressBar( const int progress )
|
||
|
{
|
||
|
d->m_progress = progress;
|
||
|
|
||
|
refreshIcon(true);
|
||
|
}
|
||
|
|
||
15 years ago
|
KIVDirectoryOverlay* KFileIVI::setShowDirectoryOverlay( bool show )
|
||
|
{
|
||
|
if ( !m_fileitem->isDir() || m_fileitem->iconName() != "folder" )
|
||
|
return 0;
|
||
|
|
||
|
if (show) {
|
||
|
if (!d->m_directoryOverlay)
|
||
|
d->m_directoryOverlay = new KIVDirectoryOverlay(this);
|
||
|
return d->m_directoryOverlay;
|
||
|
} else {
|
||
|
delete d->m_directoryOverlay;
|
||
|
d->m_directoryOverlay = 0;
|
||
15 years ago
|
setOverlay(TQString());
|
||
15 years ago
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool KFileIVI::showDirectoryOverlay( )
|
||
|
{
|
||
|
return (bool)d->m_directoryOverlay;
|
||
|
}
|
||
|
|
||
12 years ago
|
KIVFreeSpaceOverlay* KFileIVI::setShowFreeSpaceOverlay( bool show )
|
||
|
{
|
||
12 years ago
|
if ( !m_fileitem->mimetype().startsWith("media/") ) {
|
||
12 years ago
|
return 0;
|
||
12 years ago
|
}
|
||
12 years ago
|
|
||
|
if (show) {
|
||
|
if (!d->m_freeSpaceOverlay)
|
||
|
d->m_freeSpaceOverlay = new KIVFreeSpaceOverlay(this);
|
||
|
return d->m_freeSpaceOverlay;
|
||
|
} else {
|
||
|
delete d->m_freeSpaceOverlay;
|
||
|
d->m_freeSpaceOverlay = 0;
|
||
|
setOverlayProgressBar(-1);
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool KFileIVI::showFreeSpaceOverlay( )
|
||
|
{
|
||
|
return (bool)d->m_freeSpaceOverlay;
|
||
|
}
|
||
|
|
||
15 years ago
|
void KFileIVI::setPixmapDirect( const TQPixmap& pixmap, bool recalc, bool redraw )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQIconSet::Mode mode;
|
||
15 years ago
|
switch( m_state )
|
||
|
{
|
||
12 years ago
|
case TDEIcon::DisabledState:
|
||
15 years ago
|
mode = TQIconSet::Disabled;
|
||
15 years ago
|
break;
|
||
12 years ago
|
case TDEIcon::ActiveState:
|
||
15 years ago
|
mode = TQIconSet::Active;
|
||
15 years ago
|
break;
|
||
12 years ago
|
case TDEIcon::DefaultState:
|
||
15 years ago
|
default:
|
||
15 years ago
|
mode = TQIconSet::Normal;
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
|
||
|
// We cannot just reset() the iconset here, because setIcon can be
|
||
|
// called with any state and not just normal state. So we just
|
||
|
// create a dummy empty iconset as base object.
|
||
15 years ago
|
d->icons = TQIconSet();
|
||
|
d->icons.setPixmap( pixmap, TQIconSet::Large, mode );
|
||
15 years ago
|
|
||
|
updatePixmapSize();
|
||
15 years ago
|
TQIconViewItem::setPixmap( d->icons.pixmap( TQIconSet::Large, mode ),
|
||
15 years ago
|
recalc, redraw );
|
||
|
}
|
||
|
|
||
|
void KFileIVI::setDisabled( bool disabled )
|
||
|
{
|
||
|
if ( m_bDisabled != disabled )
|
||
|
{
|
||
|
m_bDisabled = disabled;
|
||
12 years ago
|
bool active = ( m_state == TDEIcon::ActiveState );
|
||
|
setEffect( m_bDisabled ? TDEIcon::DisabledState :
|
||
|
( active ? TDEIcon::ActiveState : TDEIcon::DefaultState ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void KFileIVI::setThumbnailPixmap( const TQPixmap & pixmap )
|
||
15 years ago
|
{
|
||
|
m_bThumbnail = true;
|
||
|
d->thumb = pixmap;
|
||
15 years ago
|
// TQIconSet::reset() doesn't seem to clear the other generated pixmaps,
|
||
|
// so we just create a blank TQIconSet here
|
||
|
d->icons = TQIconSet();
|
||
12 years ago
|
d->icons.setPixmap( TDEGlobal::iconLoader()->iconEffect()->
|
||
12 years ago
|
apply( pixmap, TDEIcon::Desktop, TDEIcon::DefaultState ),
|
||
15 years ago
|
TQIconSet::Large, TQIconSet::Normal );
|
||
15 years ago
|
|
||
12 years ago
|
m_state = TDEIcon::DefaultState;
|
||
15 years ago
|
|
||
|
// Recalc when setting this pixmap!
|
||
|
updatePixmapSize();
|
||
15 years ago
|
TQIconViewItem::setPixmap( d->icons.pixmap( TQIconSet::Large,
|
||
|
TQIconSet::Normal ), true );
|
||
15 years ago
|
}
|
||
|
|
||
|
void KFileIVI::setActive( bool active )
|
||
|
{
|
||
|
if ( active )
|
||
12 years ago
|
setEffect( TDEIcon::ActiveState );
|
||
15 years ago
|
else
|
||
12 years ago
|
setEffect( m_bDisabled ? TDEIcon::DisabledState : TDEIcon::DefaultState );
|
||
15 years ago
|
}
|
||
|
|
||
|
void KFileIVI::setEffect( int state )
|
||
|
{
|
||
15 years ago
|
TQIconSet::Mode mode;
|
||
15 years ago
|
switch( state )
|
||
|
{
|
||
12 years ago
|
case TDEIcon::DisabledState:
|
||
15 years ago
|
mode = TQIconSet::Disabled;
|
||
15 years ago
|
break;
|
||
12 years ago
|
case TDEIcon::ActiveState:
|
||
15 years ago
|
mode = TQIconSet::Active;
|
||
15 years ago
|
break;
|
||
12 years ago
|
case TDEIcon::DefaultState:
|
||
15 years ago
|
default:
|
||
15 years ago
|
mode = TQIconSet::Normal;
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
// Do not update if the fingerprint is identical (prevents flicker)!
|
||
|
|
||
12 years ago
|
TDEIconEffect *effect = TDEGlobal::iconLoader()->iconEffect();
|
||
15 years ago
|
|
||
12 years ago
|
bool haveEffect = effect->hasEffect( TDEIcon::Desktop, m_state ) !=
|
||
|
effect->hasEffect( TDEIcon::Desktop, state );
|
||
15 years ago
|
|
||
|
//kdDebug(1203) << "desktop;defaultstate=" <<
|
||
12 years ago
|
// effect->fingerprint(TDEIcon::Desktop, TDEIcon::DefaultState) <<
|
||
15 years ago
|
// endl;
|
||
|
//kdDebug(1203) << "desktop;activestate=" <<
|
||
12 years ago
|
// effect->fingerprint(TDEIcon::Desktop, TDEIcon::ActiveState) <<
|
||
15 years ago
|
// endl;
|
||
|
|
||
|
if( haveEffect &&
|
||
12 years ago
|
effect->fingerprint( TDEIcon::Desktop, m_state ) !=
|
||
|
effect->fingerprint( TDEIcon::Desktop, state ) )
|
||
15 years ago
|
{
|
||
|
// Effects on are not applied until they are first accessed to
|
||
|
// save memory. Do this now when needed
|
||
|
if( m_bThumbnail )
|
||
|
{
|
||
15 years ago
|
if( d->icons.isGenerated( TQIconSet::Large, mode ) )
|
||
12 years ago
|
d->icons.setPixmap( effect->apply( d->thumb, TDEIcon::Desktop, state ),
|
||
15 years ago
|
TQIconSet::Large, mode );
|
||
15 years ago
|
}
|
||
|
else
|
||
|
{
|
||
15 years ago
|
if( d->icons.isGenerated( TQIconSet::Large, mode ) )
|
||
15 years ago
|
d->icons.setPixmap( m_fileitem->pixmap( m_size, state ),
|
||
15 years ago
|
TQIconSet::Large, mode );
|
||
15 years ago
|
}
|
||
15 years ago
|
TQIconViewItem::setPixmap( d->icons.pixmap( TQIconSet::Large, mode ) );
|
||
15 years ago
|
}
|
||
|
m_state = state;
|
||
|
}
|
||
|
|
||
|
void KFileIVI::refreshIcon( bool redraw )
|
||
|
{
|
||
12 years ago
|
if (!isThumbnail()) {
|
||
15 years ago
|
setIcon( m_size, m_state, true, redraw );
|
||
12 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
|
void KFileIVI::invalidateThumbnail()
|
||
|
{
|
||
15 years ago
|
d->thumb = TQPixmap();
|
||
15 years ago
|
}
|
||
|
|
||
|
bool KFileIVI::isThumbnailInvalid() const
|
||
|
{
|
||
|
return d->thumb.isNull();
|
||
|
}
|
||
|
|
||
15 years ago
|
bool KFileIVI::acceptDrop( const TQMimeSource *mime ) const
|
||
15 years ago
|
{
|
||
|
if ( mime->provides( "text/uri-list" ) ) // We're dragging URLs
|
||
|
{
|
||
|
if ( m_fileitem->acceptsDrops() ) // Directory, executables, ...
|
||
|
return true;
|
||
|
|
||
|
// Use cache
|
||
|
KURL::List uris = ( static_cast<KonqIconViewWidget*>(iconView()) )->dragURLs();
|
||
|
|
||
|
// Check if we want to drop something on itself
|
||
|
// (Nothing will happen, but it's a convenient way to move icons)
|
||
|
KURL::List::Iterator it = uris.begin();
|
||
|
for ( ; it != uris.end() ; it++ )
|
||
|
{
|
||
|
if ( m_fileitem->url().equals( *it, true /*ignore trailing slashes*/ ) )
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
15 years ago
|
return TQIconViewItem::acceptDrop( mime );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KFileIVI::setKey( const TQString &key )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString theKey = key;
|
||
15 years ago
|
|
||
15 years ago
|
TQVariant sortDirProp = iconView()->property( "sortDirectoriesFirst" );
|
||
15 years ago
|
|
||
15 years ago
|
bool isdir = ( S_ISDIR( m_fileitem->mode() ) && ( !sortDirProp.isValid() || ( sortDirProp.type() == TQVariant::Bool && sortDirProp.toBool() ) ) );
|
||
15 years ago
|
|
||
|
// The order is: .dir (0), dir (1), .file (2), file (3)
|
||
|
int sortChar = isdir ? 1 : 3;
|
||
|
if ( m_fileitem->text()[0] == '.' )
|
||
|
--sortChar;
|
||
|
|
||
|
if ( !iconView()->sortDirection() ) // reverse sorting
|
||
|
sortChar = 3 - sortChar;
|
||
|
|
||
15 years ago
|
theKey.prepend( TQChar( sortChar + '0' ) );
|
||
15 years ago
|
|
||
15 years ago
|
TQIconViewItem::setKey( theKey );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KFileIVI::dropped( TQDropEvent *e, const TQValueList<TQIconDragItem> & )
|
||
15 years ago
|
{
|
||
|
KonqOperations::doDrop( item(), item()->url(), e, iconView() );
|
||
|
}
|
||
|
|
||
|
void KFileIVI::returnPressed()
|
||
|
{
|
||
|
if ( static_cast<KonqIconViewWidget*>(iconView())->isDesktop() ) {
|
||
|
KURL url = m_fileitem->url();
|
||
12 years ago
|
if (url.protocol() == "media") {
|
||
5 years ago
|
TQString mimetype = m_fileitem->mimetype();
|
||
|
TQString lockingAction = TQString::null;
|
||
|
if (mimetype.contains("encrypted_locked")) {
|
||
|
lockingAction = "konqueror/servicemenus/media_unlock.desktop";
|
||
|
}
|
||
|
else if (mimetype.contains("encrypted_unlocked")) {
|
||
|
lockingAction = "konqueror/servicemenus/media_lock.desktop";
|
||
|
}
|
||
|
if (!lockingAction.isEmpty()) {
|
||
|
TQString lockingService = TDEGlobal::dirs()->findResource("data", lockingAction);
|
||
|
if (!lockingService.isEmpty()) {
|
||
|
TQValueList<KDEDesktopMimeType::Service> serviceList = KDEDesktopMimeType::userDefinedServices(lockingService, m_fileitem->isLocalFile());
|
||
|
if (serviceList.count() == 1) {
|
||
|
KURL::List m_lstURLs;
|
||
|
m_lstURLs.append(m_fileitem->url());
|
||
|
KDEDesktopMimeType::executeService(m_lstURLs, serviceList[0]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
(void) new KRun( url, m_fileitem->mode(), m_fileitem->isLocalFile() );
|
||
|
}
|
||
12 years ago
|
}
|
||
|
else {
|
||
|
// When clicking on a link to e.g. $HOME from the desktop, we want to open $HOME
|
||
|
// Symlink resolution must only happen on the desktop though (#63014)
|
||
|
if ( m_fileitem->isLink() && url.isLocalFile() ) {
|
||
|
url = KURL( url, m_fileitem->linkDest() );
|
||
|
}
|
||
|
|
||
|
(void) new KRun( url, m_fileitem->mode(), m_fileitem->isLocalFile() );
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
15 years ago
|
m_fileitem->run();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
void KFileIVI::paintItem( TQPainter *p, const TQColorGroup &c )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQColorGroup cg = updateColors(c);
|
||
15 years ago
|
paintFontUpdate( p );
|
||
|
|
||
|
//*** TEMPORARY CODE - MUST BE MADE CONFIGURABLE FIRST - Martijn
|
||
|
// SET UNDERLINE ON HOVER ONLY
|
||
|
/*if ( ( ( KonqIconViewWidget* ) iconView() )->m_pActiveItem == this )
|
||
|
{
|
||
15 years ago
|
TQFont f( p->font() );
|
||
15 years ago
|
f.setUnderline( TRUE );
|
||
|
p->setFont( f );
|
||
|
}*/
|
||
|
|
||
12 years ago
|
TDEIconViewItem::paintItem( p, cg );
|
||
15 years ago
|
paintOverlay(p);
|
||
12 years ago
|
paintOverlayProgressBar(p);
|
||
15 years ago
|
|
||
|
}
|
||
|
|
||
15 years ago
|
void KFileIVI::paintOverlay( TQPainter *p ) const
|
||
15 years ago
|
{
|
||
|
if ( !d->m_overlay.isNull() ) {
|
||
15 years ago
|
TQRect rect = pixmapRect(true);
|
||
15 years ago
|
p->drawPixmap(x() + rect.x() , y() + pixmapRect().height() - d->m_overlay.height(), d->m_overlay);
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void KFileIVI::paintOverlayProgressBar( TQPainter *p ) const
|
||
|
{
|
||
|
if (d->m_progress != -1) {
|
||
|
// // Pie chart
|
||
|
// TQRect rect = pixmapRect(true);
|
||
|
// rect.setX(x() + rect.x());
|
||
|
// rect.setY(y() + rect.y() + ((pixmapRect().height()*3)/4));
|
||
|
// rect.setWidth(pixmapRect().width()/4);
|
||
|
// rect.setHeight(pixmapRect().height()/4);
|
||
|
//
|
||
|
// p->save();
|
||
|
//
|
||
|
// p->setPen(TQPen::NoPen);
|
||
|
// p->setBrush(TQt::red);
|
||
|
// p->drawEllipse(rect);
|
||
|
// p->setBrush(TQt::green);
|
||
|
// p->drawPie(rect, 1440, (((100-d->m_progress)*5760)/100));
|
||
|
|
||
12 years ago
|
// // Horizontal progress bar
|
||
|
// TQRect rect = pixmapRect(true);
|
||
|
// int verticalOffset = 0;
|
||
|
// int usedBarWidth = ((d->m_progress*pixmapRect().width())/100);
|
||
|
// int endPosition = x() + rect.x() + usedBarWidth;
|
||
|
//
|
||
|
// p->save();
|
||
|
//
|
||
|
// p->setPen(TQPen::NoPen);
|
||
|
// p->setBrush(TQt::red);
|
||
|
// p->drawRect(TQRect(x() + rect.x(), y() + rect.y() + (pixmapRect().height() - verticalOffset), usedBarWidth, 1));
|
||
|
// p->setBrush(TQt::green);
|
||
|
// p->drawRect(TQRect(endPosition, y() + rect.y() + (pixmapRect().height() - verticalOffset), pixmapRect().width() - usedBarWidth, 1));
|
||
|
|
||
|
// Vertical progress bar
|
||
12 years ago
|
TQRect rect = pixmapRect(true);
|
||
12 years ago
|
int horizontalOffset = 0;
|
||
|
int usedBarHeight = (((100-d->m_progress)*pixmapRect().height())/100);
|
||
|
int endPosition = y() + rect.y() + usedBarHeight;
|
||
12 years ago
|
|
||
|
p->save();
|
||
|
|
||
|
p->setPen(TQPen::NoPen);
|
||
|
p->setBrush(TQt::green);
|
||
12 years ago
|
p->drawRect(TQRect(x() + rect.x() + (pixmapRect().width() - horizontalOffset), y() + rect.y(), 1, usedBarHeight));
|
||
|
p->setBrush(TQt::red);
|
||
|
p->drawRect(TQRect(x() + rect.x() + (pixmapRect().width() - horizontalOffset), endPosition, 1, pixmapRect().height() - usedBarHeight));
|
||
12 years ago
|
|
||
|
p->restore();
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void KFileIVI::paintFontUpdate( TQPainter *p ) const
|
||
15 years ago
|
{
|
||
|
if ( m_fileitem->isLink() )
|
||
|
{
|
||
15 years ago
|
TQFont f( p->font() );
|
||
15 years ago
|
f.setItalic( TRUE );
|
||
|
p->setFont( f );
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
TQColorGroup KFileIVI::updateColors( const TQColorGroup &c ) const
|
||
15 years ago
|
{
|
||
15 years ago
|
TQColorGroup cg( c );
|
||
|
cg.setColor( TQColorGroup::Text, static_cast<KonqIconViewWidget*>(iconView())->itemColor() );
|
||
15 years ago
|
return cg;
|
||
|
}
|
||
|
|
||
|
bool KFileIVI::move( int x, int y )
|
||
|
{
|
||
|
if ( static_cast<KonqIconViewWidget*>(iconView())->isDesktop() ) {
|
||
|
if ( x < 5 )
|
||
|
x = 5;
|
||
|
if ( x > iconView()->viewport()->width() - ( width() + 5 ) )
|
||
|
x = iconView()->viewport()->width() - ( width() + 5 );
|
||
|
if ( y < 5 )
|
||
|
y = 5;
|
||
|
if ( y > iconView()->viewport()->height() - ( height() + 5 ) )
|
||
|
y = iconView()->viewport()->height() - ( height() + 5 );
|
||
|
}
|
||
15 years ago
|
return TQIconViewItem::move( x, y );
|
||
15 years ago
|
}
|
||
|
|
||
|
bool KFileIVI::hasAnimation() const
|
||
|
{
|
||
|
return !d->m_animatedIcon.isEmpty() && !m_bThumbnail;
|
||
|
}
|
||
|
|
||
15 years ago
|
void KFileIVI::setMouseOverAnimation( const TQString& movieFileName )
|
||
15 years ago
|
{
|
||
|
if ( !movieFileName.isEmpty() )
|
||
|
{
|
||
12 years ago
|
//kdDebug(1203) << "TDEIconViewItem::setMouseOverAnimation " << movieFileName << endl;
|
||
15 years ago
|
d->m_animatedIcon = movieFileName;
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KFileIVI::mouseOverAnimation() const
|
||
15 years ago
|
{
|
||
|
return d->m_animatedIcon;
|
||
|
}
|
||
|
|
||
|
bool KFileIVI::isAnimated() const
|
||
|
{
|
||
|
return d->m_animated;
|
||
|
}
|
||
|
|
||
|
void KFileIVI::setAnimated( bool a )
|
||
|
{
|
||
|
d->m_animated = a;
|
||
|
}
|
||
|
|
||
15 years ago
|
int KFileIVI::compare( TQIconViewItem *i ) const
|
||
15 years ago
|
{
|
||
|
KonqIconViewWidget* view = static_cast<KonqIconViewWidget*>(iconView());
|
||
|
if ( view->caseInsensitiveSort() )
|
||
|
return key().localeAwareCompare( i->key() );
|
||
|
else
|
||
|
return view->m_pSettings->caseSensitiveCompare( key(), i->key() );
|
||
|
}
|
||
|
|
||
|
void KFileIVI::updatePixmapSize()
|
||
|
{
|
||
|
int size = m_size ? m_size :
|
||
12 years ago
|
TDEGlobal::iconLoader()->currentSize( TDEIcon::Desktop );
|
||
15 years ago
|
|
||
|
KonqIconViewWidget* view = static_cast<KonqIconViewWidget*>( iconView() );
|
||
|
|
||
10 years ago
|
bool mimeDetermined = false;
|
||
|
if ( m_fileitem->isMimeTypeKnown() ) {
|
||
|
mimeDetermined = true;
|
||
15 years ago
|
}
|
||
10 years ago
|
|
||
|
if (mimeDetermined) {
|
||
|
bool changed = false;
|
||
|
if ( view && view->canPreview( item() ) ) {
|
||
|
int previewSize = view->previewIconSize( size );
|
||
|
if (previewSize != size) {
|
||
|
setPixmapSize( TQSize( previewSize, previewSize ) );
|
||
|
changed = true;
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
TQSize pixSize = TQSize( size, size );
|
||
|
if ( pixSize != pixmapSize() ) {
|
||
|
setPixmapSize( pixSize );
|
||
|
changed = true;
|
||
|
}
|
||
|
}
|
||
|
if (changed) {
|
||
|
view->adjustItems();
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
TQSize pixSize = TQSize( size, size );
|
||
|
if ( pixSize != pixmapSize() ) {
|
||
|
setPixmapSize( pixSize );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KFileIVI::mimeTypeAndIconDetermined()
|
||
|
{
|
||
|
updatePixmapSize();
|
||
15 years ago
|
}
|