Index: scribus/guidesmodel.cpp =================================================================== --- scribus/guidesmodel.cpp (revision 20488) +++ scribus/guidesmodel.cpp (working copy) @@ -66,6 +66,7 @@ if (role != Qt::EditRole || !index.isValid()) return false; bool ok; + double from = data(index,role).toDouble(); double newVal = value.toDouble(&ok); if (!ok) return false; @@ -72,7 +73,7 @@ m_values[index.row()] = value2pts(newVal, m_docUnitIndex) + rule; qSort(m_values); emit dataChanged(index, index); - emit valueChanged(); + emit valueChanged(from,newVal); return true; } @@ -121,8 +122,8 @@ { // insertRows(rowCount(), 1); beginResetModel(); - if (m_values.contains(0.0)) - return; +// if (m_values.contains(0.0)) +// return; m_values.append(0.0); qSort(m_values); endResetModel(); Index: scribus/guidesmodel.h =================================================================== --- scribus/guidesmodel.h (revision 20488) +++ scribus/guidesmodel.h (working copy) @@ -58,8 +58,7 @@ signals: /*! \brief Signal emmitted when the user finish the editation of one value. */ - void valueChanged(); - + void valueChanged(double from, double to); private: Guides m_values; int m_docUnitIndex; Index: scribus/ui/guidemanager.cpp =================================================================== --- scribus/ui/guidemanager.cpp (revision 20488) +++ scribus/ui/guidemanager.cpp (working copy) @@ -97,8 +97,8 @@ connect(lockCheck, SIGNAL(stateChanged(int)), this, SLOT(lockCheck_stateChanged(int))); - connect(horizontalModel, SIGNAL(valueChanged()), this, SLOT(horizontalModel_valueChanged())); - connect(verticalModel, SIGNAL(valueChanged()), this, SLOT(verticalModel_valueChanged())); + connect(horizontalModel, SIGNAL(valueChanged(double, double)), this, SLOT(horizontalModel_valueChanged(double, double))); + connect(verticalModel, SIGNAL(valueChanged(double, double)), this, SLOT(verticalModel_valueChanged(double, double))); } void GuideManager::setDoc(ScribusDoc* doc) @@ -294,10 +294,18 @@ // see GuidesModel::data() v.append(horizontalModel->data(ix, Qt::EditRole).toDouble()); + UndoTransaction trans; + if(UndoManager::undoEnabled()) + trans = UndoManager::instance()->beginTransaction(currentPage->getUName(), + currentPage->getUPixmap(), + Um::DelHGuide, "", + Um::IGuides); horizontalModel->removeValues(v); currentPage->guides.clearHorizontals(GuideManagerCore::Standard); currentPage->guides.addHorizontals(horizontalModel->values(), GuideManagerCore::Standard); + if (trans) + trans.commit(); drawGuides(); m_Doc->changed(); } @@ -313,10 +321,18 @@ // see GuidesModel::data() v.append(verticalModel->data(ix, Qt::EditRole).toDouble()); + UndoTransaction trans; + if(UndoManager::undoEnabled()) + trans = UndoManager::instance()->beginTransaction(currentPage->getUName(), + currentPage->getUPixmap(), + Um::DelVGuide, "", + Um::IGuides); + verticalModel->removeValues(v); - currentPage->guides.clearVerticals(GuideManagerCore::Standard); currentPage->guides.addVerticals(verticalModel->values(), GuideManagerCore::Standard); + if (trans) + trans.commit(); drawGuides(); m_Doc->changed(); } @@ -323,16 +339,41 @@ void GuideManager::addHorButton_clicked() { + UndoTransaction trans; + if(UndoManager::undoEnabled()) + trans = UndoManager::instance()->beginTransaction(currentPage->getUName(), + currentPage->getUPixmap(), + Um::AddHGuide, "", + Um::IGuides); horizontalModel->insertRow(); - horizontalView->setCurrentIndex(horizontalModel->index(0, 0, QModelIndex())); - horizontalView->edit(horizontalView->currentIndex()); + currentPage->guides.clearHorizontals(GuideManagerCore::Standard); + currentPage->guides.addHorizontal(0.0, GuideManagerCore::Standard); + + if (trans) + trans.commit(); + + drawGuides(); + m_Doc->changed(); +// horizontalView->setCurrentIndex(horizontalModel->index(0, 0, QModelIndex())); +// horizontalView->edit(horizontalView->currentIndex()); } void GuideManager::addVerButton_clicked() { + UndoTransaction trans; + if(UndoManager::undoEnabled()) + trans = UndoManager::instance()->beginTransaction(currentPage->getUName(), + currentPage->getUPixmap(), + Um::AddVGuide, "", + Um::IGuides); + verticalModel->insertRow(); - verticalView->setCurrentIndex(verticalModel->index(0, 0, QModelIndex())); - verticalView->edit(verticalView->currentIndex()); + currentPage->guides.clearVerticals(GuideManagerCore::Standard); + currentPage->guides.addVertical(0.0, GuideManagerCore::Standard); + if(trans) + trans.commit(); +// verticalView->setCurrentIndex(verticalModel->index(0, 0, QModelIndex())); +// verticalView->edit(verticalView->currentIndex()); } void GuideManager::lockCheck_stateChanged( int ) @@ -624,18 +665,17 @@ } } -void GuideManager::verticalModel_valueChanged() +void GuideManager::verticalModel_valueChanged(double from, double to) { - currentPage->guides.clearVerticals(GuideManagerCore::Standard); - currentPage->guides.addVerticals(verticalModel->values(), GuideManagerCore::Standard); + + currentPage->guides.moveVertical(from,to,GuideManagerCore::Standard); drawGuides(); m_Doc->changed(); } -void GuideManager::horizontalModel_valueChanged() +void GuideManager::horizontalModel_valueChanged(double from, double to) { - currentPage->guides.clearHorizontals(GuideManagerCore::Standard); - currentPage->guides.addHorizontals(horizontalModel->values(), GuideManagerCore::Standard); + currentPage->guides.moveHorizontal(from,to,GuideManagerCore::Standard); drawGuides(); m_Doc->changed(); } Index: scribus/ui/guidemanager.h =================================================================== --- scribus/ui/guidemanager.h (revision 20488) +++ scribus/ui/guidemanager.h (working copy) @@ -134,8 +134,8 @@ private slots: //! Wrapper slot for drawGuides() void forceDrawGuides(const QItemSelection &, const QItemSelection &); - void verticalModel_valueChanged(); - void horizontalModel_valueChanged(); + void verticalModel_valueChanged(double from, double to); + void horizontalModel_valueChanged(double from, double to); void addHorButton_clicked(); void delHorButton_clicked(); void addVerButton_clicked();