Which questline/faction a quest belongs to is controlled by the "Type" drop down box on the Quest Data tab.
Faction quests have something like "Thieves Guild", and "Miscellaneous", for example, causes quests to be treated as miscellaneous objectives.
You will also notice that dummy quests and invisible quests for scripting purposes will have "None" as the type, even if they obviously relate to the thieves guild.
So far, the counting of these quests appears to be handled by the game code itself ... as part of the stats system.
Limited access to the stats is available via the functions:
http://www.creationkit.com/IncrementStat_-_Game
http://www.creationkit.com/QueryStat_-_Game
You can have a look at the script AchievementsScript.psc for examples of some stats being queries.
Presumably you can access any stat using the string that represents it ...
The quests completed numbers are incremented when you complete them and DECREMENTED if you fail them, from which I surmise that it is based on objectives, not quest stages.
Though perhaps a "stop()" command may need to be issued by the quest for the game to decide to increment or decrement the counter?
You can complete or fail a quest multiple times, for example the quests given to you by Vex and Delvin can quickly give you a negative "Thieves Guild Quests Completed".
The (displayed) quests in the Civil War all have Type = "Civil War".
Both the imperial and stormcloak versions of quests have this, and when the player completes either one, the Civil War Quests Completed stat is (automatically?) incremented by the game.
The "Questlines Completed" stat, however, is incremented directly by the quest scripts:
Game.IncrementStat("Questlines Completed",1)Have a look at the quest MG08, stage 200.
The "Type" of the quest presumably also controls the symbol that is displayed in the menu.
I'm afraid I have no idea where those images are. I expect their behavior might be controlled by the (flash?) UI files for the journal.
I also don't know hope you can create new quest "Type"s. I sincerely hope you can ,and they aren't hardcoded somehow ...