- enhancement: when add files to project, auto add it to git (if the project has a git repository)

This commit is contained in:
royqh1979@gmail.com 2022-02-16 16:27:09 +08:00
parent a2289463f9
commit 79edb0829a
8 changed files with 345 additions and 279 deletions

View File

@ -13,6 +13,8 @@ Red Panda C++ Version 0.14.3
- enhancement: git - commit - enhancement: git - commit
- enhancement: git - restore - enhancement: git - restore
- fix: compiler set index not correctly saved, when remove compiler sets in options dialog - fix: compiler set index not correctly saved, when remove compiler sets in options dialog
- enhancement: when add files to project, auto add it to git (if the project has a git repository)
Red Panda C++ Version 0.14.2 Red Panda C++ Version 0.14.2
- enhancement: file system view mode for project - enhancement: file system view mode for project

File diff suppressed because it is too large Load Diff

View File

@ -748,12 +748,20 @@ void MainWindow::updateDPI()
void MainWindow::onFileSaved(const QString &path, bool inProject) void MainWindow::onFileSaved(const QString &path, bool inProject)
{ {
if (pSettings->vcs().gitOk()) { if (pSettings->vcs().gitOk()) {
if (inProject && mProject) { QString branch;
if (inProject && mProject && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
mProject->model()->beginUpdate(); mProject->model()->beginUpdate();
mProject->model()->endUpdate(); mProject->model()->endUpdate();
} }
QModelIndex index = mFileSystemModel.index(path); QModelIndex index = mFileSystemModel.index(path);
if (index.isValid()) { if (index.isValid()) {
if (!inProject) {
if ( (isCFile(path) || isHFile(path))
&& !mFileSystemModelIconProvider.VCSRepository()->isFileInRepository(path)) {
mFileSystemModelIconProvider.VCSRepository()->add(extractRelativePath(mFileSystemModelIconProvider.VCSRepository()->folder(),path));
}
}
mFileSystemModelIconProvider.update(); mFileSystemModelIconProvider.update();
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider); mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
ui->treeFiles->update(index); ui->treeFiles->update(index);
@ -5375,6 +5383,12 @@ void MainWindow::on_actionAdd_to_project_triggered()
foreach (const QString& filename, dialog.selectedFiles()) { foreach (const QString& filename, dialog.selectedFiles()) {
mProject->addUnit(filename,folderNode,false); mProject->addUnit(filename,folderNode,false);
mProject->cppParser()->addFileToScan(filename); mProject->cppParser()->addFileToScan(filename);
QString branch;
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
mProject->model()->iconProvider()->VCSRepository()->add(
extractRelativePath(mProject->folder(),filename)
);
}
} }
mProject->rebuildNodes(); mProject->rebuildNodes();
mProject->saveUnits(); mProject->saveUnits();
@ -5616,14 +5630,21 @@ void MainWindow::newProjectUnitFile()
} }
PProjectUnit newUnit = mProject->newUnit( PProjectUnit newUnit = mProject->newUnit(
mProject->pointerToNode(node),newFileName); mProject->pointerToNode(node),newFileName);
idx = mProject->units().count()-1;
mProject->rebuildNodes(); mProject->rebuildNodes();
mProject->saveUnits(); mProject->saveAll();
updateProjectView(); updateProjectView();
idx = mProject->units().count()-1;
Editor * editor = mProject->openUnit(idx); Editor * editor = mProject->openUnit(idx);
//editor->setUseCppSyntax(mProject->options().useGPP); //editor->setUseCppSyntax(mProject->options().useGPP);
//editor->setModified(true); //editor->setModified(true);
editor->activate(); editor->activate();
QString branch;
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
mProject->model()->iconProvider()->VCSRepository()->add(newFileName);
mProject->model()->beginUpdate();
mProject->model()->endUpdate();
}
updateProjectView();
} }
void MainWindow::doFilesViewRemoveFile(const QModelIndex &index) void MainWindow::doFilesViewRemoveFile(const QModelIndex &index)
@ -5802,6 +5823,7 @@ void MainWindow::showSearchReplacePanel(bool show)
void MainWindow::setFilesViewRoot(const QString &path) void MainWindow::setFilesViewRoot(const QString &path)
{ {
mFileSystemModelIconProvider.setRootFolder(path); mFileSystemModelIconProvider.setRootFolder(path);
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
mFileSystemModel.setRootPath(path); mFileSystemModel.setRootPath(path);
ui->treeFiles->setRootIndex(mFileSystemModel.index(path)); ui->treeFiles->setRootIndex(mFileSystemModel.index(path));
pSettings->environment().setCurrentFolder(path); pSettings->environment().setCurrentFolder(path);
@ -6004,7 +6026,8 @@ void MainWindow::on_actionC_C_Reference_triggered()
if (fileInfo.exists()) { if (fileInfo.exists()) {
QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath())); QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath()));
} else { } else {
QDesktopServices::openUrl(QUrl("https://zh.cppreference.com/w/cpp"));
QDesktopServices::openUrl(QUrl("https://qingcms.gitee.io/cppreference/20210212/zh/cpp.html"));
} }
} else { } else {
QDesktopServices::openUrl(QUrl("https://en.cppreference.com/w/cpp")); QDesktopServices::openUrl(QUrl("https://en.cppreference.com/w/cpp"));
@ -6244,7 +6267,7 @@ void MainWindow::on_btnRunAllProblemCases_clicked()
void MainWindow::on_actionC_Reference_triggered() void MainWindow::on_actionC_Reference_triggered()
{ {
if (pSettings->environment().language()=="zh_CN") { if (pSettings->environment().language()=="zh_CN") {
QDesktopServices::openUrl(QUrl("https://zh.cppreference.com/w/c")); QDesktopServices::openUrl(QUrl("https://qingcms.gitee.io/cppreference/20210212/zh/c.html"));
} else { } else {
QDesktopServices::openUrl(QUrl("https://en.cppreference.com/w/c")); QDesktopServices::openUrl(QUrl("https://en.cppreference.com/w/c"));
} }
@ -6614,6 +6637,7 @@ void MainWindow::on_actionGit_Create_Repository_triggered()
GitManager vcsManager; GitManager vcsManager;
vcsManager.createRepository(mProject->folder()); vcsManager.createRepository(mProject->folder());
vcsManager.add(mProject->folder(), extractFileName(mProject->filename())); vcsManager.add(mProject->folder(), extractFileName(mProject->filename()));
vcsManager.add(mProject->folder(), extractFileName(mProject->options().icon));
//update project view //update project view
mProject->addUnit(includeTrailingPathDelimiter(mProject->folder())+".gitignore", mProject->rootNode(), true); mProject->addUnit(includeTrailingPathDelimiter(mProject->folder())+".gitignore", mProject->rootNode(), true);
mProject->saveAll(); mProject->saveAll();
@ -6726,3 +6750,13 @@ void MainWindow::on_actionGit_Restore_triggered()
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider); mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
} }
void MainWindow::on_actionWebsite_triggered()
{
if (pSettings->environment().language()=="zh_CN") {
QDesktopServices::openUrl(QUrl("https://royqh1979.gitee.io/redpandacpp/"));
} else {
QDesktopServices::openUrl(QUrl("https://sourceforge.net/projects/redpanda-cpp/"));
}
}

