From ee80fb411825673bce497c0e37852e018531cf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Mon, 19 Sep 2011 01:16:29 +0000 Subject: [PATCH] [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 --- .../.src/Project/FPropertyProject.form | 2 +- .../gb.form.mdi/.src/Shortcut/FShortcut.form | 3 +- comp/src/gb.form/.lang/.pot | 4 + comp/src/gb.form/.project | 2 +- comp/src/gb.form/.src/Test/FMain.form | 10 +-- gb.qt4/src/CGridView.cpp | 77 ++++++++++--------- gb.qt4/src/CGridView.h | 6 +- main/gbx/gbx_c_string.c | 2 +- 8 files changed, 52 insertions(+), 54 deletions(-) diff --git a/app/src/gambas3/.src/Project/FPropertyProject.form b/app/src/gambas3/.src/Project/FPropertyProject.form index 59189813b..7f694ead7 100644 --- a/app/src/gambas3/.src/Project/FPropertyProject.form +++ b/app/src/gambas3/.src/Project/FPropertyProject.form @@ -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 diff --git a/comp/src/gb.form.mdi/.src/Shortcut/FShortcut.form b/comp/src/gb.form.mdi/.src/Shortcut/FShortcut.form index 61674bfae..27569e619 100644 --- a/comp/src/gb.form.mdi/.src/Shortcut/FShortcut.form +++ b/comp/src/gb.form.mdi/.src/Shortcut/FShortcut.form @@ -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) diff --git a/comp/src/gb.form/.lang/.pot b/comp/src/gb.form/.lang/.pot index d809f8e8f..431a2124c 100644 --- a/comp/src/gb.form/.lang/.pot +++ b/comp/src/gb.form/.lang/.pot @@ -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 "" diff --git a/comp/src/gb.form/.project b/comp/src/gb.form/.project index 05a6f02e8..7237239f6 100644 --- a/comp/src/gb.form/.project +++ b/comp/src/gb.form/.project @@ -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 diff --git a/comp/src/gb.form/.src/Test/FMain.form b/comp/src/gb.form/.src/Test/FMain.form index fe4e9953f..373c381b4 100644 --- a/comp/src/gb.form/.src/Test/FMain.form +++ b/comp/src/gb.form/.src/Test/FMain.form @@ -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") } } diff --git a/gb.qt4/src/CGridView.cpp b/gb.qt4/src/CGridView.cpp index f710af990..ae9c4d0cd 100644 --- a/gb.qt4/src/CGridView.cpp +++ b/gb.qt4/src/CGridView.cpp @@ -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); } } diff --git a/gb.qt4/src/CGridView.h b/gb.qt4/src/CGridView.h index 934bd4d1d..c0129241e 100644 --- a/gb.qt4/src/CGridView.h +++ b/gb.qt4/src/CGridView.h @@ -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; diff --git a/main/gbx/gbx_c_string.c b/main/gbx/gbx_c_string.c index 1eab9bffd..37396d52c 100644 --- a/main/gbx/gbx_c_string.c +++ b/main/gbx/gbx_c_string.c @@ -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; }