10 #include <Wt/WApplication> 11 #include <Wt/WContainerWidget> 12 #include <Wt/WEnvironment> 13 #include <Wt/WLineEdit> 14 #include <Wt/WGridLayout> 15 #include <Wt/WHBoxLayout> 16 #include <Wt/WPushButton> 19 #include <Wt/WTreeView> 20 #include <Wt/WVBoxLayout> 21 #include <Wt/WViewWidget> 24 #include "../wt-homepage/SourceView.h" 47 useStyleSheet(
"gitview.css");
48 setTitle(
"Git model example");
50 const char *gitRepo = getenv(
"GITVIEW_REPOSITORY_PATH");
61 repositoryEdit_->setTextSize(30);
62 revisionEdit_->setTextSize(20);
63 repositoryError_->setStyleClass(
"error-msg");
64 revisionError_->setStyleClass(
"error-msg");
66 repositoryEdit_->enterPressed()
68 revisionEdit_->enterPressed()
77 gitView_->setSortingEnabled(
false);
78 gitView_->setModel(gitModel_ =
new GitModel(
this));
79 gitView_->setSelectionMode(SingleSelection);
85 sourceView_->setStyleClass(
"source-view");
87 if (environment().javaScript()) {
100 root()->setLayout(topLayout);
101 root()->setStyleClass(
"maindiv");
107 root()->setStyleClass(
"maindiv");
110 root()->addWidget(top);
111 root()->addWidget(gitView_);
112 gitView_->setFloatSide(
Left);
113 gitView_->setMargin(6);
114 root()->addWidget(sourceView_);
115 sourceView_->setMargin(6);
137 revisionError_->
setText(e.what());
140 repositoryError_->
setText(e.what());
160 int main(
int argc,
char **argv)
void setRepositoryPath(const std::string &repositoryPath)
Set the repository and load its 'master' revision.
int main(int argc, char **argv)
const WString & text() const
void addWidget(std::unique_ptr< WWidget > widget, int row, int column, WFlags< AlignmentFlag > alignment)
void loadGitModel()
Change repository and/or revision.
void addLayout(std::unique_ptr< WLayout > layout, int stretch, WFlags< AlignmentFlag > alignment)
void addWidget(std::unique_ptr< WWidget > widget, int stretch, WFlags< AlignmentFlag > alignment)
WApplication * createApplication(const WEnvironment &env)
static const int ContentsRole
The role which may be used on a file to retrieve its contents.
A simple application to navigate a git repository.
bool setText(const WString &text)
void showFile()
Displayed the currently selected file.
GitViewApplication(const WEnvironment &env)
Constructor.
std::string toUTF8() const
WLineEdit * revisionEdit_
WModelIndexSet selectedIndexes() const
View class for source code.
bool setIndex(const Wt::WModelIndex &index)
Sets the model index.
static const int FilePathRole
A model that retrieves revision trees from a git repository.
void loadRevision(const std::string &revName)
Load a particular revision.