Commit f142be47 authored by Jarosław Staniek's avatar Jarosław Staniek

Make combo-boxes in Kexi table and form views show just one column

Without this fix the combo-boxes show all possible columns instead
of just one but Kexi lets the user to define just one visible column.
Even bound column (such as id) is presented, what results in an unpleasant look & feel.

The fix works for both tables and queries used as a combo box row source

BUG:345631
REVIEW:123166
parent a5747eb1
/* This file is part of the KDE project
Copyright (C) 2006-2012 Jarosław Staniek <staniek@kde.org>
Copyright (C) 2006-2015 Jarosław Staniek <staniek@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -625,13 +625,13 @@ void LookupFieldSchema::setVisibleColumns(const QList<uint>& list)
d->visibleColumns = list;
}
int LookupFieldSchema::visibleColumn(uint fieldsCount) const
int LookupFieldSchema::visibleColumn(uint index) const
{
if (d->visibleColumns.count() == 1)
return (d->visibleColumns.first() < fieldsCount) ? (int)d->visibleColumns.first() : -1;
if (d->visibleColumns.isEmpty())
//kDebug() << "d->visibleColumns.first()" << d->visibleColumns.first() << "index" << index;
if (index >= d->visibleColumns.count()) {
return -1;
return fieldsCount - 1;
}
return index;
}
QList<int> LookupFieldSchema::columnWidths() const
......
/* This file is part of the KDE project
Copyright (C) 2006-2012 Jarosław Staniek <staniek@kde.org>
Copyright (C) 2006-2015 Jarosław Staniek <staniek@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -142,26 +142,24 @@ public:
/*! Sets bound column number to \a column. @see boundColumn() */
void setBoundColumn(int column);
/*! @return a list of visible column: a list of integers specifying a column that has
to be visible in the combo box (counted from 0).
/*! @return a list of visible column: a list of integers specifying indices (counted from 0)
of columns within the row source that are visible in the combo box.
Empty list means unspecified value. */
QList<uint> visibleColumns() const;
/*! Sets a list of visible columns to \a list.
Columns will be separated with a single space character when displayed. */
/*! Sets a list of visible columns to \a list. @see visibleColumns() */
void setVisibleColumns(const QList<uint>& list);
/*! A helper method.
If visibleColumns() contains one item, this item is returned (a typical case).
If visibleColumns() contains no item, -1 is returned.
If visibleColumns() multiple items, \a fieldsCount - 1 is returned. */
int visibleColumn(uint fieldsCount) const;
If index >= visibleColumns().count(), -1 is returned,
else \a index is returned. */
int visibleColumn(uint index) const;
/*! @return a number of ordered integers specifying column widths;
-1 means 'default width' for a given column. */
QList<int> columnWidths() const;
/*! Sets column widths. @see columnWidths */
/*! Sets column widths. @see columnWidths() */
void setColumnWidths(const QList<int>& widths);
/*! @return true if column headers are visible in the associated
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment