Editor: Replace | by line breaks in descriptions and EditorHelp texts

directional-lights
Sven Eberhardt 2016-10-10 16:27:43 -04:00
parent a6b65f0dee
commit 20d234e324
3 changed files with 12 additions and 9 deletions

View File

@ -997,7 +997,8 @@ QStandardItemModel *C4PropertyDelegateEnum::CreateOptionModel() const
new_item->setData(QVariant(idx), C4DeepQComboBox::OptionIndexRole);
C4Object *item_obj_data = opt.value.getObj();
if (item_obj_data) new_item->setData(QVariant(item_obj_data->Number), C4DeepQComboBox::ObjectHighlightRole);
new_item->setData(QString((opt.help ? opt.help : opt.name)->GetCStr()), Qt::ToolTipRole);
QString help = QString((opt.help ? opt.help : opt.name)->GetCStr());
new_item->setData(help.replace('|', '\n'), Qt::ToolTipRole);
if (opt.help) new_item->setData(QIcon(":/editor/res/Help.png"), Qt::DecorationRole);
if (opt.sound_name) new_item->setData(QIcon(":/editor/res/Sound.png"), Qt::DecorationRole);
if (allow_editing)
@ -2763,15 +2764,17 @@ QMimeData *C4ConsoleQtPropListModel::mimeData(const QModelIndexList &indexes) co
return mimeData;
}
const char *C4ConsoleQtPropListModel::GetTargetPathHelp() const
QString C4ConsoleQtPropListModel::GetTargetPathHelp() const
{
// Help text in EditorInfo prop. Fall back to description.
C4PropList *info_proplist = this->info_proplist.getPropList();
if (!info_proplist) return nullptr;
if (!info_proplist) return QString();
C4String *desc = info_proplist->GetPropertyStr(P_EditorHelp);
if (!desc) desc = info_proplist->GetPropertyStr(P_Description);
if (!desc) return nullptr;
return desc->GetCStr();
if (!desc) return QString();
QString result = QString(desc->GetCStr());
result = result.replace('|', '\n');
return result;
}
const char *C4ConsoleQtPropListModel::GetTargetPathName() const

View File

@ -671,7 +671,7 @@ public:
class C4PropList *GetBasePropList() const { return base_proplist.getPropList(); }
int32_t GetTargetPathStackSize() const { return target_path_stack.size(); }
const char *GetTargetPathText() const { return target_path.GetGetPath(); }
const char *GetTargetPathHelp() const;
QString GetTargetPathHelp() const;
const char *GetTargetPathName() const;
bool IsArray() const { return !!target_value.getArray(); }
void AddArrayElement();

View File

@ -921,12 +921,12 @@ void C4ConsoleGUIState::PropertyDlgUpdate(C4EditCursorSelection &rSelection, boo
property_model->UpdateValue(false);
}
ui.selectionInfoLabel->setText(property_model->GetTargetPathText());
const char *help_text = property_model->GetTargetPathHelp();
if (help_text && ::Config.Developer.ShowHelp)
QString help_text = property_model->GetTargetPathHelp();
if (!help_text.isEmpty() && ::Config.Developer.ShowHelp)
{
const char *help_label = property_model->GetTargetPathName();
if (!help_label) help_label = LoadResStr("IDS_CNS_DESCRIPTION");
ui.selectionHelpLabel->setText(FormatString("%s: %s", help_label, help_text).getData());
ui.selectionHelpLabel->setText(QString("%1: %2").arg(help_label).arg(help_text));
ui.selectionHelpLabel->show();
}
else