Logo Search packages:      
Sourcecode: tellico version File versions

void MainWindow::slotUpdateCollectionToolBar ( Tellico::Data::Collection coll  )  [private, slot]

Updates the collection toolbar.

Definition at line 1514 of file mainwindow.cpp.

References Tellico::Data::Collection::defaultGroupField(), Tellico::Data::Collection::entryGroups(), Tellico::Data::Collection::fieldTitleByName(), Tellico::GroupView::groupBy(), Tellico::Data::Collection::s_peopleGroupName, Tellico::GroupView::setGroupField(), and slotChangeGrouping().

Referenced by readCollectionOptions().

                                                                  {
//  kdDebug() << "MainWindow::updateCollectionToolBar()" << endl;

  if(!coll_) {
    kdWarning() << "MainWindow::slotUpdateCollectionToolBar() - no collection pointer!" << endl;
    return;
  }

  QString current = m_groupView->groupBy();
  if(current.isEmpty() || !coll_->entryGroups().contains(current)) {
    current = coll_->defaultGroupField();
    m_groupView->setGroupField(coll_, current);
  }

  QStringList groups = coll_->entryGroups();
  if(groups.isEmpty()) {
    m_entryGrouping->clear();
    return;
  }

  QStringList groupTitles;
  int index = 0;
  QStringList::ConstIterator groupIt = groups.begin();
  for(int i = 0; groupIt != groups.end(); ++groupIt, ++i) {
    // special case for people "pseudo-group"
    if(*groupIt == Data::Collection::s_peopleGroupName) {
      groupTitles << (QString::fromLatin1("<") + i18n("People") + QString::fromLatin1(">"));
    } else {
      groupTitles << coll_->fieldTitleByName(*groupIt);
    }
    if(*groupIt == current) {
      index = i;
    }
  }

// is it more of a performance hit to compare two stringlists then to repopulate needlessly?
//  if(groupTitles != m_entryGrouping->items()) {
    m_entryGrouping->setItems(groupTitles);
//  }
  m_entryGrouping->setCurrentItem(index);
  // in case the current grouping field get modified to be non-grouping...
  slotChangeGrouping();

  // this isn't really proper, but works so the combo box width gets adjusted
  int len = m_entryGrouping->containerCount();
  for(int i = 0; i < len; ++i) {
    KToolBar* tb = dynamic_cast<KToolBar*>(m_entryGrouping->container(i));
    if(tb) {
      KComboBox* cb = tb->getCombo(m_entryGrouping->itemId(i));
      if(cb) {
        // qt caches the combobox size and never recalculates the sizeHint()
        // the source code recommends calling setFont to invalidate the sizeHint
        cb->setFont(cb->font());
        cb->updateGeometry();
      }
    }
  }
}


Generated by  Doxygen 1.6.0   Back to index