mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 20:20:06 +00:00
Placefile "Remove" functionality
This commit is contained in:
parent
9955c4ccbe
commit
ad5c2b583d
6 changed files with 115 additions and 2 deletions
|
|
@ -45,6 +45,11 @@ PlacefileModel::PlacefileModel(QObject* parent) :
|
|||
this,
|
||||
&PlacefileModel::HandlePlacefileUpdate);
|
||||
|
||||
connect(p->placefileManager_.get(),
|
||||
&manager::PlacefileManager::PlacefileRemoved,
|
||||
this,
|
||||
&PlacefileModel::HandlePlacefileRemoved);
|
||||
|
||||
connect(p->placefileManager_.get(),
|
||||
&manager::PlacefileManager::PlacefileRenamed,
|
||||
this,
|
||||
|
|
@ -292,6 +297,24 @@ bool PlacefileModel::setData(const QModelIndex& index,
|
|||
return true;
|
||||
}
|
||||
|
||||
void PlacefileModel::HandlePlacefileRemoved(const std::string& name)
|
||||
{
|
||||
auto it =
|
||||
std::find(p->placefileNames_.begin(), p->placefileNames_.end(), name);
|
||||
|
||||
if (it != p->placefileNames_.end())
|
||||
{
|
||||
// Placefile exists, delete row
|
||||
const int row = std::distance(p->placefileNames_.begin(), it);
|
||||
QModelIndex topLeft = createIndex(row, kFirstColumn);
|
||||
QModelIndex bottomRight = createIndex(row, kLastColumn);
|
||||
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
p->placefileNames_.erase(it);
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
|
||||
void PlacefileModel::HandlePlacefileRenamed(const std::string& oldName,
|
||||
const std::string& newName)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public:
|
|||
int role = Qt::EditRole) override;
|
||||
|
||||
public slots:
|
||||
void HandlePlacefileRemoved(const std::string& name);
|
||||
void HandlePlacefileRenamed(const std::string& oldName,
|
||||
const std::string& newName);
|
||||
void HandlePlacefileUpdate(const std::string& name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue