Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 1210 → Rev 1211

/branches/Version13x/Scribus/scribus/undomanager.h
222,8 → 222,10
static const QString UnlockGuides;
static const QString Move;
static const QString Resize;
static const QString FromXToY;
static const QString FromHToW;
static const QString Rotate;
static const QString MoveFromTo;
static const QString ResizeFromTo;
static const QString RotateFromTo;
static const QString From;
static const QString To;
static const QString X;
255,6 → 257,12
static QPixmap *IResizePolygon;
static QPixmap *IResizePolyline;
static QPixmap *IResizePathText;
static QPixmap *IRotateText;
static QPixmap *IRotateImage;
static QPixmap *IRotateLine;
static QPixmap *IRotatePolygon;
static QPixmap *IRotatePolyline;
static QPixmap *IRotatePathText;
/*@}*/
 
protected:
/branches/Version13x/Scribus/scribus/scribusview.h
183,6 → 183,7
void RotateGroup(double win);
void scaleGroup(double scx, double scy);
void RotateItem(double win, int ite);
void RotateItem(double win, PageItem *pi);
void AdjustItemSize(PageItem *b);
void AdvanceSel(PageItem *b, int oldPos, int len, int dir, int expandSel, int state);
void setNewPos(PageItem *b, int oldPos, int len, int dir);
259,6 → 260,7
void UniteObj();
void SplitObj();
void rememberPreviousSettings(int mx=0, int my=0);
bool mousePressed();
 
public slots: // Public slots
/** Fhrt die Vergr´┐Żerung/Verkleinerung aus; */
318,6 → 320,7
bool Ready;
int oldX;
int oldY;
bool _mousePressed;
private slots:
void Zval();
337,6 → 340,8
virtual void contentsWheelEvent ( QWheelEvent *ev );
virtual void setHBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
virtual void setVBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
virtual void mousePressEvent(QMouseEvent *e);
virtual void mouseReleaseEvent(QMouseEvent *e);
 
signals:
void changeUN(int);
/branches/Version13x/Scribus/scribus/pageitem.h
91,6 → 91,8
int PType;
/** Winkel um den das Item gedreht wird */
double Rot;
/** @brief Stores the old rotation value for undo action. Is used to detect rotation actions. */
double oldRot;
/** Enthaelt das Dokument */
ScribusDoc *Doc;
int GrType;
140,6 → 142,8
bool Frame;
/** Seite zu der das Element gehoert */
int OwnPage;
/** @brief Old page number tracked for the move undo action */
int oldOwnPage;
/** Darzustellendes Bild */
QImage pixm;
QImage pixmOrg;
302,6 → 306,9
QPixmap *undoIconMove;
/** @brief Icon for resize action */
QPixmap *undoIconResize;
/** @brief Icon for rotate action */
QPixmap *undoIconRotate;
/** @brief Manages undostack and is where all undo actions/states are sent. */
UndoManager *undoManager;
/**
* @brief Set name of the item
309,17 → 316,36
* @author Riku Leino
*/
void setName(const QString& newName);
/**
* @brief Check the changes to the item and add undo actions for them.
* @param force Force the check. Do not care if mouse button or arrow key is down
* check anyway.
* @author Riku Leino
*/
void checkChanges(bool force = false);
/**
* @name Store undo actions
* @brief Add an undo action to the undo guis
* @author Riku Leino
*/
/*@{*/
void moveUndoAction();
void resizeUndoAction();
void rotateUndoAction();
/*@}*/
/** @brief Required by the UndoObject */
void restore(UndoState *state, bool isUndo);
private:
/**
* @brief Add an undo action to the undo guis
* @name Restore helper methods
* Split the restore method for easier handling.
* @author Riku Leino
*/
void resizeUndoAction();
void restore(UndoState *state, bool isUndo);
/*@{*/
void restoreMove(SimpleState *state, bool isUndo);
void restoreResize(SimpleState *state, bool isUndo);
void restoreRotate(SimpleState *state, bool isUndo);
/*@}*/
};
 
