AssetTemplatesDialog::AssetTemplatesDialog( QWidget * parent )
: QDialog( parent )
{
	setupUi( this );
	
	ProjectList pl = Project::select().filter( "fkeyProjectStatus", 4 ).sorted( "name" );
	Project none;
	none.setName( "None (Global Templates)" );
	pl.insert( pl.begin(), none );
	mProjectCombo->setColumn( "name" );
	mProjectCombo->setItems( pl );
	
	AssetTypeList atl = AssetType::select().filter( "disabled", 0 ).sorted( "timesheetcategory" );
	mTypeCombo->setColumn( "name" );
	mTypeCombo->setItems( atl );
	
	connect( mProjectCombo,  SIGNAL( currentChanged( const Record & ) ), SLOT( projectChanged( const Record & ) ) );
	connect( mTypeCombo,  SIGNAL( currentChanged( const Record & ) ), SLOT( assetTypeChanged( const Record & ) ) );
	
	connect( mAddButton, SIGNAL( clicked() ),  SLOT( addTemplate() ) );
	connect( mEditButton, SIGNAL( clicked() ), SLOT( editTemplate() ) );
	connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeTemplate() ) );
	
	connect( mTemplateList, SIGNAL( currentChanged( const Record & ) ), SLOT( slotCurrentChanged( const Record & ) ) );

	RecordListModel * model = new RecordListModel( this );
	model->setColumn( "name" );
	mTemplateList->setModel( model );

	assetTypeChanged( mTypeCombo->current() );
}
Exemplo n.º 2
0
void ProjectCombo::doRefresh()
{
	mRefreshRequested = false;

	Project cur = mCurrent;
	clear();
	mCurrent = Project();

	// Filter out templates, all real projects point to themselves
	ProjectList ptl = Project::select("fkeyproject=keyelement");
	if( !mStatusFilters.isEmpty() ) {
		ProjectList tmp;
		foreach( ProjectStatus ps, mStatusFilters )
			tmp += ptl.filter( "fkeyprojectstatus", ps.key() );
		ptl = tmp.unique();
	}

	ptl = ptl.sorted( "name" );

	if( mShowSpecialItem ) {
		Project p;
		p.setName( mSpecialItemText );
		ptl.insert( ptl.begin(), p );
	}

	mModel->setRecordList( ptl );

	if( ptl.contains( cur ) ) {
		setCurrentIndex( ptl.findIndex( cur ) );
		mCurrent = cur;
	} else if( !ptl.isEmpty() ) {
		setCurrentIndex( 0 );
		mCurrent = ptl[0];
	}
}