示例#1
0
void CTile_edit_dlg::on_deleteTileSetPushButton_clicked()
{
	int nindex = ui.tileSetListWidget->currentRow();
	if (nindex != -1) 
	{

		//WORKAROUND : Qt 4.4 Behaviour (when removing at row 0 and currentRow equals to 0, currentRow is set to 1, it mess with the selectionChanged event
		if (nindex == 0)
		{
			if ( ui.tileSetListWidget->count() > 1)
				ui.tileSetListWidget->setCurrentRow(1);
			else
				ui.tileSetListWidget->setCurrentRow(-1);
		}
		//

		tileBank.removeTileSet( nindex );

		QListWidgetItem* item = ui.tileSetListWidget->takeItem(nindex);
		delete item;
	}
	else
	{
		QMessageBox::information( this, tr("No Tile Set Selected"), tr("Please, select a Tile Set to delete first ...") );
	}
}