home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kopete / kopetegroup.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  3.9 KB  |  188 lines

  1. /*
  2.     kopetegroup.h - Kopete (Meta)Contact Group
  3.  
  4.     Copyright (c) 2002-2004 by Olivier Goffart       <ogoffart @ kde.org>
  5.     Copyright (c) 2003      by Martijn Klingens      <klingens@kde.org>
  6.  
  7.     Kopete    (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
  8.  
  9.     *************************************************************************
  10.     *                                                                       *
  11.     * This library is free software; you can redistribute it and/or         *
  12.     * modify it under the terms of the GNU Lesser General Public            *
  13.     * License as published by the Free Software Foundation; either          *
  14.     * version 2 of the License, or (at your option) any later version.      *
  15.     *                                                                       *
  16.     *************************************************************************
  17. */
  18.  
  19. #ifndef KOPETEGROUP_H
  20. #define KOPETEGROUP_H
  21.  
  22. #include "kopetenotifydataobject.h"
  23. #include "kopetecontactlistelement.h"
  24.  
  25. #include "kopete_export.h"
  26.  
  27. #include <qptrlist.h>
  28.  
  29. class QDomElement;
  30.  
  31.  
  32. namespace Kopete {
  33.  
  34.  
  35. class MetaContact;
  36. class Message;
  37.  
  38. /**
  39.  * Class which represents the Group.
  40.  *
  41.  * A Group is a ConstacListElement which means plugin can save datas.
  42.  *
  43.  * some static group are availavle from this class:  topLevel and temporary
  44.  *
  45.  * @author Olivier Goffart
  46.  */
  47. class KOPETE_EXPORT Group : public ContactListElement, public NotifyDataObject
  48. {
  49.     Q_PROPERTY( QString displayName READ displayName WRITE setDisplayName )
  50.     Q_PROPERTY( uint groupId READ groupId )
  51.     Q_PROPERTY( bool expanded READ isExpanded WRITE setExpanded )
  52.  
  53.     Q_OBJECT
  54.  
  55. public:
  56.     /** Kinds of groups. */
  57.     enum GroupType { Normal=0, Temporary, TopLevel };
  58.  
  59.     /**
  60.      * \brief Create an empty group
  61.      *
  62.      * Note that the constructor will not add the group automatically to the contact list.
  63.      * Use @ref ContactList::addGroup() to add it
  64.      */
  65.     Group();
  66.  
  67.     /**
  68.      * \brief Create a group of the specified type
  69.      *
  70.      * Overloaded constructor to create a group with a display name of the specified type.
  71.      */
  72.     Group( const QString &displayName, GroupType type = Normal );
  73.     
  74.     ~Group();
  75.  
  76.     /**
  77.      * \brief Return the group's display name
  78.      *
  79.      * \return the display name of the group
  80.      */
  81.     QString displayName() const;
  82.  
  83.     /**
  84.      * \brief Rename the group
  85.      */
  86.     void setDisplayName( const QString &newName );
  87.  
  88.     /**
  89.      * \return the group type
  90.      */
  91.     GroupType type() const;
  92.  
  93.     /**
  94.      * \brief Set the group type
  95.      */
  96.     void setType( GroupType newType );
  97.  
  98.     /**
  99.      * \return the unique id for this group
  100.      */
  101.     uint groupId() const;
  102.  
  103.     /**
  104.      * @brief child metacontact
  105.      * This function is not very efficient - it searches through all the metacontacts in the contact list
  106.      * \return the members of this group
  107.      */
  108.     QPtrList<MetaContact> members() const;
  109.  
  110.     /**
  111.      * \brief Set if the group is expanded.
  112.      *
  113.      * This is saved to the xml contactlist file
  114.      */
  115.     void setExpanded( bool expanded );
  116.  
  117.     /**
  118.      *
  119.      * \return true if the group is expanded.
  120.      * \return false otherwise
  121.      */
  122.     bool isExpanded() const;
  123.  
  124.     /**
  125.      * \return a Group pointer to the toplevel group
  126.      */
  127.     static Group *topLevel();
  128.  
  129.     /**
  130.      * \return a Group pointer to the temporary group
  131.      */
  132.     static Group *temporary();
  133.     
  134.  
  135.     
  136.     /**
  137.      * @internal
  138.      * Outputs the group data in XML
  139.      */
  140.     const QDomElement toXML();
  141.  
  142.     
  143.     /**
  144.      * @internal
  145.      * Loads the group data from XML
  146.      */
  147.      bool fromXML( const QDomElement &data );
  148.  
  149.      
  150.      
  151.          
  152. public slots:
  153.     /**
  154.      * Send a message to all contacts in the group
  155.      */
  156.     void sendMessage();
  157.  
  158.  
  159. signals:
  160.     /**
  161.      * \brief Emitted when the group has been renamed
  162.      */
  163.     void displayNameChanged( Kopete::Group *group , const QString &oldName );
  164.  
  165.     
  166. private slots:
  167.     void sendMessage( Kopete::Message& );
  168.  
  169. private:
  170.     static Group *s_topLevel;
  171.     static Group *s_temporary;
  172.  
  173.     class Private;
  174.     Private *d;
  175.     
  176.     
  177.     /**
  178.      * @internal  used to get reachabe contact to send message to thom.
  179.      */
  180.     QPtrList<MetaContact> onlineMembers() const;
  181. };
  182.  
  183. } //END namespace Kopete 
  184.  
  185. #endif
  186.  
  187.  
  188.