/** * @brief Sets the sprite model. * @param model The sprite model, or nullptr to remove any model. * This class does not take ownership on the model. * The model can be deleted safely. */ void SpritePreviewer::set_model(SpriteModel* model) { if (this->model != nullptr) { this->model->disconnect(this); this->model = nullptr; } this->model = model; if (model != nullptr) { connect(&model->get_selection_model(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(update_selection())); update_selection(); connect(model, SIGNAL(animation_frame_delay_changed(Index,uint32_t)), this, SLOT(update_frame_delay())); connect(model, SIGNAL(animation_image_changed(Index,QString)), this, SLOT(update_frames())); connect(model, SIGNAL(direction_position_changed(Index,QPoint)), this, SLOT(update_frames())); connect(model, SIGNAL(direction_size_changed(Index,QSize)), this, SLOT(update_frames())); connect(model, SIGNAL(direction_num_frames_changed(Index,int)), this, SLOT(update_frames())); connect(model, SIGNAL(direction_num_columns_changed(Index,int)), this, SLOT(update_frames())); connect(model, SIGNAL(direction_origin_changed(Index,QPoint)), this, SLOT(update_origin())); }
/** * @brief Sets the position of a direction. * * Emits direction_position_changed() if there is a change. * * @param index A direction index. * @param position The position to set. */ void SpriteModel::set_direction_position( const Index& index, const QPoint& position) { if (!direction_exists(index)) { return; } SpriteAnimationDirectionData& direction = get_direction(index); if (Point::to_qpoint(direction.get_xy()) == position) { return; } direction.set_xy(Point::to_solarus_point(position)); set_direction_image_dirty(index); emit direction_position_changed(index, position); }