Project

General

Profile

troubles with a WTableView

Added by fedya fedyakov about 11 years ago

Guys,

I have some troubles with WTableView. The first one is the WTableView doesn't scroll to the last row, but to the row just before last one, leaving the last row invisible.

I believe that the code like this

WAbstractTableModel* model = table_view->model();

table_view~~scrollTo(model>index(modelrowCount()~~ 1, 0));

should do the trick, but in fact it doesn't.

The second one is a very long time takes WTableView to change selection in response to mouse click.

Actually it takes about half a second to select the row being clicked.

Is there a way to get it to work faster?

Thanks


Replies (6)

RE: troubles with a WTableView - Added by fedya fedyakov about 11 years ago

I'm new to Wt, so I'm sorry if these questions look stupid...

RE: troubles with a WTableView - Added by Koen Deforche about 11 years ago

Hey,

Your first problem seems indeed to be a regression with scrollTo() API. I'll take a look at it.

The long timeout for mouse click is because of a timeout that has been added to differentiate with double clicks. This has already been reported as a bug and indeed we can fix this by only keeping this delay if there is effectively any interest in the double click signal.

Thanks,

koen

RE: troubles with a WTableView - Added by Koen Deforche about 11 years ago

Hey,

I seem to be underestimating the library: both these problems no longer exist with Wt 3.3.0(RC2).

In fact, the second issues should have been fixed since Wt 3.2.3 --- what version are you using ?

Regards,

koen

RE: troubles with a WTableView - Added by fedya fedyakov about 11 years ago

Hey Koen,

I'm using 3.3.0 rc2 and as I can see, the problems are still there.

May be the root of the first problem ( not showing of the last row in the table) due to inpack of the layout manager?

My ui cosists of two WTableView-s and two WCartesianChart-s

void create_ui() {

create_master_table();

create_slave_table();

create_charts();

setup_charts();

WGridLayout *grid = new WGridLayout();

grid->addWidget(createTitle(WString::fromUTF8("Measures")), 0, 0);

grid->addWidget(createTitle(WString::fromUTF8("Испытания")), 0, 1);

grid->addWidget(slave_table_, 1, 0);

grid->addWidget(master_table_, 1, 1);

grid->setColumnStretch(1, 1);

grid->setRowStretch(1, 1);

grid->setColumnResizable(0);

WHBoxLayout *hbox = new WHBoxLayout();

hbox->addWidget(slave_plot_, 1);

hbox->addWidget(narrowed_slave_plot_, 1);

hbox->setResizable(0);

WVBoxLayout *vbox = new WVBoxLayout();

vbox->addLayout(grid);

vbox->addLayout(hbox);

vbox->setResizable(0);

setLayout(vbox);

}

And at the some point the following method is called

void master_select_last_row() {

master_table_->selectionChanged().setBlocked(true);

BOOST_SCOPE_EXIT(master_table_) {

master_table_->selectionChanged().setBlocked(false);

} BOOST_SCOPE_EXIT_END;

if (int n = master_model_->rowCount()) {

---n;

master_table_scrollTo(master_model_>index(n, 0));

master_table_select(master_model_>index(n, 0));

}

}

And after this code being executed the WTableView scrolls to the row just before the last one which is

still invisible and selected.

As for the next problem - is I said before - I have two tables ( WTableView ) master one and slave one and

two plots ( WCartesialChart ). Master table shows about 10 - 15 rows and slave table ~ 25 - 30 (slave table contains ~250 - 300 records).

changing the current row of the master table lead to chandge the of content of the slave one.

void slave_model_t::set_current(int cur) {

if (cur < data_.size()) {

layoutAboutToBeChanged().emit();

// current is the master record index

current_ = cur;

layoutChanged().emit();

}

}

Which in turn leads to repaint of the plots (250-300 points).

On the console this activity looks as a bunch of web requests with a very

long roundtrip.

[2013-Mar-03 13:03:39.311817] 6112 - [info] "WebRequest: too1k2 72.7707..01.61m

s~~\"~~ [2013-Mar-03 13:03:39.325817] "POST /pctl?wtd=3HT4KAZigEOda8Ns HTTP/1.1\" 2

00 50

[2013-Mar-03 13:03:39.355819] 6112 - [info] "WebRequest: took 52.003ms"

[2013-Mar-03 13:03:39.408822] 6112 - [info] "WebRequest: took 41.002ms"

127.0.0.1 - - [2013-Mar-03 13:03:39.418823] "POST /pctl?wtd=3HT4KAZigEOda8Ns HTT

P/1.1" 200 50

[2013-Mar-03 13:03:39.433823] 6112 - [info] "WebRequest: took 31.001ms"

[2013-Mar-03 13:03:39.614834] 6112 - [info] "WebRequest: took 169.01ms"

127.0.0.1 - - [2013-Mar-03 13:03:39.841847] "POST /pctl?wtd=3HT4KAZigEOda8Ns HTT

P/1.1" 200 4864

[2013-Mar-03 13:03:39.858848] 6112 - [info] "WebRequest: took 353.015ms"

Regards

fedya

RE: troubles with a WTableView - Added by fedya fedyakov about 11 years ago

Oh, sorry for my poor english.

I think I could try to cope with this by not just directly

switch the current record in the event handler as I currently do

void on_master_selection_changed() {

int row = selected_row();

if (row != --1) {

master_model_->set_current(row);

}

}

but make something like this

void on_master_selection_changed() {

int row = selected_row();

if (row != --1) {

///master_model_->set_current(row);

WServer::instance()post( WApplication::instance()>sessionId(),

std::bind(&master_model_t::set_current_row, master_model, row));

}

}

hope it'll do the trick

    (1-6/6)