mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-03-30 05:26:55 +00:00
Resolve some variables from the project.
This commit is contained in:
parent
413fe65bd8
commit
89706aedae
@ -154,11 +154,6 @@ wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
|
||||
*token = fn.GetFullPath();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "PROJECTNAME" ) ) && m_project )
|
||||
{
|
||||
*token = m_project->GetProjectName();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "PAPER" ) ) )
|
||||
{
|
||||
*token = m_paperFormat;
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <title_block.h>
|
||||
|
||||
PROJECT::PROJECT() :
|
||||
m_readOnly( false ),
|
||||
@ -71,7 +72,17 @@ PROJECT::~PROJECT()
|
||||
|
||||
bool PROJECT::TextVarResolver( wxString* aToken ) const
|
||||
{
|
||||
if( GetTextVars().count( *aToken ) > 0 )
|
||||
if( aToken->IsSameAs( wxT( "PROJECTNAME" ) ) )
|
||||
{
|
||||
*aToken = GetProjectName();
|
||||
return true;
|
||||
}
|
||||
else if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
|
||||
{
|
||||
*aToken = TITLE_BLOCK::GetCurrentDate();
|
||||
return true;
|
||||
}
|
||||
else if( GetTextVars().count( *aToken ) > 0 )
|
||||
{
|
||||
*aToken = GetTextVars().at( *aToken );
|
||||
return true;
|
||||
|
@ -92,23 +92,23 @@ void TITLE_BLOCK::GetContextualTextVars( wxArrayString* aVars )
|
||||
}
|
||||
|
||||
|
||||
wxString TITLE_BLOCK::GetCurrentDate()
|
||||
{
|
||||
// We can choose different formats. Should probably be kept in sync with ISSUE_DATE
|
||||
// formatting in DIALOG_PAGES_SETTINGS.
|
||||
//
|
||||
// return wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
|
||||
// return wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
|
||||
// return wxDateTime::Now().Format( wxT("%Y-%b-%d") );
|
||||
return wxDateTime::Now().FormatISODate();
|
||||
};
|
||||
|
||||
|
||||
bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject, int aFlags ) const
|
||||
{
|
||||
bool tokenUpdated = false;
|
||||
wxString originalToken = *aToken;
|
||||
|
||||
auto getCurrentDate =
|
||||
[]() -> wxString
|
||||
{
|
||||
// We can choose different formats. Should probably be kept in sync with ISSUE_DATE
|
||||
// formatting in DIALOG_PAGES_SETTINGS.
|
||||
//
|
||||
// return wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
|
||||
// return wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
|
||||
// return wxDateTime::Now().Format( wxT("%Y-%b-%d") );
|
||||
return wxDateTime::Now().FormatISODate();
|
||||
};
|
||||
|
||||
if( aToken->IsSameAs( wxT( "ISSUE_DATE" ) ) )
|
||||
{
|
||||
*aToken = GetDate();
|
||||
@ -116,7 +116,7 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject, in
|
||||
}
|
||||
else if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
|
||||
{
|
||||
*aToken = getCurrentDate();
|
||||
*aToken = GetCurrentDate();
|
||||
tokenUpdated = true;
|
||||
}
|
||||
else if( aToken->IsSameAs( wxT( "REVISION" ) ) )
|
||||
@ -157,7 +157,7 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject, in
|
||||
if( tokenUpdated )
|
||||
{
|
||||
if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
|
||||
*aToken = getCurrentDate();
|
||||
*aToken = GetCurrentDate();
|
||||
else if( aProject )
|
||||
*aToken = ExpandTextVars( *aToken, aProject, aFlags );
|
||||
|
||||
|
@ -126,6 +126,8 @@ public:
|
||||
*/
|
||||
virtual void Format( OUTPUTFORMATTER* aFormatter ) const;
|
||||
|
||||
static wxString GetCurrentDate();
|
||||
|
||||
private:
|
||||
wxArrayString m_tbTexts;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user