Project

General

Profile

Bug #1401 ยป main.cpp

Rob Van Dyck, 08/17/2012 09:36 AM

 
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WInPlaceEdit>
#include <Wt/WLength>
#include <Wt/WSuggestionPopup>
#include <Wt/WStandardItemModel>
#include <Wt/WLineEdit>
#include <Wt/WText>
#include <Wt/WString>
#include <Wt/WTableView>
#include <Wt/WTreeView>
#include <Wt/WStandardItem>
#include <Wt/WItemDelegate>
#include <Wt/WDialog>
#include <Wt/WPushButton>
#include <Wt/WAbstractProxyModel>
#include <Wt/WEvent>
#include <Wt/WSignal>
#include <Wt/WModelIndex>
#include <Wt/WHBoxLayout>
#include <Wt/WVBoxLayout>
#include <Wt/WGroupBox>
#include <Wt/WTemplate>
#include <Wt/WStackedWidget>
#include <Wt/WMenu>
#include <Wt/WServer>
#include <Wt/WSubMenuItem>
#include <Wt/WMenuItem>
#include <Wt/WTabWidget>
#include <Wt/WSpinBox>
#include <Wt/WImage>
#include <Wt/WRectArea>
#include <Wt/WRadioButton>
#include <Wt/WStreamResource>


#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include <Wt/WPainter>
#include <Wt/WPaintDevice>
#include <Wt/WPaintedWidget>
#include <Wt/WTableView>

#include <fstream>
#include <sstream>

#include <boost/thread.hpp>
#include <boost/foreach.hpp>

using namespace Wt;
using namespace boost;

using std::string;
using std::list;


class MyApplication: public WApplication {

public:
MyApplication(const Wt::WEnvironment& env);
WTableView *inputs1_;
WStandardItemModel *input_model1_;
void add_input();
WTableView* inputs2_;
WStandardItemModel *input_model2_;

};

MyApplication::MyApplication(const Wt::WEnvironment& env)
: Wt::WApplication(env)
{
inputs1_ = new WTableView();
input_model1_ = new WStandardItemModel(0, 1, this);
inputs1_->setModel(input_model1_);
inputs1_->setSelectable(true);
inputs1_->setSelectionMode(SelectionMode::SingleSelection);
inputs1_->setHeight(WLength(200));
inputs1_->setMinimumSize(WLength::Auto, WLength(200));
inputs1_->setMaximumSize(WLength::Auto, WLength(200));

inputs2_ = new WTableView();
input_model2_ = new WStandardItemModel(0, 1, this);
inputs2_->setModel(input_model2_);
inputs2_->setSelectable(true);
inputs2_->setSelectionMode(SelectionMode::SingleSelection);
inputs2_->setHeight(WLength(200));
inputs2_->setMinimumSize(WLength::Auto, WLength(200));
inputs2_->setMaximumSize(WLength::Auto, WLength(200));

WPushButton *pushbutton1_ = new WPushButton();
pushbutton1_->setText("add input1");
pushbutton1_->clicked().connect(boost::bind(&MyApplication::add_input, this));

root()->addWidget(inputs1_);
root()->addWidget(inputs2_);
root()->addWidget(pushbutton1_);

}

void MyApplication::add_input()
{
WStandardItem *name1__ = new WStandardItem("test");
input_model1_->setItem(0, 0, name1__);
inputs1_->select(input_model1_->index(0,0));
// WServer::instance()->post(WApplication::instance()->sessionId(), boost::bind(&WTableView::select, inputs1_, input_model1_->index(0, 0), ClearAndSelect));

WStandardItem *name2__ = new WStandardItem("test");
input_model2_->setItem(0, 0, name2__);
// inputs2_->select(input_model2_->index(0,0));
WServer::instance()->post(WApplication::instance()->sessionId(), boost::bind(&WTableView::select, inputs2_, input_model2_->index(0, 0), ClearAndSelect));
}

WApplication* createApplication(const Wt::WEnvironment& env)
{
WApplication* app = new MyApplication(env);
return app;
}

int main(int argc, char *argv[])
{
return Wt::WRun(argc, argv, &createApplication);
}
    (1-1/1)