selection bugs at import and delete fixed

This commit is contained in:
Rafael 2016-04-03 03:56:24 +02:00
parent f866de1137
commit 50809e7a7c
7 changed files with 55 additions and 12 deletions

View File

@ -58,8 +58,15 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
ProfileInterface::~ProfileInterface()
{
foreach(ProfileWidget *widget, widgets.keys())
{
widgets.remove(widget);
widget->deleteLater();
delete widget;
}
foreach(SavegameData *savegame, savegames)
{
savegames.removeAll(savegame);
savegame->deleteLater();
delete savegame;
}
@ -69,12 +76,6 @@ ProfileInterface::~ProfileInterface()
picture->deleteLater();
delete picture;
}
foreach(ProfileWidget *widget, widgets.keys())
{
widgets.remove(widget);
widget->deleteLater();
delete widget;
}
profileLoader->deleteLater();
delete profileLoader;
delete ui;
@ -104,6 +105,7 @@ void ProfileInterface::on_savegameLoaded(SavegameData *savegame, QString savegam
ui->vlSavegame->addWidget(sgdWidget);
widgets[sgdWidget] = "SavegameWidget";
savegames.append(savegame);
if (selectedWidgts != 0) { sgdWidget->setSelectionMode(true); }
QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(on_savegameDeleted()));
QObject::connect(sgdWidget, SIGNAL(widgetSelected()), this, SLOT(on_profileWidgetSelected()));
QObject::connect(sgdWidget, SIGNAL(widgetDeselected()), this, SLOT(on_profileWidgetDeselected()));
@ -116,6 +118,7 @@ void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString pictu
ui->vlSnapmatic->addWidget(picWidget);
widgets[picWidget] = "SnapmaticWidget";
pictures.append(picture);
if (selectedWidgts != 0) { picWidget->setSelectionMode(true); }
QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(on_pictureDeleted()));
QObject::connect(picWidget, SIGNAL(widgetSelected()), this, SLOT(on_profileWidgetSelected()));
QObject::connect(picWidget, SIGNAL(widgetDeselected()), this, SLOT(on_profileWidgetDeselected()));
@ -140,17 +143,21 @@ void ProfileInterface::on_profileLoaded()
void ProfileInterface::on_savegameDeleted()
{
SavegameWidget *sgdWidget = (SavegameWidget*)sender();
widgets.remove(sgdWidget);
sgdWidget->deleteLater();
delete sgdWidget;
SavegameData *savegame = sgdWidget->getSavegame();
if (sgdWidget->isSelected()) { sgdWidget->setChecked(false); }
sgdWidget->close();
savegames.removeAll(savegame);
delete savegame;
}
void ProfileInterface::on_pictureDeleted()
{
SnapmaticWidget *picWidget = (SnapmaticWidget*)sender();
widgets.remove(picWidget);
picWidget->deleteLater();
delete picWidget;
SnapmaticPicture *picture = picWidget->getPicture();
if (picWidget->isSelected()) { picWidget->setChecked(false); }
picWidget->close();
pictures.removeAll(picture);
delete picture;
}
void ProfileInterface::on_cmdCloseProfile_clicked()

View File

@ -24,6 +24,16 @@ ProfileWidget::ProfileWidget(QWidget *parent) : QWidget(parent)
}
ProfileWidget::~ProfileWidget()
{
}
bool ProfileWidget::isSelected()
{
qDebug() << "ProfileWidget got used without overwrite";
return false;
}
void ProfileWidget::setSelectionMode(bool selectionMode)
{
qDebug() << "ProfileWidget got used without overwrite, result:" << selectionMode;

View File

@ -27,6 +27,8 @@ class ProfileWidget : public QWidget
public:
explicit ProfileWidget(QWidget *parent = 0);
virtual void setSelectionMode(bool selectionMode);
virtual bool isSelected();
~ProfileWidget();
signals:

View File

@ -141,7 +141,17 @@ void SavegameWidget::on_cbSelected_stateChanged(int arg1)
}
}
bool SavegameWidget::isSelected()
{
return ui->cbSelected->isChecked();
}
void SavegameWidget::setSelectionMode(bool selectionMode)
{
ui->cbSelected->setVisible(selectionMode);
}
SavegameData* SavegameWidget::getSavegame()
{
return sgdata;
}

View File

@ -38,6 +38,8 @@ public:
void setSavegameData(SavegameData *savegame, QString savegamePath);
void setSelectionMode(bool selectionMode);
void setChecked(bool isChecked);
SavegameData* getSavegame();
bool isSelected();
~SavegameWidget();
private slots:

View File

@ -155,7 +155,17 @@ void SnapmaticWidget::on_cbSelected_stateChanged(int arg1)
}
}
bool SnapmaticWidget::isSelected()
{
return ui->cbSelected->isChecked();
}
void SnapmaticWidget::setSelectionMode(bool selectionMode)
{
ui->cbSelected->setVisible(selectionMode);
}
SnapmaticPicture* SnapmaticWidget::getPicture()
{
return smpic;
}

View File

@ -40,6 +40,8 @@ public:
void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath);
void setSelectionMode(bool selectionMode);
void setChecked(bool isChecked);
bool isSelected();
SnapmaticPicture *getPicture();
~SnapmaticWidget();
private slots: