QColorDialog: Fix matching against predefined colors.

The grids are filled top to bottom, left to right, so use division to get
the column.

Task-number: QTBUG-43371
Change-Id: I02ad518512858ed71e0e3a0cae8c4e02d537a9b9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
bb10
Sérgio Martins 2014-12-15 21:02:39 +00:00
parent 87ede1fc7a
commit 2746fe4243
1 changed files with 4 additions and 4 deletions

View File

@ -1489,8 +1489,8 @@ bool QColorDialogPrivate::selectColor(const QColor &col)
const QRgb *match = std::find(standardColors, standardColorsEnd, color);
if (match != standardColorsEnd) {
const int index = int(match - standardColors);
const int row = index / standardColorRows;
const int column = index % standardColorRows;
const int column = index / standardColorRows;
const int row = index % standardColorRows;
_q_newStandard(row, column);
standard->setCurrent(row, column);
standard->setSelected(row, column);
@ -1505,8 +1505,8 @@ bool QColorDialogPrivate::selectColor(const QColor &col)
const QRgb *match = std::find(customColors, customColorsEnd, color);
if (match != customColorsEnd) {
const int index = int(match - customColors);
const int row = index / customColorRows;
const int column = index % customColorRows;
const int column = index / customColorRows;
const int row = index % customColorRows;
_q_newCustom(row, column);
custom->setCurrent(row, column);
custom->setSelected(row, column);