/*
Gwenview - A simple image viewer for TDE
Copyright 2000-2004 Aur�lien G�teau

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program 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 General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/
#ifndef FILETHUMBNAILVIEW_H
#define FILETHUMBNAILVIEW_H

// TQt includes
#include <tqguardedptr.h>
#include <tqptrlist.h>

// KDE includes
#include <kiconview.h>

// Our includes
#include "fileviewbase.h"
#include "busylevelmanager.h"
#include "libgwenview_export.h"

class TQDragEnterEvent;
class TQIconViewItem;
class TQPopupMenu;
class TQShowEvent;

class TDEConfig;
class KFileItem;
typedef TQPtrList<KFileItem> KFileItemList;

namespace Gwenview {
class FileThumbnailViewItem;

class LIBGWENVIEW_EXPORT FileThumbnailView : public TDEIconView, public FileViewBase {
TQ_OBJECT
  
	friend class FileThumbnailViewItem;
	
public:
	enum ItemDetail { FILENAME=1, FILESIZE=2, FILEDATE=4, IMAGESIZE=8 };
	FileThumbnailView(TQWidget* parent);
	~FileThumbnailView();

	TQWidget* widget() { return this; }

	// KFileView methods
	void clearView();
	void clearSelection() { TQIconView::clearSelection(); }
	void insertItem(KFileItem* item);
	void ensureItemVisible(const KFileItem* item);
	void setCurrentItem(const KFileItem* item);
	void setSelected(const KFileItem* item,bool enable);
	bool isSelected(const KFileItem* item) const;
	void removeItem(const KFileItem* item);
	void updateView(const KFileItem* item, bool metaInfoOnly);
	void setSorting(TQDir::SortSpec);

	KFileItem* firstFileItem() const;
	KFileItem* prevItem( const KFileItem*) const;
	KFileItem* currentFileItem() const;
	KFileItem* nextItem( const KFileItem*) const;

	void setThumbnailSize(int value);
	int thumbnailSize() const;

	void setMarginSize(int value);
	int marginSize() const;

	void setItemDetails(int);
	int itemDetails() const;
	
	void setItemTextPos(ItemTextPos);

	void setShownFileItem(KFileItem*);

	void updateThumbnail(const KFileItem*);

public slots:
	void setThumbnailPixmap(const KFileItem*,const TQPixmap&, const TQSize&);
	void startThumbnailUpdate();
	void stopThumbnailUpdate();

	void showThumbnailDetailsDialog();

	void sortView();

signals:
	void dropped(TQDropEvent*, KFileItem* target);

protected:
	void showEvent(TQShowEvent*);
	void contentsDragEnterEvent(TQDragEnterEvent*);
	void startDrag();
	virtual void keyPressEvent( TQKeyEvent* );

private:
	struct Private;
	Private* d;

	void updateGrid();
	TQPixmap createItemPixmap(const KFileItem*) const;
	void doStartThumbnailUpdate(const KFileItemList*);
	void setSortingKey(TQIconViewItem*, const KFileItem*);
	void updateVisibilityInfo( int x, int y );

private slots:
	void slotClicked(TQIconViewItem*);
	void slotDoubleClicked(TQIconViewItem*);
	void slotDropped(TQDropEvent*);
	void slotContentsMoving( int, int );
	void slotCurrentChanged(TQIconViewItem*);
	void slotBusyLevelChanged( BusyLevel );
	void slotUpdateEnded();
	void prefetchDone();
};


} // namespace
#endif