Mercurial > hg > svgui
comparison widgets/TransformFinder.cpp @ 431:4711b400f976
* Add beginnings of capability to search plugins that are not yet
installed -- lots more work to do here, though
author | Chris Cannam |
---|---|
date | Tue, 14 Oct 2008 16:36:35 +0000 |
parents | 6bf3c906b7a5 |
children | 1e0744b2cebe |
comparison
equal
deleted
inserted
replaced
430:bcaeb2ba9b74 | 431:4711b400f976 |
---|---|
129 TransformFactory::SearchResults results = | 129 TransformFactory::SearchResults results = |
130 TransformFactory::getInstance()->search(keywords); | 130 TransformFactory::getInstance()->search(keywords); |
131 | 131 |
132 std::cerr << results.size() << " result(s)..." << std::endl; | 132 std::cerr << results.size() << " result(s)..." << std::endl; |
133 | 133 |
134 std::set<TransformFactory::Match> sorted; | 134 std::set<TextMatcher::Match> sorted; |
135 sorted.clear(); | 135 sorted.clear(); |
136 for (TransformFactory::SearchResults::const_iterator j = results.begin(); | 136 for (TransformFactory::SearchResults::const_iterator j = results.begin(); |
137 j != results.end(); ++j) { | 137 j != results.end(); ++j) { |
138 sorted.insert(j->second); | 138 sorted.insert(j->second); |
139 } | 139 } |
140 | 140 |
141 m_sortedResults.clear(); | 141 m_sortedResults.clear(); |
142 for (std::set<TransformFactory::Match>::const_iterator j = sorted.end(); | 142 for (std::set<TextMatcher::Match>::const_iterator j = sorted.end(); |
143 j != sorted.begin(); ) { | 143 j != sorted.begin(); ) { |
144 --j; | 144 --j; |
145 m_sortedResults.push_back(*j); | 145 m_sortedResults.push_back(*j); |
146 if (m_sortedResults.size() == maxResults) break; | 146 if (m_sortedResults.size() == maxResults) break; |
147 } | 147 } |
148 | 148 |
149 if (m_sortedResults.empty()) m_selectedTransform = ""; | 149 if (m_sortedResults.empty()) m_selectedTransform = ""; |
150 else m_selectedTransform = m_sortedResults.begin()->transform; | 150 else m_selectedTransform = m_sortedResults.begin()->key; |
151 | 151 |
152 m_upToDateCount = 0; | 152 m_upToDateCount = 0; |
153 | 153 |
154 for (int j = m_labels.size(); j > m_sortedResults.size(); ) { | 154 for (int j = m_labels.size(); j > m_sortedResults.size(); ) { |
155 m_labels[--j]->hide(); | 155 m_labels[--j]->hide(); |
162 | 162 |
163 while (m_upToDateCount < m_sortedResults.size()) { | 163 while (m_upToDateCount < m_sortedResults.size()) { |
164 | 164 |
165 int i = m_upToDateCount; | 165 int i = m_upToDateCount; |
166 | 166 |
167 std::cerr << "sorted size = " << m_sortedResults.size() << std::endl; | 167 // std::cerr << "sorted size = " << m_sortedResults.size() << std::endl; |
168 | 168 |
169 TransformDescription desc = | 169 TransformDescription desc; |
170 TransformFactory::getInstance()->getTransformDescription | 170 TransformId tid = m_sortedResults[i].key; |
171 (m_sortedResults[i].transform); | 171 TransformFactory *factory = TransformFactory::getInstance(); |
172 TransformFactory::TransformInstallStatus status = | |
173 factory->getTransformInstallStatus(tid); | |
174 QString suffix; | |
175 | |
176 if (status == TransformFactory::TransformInstalled) { | |
177 desc = factory->getTransformDescription(tid); | |
178 } else { | |
179 desc = factory->getUninstalledTransformDescription(tid); | |
180 suffix = tr("<i> (not installed)</i>"); | |
181 } | |
172 | 182 |
173 QString labelText; | 183 QString labelText; |
174 labelText += tr("%1<br><small>") | 184 labelText += tr("%1%2<br><small>") |
175 .arg(XmlExportable::encodeEntities(desc.name)); | 185 .arg(XmlExportable::encodeEntities(desc.name)) |
186 .arg(suffix); | |
176 | 187 |
177 labelText += "..."; | 188 labelText += "..."; |
178 for (TransformFactory::Match::FragmentMap::const_iterator k = | 189 for (TextMatcher::Match::FragmentMap::const_iterator k = |
179 m_sortedResults[i].fragments.begin(); | 190 m_sortedResults[i].fragments.begin(); |
180 k != m_sortedResults[i].fragments.end(); ++k) { | 191 k != m_sortedResults[i].fragments.end(); ++k) { |
181 labelText += k->second; | 192 labelText += k->second; |
182 labelText += "... "; | 193 labelText += "... "; |
183 } | 194 } |
184 labelText += tr("</small>"); | 195 labelText += tr("</small>"); |
185 | 196 |
186 QString selectedText; | 197 QString selectedText; |
187 selectedText += tr("<b>%1</b><br>") | 198 selectedText += tr("<b>%1</b>%2<br>") |
188 .arg(XmlExportable::encodeEntities(desc.name)); | 199 .arg(XmlExportable::encodeEntities |
189 selectedText += tr("<small>%1</small>") | 200 (desc.name == "" ? desc.identifier : desc.name)) |
190 .arg(XmlExportable::encodeEntities(desc.longDescription)); | 201 .arg(suffix); |
202 | |
203 if (desc.longDescription != "") { | |
204 selectedText += tr("<small>%1</small>") | |
205 .arg(XmlExportable::encodeEntities(desc.longDescription)); | |
206 } else if (desc.description != "") { | |
207 selectedText += tr("<small>%1</small>") | |
208 .arg(XmlExportable::encodeEntities(desc.description)); | |
209 } | |
191 | 210 |
192 selectedText += tr("<br><small>"); | 211 selectedText += tr("<br><small>"); |
193 selectedText += tr(" — Plugin type: %1<br>") | 212 if (desc.type != "") { |
194 .arg(XmlExportable::encodeEntities(desc.type)); | 213 selectedText += tr(" — Plugin type: %1<br>") |
195 selectedText += tr(" — Category: %1<br>") | 214 .arg(XmlExportable::encodeEntities(desc.type)); |
196 .arg(XmlExportable::encodeEntities(desc.category)); | 215 } |
216 if (desc.category != "") { | |
217 selectedText += tr(" — Category: %1<br>") | |
218 .arg(XmlExportable::encodeEntities(desc.category)); | |
219 } | |
197 selectedText += tr(" — System identifier: %1") | 220 selectedText += tr(" — System identifier: %1") |
198 .arg(XmlExportable::encodeEntities(desc.identifier)); | 221 .arg(XmlExportable::encodeEntities(desc.identifier)); |
199 selectedText += tr("</small>"); | 222 selectedText += tr("</small>"); |
200 | 223 |
201 if (i >= m_labels.size()) { | 224 if (i >= m_labels.size()) { |