BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
qdesigner_internal::WidgetBoxCategoryListView Class Reference
Inheritance diagram for qdesigner_internal::WidgetBoxCategoryListView:
[legend]
Collaboration diagram for qdesigner_internal::WidgetBoxCategoryListView:
[legend]

Public Types

enum  EAccessMode { FILTERED , UNFILTERED }
 

Public Slots

void filter (const QRegExp &re)
 

Signals

void itemRemoved ()
 
void lastItemRemoved ()
 
void pressed (const QString &name, const QString &xml, const QPoint &globalPos)
 
void scratchPadChanged ()
 

Public Member Functions

 WidgetBoxCategoryListView (SampleDesignerInterface *core, QWidget *parent=0)
 
void addWidget (const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon, bool editable)
 
QDesignerWidgetBoxInterface::Category category () const
 
bool containsWidget (const QString &name)
 
int count (EAccessMode am) const
 
void dropWidgets (const QList< QDesignerDnDItemInterface * > &item_list)
 
bool removeCustomWidgets ()
 
void removeRow (EAccessMode am, int row)
 
void setCurrentItem (EAccessMode am, int row)
 
void setViewMode (ViewMode vm)
 
QDesignerWidgetBoxInterface::Widget widgetAt (EAccessMode am, const QModelIndex &index) const
 
QDesignerWidgetBoxInterface::Widget widgetAt (EAccessMode am, int row) const
 

Static Public Member Functions

static QString widgetDomXml (const QDesignerWidgetBoxInterface::Widget &widget)
 

Private Slots

void editCurrentItem ()
 
void removeCurrentItem ()
 
void slotPressed (const QModelIndex &index)
 

Private Member Functions

int mapRowToSource (int filterRow) const
 

Private Attributes

WidgetBoxCategoryModelm_model
 
QSortFilterProxyModel * m_proxyModel
 

Detailed Description

Definition at line 66 of file widgetboxcategorylistview.h.

Member Enumeration Documentation

◆ EAccessMode

Constructor & Destructor Documentation

◆ WidgetBoxCategoryListView()

qdesigner_internal::WidgetBoxCategoryListView::WidgetBoxCategoryListView ( SampleDesignerInterface core,
QWidget *  parent = 0 
)
explicit

Definition at line 409 of file widgetboxcategorylistview.cpp.

410  : QListView(parent)
411  , m_proxyModel(new QSortFilterProxyModel(this))
412  , m_model(new WidgetBoxCategoryModel(core, this))
413 {
414  setFocusPolicy(Qt::NoFocus);
415  setFrameShape(QFrame::NoFrame);
416  // setIconSize(QSize(22, 22));
417  setIconSize(QSize(32, 32));
418  setSpacing(1);
419  setTextElideMode(Qt::ElideMiddle);
420  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
421  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
422  setResizeMode(QListView::Adjust);
423  setUniformItemSizes(true);
424 
425  setItemDelegate(new WidgetBoxCategoryEntryDelegate(this));
426 
427  connect(this, SIGNAL(pressed(QModelIndex)), this, SLOT(slotPressed(QModelIndex)));
428  setEditTriggers(QAbstractItemView::AnyKeyPressed);
429 
430  m_proxyModel->setSourceModel(m_model);
431  m_proxyModel->setFilterRole(FILTER_ROLE);
432  setModel(m_proxyModel);
433  connect(m_model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
434  SIGNAL(scratchPadChanged()));
435 }
void pressed(const QString &name, const QString &xml, const QPoint &globalPos)

References FILTER_ROLE, m_model, m_proxyModel, pressed(), scratchPadChanged(), and slotPressed().

Here is the call graph for this function:

Member Function Documentation

◆ addWidget()

void qdesigner_internal::WidgetBoxCategoryListView::addWidget ( const QDesignerWidgetBoxInterface::Widget &  widget,
const QIcon &  icon,
bool  editable 
)

Definition at line 517 of file widgetboxcategorylistview.cpp.

519 {
520  m_model->addWidget(widget, icon, editable);
521 }
void addWidget(const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon, bool editable)

References qdesigner_internal::WidgetBoxCategoryModel::addWidget(), and m_model.

Referenced by qdesigner_internal::WidgetBoxTreeWidget::addCategory(), qdesigner_internal::WidgetBoxTreeWidget::addWidget(), and qdesigner_internal::WidgetBoxTreeWidget::dropWidgets().

Here is the call graph for this function:

◆ category()

QDesignerWidgetBoxInterface::Category qdesigner_internal::WidgetBoxCategoryListView::category ( ) const

Definition at line 542 of file widgetboxcategorylistview.cpp.

543 {
544  return m_model->category();
545 }
QDesignerWidgetBoxInterface::Category category() const

References qdesigner_internal::WidgetBoxCategoryModel::category(), and m_model.

