[INTERPRETER]

* BUG: Fix String.Pos(), and String.InStr() with a third argument.

[GB.QT4]
* BUG: GridView: Fix how the Change event is raised in single selection 
  mode.


git-svn-id: svn://localhost/gambas/trunk@4140 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2011-09-19 01:16:29 +00:00
parent 5ba145d20e
commit ee80fb4118
8 changed files with 52 additions and 54 deletions

View File

@ -311,7 +311,7 @@
Text = ("Environment variables")
}
{ tvwEnv TableView
MoveScaled(2,41,47,16)
MoveScaled(2,41,68,16)
Expand = True
Header = GridView.Horizontal
Scrollbar = Scroll.Vertical

View File

@ -14,8 +14,7 @@
Header = GridView.Horizontal
}
{ timAfter #Timer
#X = 444
#Y = 204
#MoveScaled(63.4286,29.1429)
}
{ HBox2 HBox
MoveScaled(1,51,84,4)

View File

@ -235,6 +235,10 @@ msgstr ""
msgid "Enabled"
msgstr ""
#: FMain.form:13
msgid "&Insérer"
msgstr ""
#: FMessage.form:39
msgid "Do not display this message again"
msgstr ""

View File

@ -1,7 +1,7 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.4
Title=More controls for graphical components
Startup=Main
Startup=FMain
Version=2.99.4
VersionProgram=gbx3 -V
Component=gb.image

View File

@ -5,12 +5,8 @@
#Scaled = False
Spacing = True
Margin = True
{ DateChooser1 DateChooser
Move(28,21,399,210)
Mode = DateChooser.DateTime
}
{ DateBox1 DateBox
Move(28,266,168,28)
Mode = DateChooser.DateTime
{ MenuButton1 MenuButton
Move(42,28,231,28)
Text = ("&Insérer")
}
}

View File

@ -463,8 +463,6 @@ Q3Table(0, 0, parent)
_header = 0;
_rows = 0;
_cols = 0;
_no_row = true;
_no_col = true;
_layouting_columns = false;
_autoresize = true;
_layout_columns_later = false;
@ -782,8 +780,7 @@ void MyTable::setNumCols(int newCols)
BEGIN_NO_REPAINT
{
b = signalsBlocked();
blockSignals(true);
b = blockSignals(true);
Q3Table::setNumCols(newCols);
if (newCols > _cols)
@ -812,7 +809,7 @@ void MyTable::setNumCols(int newCols)
setCurrentCell(row, col);
if (row >= 0 && col >= 0)
{
emit currentChanged(-1, -1);
//emit currentChanged(-1, -1);
emit selectionChanged();
}
}
@ -832,8 +829,7 @@ void MyTable::setNumRows(int newRows)
_rows = newRows;
_item->invalidate();
b = signalsBlocked();
blockSignals(true);
b = blockSignals(true);
Q3Table::setNumRows(newRows);
clearSelection();
@ -844,7 +840,7 @@ void MyTable::setNumRows(int newRows)
setCurrentCell(row, col);
if (row >= 0 && col >= 0)
{
emit currentChanged(-1, -1);
//emit currentChanged(-1, -1);
emit selectionChanged();
}
}
@ -891,21 +887,15 @@ void MyTable::setCurrentCell(int row, int col)
{
int rowspan, colspan;
_no_row = row < 0 || row >= numRows();
_no_col = col < 0 || col >= numCols();
if (_no_col && !_no_row)
{
_no_col = false;
col = 0;
}
if (_no_row || _no_col)
if (row < 0)
{
clearSelection();
emit currentChanged(-1, -1);
return;
}
if (col < 0)
col = 0;
if (selectionMode() != MultiRow)
{
@ -922,26 +912,21 @@ void MyTable::setCurrentCell(int row, int col)
void MyTable::updateCurrentCell()
{
bool b = blockSignals(true);
setCurrentCell(currentRow(), currentColumn());
blockSignals(b);
}
void MyTable::getCurrentCell(int *row, int *col)
{
if (row)
if (selectionMode() == SingleRow && !isRowReallySelected(currentRow()))
{
if (_no_row)
*row = -1;
else
*row = currentRow();
*row = *col = -1;
return;
}
if (col)
{
if (_no_col)
*col = -1;
else
*col = currentColumn();
}
*row = currentRow();
*col = currentColumn();
}
int MyTable::findSelection(int row)
@ -1149,6 +1134,18 @@ void MyTable::setContentsPos(int x, int y)
/** GridView *****************************************************************/
static void raise_change(void *_object)
{
int row, col;
WIDGET->getCurrentCell(&row, &col);
if (row == THIS->last_row && col == THIS->last_col)
return;
THIS->last_row = row;
THIS->last_col = col;
GB.Raise(THIS, EVENT_Change, NULL);
}
static MyTableItem *get_item(void *_object, bool create)
{
return (MyTableItem *)(!create ? WIDGET->item() : WIDGET->item(THIS->row, THIS->col));
@ -1905,6 +1902,8 @@ BEGIN_METHOD(CGRIDVIEW_new, GB_OBJECT parent)
THIS->row = -1;
THIS->col = -1;
THIS->last_row = -1;
THIS->last_col = -1;
END_METHOD
@ -1918,7 +1917,8 @@ END_METHOD
static void set_current_cell(CGRIDVIEW *_object, int row, int col)
{
WIDGET->clearSelection();
if (WIDGET->selectionMode() == Q3Table::MultiRow)
WIDGET->clearSelection();
WIDGET->setCurrentCell(row, col);
}
@ -2484,18 +2484,18 @@ bool CGridView::check(Q3Table *table, int row, int col)
void CGridView::changed(void)
{
int row, col;
//int row, col;
GET_SENDER();
MyTable *w = (MyTable *)sender();
//MyTable *w = (MyTable *)sender();
w->updateCurrentCell();
w->getCurrentCell(&row, &col);
WIDGET->updateCurrentCell();
//WIDGET->getCurrentCell(&row, &col);
//if (row < 0 || col < 0)
// return;
GB.Raise(THIS, EVENT_Change, 0);
raise_change(THIS);
}
void CGridView::activated(void)
@ -2508,11 +2508,12 @@ void CGridView::selected(void)
{
GET_SENDER();
if (WIDGET->selectionMode() == Q3Table::SingleRow)
{
raise_change(THIS);
GB.Raise(THIS, EVENT_Select, 0);
}
else
{
//QRect r(WIDGET->contentsToViewport(QPoint(WIDGET->contentsX(), WIDGET->contentsY())), QSize(WIDGET->contentsWidth(), WIDGET->contentsHeight()));
//WIDGET->viewport()->update();
GB.RaiseLater(THIS, EVENT_Select);
}
}

View File

@ -58,6 +58,8 @@ typedef
CWIDGET widget;
int row;
int col;
int last_row;
int last_col;
unsigned scroll_event : 1;
}
CGRIDVIEW;
@ -186,8 +188,6 @@ public:
virtual QRect cellGeometry(int row, int col) const;
void setDefaultRowHeight(int h) { _default_row_height = h; }
//virtual QRect cellRect(int row, int col) const
Q_SIGNALS:
void scrolled(void);
@ -220,8 +220,6 @@ private:
int _rows;
int _cols;
int _default_row_height;
bool _no_row;
bool _no_col;
bool _layouting_columns;
bool _layout_columns_later;
bool _autoresize;

View File

@ -192,7 +192,7 @@ static int index_to_byte(const char *str, int len, int index)
if (index <= 0)
return 0;
return utf8_get_pos(str, len, index) + 1;
return utf8_get_pos(str, len, index - 1) + 1;
}