Ok, let's see...
In a first step we rewrite the integral as
$$
\int_{-\infty}^{\infty}\frac{e^{2\pi i (a-T)q}}{2\pi i q}dq-\int_{-\infty}^{\infty}\frac{e^{-2\pi i qT}}{2\pi i q}dq
$$
First thing we note that both integrals have a singularity of order $1$ at the origin. This means that the integrals are not defined in the usual sense, but have to be interpreted as Cauchy principal part integrals denoted by $P\int=\int_R^{}$.
Now let's try to apply Complex analysis to the first integral. Therefore we look at the function $f(z)=\frac{e^{2\pi i(z-T)}}{2\pi z}$ where $z$ is now a complex variable.
If $0<a-T$, $f(z)\rightarrow 0$ in the whole upper half plane (For a formal proof of this, apply the Lemma of Jordan) we therefore can write according to Cauchys theorem
$$
\underbrace{\int_{SC_+}f(z)dz}_{=0}+ \underbrace{(-i)\lim_{\epsilon\rightarrow0}\int_{\pi}^{0}f(\epsilon e^{i\phi})\epsilon e^{i\phi}d\phi}_{\text{small cemircircle to avoid the singularity}}+\underbrace{P\int_{-\infty}^{\infty}\frac{e^{2\pi i (q-T)}}{2\pi i q}dq}_{\text{the integral we are interested in}}=0
$$
Here $SC_+$ denotes a big semicircle in the upper half plane. The second integral can now be easily calculated.
$$
(-i)\lim_{\epsilon\rightarrow0}\int_{\pi}^{0}f(\epsilon e^{i\phi})\epsilon e^{i\phi}d\phi=-i\int_{\pi}^{0}d\phi=-1/2$$
And we can conclude that
$$
P\int_{-\infty}^{\infty}\frac{e^{2\pi i (q-T)}}{2\pi i q}dq=1/2 \quad \text{if} \quad a>T
$$
Applying the same analyis to the case were $0<a-T$, we have yo keep in mind, that we now have to close our contour in the lower half plane.
$$
\underbrace{\int_{SC_-}f(z)dz}_{=0}+ \underbrace{i\lim_{\epsilon\rightarrow0}\int_{\pi}^{0}f(\epsilon e^{i\phi})\epsilon e^{i\phi}d\phi}_{\text{small cemircircle to avoid the singularity}}+\underbrace{P\int_{-\infty}^{\infty}\frac{e^{2\pi i (a-T)q}}{2\pi i q}dq}_{\text{the integral we are interested in}}=0
$$
Note the missing minus sign in front of the second integral. It stems from the fact that we now going around the singularity in counter clockwise direction.
As a result we get
And we can conclude that
$$
P\int_{-\infty}^{\infty}\frac{e^{2\pi i (a-T)q}}{2\pi i q}dq=-1/2 \quad \text{if} \quad a<T
$$
Or, putting both results together,
$$
P\int_{-\infty}^{\infty}\frac{e^{2\pi i (a-T)q}}{2\pi i q}dq=\text{sign}[a-T]/2
$$
You can now apply a very similar analysis to the second integral (somehow easier because $T>0$ and therefore no case deception) with the result that
$$
-P\int_{-\infty}^{\infty}\frac{e^{-2\pi i qT}}{2\pi i q}dq=1/2
$$
So the complete integral is just given by
$$
(1+\text{sign}[a-T])/2
$$
I hope everything is clear now :)