Skip to content

Commit

Permalink
TableView3D: More features to the new TableVier to replace QTableWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
malcom2073 committed Jul 31, 2014
1 parent 68043e7 commit af93a0b
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
68 changes: 68 additions & 0 deletions core/src/tableviewnew3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,74 @@ TableViewNew3D::TableViewNew3D(QWidget *parent) : QWidget(parent)
}

}
void TableViewNew3D::clear()
{
//Clear everything out
yaxis.clear();
m_highlightList.clear();
values.clear();
xaxis.clear();
}
void TableViewNew3D::rebuildTable()
{
yaxis.clear();
m_highlightList.clear();
values.clear();
xaxis.clear();
for (int y=0;y<m_rowCount;y++)
{
yaxis.append(0);
QList<double> row;
QList<int> highlightrow;
highlightrow.append(0); //For the Y column
for (int x=0;x<m_columnCount;x++)
{
xaxis.append(0);
row.append(0);
highlightrow.append(0);
}
m_highlightList.append(highlightrow);
if (y == 0)
{
m_highlightList.append(highlightrow); //Double add it for the last row
}
highlightrow.clear();
values.append(row);
}

}

void TableViewNew3D::setRowCount(int count)
{
if (count < m_rowCount)
{
//Reducing the number of rows
}
else if (count > m_rowCount)
{

}
else
{
//Row count stays the same
return;
}
//Assume row count is changing from 0 to whatever
m_rowCount = count;
rebuildTable();
}
void TableViewNew3D::setItem(int row,int column,QString text)
{
values[row][column] = text.toDouble();
update();
}

void TableViewNew3D::setColumnCount(int count)
{
m_columnCount = count;
rebuildTable();
}

void TableViewNew3D::paintEvent (QPaintEvent *evt)
{
Q_UNUSED(evt)
Expand Down
11 changes: 10 additions & 1 deletion core/src/tableviewnew3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ class TableViewNew3D : public QWidget
Q_OBJECT
public:
explicit TableViewNew3D(QWidget *parent = 0);
void clear();
void setRowCount(int count);
void setColumnCount(int count);
void setItem(int row,int column,QString text);
void rebuildTable();

private:
void paintEvent (QPaintEvent *evt);
QList<double> xaxis;
Expand All @@ -23,10 +29,13 @@ class TableViewNew3D : public QWidget
QPoint currentCell;
QPoint startSelectCell;
bool multiSelect;
int m_rowCount;
int m_columnCount;
void rebuildtable();
signals:

public slots:

};

#endif // TABLEVIEWNEW3D_H
#endif // TABLEVIEWNEW3D_

0 comments on commit af93a0b

Please sign in to comment.