Author: rpmcruz
Date: Fri Jan 4 02:41:56 2008
New Revision: 43262
URL: http://svn.opensuse.org/viewcvs/yast?rev=43262&view=rev
Log:
* src/YGPackageSelector.cc (ChangesPane): don't try building it at start;
there aren't changes for sw_single.
* src/yzyppwrapper.h/cc: allow multiple matches for attributes.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/yzyppwrapper.cc
trunk/gtk/src/yzyppwrapper.h
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=43262&r1=43261&r2=43262&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Fri Jan 4 02:41:56 2008
@@ -1,3 +1,10 @@
+2007-01-04 Ricardo Cruz
+
+ * src/YGPackageSelector.cc (ChangesPane): don't try building it at start;
+ there aren't changes for sw_single.
+
+ * src/yzyppwrapper.h/cc: allow multiple matches for attributes.
+
2007-12-30 Ricardo Cruz
* src/ygtkzyppwrapper.cc: noticed, from another project, that we should handle
Modified: trunk/gtk/src/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=43262&r1=43261&r2=43262&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Fri Jan 4 02:41:56 2008
@@ -343,7 +343,7 @@
GtkWidget *getWidget()
{ return m_box; }
- ChangesPane()
+ ChangesPane (bool update_mode)
: m_container (NULL), m_entries (NULL)
{
GtkWidget *heading = gtk_label_new (_("Changes:"));
@@ -378,11 +378,10 @@
Ypp::Query *query = new Ypp::Query();
query->setIsModified (true);
- m_pool = new Ypp::Pool (query);
+ m_pool = new Ypp::Pool (query, !update_mode);
// initialize list -- there could already be packages modified
- for (Ypp::Pool::Iter it = m_pool->getFirst(); it; it = m_pool->getNext (it)) {
+ for (Ypp::Pool::Iter it = m_pool->getFirst(); it; it = m_pool->getNext (it))
ChangesPane::entryInserted (it, m_pool->get (it));
- }
m_pool->setListener (this);
}
@@ -619,7 +618,7 @@
{
Ypp::Node *node = getActive();
if (node)
- query->setCategory (node);
+ query->addCategory (node);
}
};
@@ -636,7 +635,7 @@
{
m_view = new PackagesView();
Ypp::Query *query = new Ypp::Query();
- query->setType (type);
+ query->addType (type);
m_view->setQuery (query);
m_view->setListener (this);
@@ -672,8 +671,9 @@
virtual void writeQuery (Ypp::Query *query)
{
- if (!m_selected.empty())
- query->setCollection (m_selected.front());
+ for (std::list ::const_iterator it = m_selected.begin();
+ it != m_selected.end(); it++)
+ query->addCollection (*it);
}
void doAll (bool install /*or remove*/)
@@ -896,13 +896,13 @@
// create query
Ypp::Query *query = new Ypp::Query();
if (type == Ypp::Package::PATCH_TYPE)
- query->setType (Ypp::Package::PATCH_TYPE);
+ query->addType (Ypp::Package::PATCH_TYPE);
else
- query->setType (Ypp::Package::PACKAGE_TYPE);
+ query->addType (Ypp::Package::PACKAGE_TYPE);
const char *name = gtk_entry_get_text (GTK_ENTRY (m_name));
if (*name)
- query->setName (std::string (name));
+ query->addNames (name, ' ');
switch (m_statuses->getActive())
{
@@ -914,11 +914,8 @@
m_collection->writeQuery (query);
- if (selectedRepo() >= 0) {
- std::list <int> reposQuery;
- reposQuery.push_back (selectedRepo());
- query->setRepositories (reposQuery);
- }
+ if (selectedRepo() >= 0)
+ query->addRepository (selectedRepo());
m_listener->doQuery (query);
}
@@ -1485,7 +1482,7 @@
m_filters = new Filters (update_mode);
m_details = new PackageDetails (m_filters);
m_disk = new DiskView();
- m_changes = new ChangesPane();
+ m_changes = new ChangesPane (update_mode);
m_packages->setListener (this);
m_filters->setListener (this);
Modified: trunk/gtk/src/yzyppwrapper.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.cc?rev=43262&r1=43261&r2=43262&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.cc (original)
+++ trunk/gtk/src/yzyppwrapper.cc Fri Jan 4 02:41:56 2008
@@ -429,6 +429,7 @@
Ypp::Node *Ypp::Package::category()
{
+fprintf (stderr, "package %s category: %s\n", name().c_str(), impl->category->name.c_str());
return impl->category;
}
@@ -722,10 +723,8 @@
template <typename T>
struct Key
{
- Key()
- : defined (false)
- {}
- void define (T v)
+ Key() : defined (false) {}
+ void set (T v)
{
defined = true;
value = v;
@@ -739,14 +738,36 @@
T value;
};
- Key Ypp::Package::Type type;
- Key std::string > name;
- Key category;
+ template <typename T>
+ struct Keys
+ {
+ Keys() : defined (false) {}
+ void add (T v)
+ {
+ defined = true;
+ values.push_back (v);
+ }
+ bool is (const T &v) const
+ {
+ if (!defined) return true;
+ typename std::list <T>::const_iterator it;
+ for (it = values.begin(); it != values.end(); it++)
+ if (*it == v)
+ return true;
+ return false;
+ }
+ bool defined;
+ std::list <T> values;
+ };
+
+ Keys Ypp::Package::Type types;
+ Keys std::string names;
+ Keys categories;
+ Keys collections;
+ Keys <int> repositories;
Key <bool> isInstalled;
Key <bool> hasUpgrade;
Key <bool> isModified;
- Key onRepositories;
- Key onCollection;
Impl()
{}
@@ -754,43 +775,50 @@
bool match (Package *package)
{
bool match = true;
-// we must avoid passing values by copy, as well as zypp calls
- if (match && type.defined)
- match = type.is (package->type());
+ if (match && types.defined)
+ match = types.is (package->type());
if (match && isInstalled.defined)
match = isInstalled.is (package->isInstalled());
if (match && hasUpgrade.defined)
match = hasUpgrade.is (package->hasUpgrade());
if (match && isModified.defined)
match = isModified.is (package->isModified());
- if (match && name.defined) {
- const std::list std::string &names = name.value;
+ if (match && names.defined) {
+ const std::list std::string &values = names.values;
std::list std::string::const_iterator it;
- for (it = names.begin(); it != names.end(); it++) {
+ for (it = values.begin(); it != values.end(); it++)
if (!YGUtils::contains (package->name(), *it) &&
!YGUtils::contains (package->summary(), *it) &&
- !YGUtils::contains (package->provides(), *it)) {
- match = false;
+ !YGUtils::contains (package->provides(), *it))
break;
- }
- }
+ match = it != values.end();
+ }
+ if (match && collections.defined) {
+ const std::list &values = collections.values;
+ std::list ::const_iterator it;
+ for (it = values.begin(); it != values.end(); it++)
+ if (package->fromCollection (*it))
+ break;
+ match = it != values.end();
}
- if (match && onCollection.defined)
- match = package->fromCollection (onCollection.value);
- if (match && category.defined) {
- Ypp::Node *query_category = category.value;
+ if (match && categories.defined) {
Ypp::Node *pkg_category = package->category();
- GNode *node = (GNode *) query_category->impl;
- if (!g_node_find (node, G_PRE_ORDER, G_TRAVERSE_ALL, pkg_category))
- match = false;
+ const std::list &values = categories.values;
+ std::list ::const_iterator it;
+ for (it = values.begin(); it != values.end(); it++) {
+ GNode *node = (GNode *) (*it)->impl;
+ if (g_node_find (node, G_PRE_ORDER, G_TRAVERSE_ALL, pkg_category))
+ break;
+ }
+ match = it != values.end();
}
- if (match && onRepositories.defined) {
- const std::list <int> &repos = onRepositories.value;
+ if (match && repositories.defined) {
+ const std::list <int> &values = repositories.values;
std::list <int>::const_iterator it;
- for (it = repos.begin(); it != repos.end(); it++)
+ for (it = values.begin(); it != values.end(); it++)
if (package->isOnRepository (*it))
break;
- match = it != repos.end();
+ match = it != values.end();
}
return match;
}
@@ -801,22 +829,31 @@
Ypp::Query::~Query()
{ delete impl; }
-void Ypp::Query::setType (Ypp::Package::Type value)
-{ impl->type.define (value); }
-void Ypp::Query::setName (std::string value)
-{ impl->name.define (YGUtils::splitString (value, ' ')); }
-void Ypp::Query::setCategory (Ypp::Node *value)
-{ impl->category.define (value); }
+void Ypp::Query::addType (Ypp::Package::Type value)
+{ impl->types.add (value); }
+void Ypp::Query::addNames (std::string value, char separator)
+{
+ if (separator) {
+ std::list std::string values = YGUtils::splitString (value, separator);
+ for (std::list std::string::const_iterator it = values.begin();
+ it != values.end(); it++)
+ impl->names.add (*it);
+ }
+ else
+ impl->names.add (value);
+}
+void Ypp::Query::addCategory (Ypp::Node *value)
+{ impl->categories.add (value); }
+void Ypp::Query::addCollection (Ypp::Package *value)
+{ impl->collections.add (value); }
+void Ypp::Query::addRepository (int value)
+{ impl->repositories.add (value); }
void Ypp::Query::setIsInstalled (bool value)
-{ impl->isInstalled.define (value); }
+{ impl->isInstalled.set (value); }
void Ypp::Query::setHasUpgrade (bool value)
-{ impl->hasUpgrade.define (value); }
+{ impl->hasUpgrade.set (value); }
void Ypp::Query::setIsModified (bool value)
-{ impl->isModified.define (value); }
-void Ypp::Query::setRepositories (std::list <int> value)
-{ impl->onRepositories.define (value); }
-void Ypp::Query::setCollection (Ypp::Package *value)
-{ impl->onCollection.define (value); }
+{ impl->isModified.set (value); }
//** Pool
@@ -826,10 +863,11 @@
GSList *packages;
Pool::Listener *listener;
- Impl (Query *query)
- : query (query), listener (NULL)
+ Impl (Query *query, bool startEmpty)
+ : query (query), packages (NULL), listener (NULL)
{
- packages = buildPool (query);
+ if (!startEmpty)
+ packages = buildPool (query);
ypp->impl->addPool (this);
}
@@ -881,7 +919,7 @@
{
GSList *pool = NULL;
for (int t = 0; t < Ypp::Package::TOTAL_TYPES; t++) {
- if (!query->impl->type.is ((Ypp::Package::Type) t))
+ if (!query->impl->types.is ((Ypp::Package::Type) t))
continue;
GSList *entire_pool = ypp->impl->getPackages ((Ypp::Package::Type) t);
for (GSList *i = entire_pool; i; i = i->next) {
@@ -894,8 +932,8 @@
}
};
-Ypp::Pool::Pool (Query *query)
-{ impl = new Impl (query); }
+Ypp::Pool::Pool (Query *query, bool startEmpty)
+{ impl = new Impl (query, startEmpty); }
Ypp::Pool::~Pool()
{ delete impl; }
Modified: trunk/gtk/src/yzyppwrapper.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.h?rev=43262&r1=43261&r2=43262&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.h (original)
+++ trunk/gtk/src/yzyppwrapper.h Fri Jan 4 02:41:56 2008
@@ -94,14 +94,14 @@
// Query
struct Query {
Query();
- void setType (Package::Type type);
- void setName (std::string name);
- void setCategory (Ypp::Node *category);
+ void addType (Package::Type type);
+ void addNames (std::string name, char separator = 0);
+ void addCategory (Ypp::Node *category);
+ void addCollection (Ypp::Package *package);
+ void addRepository (int repositories);
void setIsInstalled (bool installed);
void setHasUpgrade (bool upgradable);
void setIsModified (bool modified);
- void setRepositories (std::list <int> repositories);
- void setCollection (Ypp::Package *package);
~Query();
struct Impl;
@@ -110,9 +110,9 @@
// Pool
struct Pool {
- // TODO: add a flag to check if the pool should be constructed at initilization
- // e.g. it may make no sense to try to build for the ChangesPane.
- Pool (Query *query);
+ Pool (Query *query, bool startEmpty = false);
+ // startEmpty is an optimization when you know the pool won't have
+ // elements at creations.
typedef void * Iter;
Iter getFirst();
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org