From 68043e7700d17f60c78779c7b4954102102f03b8 Mon Sep 17 00:00:00 2001 From: Michael Carpenter Date: Thu, 3 Apr 2014 17:17:28 -0400 Subject: [PATCH] TableView3D: Added a new TableView3D to replace the old QTableWidget based one --- core/core.pro | 6 +- core/src/mainwindow.cpp | 5 +- core/src/tableviewnew3d.cpp | 245 ++++++++++++++++++++++++++++++++++++ core/src/tableviewnew3d.h | 32 +++++ 4 files changed, 285 insertions(+), 3 deletions(-) create mode 100644 core/src/tableviewnew3d.cpp create mode 100644 core/src/tableviewnew3d.h diff --git a/core/core.pro b/core/core.pro index f522d57..f935fee 100644 --- a/core/core.pro +++ b/core/core.pro @@ -119,7 +119,8 @@ SOURCES += src/main.cpp\ src/comboparam.cpp \ src/ramdiffwindow.cpp \ src/pluginmanager.cpp \ - src/qcustomplot.cpp + src/qcustomplot.cpp \ + src/tableviewnew3d.cpp HEADERS += src/mainwindow.h \ @@ -172,7 +173,8 @@ HEADERS += src/mainwindow.h \ src/comboparam.h \ src/ramdiffwindow.h \ src/pluginmanager.h \ - src/qcustomplot.h + src/qcustomplot.h \ + src/tableviewnew3d.h FORMS += src/mainwindow.ui \ src/comsettings.ui \ diff --git a/core/src/mainwindow.cpp b/core/src/mainwindow.cpp index bf9af9d..c04d73c 100644 --- a/core/src/mainwindow.cpp +++ b/core/src/mainwindow.cpp @@ -30,12 +30,15 @@ #include "logloader.h" #include "QsLog.h" #include "wizardview.h" - +#include "tableviewnew3d.h" #define define2string_p(x) #x #define define2string(x) define2string_p(x) MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { + TableViewNew3D *table = new TableViewNew3D(); + table->setGeometry(100,100,800,600); + table->show(); m_interrogationInProgress = false; m_offlineMode = false; m_checkEmsDataInUse = false; diff --git a/core/src/tableviewnew3d.cpp b/core/src/tableviewnew3d.cpp new file mode 100644 index 0000000..c365b3c --- /dev/null +++ b/core/src/tableviewnew3d.cpp @@ -0,0 +1,245 @@ +#include "tableviewnew3d.h" +#include +#include +#define ITEM_WIDTH 60 +#define ITEM_HEIGHT 30 +#define ROWS 19 +#define COLUMNS 21 +TableViewNew3D::TableViewNew3D(QWidget *parent) : QWidget(parent) +{ + multiSelect = false; + for (int y=0;y row; + QList highlightrow; + highlightrow.append(0); //For the Y column + for (int x=0;xx() / ITEM_WIDTH; + m_y = evt->y() / ITEM_HEIGHT; + update(); +} +void TableViewNew3D::mousePressEvent(QMouseEvent *evt) +{ + m_x = evt->x() / ITEM_WIDTH; + m_y = evt->y() / ITEM_HEIGHT; + currentCell.setX(m_x); + currentCell.setY(m_y); + /*if (m_highlightList.size() > m_y) + { + if (m_highlightList.at(m_y).size() > m_x) + { + m_highlightList[m_y][m_x] = 1; + } + }*/ + + update(); +} + +void TableViewNew3D::mouseReleaseEvent(QMouseEvent *evt) +{ + Q_UNUSED(evt) +} +void TableViewNew3D::keyPressEvent(QKeyEvent *evt) +{ + if (evt->key() == Qt::Key_Up) + { + if (currentCell.y() > 0) + { + /*if (evt->modifiers() & Qt::ShiftModifier) + { + if (!multiSelect) + { + //No selection yet. + startSelectCell = currentCell; + multiSelect = true; + } + for (int i=) + //Selecting a rectangle + //selection will be + for (int i=0;imodifiers() & Qt::ControlModifier) + { + //Moving selection without clearing + } + else + { + //Deselect everything, and move cursor to new point + for (int i=0;ikey() == Qt::Key_Down) + { + if (currentCell.y() < ROWS) + { + currentCell.setY(currentCell.y()+1); + update(); + return; + } + } + if (evt->key() == Qt::Key_Left) + { + if (currentCell.x() > 0) + { + currentCell.setX(currentCell.x()-1); + update(); + return; + } + } + if (evt->key() == Qt::Key_Right) + { + if (currentCell.x() < COLUMNS) + { + currentCell.setX(currentCell.x()+1); + update(); + return; + } + } + if (evt->key() == Qt::Key_Equal) + { + if (currentCell.x() == 0 && currentCell.y() != 0) + { + //Y Axis + yaxis[currentCell.y()]++; + update(); + return; + } + else if (currentCell.y() == ROWS) + { + xaxis[currentCell.x()-1]++; + update(); + return; + //X Axis + } + values[currentCell.y()][currentCell.x()-1]++; + update(); + return; + } + if (evt->key() == Qt::Key_Minus) + { + if (currentCell.x() == 0 && currentCell.y() != 0) + { + //Y axis + yaxis[currentCell.y()]--; + update(); + return; + } + else if (currentCell.y() == ROWS) + { + //X Axis + xaxis[currentCell.x()-1]--; + update(); + return; + } + values[currentCell.y()][currentCell.x()-1]--; + update(); + return; + } +} diff --git a/core/src/tableviewnew3d.h b/core/src/tableviewnew3d.h new file mode 100644 index 0000000..f2fe509 --- /dev/null +++ b/core/src/tableviewnew3d.h @@ -0,0 +1,32 @@ +#ifndef TABLEVIEWNEW3D_H +#define TABLEVIEWNEW3D_H + +#include + +class TableViewNew3D : public QWidget +{ + Q_OBJECT +public: + explicit TableViewNew3D(QWidget *parent = 0); +private: + void paintEvent (QPaintEvent *evt); + QList xaxis; + QList yaxis; + QList > values; + void mouseMoveEvent(QMouseEvent *evt); + void mousePressEvent(QMouseEvent *evt); + void mouseReleaseEvent(QMouseEvent *evt); + int m_x; + int m_y; + QList > m_highlightList; + void keyPressEvent(QKeyEvent *evt); + QPoint currentCell; + QPoint startSelectCell; + bool multiSelect; +signals: + +public slots: + +}; + +#endif // TABLEVIEWNEW3D_H