summaryrefslogtreecommitdiffstats
path: root/src/common/gui/list_container.h
blob: f99e3dc90a86107be5a73a695effa1362736ad2d (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/***************************************************************************
 *   Copyright (C) 2007 Nicolas Hadacek <[email protected]>                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/
#ifndef LIST_CONTAINER_H
#define LIST_CONTAINER_H

#include <tdepopupmenu.h>
#include <tdelistview.h>

//----------------------------------------------------------------------------
class ListContainer
{
public:
  virtual ~ListContainer() {}
  virtual ListContainer *appendBranch(const TQString &title) = 0;
  enum ItemState { Normal, Checked, UnChecked, Disabled };
  void appendItem(const TQString &label, uint id, ItemState state) { appendItem(TQPixmap(), label, id, state); }
  virtual void appendItem(const TQPixmap &icon, const TQString &label, uint id, ItemState state) = 0;
};

//----------------------------------------------------------------------------
class PopupContainer : public TDEPopupMenu, public ListContainer
{
TQ_OBJECT
  
public:
  PopupContainer(const TQString &title, TQWidget *parent = 0, const char *name = 0);
  virtual ListContainer *appendBranch(const TQString &title);
  virtual ListContainer *appendBranch(const TQPixmap &icon, const TQString &title);
  virtual void appendItem(const TQPixmap &icon, const TQString &label, uint id, ItemState state);
};

//----------------------------------------------------------------------------
class ListViewItemContainer : public TDEListViewItem, public ListContainer
{
public:
  ListViewItemContainer(const TQString &title, TDEListView *parent);
  ListViewItemContainer(const TQString &title, ListViewItemContainer *parent);
  virtual ~ListViewItemContainer();
  void setColumn(uint column) { _column = column; }
  virtual ListContainer *appendBranch(const TQString &title);
  virtual void appendItem(const TQPixmap &icon, const TQString &label, uint id, ItemState state);
  int id(const TQListViewItem* item) const; // -1 if not known

private:
  ListViewItemContainer *_parent;
  uint _column;
  TQMap<const TQListViewItem *, uint> *_ids;
};

#endif