blob: 992633f7535cc0f9f7f9231ce051c4c9b729d104 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/***************************************************************************
copyright : (C) 2002-2006 by Robby Stephenson
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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 <tqintdict.h>
namespace Tellico {
class EntryIconViewItem;
namespace Data {
class Collection;
}
class ListViewComparison;
/**
* @author Robby Stephenson
*/
class EntryIconView : public TDEIconView, public Observer {
TQ_OBJECT
friend class EntryIconViewItem;
public:
EntryIconView(TQWidget* 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 TQString& imageField();
const TQString& sortField();
void setMaxAllowedIconWidth(int width);
int maxAllowedIconWidth() const { return m_maxAllowedIconWidth; }
const TQPixmap& defaultPixmap();
/**
* Returns a list of the currently selected items;
*
* @return The list of selected items
*/
const TQPtrList<EntryIconViewItem>& selectedItems() const { return m_selectedItems; }
int compare(const EntryIconViewItem* item1, EntryIconViewItem* item2);
private slots:
void slotSelectionChanged();
void slotDoubleClicked(TQIconViewItem* item);
void slotShowContextMenu(TQIconViewItem* item, const TQPoint& 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 TQPtrList<EntryIconViewItem> m_selectedItems;
void findImageField();
void fillView();
Data::CollPtr m_coll;
Data::EntryVec m_entries;
TQString m_imageField;
TQIntDict<TQPixmap> m_defaultPixmaps;
int m_maxAllowedIconWidth;
int m_maxIconWidth;
int m_maxIconHeight;
ListViewComparison* m_comparison;
};
class EntryIconViewItem : public TDEIconViewItem {
public:
EntryIconViewItem(EntryIconView* parent, Data::EntryPtr entry);
~EntryIconViewItem();
EntryIconView* iconView() const { return static_cast<EntryIconView*>(TDEIconViewItem::iconView()); }
EntryIconViewItem* nextItem() const { return static_cast<EntryIconViewItem*>(TDEIconViewItem::nextItem()); }
Data::EntryPtr entry() const { return m_entry; }
virtual void setSelected(bool s, bool cb);
virtual void setSelected(bool s);
virtual TQString key() const;
virtual int compare(TQIconViewItem* item_) const;
bool usesImage() const { return m_usesImage; }
void updatePixmap();
void update();
protected:
virtual void calcRect(const TQString& text = TQString());
virtual void paintItem(TQPainter* p, const TQColorGroup& cg);
virtual void paintFocus(TQPainter* p, const TQColorGroup& cg);
void paintPixmap(TQPainter* p, const TQColorGroup& cg);
void paintText(TQPainter* p, const TQColorGroup& cg);
private:
Data::EntryPtr m_entry;
bool m_usesImage : 1;
};
} // end namespace
#endif
|