Repository navigation
Expand file tree
/
Copy pathfunctionlistarea.cpp
More file actions
103 lines (90 loc) · 3 KB
/
Copy pathfunctionlistarea.cpp
File metadata and controls
103 lines (90 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
This file is part of cPad Project.
cPad is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cPad is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cPad. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>
#include "functionlistarea.h"
FunctionListArea::FunctionListArea(QWidget *parent,
CodeEditor *editor):
QDockWidget(parent)
{
codeEditor = editor;
functionListBox = new FunctionListBox(this);
memoryCenter = new MemoryCenter();
generalSetting();
}
void FunctionListArea::enableArea(bool enable)
{
if (enable) {
createFunctionList();
show();
}
else
close();
}
void FunctionListArea::cursorMove(int index)
{
if (index == 0) return;
int line = functionListBox->itemData(index).toInt();
codeEditor->moveCursor(QTextCursor::End);
QTextCursor tcr(
codeEditor->document()->findBlockByNumber(line-1));
codeEditor->setTextCursor(tcr);
}
void FunctionListArea::createFunctionList()
{
functionListBox->close();
functionListBox->clear();
QString str(codeEditor->toPlainText());
memoryCenter->analysisMain(str);
memoryCenter->makeFunctionList(str);
struct FunctionList *list = memoryCenter->getFunctionList();
functionListBox->addItem(tr("<Please Select>"));
for ( list = list->nextFunction; list; list = list->nextFunction) {
functionListBox->addItem(list->functionOutput,
list->functionLine);
}
functionListBox->show();
}
void FunctionListArea::generalSetting()
{
QWidget *widget = new QWidget();
QHBoxLayout *layout = new QHBoxLayout();
QLabel *label = new QLabel(tr("º¯ÊýÁбí:"), this);
widget->setLayout(layout);
layout->addWidget(label);
layout->addWidget(functionListBox, 1);
setTitleBarWidget(widget);
setWidget(new QWidget());
setFixedHeight(24);
layout->setContentsMargins(5, 4, 5, 0);
connect(functionListBox,
SIGNAL(activated(int)),
this,
SLOT(cursorMove(int))
);
connect(functionListBox,
SIGNAL(updateFunctionList()),
this,
SLOT(createFunctionList())
);
QFont afont(font());
afont.setPointSize(10);
setFont(afont);
setWindowTitle(tr(""));
setAllowedAreas(Qt::TopDockWidgetArea);
setFeatures(QDockWidget::DockWidgetClosable);
//QDockWidget::DockWidgetVerticalTitleBar);
QMainWindow *main = qobject_cast<QMainWindow *>(parent());
main->addDockWidget(Qt::TopDockWidgetArea, this);
hide();//ĬÈϹرÕ
}