summaryrefslogtreecommitdiffstats
path: root/kexi/widget/tableview/kexicomboboxbase.cpp
blob: 89ba63cf94c1f5aa643ad2505a8638fbdfead2c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
/* This file is part of the KDE project
   Copyright (C) 2002 Peter Simonsson <psn@linux.se>
   Copyright (C) 2003-2007 Jaroslaw Staniek <js@iidea.pl>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#include <tqlayout.h>
#include <tqstyle.h>
#include <tqwindowsstyle.h>
#include <tqpainter.h>

#include "kexicomboboxbase.h"
#include <widget/utils/kexicomboboxdropdownbutton.h>
#include "kexicomboboxpopup.h"
#include "kexitableview.h"
#include "kexitableitem.h"
#include "kexi.h"

#include <klineedit.h>

KexiComboBoxBase::KexiComboBoxBase()
{
	m_internalEditorValueChanged = false; //user has text or other value inside editor
	m_slotInternalEditorValueChanged_enabled = true;
	m_mouseBtnPressedWhenPopupVisible = false;
	m_insideCreatePopup = false;
	m_setValueOrTextInInternalEditor_enabled = true;
	m_updatePopupSelectionOnShow = true;
	m_moveCursorToEndInInternalEditor_enabled = true;
	m_selectAllInInternalEditor_enabled = true;
	m_setValueInInternalEditor_enabled = true;
	m_setVisibleValueOnSetValueInternal = false;
}

KexiComboBoxBase::~KexiComboBoxBase()
{
}

KexiDB::LookupFieldSchema *KexiComboBoxBase::lookupFieldSchema() const
{
	if (field() && field()->table()) {
		KexiDB::LookupFieldSchema *lookupFieldSchema = field()->table()->lookupFieldSchema( *field() );
		if (lookupFieldSchema && !lookupFieldSchema->rowSource().name().isEmpty())
			return lookupFieldSchema;
	}
	return 0;
}

int KexiComboBoxBase::rowToHighlightForLookupTable() const
{
	if (!popup())
		return -1;//err
	KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema();
	if (!lookupFieldSchema)
		return -1;
	if (lookupFieldSchema->boundColumn()==-1)
		return -1; //err
	bool ok;
	const int rowUid = origValue().toInt();
//! @todo for now we're assuming the id is INTEGER
	KexiTableViewData *tvData = popup()->tableView()->KexiDataAwareObjectInterface::data();
	const int boundColumn = lookupFieldSchema->boundColumn();
	KexiTableViewData::Iterator it(tvData->iterator());
	int row=0;
	for (;it.current();++it, row++)
	{
		if (it.current()->at(boundColumn).toInt(&ok) == rowUid && ok || !ok)
			break;
	}
	if (!ok || !it.current()) //item not found: highlight 1st row, if available
		return -1;
	return row;
}

void KexiComboBoxBase::setValueInternal(const TQVariant& add_, bool removeOld)
{
	Q_UNUSED(removeOld);
	m_mouseBtnPressedWhenPopupVisible = false;
	m_updatePopupSelectionOnShow = true;
	TQString add(add_.toString());
	if (add.isEmpty()) {
		KexiTableViewData *relData = column() ? column()->relatedData() : 0;
		TQVariant valueToSet;
		bool hasValueToSet = true;
		int rowToHighlight = -1;
		KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema();
		if (lookupFieldSchema) {
			//use 'lookup field' model
//! @todo support more RowSourceType's, not only table
			if (lookupFieldSchema->boundColumn()==-1)
//! @todo errmsg
				return;
			if (m_setVisibleValueOnSetValueInternal) {
				//only for table views
				if (!popup())
					createPopup(false/*!show*/);
			}
			if (popup()) {
				const int rowToHighlight = rowToHighlightForLookupTable();
				popup()->tableView()->setHighlightedRow(rowToHighlight);

				const int visibleColumn = lookupFieldSchema->visibleColumn( popup()->tableView()->KexiDataAwareObjectInterface::data()->columnsCount() );
				if (m_setVisibleValueOnSetValueInternal && -1!=visibleColumn) {
					//only for table views
					KexiTableItem *it = popup()->tableView()->highlightedItem();
					if (it)
						valueToSet = it->at( visibleColumn );
				}
				else {
					hasValueToSet = false;
				}
			}
		}
		else if (relData) {
			//use 'related table data' model
			valueToSet = valueForString(origValue().toString(), &rowToHighlight, 0, 1);
		}
		else {
			//use 'enum hints' model
			const int row = origValue().toInt();
			valueToSet = field()->enumHint(row).stripWhiteSpace();
		}
		if (hasValueToSet)
			setValueOrTextInInternalEditor( valueToSet );
		/*impl.*/moveCursorToEndInInternalEditor();
		/*impl.*/selectAllInInternalEditor();
		
		if (popup()) {
			if (origValue().isNull()) {
				popup()->tableView()->clearSelection();
				popup()->tableView()->setHighlightedRow(0);
			} else {
				if (relData) {
					if (rowToHighlight!=-1)
						popup()->tableView()->setHighlightedRow(rowToHighlight);
				}
				else if (!lookupFieldSchema) {
					//popup()->tableView()->selectRow(origValue().toInt());
					popup()->tableView()->setHighlightedRow(origValue().toInt());
				}
			}
		}
	}
	else {
		//todo: autocompl.?
		if (popup())
			popup()->tableView()->clearSelection();
		/*impl.*/setValueInInternalEditor(add); //not setLineEditText(), because 'add' is entered by user!
		//setLineEditText( add );
		/*impl.*/moveCursorToEndInInternalEditor();
	}
}

