Wt examples  4.10.0
Loading...
Searching...
No Matches
SourceView.h
Go to the documentation of this file.
1// This may look like C code, but it's really -*- C++ -*-
2/*
3 * Copyright (C) 2009 Emweb bv, Herent, Belgium
4 *
5 * See the LICENSE file for terms of use.
6 */
7
8#ifndef SOURCEVIEW_H
9#define SOURCEVIEW_H
10
11#include <Wt/WViewWidget.h>
12#include <Wt/WModelIndex.h>
13#include <Wt/WMemoryResource.h>
14
15using namespace Wt;
16
21
28class SourceView : public WViewWidget
29{
30public:
37 SourceView(ItemDataRole fileNameRole,
38 ItemDataRole contentRole,
39 ItemDataRole filePathRole);
40
43 virtual ~SourceView();
44
50 bool setIndex(const WModelIndex& index);
51
57 virtual std::unique_ptr<WWidget> renderView();
58
59private:
61 WModelIndex index_;
62
64 Wt::ItemDataRole fileNameRole_;
65 Wt::ItemDataRole contentRole_;
66 Wt::ItemDataRole filePathRole_;
67
68 std::shared_ptr<WMemoryResource> imageResource_;
69
70private:
71 std::string imageExtension(const std::string& fileName);
72};
73
76#endif //SOURCEVIEW_H
View class for source code.
Definition SourceView.h:29
virtual std::unique_ptr< WWidget > renderView()
Returns the widget that renders the view.
Definition SourceView.C:97
Wt::ItemDataRole filePathRole_
Definition SourceView.h:66
WModelIndex index_
The index that is currently displayed.
Definition SourceView.h:61
std::string imageExtension(const std::string &fileName)
Definition SourceView.C:203
bool setIndex(const WModelIndex &index)
Sets the model index.
Definition SourceView.C:32
Wt::ItemDataRole fileNameRole_
The role that is currently displayed.
Definition SourceView.h:64
std::shared_ptr< WMemoryResource > imageResource_
Definition SourceView.h:68
Wt::ItemDataRole contentRole_
Definition SourceView.h:65
virtual ~SourceView()
Destructor.
Definition SourceView.C:29