Referenced by qdesigner_internal::WidgetBoxTreeWidget::category().

Here is the call graph for this function:

◆ containsWidget()

bool qdesigner_internal::WidgetBoxCategoryListView::containsWidget ( const QString &  name)

Definition at line 512 of file widgetboxcategorylistview.cpp.

513 {
514  return m_model->indexOfWidget(name) != -1;
515 }
QString const & name(EShape k)
Definition: particles.cpp:21

References qdesigner_internal::WidgetBoxCategoryModel::indexOfWidget(), m_model, and RealSpace::Particles::name().

Referenced by qdesigner_internal::WidgetBoxTreeWidget::addCategory().

Here is the call graph for this function:

◆ count()

int qdesigner_internal::WidgetBoxCategoryListView::count ( EAccessMode  am) const

Definition at line 483 of file widgetboxcategorylistview.cpp.

484 {
485  return am == FILTERED ? m_proxyModel->rowCount() : m_model->rowCount();
486 }
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const

References FILTERED, m_model, m_proxyModel, and qdesigner_internal::WidgetBoxCategoryModel::rowCount().

Referenced by qdesigner_internal::WidgetBoxTreeWidget::dropWidgets(), qdesigner_internal::WidgetBoxTreeWidget::filter(), qdesigner_internal::WidgetBoxTreeWidget::removeWidget(), and qdesigner_internal::WidgetBoxTreeWidget::widgetCount().

Here is the call graph for this function:

◆ dropWidgets()

void qdesigner_internal::WidgetBoxCategoryListView::dropWidgets ( const QList< QDesignerDnDItemInterface * > &  item_list)

◆ editCurrentItem

void qdesigner_internal::WidgetBoxCategoryListView::editCurrentItem ( )
privateslot

Definition at line 476 of file widgetboxcategorylistview.cpp.

477 {
478  const QModelIndex index = currentIndex();
479  if (index.isValid())
480  edit(index);
481 }

◆ filter

void qdesigner_internal::WidgetBoxCategoryListView::filter ( const QRegExp &  re)
slot

Definition at line 537 of file widgetboxcategorylistview.cpp.

538 {
539  m_proxyModel->setFilterRegExp(re);
540 }

References m_proxyModel.

Referenced by qdesigner_internal::WidgetBoxTreeWidget::filter().

◆ itemRemoved

void qdesigner_internal::WidgetBoxCategoryListView::itemRemoved ( )
signal

Referenced by removeCurrentItem().

◆ lastItemRemoved

void qdesigner_internal::WidgetBoxCategoryListView::lastItemRemoved ( )
signal

Referenced by removeCurrentItem().

◆ mapRowToSource()

int qdesigner_internal::WidgetBoxCategoryListView::mapRowToSource ( int  filterRow) const
private

Definition at line 488 of file widgetboxcategorylistview.cpp.

489 {
490  const QModelIndex filterIndex = m_proxyModel->index(filterRow, 0);
491  return m_proxyModel->mapToSource(filterIndex).row();
492 }

References m_proxyModel.

Referenced by removeRow(), and widgetAt().

◆ pressed

void qdesigner_internal::WidgetBoxCategoryListView::pressed ( const QString &  name,
const QString &  xml,
const QPoint &  globalPos 
)
signal

◆ removeCurrentItem

void qdesigner_internal::WidgetBoxCategoryListView::removeCurrentItem ( )
privateslot

Definition at line 461 of file widgetboxcategorylistview.cpp.

462 {
463  const QModelIndex index = currentIndex();
464  if (!index.isValid() || !m_proxyModel->removeRow(index.row()))
465  return;
466 
467  // We check the unfiltered item count here, we don't want to get removed if the
468  // filtered view is empty
469  if (m_model->rowCount()) {
470  emit itemRemoved();
471  } else {
472  emit lastItemRemoved();
473  }
474 }

References itemRemoved(), lastItemRemoved(), m_model, m_proxyModel, and qdesigner_internal::WidgetBoxCategoryModel::rowCount().

Here is the call graph for this function:

◆ removeCustomWidgets()

bool qdesigner_internal::WidgetBoxCategoryListView::removeCustomWidgets ( )

Definition at line 547 of file widgetboxcategorylistview.cpp.

References m_model, and qdesigner_internal::WidgetBoxCategoryModel::removeCustomWidgets().

Referenced by qdesigner_internal::WidgetBoxTreeWidget::addCustomCategories().

Here is the call graph for this function:

◆ removeRow()

void qdesigner_internal::WidgetBoxCategoryListView::removeRow ( EAccessMode  am,
int  row 
)

Definition at line 507 of file widgetboxcategorylistview.cpp.

508 {
509  m_model->removeRow(am == UNFILTERED ? row : mapRowToSource(row));
510 }

