cloud_browser.cpp
Go to the documentation of this file.
00001 #include <pcl/apps/cloud_composer/cloud_browser.h>
00002 #include <pcl/apps/cloud_composer/project_model.h>
00003 
00004 
00005 pcl::cloud_composer::CloudBrowser::CloudBrowser (QWidget* parent)
00006   : QTreeView (parent)
00007 {
00008    this->setItemDelegate (new BackgroundDelegate (this));
00009 }
00010 
00011 
00012 void
00013 pcl::cloud_composer::CloudBrowser::setModel (QAbstractItemModel* new_model)
00014 {
00015   QTreeView::setModel (new_model);
00016   
00017   current_project_model_ = dynamic_cast <ProjectModel*>(new_model);
00018 }
00019 
00020 
00021 
00022 void
00023 pcl::cloud_composer::BackgroundDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
00024 {
00025   // Fill the background before calling the base class paint
00026   // otherwise selected cells would have a white background
00027  // QVariant background = index.data (Qt::BackgroundRole);
00028  // if (background.canConvert<QBrush> ())
00029  //   painter->fillRect (option.rect, background.value<QBrush> ());
00030 
00031   QVariant text_color_variant = index.data (Qt::TextColorRole);
00032   if (text_color_variant.canConvert<QColor> ())
00033   {
00034     QColor text_color = text_color_variant.value<QColor> ();
00035     QPalette palette = option.palette;
00036     QStyleOptionViewItem option_copy = option;
00037     option_copy.palette.setColor (QPalette::HighlightedText, text_color);
00038     QStyledItemDelegate::paint (painter, option_copy, index);
00039   }
00040   else
00041     QStyledItemDelegate::paint (painter, option, index);
00042   
00043   
00044 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:22:36