For learning how PID works in general, I highly recommend An Introduction to PID Controllers by George Gillard (download it from here).
If you want an explanation of the code you have, here is a brief one (assuming you have read the above document):
This just is a placeholder for all of your PID-related variables.
These are different PID settings for turning and driving (I am not sure why leftDrive and rightDrive are separated; normally there is just a drivePID).
Turning PID function (iDes is desired angle in degrees, deg is current angle in degrees, and the rest are just constants)
Calculates error
This is just to get the turnPID error within the right range.
Accumulate the total error
I am not sure why the total error is accumulated twice, and I don’t think the previously mentioned line (turnPID.integral += turnPID.error;) should be there.
Set the previous error
Calculate power
That was just the PID; if you are confused about the other code I can help you. If you are having trouble with integral windup (explained in the George Gillard document), it might help to look at the part about integral windup in this post. You probably don’t really need it (you don’t really need the I term itself either), but it is nice to have.