/** * @brief Opens a file with a language dialogs editor in a new tab. * @param quest A Solarus quest. * @param path Path of the dialogs file to open. */ void EditorTabs::open_dialogs_editor(Quest& quest, const QString& language_id) { // Get the strings file path. QString path = quest.get_dialogs_path(language_id); if (!quest.is_in_root_path(path)) { // Not a file of this quest. return; } // Find the existing tab if any. int index = find_editor(path); if (index != -1) { // Already open. setCurrentIndex(index); return; } try { add_editor(new DialogsEditor(quest, language_id)); } catch (const EditorException& ex) { ex.show_dialog(); } }
/** * @brief Creates a dialogs model. * @param quest The quest. * @param language_id Id of the language of dialogs to manage. * @param parent The parent object or nullptr. * @throws EditorException If the file could not be opened. */ DialogsModel::DialogsModel( const Quest& quest, const QString& language_id, QObject* parent) : QAbstractItemModel(parent), quest(quest), language_id(language_id), selection_model(this) { // Load the strings data file. QString path = quest.get_dialogs_path(language_id); if (!resources.import_from_file(path.toStdString())) { throw EditorException(tr("Cannot open dialogs data file '%1'").arg(path)); } // Create the indexed tree. build_dialog_tree(); }