Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
NetworkModel Class Reference

#include </tmp/quassel/src/client/networkmodel.h>

Inheritance diagram for NetworkModel:
Collaboration diagram for NetworkModel:

Public Types

enum  Role {
  BufferTypeRole = TreeModel::UserRole, ItemActiveRole, BufferActivityRole, BufferIdRole,
  NetworkIdRole, BufferInfoRole, ItemTypeRole, UserAwayRole,
  IrcUserRole, IrcChannelRole, BufferFirstUnreadMsgIdRole, MarkerLineMsgIdRole
}
enum  ItemType { NetworkItemType = 0x01, BufferItemType = 0x02, UserCategoryItemType = 0x04, IrcUserItemType = 0x08 }
enum  myRoles { SortRole = Qt::UserRole, UserRole }

Public Slots

void bufferUpdated (BufferInfo bufferInfo)
void removeBuffer (BufferId bufferId)
MsgId lastSeenMsgId (const BufferId &bufferId)
void setLastSeenMsgId (const BufferId &bufferId, const MsgId &msgId)
void setMarkerLineMsgId (const BufferId &bufferId, const MsgId &msgId)
void setBufferActivity (const BufferId &bufferId, BufferInfo::ActivityLevel activity)
void clearBufferActivity (const BufferId &bufferId)
void updateBufferActivity (Message &msg)
void networkRemoved (const NetworkId &networkId)

Signals

void requestSetLastSeenMsg (BufferId buffer, MsgId msg)
void lastSeenMsgSet (BufferId buffer, MsgId msg)
void markerLineSet (BufferId buffer, MsgId msg)

Public Member Functions

 Q_DECLARE_FLAGS (ItemTypes, ItemType) NetworkModel(QObject *parent=0)
virtual QStringList mimeTypes () const
virtual QMimeData * mimeData (const QModelIndexList &) const
void attachNetwork (Network *network)
bool isBufferIndex (const QModelIndex &) const
QModelIndex networkIndex (NetworkId networkId)
QModelIndex bufferIndex (BufferId bufferId)
const NetworknetworkByIndex (const QModelIndex &index) const
BufferInfo::ActivityLevel bufferActivity (const BufferInfo &buffer) const
BufferId bufferId (NetworkId networkId, const QString &bufferName, Qt::CaseSensitivity cs=Qt::CaseInsensitive) const
 Finds a buffer with a given name in a given network.
QString bufferName (BufferId bufferId) const
BufferInfo::Type bufferType (BufferId bufferId) const
BufferInfo bufferInfo (BufferId bufferId) const
MsgId lastSeenMsgId (BufferId bufferId) const
MsgId markerLineMsgId (BufferId bufferId) const
NetworkId networkId (BufferId bufferId) const
QString networkName (BufferId bufferId) const
QList< BufferIdallBufferIds () const
QList< BufferIdallBufferIdsSorted () const
void sortBufferIds (QList< BufferId > &bufferIds) const
virtual QVariant data (const QModelIndex &index, int role) const
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
virtual Qt::ItemFlags flags (const QModelIndex &index) const
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
QModelIndex indexByItem (AbstractTreeItem *item) const
QModelIndex parent (const QModelIndex &index) const
int rowCount (const QModelIndex &parent=QModelIndex()) const
int columnCount (const QModelIndex &parent=QModelIndex()) const
virtual void clear ()

Static Public Member Functions

static QList< QVariant > defaultHeader ()
static bool mimeContainsBufferList (const QMimeData *mimeData)
static QList< QPair< NetworkId,
BufferId > > 
mimeDataToBufferList (const QMimeData *mimeData)

Protected Attributes

AbstractTreeItemrootItem

Private Slots

void checkForRemovedBuffers (const QModelIndex &parent, int start, int end)
void checkForNewBuffers (const QModelIndex &parent, int start, int end)
void messageRedirectionSettingsChanged ()

Private Member Functions

int networkRow (NetworkId networkId) const
NetworkItemfindNetworkItem (NetworkId networkId) const
NetworkItemnetworkItem (NetworkId networkId)
BufferItemfindBufferItem (const BufferInfo &bufferInfo) const
BufferItemfindBufferItem (BufferId bufferId) const
BufferItembufferItem (const BufferInfo &bufferInfo)
void updateBufferActivity (BufferItem *bufferItem, const Message &msg)

Static Private Member Functions

