26 #include <QFileDialog> 27 #include <QMessageBox> 28 #include <QRegularExpression> 48 QAction::setText(tr(
"Import Map Templates..."));
49 QUndoCommand::setText(tr(
"Import Map Templates..."));
94 QString itemType = item->text();
97 return (itemType ==
"Maps");
116 templateFileNames = QFileDialog::getOpenFileNames(
117 qobject_cast<QWidget *>(parent()),
118 "Import Map Templates",
120 "Maps (*.map);; All Files (*)");
122 if (!templateFileNames.isEmpty()) {
123 QUndoCommand::setText(tr(
"Import %1 Template(s)").arg(templateFileNames.count()));
147 "maps/" + templateFolder.dirName() );
149 foreach (
FileName filename, templateFileNames) {
150 QFile::copy(filename.
expanded(), templateFolder.path() +
"/" + filename.
name());
151 m_list->append(
new Template(templateFolder.path() +
"/" + filename.
name(),
153 templateFolder.dirName()));
156 if (!m_list->isEmpty()) {
171 if (m_list &&
project()->templates().size() > 0) {
177 foreach (
Template *currentTemplate, *m_list) {
178 delete currentTemplate;
The main project for ipce.
File name manipulation and expansion.
ImportMapTemplateWorkOrder(Project *project)
Creates a work order to import map templates.
virtual bool setupExecution()
This sets up the state for the work order.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
void execute()
Imports the templates.
virtual bool isExecutable(ProjectItem *item)
This method returns true if the user clicked on a project tree node with the text "Maps"...
void addTemplates(TemplateList *templateFiles)
Add new templates to m_mapTemplates or m_regTemplates and update project item model.
ProjectItem * findItemData(const QVariant &data, int role=Qt::UserRole+1)
Returns the first item found that contains the given data in the given role or a null pointer if no i...
void deleteFromDisk(Project *project)
Delete all of the contained Templates from disk.
Directory * directory() const
Returns the directory associated with this Project.
ProjectItemModel * model()
Gets the ProjectItemModel for this directory.
Provide Undo/redo abilities, serialization, and history for an operation.
Add map templates to a project.
virtual void removeItem(ProjectItem *item)
Removes an item and its children from the model.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
~ImportMapTemplateWorkOrder()
Destructor.
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
void undoExecution()
Deletes the previously imported templates.
virtual ImportMapTemplateWorkOrder * clone() const
This method clones the current ImportMapTemplateWorkOrder and returns it.
void setModifiesDiskState(bool changesProjectOnDisk)
bool setupExecution()
Sets up the work order for execution.
Represents an item of a ProjectItemModel in Qt's model-view framework.
Namespace for ISIS/Bullet specific routines.
Project * project() const
Returns the Project this WorkOrder is attached to.
QDir addTemplateFolder(QString prefix)
Create and navigate to the appropriate template type folder in the project directory.
QStringList internalData() const
Gets the internal data for this WorkOrder.
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
void setClean(bool value)
Function to change the clean state of the project.