#endif
/branches/Version13x/Scribus/scribus/pageitem.cpp
77,6 → 77,7
OldH2 = Height;
PType = art;
Rot = 0;
oldRot = 0;
Doc = pa;
Pcolor = fill;
Pcolor2 = PType == 4 ? fill : outline;
158,6 → 159,7
PoShow = false;
BaseOffs = 0;
OwnPage = Doc->currentPage->PageNr;
oldOwnPage = OwnPage;
PicArt = true;
PicAvail = false;
isPrintable = true;
184,36 → 186,43
AnName = tr("Image");
undoIconMove = Um::IMoveImage;
undoIconResize = Um::IResizeImage;
undoIconRotate = Um::IRotateImage;
break;
case 4:
AnName = tr("Text");
undoIconMove = Um::IMoveText;
undoIconResize = Um::IResizeText;
undoIconRotate = Um::IRotateText;
break;
case 5:
AnName = tr("Line");
undoIconMove = Um::IMoveLine;
undoIconResize = Um::IResizeLine;
undoIconRotate = Um::IRotateLine;
break;
case 6:
AnName = tr("Polygon");
undoIconMove = Um::IMovePolygon;
undoIconResize = Um::IResizePolygon;
undoIconRotate = Um::IRotatePolygon;
break;
case 7:
AnName = tr("Polyline");
undoIconMove = Um::IMovePolyline;
undoIconResize = Um::IResizePolyline;
undoIconRotate = Um::IRotatePolyline;
break;
case 8:
AnName = tr("PathText");
undoIconMove = Um::IMovePathText;
undoIconResize = Um::IResizePathText;
undoIconRotate = Um::IRotatePathText;
break;
default:
AnName = "Item";
undoIconMove = NULL;
undoIconResize = NULL;
undoIconRotate = NULL;
break;
}
AnName += tmp.setNum(Doc->TotalItems); // +" "+QDateTime::currentDateTime().toString();
1913,14 → 1922,7
FrameOnly = false;
p->restore();
pf.end();
// store an undo action if object has been resize but is not being resized at the moment
if ((oldWidth != Width || oldHeight != Height) &&
(!ScApp->view->Mpressed) && (!ScApp->arrowKeyDown()))
resizeUndoAction();
// store an undo action if object has moved and it's not been moved at the moment
if ((oldXpos != Xpos || oldYpos != Ypos) &&
(!ScApp->view->Mpressed) && (!ScApp->arrowKeyDown()))
moveUndoAction();
checkChanges(); // check the changes for undo actions
}
 
void PageItem::paintObj(QRect e, QPixmap *ppX)
2048,6 → 2050,7
Tinput = false;
FrameOnly = false;
p.end();
checkChanges(); // Check changes for undo actions
}
 
QString PageItem::ExpandToken(uint base)
2270,12 → 2273,29
setUName(newName);
}
 
void PageItem::checkChanges(bool force)
{
// has the item been rotated
if ((force) || ((oldRot != Rot) && (!ScApp->view->mousePressed()) && (!ScApp->arrowKeyDown())))
rotateUndoAction();
// has the item been resized
if ((force) || ((oldWidth != Width || oldHeight != Height) &&
(!ScApp->view->mousePressed()) && (!ScApp->arrowKeyDown())))
resizeUndoAction();
// has the item been moved
if ((force) || ((oldXpos != Xpos || oldYpos != Ypos) &&
(!ScApp->view->mousePressed()) && (!ScApp->arrowKeyDown())))
moveUndoAction();
}
 
void PageItem::moveUndoAction()
{
if (oldXpos == Xpos && oldYpos == Ypos)
return;
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::Move,
QString(Um::FromXToY).arg(oldXpos).arg(oldYpos).arg(Xpos).arg(Ypos),
QString(Um::MoveFromTo).arg(oldXpos).arg(oldYpos).arg(oldOwnPage).arg(Xpos).arg(Ypos).arg(OwnPage),
undoIconMove);
ss->set("OLD_XPOS", oldXpos);
ss->set("OLD_YPOS", oldYpos);
2285,14 → 2305,17
}
oldXpos = Xpos;
oldYpos = Ypos;
oldOwnPage = OwnPage;
}
 
void PageItem::resizeUndoAction()
{
if (oldHeight == Height && oldWidth == Width)
return;
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::Resize,
QString(Um::FromHToW).arg(oldWidth).arg(oldHeight).arg(Width).arg(Height),
QString(Um::ResizeFromTo).arg(oldWidth).arg(oldHeight).arg(Width).arg(Height),
undoIconResize);
ss->set("OLD_WIDTH", oldWidth);
ss->set("OLD_HEIGHT", oldHeight);
2308,8 → 2331,32
oldYpos = Ypos;
oldHeight = Height;
oldWidth = Width;
oldOwnPage = OwnPage;
}
 
void PageItem::rotateUndoAction()
{
if (oldRot == Rot)
return;
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::Rotate,
QString(Um::RotateFromTo).arg(oldRot).arg(Rot),
undoIconRotate);
ss->set("OLD_ROT", oldRot);
ss->set("NEW_ROT", Rot);
ss->set("OLD_RXPOS", oldXpos);
ss->set("OLD_RYPOS", oldYpos);
ss->set("NEW_RXPOS", Xpos);
ss->set("NEW_RYPOS", Ypos);
undoManager->action(this, ss);
}
oldRot = Rot;
oldXpos = Xpos;
oldYpos = Ypos;
oldOwnPage = OwnPage;
}
 