static bool bufferItemLessThan (const BufferItem *left, const BufferItem *right)

Private Attributes

QHash< BufferId, BufferItem * > _bufferItemCache
int _userNoticesTarget
int _serverNoticesTarget
int _errorMsgsTarget

Detailed Description

Definition at line 280 of file networkmodel.h.

Member Enumeration Documentation

enum Role
Enumerator:
BufferTypeRole 
ItemActiveRole 
BufferActivityRole 
BufferIdRole 
NetworkIdRole 
BufferInfoRole 
ItemTypeRole 
UserAwayRole 
IrcUserRole 
IrcChannelRole 
BufferFirstUnreadMsgIdRole 
MarkerLineMsgIdRole 

Definition at line 285 of file networkmodel.h.

enum ItemType
Enumerator:
NetworkItemType 
BufferItemType 
UserCategoryItemType 
IrcUserItemType 

Definition at line 300 of file networkmodel.h.

enum myRoles
inherited
Enumerator:
SortRole 
UserRole 

Definition at line 155 of file treemodel.h.

Member Function Documentation

Q_DECLARE_FLAGS ( ItemTypes  ,
ItemType   
)
pure virtual
QList< QVariant > defaultHeader ( )
static

Definition at line 999 of file networkmodel.cpp.

References TreeModel::data().

bool mimeContainsBufferList ( const QMimeData *  mimeData)
static

Definition at line 1107 of file networkmodel.cpp.

Referenced by BufferViewFilter::dropMimeData(), and mimeDataToBufferList().

QList< QPair< NetworkId, BufferId > > mimeDataToBufferList ( const QMimeData *  mimeData)
static
QStringList mimeTypes ( ) const
virtual

Definition at line 1096 of file networkmodel.cpp.

QMimeData * mimeData ( const QModelIndexList &  indexes) const
virtual

Definition at line 1134 of file networkmodel.cpp.

References BufferIdRole, TreeModel::index(), NetworkIdRole, and toInt().

void attachNetwork ( Network network)

Definition at line 1154 of file networkmodel.cpp.

References NetworkItem::attachNetwork(), Network::networkId(), and networkItem().

Referenced by Client::addNetwork().

bool isBufferIndex ( const QModelIndex &  index) const

Definition at line 1007 of file networkmodel.cpp.

References BufferItemType, and ItemTypeRole.

QModelIndex networkIndex ( NetworkId  networkId)
const Network * networkByIndex ( const QModelIndex &  index) const

Definition at line 1321 of file networkmodel.cpp.

References NetworkEvent::network(), networkId(), and NetworkIdRole.

Referenced by InputWidget::updateEnabledState().

BufferInfo::ActivityLevel bufferActivity ( const BufferInfo buffer) const
BufferId bufferId ( NetworkId  networkId,
const QString &  bufferName,
Qt::CaseSensitivity  cs = Qt::CaseInsensitive 
) const

Finds a buffer with a given name in a given network.

This performs a linear search through all BufferItems, hence it is expensive.

Parameters
networkIdThe network which we search in
bufferNameThe bufferName we look for
Returns
The id of the buffer if found, an invalid one else

Definition at line 1408 of file networkmodel.cpp.

References BufferItem::bufferId(), bufferItem(), BufferItem::bufferName, AbstractTreeItem::child(), AbstractTreeItem::childCount(), and findNetworkItem().

Referenced by ContextMenuActionProvider::addActions(), bufferInfo(), bufferName(), bufferType(), clearBufferActivity(), NetworkModelController::findQueryBuffer(), lastSeenMsgId(), markerLineMsgId(), networkId(), networkName(), setBufferActivity(), setLastSeenMsgId(), setMarkerLineMsgId(), sortBufferIds(), ClientUserInputHandler::switchBuffer(), and BufferModel::switchToOrJoinBuffer().

BufferInfo bufferInfo ( BufferId  bufferId) const
MsgId lastSeenMsgId ( BufferId  bufferId) const
MsgId markerLineMsgId ( BufferId  bufferId) const

Definition at line 1188 of file networkmodel.cpp.

References _bufferItemCache, and bufferId().

Referenced by BufferWidget::currentChanged(), and Client::markerLine().

QList< BufferId > allBufferIdsSorted ( ) const

Definition at line 1440 of file networkmodel.cpp.

References allBufferIds(), and sortBufferIds().

