22#include <tqdatetime.h>
23#include <tqfileinfo.h>
28#include "KoPictureKey.h"
30static void resetDateTimeToEpoch(TQDateTime& dt)
33 dt.setDate(TQDate(1970,1,1));
34 dt.setTime(TQTime(0,0));
40 resetDateTimeToEpoch(m_lastModified);
44 : m_filename( fn ), m_lastModified( mod )
46 if (!m_lastModified.isValid())
49 resetDateTimeToEpoch(m_lastModified);
56 resetDateTimeToEpoch(m_lastModified);
60 : m_filename( key.m_filename ), m_lastModified( key.m_lastModified )
66 m_filename = key.m_filename;
67 m_lastModified = key.m_lastModified;
73 return ( key.m_filename == m_filename &&
74 key.m_lastModified == m_lastModified );
84 TQDate date = m_lastModified.date();
85 TQTime time = m_lastModified.time();
86 elem.setAttribute( "filename", m_filename );
87 elem.setAttribute( "year", date.year() );
88 elem.setAttribute( "month", date.month() );
89 elem.setAttribute( "day", date.day() );
90 elem.setAttribute( "hour", time.hour() );
91 elem.setAttribute( "minute", time.minute() );
92 elem.setAttribute( "second", time.second() );
93 elem.setAttribute( "msec", time.msec() );
99 int year=1970, month=1, day=1;
100 int hour=0, minute=0, second=0, msec=0;
102 if( elem.hasAttribute( "key" ) )
105 m_filename=elem.attribute( "key" );
110 m_filename=elem.attribute( "filename" );
113 if( elem.hasAttribute( "year" ) )
114 year=elem.attribute( "year" ).toInt();
115 if( elem.hasAttribute( "month" ) )
116 month=elem.attribute( "month" ).toInt();
117 if( elem.hasAttribute( "day" ) )
118 day=elem.attribute( "day" ).toInt();
119 if( elem.hasAttribute( "hour" ) )
120 hour=elem.attribute( "hour" ).toInt();
121 if( elem.hasAttribute( "minute" ) )
122 minute=elem.attribute( "minute" ).toInt();
123 if( elem.hasAttribute( "second" ) )
124 second=elem.attribute( "second" ).toInt();
125 if( elem.hasAttribute( "msec" ) )
126 msec=elem.attribute( "msec" ).toInt();
128 m_lastModified.setDate( TQDate( year, month, day ) );
129 m_lastModified.setTime( TQTime( hour, minute, second, msec ) );
131 if (!m_lastModified.isValid())
134 kdWarning(30003) << "Correcting invalid date/time: " << toString() << " (in KoPictureKey::loadAttributes)" << endl;
135 resetDateTimeToEpoch(m_lastModified);
142 return TQString::fromLatin1( "%1 %2" )
143 .arg( m_filename, m_lastModified.toString( "yyyy-MM-dd hh:mm:ss.zzz") );
150 m_lastModified = inf.lastModified();
KoPictureKey is the structure describing a picture in a unique way.
bool operator==(const KoPictureKey &key) const Comparison operator.
KoPictureKey() Default constructor.
TQString toString() const Convert this key into a string representation of it.
void saveAttributes(TQDomElement &elem) const Save this key in XML (as KOffice 1.3)
void loadAttributes(const TQDomElement &elem) Load this key from XML (as KOffice 1.3)
bool operator<(const KoPictureKey &key) const Comparison operator.
TQString filename() const First part of the key: the filename.
KoPictureKey & operator=(const KoPictureKey &key) Assignment operator.
void setKeyFromFile(const TQString &filename) Sets the key according to filename, including modification time.
|