work save

This commit is contained in:
royqh1979 2021-08-30 19:52:38 +08:00
parent 08ac0ad419
commit 1684f9a71d
9 changed files with 90 additions and 20 deletions

View File

@ -774,9 +774,10 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
e->setCaretPositionAndActivate(1,1);
return;
}
} else {
gotoDeclaration(p);
return;
}
// else
// MainForm.actGotoImplDeclEditorExecute(self);
}
}
SynEdit::mouseReleaseEvent(event);
@ -2022,7 +2023,7 @@ QString Editor::getParserHint(const QString &s, int line)
} else if (statement->line>0) {
QFileInfo fileInfo(statement->fileName);
result = mParser->prettyPrintStatement(statement,mFilename, line) + " - "
+ QString("%1(%2)").arg(fileInfo.fileName()).arg(line)
+ QString("%1(%2) ").arg(fileInfo.fileName()).arg(line)
+ tr("Ctrl+click for more info");
} else { // hard defines
result = mParser->prettyPrintStatement(statement, mFilename);
@ -2071,15 +2072,70 @@ QString Editor::getHintForFunction(const PStatement &statement, const PStatement
continue;
if (!result.isEmpty())
result += "<BR />";
QFileInfo fileInfo(filename);
QFileInfo fileInfo(childStatement->fileName);
result = mParser->prettyPrintStatement(childStatement,filename,line) + " - "
+ QString("%1(%2)").arg(fileInfo.fileName()).arg(line)
+ QString("%1(%2) ").arg(fileInfo.fileName()).arg(line)
+ tr("Ctrl+click for more info");
}
}
return result;
}
void Editor::gotoDeclaration(const BufferCoord &pos)
{
// Exit early, don't bother creating a stream (which is slow)
BufferCoord pBeginPos, pEndPos;
QString phrase = getWordAtPosition(pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
if (phrase.isEmpty())
return;
PStatement statement = mParser->findStatementOf(
mFilename,phrase,pos.Line);
if (!statement) {
pMainWindow->updateStatusBarMessage(tr("Symbol '%1' not found!").arg(phrase));
return;
}
QString filename;
int line;
if (statement->fileName == mFilename && statement->line == pos.Line) {
filename = statement->definitionFileName;
line = statement->definitionLine;
} else {
filename = statement->fileName;
line = statement->line;
}
Editor* e = pMainWindow->editorList()->getEditorByFilename(filename);
if (e) {
e->setCaretPositionAndActivate(line,1);
}
}
void Editor::gotoDefinition(const BufferCoord &pos)
{
// Exit early, don't bother creating a stream (which is slow)
BufferCoord pBeginPos, pEndPos;
QString phrase = getWordAtPosition(pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
if (phrase.isEmpty())
return;
PStatement statement = mParser->findStatementOf(
mFilename,phrase,pos.Line);
if (!statement) {
pMainWindow->updateStatusBarMessage(tr("Symbol '%1' not found!").arg(phrase));
return;
}
QString filename;
int line;
filename = statement->definitionFileName;
line = statement->definitionLine;
Editor* e = pMainWindow->editorList()->getEditorByFilename(filename);
if (e) {
e->setCaretPositionAndActivate(line,1);
}
}
QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin, BufferCoord &pWordEnd, WordPurpose purpose)
{
QString result = "";

View File

@ -191,6 +191,9 @@ private:
QString getHintForFunction(const PStatement& statement, const PStatement& scope,
const QString& filename, int line);
void gotoDeclaration(const BufferCoord& pos);
void gotoDefinition(const BufferCoord& pos);
private:
static int newfileCount;
QByteArray mEncodingOption; // the encoding type set by the user

View File

@ -57,11 +57,11 @@ int main(int argc, char *argv[])
if (settingFilename.isEmpty())
return -1;
{
// QSettings languageSetting(settingFilename,QSettings::IniFormat);
// languageSetting.beginGroup(SETTING_ENVIRONMENT);
// QString language = languageSetting.value("language",QLocale::system().name()).toString();
// trans.load("RedPandaIDE_"+language,":/translations");
// app.installTranslator(&trans);
QSettings languageSetting(settingFilename,QSettings::IniFormat);
languageSetting.beginGroup(SETTING_ENVIRONMENT);
QString language = languageSetting.value("language",QLocale::system().name()).toString();
trans.load("RedPandaIDE_"+language,":/translations");
app.installTranslator(&trans);
}
qRegisterMetaType<PCompileIssue>("PCompileIssue");

View File

@ -466,7 +466,7 @@ void MainWindow::updateForStatusbarModeInfo()
}
}
void MainWindow::updateStatusBarForParsing(const QString &s)
void MainWindow::updateStatusBarMessage(const QString &s)
{
ui->statusbar->showMessage(s);
}
@ -1005,10 +1005,11 @@ void MainWindow::on_actionOpen_triggered()
{
try {
QString selectedFileFilter;
if (pSettings->editor().defaultFileCpp())
if (pSettings->editor().defaultFileCpp()){
selectedFileFilter = pSystemConsts->defaultCPPFileFilter();
else
} else {
selectedFileFilter = pSystemConsts->defaultCFileFilter();
}
QStringList files = QFileDialog::getOpenFileNames(pMainWindow,
tr("Open"), QString(), pSystemConsts->defaultFileFilters().join(";;"),
&selectedFileFilter);
@ -1610,7 +1611,7 @@ void MainWindow::onParserProgress(const QString &fileName, int total, int curren
// Only show if needed (it's a very slow operation)
if (current ==1 || current % showStep==0) {
updateStatusBarForParsing(tr("Parsing file %1 of %2: \"%3\"")
updateStatusBarMessage(tr("Parsing file %1 of %2: \"%3\"")
.arg(current).arg(total).arg(fileName));
}
}
@ -1632,13 +1633,13 @@ void MainWindow::onEndParsing(int total, int)
} else {
parsingFrequency = 999;
}
updateStatusBarForParsing(tr("Done parsing %1 files in %2 seconds")
updateStatusBarMessage(tr("Done parsing %1 files in %2 seconds")
.arg(total).arg(parseTime)
+ " "
+ tr("(%1 files per second)")
.arg(parsingFrequency));
} else {
updateStatusBarForParsing(tr("Done parsing %1 files in %2 seconds")
updateStatusBarMessage(tr("Done parsing %1 files in %2 seconds")
.arg(total).arg(parseTime));
}
}

View File

@ -52,7 +52,7 @@ public:
void updateForEncodingInfo();
void updateStatusbarForLineCol();
void updateForStatusbarModeInfo();
void updateStatusBarForParsing(const QString& s);
void updateStatusBarMessage(const QString& s);
void updateEditorSettings();
void updateEditorActions();
void updateCompileActions();

View File

@ -53,6 +53,6 @@ void EditorCodeCompletionWidget::doSave()
pSettings->codeCompletion().setAppendFunc(ui->chkAppendFunc->isChecked());
pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked());
pSettings->editor().save();
pSettings->codeCompletion().save();
}

