/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2013, Regents of the University of California
 *                     Yingdi Yu
 *
 * BSD license, See the LICENSE file for more information
 *
 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
 */

#include "endorse-combobox-delegate.h"

#include <QComboBox>
#include <QApplication>

#ifndef Q_MOC_RUN
#include "logging.h"
#endif

INIT_LOGGER("EndorseComboBoxDelegate");

EndorseComboBoxDelegate::EndorseComboBoxDelegate(QObject *parent)
 : QItemDelegate(parent)
{
  m_items.push_back("Not Endorsed");
  m_items.push_back("Endorsed");
}
 
 
QWidget*
EndorseComboBoxDelegate::createEditor(QWidget *parent, 
			       const QStyleOptionViewItem &/* option */, 
			       const QModelIndex &/* index */) const
{
  QComboBox* editor = new QComboBox(parent);
  for(unsigned int i = 0; i < m_items.size(); ++i)
      editor->addItem(m_items[i].c_str());
  return editor;
}
 
void 
EndorseComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
  QComboBox *comboBox = static_cast<QComboBox*>(editor);
  int value = index.model()->data(index, Qt::EditRole).toUInt();
  comboBox->setCurrentIndex(value);
}
 
void 
EndorseComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
  QComboBox *comboBox = static_cast<QComboBox*>(editor);
  model->setData(index, comboBox->currentIndex(), Qt::EditRole);
}
 
void 
EndorseComboBoxDelegate::updateEditorGeometry(QWidget *editor, 
				       const QStyleOptionViewItem &option, 
				       const QModelIndex &/* index */) const
{
  editor->setGeometry(option.rect);
}
 
void 
EndorseComboBoxDelegate::paint(QPainter *painter, 
			       const QStyleOptionViewItem &option, 
			       const QModelIndex &index) const
{
  QStyleOptionViewItemV4 myOption = option;
  QString text = m_items[index.model()->data(index, Qt::EditRole).toUInt()].c_str();
 
  myOption.text = text;
 
  QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &myOption, painter);
}

#if WAF
#include "endorse-combobox-delegate.moc"
#include "endorse-combobox-delegate.cpp.moc"
#endif
