Logo Search packages:      
Sourcecode: adept version File versions  Download package

desktoplist.h

/** -*- C++ -*-
    @file adept/desktoplist.h
    @author Peter Rockai <me@mornfall.net>
*/

#include <qimage.h>
#include <klocale.h>

#include <apt-front/cache/entity/desktop.h>
#include <adept/extendablelist.h>
#include <adept/desktopentryui.h>

#ifndef EPT_DESKTOPLIST_H
#define EPT_DESKTOPLIST_H

class QPopupMenu;

namespace adept {
using namespace aptFront;
using namespace aptFront::cache;

class DesktopItem;

class DesktopList : public ExtendableList, public cache::Observer
{
    Q_OBJECT
public:
    typedef utils::Range< entity::Desktop > Range;
    DesktopList( QWidget *parent = 0, const char *name = 0 );
    void insertRange( Range );
    QPixmap emptyIcon() { return m_emptyIcon; }
    void polishing();
    void polished();

    void setTitle( QString s ) {
        setColumnText( 0, i18n( "Application (" ) + s + i18n( ")" ) );
    }

    void setDisplayCheckboxes( bool d ) { m_displayCheckboxes = d; }
    bool displayCheckboxes() { return m_displayCheckboxes; }
    virtual void notifyPostChange( cache::component::Base * );
    void fireRequest( entity::Package p, component::State::Action a ) {
        emit request( p, a );
    }
protected slots:
    void processClick( QListViewItem *, const QPoint &, int );
signals:
    void request( cache::entity::Package, cache::component::State::Action );
    void showDescription( cache::entity::Desktop );
protected:
    Range m_range;
    QPixmap m_emptyIcon;
    int m_polishing;
    bool m_displayCheckboxes;
};

class DesktopEntry : public DesktopEntryUi
{
    Q_OBJECT
public:
    DesktopEntry( QWidget * = 0, const char * = 0 );
    DesktopItem *item() const;
    entity::Desktop entity() const;
    void setItem( ExtendableItem * );
    entity::Package package() { return entity().package(); }
    virtual void notifyPostChange();
    virtual void resize( int, int );
    // virtual void polish();
public slots:
    void toggled();
protected:
    virtual void mousePressEvent( QMouseEvent *e );
    virtual void mouseReleaseEvent( QMouseEvent *e );
    virtual void showEvent( QShowEvent * );
    bool m_polished;
};

class DesktopItem : public ExtendableItem
{
public:
    ItemExtender *createExtender();
    DesktopItem( DesktopList *l ) 
        : ExtendableItem( l ), m_delayedDone( false )
    {
    }
    DesktopItem( DesktopList *v, DesktopItem *i )
        : ExtendableItem( v, i ), m_delayedDone( false )
    {
    }

    void setup() {
        ExtendableItem::setup();
        if (m_delayedDone)
            return;
        m_delayedDone = true;
        showExtender();
    }

    DesktopList *list() { return dynamic_cast< DesktopList * >( listView() ); }

    QString text( int ) const { return QString( "you shouldn't see this" ); }
    entity::Desktop entity() const { return m_entity; }
    void setEntity( entity::Desktop e ) { m_entity = e; }

    virtual bool less( const ExtendableItem *other ) const {
        const DesktopItem *o = dynamic_cast< const DesktopItem * >( other );
        return entity() < o->entity();
    }

protected:
    entity::Desktop m_entity;
    bool m_delayedDone:1;
};

}

#endif

Generated by  Doxygen 1.6.0   Back to index