1/*
2 * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#include "editorcodecompletionwidget.h"
18#include "ui_editorcodecompletionwidget.h"
19#include "../settings.h"
20#include "../mainwindow.h"
21#include "../symbolusagemanager.h"
22
23EditorCodeCompletionWidget::EditorCodeCompletionWidget(const QString& name, const QString& group,
24 QWidget *parent) :
25 SettingsWidget(name,group,parent),
26 ui(new Ui::EditorCodeCompletionWidget)
27{
28 ui->setupUi(this);
29}
30
31EditorCodeCompletionWidget::~EditorCodeCompletionWidget()
32{
33 delete ui;
34}
35
36void EditorCodeCompletionWidget::doLoad()
37{
38 ui->grpEnabled->setChecked(pSettings->codeCompletion().enabled());
39
40 ui->chkParseLocalFiles->setChecked(pSettings->codeCompletion().parseLocalHeaders());
41 ui->chkParseSystemFiles->setChecked(pSettings->codeCompletion().parseGlobalHeaders());
42
43 ui->spinWidth->setValue(pSettings->codeCompletion().width());
44 ui->spinHeight->setValue(pSettings->codeCompletion().height());
45
46 ui->chkShowSuggestionWhileTyping->setChecked(pSettings->codeCompletion().showCompletionWhileInput());
47 ui->chkRecordUsage->setChecked(pSettings->codeCompletion().recordUsage());
48 ui->chkSortByScope->setChecked(pSettings->codeCompletion().sortByScope());
49 ui->chkShowKeywords->setChecked(pSettings->codeCompletion().showKeywords());
50 ui->chkIgnoreCases->setChecked(pSettings->codeCompletion().ignoreCase());
51 ui->chkAppendFunc->setChecked(pSettings->codeCompletion().appendFunc());
52 ui->chkShowCodeIns->setChecked(pSettings->codeCompletion().showCodeIns());
53 ui->chkClearWhenEditorHidden->setChecked(pSettings->codeCompletion().clearWhenEditorHidden());
54 ui->chkHideSymbolsStartWithTwoUnderline->setChecked(pSettings->codeCompletion().hideSymbolsStartsWithTwoUnderLine());
55 ui->chkHideSymbolsStartWithUnderline->setChecked(pSettings->codeCompletion().hideSymbolsStartsWithUnderLine());
56
57 ui->spinMinCharRequired->setValue(pSettings->codeCompletion().minCharRequired());
58}
59
60void EditorCodeCompletionWidget::doSave()
61{
62 //font
63 pSettings->codeCompletion().setEnabled(ui->grpEnabled->isChecked());
64
65 pSettings->codeCompletion().setParseLocalHeaders(ui->chkParseLocalFiles->isChecked());
66 pSettings->codeCompletion().setParseGlobalHeaders(ui->chkParseSystemFiles->isChecked());
67
68 pSettings->codeCompletion().setWidth(ui->spinWidth->value());
69 pSettings->codeCompletion().setHeight(ui->spinHeight->value());
70
71 pSettings->codeCompletion().setShowCompletionWhileInput(ui->chkShowSuggestionWhileTyping->isChecked());
72 pSettings->codeCompletion().setRecordUsage(ui->chkRecordUsage->isChecked());
73 pSettings->codeCompletion().setSortByScope(ui->chkSortByScope->isChecked());
74 pSettings->codeCompletion().setShowKeywords(ui->chkShowKeywords->isChecked());
75 pSettings->codeCompletion().setIgnoreCase(ui->chkIgnoreCases->isChecked());
76 pSettings->codeCompletion().setAppendFunc(ui->chkAppendFunc->isChecked());
77 pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked());
78 pSettings->codeCompletion().setMinCharRequired(ui->spinMinCharRequired->value());
79
80 pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked());
81
82 pSettings->codeCompletion().setHideSymbolsStartsWithTwoUnderLine(ui->chkHideSymbolsStartWithTwoUnderline->isChecked());
83 pSettings->codeCompletion().setHideSymbolsStartsWithUnderLine(ui->chkHideSymbolsStartWithUnderline->isChecked());
84
85 pSettings->codeCompletion().save();
86}
87
88
89void EditorCodeCompletionWidget::on_btnClearUsageData_clicked()
90{
91 pMainWindow->symbolUsageManager()->reset();
92}
93
94