Skip to content

Commit b224445

Browse files
committed
#5364 Fixed triggering inline cell editor with polish characters.
1 parent 1174e92 commit b224445

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- BUGFIX: #5342 Fixed broken filtering in View data, when the View's source table name requires quoting (i.e. has whitespaces, etc.).
2020
- BUGFIX: #5347 Fixed SQL formatter to keep single-quote wrapper around string literals.
2121
- BUGFIX: #5370 Fixed cell inline editor context menu actions for Copy, Cut and Delete.
22+
- BUGFIX: #5364 Fixed triggering inline cell editor with polish characters.
2223
- BUGFIX: Fixed arbitrary crashes when opening SQL Editor, while having non-thread-safe SQLite extensions loaded in the active database.
2324

2425
### 3.4.17

SQLiteStudio3/guiSQLiteStudio/datagrid/sqlqueryitemdelegate.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ void SqlQueryItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
4747

4848
QWidget* SqlQueryItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
4949
{
50+
qDebug() << "create editor";
5051
UNUSED(option);
5152
if (!index.isValid())
5253
return nullptr;

SQLiteStudio3/guiSQLiteStudio/datagrid/sqlqueryview.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ void SqlQueryView::init()
4747
itemDelegate = new SqlQueryItemDelegate();
4848
setItemDelegate(itemDelegate);
4949
setMouseTracking(true);
50-
setEditTriggers(QAbstractItemView::AnyKeyPressed|QAbstractItemView::EditKeyPressed);
50+
// setEditTriggers(QAbstractItemView::AnyKeyPressed|QAbstractItemView::EditKeyPressed);
51+
setEditTriggers(QAbstractItemView::NoEditTriggers);
5152

5253
setContextMenuPolicy(Qt::CustomContextMenu);
5354
contextMenu = new QMenu(this);
@@ -668,6 +669,28 @@ void SqlQueryView::scrollContentsBy(int dx, int dy)
668669
emit scrolledBy(dx, dy);
669670
}
670671

672+
void SqlQueryView::keyPressEvent(QKeyEvent *e)
673+
{
674+
// Overriden EditTrigger, so it works consistently across platforms.
675+
// Default implementation caused problem with Polish characters under Windows (#5364)
676+
const QString txt = e->text();
677+
bool shouldOpenEditor = false;
678+
if (!txt.isEmpty() && txt.at(0).isPrint())
679+
{
680+
if (state() != QAbstractItemView::EditingState)
681+
shouldOpenEditor = true;
682+
// edit(currentIndex());
683+
}
684+
685+
QTableView::keyPressEvent(e);
686+
687+
if (shouldOpenEditor)
688+
{
689+
edit(currentIndex());
690+
QApplication::sendEvent(focusWidget(), e);
691+
}
692+
}
693+
671694
void SqlQueryView::updateCommitRollbackActions(bool enabled)
672695
{
673696
actionMap[COMMIT]->setEnabled(enabled);

SQLiteStudio3/guiSQLiteStudio/datagrid/sqlqueryview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class GUI_API_EXPORT SqlQueryView : public QTableView, public ExtActionContainer
9393

9494
protected:
9595
void scrollContentsBy(int dx, int dy);
96+
void keyPressEvent(QKeyEvent *e);
9697

9798
private:
9899
class Header : public QHeaderView

0 commit comments

Comments
 (0)