View File

@ -586,6 +586,8 @@ private slots:
void on_actionGit_Restore_triggered(); void on_actionGit_Restore_triggered();
void on_actionWebsite_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
EditorList *mEditorList; EditorList *mEditorList;

View File

@ -576,7 +576,6 @@
<widget class="IssuesTable" name="tableIssues"> <widget class="IssuesTable" name="tableIssues">
<property name="font"> <property name="font">
<font> <font>
<weight>50</weight>
<bold>false</bold> <bold>false</bold>
</font> </font>
</property> </property>
@ -1422,7 +1421,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1114</width> <width>1114</width>
<height>26</height> <height>25</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -1559,6 +1558,7 @@
<property name="title"> <property name="title">
<string>Help</string> <string>Help</string>
</property> </property>
<addaction name="actionWebsite"/>
<addaction name="actionC_Reference"/> <addaction name="actionC_Reference"/>
<addaction name="actionC_C_Reference"/> <addaction name="actionC_C_Reference"/>
<addaction name="actionEGE_Manual"/> <addaction name="actionEGE_Manual"/>
@ -2783,6 +2783,11 @@
<string>Restore</string> <string>Restore</string>
</property> </property>
</action> </action>
<action name="actionWebsite">
<property name="text">
<string>Website</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@ -218,11 +218,14 @@ QString GitManager::runGit(const QString& workingFolder, const QStringList &args
.arg(workingFolder, .arg(workingFolder,
pSettings->vcs().gitPath(), pSettings->vcs().gitPath(),
args.join("\" \""))); args.join("\" \"")));
// qDebug()<<"---------";
// qDebug()<<args;
QString output = runAndGetOutput( QString output = runAndGetOutput(
fileInfo.absoluteFilePath(), fileInfo.absoluteFilePath(),
workingFolder, workingFolder,
args); args);
output = escapeUTF8String(output.toUtf8()); output = escapeUTF8String(output.toUtf8());
// qDebug()<<output;
emit gitCmdFinished(output); emit gitCmdFinished(output);
// if (output.startsWith("fatal:")) // if (output.startsWith("fatal:"))
// throw GitError(output); // throw GitError(output);

