HowManyAreAnalyzed(): use status_user_agent to report progress
[linguistica.git] / linguisticamainwindow_collectionview.cpp
blob1dc328e550541bfb20ec38da85b77e6ff094a042
1 // Updating the main window’s morpheme collection view
2 // Copyright © 2009 The University of Chicago
3 #include "linguisticamainwindow.h"
5 #include "MiniLexicon.h"
6 #include "Lexicon.h"
7 #include "TreeViewItem.h"
8 #include "GUIclasses.h"
9 #include "FSA.h"
10 #include "DescriptionLength.h"
11 #include "DLHistory.h"
12 #include "SignatureCollection.h"
13 #include "TemplateCollection.h"
14 #include "BiphoneCollection.h"
15 #include "SuffixCollection.h"
16 #include "PrefixCollection.h"
17 #include "PhoneCollection.h"
18 #include "StemCollection.h"
19 #include "WordCollection.h"
20 #include "POSCollection.h"
22 class LxPoSCollection;
23 class GUIWordCollection;
25 void LinguisticaMainWindow::updateCollectionViewSlot()
27 if (m_docType == TOKENS_REQUESTED) {
28 emit tokensRequestedSignal();
29 } else if (CMiniLexicon* mini = m_lexicon->GetMiniLexicon(
30 m_lexicon->GetActiveMiniIndex())) {
31 switch (m_docType) {
32 case WORDS:
33 mini->GetGUIWords()
34 ->ListDisplay(m_collectionView,
35 m_lexicon->GetOutFilter(),
36 false);
37 break;
38 case ANALYZED_WORDS:
39 mini->GetGUIWords()
40 ->ListDisplay(m_collectionView,
41 m_lexicon->GetOutFilter(),
42 true);
43 break;
44 case STEMS:
45 mini->GetStems()->ListDisplay(m_collectionView,
46 m_lexicon->GetOutFilter());
47 break;
48 case PREFIXES:
49 if (CPrefixCollection* prefixes = mini->GetPrefixes())
50 prefixes->ListDisplay(m_collectionView,
51 m_lexicon->GetOutFilter(),
52 status_display());
53 break;
54 case SUFFIXES:
55 if (CSuffixCollection* suffixes = mini->GetSuffixes())
56 suffixes->ListDisplay(m_collectionView,
57 m_lexicon->GetOutFilter(),
58 status_display(),
59 false);
60 break;
61 case PHONES:
62 if (CPhoneCollection* phones = mini->GetWords()->GetPhones())
63 phones->ListDisplay(m_collectionView,
64 status_display());
65 break;
66 case BIPHONES:
67 if (CBiphoneCollection* biphones =
68 mini->GetWords()->GetPhones()
69 ->GetMyBiphones())
70 biphones->ListDisplay(m_collectionView);
71 break;
72 case PHONES_Tier2:
73 if (CPhoneCollection* phones =
74 mini->GetWords()->GetPhones_Tier2())
75 phones->ListDisplay(m_collectionView,
76 status_display());
77 break;
78 case BIPHONES_Tier2:
79 if (CBiphoneCollection* biphones =
80 mini->GetWords()->GetPhones_Tier2()
81 ->GetMyBiphones())
82 biphones->ListDisplay(m_collectionView);
83 break;
84 case PHONES_Tier1_Skeleton:
85 if (CPhoneCollection* phones =
86 mini->GetWords()
87 ->GetPhones_Tier1_Skeleton())
88 phones->ListDisplay(m_collectionView,
89 status_display());
90 break;
91 case BIPHONES_Tier1_Skeleton:
92 if (CBiphoneCollection* biphones =
93 mini->GetWords()
94 ->GetPhones_Tier1_Skeleton()
95 ->GetMyBiphones())
96 biphones->ListDisplay(m_collectionView);
97 break;
98 case SIGNATURES:
99 mini->GetSignatures()
100 ->ListDisplay(m_collectionView,
101 m_lexicon->GetOutFilter());
102 break;
103 case POS:
104 // Parts of speech
105 mini->GetPOS()->ListDisplay(m_collectionView);
106 break;
107 case FSA_DOC:
108 mini->GetFSA()->FSAListDisplay(m_collectionView,
109 m_lexicon->GetOutFilter(),
110 false);
111 break;
112 case REVERSE_TRIE:
113 mini->GetWords()->GetReverseTrie()
114 ->ListDisplay(m_collectionView,
115 this,
116 m_lexicon->GetOutFilter(),
117 true);
118 break;
119 case TRIE:
120 mini->GetWords()->GetTrie()
121 ->ListDisplay(m_collectionView,
122 this,
123 m_lexicon->GetOutFilter());
124 break;
125 case TOKENS_REQUESTED:
126 // not reached
127 emit tokensRequestedSignal();
128 break;
129 case DESCRIPTION_LENGTH:
130 if (mini->GetDescriptionLength() == 0)
131 mini->CalculateDescriptionLength();
132 if (CDescriptionLength* dl =
133 mini->GetDescriptionLength())
134 dl->DescriptionLengthListDisplay(m_collectionView);
135 // XXX. add a section for CLexicon
136 break;
137 default:
138 break;
142 if (m_lexicon != 0) {
143 switch (m_docType) {
144 case CORPUS_WORDS:
145 m_lexicon->CorpusWordListDisplay(
146 m_collectionView,
147 m_lexicon->GetOutFilter(),
148 false);
149 break;
150 case ANALYZED_CORPUS_WORDS:
151 m_lexicon->CorpusWordListDisplay(
152 m_collectionView,
153 m_lexicon->GetOutFilter(),
154 true);
155 break;
156 case ALL_WORDS: // is this ever used? Jan 2010
157 m_lexicon->WordListDisplay(
158 m_collectionView,
159 false);
160 break;
161 case ALL_ANALYZED_WORDS:
162 m_lexicon->WordListDisplay(
163 m_collectionView,
164 true);
165 break;
166 case ALL_STEMS:
167 m_lexicon->StemListDisplay(m_collectionView);
168 break;
169 case ALL_PREFIXES:
170 m_lexicon->PrefixListDisplay(m_collectionView);
171 break;
172 case ALL_PREFIX_SIGNATURES:
173 m_lexicon->SignatureListDisplay(
174 m_collectionView,
175 PREFIX_SIGNATURES);
176 break;
177 case ALL_SUFFIXES:
178 m_lexicon->SuffixListDisplay(m_collectionView);
179 break;
180 case ALL_SUFFIX_SIGNATURES:
181 m_lexicon->SignatureListDisplay(
182 m_collectionView,
183 SUFFIX_SIGNATURES);
184 break;
185 case COMPOUNDS:
186 m_lexicon->CompoundListDisplay(
187 m_collectionView,
188 m_lexicon->GetOutFilter(),
189 QChar());
190 break;
191 case LINKERS:
192 m_lexicon->LinkerListDisplay(
193 m_collectionView,
194 m_lexicon->GetOutFilter());
195 break;
196 case COMPOUND_COMPONENTS:
197 m_lexicon->CompoundComponentListDisplay(
198 m_collectionView);
199 break;
200 case TOKENS_REQUESTED:
201 emit tokensRequestedSignal();
202 break;
203 case INITIALSTRINGEDITTEMPLATES:
204 m_Words_InitialTemplates->ListDisplay(
205 m_collectionView, status_display());
206 break;
207 case WORKINGSTRINGEDITTEMPLATES:
208 m_Words_Templates->ListDisplay(
209 m_collectionView, status_display());
210 break;
211 case DESCRIPTION_LENGTH_HISTORY:
212 m_lexicon->GetDLHistory()
213 ->DLHistoryListDisplay(m_collectionView);
214 break;
215 default:
216 break;
220 m_collectionView->setFont(m_eastFont);
223 void LinguisticaMainWindow::updateCollectionViewSlot(Q3ListViewItem* item)
225 if (item == 0)
226 return;
228 CTreeViewItem& it = *static_cast<CTreeViewItem*>(item);
229 enum eDocumentType newDocType = it.GetState();
230 int newIndex = it.GetIndex();
232 if (newDocType == MINI_LEXICON) {
233 m_lexicon->SetActiveMiniIndex(newIndex);
234 updateTreeViewSlot();
235 return;
238 if (newDocType == m_docType &&
239 newIndex == m_lexicon->GetActiveMiniIndex())
240 // nothing to do.
241 return;
243 m_commandMini = newIndex;
244 m_docType = newDocType;
245 if (newIndex >= 0)
246 m_lexicon->SetActiveMiniIndex(newIndex);
247 updateCollectionViewSlot();