View File

@ -6,6 +6,7 @@
#include <QLineEdit>
#include <QListView>
#include <QPlainTextEdit>
#include <QRadioButton>
#include <QSpinBox>
#include "../widgets/coloredit.h"
@ -60,7 +61,10 @@ void SettingsWidget::connectInputs()
connect(p, &QLineEdit::textChanged, this, &SettingsWidget::setSettingsChanged);
}
for (QCheckBox* p:findChildren<QCheckBox*>()) {
connect(p, &QCheckBox::stateChanged, this, &SettingsWidget::setSettingsChanged);
connect(p, &QCheckBox::toggled, this, &SettingsWidget::setSettingsChanged);
}
for (QRadioButton* p:findChildren<QRadioButton*>()) {
connect(p, &QRadioButton::toggled, this, &SettingsWidget::setSettingsChanged);
}
for (QPlainTextEdit* p:findChildren<QPlainTextEdit*>()) {
connect(p, &QPlainTextEdit::textChanged, this, &SettingsWidget::setSettingsChanged);

View File

@ -29,6 +29,11 @@ const QString &SystemConsts::defaultCPPFileFilter() const noexcept
return mDefaultFileFilters[1];
}
const QString &SystemConsts::defaultAllFileFilter() const noexcept
{
return mDefaultFileFilters.back();
}
void SystemConsts::addDefaultFileFilter(const QString &name, const QString &fileExtensions)
{
mDefaultFileFilters.append(name+ " (" + fileExtensions+")");

View File

@ -30,7 +30,7 @@
#error "Only support windows and linux now!"
#endif
#define DEVCPP_VERSION "0.05"
#define DEVCPP_VERSION "0.0.5"
class SystemConsts
{
@ -39,6 +39,7 @@ public:
const QStringList& defaultFileFilters() const noexcept;
const QString& defaultCFileFilter() const noexcept;
const QString& defaultCPPFileFilter() const noexcept;
const QString& defaultAllFileFilter() const noexcept;
void addDefaultFileFilter(const QString& name, const QString& fileExtensions);
private:
QStringList mDefaultFileFilters;