summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show 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.cpp25
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h26
4 files changed, 64 insertions, 27 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
@@ -110,32 +110,37 @@ void OListView::setAlternateBackground( const QColor &c )
{
m_alternateBackground = c;
repaint();
}
const QPen& OListView::columnSeparator() const
{
return m_columnSeparator;
}
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...
qDebug( "storing OListView..." );
// store number of columns and the labels
s << columns();
for ( int i = 0; i < columns(); ++i )
s << columnText( i );
// calculate the number of top-level items to serialize
int items = 0;
QListViewItem* item = firstChild();
while ( item )
{
@@ -167,33 +172,33 @@ void OListView::serializeFrom( QDataStream& s )
while ( columns() < cols ) addColumn( QString::null );
for ( int i = 0; i < cols; ++i )
{
QString coltext;
s >> coltext;
qDebug( "read text '%s' for column %d", (const char*) coltext, i );
setColumnText( i, coltext );
}
int items;
s >> items;
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." );
}
QDataStream& operator<<( QDataStream& s, const OListView& lv )
{
lv.serializeTo( s );
}
QDataStream& operator>>( QDataStream& s, OListView& lv )
{
lv.serializeFrom( s );
}
@@ -324,32 +329,37 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in
_cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) );
p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
}
else if ( isAlternate() )
{
_cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() );
}
QListViewItem::paintCell( p, _cg, column, width, alignment );
//FIXME: Use styling here!
const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator();
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...
qDebug( "storing OListViewItem..." );
// store item text
for ( int i = 0; i < listView()->columns(); ++i )
{
s << text( i );
}
// calculate the number of children to serialize
int items = 0;
QListViewItem* item = firstChild();
while ( item )
@@ -375,33 +385,33 @@ void OListViewItem::serializeFrom( QDataStream& s )
qDebug( "loading OListViewItem..." );
for ( int i = 0; i < listView()->columns(); ++i )
{
QString coltext;
s >> coltext;
qDebug( "read text '%s' for column %d", (const char*) coltext, i );
setText( i, coltext );
}
int items;
s >> items;
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." );
}
QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi )
{
lvi.serializeTo( s );
}
QDataStream& operator>>( QDataStream& s, OListViewItem& lvi )
{
lvi.serializeFrom( s );
}
#endif // QT_NO_DATASTREAM
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
@@ -25,33 +25,33 @@
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OLISTVIEW_H
#define OLISTVIEW_H
#include <qcolor.h>
#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
* for the width of the widget ( >= Qt 3 only ) and persistence capabilities.
*
* @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
* @short OListView list/tree widget.
*/
class OListView: public QListView
{
public:
/**
* Constructor.
*
* The parameters @p parent and @p name are handled by
@@ -102,62 +102,56 @@ class OListViewFactory;
* sets the column separator pen.
*
* @param p the pen used to draw the column separator.
*/
void setColumnSeparator( const QPen &p );
/**
* @return the alternate background color
*/
const QColor& alternateBackground() const;
/**
* @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.
*/
virtual void serializeTo( QDataStream& s ) const;
/**
* serialize this object from a @ref QDataStream
* @param s the stream used to serialize this object.
*/
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
/**
* \relates QListView
* Writes a listview to the stream and returns a reference to the stream.
*/
QDataStream& operator<<( QDataStream& s, const OListView& lv );
/**
* \relates QListView
* Reads a listview from the stream and returns a reference to the stream.
*/
QDataStream& operator>>( QDataStream& s, OListView& lv );
#endif // QT_NO_DATASTREAM
//****************************** OListViewItem ******************************************************************
@@ -188,32 +182,38 @@ class OListViewItem: public QListViewItem
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
OListViewItem( QListViewItem * parent, QListViewItem * after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
virtual ~OListViewItem();
const QColor& backgroundColor();
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.
*/
virtual void serializeTo( QDataStream& s ) const;
/**
* serialize this object to or from a @ref QDataStream
* @param s the stream used to serialize this object.
*/
virtual void serializeFrom( QDataStream& s );
#endif
private:
bool m_known;
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
@@ -40,32 +40,37 @@ MScanListView::MScanListView( QWidget* parent, const char* name )
addColumn( tr( "T" ) );
setColumnAlignment( 5, AlignCenter );
addColumn( tr( "Manufacturer" ) );
setColumnAlignment( 6, AlignCenter );
addColumn( tr( "First Seen" ) );
setColumnAlignment( 7, AlignCenter );
addColumn( tr( "Last Seen" ) );
setColumnAlignment( 8, AlignCenter );
setRootIsDecorated( true );
setAllColumnsShowFocus( true );
};
MScanListView::~MScanListView()
{
};
+OListViewItem* MScanListView::childFactory()
+{
+ return new MScanListItem( this );
+}
+
void MScanListView::serializeTo( QDataStream& s) const
{
qDebug( "serializing MScanListView" );
OListView::serializeTo( s );
}
void MScanListView::serializeFrom( QDataStream& s)
{
qDebug( "serializing MScanListView" );
OListView::serializeFrom( s );
}
void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb )
{
_manufacturerdb = manufacturerdb;
}
@@ -185,40 +190,60 @@ MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QS
:OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
_type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
_channel( channel ), _signal( signal ), _beacons( 0 )
{
qDebug( "creating scanlist item" );
decorateItem( type, essid, macaddr, wep, channel, signal );
}
MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
bool wep, int channel, int signal )
:OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
{
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 )
{
qDebug( "decorating scanlist item %s / %s / %s [%d]",
(const char*) type,
(const char*) essid,
(const char*) macaddr,
channel );
// set icon for managed or adhoc mode
QString name;
name.sprintf( "wellenreiter/%s", (const char*) type );
setPixmap( col_type, Resource::loadPixmap( name ) );
// set icon for wep (wireless encryption protocol)
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
@@ -20,85 +20,87 @@
#include <qtextstream.h>
class QString;
class ManufacturerDB;
class MScanListView: public OListView
{
Q_OBJECT
public:
MScanListView( QWidget* parent = 0, const char* name = 0 );
virtual ~MScanListView();
void setManufacturerDB( ManufacturerDB* manufacturerdb );
+ virtual OListViewItem* childFactory();
virtual void serializeTo( QDataStream& s ) const;
virtual void serializeFrom( QDataStream& s );
public slots:
void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
private:
ManufacturerDB* _manufacturerdb;
};
//****************************** MScanListItem ****************************************************************
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 );
public:
QString type;
public:
//const QString& type() { return _type; };
const QString& essid() { return _essid; };
const QString& macaddr() { return _macaddr; };
bool wep() { return _wep; };
int channel() { return _channel; };
int signal() { return _signal; };
int beacons() { return _beacons; };
void setSignal( int signal ) { /* TODO */ };
void receivedBeacon();
void setManufacturer( const QString& manufacturer );
+ virtual OListViewItem* childFactory();
virtual void serializeTo( QDataStream& s ) const;
virtual void serializeFrom( QDataStream& s );
private:
QString _type;
QString _essid;
QString _macaddr;
bool _wep;
int _channel;
int _signal;
int _beacons;
};
//****************************** MScanListViewFactory ****************************************************************