#include "Label.h"
#include "P4Client.h"
namespace Perforce {
Label::LabelCache Label::_labelCache;
const LabelList& Label::getLabels()
{
_labelCache.updateCacheIfNecessary();
return _labelCache.getCache();
}
void Label::LabelCache::HandleError( Error* err )
{
ASSERT( 0 && "Failed to update label cache" );
}
void Label::LabelCache::OutputStat( StrDict* varList )
{
ASSERT( varList != NULL );
Label* l = new Label();
QString temp = varList->GetVar( "Access" )->Text();
l->_date.setTime_t( temp.toInt() );
l->_description = varList->GetVar( "Description" )->Text();
replaceNewlinesWithSpaces( l->_description );
l->_name = varList->GetVar( "label" )->Text();
l->_owner = varList->GetVar( "Owner" )->Text();
temp = varList->GetVar( "Options" )->Text();
if (temp.find("unlocked") != -1) {
l->_status = "Unlocked";
} else {
l->_status = "Locked";
}
_cache.append( l );
}
void Label::LabelCache::updateCache()
{
char* p[] = { "" };
RunP4Command( 0, p, "labels", this );
}
} // end namespace