[Aptitude-devel] Experimental package and package_pool implementation

Piotr Galiszewski piotr at galiszewski.pl
Wed Jul 14 19:31:26 UTC 2010


2010/7/14 Daniel Burrows <dburrows at google.com>:
> On Wed, Jul 14, 2010 at 12:11 PM, Piotr Galiszewski
> <piotr at galiszewski.pl> wrote:
>> 2010/7/14 Daniel Burrows <dburrows at google.com>:
>>> On Wed, Jul 14, 2010 at 8:50 AM, Piotr Galiszewski <piotr at galiszewski.pl> wrote:
>>>> Indexes are not stored. Packages count is used to determine how much
>>>> rows should be added to view, packages_at_index is used to get
>>>> information about package that should be shown in given row. It is
>>>> simple and typical for model in Qt Model Architecture
>>>
>>>  Ah, ok, here's my point of confusion: I thought package_pool was supposed
>>> to contain all the packages in the entire program, acting basically as a
>>> cache/flyweight holder to ensure we only have one package object per apt
>>> package.  But actually, from what you said and from the patch you posted,
>>> it contains just the packages in a single view.
>>>
>>>  Is that right?  How does that reconcile with package_pool being a singleton?
>>>
>>
>> It is one of the tasks this class will have. Other classes (such as
>> each package_info_tab, maybe another models, or status_widget,
>> resolver etc.) will use signals about changing cache state. This
>> classes will probably use package_ptr objects, so cache's signals have
>> to be translated somewhere to package objects.
>
>  So, let me ask my main question more directly: suppose I have
> two different package tabs with different filters.  How do they end
> up displaying different lists of packages, if they both just show all
> the packages in the singleton package_pool?
>

It is the power of Qt models ;) Model is only asked about what should
be displayed. Sorting and filtering is done by proxy model, which
decides is one particular package should be displayed or not. So model
always contains reference to all objects in view (is not entirely true
because data could lazy loaded), and by default all packages are
displayed. But each view will have different proxy model. And every
proxy model decides which item will be displayed. My sample code from
later patch:

packages_list_view *packages_view = new packages_list_view(this);
packages_model *model = new packages_model(this);
packages_proxy_model *proxy_model = new packages_proxy_model(this);
proxy_model->setSourceModel(model);
packages_view->setModel(proxy_model);

A proxy model uses "normal" model as a data source. And the proxy
model is added as a model for view

>  Daniel
>
-- 
Regards
Piotr Galiszewski



More information about the Aptitude-devel mailing list