It all related to how your trip is ticketed.
If (as per your example) you have two segment ticketed as A-B and B-A, even if B-A actually has a stopover at C you will get credit as I described.
Originally Posted by QFF T&C
9.3 Earning Points for Air Travel
...
9.3.3 Points for travel on Eligible Flights are calculated on the distance between the origin and destination according to the Great Circle distance - the shortest route between two points on the surface of the globe - not the actual distance flown. On multiple-stop through flights (connecting flights which do not involve a change of flight number and which do not involve a Stopover), Members will earn Points for the non-stop distance travelled between origin and destination. On connecting flights which involve a change of flight number or a Stopover regardless of whether there is a change of flight number, Points are earned for each Flight Segment.
If you were ticketed A-B and B-xC-A then the credit would be for A-B, B-C and C-A. Of course there would be additional
+++ for this.