ResourceItem: added property "author"

Added new property "author" for retaining authorship information of
files. Furthermore this allows filtering for authors in ResourceBrowser.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Tobias Doerffel
2009-06-19 09:42:03 +02:00
parent 9ca93040de
commit 4bc010cea9
6 changed files with 24 additions and 1 deletions

View File

@@ -70,6 +70,7 @@ public:
BaseDirectory _base_dir = BaseWorkingDir,
const QString & _path = QString::null,
const QString & _hash = QString::null,
const QString & _author = QString::null,
const QString & _tags = QString::null,
int _size = -1,
const QDateTime & _last_mod = QDateTime() );
@@ -125,6 +126,11 @@ public:
return m_hash;
}
const QString & author( void ) const
{
return m_author;
}
int size( void ) const
{
return m_size;
@@ -208,6 +214,7 @@ private:
BaseDirectory m_baseDir;
QString m_path;
QString m_hash;
QString m_author;
int m_size;
QDateTime m_lastMod;
QString m_tags;

View File

@@ -245,7 +245,11 @@ printf("read dir: %s\n", d.canonicalPath().toAscii().constData() );
new ResourceItem( this,
f.fileName(),
ResourceItem::TypeUnknown,
m_baseDir, _dir );
m_baseDir,
_dir,
QString::null, // hash
QString::null // TODO: author
);
newItem->setLastMod( f.lastModified() );
database()->addItem( newItem );
ResourceTreeItem * rti =

View File

@@ -139,6 +139,7 @@ void ResourceDB::saveTreeItem( const ResourceTreeItem * _i,
e.setAttribute( "basedir", baseDirName( it->baseDir() ) );
e.setAttribute( "path", it->path() );
e.setAttribute( "hash", it->hash() );
e.setAttribute( "author", it->author() );
e.setAttribute( "size", it->size() );
e.setAttribute( "tags", it->tags() );
e.setAttribute( "lastmod", it->lastMod().
@@ -167,6 +168,7 @@ ResourceItem * item = new ResourceItem( m_provider,
baseDirFromName( e.attribute( "basedir" ) ),
e.attribute( "path" ),
h,
e.attribute( "author" ),
e.attribute( "tags" ),
e.attribute( "size" ).toInt(),
QDateTime::fromString( e.attribute( "lastmod" ), Qt::ISODate ) );

View File

@@ -39,6 +39,7 @@ ResourceItem::ResourceItem( ResourceProvider * _provider,
BaseDirectory _base_dir,
const QString & _path,
const QString & _hash,
const QString & _author,
const QString & _tags,
int _size,
const QDateTime & _last_mod ) :
@@ -49,6 +50,7 @@ ResourceItem::ResourceItem( ResourceProvider * _provider,
m_baseDir( _base_dir ),
m_path( _path ),
m_hash( _hash ),
m_author( _author ),
m_size( _size ),
m_lastMod( _last_mod ),
m_tags( _tags ),
@@ -77,6 +79,7 @@ bool ResourceItem::operator==( const ResourceItem & _other ) const
m_type == _other.m_type &&
m_path == _other.m_path &&
m_hash == _other.m_hash &&
m_author == _other.m_author &&
m_size == _other.m_size &&
m_tags == _other.m_tags;
}
@@ -107,6 +110,11 @@ int ResourceItem::equalityLevel( const ResourceItem & _other ) const
l += 5;
}
if( m_author == _other.m_author )
{
l += 5;
}
if( !m_tags.isEmpty() && !_other.m_tags.isEmpty() )
{
QStringList my_tags = m_tags.split( " " );

View File

@@ -245,6 +245,7 @@ bool ResourceTreeModel::filterItems( ResourceTreeItem * _item,
{
if( !( i->name().toLower().contains( *it ) ||
i->path().toLower().contains( *it ) ||
i->author().toLower().contains( *it ) ||
i->tags().toLower().contains( *it ) ) )
{
accept = false;

View File

@@ -179,6 +179,7 @@ void WebResourceProvider::importNodeIntoDB( const QDomNode & _n,
ResourceItem::BaseURL,
path,
n.firstChildElement( "hash" ).text(),
n.firstChildElement( "author" ).text(),
n.firstChildElement( "tags" ).text(),
n.firstChildElement( "size" ).text().toInt() );
database()->addItem( item );