Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
geometrize::dialog::TemplateGrid::TemplateGridImpl Class Reference
Collaboration diagram for geometrize::dialog::TemplateGrid::TemplateGridImpl:
Collaboration graph
[legend]

Public Member Functions

 TemplateGridImpl (TemplateGrid *pQ)
 
void loadTemplates ()
 
void setItemFilter (const QString &filter)
 
TemplateGridImpl operator= (const TemplateGridImpl &)=delete
 
 TemplateGridImpl (const TemplateGridImpl &)=delete
 
 ~TemplateGridImpl ()=default
 
void onLanguageChange ()
 

Private Member Functions

void populateUi ()
 
void addTemplateItem (const QString &templateFolder)
 

Private Attributes

TemplateGridq
 
layout::FlowLayoutm_layout
 
std::unique_ptr
< chaiscript::ChaiScript > 
m_templateLoader
 
std::vector< TemplateButton * > m_buttons
 

Constructor & Destructor Documentation

geometrize::dialog::TemplateGrid::TemplateGridImpl::TemplateGridImpl ( TemplateGrid pQ)
inline
26  : q{pQ}, m_layout{new layout::FlowLayout(24, 24, 24)}, m_templateLoader{geometrize::script::createDefaultEngine()}
27  {
28  q->setLayout(m_layout);
29  populateUi();
30  }
std::unique_ptr< chaiscript::ChaiScript > createDefaultEngine()
createDefaultEngine Creates a default Chaiscript engine object, with the default bindings (Geometrize...
Definition: chaiscriptcreator.cpp:26
TemplateGrid * q
Definition: templategrid.cpp:104
void populateUi()
Definition: templategrid.cpp:93
layout::FlowLayout * m_layout
Definition: templategrid.cpp:105
std::unique_ptr< chaiscript::ChaiScript > m_templateLoader
Definition: templategrid.cpp:106

Here is the caller graph for this function:

geometrize::dialog::TemplateGrid::TemplateGridImpl::TemplateGridImpl ( const TemplateGridImpl )
delete
geometrize::dialog::TemplateGrid::TemplateGridImpl::~TemplateGridImpl ( )
default

Here is the caller graph for this function:

Member Function Documentation

void geometrize::dialog::TemplateGrid::TemplateGridImpl::addTemplateItem ( const QString &  templateFolder)
inlineprivate
98  {
99  TemplateButton* item{new TemplateButton(m_templateLoader.get(), templateFolder)};
100  m_layout->addWidget(item);
101  m_buttons.push_back(item);
102  }
std::vector< TemplateButton * > m_buttons
Definition: templategrid.cpp:107
layout::FlowLayout * m_layout
Definition: templategrid.cpp:105
std::unique_ptr< chaiscript::ChaiScript > m_templateLoader
Definition: templategrid.cpp:106

Here is the caller graph for this function:

void geometrize::dialog::TemplateGrid::TemplateGridImpl::loadTemplates ( )
inline
33  {
34  // Build the list of templates to load
35  std::vector<std::string> templateFolders;
36 
37  const std::vector<std::string> paths{geometrize::searchpaths::getTemplateSearchPaths()};
38  for(const std::string& path : paths) {
39  const std::vector<std::string> folders{util::getSubdirectoriesForDirectory(path)};
40  templateFolders.insert(templateFolders.end(), folders.begin(), folders.end());
41  }
42 
43  // Put the folders in a sensible order so it doesn't vary based on filesystem implementation/state
44  std::sort(templateFolders.begin(), templateFolders.end());
45 
46  // Add a template item every few ms
47  for(std::size_t i = 0; i < templateFolders.size(); i++) {
48  std::string folder = templateFolders[i];
49  QTimer::singleShot(16 * i, Qt::PreciseTimer, q, [this, folder]() {
50  addTemplateItem(QString::fromStdString(folder));
51  });
52  }
53  }
void addTemplateItem(const QString &templateFolder)
Definition: templategrid.cpp:97
TemplateGrid * q
Definition: templategrid.cpp:104
std::vector< std::string > getTemplateSearchPaths()
getTemplateSearchpaths Gets the directory paths that the program will search for project file templat...
Definition: searchpaths.cpp:26
std::vector< std::string > getSubdirectoriesForDirectory(const std::string &dirPath)
getSubdirectoriesForDirectory Gets the absolute paths for direct subdirectories of the given director...
Definition: util.cpp:137

Here is the call graph for this function:

void geometrize::dialog::TemplateGrid::TemplateGridImpl::onLanguageChange ( )
inline
88  {
89  populateUi();
90  }
void populateUi()
Definition: templategrid.cpp:93

Here is the call graph for this function:

TemplateGridImpl geometrize::dialog::TemplateGrid::TemplateGridImpl::operator= ( const TemplateGridImpl )
delete

Here is the caller graph for this function:

void geometrize::dialog::TemplateGrid::TemplateGridImpl::populateUi ( )
inlineprivate
94  {
95  }

Here is the caller graph for this function:

void geometrize::dialog::TemplateGrid::TemplateGridImpl::setItemFilter ( const QString &  filter)
inline
56  {
57  if(filter.isEmpty()) {
58  for(TemplateButton* const button : m_buttons) {
59  button->show();
60  }
61  return;
62  }
63 
64  for(TemplateButton* const button : m_buttons) {
65  const QString name{QString::fromStdString(button->getTemplateManifest().getName())};
66  const std::vector<std::string> tags{button->getTemplateManifest().getTags()};
67 
68  if(name.contains(filter, Qt::CaseInsensitive)) {
69  button->show();
70  } else {
71  button->hide();
72  }
73 
74  for(const std::string& tag : tags) {
75  const QString qTag{QString::fromStdString(tag)};
76  if(qTag.contains(filter, Qt::CaseInsensitive)) {
77  button->show();
78  }
79  }
80  }
81  }
std::vector< TemplateButton * > m_buttons
Definition: templategrid.cpp:107

Here is the call graph for this function:

Member Data Documentation

std::vector<TemplateButton*> geometrize::dialog::TemplateGrid::TemplateGridImpl::m_buttons
private
layout::FlowLayout* geometrize::dialog::TemplateGrid::TemplateGridImpl::m_layout
private
std::unique_ptr<chaiscript::ChaiScript> geometrize::dialog::TemplateGrid::TemplateGridImpl::m_templateLoader
private
TemplateGrid* geometrize::dialog::TemplateGrid::TemplateGridImpl::q
private

The documentation for this class was generated from the following file: