cosmetix
[dyskinesia.git] / src / psyccontact.cpp
blobc9ed44d4dcc4c9907959cf42b2604698803bd66a
1 /* coded by Ketmar // Vampire Avalon (psyc://ketmar.no-ip.org/~Ketmar)
2 * Understanding is not required. Only obedience.
4 * This program is free software. It comes without any warranty, to
5 * the extent permitted by applicable law. You can redistribute it
6 * and/or modify it under the terms of the Do What The Fuck You Want
7 * To Public License, Version 2, as published by Sam Hocevar. See
8 * http://sam.zoy.org/wtfpl/COPYING for more details.
9 */
10 #include <QDebug>
12 #include "psyccontact.h"
15 MyMessage::MyMessage (const PsycEntity &aUser, const QString &aText, const QString &aAction, const QDateTime &aTime) :
16 text(aText), action(aAction), time(aTime), user(aUser)
21 ///////////////////////////////////////////////////////////////////////////////
22 PsycContact::PsycContact (const QString &uni, bool aTemp, QObject *parent) :
23 QObject(parent), mEntity(new PsycEntity(uni)),
24 mLastSeen(0),
25 mAuthorized(false), mGroupName(QString()),
26 mTemp(aTemp), mIsOTRActive(false)
28 mIsPlace = mEntity->isPlace();
32 PsycContact::~PsycContact () {
33 clearMessages();
34 clearPersons();
35 delete mEntity;
39 ///////////////////////////////////////////////////////////////////////////////
40 void PsycContact::addMessage (const PsycEntity &aUser, const QString &aText, const QString &aAction, const QDateTime &aTime) {
41 MyMessage *msg = new MyMessage(aUser, aText, aAction, aTime);
42 mMsgList << msg;
46 void PsycContact::clearMessages () {
47 foreach (MyMessage *msg, mMsgList) delete msg;
48 mMsgList.clear();
52 QList<MyMessage *> PsycContact::messages () {
53 QList<MyMessage *> res(mMsgList);
54 return res;
58 ///////////////////////////////////////////////////////////////////////////////
59 void PsycContact::addPerson (const QString &uni) {
60 if (mPersonList.indexOf(uni.toLower()) < 0) mPersonList << uni;
64 void PsycContact::delPerson (const QString &uni) {
65 int idx = mPersonList.indexOf(uni.toLower());
66 if (idx >= 0) mPersonList.removeAt(idx);
70 bool PsycContact::hasPerson (const QString &uni) const {
71 return mPersonList.contains(uni.toLower());
75 QStringList PsycContact::persons () const {
76 return mPersonList;
80 QString PsycContact::person (int idx) const {
81 if (idx < 0 || idx >= mPersonList.count()) return QString("");
82 return mPersonList[idx];