summaryrefslogtreecommitdiffstats
path: root/src/entryiconview.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 19:17:32 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 19:17:32 +0000
commite38d2351b83fa65c66ccde443777647ef5cb6cff (patch)
tree1897fc20e9f73a81c520a5b9f76f8ed042124883 /src/entryiconview.h
downloadtellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.tar.gz
tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.zip
Added KDE3 version of Tellico
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1097620 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/entryiconview.h')
-rw-r--r--src/entryiconview.h133
1 files changed, 133 insertions, 0 deletions
diff --git a/src/entryiconview.h b/src/entryiconview.h
new file mode 100644
index 0000000..335818c
--- /dev/null
+++ b/src/entryiconview.h
@@ -0,0 +1,133 @@
+/***************************************************************************
+ copyright : (C) 2002-2006 by Robby Stephenson
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of version 2 of the GNU General Public License as *
+ * published by the Free Software Foundation; *
+ * *
+ ***************************************************************************/
+
+#ifndef TELLICOENTRYICONVIEW_H
+#define TELLICOENTRYICONVIEW_H
+
+#include "observer.h"
+#include "entry.h"
+
+#include <kiconview.h>
+
+#include <qintdict.h>
+
+namespace Tellico {
+ class EntryIconViewItem;
+ namespace Data {
+ class Collection;
+ }
+ class ListViewComparison;
+
+/**
+ * @author Robby Stephenson
+ */
+class EntryIconView : public KIconView, public Observer {
+Q_OBJECT
+
+friend class EntryIconViewItem;
+
+public:
+ EntryIconView(QWidget* parent, const char* name = 0);
+ ~EntryIconView();
+
+ EntryIconViewItem* firstItem() const;
+
+ virtual void clear();
+ void refresh();
+ void showEntries(const Data::EntryVec& entries);
+ /**
+ * Adds a new list item showing the details for a entry.
+ *
+ * @param entry A pointer to the entry
+ */
+ virtual void addEntries(Data::EntryVec entries);
+ virtual void modifyEntries(Data::EntryVec entries);
+ virtual void removeEntries(Data::EntryVec entries);
+
+ const QString& imageField();
+ const QString& sortField();
+ void setMaxAllowedIconWidth(int width);
+ int maxAllowedIconWidth() const { return m_maxAllowedIconWidth; }
+
+ const QPixmap& defaultPixmap();
+ /**
+ * Returns a list of the currently selected items;
+ *
+ * @return The list of selected items
+ */
+ const QPtrList<EntryIconViewItem>& selectedItems() const { return m_selectedItems; }
+
+ int compare(const EntryIconViewItem* item1, EntryIconViewItem* item2);
+
+private slots:
+ void slotSelectionChanged();
+ void slotDoubleClicked(QIconViewItem* item);
+ void slotShowContextMenu(QIconViewItem* item, const QPoint& point);
+ void slotSortMenuActivated(int id);
+
+private:
+ /**
+ * Updates the pointer list.
+ *
+ * @param item The item being selected or deselected
+ * @param s Selected or not
+ */
+ void updateSelected(EntryIconViewItem* item, bool s) const;
+ mutable QPtrList<EntryIconViewItem> m_selectedItems;
+
+ void findImageField();
+ void fillView();
+
+ Data::CollPtr m_coll;
+ Data::EntryVec m_entries;
+ QString m_imageField;
+ QIntDict<QPixmap> m_defaultPixmaps;
+ int m_maxAllowedIconWidth;
+ int m_maxIconWidth;
+ int m_maxIconHeight;
+ ListViewComparison* m_comparison;
+};
+
+class EntryIconViewItem : public KIconViewItem {
+public:
+ EntryIconViewItem(EntryIconView* parent, Data::EntryPtr entry);
+ ~EntryIconViewItem();
+
+ EntryIconView* iconView() const { return static_cast<EntryIconView*>(KIconViewItem::iconView()); }
+ EntryIconViewItem* nextItem() const { return static_cast<EntryIconViewItem*>(KIconViewItem::nextItem()); }
+
+ Data::EntryPtr entry() const { return m_entry; }
+ virtual void setSelected(bool s, bool cb);
+ virtual void setSelected(bool s);
+ virtual QString key() const;
+ virtual int compare(QIconViewItem* item_) const;
+
+ bool usesImage() const { return m_usesImage; }
+ void updatePixmap();
+
+ void update();
+
+protected:
+ virtual void calcRect(const QString& text = QString::null);
+ virtual void paintItem(QPainter* p, const QColorGroup& cg);
+ virtual void paintFocus(QPainter* p, const QColorGroup& cg);
+ void paintPixmap(QPainter* p, const QColorGroup& cg);
+ void paintText(QPainter* p, const QColorGroup& cg);
+
+private:
+ Data::EntryPtr m_entry;
+ bool m_usesImage : 1;
+};
+
+} // end namespace
+#endif