void PageItem::restore(UndoState *state, bool isUndo)
{
SimpleState *ss = dynamic_cast<SimpleState*>(state);
2316,50 → 2363,88
if (ss)
{
if (ss->contains("OLD_XPOS"))
{
double ox = ss->getDouble("OLD_XPOS");
double oy = ss->getDouble("OLD_YPOS");
double x = ss->getDouble("NEW_XPOS");
double y = ss->getDouble("NEW_YPOS");
double mx = ox - x;
double my = oy - y;
if (!isUndo)
{
mx = x - ox;
my = y - oy;
}
ScApp->view->MoveItem(mx, my, this, false);
oldXpos = Xpos;
oldYpos = Ypos;
}
restoreMove(ss, isUndo);
else if (ss->contains("OLD_HEIGHT"))
{
double ow = ss->getDouble("OLD_WIDTH");
double oh = ss->getDouble("OLD_HEIGHT");
double w = ss->getDouble("NEW_WIDTH");
double h = ss->getDouble("NEW_HEIGHT");
double ox = ss->getDouble("OLD_RXPOS");
double oy = ss->getDouble("OLD_RYPOS");
double x = ss->getDouble("NEW_RXPOS");
double y = ss->getDouble("NEW_RYPOS");
double mx = ox - x;
double my = oy - y;
if (isUndo)
{
ScApp->view->SizeItem(ow, oh, this, false, true, true);
ScApp->view->MoveItem(mx, my, this, false);
}
else
{
mx = x - ox;
my = y - oy;
ScApp->view->SizeItem(w, h, this, false, true, true);
ScApp->view->MoveItem(mx, my, this, false);
}
oldWidth = Width;
oldHeight = Height;
oldXpos = Xpos;
oldYpos = Ypos;
}
restoreResize(ss, isUndo);
else if (ss->contains("OLD_ROT"))
restoreRotate(ss, isUndo);
}
}
 
void PageItem::restoreMove(SimpleState *state, bool isUndo)
{
double ox = state->getDouble("OLD_XPOS");
double oy = state->getDouble("OLD_YPOS");
double x = state->getDouble("NEW_XPOS");
double y = state->getDouble("NEW_YPOS");
double mx = ox - x;
double my = oy - y;
if (!isUndo)
{
mx = x - ox;
my = y - oy;
}
ScApp->view->MoveItem(mx, my, this, false);
oldXpos = Xpos;
oldYpos = Ypos;
oldOwnPage = OwnPage;
}
 
void PageItem::restoreResize(SimpleState *state, bool isUndo)
{
double ow = state->getDouble("OLD_WIDTH");
double oh = state->getDouble("OLD_HEIGHT");
double w = state->getDouble("NEW_WIDTH");
double h = state->getDouble("NEW_HEIGHT");
double ox = state->getDouble("OLD_RXPOS");
double oy = state->getDouble("OLD_RYPOS");
double x = state->getDouble("NEW_RXPOS");
double y = state->getDouble("NEW_RYPOS");
double mx = ox - x;
double my = oy - y;
if (isUndo)
{
ScApp->view->SizeItem(ow, oh, this, false, true, true);
ScApp->view->MoveItem(mx, my, this, false);
}
else
{
mx = x - ox;
my = y - oy;
ScApp->view->SizeItem(w, h, this, false, true, true);
ScApp->view->MoveItem(mx, my, this, false);
}
oldWidth = Width;
oldHeight = Height;
oldXpos = Xpos;
oldYpos = Ypos;
oldOwnPage = OwnPage;
}
 
