void DeviceTree::PopulateTree(void) { int old_sel = getValueIndex(getValue()); clearSelections(); PopulateTree(m_tree.Root()); setCurrentItem(old_sel); }
virtual void Load(void) { clearSelections(); uint_to_dbl_t::const_iterator it; for (it = m_posmap.begin(); it != m_posmap.end(); ++it) addSelection(AngleToString(*it), QString::number(*it)); double angle = m_settings.GetValue(m_node.GetDeviceID()); setValue(getValueIndex(QString::number(angle))); }
void RotorPosMap::PopulateList(void) { int old_sel = getValueIndex(getValue()); clearSelections(); uint num_pos = 64; for (uint pos = 1; pos < num_pos; pos++) { uint_to_dbl_t::const_iterator it = m_posmap.find(pos); QString posval = DeviceTree::tr("None"); if (it != m_posmap.end()) posval = AngleToString(*it); addSelection(DeviceTree::tr("Position #%1 (%2)").arg(pos).arg(posval), QString::number(pos)); } setCurrentItem(old_sel); }
void CSVWorld::DataDisplayDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { painter->save(); //default to enum delegate's paint method for text-only conditions if (mDisplayMode == Mode_TextOnly) EnumDelegate::paint(painter, option, index); else { int valueIndex = getValueIndex(index); if (valueIndex != -1) { paintIcon(painter, option, valueIndex); } } painter->restore(); }
QSize CSVWorld::DataDisplayDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { QSize size = EnumDelegate::sizeHint(option, index); int valueIndex = getValueIndex(index); if (valueIndex != -1) { if (mDisplayMode == Mode_IconOnly) { size.setWidth(mIconSize.width() + 2 * mHorizontalMargin); } else if (mDisplayMode == Mode_IconAndText) { size.setWidth(size.width() + mIconSize.width() + mTextLeftOffset); } if (mDisplayMode != Mode_TextOnly) { size.setHeight(qMax(size.height(), mIconSize.height())); } } return size; }
int ChannelListSetting::fillSelections(void) { QString currentValue = getValue(); uint currentIndex = max(getValueIndex(currentValue), 0); clearSelections(); addSelection(QObject::tr("(New Channel)"), "0", 0 == currentValue.toUInt()); bool fAllSources = true; QString querystr = "SELECT channel.name,channum,chanid "; if ((currentSourceID.isEmpty()) || (currentSourceID == "Unassigned") || (currentSourceID == "All")) { querystr += ",videosource.name FROM channel " "LEFT JOIN videosource ON " "(channel.sourceid = videosource.sourceid) "; fAllSources = true; } else { querystr += QString("FROM channel WHERE sourceid='%1' ") .arg(currentSourceID); fAllSources = false; } if (currentSortMode == QObject::tr("Channel Name")) { querystr += " ORDER BY channel.name"; } else if (currentSortMode == QObject::tr("Channel Number")) { querystr += " ORDER BY channum + 0"; } MSqlQuery query(MSqlQuery::InitCon()); query.prepare(querystr); uint selidx = 0, idx = 1; if (query.exec() && query.isActive() && query.size() > 0) { for (; query.next() ; idx++) { QString name = QString::fromUtf8(query.value(0).toString()); QString channum = query.value(1).toString(); QString chanid = query.value(2).toString(); QString sourceid = "Unassigned"; if (fAllSources && !query.value(3).toString().isNull()) { sourceid = query.value(3).toString(); if (currentSourceID == "Unassigned") continue; } if (channum == "" && currentHideMode) continue; if (name == "") name = "(Unnamed : " + chanid + ")"; if (currentSortMode == QObject::tr("Channel Name")) { if (channum != "") name += " (" + channum + ")"; } else if (currentSortMode == QObject::tr("Channel Number")) { if (channum != "") name = channum + ". " + name; else name = "???. " + name; } if ((currentSourceID == "") && (currentSourceID != "Unassigned")) name += " (" + sourceid + ")"; bool sel = (chanid == currentValue); selidx = (sel) ? idx : selidx; addSelection(name, chanid, sel); } } // Make sure we select the current item, or the following one after // deletion, with wrap around to "(New Channel)" after deleting last item. setCurrentItem((!selidx && currentIndex < idx) ? currentIndex : selidx); return idx; }
virtual void Load(void) { setValue(getValueIndex(QString::number((uint) m_lnb.GetType()))); }
virtual void Load(void) { QString tmp = QString::number((uint) m_device.GetDeviceType()); setValue(getValueIndex(tmp)); }
virtual void Load(void) { double value = m_settings.GetValue(m_node.GetDeviceID()); setValue(getValueIndex(QString::number((uint)value))); }