author | mickeyl <mickeyl> | 2003-03-02 17:35:53 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-02 17:35:53 (UTC) |
commit | b3b0d6ec136e550029b9cae7fb714d47071ea5b4 (patch) (unidiff) | |
tree | 9cc1fb741bb548c90915487572c49a1ae48e33eb /noncore/net/wellenreiter/gui | |
parent | d0e64d0c7961de1c3ecb886ae76c6701f268d767 (diff) | |
download | opie-b3b0d6ec136e550029b9cae7fb714d47071ea5b4.zip opie-b3b0d6ec136e550029b9cae7fb714d47071ea5b4.tar.gz opie-b3b0d6ec136e550029b9cae7fb714d47071ea5b4.tar.bz2 |
add child item factory to allow subclasses adding custom data items
Diffstat (limited to 'noncore/net/wellenreiter/gui') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 33 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 26 |
2 files changed, 43 insertions, 16 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 58a04fb..be1245e 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -53,6 +53,11 @@ MScanListView::~MScanListView() | |||
53 | { | 53 | { |
54 | }; | 54 | }; |
55 | 55 | ||
56 | OListViewItem* MScanListView::childFactory() | ||
57 | { | ||
58 | return new MScanListItem( this ); | ||
59 | } | ||
60 | |||
56 | void MScanListView::serializeTo( QDataStream& s) const | 61 | void MScanListView::serializeTo( QDataStream& s) const |
57 | { | 62 | { |
58 | qDebug( "serializing MScanListView" ); | 63 | qDebug( "serializing MScanListView" ); |
@@ -96,7 +101,7 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo | |||
96 | // animate the item | 101 | // animate the item |
97 | 102 | ||
98 | /* | 103 | /* |
99 | 104 | ||
100 | const QPixmap* pixmap = item->pixmap( 0 ); | 105 | const QPixmap* pixmap = item->pixmap( 0 ); |
101 | const QPixmap* nextpixmap = ani2; | 106 | const QPixmap* nextpixmap = ani2; |
102 | if ( pixmap == ani1 ) | 107 | if ( pixmap == ani1 ) |
@@ -112,12 +117,12 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo | |||
112 | //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); | 117 | //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); |
113 | 118 | ||
114 | // we have already seen this net, check all childs if MAC exists | 119 | // we have already seen this net, check all childs if MAC exists |
115 | 120 | ||
116 | network = item; | 121 | network = item; |
117 | 122 | ||
118 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 123 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
119 | assert( item ); // this shouldn't fail | 124 | assert( item ); // this shouldn't fail |
120 | 125 | ||
121 | while ( item && ( item->text( 2 ) != macaddr ) ) | 126 | while ( item && ( item->text( 2 ) != macaddr ) ) |
122 | { | 127 | { |
123 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); | 128 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); |
@@ -198,14 +203,34 @@ MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid | |||
198 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 203 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
199 | } | 204 | } |
200 | 205 | ||
206 | OListViewItem* MScanListItem::childFactory() | ||
207 | { | ||
208 | return new MScanListItem( this ); | ||
209 | } | ||
210 | |||
201 | void MScanListItem::serializeTo( QDataStream& s ) const | 211 | void MScanListItem::serializeTo( QDataStream& s ) const |
202 | { | 212 | { |
213 | qDebug( "serializing MScanListItem" ); | ||
203 | OListViewItem::serializeTo( s ); | 214 | OListViewItem::serializeTo( s ); |
215 | |||
216 | s << _type; | ||
217 | s << (Q_UINT8) _wep; | ||
204 | } | 218 | } |
205 | 219 | ||
206 | void MScanListItem::serializeFrom( QDataStream& s ) | 220 | void MScanListItem::serializeFrom( QDataStream& s ) |
207 | { | 221 | { |
222 | qDebug( "serializing MScanListItem" ); | ||
208 | OListViewItem::serializeFrom( s ); | 223 | OListViewItem::serializeFrom( s ); |
224 | |||
225 | s >> _type; | ||
226 | s >> (Q_UINT8) _wep; | ||
227 | |||
228 | QString name; | ||
229 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | ||
230 | setPixmap( col_type, Resource::loadPixmap( name ) ); | ||
231 | if ( _wep ) | ||
232 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | ||
233 | listView()->triggerUpdate(); | ||
209 | } | 234 | } |
210 | 235 | ||
211 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 236 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 66c701b..222217c 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h | |||
@@ -33,6 +33,7 @@ class MScanListView: public OListView | |||
33 | 33 | ||
34 | void setManufacturerDB( ManufacturerDB* manufacturerdb ); | 34 | void setManufacturerDB( ManufacturerDB* manufacturerdb ); |
35 | 35 | ||
36 | virtual OListViewItem* childFactory(); | ||
36 | virtual void serializeTo( QDataStream& s ) const; | 37 | virtual void serializeTo( QDataStream& s ) const; |
37 | virtual void serializeFrom( QDataStream& s ); | 38 | virtual void serializeFrom( QDataStream& s ); |
38 | 39 | ||
@@ -50,20 +51,20 @@ class MScanListItem: public OListViewItem | |||
50 | { | 51 | { |
51 | public: | 52 | public: |
52 | MScanListItem::MScanListItem( QListView* parent, | 53 | MScanListItem::MScanListItem( QListView* parent, |
53 | QString type, | 54 | QString type = "unknown", |
54 | QString essid, | 55 | QString essid = "unknown", |
55 | QString macaddr, | 56 | QString macaddr = "unknown", |
56 | bool wep, | 57 | bool wep = false, |
57 | int channel, | 58 | int channel = 0, |
58 | int signal ); | 59 | int signal = 0 ); |
59 | 60 | ||
60 | MScanListItem::MScanListItem( QListViewItem* parent, | 61 | MScanListItem::MScanListItem( QListViewItem* parent, |
61 | QString type, | 62 | QString type = "unknown", |
62 | QString essid, | 63 | QString essid = "unknown", |
63 | QString macaddr, | 64 | QString macaddr = "unknown", |
64 | bool wep, | 65 | bool wep = false, |
65 | int channel, | 66 | int channel = 0, |
66 | int signal ); | 67 | int signal = 0 ); |
67 | 68 | ||
68 | 69 | ||
69 | protected: | 70 | protected: |
@@ -86,6 +87,7 @@ class MScanListItem: public OListViewItem | |||
86 | 87 | ||
87 | void setManufacturer( const QString& manufacturer ); | 88 | void setManufacturer( const QString& manufacturer ); |
88 | 89 | ||
90 | virtual OListViewItem* childFactory(); | ||
89 | virtual void serializeTo( QDataStream& s ) const; | 91 | virtual void serializeTo( QDataStream& s ) const; |
90 | virtual void serializeFrom( QDataStream& s ); | 92 | virtual void serializeFrom( QDataStream& s ); |
91 | 93 | ||