void PageItem::restoreRotate(SimpleState *state, bool isUndo)
{
double ort = state->getDouble("OLD_ROT");
double rt = state->getDouble("NEW_ROT");
double ox = state->getDouble("OLD_RXPOS");
double oy = state->getDouble("OLD_RYPOS");
double x = state->getDouble("NEW_RXPOS");
double y = state->getDouble("NEW_RYPOS");
double mx = ox - x;
double my = oy - y;
if (isUndo)
{
ScApp->view->RotateItem(ort, this);
ScApp->view->MoveItem(mx, my, this, false);
}
else
{
mx = x - ox;
my = y - oy;
ScApp->view->RotateItem(rt, this);
ScApp->view->MoveItem(mx, my, this, false);
}
oldRot = Rot;
oldXpos = Xpos;
oldYpos = Ypos;
oldOwnPage = OwnPage;
}
/branches/Version13x/Scribus/scribus/scribusview.cpp
180,6 → 180,7
GxM = 0;
ClRe = -1;
ClRe2 = -1;
_mousePressed = false;
connect(SB1, SIGNAL(clicked()), this, SLOT(slotZoomOut()));
connect(SB2, SIGNAL(clicked()), this, SLOT(slotZoomIn()));
connect(LE, SIGNAL(valueChanged(int)), this, SLOT(Zval()));
1164,6 → 1165,7
{
PageItem *b;
Mpressed = false;
mouseReleaseEvent(m);
if (Doc->guidesSettings.guidesShown)
{
bool fg = false;
3579,6 → 3581,7
QPointArray Bez(4);
QRect tx, mpo;
Mpressed = true;
mousePressEvent(m);
Imoved = false;
SeRx = qRound(m->x()/Scale);
SeRy = qRound(m->x()/Scale);
5508,7 → 5511,7
 
bool ScribusView::SizeItem(double newX, double newY, int ite, bool fromMP, bool DoUpdateClip, bool redraw)
{
SizeItem(newX, newY, Doc->Items.at(ite), fromMP, DoUpdateClip, redraw);
return SizeItem(newX, newY, Doc->Items.at(ite), fromMP, DoUpdateClip, redraw);
}
 
bool ScribusView::SizeItem(double newX, double newY, PageItem *pi, bool fromMP, bool DoUpdateClip, bool redraw)
5890,8 → 5893,13
 
void ScribusView::RotateItem(double win, int ite)
{
RotateItem(win, Doc->Items.at(ite));
}
 
void ScribusView::RotateItem(double win, PageItem *pi)
{
PageItem *b;
b = Doc->Items.at(ite);
b = pi;
if (b->Locked)
return;
FPoint n;
8030,6 → 8038,25
}
}
 
void ScribusView::mousePressEvent(QMouseEvent *e)
{
_mousePressed = true;
QScrollView::mousePressEvent(e);
}
 
void ScribusView::mouseReleaseEvent(QMouseEvent *e)
{
_mousePressed = false;
for (uint i = 0; i < SelItem.count(); ++i)
SelItem.at(i)->checkChanges(true);
QScrollView::mouseReleaseEvent(e);
}
 
bool ScribusView::mousePressed()
{
return _mousePressed;
}
 
// jjsa 27-03-2004 add for better settinf while zooming
void ScribusView::rememberPreviousSettings(int mx, int my)
{
/branches/Version13x/Scribus/scribus/undomanager.cpp
342,6 → 342,12
UndoManager::IResizePolygon = new QPixmap(iconDir + "u_resize_polygon.png");
UndoManager::IResizePolyline = new QPixmap(iconDir + "u_resize_polyline.png");
// UndoManager::IResizePathText = new QPixmap(iconDir + "u_resize_pathtext.png");
UndoManager::IRotateText = new QPixmap(iconDir + "u_rotate_text.png");
UndoManager::IRotateImage = new QPixmap(iconDir + "u_rotate_image.png");
UndoManager::IRotateLine = new QPixmap(iconDir + "u_rotate_line.png");
UndoManager::IRotatePolygon = new QPixmap(iconDir + "u_rotate_polygon.png");
UndoManager::IRotatePolyline = new QPixmap(iconDir + "u_rotate_polyline.png");
// UndoManager::IRotatePathText = new QPixmap(iconDir + "u_rotate_pathtext.png");
}
 
const QString UndoManager::AddVGuide = tr("Add vertical guide");
354,8 → 360,10
const QString UndoManager::UnlockGuides = tr("Unlock guides");
const QString UndoManager::Move = tr("Move");
const QString UndoManager::Resize = tr("Resize");
const QString UndoManager::FromXToY = tr("X: %1, Y: %2 (from)\nX: %3, Y: %4 (to)");
const QString UndoManager::FromHToW = tr("W: %1, H: %2 (from)\nW: %3, H: %4 (to)");
const QString UndoManager::Rotate = tr("Rotate");
const QString UndoManager::MoveFromTo = tr("X1: %1, Y1: %2, Page %3\nX2: %4, Y2: %5, Page %6");
const QString UndoManager::ResizeFromTo = tr("W1: %1, H1: %2\nW2: %3, H2: %4");
const QString UndoManager::RotateFromTo = tr("From %1 to %2");
const QString UndoManager::From = tr("from");
const QString UndoManager::To = tr("to");
const QString UndoManager::X = tr("X");
381,3 → 389,9
QPixmap *UndoManager::IResizePolygon = NULL;
QPixmap *UndoManager::IResizePolyline = NULL;
QPixmap *UndoManager::IResizePathText = NULL;
QPixmap *UndoManager::IRotateText = NULL;
QPixmap *UndoManager::IRotateImage = NULL;
QPixmap *UndoManager::IRotateLine = NULL;
QPixmap *UndoManager::IRotatePolygon = NULL;
QPixmap *UndoManager::IRotatePolyline = NULL;
QPixmap *UndoManager::IRotatePathText = NULL;