#pragma once

#include <vector>

#include <QWidget>

#include "BuildingId.h"
#include "SelectionContext.h"

// The "Clear items" action of the card's runtime group (REQ-UI-BELT-CLEAR): it removes
// every item from the selected belt, splitter and tunnel tiles -- how a stalled line is
// resolved, and equally how a running one is emptied, which is why the button is named
// for what it does rather than for a state the items need not be in.
//
// It stands below the item list and removes exactly what that list shows
// (REQ-UI-BELT-ITEMS): a tunnel exit takes its tunnel's invisible cargo with it, a tunnel
// entry does not.
//
// It acts on the whole selection rather than on one tile, which is why any mix of
// belt-subsystem tiles aggregates into a single card instead of a count summary
// (REQ-UI-SELECTION-AGGREGATE). It is shown nowhere else: a selection mixing belt tiles
// with other buildings shows the count summary and carries neither the list nor this
// action, a button acting on part of a selection being worse than no button.
class ClearBeltControl : public QWidget
{
    Q_OBJECT

public:
    ClearBeltControl(const SelectionContext& context,
                     const std::vector<BuildingId>& ids, QWidget* parent = nullptr);

private:
    void clearSelectedTiles() const;

    SelectionContext        m_context;
    std::vector<BuildingId> m_ids;
};
