Bug #5889 » TreeViewExample.h
1 |
// This may look like C code, but it's really -*- C++ -*-
|
---|---|
2 |
/*
|
3 |
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
|
4 |
*
|
5 |
* See the LICENSE file for terms of use.
|
6 |
*/
|
7 |
#ifndef TREEVIEWEXAMPLE_H_
|
8 |
#define TREEVIEWEXAMPLE_H_
|
9 |
|
10 |
#include <Wt/WContainerWidget.h>
|
11 |
#include <Wt/WString.h>
|
12 |
#include <Wt/WStandardItemModel.h>
|
13 |
#include <Wt/WTreeView.h>
|
14 |
#include <string>
|
15 |
#include <vector>
|
16 |
|
17 |
using namespace Wt; |
18 |
|
19 |
enum WeatherIcon { |
20 |
Sun, |
21 |
SunCloud, |
22 |
Cloud, |
23 |
Rain, |
24 |
Storm, |
25 |
Snow
|
26 |
};
|
27 |
|
28 |
namespace Wt { |
29 |
class WStandardItem; |
30 |
class WStandardItemModel; |
31 |
class WTreeView; |
32 |
class WText; |
33 |
}
|
34 |
|
35 |
class TreeViewModel : public WStandardItemModel |
36 |
{
|
37 |
public:
|
38 |
TreeViewModel(); |
39 |
~TreeViewModel() {}; |
40 |
|
41 |
bool update(); |
42 |
void toggleRowHeight(WTreeView *treeView_); |
43 |
void toggleStripes(WTreeView *treeView_); |
44 |
void toggleRoot(WTreeView *treeView_); |
45 |
void addRows(WTreeView *treeView_); |
46 |
|
47 |
private:
|
48 |
static std::unique_ptr<WStandardItem> continentItem(const std::string& continent); |
49 |
static std::unique_ptr<WStandardItem> countryItem(const std::string& country, const std::string& code); |
50 |
static std::vector<std::unique_ptr<WStandardItem> > cityItems(const std::string& city, WeatherIcon weather, const std::string& drink, bool useInternalPath, bool visited); |
51 |
|
52 |
WStandardItem *belgium_; |
53 |
};
|
54 |
|
55 |
class TreeViewExample : public WContainerWidget |
56 |
{
|
57 |
public:
|
58 |
TreeViewExample(const WString& titleText); |
59 |
WTreeView *treeView() const { return treeView_; } |
60 |
bool update(); |
61 |
|
62 |
private:
|
63 |
std::shared_ptr<WStandardItemModel> model_; |
64 |
WTreeView *treeView_; |
65 |
};
|
66 |
|
67 |
#endif
|
- « Previous
- 1
- 2
- 3
- Next »