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
|
/** -*- C++ -*-
@file adept/desktoplist.h
@author Peter Rockai <me@mornfall.net>
*/
#include <qimage.h>
#include <klocale.h>
#include <apt-front/cache/entity/desktop.h>
#include <adept/extendablelist.h>
#include <adept/desktopentryui.h>
#ifndef EPT_DESKTOPLIST_H
#define EPT_DESKTOPLIST_H
class QPopupMenu;
namespace adept {
using namespace aptFront;
using namespace aptFront::cache;
class DesktopItem;
class DesktopList : public ExtendableList, public cache::Observer
{
Q_OBJECT
public:
typedef utils::Range< entity::Desktop > Range;
DesktopList( QWidget *parent = 0, const char *name = 0 );
void insertRange( Range );
QPixmap emptyIcon() { return m_emptyIcon; }
void polishing();
void polished();
void setTitle( QString s ) {
setColumnText( 0, i18n( "Application (" ) + s + i18n( ")" ) );
}
void setDisplayCheckboxes( bool d ) { m_displayCheckboxes = d; }
bool displayCheckboxes() { return m_displayCheckboxes; }
virtual void notifyPostChange( cache::component::Base * );
void fireRequest( entity::Package p, component::State::Action a ) {
emit request( p, a );
}
protected slots:
void processClick( QListViewItem *, const QPoint &, int );
signals:
void request( cache::entity::Package, cache::component::State::Action );
void showDescription( cache::entity::Desktop );
protected:
Range m_range;
QPixmap m_emptyIcon;
int m_polishing;
bool m_displayCheckboxes;
};
class DesktopEntry : public DesktopEntryUi
{
Q_OBJECT
public:
DesktopEntry( QWidget * = 0, const char * = 0 );
DesktopItem *item() const;
entity::Desktop entity() const;
void setItem( ExtendableItem * );
entity::Package package() { return entity().package(); }
virtual void notifyPostChange();
virtual void resize( int, int );
// virtual void polish();
public slots:
void toggled();
protected:
virtual void mousePressEvent( QMouseEvent *e );
virtual void mouseReleaseEvent( QMouseEvent *e );
virtual void showEvent( QShowEvent * );
bool m_polished;
};
class DesktopItem : public ExtendableItem
{
public:
ItemExtender *createExtender();
DesktopItem( DesktopList *l )
: ExtendableItem( l ), m_delayedDone( false )
{
}
DesktopItem( DesktopList *v, DesktopItem *i )
: ExtendableItem( v, i ), m_delayedDone( false )
{
}
void setup() {
ExtendableItem::setup();
if (m_delayedDone)
return;
m_delayedDone = true;
showExtender();
}
DesktopList *list() { return dynamic_cast< DesktopList * >( listView() ); }
QString text( int ) const { return QString( "you shouldn't see this" ); }
entity::Desktop entity() const { return m_entity; }
void setEntity( entity::Desktop e ) { m_entity = e; }
virtual bool less( const ExtendableItem *other ) const {
const DesktopItem *o = dynamic_cast< const DesktopItem * >( other );
return entity() < o->entity();
}
protected:
entity::Desktop m_entity;
bool m_delayedDone:1;
};
}
#endif
|