Text this: The Optimization on Ranks and Inertias of a Quadratic Hermitian Matrix Function and Its Applications