update// added new model derived from chatmodel and contactmodel, moved listchatdelegate to a seperated class file
This commit is contained in:
135
src/Model/ChatItem.cpp
Normal file
135
src/Model/ChatItem.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
#include "ChatItem.h"
|
||||
|
||||
ChatItem::ChatItem() {}
|
||||
|
||||
ChatItem::ChatItem(long timestamp, QString address, QString contact, QString memo, QString requestZaddr, QString type, QString cid, QString txid)
|
||||
{
|
||||
_timestamp = timestamp;
|
||||
_address = address;
|
||||
_contact = contact;
|
||||
_memo = memo;
|
||||
_requestZaddr = requestZaddr;
|
||||
_type = type;
|
||||
_cid = cid;
|
||||
_txid = txid;
|
||||
_outgoing = false;
|
||||
}
|
||||
|
||||
ChatItem::ChatItem(long timestamp, QString address, QString contact, QString memo, QString requestZaddr, QString type, QString cid, QString txid, bool outgoing)
|
||||
{
|
||||
_timestamp = timestamp;
|
||||
_address = address;
|
||||
_contact = contact;
|
||||
_memo = memo;
|
||||
_requestZaddr = requestZaddr;
|
||||
_type = type;
|
||||
_cid = cid;
|
||||
_txid = txid;
|
||||
_outgoing = outgoing;
|
||||
}
|
||||
|
||||
long ChatItem::getTimestamp()
|
||||
{
|
||||
return _timestamp;
|
||||
}
|
||||
|
||||
QString ChatItem::getAddress()
|
||||
{
|
||||
return _address;
|
||||
}
|
||||
|
||||
QString ChatItem::getContact()
|
||||
{
|
||||
return _contact;
|
||||
}
|
||||
|
||||
QString ChatItem::getMemo()
|
||||
{
|
||||
return _memo;
|
||||
}
|
||||
|
||||
QString ChatItem::getRequestZaddr()
|
||||
{
|
||||
return _requestZaddr;
|
||||
}
|
||||
QString ChatItem::getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
QString ChatItem::getCid()
|
||||
{
|
||||
return _cid;
|
||||
}
|
||||
|
||||
QString ChatItem::getTxid()
|
||||
{
|
||||
return _txid;
|
||||
}
|
||||
|
||||
bool ChatItem::isOutgoing()
|
||||
{
|
||||
return _outgoing;
|
||||
}
|
||||
|
||||
void ChatItem::setTimestamp(long timestamp)
|
||||
{
|
||||
_timestamp = timestamp;
|
||||
}
|
||||
|
||||
void ChatItem::setAddress(QString address)
|
||||
{
|
||||
_address = address;
|
||||
}
|
||||
|
||||
void ChatItem::setContact(QString contact)
|
||||
{
|
||||
_contact = contact;
|
||||
}
|
||||
|
||||
void ChatItem::setMemo(QString memo)
|
||||
{
|
||||
_memo = memo;
|
||||
}
|
||||
|
||||
void ChatItem::setRequestZaddr(QString requestZaddr)
|
||||
{
|
||||
_requestZaddr = requestZaddr;
|
||||
}
|
||||
|
||||
void ChatItem::setType(QString type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
|
||||
void ChatItem::setCid(QString cid)
|
||||
{
|
||||
_cid = cid;
|
||||
}
|
||||
void ChatItem::setTxid(QString txid)
|
||||
{
|
||||
_txid = txid;
|
||||
}
|
||||
|
||||
void ChatItem::toggleOutgo()
|
||||
{
|
||||
_outgoing = true;
|
||||
}
|
||||
|
||||
QString ChatItem::toChatLine()
|
||||
{
|
||||
QDateTime myDateTime;
|
||||
myDateTime.setTime_t(_timestamp);
|
||||
QString line = QString("[") + myDateTime.toString("d.M.yy hh:mm") + QString("] ");
|
||||
line += QString("") + QString(_memo) + QString("\n\n");
|
||||
return line;
|
||||
}
|
||||
|
||||
ChatItem::~ChatItem()
|
||||
{
|
||||
/*delete timestamp;
|
||||
delete address;
|
||||
delete contact;
|
||||
delete memo;
|
||||
delete outgoing;*/
|
||||
}
|
||||
45
src/Model/ChatItem.h
Normal file
45
src/Model/ChatItem.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef CHATITEM_H
|
||||
#define CHATITEM_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class ChatItem
|
||||
{
|
||||
private:
|
||||
long _timestamp;
|
||||
QString _address;
|
||||
QString _contact;
|
||||
QString _memo;
|
||||
QString _requestZaddr;
|
||||
QString _type;
|
||||
QString _cid;
|
||||
QString _txid;
|
||||
bool _outgoing = false;
|
||||
|
||||
public:
|
||||
ChatItem();
|
||||
ChatItem(long timestamp, QString address, QString contact, QString memo,QString requestZaddr, QString type, QString cid, QString txid);
|
||||
ChatItem(long timestamp, QString address, QString contact, QString memo, QString requestZaddr, QString type, QString cid, QString txid, bool outgoing);
|
||||
long getTimestamp();
|
||||
QString getAddress();
|
||||
QString getContact();
|
||||
QString getMemo();
|
||||
QString getRequestZaddr();
|
||||
QString getType();
|
||||
QString getCid();
|
||||
QString getTxid();
|
||||
bool isOutgoing();
|
||||
void setTimestamp(long timestamp);
|
||||
void setAddress(QString address);
|
||||
void setContact(QString contact);
|
||||
void setMemo(QString memo);
|
||||
void setRequestZaddr(QString requestZaddr);
|
||||
void setType(QString type);
|
||||
void setCid(QString cid);
|
||||
void setTxid(QString txid);
|
||||
void toggleOutgo();
|
||||
QString toChatLine();
|
||||
~ChatItem();
|
||||
};
|
||||
|
||||
#endif
|
||||
66
src/Model/ContactItem.cpp
Normal file
66
src/Model/ContactItem.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "ContactItem.h"
|
||||
|
||||
ContactItem::ContactItem() {}
|
||||
|
||||
ContactItem::ContactItem(QString name, QString partnerAddress, QString myAddress, QString cid, QString avatar)
|
||||
{
|
||||
_name = name;
|
||||
_myAddress = myAddress;
|
||||
_partnerAddress = partnerAddress;
|
||||
_cid = cid;
|
||||
_avatar = avatar;
|
||||
}
|
||||
|
||||
QString ContactItem::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
QString ContactItem::getMyAddress() const
|
||||
{
|
||||
return _myAddress;
|
||||
}
|
||||
|
||||
QString ContactItem::getPartnerAddress() const
|
||||
{
|
||||
return _partnerAddress;
|
||||
}
|
||||
|
||||
QString ContactItem::getCid() const
|
||||
{
|
||||
return _cid;
|
||||
}
|
||||
|
||||
QString ContactItem::getAvatar() const
|
||||
{
|
||||
return _avatar;
|
||||
}
|
||||
|
||||
void ContactItem::setName(QString name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
void ContactItem::setMyAddress(QString myAddress)
|
||||
{
|
||||
_myAddress = myAddress;
|
||||
}
|
||||
|
||||
void ContactItem::setPartnerAddress(QString partnerAddress)
|
||||
{
|
||||
_partnerAddress = partnerAddress;
|
||||
}
|
||||
|
||||
void ContactItem::setcid(QString cid)
|
||||
{
|
||||
_cid = cid;
|
||||
}
|
||||
void ContactItem::setAvatar(QString avatar)
|
||||
{
|
||||
_avatar = avatar;
|
||||
}
|
||||
|
||||
QString ContactItem::toQTString()
|
||||
{
|
||||
return _name + "|" + _partnerAddress + "|" + _myAddress + "|" + _cid + "|" + _avatar;
|
||||
}
|
||||
32
src/Model/ContactItem.h
Normal file
32
src/Model/ContactItem.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef CONTACTITEM_H
|
||||
#define CONTACTITEM_H
|
||||
|
||||
#include <vector>
|
||||
#include <QString>
|
||||
|
||||
class ContactItem
|
||||
{
|
||||
private:
|
||||
QString _myAddress;
|
||||
QString _partnerAddress;
|
||||
QString _name;
|
||||
QString _cid;
|
||||
QString _avatar;
|
||||
|
||||
public:
|
||||
ContactItem();
|
||||
ContactItem(QString name, QString partnerAddress, QString myAddress, QString cid, QString avatar);
|
||||
QString getName() const;
|
||||
QString getMyAddress() const;
|
||||
QString getPartnerAddress() const;
|
||||
QString getCid() const;
|
||||
QString getAvatar() const;
|
||||
void setName(QString name);
|
||||
void setMyAddress(QString myAddress);
|
||||
void setPartnerAddress(QString partnerAddress);
|
||||
void setcid(QString cid);
|
||||
void setAvatar(QString avatar);
|
||||
QString toQTString();
|
||||
};
|
||||
|
||||
#endif
|
||||
1
src/Model/ContactRequestChatItem.cpp
Normal file
1
src/Model/ContactRequestChatItem.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "ContactRequestChatItem.h"
|
||||
11
src/Model/ContactRequestChatItem.h
Normal file
11
src/Model/ContactRequestChatItem.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifdef CONTACTREQUESTCHATITEM_H
|
||||
#define CONTACTREQUESTCHATITEM_H
|
||||
|
||||
#include "ChatItem.h"
|
||||
|
||||
class ContactRequestChatItem : ChatItem
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user