/* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2004-11-22 * Description : a bar widget to display image thumbnails * * Copyright (C) 2004-2005 by Renchi Raju * Copyright (C) 2005-2008 by Gilles Caulier * * 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, 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. * * ============================================================ */ #ifndef THUMBBAR_H #define THUMBBAR_H // TQt includes. #include #include #include // KDE includes. #include // Local includes. #include "digikam_export.h" namespace Digikam { class ThumbBarItem; class ThumbBarToolTip; class ThumbBarViewPriv; class ThumbBarItemPriv; class DIGIKAM_EXPORT ThumbBarToolTipSettings { public: ThumbBarToolTipSettings() { showToolTips = true; showFileName = true; showFileDate = false; showFileSize = false; showImageType = false; showImageDim = true; showPhotoMake = true; showPhotoDate = true; showPhotoFocal = true; showPhotoExpo = true; showPhotoMode = true; showPhotoFlash = false; showPhotoWB = false; }; bool showToolTips; bool showFileName; bool showFileDate; bool showFileSize; bool showImageType; bool showImageDim; bool showPhotoMake; bool showPhotoDate; bool showPhotoFocal; bool showPhotoExpo; bool showPhotoMode; bool showPhotoFlash; bool showPhotoWB; }; // ------------------------------------------------------------------------- class DIGIKAM_EXPORT ThumbBarView : public TQScrollView { Q_OBJECT TQ_OBJECT public: enum Orientation { Horizontal=0, Vertical }; public: ThumbBarView(TQWidget* tqparent, int orientation=Vertical, bool exifRotate=true, ThumbBarToolTipSettings settings=ThumbBarToolTipSettings()); virtual ~ThumbBarView(); int countItems(); KURL::List itemsURLs(); void clear(bool updateView=true); void triggerUpdate(); void removeItem(ThumbBarItem* item); void setSelected(ThumbBarItem* item); void ensureItemVisible(ThumbBarItem* item); void setExifRotate(bool exifRotate); bool getExifRotate(); void setToolTipSettings(const ThumbBarToolTipSettings &settings); ThumbBarToolTipSettings& getToolTipSettings(); ThumbBarItem* currentItem() const; ThumbBarItem* firstItem() const; ThumbBarItem* lastItem() const; ThumbBarItem* findItem(const TQPoint& pos) const; ThumbBarItem* findItemByURL(const KURL& url) const; void refreshThumbs(const KURL::List& urls); void invalidateThumb(ThumbBarItem* item); signals: void signalItemSelected(ThumbBarItem*); void signalURLSelected(const KURL&); void signalItemAdded(); protected: int getOrientation(); int getTileSize(); int getMargin(); void resizeEvent(TQResizeEvent*); void contentsMousePressEvent(TQMouseEvent*); void contentsMouseMoveEvent(TQMouseEvent*); void contentsMouseReleaseEvent(TQMouseEvent*); void contentsWheelEvent(TQWheelEvent*); void insertItem(ThumbBarItem* item); void rearrangeItems(); void repaintItem(ThumbBarItem* item); virtual void viewportPaintEvent(TQPaintEvent*); virtual void startDrag(); protected slots: void slotUpdate(); private slots: void slotGotThumbnail(const KURL&, const TQPixmap&); void slotFailedThumbnail(const KURL&); private: ThumbBarViewPriv* d; friend class ThumbBarItem; }; // ------------------------------------------------------------------------- class DIGIKAM_EXPORT ThumbBarItem { public: ThumbBarItem(ThumbBarView *view, const KURL& url); virtual ~ThumbBarItem(); KURL url() const; ThumbBarItem* next() const; ThumbBarItem* prev() const; int position() const; TQRect rect() const; TQPixmap* pixmap() const; void tqrepaint(); private: ThumbBarItemPriv* d; friend class ThumbBarView; }; // ------------------------------------------------------------------------- class DIGIKAM_EXPORT ThumbBarToolTip : public TQToolTip { public: ThumbBarToolTip(ThumbBarView *tqparent); virtual ~ThumbBarToolTip(){}; protected: const uint m_maxStringLen; TQString m_headBeg; TQString m_headEnd; TQString m_cellBeg; TQString m_cellMid; TQString m_cellEnd; TQString m_cellSpecBeg; TQString m_cellSpecMid; TQString m_cellSpecEnd; ThumbBarView *m_view; protected: TQString breakString(const TQString& input); virtual TQString tipContentExtraData(ThumbBarItem*){ return TQString(); }; private: void maybeTip(const TQPoint& pos); TQString tipContent(ThumbBarItem* item); }; } // NameSpace Digikam #endif /* THUMBBAR_H */