r3021 - software/ui/src
Enrico Zini
enrico at alioth.debian.org
Wed Jun 20 14:26:51 UTC 2007
Author: enrico
Date: 2007-06-20 14:26:51 +0000 (Wed, 20 Jun 2007)
New Revision: 3021
Modified:
software/ui/src/Engine.cpp
software/ui/src/Engine.h
software/ui/src/games.cpp
Log:
Give proper initial lists for the type and interface lists
Modified: software/ui/src/Engine.cpp
===================================================================
--- software/ui/src/Engine.cpp 2007-06-20 14:01:19 UTC (rev 3020)
+++ software/ui/src/Engine.cpp 2007-06-20 14:26:51 UTC (rev 3021)
@@ -24,13 +24,8 @@
using namespace ept::apt;
using namespace ept::debtags;
-void Engine::recompute()
+Xapian::Query Engine::makeQuery()
{
- // Clear existing results
- m_results.clear();
- m_types.clear();
- m_interfaces.clear();
-
Xapian::Query query;
Xapian::Query kwquery;
Xapian::Query typequery;
@@ -75,12 +70,67 @@
query = Xapian::Query(Xapian::Query::OP_AND, kwquery,
Xapian::Query(Xapian::Query::OP_AND, typequery, ifacequery));
- Xapian::Enquire enquire(m_textsearch.db());
// We always want programs, so always AND it here
- enquire.set_query(Xapian::Query(Xapian::Query::OP_AND,
+ return Xapian::Query(Xapian::Query::OP_AND,
Xapian::Query("Trole::program"),
- query));
+ query);
+}
+void Engine::recompute()
+{
+ // Clear existing results
+ m_results.clear();
+ m_types.clear();
+ m_interfaces.clear();
+
+ // Compute the types
+ if (m_filter_type.valid())
+ {
+ Tag tmp = m_filter_type;
+ m_filter_type = Tag();
+ Xapian::Enquire enquire(m_textsearch.db());
+ enquire.set_query(makeQuery());
+
+ // Get the 100 top matches
+ Xapian::MSet matches = enquire.get_mset(0, 100);
+ for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i)
+ {
+ // Get all the game and interface tags in the result set
+ set<Tag> tags = m_debtags.getTagsOfItem(i.get_document().get_data());
+ for (set<Tag>::const_iterator j = tags.begin();
+ j != tags.end(); ++j)
+ if (j->facet().name() == "game")
+ m_types.insert(*j);
+ }
+ m_filter_type = tmp;
+ }
+
+ // Compute the interfaces
+ if (m_filter_iface.valid())
+ {
+ Tag tmp = m_filter_iface;
+ m_filter_iface = Tag();
+ Xapian::Enquire enquire(m_textsearch.db());
+ enquire.set_query(makeQuery());
+
+ // Get the 100 top matches
+ Xapian::MSet matches = enquire.get_mset(0, 100);
+ for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i)
+ {
+ // Get all the game and interface tags in the result set
+ set<Tag> tags = m_debtags.getTagsOfItem(i.get_document().get_data());
+ for (set<Tag>::const_iterator j = tags.begin();
+ j != tags.end(); ++j)
+ if (j->facet().name() == "interface")
+ m_interfaces.insert(*j);
+ }
+ m_filter_iface = tmp;
+ }
+
+ Xapian::Enquire enquire(m_textsearch.db());
+ // We always want programs, so always AND it here
+ enquire.set_query(makeQuery());
+
// Get the 100 top matches
Xapian::MSet matches = enquire.get_mset(0, 100);
for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i)
@@ -112,17 +162,18 @@
m_results.push_back(res);
- // FIXME: WRONG: the list of types and interfaces is broader than here,
- // because they come out of selections that don't select themselves
-
// Get all the game and interface tags in the result set
- set<Tag> tags = m_debtags.getTagsOfItem(res.name);
- for (set<Tag>::const_iterator j = tags.begin();
- j != tags.end(); ++j)
- if (j->facet().name() == "game")
- m_types.insert(*j);
- else if (j->facet().name() == "interface")
- m_interfaces.insert(*j);
+ // only for type or filter when they are not set
+ if (!m_filter_type.valid() || !m_filter_iface.valid())
+ {
+ set<Tag> tags = m_debtags.getTagsOfItem(res.name);
+ for (set<Tag>::const_iterator j = tags.begin();
+ j != tags.end(); ++j)
+ if (!m_filter_type.valid() && j->facet().name() == "game")
+ m_types.insert(*j);
+ else if (!m_filter_iface.valid() && j->facet().name() == "interface")
+ m_interfaces.insert(*j);
+ }
}
m_dirty = false;
@@ -152,4 +203,6 @@
m_dirty = true;
}
+#include <ept/debtags/debtags.tcc>
+
// vim:set ts=4 sw=4:
Modified: software/ui/src/Engine.h
===================================================================
--- software/ui/src/Engine.h 2007-06-20 14:01:19 UTC (rev 3020)
+++ software/ui/src/Engine.h 2007-06-20 14:26:51 UTC (rev 3021)
@@ -71,6 +71,7 @@
std::set<ept::debtags::Tag> m_types;
std::set<ept::debtags::Tag> m_interfaces;
+ Xapian::Query makeQuery();
void recompute();
public:
Modified: software/ui/src/games.cpp
===================================================================
--- software/ui/src/games.cpp 2007-06-20 14:01:19 UTC (rev 3020)
+++ software/ui/src/games.cpp 2007-06-20 14:26:51 UTC (rev 3021)
@@ -161,8 +161,5 @@
}
#include <ept/debtags/debtags.tcc>
-#include <tagcoll/coll/simple.tcc>
-#include <tagcoll/coll/fast.tcc>
-#include <tagcoll/TextFormat.tcc>
// vim:set ts=4 sw=4:
More information about the Pkg-games-commits
mailing list