summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/cornucopia/olistview.cpp14
-rw-r--r--noncore/net/wellenreiter/cornucopia/olistview.h26
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp33
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h26
4 files changed, 68 insertions, 31 deletions
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp
index f2d3730..c292eb9 100644
--- a/noncore/net/wellenreiter/cornucopia/olistview.cpp
+++ b/noncore/net/wellenreiter/cornucopia/olistview.cpp
@@ -122,8 +122,13 @@ void OListView::setColumnSeparator( const QPen& p )
m_columnSeparator = p;
repaint();
}
+OListViewItem* OListView::childFactory()
+{
+ return new OListViewItem( this );
+}
+
#ifndef QT_NO_DATASTREAM
void OListView::serializeTo( QDataStream& s ) const
{
#warning Caution... the binary format is still under construction...
@@ -179,9 +184,9 @@ void OListView::serializeFrom( QDataStream& s )
qDebug( "read number of items = %d", items );
for ( int i = 0; i < items; ++i )
{
- OListViewItem* item = new OListViewItem( this );
+ OListViewItem* item = childFactory();
s >> *item;
}
qDebug( "OListView loaded." );
@@ -336,8 +341,13 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in
p->setPen( pen );
p->drawLine( width-1, 0, width-1, height() );
}
+OListViewItem* OListViewItem::childFactory()
+{
+ return new OListViewItem( this );
+}
+
#ifndef QT_NO_DATASTREAM
void OListViewItem::serializeTo( QDataStream& s ) const
{
#warning Caution... the binary format is still under construction...
@@ -387,9 +397,9 @@ void OListViewItem::serializeFrom( QDataStream& s )
qDebug( "read number of items = %d", items );
for ( int i = 0; i < items; ++i )
{
- OListViewItem* item = new OListViewItem( this );
+ OListViewItem* item = childFactory();
s >> (*item);
}
qDebug( "OListViewItem loaded." );
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.h b/noncore/net/wellenreiter/cornucopia/olistview.h
index 9df5500..8911e22 100644
--- a/noncore/net/wellenreiter/cornucopia/olistview.h
+++ b/noncore/net/wellenreiter/cornucopia/olistview.h
@@ -37,9 +37,9 @@
#include <qlistview.h>
#include <qpen.h>
#include <qdatastream.h>
-class OListViewFactory;
+class OListViewItem;
/**
* A @ref QListView variant featuring visual and functional enhancements
* like an alternate background for odd rows, an autostretch mode
@@ -114,8 +114,14 @@ class OListViewFactory;
* @return the column separator pen
*/
const QPen& columnSeparator() const;
+ /**
+ * create a list view item as child of this object
+ * @return the new object
+ */
+ virtual OListViewItem* childFactory();
+
#ifndef QT_NO_DATASTREAM
/**
* serialize this object to a @ref QDataStream
* @param s the stream used to serialize this object.
@@ -128,24 +134,12 @@ class OListViewFactory;
*/
virtual void serializeFrom( QDataStream& s );
#endif
- /**
- * returns a factory for OListView classes
- * creates one on the fly if it doesn't exist
- * @return the XML Factory
- */
- #ifndef QT_NO_XML
- //OListViewFactory* Factory();
- #endif
-
private:
QColor m_alternateBackground;
bool m_fullWidth;
QPen m_columnSeparator;
- #ifndef QT_NO_XML
- //OListViewFactory* m_Factory;
- #endif
};
#ifndef QT_NO_DATASTREAM
/**
@@ -200,8 +194,14 @@ class OListViewItem: public QListViewItem
bool isAlternate();
void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
void init();
+ /**
+ * create a list view item as child of this object
+ * @return the new object
+ */
+ virtual OListViewItem* childFactory();
+
#ifndef QT_NO_DATASTREAM
/**
* serialize this object to or from a @ref QDataStream
* @param s the stream used to serialize this object.
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
@@ -52,8 +52,13 @@ MScanListView::MScanListView( QWidget* parent, const char* name )
MScanListView::~MScanListView()
{
};
+OListViewItem* MScanListView::childFactory()
+{
+ return new MScanListItem( this );
+}
+
void MScanListView::serializeTo( QDataStream& s) const
{
qDebug( "serializing MScanListView" );
OListView::serializeTo( s );
@@ -95,9 +100,9 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
{
// animate the item
/*
-
+
const QPixmap* pixmap = item->pixmap( 0 );
const QPixmap* nextpixmap = ani2;
if ( pixmap == ani1 )
nextpixmap = ani2;
@@ -111,14 +116,14 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
//qDebug( "current pixmap %d, next %d", pixmap, nextpixmap );
// we have already seen this net, check all childs if MAC exists
-
+
network = item;
-
+
item = static_cast<MScanListItem*> ( item->firstChild() );
assert( item ); // this shouldn't fail
-
+
while ( item && ( item->text( 2 ) != macaddr ) )
{
qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
item = static_cast<MScanListItem*> ( item->itemBelow() );
@@ -197,16 +202,36 @@ MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid
qDebug( "creating scanlist item" );
decorateItem( type, essid, macaddr, wep, channel, signal );
}
+OListViewItem* MScanListItem::childFactory()
+{
+ return new MScanListItem( this );
+}
+
void MScanListItem::serializeTo( QDataStream& s ) const
{
+ qDebug( "serializing MScanListItem" );
OListViewItem::serializeTo( s );
+
+ s << _type;
+ s << (Q_UINT8) _wep;
}
void MScanListItem::serializeFrom( QDataStream& s )
{
+ qDebug( "serializing MScanListItem" );
OListViewItem::serializeFrom( s );
+
+ s >> _type;
+ s >> (Q_UINT8) _wep;
+
+ QString name;
+ name.sprintf( "wellenreiter/%s", (const char*) _type );
+ setPixmap( col_type, Resource::loadPixmap( name ) );
+ if ( _wep )
+ setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
+ listView()->triggerUpdate();
}
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
@@ -32,8 +32,9 @@ class MScanListView: public OListView
virtual ~MScanListView();
void setManufacturerDB( ManufacturerDB* manufacturerdb );
+ virtual OListViewItem* childFactory();
virtual void serializeTo( QDataStream& s ) const;
virtual void serializeFrom( QDataStream& s );
public slots:
@@ -49,22 +50,22 @@ class MScanListView: public OListView
class MScanListItem: public OListViewItem
{
public:
MScanListItem::MScanListItem( QListView* parent,
- QString type,
- QString essid,
- QString macaddr,
- bool wep,
- int channel,
- int signal );
+ QString type = "unknown",
+ QString essid = "unknown",
+ QString macaddr = "unknown",
+ bool wep = false,
+ int channel = 0,
+ int signal = 0 );
MScanListItem::MScanListItem( QListViewItem* parent,
- QString type,
- QString essid,
- QString macaddr,
- bool wep,
- int channel,
- int signal );
+ QString type = "unknown",
+ QString essid = "unknown",
+ QString macaddr = "unknown",
+ bool wep = false,
+ int channel = 0,
+ int signal = 0 );
protected:
virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
@@ -85,8 +86,9 @@ class MScanListItem: public OListViewItem
void receivedBeacon();
void setManufacturer( const QString& manufacturer );
+ virtual OListViewItem* childFactory();
virtual void serializeTo( QDataStream& s ) const;
virtual void serializeFrom( QDataStream& s );
private: