Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions itemframework/src/project/abstract_workspace_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class AbstractWorkspaceGui : public QObject
Q_OBJECT
public:
virtual ~AbstractWorkspaceGui();
virtual QDialog* dialogNewWorkspace(QDialog* parent = 0) const = 0;
virtual QDialog* dialogLoadWorkspace(QDialog* parent = 0) const = 0;
virtual QDialog* dialogNewWorkspace(QDialog* parent = 0) = 0;
virtual QDialog* dialogLoadWorkspace(QDialog* parent = 0) = 0;
virtual QDialog* dialogEditWorkspace(QDialog* parent = 0, QSharedPointer<AbstractWorkspace> workspace = QSharedPointer<AbstractWorkspace>()) const = 0;
virtual QString workspaceTypeName() const = 0;
virtual void addListWidgetItem(QListWidget* parentListWidget) = 0;
Expand Down
16 changes: 16 additions & 0 deletions itemframework/src/project/file_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ bool FileHelper::directoryExists(const QString &directoryPath)
return directory.isDir();
}

bool FileHelper::createDirectory(const QString &directoryPath){
QDir directory(directoryPath);

if(directory.exists()){
return true;
}

if(!QDir().mkpath(directoryPath)){
_lastError = QString("Make workspace path \"%1\" failed.").arg(directoryPath);
return false;
}

_lastError.clear();
return true;
}

bool FileHelper::removeFile(const QString& filePath)
{
QFile file(filePath);
Expand Down
9 changes: 9 additions & 0 deletions itemframework/src/project/file_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ class FileHelper
*/
static bool directoryExists(const QString& directoryPath);

/**
* @return Returns \c true if the directory was created, otherwise returns \c false.
*
* @param directoryPath The directoryPath as string.
*
* \sa directoryExists
*/
static bool createDirectory(const QString &directoryPath);

/**
* @return Returns \c true if the file was removed or does not exists, otherwise returns \c false.
*
Expand Down
4 changes: 0 additions & 4 deletions itemframework/src/project/file_project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ bool FileProject::save()
setExternChanged(false);
setDirty(false);

if (FileHelper::fileExists(_autosaveFilePath)) {
autosave();
}

return true;
}

Expand Down
19 changes: 10 additions & 9 deletions itemframework/src/project/file_workspace_edit_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ FileWorkspaceEditDialog::FileWorkspaceEditDialog(QString lastUsedPath, QDialog*
_workspacePropertiesEdited = new FileWorkspaceData;
_actionFileExists = new QAction(QIcon(":/core/projectmanager/workspace_not_valid.png"), "", this);
_actionFileExists->setToolTip(QLatin1String("File already exists."));
_lastUsedPath = lastUsedPath;

if (lastUsedPath.isEmpty()) {
_lastUsedPath = QString(HomeFolderUser);
} else {
_lastUsedPath = lastUsedPath;
}

_ui->selectedWorkspaceFile->setToolTip(QString("e.g workspaceFile.%1").arg(WspFileExt));
_ui->selectedWorkspaceFile->setToolTip(QString("workspaceFile.%1").arg(WspFileExt));
connect(_ui->selectedWorkspaceName, &QLineEdit::textChanged, this, &FileWorkspaceEditDialog::onWorkspaceNameChanged);
connect(_ui->selectedWorkspaceFile, &QLineEdit::textChanged, this, &FileWorkspaceEditDialog::onWorkspaceFileChanged);
connect(_ui->selectedWorkspaceDirectory, &QLineEdit::textChanged, this, &FileWorkspaceEditDialog::onWorkspaceDirectoryChanged);
connect(_ui->selectedWorkspaceDescription, &QTextEdit::textChanged, this, &FileWorkspaceEditDialog::onWorkspaceDescriptionChanged);
}

Expand Down Expand Up @@ -171,7 +167,7 @@ void FileWorkspaceEditDialog::accept()
{
_workspacePropertiesEdited->name = _ui->selectedWorkspaceName->text();
_workspacePropertiesEdited->fileName = _ui->selectedWorkspaceFile->text();
_workspacePropertiesEdited->directory = _ui->selectedWorkspaceDirectory->text();
_workspacePropertiesEdited->directory = QDir::cleanPath(_ui->selectedWorkspaceDirectory->text());
_workspacePropertiesEdited->filePath = QString(_workspacePropertiesEdited->directory + Slash + _workspacePropertiesEdited->fileName);
_workspacePropertiesEdited->description = _ui->selectedWorkspaceDescription->toPlainText();

Expand Down Expand Up @@ -267,7 +263,7 @@ void FileWorkspaceEditDialog::showFileDialog()
_lastUsedPath = dir;
}

overrideValidation();
onWorkspaceDirectoryChanged();
}

void FileWorkspaceEditDialog::onWorkspaceNameChanged(QString name)
Expand Down Expand Up @@ -319,3 +315,8 @@ void FileWorkspaceEditDialog::onWorkspaceIsDefaultChanged()
{
overrideValidation();
}

void FileWorkspaceEditDialog::onWorkspaceDirectoryChanged()
{
overrideValidation();
}
1 change: 1 addition & 0 deletions itemframework/src/project/file_workspace_edit_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private slots:
void onWorkspaceFileChanged(QString file);
void onWorkspaceDescriptionChanged();
void onWorkspaceIsDefaultChanged();
void onWorkspaceDirectoryChanged();
};

#endif // FILE_WORKSPACE_EDIT_DIALOG_H
4 changes: 2 additions & 2 deletions itemframework/src/project/file_workspace_edit_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<bool>true</bool>
</property>
<property name="placeholderText">
<string>e.g. workspace.twsp</string>
<string>workspace.twsp</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -120,7 +120,7 @@
<item>
<widget class="QLineEdit" name="selectedWorkspaceDirectory">
<property name="readOnly">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
Expand Down
Loading