summaryrefslogtreecommitdiffabout
path: root/korganizer/customlistviewitem.h
blob: 94e5bcea982ac373386e440cfe275df56dec2cb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef CUSTOMLISTVIEWITEM_H
#define CUSTOMLISTVIEWITEM_H

#include <qmap.h>
#include <qstring.h>
#include <klistview.h>

template<class T>
class CustomListViewItem : public KListViewItem
{
  public:
    CustomListViewItem( T data, KListView *parent ) :
      KListViewItem( parent ), mData( data ) { updateItem(); };
    ~CustomListViewItem() {};
    
    void updateItem() {};

    T data() const { return mData; }

    QString key(int column, bool) const
    {
      QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
      if (it == mKeyMap.end()) return text(column);
      else return *it;
    }

    void setSortKey(int column,const QString &key)
    {
      mKeyMap.insert(column,key);
    }

  private:
    T mData;

    QMap<int,QString> mKeyMap;
};

#endif