Skip to content
Commits on Source (4)
...@@ -94,6 +94,7 @@ class OE_controller ...@@ -94,6 +94,7 @@ class OE_controller
bool selectStitch(OE_stitchs* stitch, bool replace); bool selectStitch(OE_stitchs* stitch, bool replace);
bool selectStitches(std::list<OE_stitchs*> stitches, bool replace); bool selectStitches(std::list<OE_stitchs*> stitches, bool replace);
bool selectStitches(std::list<int> stitchesId, bool replace);
bool unselectStitches(std::list<OE_stitchs*> stitches); bool unselectStitches(std::list<OE_stitchs*> stitches);
bool clearSelectStitches(); bool clearSelectStitches();
bool clearSelection(); bool clearSelection();
......
...@@ -47,6 +47,7 @@ class OE_interfaceDisplay : public OE_display ...@@ -47,6 +47,7 @@ class OE_interfaceDisplay : public OE_display
virtual bool setDocument(OE_document* document); virtual bool setDocument(OE_document* document);
virtual bool setController(OE_controller* controller); virtual bool setController(OE_controller* controller);
OE_document* getDocument(); OE_document* getDocument();
OE_controller* getController();
virtual void showAll(); virtual void showAll();
...@@ -118,7 +119,11 @@ class OE_interfaceDisplay : public OE_display ...@@ -118,7 +119,11 @@ class OE_interfaceDisplay : public OE_display
bool run; bool run;
public slots:
void SetSelectedStitchPattern(int index);
signals: signals:
void stitchSelectionChange();
void refreshStitchList(); void refreshStitchList();
void refreshStitch(OE_stitchs* stitch); void refreshStitch(OE_stitchs* stitch);
......
...@@ -379,6 +379,26 @@ bool OE_controller::selectStitches(std::list<OE_stitchs*> stitches, bool replace ...@@ -379,6 +379,26 @@ bool OE_controller::selectStitches(std::list<OE_stitchs*> stitches, bool replace
return false; return false;
} }
bool OE_controller::selectStitches(std::list<int> stitchesId, bool replace)
{
if (document)
{
std::list<OE_stitchs*> stitches;
std::list<int>::iterator stitchId = stitchesId.begin();
while (stitchId != stitchesId.end())
{
auto l_front = document->stitchs.begin();
std::advance(l_front, *stitchId);
stitches.push_back(*l_front);
stitchId++;
}
addAction(new OE_actionSelectionAddStitches(document, stitches, replace));
return true;
}
return false;
}
bool OE_controller::unselectStitches(std::list<OE_stitchs*> stitches) bool OE_controller::unselectStitches(std::list<OE_stitchs*> stitches)
{ {
if (document) if (document)
......
...@@ -81,6 +81,11 @@ OE_document* OE_interfaceDisplay::getDocument() ...@@ -81,6 +81,11 @@ OE_document* OE_interfaceDisplay::getDocument()
return document; return document;
} }
OE_controller* OE_interfaceDisplay::getController()
{
return controller;
}
bool OE_interfaceDisplay::setController(OE_controller* controller) bool OE_interfaceDisplay::setController(OE_controller* controller)
{ {
...@@ -113,7 +118,8 @@ bool OE_interfaceDisplay::mouse_Pos(double x, double y) ...@@ -113,7 +118,8 @@ bool OE_interfaceDisplay::mouse_Pos(double x, double y)
{ {
vector_2d bbCenter = controller->getSelectionBoundingBox().getCenter(); vector_2d bbCenter = controller->getSelectionBoundingBox().getCenter();
float scale = (absMouse-bbCenter).len()/(screenToDocument(clicOldMouse)-bbCenter).len(); float scale = (absMouse-bbCenter).len()/(screenToDocument(clicOldMouse)-bbCenter).len();
controller->editActionScaleSelection(vector_2d(scale,scale)); controller->editActionScaleSelection(vector_2d(scale,scale));
emit refreshStitchList();
return true; return true;
} }
...@@ -137,8 +143,9 @@ bool OE_interfaceDisplay::mouse_Pos(double x, double y) ...@@ -137,8 +143,9 @@ bool OE_interfaceDisplay::mouse_Pos(double x, double y)
if (editionState == MovePointstitch) //if we're moving a linkstitch control point if (editionState == MovePointstitch) //if we're moving a linkstitch control point
{ {
controller->editActionMovePointLinkStitch(absMove); controller->editActionMovePointLinkStitch(absMove);
controller->editActionMoveGridPointFillStitch(absMove); controller->editActionMoveGridPointFillStitch(absMove);
return true; emit refreshStitchList();
return true;
} }
//if we're editing the scaleWidth of a linestitch //if we're editing the scaleWidth of a linestitch
...@@ -153,22 +160,24 @@ bool OE_interfaceDisplay::mouse_Pos(double x, double y) ...@@ -153,22 +160,24 @@ bool OE_interfaceDisplay::mouse_Pos(double x, double y)
{ {
editionState = TraceSubcurve; editionState = TraceSubcurve;
if (oldClosestPoint.t>editClosestPoint.t) controller->editActionAddSubcurvePosSwitchDir(); if (oldClosestPoint.t>editClosestPoint.t) controller->editActionAddSubcurvePosSwitchDir();
redraw = true; redraw = true;
emit refreshStitchList();
} }
if (editionState == TraceSubcurve) if (editionState == TraceSubcurve)
{ {
controller->editActionAddSubcurvePosEnd(editClosestPoint.t); controller->editActionAddSubcurvePosEnd(editClosestPoint.t);
redraw = true; redraw = true;
emit refreshStitchList();
} }
else if (editionState == MoveSubcurve) else if (editionState == MoveSubcurve)
{ {
controller->editActionSetSubcurvePos(editClosestPoint.t); controller->editActionSetSubcurvePos(editClosestPoint.t);
redraw = true; redraw = true;
} emit refreshStitchList();
if (redraw) }
refreshStitchList();
return redraw; return redraw;
} }
...@@ -283,11 +292,13 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -283,11 +292,13 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
{ {
controller->editActionAddSubcurvePosSwitchDir(); controller->editActionAddSubcurvePosSwitchDir();
update(); update();
emit refreshStitchList();
} }
else if (editionState == MoveSubcurve) else if (editionState == MoveSubcurve)
{ {
controller->editActionSetSubcurvePosSwitchDir(); controller->editActionSetSubcurvePosSwitchDir();
update(); update();
emit refreshStitchList();
} }
} }
if(editionState==None) if(editionState==None)
...@@ -298,6 +309,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -298,6 +309,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
{ {
controller->undoAction(); controller->undoAction();
update(); update();
emit refreshStitchList();
} }
} }
else if (event->key() == Qt::Key_S && event->modifiers() == Qt::ControlModifier) else if (event->key() == Qt::Key_S && event->modifiers() == Qt::ControlModifier)
...@@ -319,6 +331,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -319,6 +331,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
{ {
loadFile(fileName.toStdString()); loadFile(fileName.toStdString());
update(); update();
emit refreshStitchList();
} }
} }
else if (event->key() == Qt::Key_Z && event->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier)) else if (event->key() == Qt::Key_Z && event->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier))
...@@ -327,6 +340,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -327,6 +340,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
{ {
controller->redoAction(); controller->redoAction();
update(); update();
emit refreshStitchList();
} }
} }
else if (event->modifiers() == Qt::NoModifier) else if (event->modifiers() == Qt::NoModifier)
...@@ -337,6 +351,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -337,6 +351,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
{ {
controller->toggleCloseSelectedCurve(); controller->toggleCloseSelectedCurve();
update(); update();
emit refreshStitchList();
} }
} }
else if (event->key() == Qt::Key_Delete) else if (event->key() == Qt::Key_Delete)
...@@ -345,6 +360,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -345,6 +360,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
std::list<OE_stitchs*>::iterator it=selectedStitches.begin(); std::list<OE_stitchs*>::iterator it=selectedStitches.begin();
controller->addAction(new OE_actionDelStitch(document, *it)); controller->addAction(new OE_actionDelStitch(document, *it));
update(); update();
emit refreshStitchList();
} }
else if (event->key() == Qt::Key_Right) else if (event->key() == Qt::Key_Right)
{ {
...@@ -358,7 +374,8 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -358,7 +374,8 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
selectedStitches.clear(); selectedStitches.clear();
selectedStitches.push_back(*it); selectedStitches.push_back(*it);
controller->clearSelection(); controller->clearSelection();
controller->selectStitches(selectedStitches,true); controller->selectStitches(selectedStitches,true);
emit stitchSelectionChange();
update(); update();
} }
} }
...@@ -375,7 +392,8 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -375,7 +392,8 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
selectedStitches.clear(); selectedStitches.clear();
selectedStitches.push_back(*it); selectedStitches.push_back(*it);
controller->clearSelection(); controller->clearSelection();
controller->selectStitches(selectedStitches,true); controller->selectStitches(selectedStitches,true);
emit stitchSelectionChange();
update(); update();
} }
} }
...@@ -391,12 +409,14 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -391,12 +409,14 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
if (editionState == TraceSubcurve) if (editionState == TraceSubcurve)
{ {
controller->editActionAddSubcurvePosSwitchDir(); controller->editActionAddSubcurvePosSwitchDir();
update(); update();
emit refreshStitchList();
} }
else if (editionState == MoveSubcurve) else if (editionState == MoveSubcurve)
{ {
controller->editActionSetSubcurvePosSwitchDir(); controller->editActionSetSubcurvePosSwitchDir();
update(); update();
emit refreshStitchList();
} }
} }
if(editionState==None) if(editionState==None)
...@@ -493,6 +513,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -493,6 +513,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
{ {
controller->addAction(new OE_actionScaleSelectedStitchLen(document, 1.1f)); controller->addAction(new OE_actionScaleSelectedStitchLen(document, 1.1f));
update(); update();
emit refreshStitchList();
} }
else else
{ {
...@@ -506,6 +527,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -506,6 +527,7 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
{ {
controller->addAction(new OE_actionScaleSelectedStitchLen(document, 1.f/1.1f)); controller->addAction(new OE_actionScaleSelectedStitchLen(document, 1.f/1.1f));
update(); update();
emit refreshStitchList();
} }
else else
{ {
...@@ -514,49 +536,40 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -514,49 +536,40 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
} }
} }
else if (event->key() == Qt::Key_1 && event->modifiers() & Qt::KeypadModifier) else if (event->key() == Qt::Key_1 && event->modifiers() & Qt::KeypadModifier)
{ {
controller->addAction(new OE_actionSetSelectedStitchPattern(document, controller->getPattern(0))); SetSelectedStitchPattern(0);
update();
} }
else if (event->key() == Qt::Key_2 && event->modifiers() & Qt::KeypadModifier) else if (event->key() == Qt::Key_2 && event->modifiers() & Qt::KeypadModifier)
{ {
controller->addAction(new OE_actionSetSelectedStitchPattern(document, controller->getPattern(1))); SetSelectedStitchPattern(1);
update();
} }
else if (event->key() == Qt::Key_3 && event->modifiers() & Qt::KeypadModifier) else if (event->key() == Qt::Key_3 && event->modifiers() & Qt::KeypadModifier)
{ {
controller->addAction(new OE_actionSetSelectedStitchPattern(document, controller->getPattern(2))); SetSelectedStitchPattern(2);
update();
} }
else if (event->key() == Qt::Key_4 && event->modifiers() & Qt::KeypadModifier) else if (event->key() == Qt::Key_4 && event->modifiers() & Qt::KeypadModifier)
{ {
controller->addAction(new OE_actionSetSelectedStitchPattern(document, controller->getPattern(3))); SetSelectedStitchPattern(3);
update();
} }
else if (event->key() == Qt::Key_5 && event->modifiers() & Qt::KeypadModifier) else if (event->key() == Qt::Key_5 && event->modifiers() & Qt::KeypadModifier)
{ {
controller->addAction(new OE_actionSetSelectedStitchPattern(document, controller->getPattern(4))); SetSelectedStitchPattern(4);
update();
} }
else if (event->key() == Qt::Key_6 && event->modifiers() & Qt::KeypadModifier) else if (event->key() == Qt::Key_6 && event->modifiers() & Qt::KeypadModifier)
{ {
controller->addAction(new OE_actionSetSelectedStitchPattern(document, controller->getPattern(5))); SetSelectedStitchPattern(5);
update();
} }
else if (event->key() == Qt::Key_7 && event->modifiers() & Qt::KeypadModifier) else if (event->key() == Qt::Key_7 && event->modifiers() & Qt::KeypadModifier)
{ {
controller->addAction(new OE_actionSetSelectedStitchPattern(document, controller->getPattern(6))); SetSelectedStitchPattern(6);
update();
} }
else if (event->key() == Qt::Key_8 && event->modifiers() & Qt::KeypadModifier) else if (event->key() == Qt::Key_8 && event->modifiers() & Qt::KeypadModifier)
{ {
controller->addAction(new OE_actionSetSelectedStitchPattern(document, controller->getPattern(7))); SetSelectedStitchPattern(7);
update();
} }
else if (event->key() == Qt::Key_9 && event->modifiers() & Qt::KeypadModifier) else if (event->key() == Qt::Key_9 && event->modifiers() & Qt::KeypadModifier)
{ {
controller->addAction(new OE_actionSetSelectedStitchPattern(document, controller->getPattern(8))); SetSelectedStitchPattern(8);
update();
} }
if (event->key() == Qt::Key_Home) if (event->key() == Qt::Key_Home)
...@@ -568,6 +581,15 @@ void OE_interfaceDisplay::key(QKeyEvent* event) ...@@ -568,6 +581,15 @@ void OE_interfaceDisplay::key(QKeyEvent* event)
} }
} }
void OE_interfaceDisplay::SetSelectedStitchPattern(int index)
{
if (!controller->getPattern(index))
return;
controller->addAction(new OE_actionSetSelectedStitchPattern(document, controller->getPattern(index)));
update();
emit refreshStitchList();
}
void OE_interfaceDisplay::selectBox() void OE_interfaceDisplay::selectBox()
{ {
selectedCurves.clear(); selectedCurves.clear();
...@@ -602,6 +624,7 @@ void OE_interfaceDisplay::selectBox() ...@@ -602,6 +624,7 @@ void OE_interfaceDisplay::selectBox()
} }
stitch++; stitch++;
} }
emit stitchSelectionChange();
} }
bool OE_interfaceDisplay::checkJoinCurveControl(OE_joincurve* joinCurve, int &index) bool OE_interfaceDisplay::checkJoinCurveControl(OE_joincurve* joinCurve, int &index)
...@@ -659,7 +682,7 @@ bool OE_interfaceDisplay::checkPicking() ...@@ -659,7 +682,7 @@ bool OE_interfaceDisplay::checkPicking()
if (tmpLineStitch) if (tmpLineStitch)
{ {
// check generic joinCurve controls // check generic joinCurve controls
if (checkJoinCurveControl(tmpLineStitch->getJoincurve(), ControlTypeIndex)) return true; if (checkJoinCurveControl(tmpLineStitch->getJoincurve(), ControlTypeIndex)) return true;
//check picking for linestitch width controller //check picking for linestitch width controller
if (selControlType == ControlTypeIndex && selControlIndex == 0) if (selControlType == ControlTypeIndex && selControlIndex == 0)
...@@ -707,16 +730,19 @@ bool OE_interfaceDisplay::checkPicking() ...@@ -707,16 +730,19 @@ bool OE_interfaceDisplay::checkPicking()
{ {
editionState = MovePointstitch; editionState = MovePointstitch;
controller->addAction(new OE_actionMovePointLinkStitch(document, tmpLinkStitch, selControlIndex, vector_2d())); controller->addAction(new OE_actionMovePointLinkStitch(document, tmpLinkStitch, selControlIndex, vector_2d()));
return true;
} }
else if (selControlType == 1) else if (selControlType == 1)
{ {
editionState = MovePointstitch; editionState = MovePointstitch;
controller->addAction(new OE_actionAddPointLinkStitch(document, tmpLinkStitch, selControlIndex, absMouse)); controller->addAction(new OE_actionAddPointLinkStitch(document, tmpLinkStitch, selControlIndex, absMouse));
return true;
} }
else if (selControlType == 2) else if (selControlType == 2)
{ {
editionState = DelPointstitch; editionState = DelPointstitch;
controller->addAction(new OE_actionDelPointLinkStitch(document, tmpLinkStitch, selControlIndex)); controller->addAction(new OE_actionDelPointLinkStitch(document, tmpLinkStitch, selControlIndex));
return true;
} }
return false; return false;
} }
...@@ -822,7 +848,7 @@ bool OE_interfaceDisplay::drawPicking() ...@@ -822,7 +848,7 @@ bool OE_interfaceDisplay::drawPicking()
std::list<OE_stitchs*>::iterator it = document->stitchs.begin(); std::list<OE_stitchs*>::iterator it = document->stitchs.begin();
std::advance(it, *ptr); std::advance(it, *ptr);
selectedStitches.push_back(*it); selectedStitches.push_back(*it);
return true; return true;
} }
else if (names==4) //if name count correspond to a stitch sub element (like control point) else if (names==4) //if name count correspond to a stitch sub element (like control point)
...@@ -903,13 +929,15 @@ bool OE_interfaceDisplay::selectApply(std::list<OE_pointcurve*> selectedCurves, ...@@ -903,13 +929,15 @@ bool OE_interfaceDisplay::selectApply(std::list<OE_pointcurve*> selectedCurves,
} }
else else
{ {
controller->selectStitches(selectedStitches, !modState.testFlag(Qt::ShiftModifier)); controller->selectStitches(selectedStitches, !modState.testFlag(Qt::ShiftModifier));
emit stitchSelectionChange();
} }
} }
if (!selectedStitches.size() && !selectedCurves.size()) if (!selectedStitches.size() && !selectedCurves.size())
{ {
controller->clearSelection(); controller->clearSelection();
emit stitchSelectionChange();
} }
return true; return true;
...@@ -1003,4 +1031,3 @@ bool OE_interfaceDisplay::draw() ...@@ -1003,4 +1031,3 @@ bool OE_interfaceDisplay::draw()
} }
return true; return true;
} }
...@@ -6,7 +6,8 @@ OE_ui_stitchList::OE_ui_stitchList(MainWindow* window, OE_root* root) ...@@ -6,7 +6,8 @@ OE_ui_stitchList::OE_ui_stitchList(MainWindow* window, OE_root* root)
{ {
this->root = root; this->root = root;
this->window = window; this->window = window;
this->setSelectionMode(QAbstractItemView::ExtendedSelection); setSelectionMode(QAbstractItemView::ExtendedSelection);
setSelectionBehavior(QAbstractItemView::SelectRows);
setDragEnabled(true); setDragEnabled(true);
setDragDropMode(QAbstractItemView::InternalMove); setDragDropMode(QAbstractItemView::InternalMove);
viewport()->setAcceptDrops(true); viewport()->setAcceptDrops(true);
...@@ -25,8 +26,11 @@ OE_ui_stitchList::OE_ui_stitchList(MainWindow* window, OE_root* root) ...@@ -25,8 +26,11 @@ OE_ui_stitchList::OE_ui_stitchList(MainWindow* window, OE_root* root)
//getItems(); //getItems();
refreshStitches(); refreshStitches();
connect(this->root->interfaceDisplay, SIGNAL(refreshStitchList()), this, SLOT(on_refreshStitchList())); connect(getInterfaceDisplay(), SIGNAL(refreshStitchList()), this, SLOT(on_refreshStitchList()));
connect(this->root->interfaceDisplay, SIGNAL(refreshStitch(OE_stitchs*)), this, SLOT(on_refreshStitch(OE_stitchs*))); connect(getInterfaceDisplay(), SIGNAL(refreshStitch(OE_stitchs*)), this, SLOT(on_refreshStitch(OE_stitchs*)));
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleSelectionChanged()));
connect(getInterfaceDisplay(), SIGNAL(stitchSelectionChange()), this, SLOT(on_refreshStitchList()));
showMaximized(); showMaximized();
...@@ -42,7 +46,7 @@ void OE_ui_stitchList::addItem(QColor color, QIcon icon, QIcon type, QIcon patte ...@@ -42,7 +46,7 @@ void OE_ui_stitchList::addItem(QColor color, QIcon icon, QIcon type, QIcon patte
item->setData(QString::number(stitchCount),ListviewDelegate::NbpointsRole); item->setData(QString::number(stitchCount),ListviewDelegate::NbpointsRole);
item->setData(icon,ListviewDelegate::IconRole); item->setData(icon,ListviewDelegate::IconRole);
item->setData(type,ListviewDelegate::typeRole); item->setData(type,ListviewDelegate::typeRole);
item->setData(pattern,ListviewDelegate::patternole); item->setData(pattern,ListviewDelegate::patternRole);
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));//& ~Qt::ItemIsDragEnabled); item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));//& ~Qt::ItemIsDragEnabled);
model->appendRow(item); model->appendRow(item);
...@@ -109,13 +113,24 @@ void OE_ui_stitchList::addStitch(OE_stitchs* stitch) ...@@ -109,13 +113,24 @@ void OE_ui_stitchList::addStitch(OE_stitchs* stitch)
void OE_ui_stitchList::refreshStitches() void OE_ui_stitchList::refreshStitches()
{ {
if (root->interfaceDisplay->getDocument()) if (getDocument())
{ {
model->clear(); model->clear();
for (auto stitch : root->interfaceDisplay->getDocument()->stitchs) QItemSelection selection;
int id = 0;
for (auto stitch : getDocument()->stitchs)
{ {
addStitch(stitch); addStitch(stitch);
auto it = std::find(getDocument()->selectedStitchs.begin(), getDocument()->selectedStitchs.end(), stitch);
if(it != getDocument()->selectedStitchs.end())
selection.merge(QItemSelection(model->index(id, 0), model->index(id, 0)), QItemSelectionModel::Select | QItemSelectionModel::Rows);
id++;
} }
selectionModel()->blockSignals(true);
selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows);
selectionModel()->blockSignals(false);
} }
} }
...@@ -125,5 +140,44 @@ void OE_ui_stitchList::on_refreshStitchList() ...@@ -125,5 +140,44 @@ void OE_ui_stitchList::on_refreshStitchList()
} }
void OE_ui_stitchList::on_refreshStitch(OE_stitchs* stitch) void OE_ui_stitchList::on_refreshStitch(OE_stitchs* stitch)
{ {
refreshStitches(); //refreshStitches();
}
void OE_ui_stitchList::handleSelectionChanged()
{
std::list<int> stitchesId;
foreach(const QModelIndex &index, selectionModel()->selectedIndexes())
stitchesId.push_back(index.row());
getController()->selectStitches(stitchesId, true);
getInterfaceDisplay()->update();
}
void OE_ui_stitchList::keyPressEvent(QKeyEvent *event)
{
if(event->key()==Qt::Key_Right) {
QKeyEvent* eventDown = new QKeyEvent(event->type(), Qt::Key_Down, event->modifiers());
QListView::keyPressEvent(eventDown);
return;
}
if(event->key()==Qt::Key_Left) {
QKeyEvent* eventUp = new QKeyEvent(event->type(), Qt::Key_Up, event->modifiers());
QListView::keyPressEvent(eventUp);
return;
}
QListView::keyPressEvent(event);
}
OE_controller* OE_ui_stitchList::getController()
{
return this->root->interfaceDisplay->getController();
}
OE_interfaceDisplay* OE_ui_stitchList::getInterfaceDisplay()
{
return this->root->interfaceDisplay;
}
OE_document* OE_ui_stitchList::getDocument()
{
return this->root->interfaceDisplay->getDocument();
} }
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
#include "listviewdelegate.h" #include "listviewdelegate.h"
class MainWindow; class MainWindow;
class OE_controller;
class OE_interfaceDisplay;
class OE_document;
class OE_ui_stitchList : public QListView class OE_ui_stitchList : public QListView
{ {
...@@ -15,6 +18,9 @@ public: ...@@ -15,6 +18,9 @@ public:
OE_ui_stitchList(MainWindow* window, OE_root* root); OE_ui_stitchList(MainWindow* window, OE_root* root);
void addStitch(OE_stitchs* stitch); void addStitch(OE_stitchs* stitch);
void refreshStitches(); void refreshStitches();
OE_controller* getController();
OE_interfaceDisplay* getInterfaceDisplay();
OE_document* getDocument();
private: private:
OE_root* root; OE_root* root;
MainWindow* window; MainWindow* window;
...@@ -22,9 +28,11 @@ private: ...@@ -22,9 +28,11 @@ private:
ListviewDelegate* listdelegate; ListviewDelegate* listdelegate;
void addItem(QColor color, QIcon icon, QIcon type, QIcon pattern, int stitchCount); void addItem(QColor color, QIcon icon, QIcon type, QIcon pattern, int stitchCount);
void addItem(QColor color, int stitchCount); void addItem(QColor color, int stitchCount);
void keyPressEvent(QKeyEvent *event);
private slots: private slots:
void on_refreshStitchList(); void on_refreshStitchList();
void on_refreshStitch(OE_stitchs* stitch); void on_refreshStitch(OE_stitchs* stitch);
void handleSelectionChanged();
}; };
#endif // OE_UI_STITCHLIST_H #endif // OE_UI_STITCHLIST_H
...@@ -64,7 +64,7 @@ void ListviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti ...@@ -64,7 +64,7 @@ void ListviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
} }
QIcon type = qvariant_cast<QIcon>(index.data(typeRole)); QIcon type = qvariant_cast<QIcon>(index.data(typeRole));
QIcon pattern = qvariant_cast<QIcon>(index.data(patternole)); QIcon pattern = qvariant_cast<QIcon>(index.data(patternRole));
QString indexText = qvariant_cast<QString>(index.data(IndexRole)); QString indexText = qvariant_cast<QString>(index.data(IndexRole));
QString nbPoints = qvariant_cast<QString>(index.data(NbpointsRole)); QString nbPoints = qvariant_cast<QString>(index.data(NbpointsRole));
......
...@@ -11,7 +11,7 @@ public: ...@@ -11,7 +11,7 @@ public:
virtual ~ListviewDelegate(); virtual ~ListviewDelegate();
// enum datarole {headerTextRole = Qt::UserRole + 100,subHeaderTextrole = Qt::UserRole+101,IconRole = Qt::UserRole+102}; // enum datarole {headerTextRole = Qt::UserRole + 100,subHeaderTextrole = Qt::UserRole+101,IconRole = Qt::UserRole+102};
enum datarole {threadRole = Qt::UserRole + 100,IconRole = Qt::UserRole+101,typeRole = Qt::UserRole+102,patternole = Qt::UserRole+103,IndexRole = Qt::UserRole+104,NbpointsRole = Qt::UserRole+105}; enum datarole {threadRole = Qt::UserRole + 100,IconRole = Qt::UserRole+101,typeRole = Qt::UserRole+102,patternRole = Qt::UserRole+103,IndexRole = Qt::UserRole+104,NbpointsRole = Qt::UserRole+105};
void paint(QPainter *painter, const QStyleOptionViewItem &option, void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const; const QModelIndex &index) const;
......