/* -*- c++ -*-
 *
 * availability.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_availability_h__
#define __kmldonkey_availability_h__

#include <qframe.h>
#include <qcolor.h>
#include <qpalette.h>
#include <qpixmap.h>
#include <qimage.h>
#include <donkeyprotocol.h>

class AvailabilityRenderer
{
public:
    AvailabilityRenderer(int file);
    AvailabilityRenderer(int file, int source);
    FileInfo* fileInfo();
    int chunks() const;
    void loseCache();

protected:
    void paintAvailability(QPainter& p, QRect& r);
    int rfileno, clno, chunkNo;
    bool isClientRenderer;

private:
    void paintSection(QPainter& p, QRect& r, QColor& c, int depth, bool isTop);
    void paintChunk(QPainter& p, QRect& r, int chunk);
    void updateFileInfo();
    
    QPixmap m_cache;
};

class AvailabilityWidget : public QFrame, public AvailabilityRenderer
{
    Q_OBJECT
public:
    AvailabilityWidget(int file, QWidget* parent = 0, const char* name = 0, bool frame = true);

    QSizePolicy sizePolicy() const;
    QSize minimumSizeHint() const;

protected:
    void paintEvent(QPaintEvent*);

};

#include <fileinfo.h>


#endif // __kmldonkey_availability_h__
