|
#include <Wt/WApplication>
|
|
#include <Wt/WBreak>
|
|
#include <Wt/WContainerWidget>
|
|
#include <Wt/WLineEdit>
|
|
#include <Wt/WPushButton>
|
|
#include <Wt/WText>
|
|
|
|
#include <Wt/WTableView>
|
|
#include <Wt/WStandardItem>
|
|
#include <Wt/WStandardItemModel>
|
|
|
|
#include "boost/lexical_cast.hpp"
|
|
|
|
using namespace Wt;
|
|
|
|
class HelloApplication : public Wt::WApplication
|
|
{
|
|
public:
|
|
HelloApplication(const Wt::WEnvironment& env);
|
|
|
|
};
|
|
|
|
HelloApplication::HelloApplication(const Wt::WEnvironment& env)
|
|
: Wt::WApplication(env)
|
|
{
|
|
WTableView *table = new WTableView(root());
|
|
|
|
int rows = 5;
|
|
int cols = 2;
|
|
WStandardItemModel *model = new WStandardItemModel(rows, cols);
|
|
for (int i=0; i < rows; i++) {
|
|
for (int j=0; j < cols; j++) {
|
|
model->setData(i, j, "row " +
|
|
boost::lexical_cast<std::string>(i) +
|
|
", col " +
|
|
boost::lexical_cast<std::string>(j));
|
|
model->item(i, j)->setFlags(ItemIsSelectable |
|
|
ItemIsDragEnabled |
|
|
ItemIsDropEnabled);
|
|
}
|
|
}
|
|
|
|
table->setSelectionMode(SingleSelection);
|
|
table->setSelectionBehavior(SelectRows);
|
|
table->setDragEnabled(true);
|
|
table->setDropsEnabled(true);
|
|
|
|
table->setModel(model);
|
|
}
|
|
|
|
Wt::WApplication *createApplication(const Wt::WEnvironment& env)
|
|
{
|
|
return new HelloApplication(env);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
return Wt::WRun(argc, argv, &createApplication);
|
|
}
|