1
0
forked from blue/squawk
squawk/ui/models/item.h

77 lines
1.8 KiB
C
Raw Normal View History

2019-04-03 15:09:29 +00:00
#ifndef MODELS_ITEM_H
#define MODELS_ITEM_H
#include <QMap>
#include <QString>
#include <QVariant>
#include <deque>
namespace Models {
2019-04-03 18:15:36 +00:00
class Item : public QObject{
Q_OBJECT
2019-04-03 15:09:29 +00:00
public:
enum Type {
account,
group,
2019-04-03 21:23:51 +00:00
contact,
2019-04-03 15:09:29 +00:00
conversation,
2019-04-07 14:02:41 +00:00
presence,
2019-04-03 15:09:29 +00:00
root
};
explicit Item(Type p_type, const QMap<QString, QVariant> &data, Item *parentItem = 0);
~Item();
2019-04-03 18:15:36 +00:00
signals:
2019-04-07 14:02:41 +00:00
void childChanged(Item* item, int row, int col);
void childIsAboutToBeInserted(Item* parent, int first, int last);
void childInserted();
void childIsAboutToBeRemoved(Item* parent, int first, int last);
void childRemoved();
void childIsAboutToBeMoved(Item* source, int first, int last, Item* destination, int newIndex);
void childMoved();
2019-04-03 18:15:36 +00:00
public:
2019-04-07 14:02:41 +00:00
virtual void appendChild(Item *child);
virtual void removeChild(int index);
2019-04-03 15:09:29 +00:00
QString getName() const;
void setName(const QString& name);
Item *child(int row);
int childCount() const;
virtual int columnCount() const;
virtual QVariant data(int column) const;
int row() const;
Item *parentItem();
const Type type;
2019-04-07 14:02:41 +00:00
protected:
virtual void changed(int col);
virtual void _removeChild(int index);
2019-04-03 15:09:29 +00:00
protected:
QString name;
std::deque<Item*> childItems;
Item* parent;
2019-04-07 14:02:41 +00:00
protected slots:
2019-04-03 15:09:29 +00:00
};
}
2019-04-07 14:02:41 +00:00
namespace Shared {
static const std::deque<QString> AvailabilityIcons = {
"im-user-online",
"im-user-away",
"im-user-away",
"im-user-busy",
"im-user-online",
"im-user-offline"
};
}
2019-04-03 15:09:29 +00:00
#endif // MODELS_ITEM_H