You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdenetwork/kopete/libkopete/kopetepicture.h

150 lines
3.6 KiB

/*
kopetepicture.h - Kopete Picture
Copyright (c) 2005 by Michaël Larouche <michael.larouche@kdemail.net>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
*************************************************************************
*/
#ifndef KOPETEPICTURE_H
#define KOPETEPICTURE_H
#include <tdemacros.h>
#include <ksharedptr.h>
#include "kopete_export.h"
#include <tqimage.h>
namespace TDEABC
{
class Picture;
}
namespace Kopete
{
/**
* @brief Represent a picture in Kopete context
*
* It kept a cache of a TQImage object, a base64 string and
* a path to a image file. It ensure that all source are synced.
* Interally, the image is stored in PNG format when possible.
* It can happen that the image path do not return a PNG file.
*
* You can only use an TQImage and a image path to create/update
* the picture.
* If the picture doesn't exist as a file, it generate a local
* copy into ~/.trinity/share/apps/kopete/metacontactpicturecache
*
* This class is implicitly shared, so don't use it as a pointer.
*
* How to use this class:
* @code
* Kopete::Picture picture;
* picture.setPicture(TQImage());
* picture.setPicture(TQString("/tmp/image.png"));
*
* TQString base64 = picture.base64();
* TQString path = picture.path();
* TQImage image = picture.image();
* @endcode
*
* @author Michaël Larouche <michael.larouche@kdemail.net>
*/
class KOPETE_EXPORT Picture
{
public:
/**
* Create a empty Kopete::Picture
*/
Picture();
/**
* Create a picture from a local path.
*/
Picture(const TQString &path);
/**
* Create a picture from a TQImage.
*/
Picture(const TQImage &image);
/**
* Create a picture from a TDEABC::Picture.
*/
Picture(const TDEABC::Picture &picture);
/**
* Copy a picture. It doesn't create a full copy, it just make a reference.
*/
Picture(const Picture &other);
/**
* Delete the Kopete::Picture
*/
~Picture();
/**
* Assignment operator.
* Like the copy constructor, it just make a reference.
*/
Picture &operator=(const Picture &other);
/**
* Return the current picture as TQImage.
* TQImage can used to draw the image on a context.
*
* @return the TQImage cache of current picture.
*/
TQImage image();
/**
* Return the current picture as a base64 string.
* The base64 is used to include the picture into a XML/XHTML context.
*/
TQString base64();
/**
* Return the local path of the current picture.
*/
TQString path();
/**
* Check if the picture is null.
*/
bool isNull();
/**
* Reset the picture.
*/
void clear();
/**
* Set the picture content.
* @param image the picture as a TQImage.
*/
void setPicture(const TQImage &image);
/**
* Set the picture content.
* @param path the path to the picture.
*/
void setPicture(const TQString &path);
/**
* Set the picture content.
* @param picture a KABC Picture.
*/
void setPicture(const TDEABC::Picture &picture);
private:
/**
* Kopete::Picture is implicitly shared.
* Detach the instance when modifying data.
*/
void detach();
class Private;
TDESharedPtr<Private> d;
};
}//END namespace Kopete
#endif