Referenced by BufferViewSettingsPage::newBufferView().

void sortBufferIds ( QList< BufferId > &  bufferIds) const
void bufferUpdated ( BufferInfo  bufferInfo)
slot

Definition at line 1161 of file networkmodel.cpp.

References bufferItem(), and TreeModel::indexByItem().

Referenced by CoreConnection::syncToCore().

void removeBuffer ( BufferId  bufferId)
slot
MsgId lastSeenMsgId ( const BufferId bufferId)
slot
void setLastSeenMsgId ( const BufferId bufferId,
const MsgId msgId 
)
slot
void setMarkerLineMsgId ( const BufferId bufferId,
const MsgId msgId 
)
slot
void setBufferActivity ( const BufferId bufferId,
BufferInfo::ActivityLevel  activity 
)
slot
void clearBufferActivity ( const BufferId bufferId)
slot
void networkRemoved ( const NetworkId networkId)
slot
void requestSetLastSeenMsg ( BufferId  buffer,
MsgId  msg 
)
signal

Referenced by updateBufferActivity().

void lastSeenMsgSet ( BufferId  buffer,
MsgId  msg 
)
signal

Referenced by setLastSeenMsgId().

void markerLineSet ( BufferId  buffer,
MsgId  msg 
)
signal

Referenced by setMarkerLineMsgId().

void checkForRemovedBuffers ( const QModelIndex &  parent,
int  start,
int  end 
)
privateslot

Definition at line 1332 of file networkmodel.cpp.

References _bufferItemCache, BufferIdRole, ItemTypeRole, and NetworkItemType.

void checkForNewBuffers ( const QModelIndex &  parent,
int  start,
int  end 
)
privateslot

Definition at line 1343 of file networkmodel.cpp.

References _bufferItemCache, BufferIdRole, ItemTypeRole, and NetworkItemType.

int networkRow ( NetworkId  networkId) const
private
NetworkItem * findNetworkItem ( NetworkId  networkId) const
private
NetworkItem * networkItem ( NetworkId  networkId)
private

Definition at line 1047 of file networkmodel.cpp.

References findNetworkItem(), AbstractTreeItem::newChild(), and TreeModel::rootItem.

Referenced by attachNetwork(), and bufferItem().

BufferItem* findBufferItem ( const BufferInfo bufferInfo) const
inlineprivate
BufferItem * findBufferItem ( BufferId  bufferId) const
private

Definition at line 1077 of file networkmodel.cpp.

References _bufferItemCache.

void updateBufferActivity ( BufferItem bufferItem,
const Message msg 
)
private
bool bufferItemLessThan ( const BufferItem left,
const BufferItem right 
)
staticprivate

Definition at line 1448 of file networkmodel.cpp.

References BufferItem::bufferName, and BufferItem::bufferType().

Referenced by sortBufferIds().

QVariant data ( const QModelIndex &  index,
int  role 
) const
virtualinherited
bool setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
virtualinherited

Definition at line 462 of file treemodel.cpp.

References AbstractTreeItem::setData().

Referenced by Client::bufferRenamed().

Qt::ItemFlags flags ( const QModelIndex &  index) const
virtualinherited

Definition at line 472 of file treemodel.cpp.

References AbstractTreeItem::flags(), and TreeModel::rootItem.

QVariant headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
inherited

Definition at line 484 of file treemodel.cpp.

References AbstractTreeItem::data(), and TreeModel::rootItem.

QModelIndex index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
inherited
QModelIndex parent ( const QModelIndex &  index) const
inherited
int columnCount ( const QModelIndex &  parent = QModelIndex()) const
inherited

Definition at line 434 of file treemodel.cpp.

References AbstractTreeItem::columnCount(), and TreeModel::rootItem.

Referenced by TreeModel::index().

void clear ( )
virtualinherited

Member Data Documentation

int _userNoticesTarget
private

Definition at line 383 of file networkmodel.h.

Referenced by messageRedirectionSettingsChanged(), and updateBufferActivity().

int _serverNoticesTarget
private

Definition at line 384 of file networkmodel.h.

Referenced by messageRedirectionSettingsChanged(), and updateBufferActivity().

int _errorMsgsTarget
private

Definition at line 385 of file networkmodel.h.

Referenced by messageRedirectionSettingsChanged(), and updateBufferActivity().


The documentation for this class was generated from the following files: