• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • transfer-plugins
  • bittorrent
  • advanceddetails
peerviewmodel.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2008 by Joris Guisson and Ivan Vasic *
3  * joris.guisson@gmail.com *
4  * ivasic@gmail.com *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20  ***************************************************************************/
21 #ifndef KTPEERVIEWMODEL_H
22 #define KTPEERVIEWMODEL_H
23 
24 #include <kicon.h>
25 #include <QList>
26 #include <QAbstractTableModel>
27 #include <interfaces/peerinterface.h>
28 
29 namespace kt
30 {
31 
36  class PeerViewModel : public QAbstractTableModel
37  {
38  Q_OBJECT
39  public:
40  PeerViewModel(QObject* parent);
41  virtual ~PeerViewModel();
42 
44  void peerAdded(bt::PeerInterface* peer);
45 
47  void peerRemoved(bt::PeerInterface* peer);
48 
52  void update();
53 
54  void clear();
55 
56  virtual int rowCount(const QModelIndex & parent) const;
57  virtual int columnCount(const QModelIndex & parent) const;
58  virtual QVariant headerData(int section, Qt::Orientation orientation,int role) const;
59  virtual QVariant data(const QModelIndex & index,int role) const;
60  virtual bool removeRows(int row,int count,const QModelIndex & parent);
61  virtual bool insertRows(int row,int count,const QModelIndex & parent);
62  virtual QModelIndex index(int row,int column,const QModelIndex & parent = QModelIndex()) const;
63 
64  bt::PeerInterface* indexToPeer(const QModelIndex & idx);
65 
66  public slots:
67  void sort(int col, Qt::SortOrder order);
68 
69 
70  public:
71  struct Item
72  {
73  bt::PeerInterface* peer;
74  mutable bt::PeerInterface::Stats stats;
75  QString country;
76  KIcon flag;
77 
78  Item(bt::PeerInterface* peer);
79 
80  bool changed(int col,bool & modified) const;
81  QVariant data(int col) const;
82  QVariant decoration(int col) const;
83  bool lessThan(int col,const Item* other) const;
84  };
85  private:
86  QList<Item*> items;
87  int sort_column;
88  Qt::SortOrder sort_order;
89  };
90 
91 }
92 
93 #endif
kt::PeerViewModel::Item::flag
KIcon flag
Definition: peerviewmodel.h:76
kt::PeerViewModel::sort
void sort(int col, Qt::SortOrder order)
Definition: peerviewmodel.cpp:405
kt::PeerViewModel::removeRows
virtual bool removeRows(int row, int count, const QModelIndex &parent)
Definition: peerviewmodel.cpp:365
kt::PeerViewModel::clear
void clear()
Definition: peerviewmodel.cpp:248
kt::PeerViewModel::Item::decoration
QVariant decoration(int col) const
Definition: peerviewmodel.cpp:193
kt::PeerViewModel::Item::country
QString country
Definition: peerviewmodel.h:75
kt::PeerViewModel::~PeerViewModel
virtual ~PeerViewModel()
Definition: peerviewmodel.cpp:219
kt::PeerViewModel::Item::peer
bt::PeerInterface * peer
Definition: peerviewmodel.h:73
kt::PeerViewModel::Item::changed
bool changed(int col, bool &modified) const
Definition: peerviewmodel.cpp:71
QObject
kt::PeerViewModel::peerRemoved
void peerRemoved(bt::PeerInterface *peer)
A peer has been removed.
Definition: peerviewmodel.cpp:231
kt::PeerViewModel::Item::data
QVariant data(int col) const
Definition: peerviewmodel.cpp:136
kt::PeerViewModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: peerviewmodel.cpp:274
kt::PeerViewModel::PeerViewModel
PeerViewModel(QObject *parent)
Definition: peerviewmodel.cpp:211
kt::PeerViewModel
Definition: peerviewmodel.h:36
kt::PeerViewModel::data
virtual QVariant data(const QModelIndex &index, int role) const
Definition: peerviewmodel.cpp:351
kt::PeerViewModel::Item::Item
Item(bt::PeerInterface *peer)
Definition: peerviewmodel.cpp:36
kt::PeerViewModel::peerAdded
void peerAdded(bt::PeerInterface *peer)
A peer has been added.
Definition: peerviewmodel.cpp:224
kt::PeerViewModel::rowCount
virtual int rowCount(const QModelIndex &parent) const
Definition: peerviewmodel.cpp:282
kt::PeerViewModel::update
void update()
Update the model.
Definition: peerviewmodel.cpp:255
kt::PeerViewModel::Item
Definition: peerviewmodel.h:71
kt::PeerViewModel::insertRows
virtual bool insertRows(int row, int count, const QModelIndex &parent)
Definition: peerviewmodel.cpp:372
kt::PeerViewModel::columnCount
virtual int columnCount(const QModelIndex &parent) const
Definition: peerviewmodel.cpp:290
kt::PeerViewModel::headerData
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition: peerviewmodel.cpp:298
QAbstractTableModel
kt::PeerViewModel::indexToPeer
bt::PeerInterface * indexToPeer(const QModelIndex &idx)
Definition: peerviewmodel.cpp:379
kt::PeerViewModel::Item::lessThan
bool lessThan(int col, const Item *other) const
Definition: peerviewmodel.cpp:168
kt::PeerViewModel::Item::stats
bt::PeerInterface::Stats stats
Definition: peerviewmodel.h:74
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal