diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 3 | ||||
-rw-r--r-- | qt-ui/modeldelegates.cpp | 22 |
2 files changed, 22 insertions, 3 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index abb6af9bd..05196254a 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -61,10 +61,11 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), QCompleter *completer = new QCompleter(); QListView *completerListview = new QListView(); + LocationInformationModel::instance()->setFirstRowTextField(ui.location); + completer->setPopup(completerListview); completer->setModel(LocationInformationModel::instance()); completer->setCompletionColumn(LocationInformationModel::NAME); - completer->setCompletionRole(Qt::DisplayRole); completer->setCaseSensitivity(Qt::CaseInsensitive); completerListview->setItemDelegate(new LocationFilterDelegate()); diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 3357d3909..953c16b87 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -495,14 +495,22 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem QStyledItemDelegate::initStyleOption(&opt, index); QBrush bg; QString diveSiteName = index.data().toString(); - + QString bottomText; + QIcon icon = index.data(Qt::DecorationRole).value<QIcon>(); struct dive_site *ds = get_dive_site_by_uuid( index.model()->data(index.model()->index(index.row(),0)).toInt() ); + + //Special case: do not show name, but instead, show + if (index.row() == 0) { + diveSiteName = index.data().toString(); + bottomText = index.data(Qt::ToolTipRole).toString(); + goto print_part; + } + if (!ds) return; - QString bottomText; for (int i = 0; i < ds->taxonomy.nr; i++) { if(ds->taxonomy.category[i].category == TC_NONE) continue; @@ -517,11 +525,13 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem free( (void*) gpsCoords); } + print_part: fontBigger.setPointSize(fontBigger.pointSize() + 1); fontBigger.setBold(true); initStyleOption(&opt, index); opt.text = QString(); + opt.icon = QIcon(); qApp->style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, NULL); painter->save(); @@ -539,6 +549,14 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem painter->setBrush(option.palette.brightText()); painter->drawText(option.rect.x(),option.rect.y() + fmBigger.boundingRect("YH").height() * 2, bottomText); painter->restore(); + + if (!icon.isNull()) { + painter->save(); + painter->drawPixmap( + option.rect.x() + option.rect.width() - 24, + option.rect.y() + option.rect.height() - 24, icon.pixmap(20,20)); + painter->restore(); + } } QSize LocationFilterDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const |