Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
radix
Commits
5af228b8
Commit
5af228b8
authored
Jun 24, 2018
by
Jordan P. Lefebvre
Browse files
Adding paste functionality to TableView.
parent
b104d235
Pipeline
#13849
failed with stages
in 6 minutes and 15 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
radixwidgets/tableview.cc
View file @
5af228b8
...
...
@@ -122,7 +122,37 @@ void TableView::copy()
QApplication
::
clipboard
()
->
setText
(
data
);
}
void
TableView
::
paste
()
{
radix_tagged_line
(
"paste()"
);
}
void
TableView
::
paste
()
{
radix_tagged_line
(
"paste()"
);
QModelIndex
selectedCell
=
currentIndex
();
if
(
selectedCell
.
isValid
()
==
false
)
selectedCell
=
model
()
->
index
(
0
,
0
);
// store in clipboard
QString
text
=
QApplication
::
clipboard
()
->
text
();
// split into lines
QStringList
rows
=
text
.
split
(
"
\n
"
,
QString
::
SkipEmptyParts
);
for
(
int
r
=
0
;
r
<
rows
.
size
();
++
r
)
{
if
(
model
()
->
rowCount
()
==
r
)
{
model
()
->
insertRow
(
r
);
}
QStringList
columns
=
rows
.
at
(
r
).
split
(
p
->
separator
);
for
(
int
c
=
0
;
c
<
columns
.
size
();
++
c
)
{
if
(
model
()
->
columnCount
()
==
c
)
{
model
()
->
insertColumn
(
c
);
}
model
()
->
setData
(
model
()
->
index
(
selectedCell
.
row
()
+
r
,
selectedCell
.
column
()
+
c
),
columns
.
at
(
c
));
}
}
}
void
TableView
::
keyPressEvent
(
QKeyEvent
*
event
)
{
...
...
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