CMiniLexicon::FindMajorSignatures(): use log file routines
[linguistica.git] / linguisticamainwindow_collectionview.cpp
blobcf503f896eefb4d991dccc689affa31d2647f365
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 Q_ASSERT(m_lexicon->GetFSA());
109 m_lexicon->GetFSA()->FSAListDisplay(m_collectionView,
110 m_lexicon->GetOutFilter(),
111 false);
112 break;
113 case REVERSE_TRIE:
114 mini->GetWords()->GetReverseTrie()
115 ->ListDisplay(m_collectionView,
116 this,
117 m_lexicon->GetOutFilter(),
118 true);
119 break;
120 case TRIE:
121 mini->GetWords()->GetTrie()
122 ->ListDisplay(m_collectionView,
123 this,
124 m_lexicon->GetOutFilter());
125 break;
126 case TOKENS_REQUESTED:
127 // not reached
128 emit tokensRequestedSignal();
129 break;
130 case DESCRIPTION_LENGTH:
131 if (mini->GetDescriptionLength() == 0)
132 mini->CalculateDescriptionLength();
133 if (CDescriptionLength* dl =
134 mini->GetDescriptionLength())
135 dl->DescriptionLengthListDisplay(m_collectionView);
136 // XXX. add a section for CLexicon
137 break;
138 default:
139 break;
143 if (m_lexicon != 0) {
144 switch (m_docType) {
145 case CORPUS_WORDS:
146 m_lexicon->CorpusWordListDisplay(
147 m_collectionView,
148 m_lexicon->GetOutFilter(),
149 false);
150 break;
151 case ANALYZED_CORPUS_WORDS:
152 m_lexicon->CorpusWordListDisplay(
153 m_collectionView,
154 m_lexicon->GetOutFilter(),
155 true);
156 break;
157 case ALL_WORDS: // is this ever used? Jan 2010
158 m_lexicon->WordListDisplay(
159 m_collectionView,
160 false);
161 break;
162 case ALL_ANALYZED_WORDS:
163 m_lexicon->WordListDisplay(
164 m_collectionView,
165 true);
166 break;
167 case ALL_STEMS:
168 m_lexicon->StemListDisplay(m_collectionView);
169 break;
170 case ALL_PREFIXES:
171 m_lexicon->PrefixListDisplay(m_collectionView);
172 break;
173 case ALL_PREFIX_SIGNATURES:
174 m_lexicon->SignatureListDisplay(
175 m_collectionView,
176 PREFIX_SIGNATURES);
177 break;
178 case ALL_SUFFIXES:
179 m_lexicon->SuffixListDisplay(m_collectionView);
180 break;
181 case ALL_SUFFIX_SIGNATURES:
182 m_lexicon->SignatureListDisplay(
183 m_collectionView,
184 SUFFIX_SIGNATURES);
185 break;
186 case COMPOUNDS:
187 m_lexicon->CompoundListDisplay(
188 m_collectionView,
189 m_lexicon->GetOutFilter(),
190 QChar());
191 break;
192 case LINKERS:
193 m_lexicon->LinkerListDisplay(
194 m_collectionView,
195 m_lexicon->GetOutFilter());
196 break;
197 case COMPOUND_COMPONENTS:
198 m_lexicon->CompoundComponentListDisplay(
199 m_collectionView);
200 break;
201 case TOKENS_REQUESTED:
202 emit tokensRequestedSignal();
203 break;
204 case INITIALSTRINGEDITTEMPLATES:
205 m_Words_InitialTemplates->ListDisplay(
206 m_collectionView, status_display());
207 break;
208 case WORKINGSTRINGEDITTEMPLATES:
209 m_Words_Templates->ListDisplay(
210 m_collectionView, status_display());
211 break;
212 case DESCRIPTION_LENGTH_HISTORY:
213 m_lexicon->GetDLHistory()
214 ->DLHistoryListDisplay(m_collectionView);
215 break;
216 default:
217 break;
221 m_collectionView->setFont(m_eastFont);
224 void LinguisticaMainWindow::updateCollectionViewSlot(Q3ListViewItem* item)
226 if (item == 0)
227 return;
229 CTreeViewItem& it = *static_cast<CTreeViewItem*>(item);
230 enum eDocumentType newDocType = it.GetState();
231 int newIndex = it.GetIndex();
233 if (newDocType == MINI_LEXICON) {
234 m_lexicon->SetActiveMiniIndex(newIndex);
235 updateTreeViewSlot();
236 return;
239 if (newDocType == m_docType &&
240 newIndex == m_lexicon->GetActiveMiniIndex())
241 // nothing to do.
242 return;
244 m_commandMini = newIndex;
245 m_docType = newDocType;
246 if (newIndex >= 0)
247 m_lexicon->SetActiveMiniIndex(newIndex);
248 updateCollectionViewSlot();