KexiTableItem* KexiComboBoxBase::selectItemForEnteredValueInLookupTable(const TQVariant& v)
{
	KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema();
	if (!popup() || !lookupFieldSchema)
		return 0; //safety
//-not effective for large sets: please cache it!
//.stripWhiteSpace() is not generic!

	const bool valueIsText = v.type()==TQVariant::String || v.type()==TQVariant::CString; //most common case
	const TQString txt( valueIsText ? v.toString().stripWhiteSpace().lower() : TQString() );
	KexiTableViewData *lookupData = popup()->tableView()->KexiDataAwareObjectInterface::data();
	const int visibleColumn = lookupFieldSchema->visibleColumn( lookupData->columnsCount() );
	if (-1 == visibleColumn)
		return 0;
	KexiTableViewData::Iterator it(lookupData->iterator());
	int row;
	for (row = 0;it.current();++it, row++) {
		if (valueIsText) {
			if (it.current()->at(visibleColumn).toString().stripWhiteSpace().lower() == txt)
				break;
		}
		else {
			if (it.current()->at(visibleColumn) == v)
				break;
		}
	}

	m_setValueOrTextInInternalEditor_enabled = false; // <-- this is the entered value, 
	                                                  //     so do not change the internal editor's contents
	if (it.current())
		popup()->tableView()->selectRow(row);
	else
		popup()->tableView()->clearSelection();

	m_setValueOrTextInInternalEditor_enabled = true;

	return it.current();
}

TQString KexiComboBoxBase::valueForString(const TQString& str, int* row, 
	uint lookInColumn, uint returnFromColumn, bool allowNulls)
{
	KexiTableViewData *relData = column() ? column()->relatedData() : 0;
	if (!relData)
		return TQString(); //safety
	//use 'related table data' model
	//-not effective for large sets: please cache it!
	//.stripWhiteSpace() is not generic!

	const TQString txt = str.stripWhiteSpace().lower();
	KexiTableViewData::Iterator it( relData->iterator() );
	for (*row = 0;it.current();++it, (*row)++) {
		if (it.current()->at(lookInColumn).toString().stripWhiteSpace().lower()==txt)
			break;
	}
	if (it.current())
		return it.current()->at(returnFromColumn).toString();

	*row = -1;

	if (column() && column()->relatedDataEditable())
		return str; //new value entered and that's allowed

	kexiwarn << "KexiComboBoxBase::valueForString(): no related row found, ID will be painted!" << endl;
	if (allowNulls)
		return TQString();
	return str; //for sanity but it's weird to show id to the user
}

