Source Code (Use browser search to find items of interest.)
Class Index
kpresenter'KPPixmapDataCollection (./koffice/kpresenter/kppixmapcollection.h:38)
class KPPixmapDataCollection
{
public:
struct Key
{
Key()
: filename(), lastModified()
{}
Key( const QString &fn, const QDateTime &mod )
: filename( fn ), lastModified( mod )
{}
Key( const Key &key )
: filename( key.filename ), lastModified( key.lastModified )
{}
Key &operator=( const Key &key ) {
filename = key.filename;
lastModified = key.lastModified;
return *this;
}
bool operator==( const Key &key ) const {
return ( key.filename == filename &&
key.lastModified == lastModified );
}
bool operator<( const Key &key ) const {
QString s1( key.toString() );
QString s2( toString() );
return ( s1 < s2 );
}
QString toString() const {
QString s = QString( "%1_%2" ).arg( filename ).arg( lastModified.toString() );
return QString( s );
}
QString filename;
QDateTime lastModified;
};
KPPixmapDataCollection()
: allowChangeRef( TRUE )
{}
~KPPixmapDataCollection();
QImage *findPixmapData( const Key &key );
QImage *insertPixmapData( const Key &key, const QImage &img );
void setPixmapOldVersion( const Key &key, const char *_data );
void setPixmapOldVersion( const Key &key );
void addRef( const Key &key );
void removeRef( const Key &key );
QMap< Key, QImage >::Iterator begin() { return data.begin(); }
QMap< Key, QImage >::Iterator end() { return data.end(); }
int references( const Key &key ) { return refs.contains( key ) ? refs.find( key ).data() : -1; }
void setAllowChangeRef( bool b )
{ allowChangeRef = b ; }
protected:
QMap< Key, QImage > data;
QMap< Key, int > refs;
bool allowChangeRef;
};
/******************************************************************/
/* Class: KPPixmapCollection */
/******************************************************************/
kpresenter'KPPixmapDataCollection::~KPPixmapDataCollection() (./koffice/kpresenter/kppixmapcollection.cc:32)
KPPixmapDataCollection::~KPPixmapDataCollection()
{
data.clear();
refs.clear();
}
/*================================================================*/
kpresenter'KPPixmapDataCollection::findPixmapData() (./koffice/kpresenter/kppixmapcollection.cc:39)
QImage *KPPixmapDataCollection::findPixmapData( const Key &key )
{
//printf(" KPPixmapDataCollection::findPixmapData( key = %s )\n", key.toString().latin1() );
//printf(" data.count = %d\n", data.count() );
QMap< Key, QImage >::Iterator it = data.find ( key );
if ( it != data.end() && it.key() == key ) {
//printf( " fond pixmap data %s\n", it.key().toString().latin1() );
return &it.data();
} else {
//printf( " did NOT find pixmap data\n" );
return 0L;
}
}
/*================================================================*/
kpresenter'KPPixmapDataCollection::insertPixmapData() (./koffice/kpresenter/kppixmapcollection.cc:56)
QImage *KPPixmapDataCollection::insertPixmapData( const Key &key, const QImage &img )
{
//printf(" KPPixmapDataCollection::insertPixmapData( key = %s, img = %d )\n", key.toString().latin1(), !img.isNull() );
QImage *tmp = findPixmapData( key );
if ( tmp )
return tmp;
QImage *image = new QImage( img );
image->detach();
data.insert( Key( key ), *image );
int ref = 1;
refs.insert( Key( key ), ref );
return image;
return &data[ key ];
}
/*================================================================*/
kpresenter'KPPixmapDataCollection::setPixmapOldVersion() (./koffice/kpresenter/kppixmapcollection.cc:76)
void KPPixmapDataCollection::setPixmapOldVersion( const Key &key, const char *_data )
{
if ( data.contains( key ) )
return;
QCString s( _data );
int i = s.find( ( char )1, 0 );
while ( i != -1 ) {
s[ i ] = '\"';
i = s.find( ( char )1, i + 1 );
}
QImage img;
img.loadFromData( s, "XPM" );
insertPixmapData( key, img );
}
/*================================================================*/
kpresenter'KPPixmapDataCollection::setPixmapOldVersion() (./koffice/kpresenter/kppixmapcollection.cc:95)
void KPPixmapDataCollection::setPixmapOldVersion( const Key &key )
{
if ( data.contains( key ) )
return;
QImage img( key.filename );
insertPixmapData( key, img );
}
/*================================================================*/
kpresenter'KPPixmapDataCollection::addRef() (./koffice/kpresenter/kppixmapcollection.cc:105)
void KPPixmapDataCollection::addRef( const Key &key )
{
if ( !allowChangeRef )
return;
// printf( " KPPixmapDataCollection::addRef( key = %s )\n", key.toString().latin1() );
if ( refs.contains( key ) ) {
int ref = refs[ key ];
refs[ key ] = ++ref;
// printf( " ref: %d\n", refs[ key ] );
}
}
/*================================================================*/
kpresenter'KPPixmapDataCollection::removeRef() (./koffice/kpresenter/kppixmapcollection.cc:120)
void KPPixmapDataCollection::removeRef( const Key &key )
{
if ( !allowChangeRef )
return;
// printf( " KPPixmapDataCollection::removeRef( key = %s )\n", key.toString().latin1() );
if ( refs.contains( key ) ) {
int ref = refs[ key ];
refs[ key ] = --ref;
// printf( " ref: %d\n", refs[ key ] );
if ( ref == 0 ) {
refs.remove( key );
data.remove( key );
// printf( " remove %s\n", key.toString().latin1() );
}
}
}
/******************************************************************/
/* Class: KPPixmapCollection */
/******************************************************************/
/*================================================================*/