diff options
Diffstat (limited to 'kexi/widget/tableview/kexicomboboxbase.cpp')
-rw-r--r-- | kexi/widget/tableview/kexicomboboxbase.cpp | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/kexi/widget/tableview/kexicomboboxbase.cpp b/kexi/widget/tableview/kexicomboboxbase.cpp index 2d6d52ac..19cf0b99 100644 --- a/kexi/widget/tableview/kexicomboboxbase.cpp +++ b/kexi/widget/tableview/kexicomboboxbase.cpp @@ -18,10 +18,10 @@ * Boston, MA 02110-1301, USA. */ -#include <qlayout.h> -#include <qstyle.h> -#include <qwindowsstyle.h> -#include <qpainter.h> +#include <tqlayout.h> +#include <tqstyle.h> +#include <tqwindowsstyle.h> +#include <tqpainter.h> #include "kexicomboboxbase.h" #include <widget/utils/kexicomboboxdropdownbutton.h> @@ -72,7 +72,7 @@ int KexiComboBoxBase::rowToHighlightForLookupTable() const bool ok; const int rowUid = origValue().toInt(); //! @todo for now we're assuming the id is INTEGER - KexiTableViewData *tvData = popup()->tableView()->data(); + KexiTableViewData *tvData = popup()->tableView()->KexiDataAwareObjectInterface::data(); const int boundColumn = lookupFieldSchema->boundColumn(); KexiTableViewData::Iterator it(tvData->iterator()); int row=0; @@ -86,15 +86,15 @@ int KexiComboBoxBase::rowToHighlightForLookupTable() const return row; } -void KexiComboBoxBase::setValueInternal(const QVariant& add_, bool removeOld) +void KexiComboBoxBase::setValueInternal(const TQVariant& add_, bool removeOld) { Q_UNUSED(removeOld); m_mouseBtnPressedWhenPopupVisible = false; m_updatePopupSelectionOnShow = true; - QString add(add_.toString()); + TQString add(add_.toString()); if (add.isEmpty()) { KexiTableViewData *relData = column() ? column()->relatedData() : 0; - QVariant valueToSet; + TQVariant valueToSet; bool hasValueToSet = true; int rowToHighlight = -1; KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema(); @@ -113,7 +113,7 @@ void KexiComboBoxBase::setValueInternal(const QVariant& add_, bool removeOld) const int rowToHighlight = rowToHighlightForLookupTable(); popup()->tableView()->setHighlightedRow(rowToHighlight); - const int visibleColumn = lookupFieldSchema->visibleColumn( popup()->tableView()->data()->columnsCount() ); + const int visibleColumn = lookupFieldSchema->visibleColumn( popup()->tableView()->KexiDataAwareObjectInterface::data()->columnsCount() ); if (m_setVisibleValueOnSetValueInternal && -1!=visibleColumn) { //only for table views KexiTableItem *it = popup()->tableView()->highlightedItem(); @@ -165,7 +165,7 @@ void KexiComboBoxBase::setValueInternal(const QVariant& add_, bool removeOld) } } -KexiTableItem* KexiComboBoxBase::selectItemForEnteredValueInLookupTable(const QVariant& v) +KexiTableItem* KexiComboBoxBase::selectItemForEnteredValueInLookupTable(const TQVariant& v) { KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema(); if (!popup() || !lookupFieldSchema) @@ -173,9 +173,9 @@ KexiTableItem* KexiComboBoxBase::selectItemForEnteredValueInLookupTable(const QV //-not effective for large sets: please cache it! //.stripWhiteSpace() is not generic! - const bool valueIsText = v.type()==QVariant::String || v.type()==QVariant::CString; //most common case - const QString txt( valueIsText ? v.toString().stripWhiteSpace().lower() : QString::null ); - KexiTableViewData *lookupData = popup()->tableView()->data(); + 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; @@ -204,17 +204,17 @@ KexiTableItem* KexiComboBoxBase::selectItemForEnteredValueInLookupTable(const QV return it.current(); } -QString KexiComboBoxBase::valueForString(const QString& str, int* row, +TQString KexiComboBoxBase::valueForString(const TQString& str, int* row, uint lookInColumn, uint returnFromColumn, bool allowNulls) { KexiTableViewData *relData = column() ? column()->relatedData() : 0; if (!relData) - return QString::null; //safety + return TQString(); //safety //use 'related table data' model //-not effective for large sets: please cache it! //.stripWhiteSpace() is not generic! - const QString txt = str.stripWhiteSpace().lower(); + 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) @@ -230,11 +230,11 @@ QString KexiComboBoxBase::valueForString(const QString& str, int* row, kexiwarn << "KexiComboBoxBase::valueForString(): no related row found, ID will be painted!" << endl; if (allowNulls) - return QString::null; + return TQString(); return str; //for sanity but it's weird to show id to the user } -QVariant KexiComboBoxBase::value() +TQVariant KexiComboBoxBase::value() { KexiTableViewData *relData = column() ? column()->relatedData() : 0; KexiDB::LookupFieldSchema *lookupFieldSchema = 0; @@ -248,7 +248,7 @@ QVariant KexiComboBoxBase::value() else { //use 'related table data' model KexiTableItem *it = popup() ? popup()->tableView()->selectedItem() : 0; - return it ? it->at(0) : origValue();//QVariant(); + return it ? it->at(0) : origValue();//TQVariant(); } } else if ((lookupFieldSchema = this->lookupFieldSchema())) @@ -259,41 +259,41 @@ QVariant KexiComboBoxBase::value() if (/*!it &&*/ m_internalEditorValueChanged && !m_userEnteredValue.toString().isEmpty()) { // //try to select a row using the user-entered text if (!popup()) { - QVariant prevUserEnteredValue = m_userEnteredValue; + TQVariant prevUserEnteredValue = m_userEnteredValue; createPopup(false); m_userEnteredValue = prevUserEnteredValue; } it = selectItemForEnteredValueInLookupTable( m_userEnteredValue ); } - return it ? it->at( lookupFieldSchema->boundColumn() ) : QVariant(); + return it ? it->at( lookupFieldSchema->boundColumn() ) : TQVariant(); } else if (popup()) { //use 'enum hints' model const int row = popup()->tableView()->currentRow(); if (row>=0) - return QVariant( row ); + return TQVariant( row ); } if (valueFromInternalEditor().toString().isEmpty()) - return QVariant(); + 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 } -QVariant KexiComboBoxBase::visibleValueForLookupField() +TQVariant KexiComboBoxBase::visibleValueForLookupField() { KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema(); if (!popup() || !lookupFieldSchema) - return QVariant(); - const int visibleColumn = lookupFieldSchema->visibleColumn( popup()->tableView()->data()->columnsCount() ); + return TQVariant(); + const int visibleColumn = lookupFieldSchema->visibleColumn( popup()->tableView()->KexiDataAwareObjectInterface::data()->columnsCount() ); if (-1 == visibleColumn) - return QVariant(); + return TQVariant(); KexiTableItem *it = popup()->tableView()->selectedItem(); - return it ? it->at( QMIN( (uint)visibleColumn, it->count()-1)/*sanity*/ ) : QVariant(); + return it ? it->at( TQMIN( (uint)visibleColumn, it->count()-1)/*sanity*/ ) : TQVariant(); } -QVariant KexiComboBoxBase::visibleValue() +TQVariant KexiComboBoxBase::visibleValue() { return m_visibleValue; } @@ -302,7 +302,7 @@ void KexiComboBoxBase::clear() { if (popup()) popup()->hide(); - slotInternalEditorValueChanged(QVariant()); + slotInternalEditorValueChanged(TQVariant()); } tristate KexiComboBoxBase::valueChangedInternal() @@ -332,7 +332,7 @@ tristate KexiComboBoxBase::valueChangedInternal() bool KexiComboBoxBase::valueIsNull() { // bool ok; - QVariant v( value() ); + TQVariant v( value() ); return v.isNull(); // return !ok || v.isNull(); } @@ -352,15 +352,15 @@ void KexiComboBoxBase::createPopup(bool show) if (!field()) return; m_insideCreatePopup = true; - QWidget* thisWidget = dynamic_cast<QWidget*>(this); - QWidget *widgetToFocus = internalEditor() ? internalEditor() : thisWidget; + TQWidget* thisWidget = dynamic_cast<TQWidget*>(this); + TQWidget *widgetToFocus = internalEditor() ? internalEditor() : thisWidget; if (!popup()) { setPopup( column() ? new KexiComboBoxPopup(thisWidget, *column()) : new KexiComboBoxPopup(thisWidget, *field()) ); - QObject::connect(popup(), SIGNAL(rowAccepted(KexiTableItem*,int)), - thisWidget, SLOT(slotRowAccepted(KexiTableItem*,int))); - QObject::connect(popup()->tableView(), SIGNAL(itemSelected(KexiTableItem*)), - thisWidget, SLOT(slotItemSelected(KexiTableItem*))); + 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 ); @@ -376,10 +376,10 @@ void KexiComboBoxBase::createPopup(bool show) if (show && internalEditor() && !internalEditor()->isVisible()) /*emit*/editRequested(); - QPoint posMappedToGlobal = mapFromParentToGlobal(thisWidget->pos()); - if (posMappedToGlobal != QPoint(-1,-1)) { + TQPoint posMappedToGlobal = mapFromParentToGlobal(thisWidget->pos()); + if (posMappedToGlobal != TQPoint(-1,-1)) { //! todo alter the position to fit the popup within screen boundaries - popup()->move( posMappedToGlobal + QPoint(0, thisWidget->height()) ); + 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); @@ -403,8 +403,8 @@ void KexiComboBoxBase::createPopup(bool show) m_selectAllInInternalEditor_enabled = show; m_setValueInInternalEditor_enabled = show; if (rowToHighlight==-1) { - rowToHighlight = QMAX( popup()->tableView()->highlightedRow(), 0); - setValueInInternalEditor(QVariant()); + rowToHighlight = TQMAX( popup()->tableView()->highlightedRow(), 0); + setValueInInternalEditor(TQVariant()); } popup()->tableView()->selectRow( rowToHighlight ); popup()->tableView()->setHighlightedRow( rowToHighlight ); @@ -457,11 +457,11 @@ void KexiComboBoxBase::slotItemSelected(KexiTableItem*) { kexidbg << "KexiComboBoxBase::slotItemSelected(): m_visibleValue = " << m_visibleValue << endl; - QVariant valueToSet; + TQVariant valueToSet; KexiTableViewData *relData = column() ? column()->relatedData() : 0; KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema(); - m_visibleValue = lookupFieldSchema ? visibleValueForLookupField() : QVariant(); + m_visibleValue = lookupFieldSchema ? visibleValueForLookupField() : TQVariant(); if (relData) { //use 'related table data' model @@ -471,9 +471,9 @@ void KexiComboBoxBase::slotItemSelected(KexiTableItem*) } else if (lookupFieldSchema) { KexiTableItem *item = popup()->tableView()->selectedItem(); - const int visibleColumn = lookupFieldSchema->visibleColumn( popup()->tableView()->data()->columnsCount() ); + const int visibleColumn = lookupFieldSchema->visibleColumn( popup()->tableView()->KexiDataAwareObjectInterface::data()->columnsCount() ); if (item && visibleColumn!=-1 /* && (int)item->size() >= visibleColumn --already checked*/) { - valueToSet = item->at( QMIN( (uint)visibleColumn, item->count()-1)/*sanity*/ ); + valueToSet = item->at( TQMIN( (uint)visibleColumn, item->count()-1)/*sanity*/ ); } } else { @@ -481,8 +481,8 @@ void KexiComboBoxBase::slotItemSelected(KexiTableItem*) valueToSet = field()->enumHint( popup()->tableView()->currentRow() ); if (valueToSet.toString().isEmpty() && !m_insideCreatePopup) { clear(); - QWidget* thisWidget = dynamic_cast<QWidget*>(this); - thisWidget->parentWidget()->setFocus(); + TQWidget* thisWidget = dynamic_cast<TQWidget*>(this); + thisWidget->tqparentWidget()->setFocus(); return; } } @@ -495,7 +495,7 @@ void KexiComboBoxBase::slotItemSelected(KexiTableItem*) m_updatePopupSelectionOnShow = false; } -void KexiComboBoxBase::slotInternalEditorValueChanged(const QVariant& v) +void KexiComboBoxBase::slotInternalEditorValueChanged(const TQVariant& v) { if (!m_slotInternalEditorValueChanged_enabled) return; @@ -509,24 +509,24 @@ void KexiComboBoxBase::slotInternalEditorValueChanged(const QVariant& v) } } -void KexiComboBoxBase::setValueOrTextInInternalEditor(const QVariant& value) +void KexiComboBoxBase::setValueOrTextInInternalEditor(const TQVariant& value) { if (!m_setValueOrTextInInternalEditor_enabled) return; setValueInInternalEditor( value ); //this text is not entered by hand: - m_userEnteredValue = QVariant(); + m_userEnteredValue = TQVariant(); m_internalEditorValueChanged = false; } -bool KexiComboBoxBase::handleKeyPressForPopup( QKeyEvent *ke ) +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==Qt::Key_Enter || k==Qt::Key_Return; + 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 @@ -536,37 +536,37 @@ bool KexiComboBoxBase::handleKeyPressForPopup( QKeyEvent *ke ) } switch (k) { - case Qt::Key_Up: + case TQt::Key_Up: popup()->tableView()->setHighlightedRow( - QMAX(highlightedOrSelectedRow-1, 0) ); + TQMAX(highlightedOrSelectedRow-1, 0) ); updateTextForHighlightedRow(); return true; - case Qt::Key_Down: + case TQt::Key_Down: popup()->tableView()->setHighlightedRow( - QMIN(highlightedOrSelectedRow+1, popup()->tableView()->rows()-1) ); + TQMIN(highlightedOrSelectedRow+1, popup()->tableView()->rows()-1) ); updateTextForHighlightedRow(); return true; - case Qt::Key_PageUp: + case TQt::Key_PageUp: popup()->tableView()->setHighlightedRow( - QMAX(highlightedOrSelectedRow-popup()->tableView()->rowsPerPage(), 0) ); + TQMAX(highlightedOrSelectedRow-popup()->tableView()->rowsPerPage(), 0) ); updateTextForHighlightedRow(); return true; - case Qt::Key_PageDown: + case TQt::Key_PageDown: popup()->tableView()->setHighlightedRow( - QMIN(highlightedOrSelectedRow+popup()->tableView()->rowsPerPage(), + TQMIN(highlightedOrSelectedRow+popup()->tableView()->rowsPerPage(), popup()->tableView()->rows()-1) ); updateTextForHighlightedRow(); return true; - case Qt::Key_Home: + case TQt::Key_Home: popup()->tableView()->setHighlightedRow( 0 ); updateTextForHighlightedRow(); return true; - case Qt::Key_End: + case TQt::Key_End: popup()->tableView()->setHighlightedRow( popup()->tableView()->rows()-1 ); updateTextForHighlightedRow(); return true; - case Qt::Key_Enter: - case Qt::Key_Return: //accept + 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() ); |