TQVariant KexiComboBoxBase::value()
{
	KexiTableViewData *relData = column() ? column()->relatedData() : 0;
	KexiDB::LookupFieldSchema *lookupFieldSchema = 0;
	if (relData) {
		if (m_internalEditorValueChanged) {
			//we've user-entered text: look for id
//TODO: make error if matching text not found?
			int rowToHighlight;
			return valueForString(m_userEnteredValue.toString(), &rowToHighlight, 1, 0, true/*allowNulls*/);
		}
		else {
			//use 'related table data' model
			KexiTableItem *it = popup() ? popup()->tableView()->selectedItem() : 0;
			return it ? it->at(0) : origValue();//TQVariant();
		}
	}
	else if ((lookupFieldSchema = this->lookupFieldSchema()))
	{
		if (lookupFieldSchema->boundColumn()==-1)
			return origValue();
		KexiTableItem *it = popup() ? popup()->tableView()->selectedItem() : 0;
		if (/*!it &&*/ m_internalEditorValueChanged && !m_userEnteredValue.toString().isEmpty()) { //
			//try to select a row using the user-entered text
			if (!popup()) {
				TQVariant prevUserEnteredValue = m_userEnteredValue;
				createPopup(false);
				m_userEnteredValue = prevUserEnteredValue;
			}
			it = selectItemForEnteredValueInLookupTable( m_userEnteredValue );
		}
		return it ? it->at( lookupFieldSchema->boundColumn() ) : TQVariant();
	}
	else if (popup()) {
		//use 'enum hints' model
		const int row = popup()->tableView()->currentRow();
		if (row>=0)
			return TQVariant( row );
	}

	if (valueFromInternalEditor().toString().isEmpty())
		return TQVariant();
/*! \todo don't return just 1st row, but use autocompletion feature
      and: show message box if entered text does not match! */
	return origValue(); //unchanged
}

TQVariant KexiComboBoxBase::visibleValueForLookupField()
{
	KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema();
	if (!popup() || !lookupFieldSchema)
		return TQVariant();
	const int visibleColumn = lookupFieldSchema->visibleColumn( popup()->tableView()->KexiDataAwareObjectInterface::data()->columnsCount() );
	if (-1 == visibleColumn)
		return TQVariant();
	KexiTableItem *it = popup()->tableView()->selectedItem();
	return it ? it->at( TQMIN( (uint)visibleColumn, it->count()-1)/*sanity*/ ) : TQVariant();
}

TQVariant KexiComboBoxBase::visibleValue()
{
	return m_visibleValue;
}

void KexiComboBoxBase::clear()
{
	if (popup())
		popup()->hide();
	slotInternalEditorValueChanged(TQVariant());
}

tristate KexiComboBoxBase::valueChangedInternal()
{
	//avoid comparing values:
	KexiTableViewData *relData = column() ? column()->relatedData() : 0;
	KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema();
	if (relData || lookupFieldSchema) {
		if (m_internalEditorValueChanged)
			return true;

		//use 'related table data' model
		KexiTableItem *it = popup() ? popup()->tableView()->selectedItem() : 0;
		if (!it)
			return false;
	}
	else {
		//use 'enum hints' model
		const int row = popup() ? popup()->tableView()->currentRow() : -1;
		if (row<0 && !m_internalEditorValueChanged/*true if text box is cleared*/)
			return false;
	}

	return cancelled;
}

bool KexiComboBoxBase::valueIsNull()
{
//	bool ok;
	TQVariant v( value() );
	return v.isNull();
//	return !ok || v.isNull();
}

bool KexiComboBoxBase::valueIsEmpty()
{
	return valueIsNull();
}

void KexiComboBoxBase::showPopup()
{
	createPopup(true);
}