View File

@ -18,6 +18,7 @@
#include "ui_aboutdialog.h" #include "ui_aboutdialog.h"
#include "../systemconsts.h" #include "../systemconsts.h"
#include "../utils.h" #include "../utils.h"
#include "../settings.h"
#include <QDebug> #include <QDebug>
AboutDialog::AboutDialog(QWidget *parent) : AboutDialog::AboutDialog(QWidget *parent) :
@ -41,6 +42,12 @@ AboutDialog::AboutDialog(QWidget *parent) :
#endif #endif
ui->lblCompileTime->setText(ui->lblCompileTime->text() ui->lblCompileTime->setText(ui->lblCompileTime->text()
.arg(__DATE__, __TIME__)); .arg(__DATE__, __TIME__));
QString website="https://sourceforge.net/projects/redpanda-cpp/";
if (pSettings->environment().language()=="zh_CN") {
website = "https://royqh1979.gitee.io/redpandacpp/";
}
ui->lblHomepage->setText(tr("Website: <a href=\"%1\">%1</a>").arg(website));
} }
AboutDialog::~AboutDialog() AboutDialog::~AboutDialog()

View File

@ -28,7 +28,6 @@
<widget class="QLabel" name="lblQt"> <widget class="QLabel" name="lblQt">
<property name="font"> <property name="font">
<font> <font>
<weight>50</weight>
<bold>false</bold> <bold>false</bold>
</font> </font>
</property> </property>
@ -41,7 +40,6 @@
<widget class="QLabel" name="lblCompileTime"> <widget class="QLabel" name="lblCompileTime">
<property name="font"> <property name="font">
<font> <font>
<weight>50</weight>
<bold>false</bold> <bold>false</bold>
</font> </font>
</property> </property>
@ -54,7 +52,6 @@
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="font"> <property name="font">
<font> <font>
<weight>50</weight>
<bold>false</bold> <bold>false</bold>
</font> </font>
</property> </property>
@ -64,15 +61,17 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="lblHomepage">
<property name="font"> <property name="font">
<font> <font>
<weight>50</weight>
<bold>false</bold> <bold>false</bold>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Homepage: &lt;a href=&quot;Homepage: https://sourceforge.net/projects/dev-cpp-2020/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://sourceforge.net/projects/dev-cpp-2020/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Homepage: &lt;a href=&quot;Homepage: https://sourceforge.net/projects/dev-cpp-2020/&quot;&gt;https://sourceforge.net/projects/dev-cpp-2020/&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>