|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/spreadsheetviewer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Jeremy Bullock |
807052 |
#include "toonz/preferences.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Jaroslav |
203cc8 |
#include "orientation.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qkeyevent></qkeyevent>
|
|
Toshihiro Shimizu |
890ddd |
#include <qwheelevent></qwheelevent>
|
|
Toshihiro Shimizu |
890ddd |
#include <qlabel></qlabel>
|
|
Campbell Barton |
d0e335 |
#include <qscrollbar></qscrollbar>
|
|
Toshihiro Shimizu |
890ddd |
#include <qpainter></qpainter>
|
|
Toshihiro Shimizu |
890ddd |
#include <qgridlayout></qgridlayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <qpaintevent></qpaintevent>
|
|
Toshihiro Shimizu |
890ddd |
#include <qtooltip></qtooltip>
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h></assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qmainwindow></qmainwindow>
|
|
Toshihiro Shimizu |
890ddd |
#include <qdockwidget></qdockwidget>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace Spreadsheet {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Jaroslav |
203cc8 |
FrameScroller::FrameScroller()
|
|
Jaroslav |
203cc8 |
: m_orientation(Orientations::topToBottom())
|
|
Jaroslav |
203cc8 |
, m_scrollArea(nullptr)
|
|
Jaroslav |
203cc8 |
, m_lastX(0)
|
|
Jaroslav |
203cc8 |
, m_lastY(0)
|
|
shun_iwasawa |
0cae24 |
, m_syncing(false) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
FrameScroller::~FrameScroller() {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Jaroslav |
203cc8 |
void FrameScroller::setFrameScrollArea(QScrollArea *scrollArea) {
|
|
Jaroslav |
203cc8 |
disconnectScrollbars();
|
|
Jaroslav |
203cc8 |
m_scrollArea = scrollArea;
|
|
Jaroslav |
203cc8 |
connectScrollbars();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jaroslav |
203cc8 |
void FrameScroller::disconnectScrollbars() {
|
|
Jaroslav |
203cc8 |
if (!m_scrollArea) return;
|
|
Jaroslav |
203cc8 |
disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this,
|
|
Jaroslav |
203cc8 |
&FrameScroller::onVScroll);
|
|
Jaroslav |
203cc8 |
disconnect(m_scrollArea->horizontalScrollBar(), &QScrollBar::valueChanged,
|
|
Jaroslav |
203cc8 |
this, &FrameScroller::onHScroll);
|
|
Jaroslav |
203cc8 |
}
|
|
Jaroslav |
203cc8 |
|
|
Jaroslav |
203cc8 |
void FrameScroller::connectScrollbars() {
|
|
Jaroslav |
203cc8 |
if (!m_scrollArea) return;
|
|
Jaroslav |
203cc8 |
m_lastX = m_scrollArea->horizontalScrollBar()->value();
|
|
Jaroslav |
203cc8 |
m_lastY = m_scrollArea->verticalScrollBar()->value();
|
|
Jaroslav |
203cc8 |
connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this,
|
|
Jaroslav |
203cc8 |
&FrameScroller::onVScroll);
|
|
Jaroslav |
203cc8 |
connect(m_scrollArea->horizontalScrollBar(), &QScrollBar::valueChanged, this,
|
|
Jaroslav |
203cc8 |
&FrameScroller::onHScroll);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jaroslav |
203cc8 |
void FrameScroller::onVScroll(int y) {
|
|
Jaroslav |
203cc8 |
QPoint offset(0, y - m_lastY);
|
|
Jaroslav |
203cc8 |
if (isSyncing()) return;
|
|
Jaroslav |
203cc8 |
m_lastY = y;
|
|
Jaroslav |
203cc8 |
setSyncing(true);
|
|
Jaroslav |
203cc8 |
handleScroll(offset);
|
|
Jaroslav |
203cc8 |
setSyncing(false);
|
|
Jaroslav |
203cc8 |
}
|
|
Jaroslav |
203cc8 |
void FrameScroller::onHScroll(int x) {
|
|
Jaroslav |
203cc8 |
QPoint offset(x - m_lastX, 0);
|
|
Jaroslav |
203cc8 |
if (isSyncing()) return;
|
|
Jaroslav |
203cc8 |
m_lastX = x;
|
|
Jaroslav |
203cc8 |
setSyncing(true);
|
|
Jaroslav |
203cc8 |
handleScroll(offset);
|
|
Jaroslav |
203cc8 |
setSyncing(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static QList<framescroller *=""> frameScrollers;</framescroller>
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
f643b0 |
void FrameScroller::handleScroll(QPoint &offset) {
|
|
shun_iwasawa |
0cae24 |
if ((m_orientation->isVerticalTimeline() && offset.x()) ||
|
|
shun_iwasawa |
0cae24 |
(!m_orientation->isVerticalTimeline() &&
|
|
shun_iwasawa |
0cae24 |
offset.y())) // only synchronize changes by frames axis
|
|
Jaroslav |
203cc8 |
return;
|
|
Jaroslav |
203cc8 |
|
|
manongjohn |
f643b0 |
// In case of a zoomed viewer is sending this out, adjust the
|
|
manongjohn |
f643b0 |
// zoomed offset back to a standardized offset
|
|
manongjohn |
f643b0 |
emit zoomScrollAdjust(offset, false);
|
|
manongjohn |
f643b0 |
|
|
manongjohn |
f643b0 |
CellPositionRatio ratio = orientation()->xyToPositionRatio(offset);
|
|
manongjohn |
f643b0 |
|
|
Jaroslav |
203cc8 |
for (int i = 0; i < frameScrollers.size(); i++)
|
|
shun_iwasawa |
0cae24 |
if (frameScrollers[i] != this) {
|
|
shun_iwasawa |
0cae24 |
if (!frameScrollers[i]->isSyncing()) {
|
|
shun_iwasawa |
0cae24 |
frameScrollers[i]->onScroll(ratio);
|
|
shun_iwasawa |
0cae24 |
break;
|
|
shun_iwasawa |
0cae24 |
}
|
|
shun_iwasawa |
0cae24 |
}
|
|
Jaroslav |
203cc8 |
}
|
|
Jaroslav |
203cc8 |
|
|
Jaroslav |
203cc8 |
void adjustScrollbar(QScrollBar *scrollBar, int add);
|
|
Jaroslav |
203cc8 |
|
|
Jaroslav |
203cc8 |
void FrameScroller::onScroll(const CellPositionRatio &ratio) {
|
|
Jaroslav |
203cc8 |
QPoint offset = orientation()->positionRatioToXY(ratio);
|
|
manongjohn |
f643b0 |
|
|
manongjohn |
f643b0 |
// In case of a zoomed viewer is receiving this, adjust the
|
|
manongjohn |
f643b0 |
// standardized offset to zoomed offset
|
|
manongjohn |
f643b0 |
emit zoomScrollAdjust(offset, true);
|
|
manongjohn |
f643b0 |
|
|
shun_iwasawa |
22312d |
// scroll area should be resized before moving down the scroll bar.
|
|
shun_iwasawa |
22312d |
// SpreadsheetViewer::onPrepareToScrollOffset() will be invoked immediately
|
|
shun_iwasawa |
22312d |
// since the receiver is in the same thread.
|
|
shun_iwasawa |
22312d |
// when moving up the scroll bar, resizing will be done in
|
|
shun_iwasawa |
22312d |
// SpreadsheetViewer::onVSliderChanged().
|
|
shun_iwasawa |
22312d |
if (offset.x() > 0 || offset.y() > 0) emit prepareToScrollOffset(offset);
|
|
Jaroslav |
203cc8 |
if (offset.x())
|
|
shun_iwasawa |
0cae24 |
adjustScrollbar(m_scrollArea->horizontalScrollBar(), offset.x());
|
|
Jaroslav |
203cc8 |
if (offset.y())
|
|
shun_iwasawa |
0cae24 |
adjustScrollbar(m_scrollArea->verticalScrollBar(), offset.y());
|
|
Jaroslav |
203cc8 |
}
|
|
shun_iwasawa |
22312d |
|
|
Jaroslav |
203cc8 |
void adjustScrollbar(QScrollBar *scrollBar, int add) {
|
|
Jaroslav |
203cc8 |
scrollBar->setValue(scrollBar->value() + add);
|
|
Jaroslav |
203cc8 |
}
|
|
Jaroslav |
203cc8 |
|
|
Shinya Kitaoka |
120a6e |
void FrameScroller::registerFrameScroller() {
|
|
Jaroslav |
203cc8 |
if (!frameScrollers.contains(this)) frameScrollers.append(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FrameScroller::unregisterFrameScroller() {
|
|
Jaroslav |
203cc8 |
if (frameScrollers.contains(this)) frameScrollers.removeAll(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jaroslav |
203cc8 |
void FrameScroller::prepareToScrollOthers(const QPoint &offset) {
|
|
Jaroslav |
203cc8 |
CellPositionRatio ratio = orientation()->xyToPositionRatio(offset);
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < frameScrollers.size(); i++)
|
|
Jaroslav |
203cc8 |
if (frameScrollers[i] != this)
|
|
shun_iwasawa |
0cae24 |
frameScrollers[i]->prepareToScrollRatio(ratio);
|
|
Jaroslav |
203cc8 |
}
|
|
Jaroslav |
203cc8 |
void FrameScroller::prepareToScrollRatio(const CellPositionRatio &ratio) {
|
|
Jaroslav |
203cc8 |
QPoint offset = orientation()->positionRatioToXY(ratio);
|
|
Jaroslav |
203cc8 |
emit prepareToScrollOffset(offset);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SetFrameDragTool::click(int row, int col, QMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
m_frameHandle->setFrame(row);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SetFrameDragTool::drag(int row, int col, QMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
if (row < 0) row = 0;
|
|
Shinya Kitaoka |
120a6e |
m_frameHandle->setFrame(row);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SetFrameDragTool::release(int row, int col, QMouseEvent *e) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// SelectionDragTool
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SelectionDragTool::SelectionDragTool(SpreadsheetViewer *viewer)
|
|
Shinya Kitaoka |
120a6e |
: m_viewer(viewer), m_firstRow(-1), m_firstCol(-1) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SelectionDragTool::click(int row, int col, QMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
m_firstCol = col;
|
|
Shinya Kitaoka |
120a6e |
m_firstRow = row;
|
|
Shinya Kitaoka |
120a6e |
QRect selectedCells(col, row, 1, 1);
|
|
Shinya Kitaoka |
120a6e |
m_viewer->selectCells(selectedCells);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SelectionDragTool::drag(int row, int col, QMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
int r0 = qMin(row, m_firstRow);
|
|
Shinya Kitaoka |
120a6e |
int r1 = qMax(row, m_firstRow);
|
|
Shinya Kitaoka |
120a6e |
int c0 = qMin(col, m_firstCol);
|
|
Shinya Kitaoka |
120a6e |
int c1 = qMax(col, m_firstCol);
|
|
Shinya Kitaoka |
120a6e |
QRect selectedCells(c0, r0, c1 - c0 + 1, r1 - r0 + 1);
|
|
Shinya Kitaoka |
120a6e |
m_viewer->selectCells(selectedCells);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SelectionDragTool::release(int row, int col, QMouseEvent *e) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PanTool::PanTool(Spreadsheet::GenericPanel *panel)
|
|
Shinya Kitaoka |
120a6e |
: m_panel(panel), m_viewer(panel->getViewer()), m_lastPos() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PanTool::click(int row, int col, QMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
m_lastPos = e->pos(); // m_panel->mapToGlobal(e->pos());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Shinya Kitaoka |
120a6e |
void PanTool::drag(int row, int col, QMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
QPoint pos = e->pos(); // m_panel->mapToGlobal(e->pos());
|
|
Shinya Kitaoka |
120a6e |
// QPoint delta = p - m_lastPos;
|
|
Shinya Kitaoka |
120a6e |
// m_lastPos = p;
|
|
Shinya Kitaoka |
120a6e |
// QToolTip::showText(p,"delta="+QString::number(delta.x())+","+QString::number(delta.y()));
|
|
Shinya Kitaoka |
120a6e |
m_viewer->scroll(m_lastPos - pos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Shinya Kitaoka |
120a6e |
void PanTool::release(int row, int col, QMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
// QToolTip::hideText();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050500
|
|
Toshihiro Shimizu |
890ddd |
ScrollArea::ScrollArea(QWidget *parent, Qt::WindowFlags flags)
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
ScrollArea::ScrollArea(QWidget *parent, Qt::WFlags flags)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
: QScrollArea(parent) {
|
|
Shinya Kitaoka |
120a6e |
setFrameStyle(QFrame::Panel | QFrame::Raised);
|
|
Shinya Kitaoka |
120a6e |
setLineWidth(6);
|
|
Shinya Kitaoka |
120a6e |
setContentsMargins(10, 10, 10, 10);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ScrollArea::~ScrollArea() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ScrollArea::keyPressEvent(QKeyEvent *e) { e->ignore(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ScrollArea::wheelEvent(QWheelEvent *e) { e->ignore(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
GenericPanel::GenericPanel(SpreadsheetViewer *viewer)
|
|
Shinya Kitaoka |
120a6e |
: QWidget(viewer), m_viewer(viewer), m_dragTool(0) {
|
|
Shinya Kitaoka |
120a6e |
setFocusPolicy(Qt::NoFocus);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
GenericPanel::~GenericPanel() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void GenericPanel::paintEvent(QPaintEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
QPainter p(this);
|
|
Shinya Kitaoka |
120a6e |
p.setPen(m_viewer->getLightLineColor());
|
|
Shinya Kitaoka |
120a6e |
for (int c = 0;; c++) {
|
|
Shinya Kitaoka |
120a6e |
int x = getViewer()->columnToX(c);
|
|
Shinya Kitaoka |
120a6e |
if (x > width()) break;
|
|
Shinya Kitaoka |
120a6e |
p.drawLine(x, 0, x, height());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
for (int r = 0;; r++) {
|
|
Shinya Kitaoka |
120a6e |
int y = getViewer()->rowToY(r);
|
|
Shinya Kitaoka |
120a6e |
if (y > height()) break;
|
|
Shinya Kitaoka |
120a6e |
p.drawLine(0, y, width(), y);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
p.setPen(Qt::magenta);
|
|
Shinya Kitaoka |
120a6e |
p.drawLine(e->rect().topLeft(), e->rect().bottomRight());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void GenericPanel::mousePressEvent(QMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
assert(!m_dragTool);
|
|
Shinya Kitaoka |
120a6e |
if (e->button() == Qt::MidButton)
|
|
Shinya Kitaoka |
120a6e |
m_dragTool = new PanTool(this);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
m_dragTool = createDragTool(e);
|
|
Shinya Kitaoka |
120a6e |
|
|
Jaroslav |
203cc8 |
CellPosition cellPosition = getViewer()->xyToPosition(e->pos());
|
|
Jaroslav |
203cc8 |
int row = cellPosition.frame();
|
|
Jaroslav |
203cc8 |
int col = cellPosition.layer();
|
|
Shinya Kitaoka |
120a6e |
if (m_dragTool) m_dragTool->click(row, col, e);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void GenericPanel::mouseReleaseEvent(QMouseEvent *e) {
|
|
Jaroslav |
203cc8 |
CellPosition cellPosition = getViewer()->xyToPosition(e->pos());
|
|
Jaroslav |
203cc8 |
int row = cellPosition.frame();
|
|
Jaroslav |
203cc8 |
int col = cellPosition.layer();
|
|
Shinya Kitaoka |
120a6e |
m_viewer->stopAutoPan();
|
|
Shinya Kitaoka |
120a6e |
if (m_dragTool) {
|
|
Shinya Kitaoka |
120a6e |
m_dragTool->release(row, col, e);
|
|
Shinya Kitaoka |
120a6e |
delete m_dragTool;
|
|
Shinya Kitaoka |
120a6e |
m_dragTool = 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void GenericPanel::mouseMoveEvent(QMouseEvent *e) {
|
|
Jaroslav |
203cc8 |
CellPosition cellPosition = getViewer()->xyToPosition(e->pos());
|
|
Jaroslav |
203cc8 |
int row = cellPosition.frame();
|
|
Jaroslav |
203cc8 |
int col = cellPosition.layer();
|
|
Shinya Kitaoka |
120a6e |
if (e->buttons() != 0 && m_dragTool != 0) {
|
|
Shinya Kitaoka |
120a6e |
if ((e->buttons() & Qt::LeftButton) != 0 &&
|
|
Shinya Kitaoka |
120a6e |
!visibleRegion().contains(e->pos())) {
|
|
Shinya Kitaoka |
120a6e |
QRect bounds = visibleRegion().boundingRect();
|
|
Shinya Kitaoka |
120a6e |
m_viewer->setAutoPanSpeed(bounds, e->pos());
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
m_viewer->stopAutoPan();
|
|
Shinya Kitaoka |
120a6e |
m_dragTool->drag(row, col, e);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RowPanel::RowPanel(SpreadsheetViewer *viewer)
|
|
Shinya Kitaoka |
120a6e |
: GenericPanel(viewer), m_xa(12) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DragTool *RowPanel::createDragTool(QMouseEvent *) {
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle *frameHandle = getViewer()->getFrameHandle();
|
|
Shinya Kitaoka |
120a6e |
if (frameHandle)
|
|
Shinya Kitaoka |
120a6e |
return new SetFrameDragTool(frameHandle);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RowPanel::drawRows(QPainter &p, int r0, int r1) {
|
|
Jeremy Bullock |
807052 |
QString fontName = Preferences::instance()->getInterfaceFont();
|
|
Jeremy Bullock |
807052 |
if (fontName == "") {
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Jeremy Bullock |
807052 |
fontName = "Arial";
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Jeremy Bullock |
807052 |
fontName = "Helvetica";
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Jeremy Bullock |
807052 |
}
|
|
Jeremy Bullock |
807052 |
static QFont font(fontName, -1, QFont::Bold);
|
|
shun_iwasawa |
01e417 |
font.setPixelSize(12);
|
|
Shinya Kitaoka |
120a6e |
p.setFont(font);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QRect visibleRect = visibleRegion().boundingRect();
|
|
Shinya Kitaoka |
120a6e |
int x0 = visibleRect.left();
|
|
Shinya Kitaoka |
120a6e |
int x1 = visibleRect.right();
|
|
Shinya Kitaoka |
120a6e |
int y0 = visibleRect.top();
|
|
Shinya Kitaoka |
120a6e |
int y1 = visibleRect.bottom();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int r;
|
|
Shinya Kitaoka |
120a6e |
for (r = r0; r <= r1; r++) {
|
|
Shinya Kitaoka |
120a6e |
int y = getViewer()->rowToY(r);
|
|
Shinya Kitaoka |
120a6e |
// draw horizontal line
|
|
Shinya Kitaoka |
120a6e |
QColor color = (getViewer()->isMarkRow(r))
|
|
Shinya Kitaoka |
120a6e |
? getViewer()->getMarkerLineColor()
|
|
Shinya Kitaoka |
120a6e |
: getViewer()->getLightLineColor();
|
|
Shinya Kitaoka |
120a6e |
p.setPen(color);
|
|
Shinya Kitaoka |
120a6e |
p.drawLine(x0, y, x1, y);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// draw numbers
|
|
Shinya Kitaoka |
120a6e |
p.setPen(getViewer()->getTextColor());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString number = QString::number(r + 1);
|
|
Shinya Kitaoka |
120a6e |
p.drawText(QRect(x0, y + 1, width(), 18),
|
|
Shinya Kitaoka |
120a6e |
Qt::AlignHCenter | Qt::AlignBottom, number);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// erase the marker interval at upper-end
|
|
Shinya Kitaoka |
120a6e |
if (r0 == 0) {
|
|
Shinya Kitaoka |
120a6e |
p.setPen(getViewer()->getLightLineColor());
|
|
Shinya Kitaoka |
120a6e |
p.drawLine(x0, getViewer()->rowToY(0), x1, getViewer()->rowToY(0));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RowPanel::drawCurrentRowGadget(QPainter &p, int r0, int r1) {
|
|
Shinya Kitaoka |
120a6e |
int currentRow = getViewer()->getCurrentRow();
|
|
Shinya Kitaoka |
120a6e |
int y = getViewer()->rowToY(currentRow);
|
|
Shinya Kitaoka |
120a6e |
if (currentRow < r0 || r1 < currentRow) return;
|
|
Shinya Kitaoka |
120a6e |
p.fillRect(1, y + 1, width() - 2, 19, getViewer()->getCurrentRowBgColor());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RowPanel::paintEvent(QPaintEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
QRect toBeUpdated = e->rect();
|
|
Shinya Kitaoka |
120a6e |
QPainter p(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jaroslav |
203cc8 |
CellRange visible = getViewer()->xyRectToRange(toBeUpdated);
|
|
Jaroslav |
203cc8 |
// range of visible rows
|
|
Jaroslav |
203cc8 |
int r0 = visible.from().frame();
|
|
Jaroslav |
203cc8 |
int r1 = visible.to().frame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
p.setClipRect(toBeUpdated);
|
|
Shinya Kitaoka |
120a6e |
p.fillRect(toBeUpdated, QBrush(getViewer()->getLightLightBGColor()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
drawCurrentRowGadget(p, r0, r1);
|
|
Shinya Kitaoka |
120a6e |
drawRows(p, r0, r1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ColumnPanel::ColumnPanel(SpreadsheetViewer *viewer) : GenericPanel(viewer) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
CellPanel::CellPanel(SpreadsheetViewer *viewer) : GenericPanel(viewer) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DragTool *CellPanel::createDragTool(QMouseEvent *) {
|
|
Shinya Kitaoka |
120a6e |
// FunctionSheetCellViewer::createDragTool is called instead
|
|
Shinya Kitaoka |
120a6e |
// when clicking on the CellPanel in NumericalColumns
|
|
Shinya Kitaoka |
120a6e |
return new SelectionDragTool(getViewer());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CellPanel::paintEvent(QPaintEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
QPainter painter(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QRect toBeUpdated = e->rect();
|
|
Shinya Kitaoka |
120a6e |
painter.setClipRect(toBeUpdated);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int x0 = toBeUpdated.left() - 1;
|
|
Shinya Kitaoka |
120a6e |
int y0 = toBeUpdated.top();
|
|
Shinya Kitaoka |
120a6e |
int x1 = toBeUpdated.right(), y1 = toBeUpdated.bottom();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jaroslav |
203cc8 |
QRect alteredRect(QPoint(x0, y0), QPoint(x1, y1));
|
|
Jaroslav |
203cc8 |
CellRange cellRange = getViewer()->xyRectToRange(alteredRect);
|
|
Shinya Kitaoka |
120a6e |
// visible rows range
|
|
Jaroslav |
203cc8 |
int r0 = cellRange.from().frame();
|
|
Jaroslav |
203cc8 |
int r1 = cellRange.to().frame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// visible columns range
|
|
Jaroslav |
203cc8 |
int c0 = cellRange.from().layer();
|
|
Jaroslav |
203cc8 |
int c1 = cellRange.to().layer();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// cambia colore alle celle prima di rowCount()
|
|
Shinya Kitaoka |
120a6e |
int rowCount = getViewer()->getRowCount();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// fill with bg color
|
|
Shinya Kitaoka |
120a6e |
painter.fillRect(toBeUpdated, getViewer()->getLightLightBGColor());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// scene range bg
|
|
Shinya Kitaoka |
120a6e |
int yLast = getViewer()->rowToY(rowCount);
|
|
Shinya Kitaoka |
120a6e |
if (yLast < y1)
|
|
Shinya Kitaoka |
120a6e |
painter.fillRect(x0, y0, x1 - x0, yLast - y0, getViewer()->getBGColor());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
painter.fillRect(toBeUpdated, getViewer()->getBGColor());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// draw cells
|
|
Shinya Kitaoka |
120a6e |
drawCells(painter, r0, c0, r1, c1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// draw columns
|
|
Shinya Kitaoka |
120a6e |
painter.setPen(getViewer()->getVerticalLineColor());
|
|
Shinya Kitaoka |
120a6e |
for (int col = c0; col <= c1; col++) {
|
|
Shinya Kitaoka |
120a6e |
int x = getViewer()->columnToX(col);
|
|
Shinya Kitaoka |
120a6e |
painter.drawLine(x, y0, x, y1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// draw rows
|
|
Shinya Kitaoka |
120a6e |
int currentRow = getViewer()->getCurrentRow();
|
|
Shinya Kitaoka |
120a6e |
for (int r = r0; r <= r1; r++) {
|
|
Shinya Kitaoka |
120a6e |
int y = getViewer()->rowToY(r);
|
|
Shinya Kitaoka |
120a6e |
QColor color = getViewer()->isMarkRow(r) ? getViewer()->getMarkerLineColor()
|
|
Shinya Kitaoka |
120a6e |
: getViewer()->getLightLineColor();
|
|
Shinya Kitaoka |
120a6e |
painter.setPen(color);
|
|
Shinya Kitaoka |
120a6e |
painter.drawLine(x0, y, x1, y);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// erase the marker interval at upper-end
|
|
Shinya Kitaoka |
120a6e |
painter.setPen(getViewer()->getLightLineColor());
|
|
Shinya Kitaoka |
120a6e |
painter.drawLine(x0, 0, x1, 0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace Spreadsheet
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SpreadsheetViewer::SpreadsheetViewer(QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: QFrame(parent)
|
|
Shinya Kitaoka |
120a6e |
, m_columnScrollArea(0)
|
|
Shinya Kitaoka |
120a6e |
, m_rowScrollArea(0)
|
|
Shinya Kitaoka |
120a6e |
, m_cellScrollArea(0)
|
|
Shinya Kitaoka |
120a6e |
, m_frameHandle(0)
|
|
Shinya Kitaoka |
120a6e |
, m_columnWidth(50)
|
|
Shinya Kitaoka |
120a6e |
, m_rowHeight(20)
|
|
Shinya Kitaoka |
120a6e |
, m_timerId(0)
|
|
Shinya Kitaoka |
120a6e |
, m_autoPanSpeed(0, 0)
|
|
Shinya Kitaoka |
120a6e |
, m_lastAutoPanPos(0, 0)
|
|
Shinya Kitaoka |
120a6e |
, m_rowCount(0)
|
|
Shinya Kitaoka |
120a6e |
, m_columnCount(0)
|
|
Shinya Kitaoka |
120a6e |
, m_currentRow(0)
|
|
Shinya Kitaoka |
120a6e |
, m_markRowDistance(6)
|
|
Shinya Kitaoka |
120a6e |
, m_markRowOffset(0)
|
|
Jaroslav |
203cc8 |
, m_isComputingSize(false)
|
|
Jaroslav |
203cc8 |
, m_frameScroller() {
|
|
Jaroslav |
203cc8 |
// m_orientation = Orientations::topToBottom ();
|
|
Jaroslav |
203cc8 |
|
|
Shinya Kitaoka |
120a6e |
setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setFrameStyle(QFrame::StyledPanel);
|
|
Shinya Kitaoka |
120a6e |
setObjectName("Viewer");
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// column header
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea = new Spreadsheet::ScrollArea;
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea->setObjectName("ScrollArea");
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea->setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// row area
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea = new Spreadsheet::ScrollArea;
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->setObjectName("ScrollArea");
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// cell area
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea = new Spreadsheet::ScrollArea;
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->setObjectName("ScrollArea");
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
shun_iwasawa |
ffb2f0 |
// m_cellScrollArea->horizontalScrollBar()->setObjectName("XsheetScrollBar");
|
|
shun_iwasawa |
ffb2f0 |
// m_cellScrollArea->verticalScrollBar()->setObjectName("XsheetScrollBar");
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea->setSizePolicy(
|
|
Shinya Kitaoka |
120a6e |
QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->setSizePolicy(
|
|
Shinya Kitaoka |
120a6e |
QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->setFixedWidth(30);
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea->setFixedHeight(m_rowHeight * 3 - 3);
|
|
Shinya Kitaoka |
120a6e |
// m_columnScrollArea->setFixedHeight(m_rowHeight * 3 + 60 - 63);
|
|
Shinya Kitaoka |
120a6e |
|
|
Jaroslav |
203cc8 |
m_frameScroller.setFrameScrollArea(m_cellScrollArea);
|
|
Jaroslav |
203cc8 |
connect(&m_frameScroller, &Spreadsheet::FrameScroller::prepareToScrollOffset,
|
|
Jaroslav |
203cc8 |
this, &SpreadsheetViewer::onPrepareToScrollOffset);
|
|
Jaroslav |
203cc8 |
|
|
Shinya Kitaoka |
120a6e |
//---- layout
|
|
Shinya Kitaoka |
120a6e |
QGridLayout *layout = new QGridLayout();
|
|
Shinya Kitaoka |
120a6e |
layout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
layout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(m_columnScrollArea, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(m_rowScrollArea, 1, 0);
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(m_cellScrollArea, 1, 1, 2, 2);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun_iwasawa |
ffb2f0 |
int scrollBarWidth = 16;
|
|
Shinya Kitaoka |
120a6e |
// upper-right
|
|
Shinya Kitaoka |
120a6e |
QWidget *w = new QWidget(this);
|
|
shun_iwasawa |
ffb2f0 |
w->setFixedSize(QSize(scrollBarWidth, m_rowHeight * 3 + 60 - 63));
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(w, 0, 2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// lower-left
|
|
Shinya Kitaoka |
120a6e |
w = new QWidget(this);
|
|
shun_iwasawa |
ffb2f0 |
w->setFixedSize(QSize(30, scrollBarWidth));
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(w, 2, 0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
layout->setColumnStretch(0, 0);
|
|
Shinya Kitaoka |
120a6e |
layout->setColumnStretch(1, 1);
|
|
Shinya Kitaoka |
120a6e |
layout->setColumnStretch(2, 0);
|
|
Shinya Kitaoka |
120a6e |
layout->setRowStretch(0, 0);
|
|
Shinya Kitaoka |
120a6e |
layout->setRowStretch(1, 1);
|
|
Shinya Kitaoka |
120a6e |
layout->setRowStretch(2, 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//---signal-slot connections
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// vertical slider: cell <=> row
|
|
Shinya Kitaoka |
120a6e |
connect(m_rowScrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)),
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->verticalScrollBar(), SLOT(setValue(int)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_cellScrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)),
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->verticalScrollBar(), SLOT(setValue(int)));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// horizontal slider: cell <=> column
|
|
Shinya Kitaoka |
120a6e |
connect(m_columnScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->horizontalScrollBar(), SLOT(setValue(int)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_cellScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea->horizontalScrollBar(), SLOT(setValue(int)));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
connect(m_cellScrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onVSliderChanged(int)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_cellScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onHSliderChanged(int)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SpreadsheetViewer::~SpreadsheetViewer() {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::setFrameHandle(TFrameHandle *frameHandle) {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameHandle == frameHandle) return;
|
|
Shinya Kitaoka |
120a6e |
if (m_frameHandle) m_frameHandle->disconnect(this);
|
|
Shinya Kitaoka |
120a6e |
m_frameHandle = frameHandle;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isVisible() && m_frameHandle) {
|
|
Shinya Kitaoka |
120a6e |
connect(m_frameHandle, SIGNAL(frameSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onFrameSwitched()));
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::setRowsPanel(Spreadsheet::RowPanel *rows) {
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->setWidget(rows);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::setColumnsPanel(Spreadsheet::ColumnPanel *columns) {
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea->setWidget(columns);
|
|
Shinya Kitaoka |
120a6e |
// columns->setFixedHeight(200);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::setCellsPanel(Spreadsheet::CellPanel *cells) {
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->setWidget(cells);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::setRowCount(int rowCount) {
|
|
Shinya Kitaoka |
120a6e |
if (m_rowCount != rowCount) {
|
|
Shinya Kitaoka |
120a6e |
m_rowCount = rowCount;
|
|
Shinya Kitaoka |
120a6e |
refreshContentSize(0, 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::setColumnCount(int columnCount) {
|
|
Shinya Kitaoka |
120a6e |
if (m_columnCount != columnCount) {
|
|
Shinya Kitaoka |
120a6e |
m_columnCount = columnCount;
|
|
Shinya Kitaoka |
120a6e |
refreshContentSize(0, 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
tomosu |
de525f |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::scroll(QPoint delta) {
|
|
Shinya Kitaoka |
120a6e |
int x = delta.x();
|
|
Shinya Kitaoka |
120a6e |
int y = delta.y();
|
|
tomosu |
de525f |
|
|
Shinya Kitaoka |
120a6e |
QScrollBar *hSc = m_cellScrollArea->horizontalScrollBar();
|
|
Shinya Kitaoka |
120a6e |
QScrollBar *vSc = m_cellScrollArea->verticalScrollBar();
|
|
tomosu |
de525f |
|
|
Shinya Kitaoka |
120a6e |
int valueH = hSc->value() + x;
|
|
Shinya Kitaoka |
120a6e |
int valueV = vSc->value() + y;
|
|
Shinya Kitaoka |
120a6e |
int maxValueH = hSc->maximum();
|
|
Shinya Kitaoka |
120a6e |
int maxValueV = vSc->maximum();
|
|
tomosu |
de525f |
|
|
Shinya Kitaoka |
120a6e |
bool notUpdateSizeH = maxValueH > valueH && x >= 0;
|
|
Shinya Kitaoka |
120a6e |
bool notUpdateSizeV = maxValueV > valueV && y >= 0;
|
|
Shinya Kitaoka |
120a6e |
if ((!notUpdateSizeH) && (!notUpdateSizeV))
|
|
Shinya Kitaoka |
120a6e |
refreshContentSize(x, y);
|
|
Shinya Kitaoka |
120a6e |
else if (notUpdateSizeH && !notUpdateSizeV)
|
|
Shinya Kitaoka |
120a6e |
refreshContentSize(0, y);
|
|
Shinya Kitaoka |
120a6e |
else if (!notUpdateSizeH && notUpdateSizeV)
|
|
Shinya Kitaoka |
120a6e |
refreshContentSize(x, 0);
|
|
tomosu |
de525f |
|
|
Shinya Kitaoka |
120a6e |
if (valueH > maxValueH && x > 0) valueH = hSc->maximum();
|
|
tomosu |
de525f |
|
|
Shinya Kitaoka |
120a6e |
if (valueV > maxValueV && y > 0) valueV = vSc->maximum();
|
|
tomosu |
de525f |
|
|
Shinya Kitaoka |
120a6e |
hSc->setValue(valueH);
|
|
Shinya Kitaoka |
120a6e |
vSc->setValue(valueV);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jaroslav |
203cc8 |
void SpreadsheetViewer::onPrepareToScrollOffset(const QPoint &offset) {
|
|
shun_iwasawa |
0cae24 |
refreshContentSize(offset.x(), offset.y());
|
|
Jaroslav |
203cc8 |
}
|
|
Jaroslav |
203cc8 |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::setAutoPanSpeed(const QPoint &speed) {
|
|
Shinya Kitaoka |
120a6e |
bool wasAutoPanning = isAutoPanning();
|
|
Shinya Kitaoka |
120a6e |
m_autoPanSpeed = speed;
|
|
Shinya Kitaoka |
120a6e |
if (isAutoPanning() && !wasAutoPanning && m_timerId == 0)
|
|
Shinya Kitaoka |
120a6e |
m_timerId = startTimer(40);
|
|
Shinya Kitaoka |
120a6e |
else if (!isAutoPanning() && wasAutoPanning && m_timerId != 0) {
|
|
Shinya Kitaoka |
120a6e |
killTimer(m_timerId);
|
|
Shinya Kitaoka |
120a6e |
m_timerId = 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
ccd505 |
static int getAutoPanSpeed(int pixels) {
|
|
Shinya Kitaoka |
120a6e |
int f = 40;
|
|
Shinya Kitaoka |
120a6e |
return std::min(100, (f - 1 + pixels * f) / 100);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::setAutoPanSpeed(const QRect &widgetBounds,
|
|
Shinya Kitaoka |
120a6e |
const QPoint &mousePos) {
|
|
Shinya Kitaoka |
120a6e |
QPoint speed;
|
|
Shinya Kitaoka |
120a6e |
int limit = 100, factor = 30;
|
|
Shinya Kitaoka |
120a6e |
if (mousePos.x() < widgetBounds.left())
|
|
Shinya Kitaoka |
120a6e |
speed.setX(-getAutoPanSpeed(widgetBounds.left() - mousePos.x()));
|
|
Shinya Kitaoka |
120a6e |
else if (mousePos.x() > widgetBounds.right())
|
|
Shinya Kitaoka |
120a6e |
speed.setX(getAutoPanSpeed(mousePos.x() - widgetBounds.right()));
|
|
Shinya Kitaoka |
120a6e |
if (mousePos.y() < widgetBounds.top())
|
|
Shinya Kitaoka |
120a6e |
speed.setY(-getAutoPanSpeed(widgetBounds.top() - mousePos.y()));
|
|
Shinya Kitaoka |
120a6e |
else if (mousePos.y() > widgetBounds.bottom())
|
|
Shinya Kitaoka |
120a6e |
speed.setY(getAutoPanSpeed(mousePos.y() - widgetBounds.bottom()));
|
|
Shinya Kitaoka |
120a6e |
setAutoPanSpeed(speed);
|
|
Shinya Kitaoka |
120a6e |
m_lastAutoPanPos = mousePos;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int SpreadsheetViewer::xToColumn(int x) const {
|
|
Jaroslav |
203cc8 |
CellPosition pos = xyToPosition(QPoint(x, 0));
|
|
Jaroslav |
203cc8 |
return pos.layer();
|
|
Jaroslav |
203cc8 |
}
|
|
Jaroslav |
203cc8 |
int SpreadsheetViewer::yToRow(int y) const {
|
|
Jaroslav |
203cc8 |
CellPosition pos = xyToPosition(QPoint(0, y));
|
|
Jaroslav |
203cc8 |
return pos.frame();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Shinya Kitaoka |
120a6e |
int SpreadsheetViewer::columnToX(int col) const {
|
|
Jaroslav |
203cc8 |
QPoint xy = positionToXY(CellPosition(0, col));
|
|
Jaroslav |
203cc8 |
return xy.x();
|
|
Jaroslav |
203cc8 |
}
|
|
Jaroslav |
203cc8 |
int SpreadsheetViewer::rowToY(int row) const {
|
|
Jaroslav |
203cc8 |
QPoint xy = positionToXY(CellPosition(row, 0));
|
|
Jaroslav |
203cc8 |
return xy.y();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!Shift is a consequence of style sheet border.*/
|
|
Jaroslav |
203cc8 |
CellPosition SpreadsheetViewer::xyToPosition(const QPoint &point) const {
|
|
Jaroslav |
203cc8 |
int row = (point.y() + 1) / m_rowHeight;
|
|
Jaroslav |
203cc8 |
int col = (point.x() + 1) / m_columnWidth;
|
|
Jaroslav |
203cc8 |
return CellPosition(row, col);
|
|
Jaroslav |
203cc8 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!Shift is a consequence of style sheet border.*/
|
|
Jaroslav |
203cc8 |
QPoint SpreadsheetViewer::positionToXY(const CellPosition &pos) const {
|
|
Jaroslav |
203cc8 |
int x = (pos.layer() * m_columnWidth) - 1;
|
|
Jaroslav |
203cc8 |
int y = (pos.frame() * m_rowHeight) - 1;
|
|
Jaroslav |
203cc8 |
return QPoint(x, y);
|
|
Jaroslav |
203cc8 |
}
|
|
Jaroslav |
203cc8 |
|
|
Jaroslav |
203cc8 |
CellRange SpreadsheetViewer::xyRectToRange(const QRect &rect) const {
|
|
Jaroslav |
203cc8 |
CellPosition topLeft = xyToPosition(rect.topLeft());
|
|
Jaroslav |
203cc8 |
CellPosition bottomRight = xyToPosition(rect.bottomRight());
|
|
Jaroslav |
203cc8 |
return CellRange(topLeft, bottomRight);
|
|
Jaroslav |
203cc8 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool SpreadsheetViewer::refreshContentSize(int scrollDx, int scrollDy) {
|
|
Shinya Kitaoka |
120a6e |
QSize viewportSize = m_cellScrollArea->viewport()->size();
|
|
Shinya Kitaoka |
120a6e |
QPoint offset = m_cellScrollArea->widget()->pos();
|
|
Shinya Kitaoka |
120a6e |
offset =
|
|
Shinya Kitaoka |
120a6e |
QPoint(qMin(0, offset.x() - scrollDx), qMin(0, offset.y() - scrollDy));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QSize contentSize(columnToX(m_columnCount + 1), rowToY(m_rowCount + 1));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QSize actualSize(contentSize);
|
|
Shinya Kitaoka |
120a6e |
int x = viewportSize.width() - offset.x();
|
|
Shinya Kitaoka |
120a6e |
int y = viewportSize.height() - offset.y();
|
|
Shinya Kitaoka |
120a6e |
if (x > actualSize.width()) actualSize.setWidth(x);
|
|
Shinya Kitaoka |
120a6e |
if (y > actualSize.height()) actualSize.setHeight(y);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (actualSize == m_cellScrollArea->widget()->size())
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
m_isComputingSize = true;
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->widget()->setFixedSize(actualSize);
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->widget()->setFixedSize(
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->viewport()->width(), actualSize.height());
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea->widget()->setFixedSize(
|
|
Shinya Kitaoka |
120a6e |
actualSize.width(), m_columnScrollArea->viewport()->height());
|
|
Shinya Kitaoka |
120a6e |
m_isComputingSize = false;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::showEvent(QShowEvent *) {
|
|
Shinya Kitaoka |
120a6e |
int viewportHeight = m_cellScrollArea->height();
|
|
Shinya Kitaoka |
120a6e |
int contentHeight = rowToY(m_rowCount * 0 + 50);
|
|
Shinya Kitaoka |
120a6e |
QScrollBar *vSc = m_cellScrollArea->verticalScrollBar();
|
|
Shinya Kitaoka |
120a6e |
int actualContentHeight = qMax(contentHeight, vSc->value() + viewportHeight);
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->widget()->setFixedHeight(actualContentHeight);
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->widget()->setFixedHeight(actualContentHeight);
|
|
Shinya Kitaoka |
120a6e |
if (m_frameHandle)
|
|
Shinya Kitaoka |
120a6e |
connect(m_frameHandle, SIGNAL(frameSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onFrameSwitched()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// updateAreasSize();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::hideEvent(QHideEvent *) {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameHandle) m_frameHandle->disconnect(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::resizeEvent(QResizeEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
QFrame::resizeEvent(e);
|
|
Shinya Kitaoka |
120a6e |
refreshContentSize(0, 0);
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
int w = width();
|
|
Shinya Kitaoka |
120a6e |
int h = height();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int hSpacing = 4;
|
|
Shinya Kitaoka |
120a6e |
int vSpacing = 4;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int x = m_rowScrollAreaWidth + hSpacing;
|
|
Shinya Kitaoka |
120a6e |
int y = m_columnScrollAreaHeight + vSpacing;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->setGeometry(x,y, w-x, h-y);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int sh = m_cellScrollArea->horizontalScrollBar()->height();
|
|
Shinya Kitaoka |
120a6e |
int sw = m_cellScrollArea->verticalScrollBar()->width();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_columnScrollArea->setGeometry(x, 0, w-x-sw, m_columnScrollAreaHeight);
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->setGeometry(0, y, m_rowScrollAreaWidth, h-y-sh);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
updateSizeToScroll(0,0); //Non updateAreeSize() perche' si deve tener conto
|
|
Shinya Kitaoka |
120a6e |
degli scrollbar.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::wheelEvent(QWheelEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
switch (event->source()) {
|
|
Shinya Kitaoka |
120a6e |
case Qt::MouseEventNotSynthesized: {
|
|
Shinya Kitaoka |
120a6e |
if (event->angleDelta().x() == 0) { // vertical scroll
|
|
Shinya Kitaoka |
120a6e |
int scrollPixels = (event->angleDelta().y() > 0 ? 1 : -1) *
|
|
Shinya Kitaoka |
120a6e |
m_markRowDistance * m_rowHeight;
|
|
Shinya Kitaoka |
120a6e |
scroll(QPoint(0, -scrollPixels));
|
|
Shinya Kitaoka |
120a6e |
} else { // horizontal scroll
|
|
Shinya Kitaoka |
120a6e |
int scrollPixels = (event->angleDelta().x() > 0 ? 1 : -1) * m_columnWidth;
|
|
Shinya Kitaoka |
120a6e |
scroll(QPoint(-scrollPixels, 0));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case Qt::MouseEventSynthesizedBySystem: // macbook touch-pad
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
QPoint numPixels = event->pixelDelta();
|
|
Shinya Kitaoka |
120a6e |
QPoint numDegrees = event->angleDelta() / 8;
|
|
Shinya Kitaoka |
120a6e |
if (!numPixels.isNull()) {
|
|
Shinya Kitaoka |
120a6e |
scroll(-numPixels);
|
|
Shinya Kitaoka |
120a6e |
} else if (!numDegrees.isNull()) {
|
|
Shinya Kitaoka |
120a6e |
QPoint numSteps = numDegrees / 15;
|
|
Shinya Kitaoka |
120a6e |
scroll(-numSteps);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
default: // Qt::MouseEventSynthesizedByQt,
|
|
Shinya Kitaoka |
120a6e |
// Qt::MouseEventSynthesizedByApplication
|
|
Shinya Kitaoka |
38fd86 |
{
|
|
Shinya Kitaoka |
38fd86 |
std::cout << "not supported wheelEvent.source(): "
|
|
Shinya Kitaoka |
38fd86 |
"Qt::MouseEventSynthesizedByQt, "
|
|
Shinya Kitaoka |
38fd86 |
"Qt::MouseEventSynthesizedByApplication"
|
|
Shinya Kitaoka |
38fd86 |
<< std::endl;
|
|
Shinya Kitaoka |
38fd86 |
break;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
} // end switch
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::timerEvent(QTimerEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
if (!isAutoPanning()) return;
|
|
Shinya Kitaoka |
120a6e |
scroll(m_autoPanSpeed);
|
|
Shinya Kitaoka |
120a6e |
m_lastAutoPanPos += m_autoPanSpeed;
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
if(m_dragTool)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
QMouseEvent mouseEvent(QEvent::MouseMove, m_lastAutoPanPos, Qt::NoButton, 0, 0);
|
|
Shinya Kitaoka |
120a6e |
m_dragTool->onDrag(&mouseEvent);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::keyPressEvent(QKeyEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
int frameCount = m_rowCount;
|
|
Shinya Kitaoka |
120a6e |
int row = m_frameHandle->getFrame();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (e->key() == Qt::Key_Up &&
|
|
Shinya Kitaoka |
120a6e |
row > 0) { // Row = frame precedente a quello settato
|
|
Shinya Kitaoka |
120a6e |
m_frameHandle->setFrame(row - 1);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
} else if (e->key() ==
|
|
Shinya Kitaoka |
120a6e |
Qt::Key_Down) { // Row = frame successivo a quello settato
|
|
Shinya Kitaoka |
120a6e |
m_frameHandle->setFrame(row + 1);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
} else if (e->key() == '0') {
|
|
Shinya Kitaoka |
120a6e |
QWidget *panel = parentWidget();
|
|
Shinya Kitaoka |
120a6e |
QWidget *panelParent = panel->parentWidget();
|
|
Shinya Kitaoka |
120a6e |
while (panelParent != 0 && dynamic_cast<qmainwindow *="">(panelParent) == 0) {</qmainwindow>
|
|
Shinya Kitaoka |
120a6e |
panel = panelParent;
|
|
Shinya Kitaoka |
120a6e |
panelParent = panel->parentWidget();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (panelParent) {
|
|
Shinya Kitaoka |
120a6e |
QList<qdockwidget *=""> panels = panelParent->findChildren<qdockwidget *="">();</qdockwidget></qdockwidget>
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < panels.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
QWidget *w = panels[i];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int y = 0;
|
|
Shinya Kitaoka |
120a6e |
QRect visibleRect =
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->widget()->visibleRegion().boundingRect();
|
|
Shinya Kitaoka |
120a6e |
int visibleRowCount = visibleRect.height() / m_rowHeight;
|
|
Shinya Kitaoka |
120a6e |
if (e->key() ==
|
|
Shinya Kitaoka |
120a6e |
Qt::Key_PageUp) // Setto la visualizzazione della pagina precedente
|
|
Shinya Kitaoka |
120a6e |
y = visibleRect.top() - (visibleRowCount + 1) * m_rowHeight;
|
|
Shinya Kitaoka |
120a6e |
else if (e->key() == Qt::Key_PageDown) // Setto la visualizzazione della
|
|
Shinya Kitaoka |
120a6e |
// pagina successiva
|
|
Shinya Kitaoka |
120a6e |
y = visibleRect.bottom() + (visibleRowCount + 1) * m_rowHeight;
|
|
Shinya Kitaoka |
120a6e |
else if (e->key() == Qt::Key_Home)
|
|
Shinya Kitaoka |
120a6e |
y = 0;
|
|
Shinya Kitaoka |
120a6e |
else if (e->key() == Qt::Key_End)
|
|
Shinya Kitaoka |
120a6e |
y = (frameCount + 1) * m_rowHeight;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int deltaY = 0;
|
|
Shinya Kitaoka |
120a6e |
if (y < visibleRect.top())
|
|
Shinya Kitaoka |
120a6e |
deltaY = y - visibleRect.top();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
deltaY = y - visibleRect.bottom();
|
|
Shinya Kitaoka |
120a6e |
scroll(QPoint(0, deltaY));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::frameSwitched() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
void SpreadsheetViewer::updateAllAree()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void SpreadsheetViewer::updateCellColumnAree()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void SpreadsheetViewer::updateCellRowAree()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::updateAreas() {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::onVSliderChanged(int) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_isComputingSize) refreshContentSize(0, 0);
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
QScrollBar *vSc = m_cellScrollArea->verticalScrollBar();
|
|
Shinya Kitaoka |
120a6e |
int h = qMax(vSc->value() + m_cellScrollArea->height(), rowToY(getRowCount()));
|
|
Shinya Kitaoka |
120a6e |
if(m_cellScrollArea->widget())
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->widget()->setFixedHeight(h);
|
|
Shinya Kitaoka |
120a6e |
if(m_rowScrollArea->widget())
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->widget()->setFixedHeight(h);
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
int viewportHeight = m_cellScrollArea->height();
|
|
Shinya Kitaoka |
120a6e |
int contentHeight = rowToY(m_rowCount*0 + 50);
|
|
Shinya Kitaoka |
120a6e |
QScrollBar *vSc = m_cellScrollArea->verticalScrollBar();
|
|
Shinya Kitaoka |
120a6e |
int actualContentHeight = qMax(contentHeight, vSc->value() + viewportHeight);
|
|
Shinya Kitaoka |
120a6e |
m_rowScrollArea->widget()->setFixedHeight(actualContentHeight);
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->widget()->setFixedHeight(actualContentHeight);
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::onHSliderChanged(int) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_isComputingSize) refreshContentSize(0, 0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpreadsheetViewer::ensureVisibleCol(int col) {
|
|
Shinya Kitaoka |
120a6e |
int x = columnToX(col) + m_columnWidth / 2;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int vertValue = m_cellScrollArea->verticalScrollBar()->value();
|
|
Shinya Kitaoka |
120a6e |
m_cellScrollArea->ensureVisible(x, vertValue, m_columnWidth / 2, 0);
|
|
Toshihiro Shimizu |
890ddd |
}
|