diff --git a/src/BoolQuestion.cpp b/src/BoolQuestion.cpp index 44e17ec..9f9c43e 100644 --- a/src/BoolQuestion.cpp +++ b/src/BoolQuestion.cpp @@ -85,8 +85,7 @@ std::ostream& operator<<(std::ostream& out, const BoolQuestion& question) { return out << question.print(); } -Wt::WTreeTableNode* BoolQuestion::widget() { - Wt::WTreeTableNode* node = Question::widget(); +Wt::WContainerWidget* BoolQuestion::widget() { Wt::WContainerWidget* container = new Wt::WContainerWidget(); Wt::WButtonGroup* group = new Wt::WButtonGroup(container); @@ -97,6 +96,5 @@ Wt::WTreeTableNode* BoolQuestion::widget() { yes->checked().connect(boost::bind(&BoolQuestion::setAnswer, this, true)); no->checked().connect(boost::bind(&BoolQuestion::setAnswer, this, false)); - node->setColumnWidget(1, container); - return node; + return container; } diff --git a/src/BoolQuestion.h b/src/BoolQuestion.h index bcad78e..7c883c5 100644 --- a/src/BoolQuestion.h +++ b/src/BoolQuestion.h @@ -22,7 +22,7 @@ class BoolQuestion : public AnswerQuestion { virtual void ask(); virtual std::ostream& save(std::ostream& out); - virtual Wt::WTreeTableNode* widget(); + virtual Wt::WContainerWidget* widget(); friend std::ostream& operator<<(std::ostream& out, const BoolQuestion& question); diff --git a/src/ChoiceQuestion.cpp b/src/ChoiceQuestion.cpp index 1ca55ab..8a41976 100644 --- a/src/ChoiceQuestion.cpp +++ b/src/ChoiceQuestion.cpp @@ -144,8 +144,7 @@ std::ostream& operator<<(std::ostream& out, const ChoiceQuestion& choiceQuestion return out << choiceQuestion.print() << choiceQuestion.printChoices(); } -Wt::WTreeTableNode* ChoiceQuestion::widget() { - Wt::WTreeTableNode* node = Question::widget(); +Wt::WContainerWidget* ChoiceQuestion::widget() { Wt::WContainerWidget* container = new Wt::WContainerWidget(); Wt::WComboBox* comboBox = new Wt::WComboBox(container); @@ -154,6 +153,5 @@ Wt::WTreeTableNode* ChoiceQuestion::widget() { } comboBox->changed().connect(boost::bind(&ChoiceQuestion::setAnswer, this, comboBox->currentIndex()+1)); - node->setColumnWidget(1, container); - return node; + return container; } diff --git a/src/ChoiceQuestion.h b/src/ChoiceQuestion.h index 2e6a68b..805ae01 100644 --- a/src/ChoiceQuestion.h +++ b/src/ChoiceQuestion.h @@ -27,7 +27,7 @@ class ChoiceQuestion: public AnswerQuestion { virtual void ask(); virtual std::ostream& save(std::ostream& out); - virtual Wt::WTreeTableNode* widget(); + virtual Wt::WContainerWidget* widget(); friend std::ostream& operator<<(std::ostream& out, const ChoiceQuestion& choiceQuestion); diff --git a/src/GroupQuestion.cpp b/src/GroupQuestion.cpp index e60867f..56af5a8 100644 --- a/src/GroupQuestion.cpp +++ b/src/GroupQuestion.cpp @@ -75,12 +75,7 @@ void GroupQuestion::insert(Question* q, Iterator previous) { } } -Wt::WTreeTableNode* GroupQuestion::widget() { - Wt::WTreeTableNode* node = Question::widget(); - for(Iterator it = begin(); it != end(); it.levelForward()) { - Wt::WTreeTableNode* child = (*it)->widget(); - node->addChildNode(child); - } +Wt::WContainerWidget* GroupQuestion::widget() { - return node; + return new Wt::WContainerWidget(); } diff --git a/src/GroupQuestion.h b/src/GroupQuestion.h index 948b940..2d0d2e3 100644 --- a/src/GroupQuestion.h +++ b/src/GroupQuestion.h @@ -8,7 +8,7 @@ #ifndef GROUPQUESTION_H_ #define GROUPQUESTION_H_ -#include"Wt/WTreeTableNode" +#include"Wt/WContainerWidget" #include "Question.h" #include "QuestionList.h" #include @@ -24,7 +24,7 @@ class GroupQuestion : public QuestionList, public Question{ virtual std::string print() const; - virtual Wt::WTreeTableNode* widget(); + virtual Wt::WContainerWidget* widget(); friend std::ostream& operator<<(std::ostream& out, const GroupQuestion& question) { return out << question.print(); diff --git a/src/OpenQuestion.cpp b/src/OpenQuestion.cpp index eb2f30e..5b5a635 100644 --- a/src/OpenQuestion.cpp +++ b/src/OpenQuestion.cpp @@ -85,14 +85,12 @@ std::ostream& operator<<(std::ostream& out, const OpenQuestion& openQuestion) { return out << openQuestion.print(); } -Wt::WTreeTableNode* OpenQuestion::widget() { - Wt::WTreeTableNode* node = Question::widget(); +Wt::WContainerWidget* OpenQuestion::widget() { Wt::WContainerWidget* container = new Wt::WContainerWidget(); Wt::WLineEdit* text = new Wt::WLineEdit(container); text->changed().connect(boost::bind(&OpenQuestion::setAnswer, this, text->text().toUTF8())); - node->setColumnWidget(1, container); - return node; + return container; } diff --git a/src/OpenQuestion.h b/src/OpenQuestion.h index 8b9003a..5b7ffce 100644 --- a/src/OpenQuestion.h +++ b/src/OpenQuestion.h @@ -8,7 +8,7 @@ #ifndef OPENQUESTION_H_ #define OPENQUESTION_H_ -#include "Wt/WTreeTableNode" +#include "Wt/WContainerWidget" #include "AnswerQuestion.h" #include @@ -22,7 +22,7 @@ class OpenQuestion: public AnswerQuestion { virtual void ask(); virtual std::ostream& save(std::ostream& out); - virtual Wt::WTreeTableNode* widget(); + virtual Wt::WContainerWidget* widget(); friend std::ostream& operator<<(std::ostream& out, const OpenQuestion& openQuestion); diff --git a/src/Question.cpp b/src/Question.cpp index 41cd94b..6cc61a9 100644 --- a/src/Question.cpp +++ b/src/Question.cpp @@ -77,13 +77,3 @@ std::ostream& operator<<(std::ostream& out, const Question& question) { return out << question.print(); } -Wt::WTreeTableNode* Question::widget() { - Wt::WCssDecorationStyle style; - style.setForegroundColor(Wt::WColor(0,255,0)); - - Wt::WTreeTableNode* node = new Wt::WTreeTableNode(getQuestion(), 0); - if(isOptional()) node->setDecorationStyle(style); - - return node; -} - diff --git a/src/Question.h b/src/Question.h index 9d79eb5..d9e9a54 100644 --- a/src/Question.h +++ b/src/Question.h @@ -8,7 +8,7 @@ #ifndef QUESTION_H_ #define QUESTION_H_ -#include"Wt/WTreeTableNode" +#include"Wt/WContainerWidget" #include class Question { @@ -25,7 +25,7 @@ class Question { virtual Question* copy() = 0; - virtual Wt::WTreeTableNode* widget(); + virtual Wt::WContainerWidget* widget() = 0; friend std::ostream& operator<<(std::ostream& out, const Question& question); diff --git a/src/ScaleQuestion.cpp b/src/ScaleQuestion.cpp index c10d7fc..634e1cb 100644 --- a/src/ScaleQuestion.cpp +++ b/src/ScaleQuestion.cpp @@ -114,8 +114,7 @@ std::ostream& operator<<(std::ostream& out, const ScaleQuestion& question) { return out << question.print(); } -Wt::WTreeTableNode* ScaleQuestion::widget() { - Wt::WTreeTableNode* node = Question::widget(); +Wt::WContainerWidget* ScaleQuestion::widget() { Wt::WContainerWidget* container = new Wt::WContainerWidget(); Wt::WSlider* slider = new Wt::WSlider(container); @@ -128,7 +127,6 @@ Wt::WTreeTableNode* ScaleQuestion::widget() { slider->valueChanged().connect(boost::bind(&ScaleQuestion::setAnswer, this, slider->value())); - node->setColumnWidget(1, container); - return node; + return container; } diff --git a/src/ScaleQuestion.h b/src/ScaleQuestion.h index d41208a..18505c2 100644 --- a/src/ScaleQuestion.h +++ b/src/ScaleQuestion.h @@ -24,7 +24,7 @@ class ScaleQuestion : public AnswerQuestion { virtual void ask(); virtual std::ostream& save(std::ostream& out); - virtual Wt::WTreeTableNode* widget(); + virtual Wt::WContainerWidget* widget(); friend std::ostream& operator<<(std::ostream& out, const ScaleQuestion& question); diff --git a/src/SurveyFiller.cpp b/src/SurveyFiller.cpp index b34a6a7..c668cfc 100644 --- a/src/SurveyFiller.cpp +++ b/src/SurveyFiller.cpp @@ -15,11 +15,14 @@ #include "Wt/WLink" #include "Wt/WSignal" #include "Wt/WText" -#include "Wt/WTree" -#include "Wt/WTreeTableNode" +#include "Wt/WCssDecorationStyle" +#include "Wt/WColor" +#include "Wt/WLineEdit" #include "Question.h" +#include + SurveyFiller::SurveyFiller(std::string title, std::string username) : title_(title),user_(username) { std::string filename("./"); @@ -31,8 +34,8 @@ SurveyFiller::SurveyFiller(std::string title, std::string username) : title_(tit //Title new Wt::WText(title_, this); //Tree - questionTree_ = new Wt::WTreeTable(this); - fillQuestionTree(); + questionTable = new Wt::WTable(this); + fillQuestionTable(); //Buttons save_ = new Wt::WPushButton("Save", this); save_->clicked().connect(this, &SurveyFiller::save); @@ -57,23 +60,26 @@ void SurveyFiller::save() { //} } -void SurveyFiller::fillQuestionTree() { - //one column for answers - questionTree_->tree()->setSelectionMode(Wt::ExtendedSelection); - questionTree_->addColumn("Answers", 120); +void SurveyFiller::fillQuestionTable() { + //default columns + questionTable->elementAt(0, 0)->addWidget(new Wt::WText("Path")); + questionTable->elementAt(0, 1)->addWidget(new Wt::WText("Question")); + questionTable->elementAt(0, 2)->addWidget(new Wt::WText("Answer")); - //rootnode - Wt::WTreeTableNode* root = new Wt::WTreeTableNode("Survey"); - questionTree_->setTreeRoot(root, "Questions"); + int i(1); //add questions - for(Questionary::Iterator it = questionary_->begin(); it != questionary_->end(); it.levelForward()) { - root->addChildNode((*it)->widget()); - } - root->expand(); - - //add optional to answered for(Questionary::Iterator it = questionary_->begin(); it != questionary_->end(); ++it) { + questionTable->elementAt(i, 0)->addWidget(new Wt::WText(it.getPath().print())); + Wt::WCssDecorationStyle style; + style.setForegroundColor(Wt::WColor(0,255,0)); + Wt::WText* question = new Wt::WText((*it)->getQuestion()); + if((*it)->isOptional()) question->setDecorationStyle(style); + questionTable->elementAt(i, 1)->addWidget(question); + questionTable->elementAt(i, 2)->addWidget((*it)->widget()); + + //optional? if((*it)->isOptional()) answered_.insert(*it); + ++i; } updateAnswered(); } diff --git a/src/SurveyFiller.h b/src/SurveyFiller.h index e42ea40..2907c6f 100644 --- a/src/SurveyFiller.h +++ b/src/SurveyFiller.h @@ -11,7 +11,7 @@ #include"Questionary.h" #include "QuestionList.h" #include -#include +#include #include #include #include @@ -22,7 +22,7 @@ class SurveyFiller : public Wt::WGroupBox { virtual ~SurveyFiller(); private: - void fillQuestionTree(); + void fillQuestionTable(); void save(); bool isCompleted(QuestionList& ql); @@ -32,7 +32,7 @@ class SurveyFiller : public Wt::WGroupBox { std::string user_; std::set answered_; Questionary *questionary_; - Wt::WTreeTable* questionTree_; + Wt::WTable* questionTable; Wt::WPushButton* save_; Wt::WPushButton* back_; };