Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bipscript
ide
Commits
47ec0d1d
Commit
47ec0d1d
authored
Oct 07, 2020
by
jhammen
Browse files
basic text search function
parent
d8ed1474
Changes
10
Hide whitespace changes
Inline
Side-by-side
bipscript-ide.pro
View file @
47ec0d1d
...
...
@@ -33,6 +33,7 @@ SOURCES += \
outputwidget
.
cpp
\
projectlist
.
cpp
\
projectsdialog
.
cpp
\
searchwidget
.
cpp
\
synhighlighter
.
cpp
HEADERS
+=
\
...
...
@@ -40,6 +41,7 @@ HEADERS += \
editorwidget
.
h
\
scriptrun
.
h
\
outputwidget
.
h
\
searchwidget
.
h
\
style
.
h
\
projectlist
.
h
\
foldertreeitem
.
h
\
...
...
@@ -62,7 +64,8 @@ unix {
FORMS
+=
\
mainwindow
.
ui
\
outputwidget
.
ui
\
projectsdialog
.
ui
projectsdialog
.
ui
\
searchwidget
.
ui
#
Default
rules
for
deployment
.
qnx
:
target
.
path
=
/
tmp
/
$$
{
TARGET
}
/
bin
...
...
editorwidget.cpp
View file @
47ec0d1d
...
...
@@ -81,6 +81,23 @@ bool EditorWidget::save() {
return
true
;
}
uint32_t
EditorWidget
::
searchText
(
const
QString
&
term
)
{
moveCursor
(
QTextCursor
::
Start
);
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
uint32_t
count
=
0
;
while
(
find
(
term
))
{
QTextEdit
::
ExtraSelection
extra
;
extra
.
cursor
=
textCursor
();
extra
.
format
.
fontUnderline
();
QColor
color
(
210
,
210
,
210
);
extra
.
format
.
setBackground
(
color
);
selections
.
append
(
extra
);
count
++
;
}
setExtraSelections
(
selections
);
return
count
;
}
void
EditorWidget
::
focusLine
(
int
line
,
int
column
)
{
QTextCursor
cursor
=
textCursor
();
cursor
.
movePosition
(
QTextCursor
::
Start
);
...
...
editorwidget.h
View file @
47ec0d1d
...
...
@@ -55,6 +55,7 @@ class EditorWidget : public QPlainTextEdit {
bool
hasSelection
()
{
return
textCursor
().
hasSelection
();
}
bool
load
();
bool
save
();
uint32_t
searchText
(
const
QString
&
term
);
void
focusLine
(
int
line
,
int
column
=
0
);
void
commentSelection
();
void
moveFile
(
NamedFile
&
file
)
{
mfile
=
file
;
}
...
...
format
0 → 100755
View file @
47ec0d1d
clang-format -style="{BasedOnStyle: llvm, IndentWidth: 4, ColumnLimit: 100}" -i ./*.h ./*.cpp
mainwindow.cpp
View file @
47ec0d1d
...
...
@@ -54,6 +54,10 @@ MainWindow::MainWindow(QWidget *parent)
ui
->
outputDockWidget
->
setHidden
(
true
);
ui
->
folderTree
->
setColumnCount
(
1
);
//
searchWidget
=
new
SearchWidget
();
ui
->
leftTabWidget
->
addTab
(
searchWidget
,
"Search"
);
connect
(
searchWidget
,
SIGNAL
(
searchCurrent
(
QString
)),
this
,
SLOT
(
searchCurrent
(
QString
)));
ProjectList
&
projectList
=
ProjectList
::
getProjectList
();
projectList
.
load
();
...
...
@@ -201,6 +205,14 @@ void MainWindow::markDirty(bool value) {
setWindowModified
(
value
);
}
void
MainWindow
::
searchCurrent
(
const
QString
&
term
)
{
EditorWidget
*
editor
=
currentEditor
();
if
(
editor
)
{
uint32_t
results
=
editor
->
searchText
(
term
);
searchWidget
->
results
(
results
);
}
}
void
MainWindow
::
showTime
(
Position
pos
)
{
QTime
qtime
(
0
,
0
,
0
);
qtime
=
qtime
.
addMSecs
(
pos
.
msec
);
...
...
@@ -482,6 +494,11 @@ void MainWindow::on_actionRewind_triggered() {
void
MainWindow
::
on_actionSaveFile_triggered
()
{
currentEditor
()
->
save
();
}
void
MainWindow
::
on_actionFocusFind_triggered
()
{
searchWidget
->
newFileSearch
();
ui
->
leftTabWidget
->
setCurrentWidget
(
searchWidget
);
}
void
MainWindow
::
on_actionStartStopTransport_toggled
(
bool
start
)
{
if
(
start
)
{
audioEngine
.
transportStart
();
...
...
mainwindow.h
View file @
47ec0d1d
...
...
@@ -23,6 +23,7 @@
#include "outputwidget.h"
#include "position.h"
#include "projectlist.h"
#include "searchwidget.h"
#include <QFileInfo>
#include <QLabel>
...
...
@@ -48,6 +49,7 @@ class MainWindow : public QMainWindow {
void
folderTreeClicked
(
QTreeWidgetItem
*
item
,
int
col
);
void
handleLink
(
const
QUrl
&
);
void
markDirty
(
bool
unsaved
);
void
searchCurrent
(
const
QString
&
);
void
showTime
(
Position
pos
);
void
tabChanged
(
int
index
);
void
closeOtherEditors
();
...
...
@@ -78,6 +80,7 @@ class MainWindow : public QMainWindow {
void
on_actionUndo_triggered
();
void
on_actionWebsite_triggered
();
void
on_tabWidget_customContextMenuRequested
(
const
QPoint
&
pos
);
void
on_actionFocusFind_triggered
();
private:
QString
*
selectedFolder
;
...
...
@@ -86,6 +89,7 @@ class MainWindow : public QMainWindow {
uint
transportPosition
;
AudioConfiguration
audioConfig
;
Ui
::
MainWindow
*
ui
;
SearchWidget
*
searchWidget
;
QLabel
timeWidget
;
QLabel
bbtWidget
;
QLabel
engineWidget
;
...
...
mainwindow.ui
View file @
47ec0d1d
...
...
@@ -23,18 +23,26 @@
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<widget
class=
"QT
ree
Widget"
name=
"
folderTree
"
>
<property
name=
"c
olumnCount
"
>
<number>
1
</number>
<widget
class=
"QT
ab
Widget"
name=
"
leftTabWidget
"
>
<property
name=
"c
urrentIndex
"
>
<number>
0
</number>
</property>
<widget
class=
"QTreeWidget"
name=
"folderTree"
>
<property
name=
"columnCount"
>
<number>
1
</number>
</property>
<attribute
name=
"headerVisible"
>
<bool>
false
</bool>
</attribute>
<column>
<property
name=
"text"
>
<string
notr=
"true"
>
1
</string>
</property>
</column>
<attribute
name=
"title"
>
<string>
Filesystem
</string>
</attribute>
<column>
<property
name=
"text"
>
<string
notr=
"true"
>
1
</string>
</property>
</column>
</widget>
</widget>
<widget
class=
"QTabWidget"
name=
"tabWidget"
>
<property
name=
"sizePolicy"
>
...
...
@@ -96,6 +104,8 @@
<addaction
name=
"actionPaste"
/>
<addaction
name=
"separator"
/>
<addaction
name=
"actionComment"
/>
<addaction
name=
"separator"
/>
<addaction
name=
"actionFocusFind"
/>
</widget>
<widget
class=
"QMenu"
name=
"menuTransport"
>
<property
name=
"title"
>
...
...
@@ -504,6 +514,21 @@
<string>
F2
</string>
</property>
</action>
<action
name=
"actionFocusFind"
>
<property
name=
"icon"
>
<iconset
theme=
"edit-find"
>
<normaloff>
.
</normaloff>
.
</iconset>
</property>
<property
name=
"text"
>
<string>
Find
</string>
</property>
<property
name=
"toolTip"
>
<string>
Find text
</string>
</property>
<property
name=
"shortcut"
>
<string>
Ctrl+F
</string>
</property>
</action>
</widget>
<layoutdefault
spacing=
"6"
margin=
"11"
/>
<resources/>
...
...
searchwidget.cpp
0 → 100644
View file @
47ec0d1d
#include "searchwidget.h"
#include "ui_searchwidget.h"
SearchWidget
::
SearchWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
),
ui
(
new
Ui
::
SearchWidget
)
{
ui
->
setupUi
(
this
);
}
void
SearchWidget
::
newFileSearch
()
{
ui
->
searchLineEdit
->
setFocus
();
ui
->
searchLineEdit
->
selectAll
();
}
void
SearchWidget
::
results
(
uint32_t
results
)
{
QString
mesg
=
QString
(
"%1 results"
).
arg
(
results
);
ui
->
countLabel
->
setText
(
mesg
);
}
SearchWidget
::~
SearchWidget
()
{
delete
ui
;
}
void
SearchWidget
::
on_searchButton_clicked
()
{
QLineEdit
*
lineEdit
=
this
->
ui
->
searchLineEdit
;
emit
searchCurrent
(
lineEdit
->
text
());
}
void
SearchWidget
::
on_searchLineEdit_returnPressed
()
{
QLineEdit
*
lineEdit
=
this
->
ui
->
searchLineEdit
;
emit
searchCurrent
(
lineEdit
->
text
());
}
searchwidget.h
0 → 100644
View file @
47ec0d1d
#ifndef SEARCHWIDGET_H
#define SEARCHWIDGET_H
#include <QWidget>
namespace
Ui
{
class
SearchWidget
;
}
class
SearchWidget
:
public
QWidget
{
Q_OBJECT
public:
explicit
SearchWidget
(
QWidget
*
parent
=
nullptr
);
void
newFileSearch
();
void
results
(
uint32_t
results
);
~
SearchWidget
();
signals:
void
searchCurrent
(
QString
);
private
slots
:
void
on_searchButton_clicked
();
void
on_searchLineEdit_returnPressed
();
private:
Ui
::
SearchWidget
*
ui
;
};
#endif // SEARCHWIDGET_H
searchwidget.ui
0 → 100644
View file @
47ec0d1d
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
SearchWidget
</class>
<widget
class=
"QWidget"
name=
"SearchWidget"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
400
</width>
<height>
496
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Form
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QLineEdit"
name=
"searchLineEdit"
/>
</item>
<item>
<widget
class=
"QPushButton"
name=
"searchButton"
>
<property
name=
"text"
>
<string>
Find
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget
class=
"QRadioButton"
name=
"radioButton"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
<property
name=
"text"
>
<string>
Find in current file
</string>
</property>
<property
name=
"checked"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"countLabel"
>
<property
name=
"text"
>
<string/>
</property>
</widget>
</item>
<item>
<widget
class=
"QTreeWidget"
name=
"treeWidget"
>
<attribute
name=
"headerVisible"
>
<bool>
false
</bool>
</attribute>
<column>
<property
name=
"text"
>
<string
notr=
"true"
>
1
</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment