/
PostView.h
63 lines (47 loc) · 1.21 KB
/
PostView.h
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
57
58
59
60
61
62
63
// This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2009 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef POST_VIEW_H_
#define POST_VIEW_H_
#include <Wt/WTemplate>
#include <Wt/Dbo/ptr>
#include "../model/Post.h"
namespace Wt {
class WText;
}
class BlogSession;
class Comment;
class PostView : public Wt::WTemplate
{
public:
enum RenderType { Brief, Detail, Edit };
PostView(BlogSession& session, const std::string& basePath,
dbo::ptr<Post> post, RenderType type);
virtual void resolveString(const std::string& varName,
const std::vector<Wt::WString>& args,
std::ostream& result);
protected:
virtual void renderTemplate(std::ostream& result);
private:
BlogSession& session_;
std::string basePath_;
dbo::ptr<Post> post_;
RenderType viewType_;
Wt::WText *commentCount_;
Wt::WLineEdit *titleEdit_;
Wt::WTextArea *briefEdit_, *bodyEdit_;
void render(RenderType type);
void updateCommentCount(dbo::ptr<Comment> comment);
void saveEdit();
void showView();
void publish();
void retract();
void showEdit();
void rm();
void setState(Post::State state);
using WWebWidget::render;
};
#endif // POST_VIEW_H_