ItemWidget *ItemTextLoader::create(const QModelIndex &index, QWidget *parent) const { const QStringList formats = index.data(contentType::formats).toStringList(); QString text; bool isRichText = m_settings.value("use_rich_text", true).toBool() && getRichText(index, formats, &text); if ( isRichText || getText(index, &text) ) return new ItemText(text, isRichText, parent); return NULL; }
ItemWidget *ItemTextLoader::create(const QModelIndex &index, QWidget *parent) const { QString text; bool isRichText = m_settings.value(optionUseRichText, true).toBool() && getRichText(index, &text); if ( !isRichText && !getText(index, &text) ) return NULL; const int maxLines = m_settings.value(optionMaximumLines, 0).toInt(); const int maxHeight = m_settings.value(optionMaximumHeight, 0).toInt(); return new ItemText(text, isRichText, maxLines, maxHeight, parent); }
// ----------------------------------------------------------------- // Name : update // ----------------------------------------------------------------- void InterfaceManager::update(double delta) { // Update frames for(list<guiFrame*>::iterator it = m_pFrameList.begin(); it != m_pFrameList.end(); ++it) { guiFrame * frm = *it; frm->update(delta); if (frm->getDocument() == NULL) // Dead frame { it = m_pFrameList.erase(it); } } // Tooltip if (m_pPointedObject != NULL && m_fTooltipTime > 0) { m_fTooltipTime -= delta; if (m_fTooltipTime <= 0) { m_fTooltipTime = 0; string sText = m_pPointedObject->getTooltipText(); if (sText != "") { m_pTooltip->getDocument()->deleteAllComponents(); m_pTooltip->getDocument()->setDimensions(0, 0); getRichText(m_pTooltip->getDocument(), CoordsScreen(0, 0), sText); m_pTooltip->updateSizeFit(); CoordsScreen cs = _input->getCurrentCursorPosition(); cs.y += 10; int width = m_pTooltip->getDocument()->getWidth() + 2; int height = m_pTooltip->getDocument()->getHeight() + 2; if (cs.x + width + 10 > _params->getScreenXSize()) { cs.x = _params->getScreenXSize() - width - 10; } if (cs.y + height + 10 > _params->getScreenYSize()) { cs.y = _params->getScreenYSize() - height - 10; } m_pTooltip->moveTo(cs.x, cs.y); m_pTooltip->setVisible(true); bringFrameAbove(m_pTooltip); } } } }