[Debtags-commits] [svn] r893 - debtags-edit/trunk/src
Enrico Zini
debtags-commits@lists.alioth.debian.org
Fri, 17 Jun 2005 23:01:10 +0000
Author: enrico
Date: Fri Jun 17 23:01:09 2005
New Revision: 893
Modified:
debtags-edit/trunk/src/DebtagsDocument.cc
debtags-edit/trunk/src/DebtagsDocument.h
debtags-edit/trunk/src/DebtagsEditor.cc
debtags-edit/trunk/src/FilterPanel.cc
debtags-edit/trunk/src/RelatedPanel.cc
debtags-edit/trunk/src/TagEditor.cc
debtags-edit/trunk/src/TagMenu.cc
debtags-edit/trunk/src/TagSelector.cc
debtags-edit/trunk/src/debtags-edit.cc
Log:
Don't use Debtags::Environment anymore
Modified: debtags-edit/trunk/src/DebtagsDocument.cc
==============================================================================
--- debtags-edit/trunk/src/DebtagsDocument.cc (original)
+++ debtags-edit/trunk/src/DebtagsDocument.cc Fri Jun 17 23:01:09 2005
@@ -30,7 +30,6 @@
#include <tagcoll/StdioParserInput.h>
#include <tagcoll/StringParserInput.h>
-#include <debtags/Environment.h>
#include <debtags/TagDB.h>
#include "Environment.h"
@@ -46,7 +45,7 @@
const char* fn_deriv = "/var/lib/debtags/derived-tags";
*/
-DebtagsDocument::DebtagsDocument() throw () : _undoTail(0), specialsGen(*this), computeIntensive(true), specials(100), hasSpecials(NO)
+DebtagsDocument::DebtagsDocument() throw () : DebtagsSimple<Package>(true), _undoTail(0), specialsGen(*this), computeIntensive(true), specials(100), hasSpecials(NO)
{
regenerateSpecials();
}
@@ -91,9 +90,9 @@
{
// Limit the number of packages, to have decent times during debugging
TFLimit limFilter(100, &doc.specials);
- Debtags::Environment::get().output(limFilter);
+ doc.tagDB().output(limFilter);
} else {
- Debtags::Environment::get().output(doc.specials);
+ doc.tagDB().output(doc.specials);
}
fprintf(stderr, "SpecialsGen thread: specials fed data\n");
if (_interrupt) return 0;
@@ -177,7 +176,7 @@
debug("Pre undo: tail: %d, size: %d\n", _undoTail, _undoBuffer.size());
_undoTail--;
- Debtags::Environment::get().tagDB().applyChange(_undoBuffer[_undoTail]);
+ tagDB().applyChange(_undoBuffer[_undoTail]);
_undoBuffer[_undoTail] = _undoBuffer[_undoTail].getReverse();
debug("Post undo: tail: %d, size: %d\n", _undoTail, _undoBuffer.size());
@@ -192,7 +191,7 @@
debug("Pre redo: tail: %d, size: %d\n", _undoTail, _undoBuffer.size());
- Debtags::Environment::get().tagDB().applyChange(_undoBuffer[_undoTail]);
+ tagDB().applyChange(_undoBuffer[_undoTail]);
_undoBuffer[_undoTail] = _undoBuffer[_undoTail].getReverse();
_undoTail++;
@@ -205,7 +204,7 @@
void DebtagsDocument::applyChange(const PatchList<Debtags::Package, Tag>& change)
{
//TagcollChange<Debtags::Package, Tag> reverse = Debtags::Environment::get().tagDB().applyChange(change);
- Debtags::Environment::get().tagDB().applyChange(change);
+ tagDB().applyChange(change);
if (1 /*reverse != change*/)
{
@@ -255,7 +254,7 @@
void DebtagsDocument::save() throw (FileException)
{
- Debtags::Environment::get().tagDB().savePatch();
+ tagDB().savePatch();
//DebtagsEnvironment::get().savePatch(_collection);
/*
FILE* out = fopen(file.c_str(), "wt");
@@ -280,7 +279,7 @@
void DebtagsDocument::send() throw (FileException)
{
- Debtags::Environment::get().tagDB().sendPatch();
+ tagDB().sendPatch();
}
/*
Modified: debtags-edit/trunk/src/DebtagsDocument.h
==============================================================================
--- debtags-edit/trunk/src/DebtagsDocument.h (original)
+++ debtags-edit/trunk/src/DebtagsDocument.h Fri Jun 17 23:01:09 2005
@@ -25,6 +25,7 @@
#include <sigc++/sigc++.h>
+#include <debtags/DebtagsSimple.h>
#include <debtags/Package.h>
#include <debtags/Tag.h>
#include <debtags/PackageSet.h>
@@ -39,7 +40,7 @@
#include <vector>
-class DebtagsDocument
+class DebtagsDocument : public Debtags::DebtagsSimple<Debtags::Package>
{
public:
typedef SigC::Signal0<void> type_signal_changed;
Modified: debtags-edit/trunk/src/DebtagsEditor.cc
==============================================================================
--- debtags-edit/trunk/src/DebtagsEditor.cc (original)
+++ debtags-edit/trunk/src/DebtagsEditor.cc Fri Jun 17 23:01:09 2005
@@ -25,7 +25,6 @@
#include <tagcoll/stringf.h>
#include <debtags/TagSet.h>
#include <tagcoll/Patches.h>
-#include <debtags/Environment.h>
#include <debtags/TagDB.h>
#include "Environment.h"
#include "DebtagsDocument.h"
@@ -204,7 +203,7 @@
{
current = pkg;
descrBuf->set_text(pkg.fulldata());
- tagEditor.setSelected(pkg.tags());
+ tagEditor.setSelected(doc.tagDB().getTags(pkg));
}
template<class DOC>
@@ -214,7 +213,7 @@
// Make the change
PatchList<Debtags::Package, Tag> change;
- TagSet oldTags = Debtags::Environment::get().tagDB().getTags(current);
+ TagSet oldTags = doc.tagDB().getTags(current);
change.addPatch(Patch<Package, Tag>(current, newTags - oldTags, oldTags - newTags));
doc.applyChange(change);
//Debtags::Environment::get().tagDB().applyChange(change);
Modified: debtags-edit/trunk/src/FilterPanel.cc
==============================================================================
--- debtags-edit/trunk/src/FilterPanel.cc (original)
+++ debtags-edit/trunk/src/FilterPanel.cc Fri Jun 17 23:01:09 2005
@@ -23,7 +23,6 @@
#include "FilterPanel.h"
#include <tagcoll/stringf.h>
-#include <debtags/Environment.h>
#include <debtags/TagDB.h>
#include <debtags/DebtagsFilters.h>
#include <debtags/Vocabulary.h>
@@ -163,6 +162,7 @@
class Stats : public TagcollConsumer<Package, Tag>, public std::map<Facet, int>
{
protected:
+ DOC& doc;
const Facet& pivot;
FacetSet facets;
@@ -181,9 +181,9 @@
}
public:
- Stats(const Facet& pivot) : pivot(pivot)
+ Stats(DOC& doc, const Facet& pivot) : doc(doc), pivot(pivot)
{
- facets = Debtags::Environment::get().vocabulary().getFacets();
+ facets = doc.vocabulary().getFacets();
}
virtual ~Stats() {}
void consume(const Package& pkg) {}
@@ -206,8 +206,8 @@
slaveListModel->clear();
Gtk::TreeModel::Row row;
- Stats stats(master);
- Debtags::Environment::get().tagDB().outputPatched(stats);
+ Stats stats(doc, master);
+ doc.tagDB().outputPatched(stats);
std::map<int, Facet> rstats;
for (typename Stats::const_iterator i = stats.begin();
i != stats.end(); i++)
@@ -271,7 +271,7 @@
add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
Gtk::TreeModel::Row row;
- FacetSet facets = Debtags::Environment::get().vocabulary().getFacets();
+ FacetSet facets = doc.vocabulary().getFacets();
for (FacetSet::const_iterator i = facets.begin();
i != facets.end(); i++)
{
@@ -492,21 +492,21 @@
if (specialID == -1)
{
ExpressionFilter filter(specialExpression, &consumer);
- Debtags::Environment::get().output(filter);
+ doc.tagDB().output(filter);
} else if (specialID == 0) {
- Debtags::Environment::get().output(consumer);
+ doc.tagDB().output(consumer);
} else if (specialID == 1) {
UntaggedFilter filter(&consumer);
- Debtags::Environment::get().output(filter);
+ doc.tagDB().output(filter);
} else if (specialID == 2) {
ExpressionFilter filter("uitoolkit::* && !interface::*", &consumer);
- Debtags::Environment::get().output(filter);
+ doc.tagDB().output(filter);
} else if (specialID == 3) {
ExpressionFilter filter("uitoolkit::* && !implemented-in::*", &consumer);
- Debtags::Environment::get().output(filter);
+ doc.tagDB().output(filter);
} else if (specialID == 4) {
ExpressionFilter filter("!role::*", &consumer);
- Debtags::Environment::get().output(filter);
+ doc.tagDB().output(filter);
} else {
if (!specialFacet)
{
@@ -515,7 +515,7 @@
for (PackageSet::const_iterator i = specialPackages.begin();
i != specialPackages.end(); i++)
{
- TagSet tags = i->tags();
+ TagSet tags = doc.tagDB().getTags(*i);
if (tags.empty())
consumer.consume(*i);
else
@@ -539,7 +539,20 @@
}
else
{
- Debtags::Environment::get().output(doc.subCollection, filter);
+ //doc.serializer().packageDB().output(doc.subCollection, filter);
+ if (filter.hasOnlyDebtags())
+ doc.tagDB().outputHavingTags(filter.debtagsTagset(), doc.subCollection);
+ else if (filter.hasDebtags())
+ {
+ filter.setConsumer(&doc.subCollection);
+ doc.tagDB().outputHavingTags(filter.debtagsTagset(), filter);
+ }
+ else
+ {
+ filter.setConsumer(&doc.subCollection);
+ doc.tagDB().output(filter);
+ }
+
}
//PackageBuffer::iterator lastIter = pkgs.size() > max_pkg ? pkgs.begin() + max_pkg : pkgs.end();
Modified: debtags-edit/trunk/src/RelatedPanel.cc
==============================================================================
--- debtags-edit/trunk/src/RelatedPanel.cc (original)
+++ debtags-edit/trunk/src/RelatedPanel.cc Fri Jun 17 23:01:09 2005
@@ -25,8 +25,6 @@
#include <tagcoll/stringf.h>
#include <debtags/TagSet.h>
-#include <debtags/Environment.h>
-
#include "DebtagsDocument.h"
#include <map>
@@ -98,11 +96,12 @@
unsigned int dist = 0;
pkgs.clear();
- TagSet ref = pivot.tags();
+ TagSet ref = doc.tagDB().getTags(pivot);
for ( ; pkgs.size() == 0 && dist <= ref.size(); dist++)
{
fprintf(stderr, "Trying distance %d...\n", dist);
- Debtags::Environment::get().outputRelated(pkgs, pivot, dist);
+ //Debtags::Environment::get().outputRelated(pkgs, pivot, dist);
+ PackageSet(doc.tagDB().getRelatedItems(pivot, dist)).output(pkgs);
}
PackageBuffer::const_iterator lastIter = pkgs.size() > max_pkg ? pkgs.begin() + max_pkg : pkgs.end();
Modified: debtags-edit/trunk/src/TagEditor.cc
==============================================================================
--- debtags-edit/trunk/src/TagEditor.cc (original)
+++ debtags-edit/trunk/src/TagEditor.cc Fri Jun 17 23:01:09 2005
@@ -26,7 +26,6 @@
#include "Environment.h"
-#include <debtags/Environment.h>
#include <debtags/Vocabulary.h>
#include <gtkmm/eventbox.h>
@@ -137,7 +136,7 @@
void TagEditor<DOC>::on_document_changed()
{
time_t start = time(NULL);
- TagSet allTags = Debtags::Environment::get().vocabulary().getTags();
+ TagSet allTags = doc.vocabulary().getTags();
_selected = _selected ^ allTags;
updateView();
time_t end = time(NULL);
Modified: debtags-edit/trunk/src/TagMenu.cc
==============================================================================
--- debtags-edit/trunk/src/TagMenu.cc (original)
+++ debtags-edit/trunk/src/TagMenu.cc Fri Jun 17 23:01:09 2005
@@ -25,12 +25,11 @@
#include "Environment.h"
#include "DebtagsDocument.h"
-#include "debtags/Environment.h"
-#include "debtags/Vocabulary.h"
-#include "debtags/TagDB.h"
-#include "debtags/TagToFacet.h"
-#include "tagcoll/TagCollection.h"
-#include "tagcoll/SmartHierarchy.h"
+#include <debtags/Vocabulary.h>
+#include <debtags/TagDB.h>
+#include <debtags/TagToFacet.h>
+#include <tagcoll/TagCollection.h>
+#include <tagcoll/SmartHierarchy.h>
#include <map>
#include <vector>
@@ -144,7 +143,7 @@
template<class DOC>
void TagMenu<DOC>::populateAll(const DOC& doc) throw ()
{
- populateWith(Debtags::Environment::get().vocabulary().getTags());
+ populateWith(doc.vocabulary().getTags());
}
template<class DOC>
@@ -204,8 +203,8 @@
void TagMenu<DOC>::populateAvailable(const DOC& doc, const TagSet& selectedTags) throw ()
{
TagSet tags = selectedTags.empty() ?
- Debtags::Environment::get().tagDB().getAllTags()
- : Debtags::Environment::get().tagDB().getCompanionTags(selectedTags);
+ doc.tagDB().getAllTags()
+ : doc.tagDB().getCompanionTags(selectedTags);
//TagSet tags = Debtags::Environment::get().tagDB().getCompanionTags(selectedTags);
populateWith(tags);
}
@@ -213,14 +212,14 @@
template<class DOC>
void TagMenu<DOC>::populateAvailable(const DOC& doc, const TagSet& selectedTags, const Facet& facet) throw ()
{
- TagSet tags = Debtags::Environment::get().tagDB().getCompanionTags(selectedTags);
+ TagSet tags = doc.tagDB().getCompanionTags(selectedTags);
populateWith(tags, facet);
}
template<class DOC>
void TagMenu<DOC>::populateUnselected(const DOC& doc, const TagSet& selectedTags) throw ()
{
- TagSet tags = Debtags::Environment::get().vocabulary().getTags() - selectedTags;
+ TagSet tags = doc.vocabulary().getTags() - selectedTags;
//for (OpSet<string>::const_iterator i = tags.begin(); i != tags.end(); i++)
//printf("Sel: %.*s\n", PFSTR(*i));
populateWith(tags);
@@ -229,7 +228,7 @@
template<class DOC>
void TagMenu<DOC>::populateUnselected(const DOC& doc, const TagSet& selectedTags, const Facet& facet) throw ()
{
- TagSet tags = Debtags::Environment::get().vocabulary().getTags() - selectedTags;
+ TagSet tags = doc.vocabulary().getTags() - selectedTags;
//for (OpSet<string>::const_iterator i = tags.begin(); i != tags.end(); i++)
//printf("Sel: %.*s\n", PFSTR(*i));
populateWith(tags, facet);
Modified: debtags-edit/trunk/src/TagSelector.cc
==============================================================================
--- debtags-edit/trunk/src/TagSelector.cc (original)
+++ debtags-edit/trunk/src/TagSelector.cc Fri Jun 17 23:01:09 2005
@@ -24,7 +24,6 @@
#include "TagMenu.h"
#include "Environment.h"
-#include <debtags/Environment.h>
#include <debtags/Vocabulary.h>
#include <gtkmm/eventbox.h>
@@ -130,7 +129,7 @@
void TagSelector::on_document_changed()
{
time_t start = time(NULL);
- TagSet allTags = Debtags::Environment::get().vocabulary().getTags();
+ TagSet allTags = doc.vocabulary().getTags();
_selected = _selected ^ allTags;
updateView();
time_t end = time(NULL);
Modified: debtags-edit/trunk/src/debtags-edit.cc
==============================================================================
--- debtags-edit/trunk/src/debtags-edit.cc (original)
+++ debtags-edit/trunk/src/debtags-edit.cc Fri Jun 17 23:01:09 2005
@@ -29,7 +29,6 @@
#include <tagcoll/Exception.h>
#include <tagcoll/stringf.h>
-#include <debtags/Environment.h>
#include <debtags/TagDB.h>
#include "Environment.h"
@@ -77,16 +76,16 @@
if (opts.get("debug").defined())
Environment::get().debug(true);
- Debtags::Environment::init(true);
+ //Debtags::Environment::init(true);
//printf("State dir is %.*s\n", PFSTR(Debtags::TagDB<Debtags::Package>::statedir()));
- // Check for the existance of a database
- if (!Debtags::Environment::get().hasTagDatabase())
- warning("The tag database has not yet been generated: you need to run \"debtags update\" (as root) before using Package Tags\n");
-
// Read the full collection
DebtagsDocument document;
+ // Check for the existance of a database
+ if (!document.hasTagDatabase())
+ warning("The tag database has not yet been generated: you need to run \"debtags update\" (as root) before using Package Tags\n");
+
//document.load();
Gtk::Main app(&argc, &argv);