Commit 7f97c7d7 authored by Huff, Israel's avatar Huff, Israel
Browse files

adding properties and methods for disabling headers in copy/paste

parent de668f69
Pipeline #56737 passed with stages
in 14 minutes and 6 seconds
......@@ -13,6 +13,8 @@ class RADIX_PUBLIC TableView::PImpl
{
public:
bool allow_paste;
bool copy_vert_header;
bool copy_horiz_header;
char separator;
PImpl();
};
......@@ -20,6 +22,8 @@ class RADIX_PUBLIC TableView::PImpl
TableView::PImpl::PImpl()
{
allow_paste = false;
copy_vert_header = false;
copy_horiz_header = false;
separator = '\t';
}
......@@ -33,6 +37,10 @@ char TableView::separator() const { return p->separator; }
void TableView::setSeparator(char value) { p->separator = value; }
void TableView::setCopyVertHeader(bool value) { p->copy_vert_header = value; }
void TableView::setCopyHorizHeader(bool value) { p->copy_horiz_header = value; }
bool TableView::allowPaste() const { return p->allow_paste; }
void TableView::setAllowPaste(bool value) { p->allow_paste = value; }
......@@ -82,16 +90,19 @@ void TableView::copy()
QString data;
// add column headers
if (horizontalHeader()->isVisible())
if (horizontalHeader()->isVisible() && p->copy_horiz_header)
{
if (verticalHeader()->isVisible())
if (verticalHeader()->isVisible() && p->copy_vert_header)
{
data.append(p->separator);
}
for (auto col : cols)
if (p->copy_horiz_header)
{
data.append(chmodel->headerData(col, Qt::Horizontal).toString())
.append(p->separator);
for (int i = 0; i < cols.size(); i++)
{
if (i > 0) data.append(p->separator);
data.append(chmodel->headerData(cols[i], Qt::Horizontal).toString());
}
}
data.append('\n');
}
......@@ -100,24 +111,24 @@ void TableView::copy()
for (auto row : rows)
{
// add row header
if (verticalHeader()->isVisible())
if (verticalHeader()->isVisible() && p->copy_vert_header)
{
data.append(rhmodel->headerData(row, Qt::Vertical).toString())
.append(p->separator);
}
// add row's cells
for (auto col : cols)
for (int i = 0; i < cols.size(); i++)
{
if (i > 0) data.append(p->separator);
// row's data
auto &rd = cells[row];
// current cell is valid
if (rd.contains(col))
if (rd.contains(cols[i]))
{
data.append(rd[col]);
data.append(rd[cols[i]]);
}
data.append(p->separator);
}
data.append('\n');
}
......
......@@ -27,6 +27,8 @@ class RADIX_PUBLIC TableView : public QTableView
char separator() const;
void setSeparator(char value);
void setCopyVertHeader(bool value);
void setCopyHorizHeader(bool value);
bool allowPaste() const;
void setAllowPaste(bool value);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment