#ifndef MAILLIST_H
#define MAILLIST_H

#include <QObject>
#include <QTreeView>

#include "Mail.h"


class MailListItemDelegate : public QAbstractItemDelegate
{
public:
    MailListItemDelegate(QObject *parent = Q_NULLPTR);
    virtual ~MailListItemDelegate();

    void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
    QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
private:
    bool detailedRendering;
    int  rowHeight;
};




class MailList : public QTreeView
{
    Q_OBJECT
public:
    explicit MailList(QWidget *parent = Q_NULLPTR);
    ~MailList();

    //void Initialize(MailView* ptr);

    void MoveToNext();
    void MoveToPrevious();

    void DeleteCurrent();
    void FlagCurrent();
    void MarkAsSeenCurrent();

    MailHeader GetCurrentToken();

signals:
    void MailSelected(MailHeader emlhdr);

public slots:
    void eventMailSelected(QItemSelection &selection);
    void eventMailListReceived(QVector<MailHeader>& mlist);
    void eventClearMailView();

private:
    void HeaderReceived(MailHeader emlhdr);

    /*MailView*/QWidget* mailViewPtr;
    QItemSelection* currentViewItem;

    MailHeader currentToken;
    QMap<QString, MailHeader> mailLookup;

protected:
    void resizeEvent(QResizeEvent *event) override;
};

#endif // MAILLIST_H
