General Quantum Variational Calculus