void KexiComboBoxBase::createPopup(bool show)
{
	if (!field())
		return;
	m_insideCreatePopup = true;
	TQWidget* thisWidget = dynamic_cast<TQWidget*>(this);
	TQWidget *widgetToFocus = internalEditor() ? internalEditor() : thisWidget;
	if (!popup()) {
		setPopup( column() ? new KexiComboBoxPopup(thisWidget, *column()) 
			: new KexiComboBoxPopup(thisWidget, *field()) );
		TQObject::connect(popup(), TQT_SIGNAL(rowAccepted(KexiTableItem*,int)), 
			thisWidget, TQT_SLOT(slotRowAccepted(KexiTableItem*,int)));
		TQObject::connect(popup()->tableView(), TQT_SIGNAL(itemSelected(KexiTableItem*)),
			thisWidget, TQT_SLOT(slotItemSelected(KexiTableItem*)));

		popup()->setFocusProxy( widgetToFocus );	
		popup()->tableView()->setFocusProxy( widgetToFocus );
		popup()->installEventFilter(thisWidget);

		if (origValue().isNull())
			popup()->tableView()->clearSelection();
		else {
			popup()->tableView()->selectRow( 0 );
			popup()->tableView()->setHighlightedRow( 0 );
		}
	}
	if (show && internalEditor() && !internalEditor()->isVisible())
		/*emit*/editRequested();

	TQPoint posMappedToGlobal = mapFromParentToGlobal(thisWidget->pos());
	if (posMappedToGlobal != TQPoint(-1,-1)) {
//! todo alter the position to fit the popup within screen boundaries
		popup()->move( posMappedToGlobal + TQPoint(0, thisWidget->height()) );
		//to avoid flickering: first resize to 0-height, then show and resize back to prev. height
		const int w = popupWidthHint();
		popup()->resize(w, 0);
		if (show)
			popup()->show();
		popup()->updateSize(w);
		if (m_updatePopupSelectionOnShow) {
			int rowToHighlight = -1;
			KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema();
			KexiTableViewData *relData = column() ? column()->relatedData() : 0;
			if (lookupFieldSchema) {
				rowToHighlight = rowToHighlightForLookupTable();
			}
			else if (relData) {
				(void)valueForString(origValue().toString(), &rowToHighlight, 0, 1);
			}
			else //enum hint
				rowToHighlight = origValue().toInt();

/*-->*/	m_moveCursorToEndInInternalEditor_enabled = show;
			m_selectAllInInternalEditor_enabled = show;
			m_setValueInInternalEditor_enabled = show;
			if (rowToHighlight==-1) {
				rowToHighlight = TQMAX( popup()->tableView()->highlightedRow(), 0);
				setValueInInternalEditor(TQVariant());
			}
			popup()->tableView()->selectRow( rowToHighlight );
			popup()->tableView()->setHighlightedRow( rowToHighlight );
			if (rowToHighlight < popup()->tableView()->rowsPerPage())
				popup()->tableView()->ensureCellVisible( 0, -1 );

/*-->*/	m_moveCursorToEndInInternalEditor_enabled = true;
			m_selectAllInInternalEditor_enabled = true;
			m_setValueInInternalEditor_enabled = true;
		}
	}

	if (show) {
		moveCursorToEndInInternalEditor();
		selectAllInInternalEditor();
		widgetToFocus->setFocus();
	}
	m_insideCreatePopup = false;
}

void KexiComboBoxBase::hide()
{
	if (popup())
		popup()->hide();
}

void KexiComboBoxBase::slotRowAccepted(KexiTableItem * item, int row)
{
	Q_UNUSED(row);
	//update our value
	//..nothing to do?
	updateButton();
	slotItemSelected(item);
	/*emit*/acceptRequested();
}

void KexiComboBoxBase::acceptPopupSelection()
{
	if (!popup())
		return;
	KexiTableItem *item = popup()->tableView()->highlightedItem();
	if (item) {
		popup()->tableView()->selectRow( popup()->tableView()->highlightedRow() );
		slotRowAccepted(item, -1);
	}
	popup()->hide();
}

void KexiComboBoxBase::slotItemSelected(KexiTableItem*)
{
	kexidbg << "KexiComboBoxBase::slotItemSelected(): m_visibleValue = " << m_visibleValue << endl;

	TQVariant valueToSet;
	KexiTableViewData *relData = column() ? column()->relatedData() : 0;
	KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema();

	m_visibleValue = lookupFieldSchema ? visibleValueForLookupField() : TQVariant();

	if (relData) {
		//use 'related table data' model
		KexiTableItem *item = popup()->tableView()->selectedItem();
		if (item)
			valueToSet = item->at(1);
	}
	else if (lookupFieldSchema) {
		KexiTableItem *item = popup()->tableView()->selectedItem();
		const int visibleColumn = lookupFieldSchema->visibleColumn( popup()->tableView()->KexiDataAwareObjectInterface::data()->columnsCount() );
		if (item && visibleColumn!=-1 /* && (int)item->size() >= visibleColumn --already checked*/) {
			valueToSet = item->at( TQMIN( (uint)visibleColumn, item->count()-1)/*sanity*/ );
		}
	}
	else {
		//use 'enum hints' model
		valueToSet = field()->enumHint( popup()->tableView()->currentRow() );
		if (valueToSet.toString().isEmpty() && !m_insideCreatePopup) {
			clear();
			TQWidget* thisWidget = dynamic_cast<TQWidget*>(this);
			thisWidget->parentWidget()->setFocus();
			return;
		}
	}
	setValueOrTextInInternalEditor( valueToSet );
	if (m_setValueOrTextInInternalEditor_enabled) {
		moveCursorToEndInInternalEditor();
		selectAllInInternalEditor();
	}
	// a new (temp) popup table index is selected: do not update selection next time:
	m_updatePopupSelectionOnShow = false;
}

