/* -*- c++ -*-
 *
 * clientlist.h
 *
 * Copyright (C) 2003 Petter Stokke <ummo@hellokitty.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef __kmldonkey_clientlist_h__
#define __kmldonkey_clientlist_h__

#include <klistview.h>

#include "availability.h"

class SourceItem;

class ClientList : public KListView
{
    Q_OBJECT

public:

    ClientList(int file, QWidget* parent = 0, const char* name = 0);

public slots:

    void fileSourceUpdated(int fileno, int source);
    void fileSourceRemoved(int fileno, int source);
    void clientUpdated(int client);
    void clientRemoved(int client);
    void contextSource(KListView*, QListViewItem* item, const QPoint& pt);
    void loseCache();

protected slots:

    void addToFriends();

protected:

    void showEvent(QShowEvent*);

private:

    bool showsources;
    int fn;
    QIntDict<SourceItem> sources;

};

class SourceItem : public KListViewItem, public AvailabilityRenderer
{
public:
    SourceItem(ClientList* parent, int fileno, int clientno);

    int fileNo() const;
    int clientNo() const;

    virtual QString text(int column) const;

    virtual void paintCell(QPainter* p, const QColorGroup& cg, int col, int w, int align);
    virtual int width(const QFontMetrics& fm, const QListView* lv, int c) const;

private:
    int fn, cn;
};


#endif // __kmldonkey_clientlist_h__
