Certain forms of AdjP occur right at the beginning of the NP, before
the indefinite article a:
 i. a) [How long a delay] will there be? (=> Here How long is an AdjP and in this AdjP the head adjective is long and
modifier is how. The noun phrase where this AdjP occurs is How long
 ii. b) He'd chosen [too dark a colour] (=> Here too dark is an AdjP and in this AdjP the head adjective is dark and
modifier is too. The noun phrase where this AdjP occurs is too dark
 i. a) It seemed [such a bargain]
 ii. b) [What a fool] I was.
One type are AdjPs containing how, as, so, too, this or that as
modifier, as in [i]. There are two adjectives that can appear by
themselves in this position: such and the exclamative word what,
shown in [ii].
Source - A Student's Introduction to English Grammar by Rodney Huddleston and Geoffrey K. Pullum
That is why For how long time is incorrect. The correct one is For how long a time.
In your sentence -
Quite a long time I have been waiting ....
Quite there is a PREDETERMINER. And hence it comes before the CENTRAL DETERMINER a.
The noun phrase here is - Quite a long time
The structure of this NP is -
PREDETRMINER + CENTRAL DETERMINER + ADJECTIVE + HEAD NOUN
This is perfectly fine. It's correct to write or say quite a long time. Here it's the NP that is acting as an adverbial without the need of any preposition.
One the other hand the phrase quite a long is incorrect here. This is incorrect because there is no head noun there like it's other version.
In order for this phrase to be correct we need to take out that a. Then it will be an Adverb Phrase. And quite there is an adjective, a modifier to the head adverb - long.
Source - Macmillan Dictionary