void KexiComboBoxBase::slotInternalEditorValueChanged(const TQVariant& v)
{
	if (!m_slotInternalEditorValueChanged_enabled)
		return;
	m_userEnteredValue = v;
	m_internalEditorValueChanged = true;
	if (v.toString().isEmpty()) {
		if (popup()) {
			popup()->tableView()->clearSelection();
		}
		return;
	}
}

void KexiComboBoxBase::setValueOrTextInInternalEditor(const TQVariant& value)
{
	if (!m_setValueOrTextInInternalEditor_enabled)
		return;
	setValueInInternalEditor( value );
	//this text is not entered by hand:
	m_userEnteredValue = TQVariant();
	m_internalEditorValueChanged = false;
}

bool KexiComboBoxBase::handleKeyPressForPopup( TQKeyEvent *ke )
{
	const int k = ke->key();
	int highlightedOrSelectedRow = popup() ? popup()->tableView()->highlightedRow() : -1;
	if (popup() && highlightedOrSelectedRow < 0)
		highlightedOrSelectedRow = popup()->tableView()->currentRow();

	const bool enterPressed = k==TQt::Key_Enter || k==TQt::Key_Return;

	// The editor may be active but the pull down menu not existant/visible,
	// e.g. when the user has pressed a normal button to activate the editor
	// Don't handle the event here in that case.
	if (!popup() || (!enterPressed && !popup()->isVisible())) {
		return false;
	}

	switch (k) {
	case TQt::Key_Up:
			popup()->tableView()->setHighlightedRow( 
				TQMAX(highlightedOrSelectedRow-1, 0) );
			updateTextForHighlightedRow();
			return true;
	case TQt::Key_Down:
			popup()->tableView()->setHighlightedRow( 
				TQMIN(highlightedOrSelectedRow+1, popup()->tableView()->rows()-1) );
			updateTextForHighlightedRow();
			return true;
	case TQt::Key_PageUp:
			popup()->tableView()->setHighlightedRow( 
				TQMAX(highlightedOrSelectedRow-popup()->tableView()->rowsPerPage(), 0) );
			updateTextForHighlightedRow();
			return true;
	case TQt::Key_PageDown:
			popup()->tableView()->setHighlightedRow( 
				TQMIN(highlightedOrSelectedRow+popup()->tableView()->rowsPerPage(), 
				 popup()->tableView()->rows()-1) );
			updateTextForHighlightedRow();
			return true;
	case TQt::Key_Home:
			popup()->tableView()->setHighlightedRow( 0 );
			updateTextForHighlightedRow();
			return true;
	case TQt::Key_End:
			popup()->tableView()->setHighlightedRow( popup()->tableView()->rows()-1 );
			updateTextForHighlightedRow();
			return true;
	case TQt::Key_Enter:
	case TQt::Key_Return: //accept
			//select row that is highlighted
			if (popup()->tableView()->highlightedRow()>=0)
				popup()->tableView()->selectRow( popup()->tableView()->highlightedRow() );
			//do not return true: allow to process event
	default: ;
	}
	return false;
}

void KexiComboBoxBase::updateTextForHighlightedRow()
{
	KexiTableItem *item = popup() ? popup()->tableView()->highlightedItem() : 0;
	if (item)
		slotItemSelected(item);
}

void KexiComboBoxBase::undoChanges()
{
	KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema();
	if (lookupFieldSchema) {
//		kexidbg << "KexiComboBoxBase::undoChanges(): m_visibleValue BEFORE = " << m_visibleValue << endl;
		if (popup())
			popup()->tableView()->selectRow( popup()->tableView()->highlightedRow() );
		m_visibleValue = visibleValueForLookupField();
//		kexidbg << "KexiComboBoxBase::undoChanges(): m_visibleValue AFTER = " << m_visibleValue << endl;
		setValueOrTextInInternalEditor( m_visibleValue );
	}
}