References m_model, mapRowToSource(), and UNFILTERED.

Referenced by qdesigner_internal::WidgetBoxTreeWidget::removeWidget().

Here is the call graph for this function:

◆ scratchPadChanged

void qdesigner_internal::WidgetBoxCategoryListView::scratchPadChanged ( )
signal

◆ setCurrentItem()

void qdesigner_internal::WidgetBoxCategoryListView::setCurrentItem ( EAccessMode  am,
int  row 
)

Definition at line 443 of file widgetboxcategorylistview.cpp.

444 {
445  const QModelIndex index = am == FILTERED ? m_proxyModel->index(row, 0)
446  : m_proxyModel->mapFromSource(m_model->index(row, 0));
447 
448  if (index.isValid())
449  setCurrentIndex(index);
450 }

References FILTERED, m_model, and m_proxyModel.

Referenced by qdesigner_internal::WidgetBoxTreeWidget::dropWidgets().

◆ setViewMode()

void qdesigner_internal::WidgetBoxCategoryListView::setViewMode ( ViewMode  vm)

Definition at line 437 of file widgetboxcategorylistview.cpp.

438 {
439  QListView::setViewMode(vm);
440  m_model->setViewMode(vm);
441 }

References m_model, and qdesigner_internal::WidgetBoxCategoryModel::setViewMode().

Referenced by qdesigner_internal::WidgetBoxTreeWidget::addCategoryView().

Here is the call graph for this function:

◆ slotPressed

void qdesigner_internal::WidgetBoxCategoryListView::slotPressed ( const QModelIndex &  index)
privateslot

Definition at line 452 of file widgetboxcategorylistview.cpp.

453 {
454  const QDesignerWidgetBoxInterface::Widget wgt =
455  m_model->widgetAt(m_proxyModel->mapToSource(index));
456  if (wgt.isNull())
457  return;
458  emit pressed(wgt.name(), widgetDomXml(wgt), QCursor::pos());
459 }
static QString widgetDomXml(const QDesignerWidgetBoxInterface::Widget &widget)
QDesignerWidgetBoxInterface::Widget widgetAt(const QModelIndex &index) const

References m_model, m_proxyModel, pressed(), qdesigner_internal::WidgetBoxCategoryModel::widgetAt(), and widgetDomXml().

Referenced by WidgetBoxCategoryListView().

Here is the call graph for this function:

◆ widgetAt() [1/2]

QDesignerWidgetBoxInterface::Widget qdesigner_internal::WidgetBoxCategoryListView::widgetAt ( EAccessMode  am,
const QModelIndex &  index 
) const

Definition at line 495 of file widgetboxcategorylistview.cpp.

496 {
497  const QModelIndex unfilteredIndex = am == FILTERED ? m_proxyModel->mapToSource(index) : index;
498  return m_model->widgetAt(unfilteredIndex);
499 }

References FILTERED, m_model, m_proxyModel, and qdesigner_internal::WidgetBoxCategoryModel::widgetAt().

Referenced by qdesigner_internal::WidgetBoxTreeWidget::widget().

Here is the call graph for this function:

◆ widgetAt() [2/2]

QDesignerWidgetBoxInterface::Widget qdesigner_internal::WidgetBoxCategoryListView::widgetAt ( EAccessMode  am,
int  row 
) const

Definition at line 501 of file widgetboxcategorylistview.cpp.

503 {
504  return m_model->widgetAt(am == UNFILTERED ? row : mapRowToSource(row));
505 }

References m_model, mapRowToSource(), UNFILTERED, and qdesigner_internal::WidgetBoxCategoryModel::widgetAt().

Here is the call graph for this function:

◆ widgetDomXml()

QString qdesigner_internal::WidgetBoxCategoryListView::widgetDomXml ( const QDesignerWidgetBoxInterface::Widget &  widget)
static

Definition at line 523 of file widgetboxcategorylistview.cpp.

524 {
525  QString domXml = widget.domXml();
526 
527  if (domXml.isEmpty()) {
528  domXml = QLatin1String(uiOpeningTagC);
529  domXml += "<widget class=\"";
530  domXml += widget.name();
531  domXml += "\"/>";
532  domXml += QLatin1String(uiClosingTagC);
533  }
534  return domXml;
535 }
static const char * uiOpeningTagC
static const char * uiClosingTagC

References uiClosingTagC, and uiOpeningTagC.

Referenced by qdesigner_internal::WidgetBoxCategoryModel::setData(), slotPressed(), and qdesigner_internal::WidgetBoxTreeWidget::writeCategories().

Member Data Documentation

◆ m_model

◆ m_proxyModel

QSortFilterProxyModel* qdesigner_internal::WidgetBoxCategoryListView::m_proxyModel
private

The documentation for this class was generated from the following files: