Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 23756 → Rev 23757

/trunk/Scribus/scribus/canvasmode_editgradient.cpp
228,7 → 228,7
}
}
 
void CanvasMode_EditGradient::enterEvent(QEvent *)
void CanvasMode_EditGradient::enterEvent(QEvent */*e*/)
{
if (!m_canvas->m_viewMode.m_MouseButtonPressed)
{
236,7 → 236,7
}
}
 
void CanvasMode_EditGradient::leaveEvent(QEvent *e)
void CanvasMode_EditGradient::leaveEvent(QEvent */*e*/)
{
}
 
/trunk/Scribus/scribus/canvasmode_editpolygon.cpp
61,7 → 61,9
#include "util_math.h"
 
 
CanvasMode_EditPolygon::CanvasMode_EditPolygon(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
CanvasMode_EditPolygon::CanvasMode_EditPolygon(ScribusView* view) :
CanvasMode(view),
m_ScMW(view->m_ScMW)
{
}
 
/trunk/Scribus/scribus/canvasmode_editpolygon.h
73,29 → 73,28
double GetMaxFactor();
double getUserValFromFactor(double factor);
 
double m_Mxp {-1.0};
double m_Myp {-1.0};
ScribusMainWindow* m_ScMW {nullptr};
QPointF m_startPoint;
PolyVectorDialog *m_VectorDialog {nullptr};
QPointF m_centerPoint;
QPointF m_endPoint;
QPointF m_centerPoint;
QPointF m_innerCPoint;
QPointF m_outerCPoint;
int m_polyCorners {0};
QPointF m_startPoint;
ScribusMainWindow* m_ScMW {nullptr};
UndoTransaction m_transaction;
bool m_polyUseFactor {false};
double m_Mxp {-1.0};
double m_Myp {-1.0};
double m_polyCurvature {0.0};
double m_polyFactor {0.0};
double m_polyRotation {0.0};
double m_polyCurvature {0.0};
double m_polyInnerRot {0.0};
double m_polyOuterCurvature {0.0};
double m_polyRotation {0.0};
ePolygonPoint m_polygonPoint {noPointDefined};
PolyVectorDialog *m_VectorDialog;
UndoTransaction m_transaction;
int m_blockUpdateFromItem {0};
int m_polyCorners {0};
void blockUpdateFromItem(bool block) { if (block) ++m_blockUpdateFromItem; else --m_blockUpdateFromItem; }
bool updateFromItemBlocked() { return (m_blockUpdateFromItem > 0); }
 
int m_blockUpdateFromItem;
void blockUpdateFromItem(bool block) { if (block) ++m_blockUpdateFromItem; else --m_blockUpdateFromItem; }
bool updateFromItemBlocked() { return (m_blockUpdateFromItem > 0); }
 
public slots:
void applyValues(int polyC, double polyF, bool polyUseCF, double polyR, double polyCur, double polyIRot, double polyOCur);
void updateFromItem();
/trunk/Scribus/scribus/canvasmode_nodeedit.cpp
959,7 → 959,7
 
 
 
bool CanvasMode_NodeEdit::handleNodeEditMove(QMouseEvent* m, QRect r, PageItem* currItem, const QTransform&)
bool CanvasMode_NodeEdit::handleNodeEditMove(QMouseEvent* m, QRect /*r*/, PageItem* currItem, const QTransform& /*t*/)
{
QTransform itemPos = currItem->getTransform();
if ((currItem->isSymbol() || currItem->isGroup()) && (!m_doc->nodeEdit.isContourLine()))
/trunk/Scribus/scribus/canvasmode_normal.cpp
286,7 → 286,6
bool wasLastPostOverGuide = m_lastPosWasOverGuide;
m_lastPosWasOverGuide = false;
double newX, newY;
PageItem *currItem=nullptr;
bool erf = false;
m->accept();
456,8 → 455,8
m_mouseCurrentPoint = mousePointDoc;
if ((GetItem(&currItem)) && (!m_shiftSelItems))
{
newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
double newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
double newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
// #0007865
if (/*(((m_view->dragTimerElapsed()) && (m->buttons() & Qt::LeftButton)) ||*/
(m_view->moveTimerElapsed())
799,8 → 798,8
{
if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton))
{
newX = qRound(mousePointDoc.x());
newY = qRound(mousePointDoc.y());
double newX = qRound(mousePointDoc.x());
double newY = qRound(mousePointDoc.y());
m_mouseSavedPoint.setXY(newX, newY);
QPoint startP = m_canvas->canvasToGlobal(m_mousePressPoint);
m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
/trunk/Scribus/scribus/colormgmt/scspectralvaluesconvertor.h
28,7 → 28,7
/**
* Construct spectral values to CIEXYZ convertor with specified E308 table
*/
ScSpectralValuesConvertor(const ScE308Table& e380table);
ScSpectralValuesConvertor(const ScE308Table& e308table);
 
/**
* Retrieve CIE XYZ values of illuminant white
/trunk/Scribus/scribus/desaxe/saxfilter.cpp
28,7 → 28,7
}
 
 
KeepOpen::KeepOpen(SaxHandler* delegate) : SaxFilter(delegate), m_level(0) {}
KeepOpen::KeepOpen(SaxHandler* delegate) : SaxFilter(delegate) {}
 
void KeepOpen::begin(const Xml_string& tag, Xml_attr attr)
{
51,10 → 51,10
}
 
RenameElem::RenameElem(SaxHandler* delegate, const Xml_string& oldname, const Xml_string& newname)
: SaxFilter(delegate), m_level(0), m_old(oldname), m_new(newname) {}
: SaxFilter(delegate), m_old(oldname), m_new(newname) {}
 
RenameElem::RenameElem(SaxHandler* delegate, const Xml_string& newname)
: SaxFilter(delegate), m_level(0), m_new(newname) {}
: SaxFilter(delegate), m_new(newname) {}
 
void RenameElem::begin(const Xml_string& tag, Xml_attr attr)
{
76,7 → 76,7
 
 
AddAttributes::AddAttributes(SaxHandler* delegate, Xml_attr add)
: SaxFilter(delegate), m_oneshot(false), m_attributes(add) {}
: SaxFilter(delegate), m_attributes(add) {}
 
 
void AddAttributes::begin(const Xml_string& tag, Xml_attr attr)
/trunk/Scribus/scribus/desaxe/saxfilter.h
48,7 → 48,7
virtual void end(const Xml_string& tag);
Xml_string openTag();
private:
int m_level;
int m_level {0};
Xml_string m_tag;
};
 
64,7 → 64,7
virtual void begin(const Xml_string& tag, Xml_attr attr);
virtual void end(const Xml_string& tag);
private:
int m_level;
int m_level {0};
Xml_string m_old;
Xml_string m_new;
};
78,7 → 78,7
AddAttributes(SaxHandler* delegate, Xml_attr add);
virtual void begin(const Xml_string& tag, Xml_attr attr);
private:
bool m_oneshot;
bool m_oneshot {false};
Xml_attr m_attributes;
};
 
/trunk/Scribus/scribus/fonts/scface.h
408,7 → 408,7
 
friend class SCFonts;
 
ScFace(ScFaceData* md);
ScFace(ScFaceData* data);
ScFaceData* m_m;
QString m_replacedName;
QString m_replacedInDoc;
/trunk/Scribus/scribus/fonts/scface_ps.cpp
242,11 → 242,8
str += "\n";
return true;
}
else
{
qDebug("%s", QObject::tr("Font %1 cannot be read, no embedding").arg(fontFile).toLatin1().constData());
return false;
}
qDebug("%s", QObject::tr("Font %1 cannot be read, no embedding").arg(fontFile).toLatin1().constData());
return false;
}
 
ScFace_PFA::ScFace_PFA(const QString& fam, const QString& sty, const QString& alt, const QString& scname, const QString& psname, const QString& path, int face, const QStringList& features) :
/trunk/Scribus/scribus/fonts/scfontmetrics.cpp
243,7 → 243,7
int encode = setBestEncoding(face);
qreal uniEM = static_cast<qreal>(face->units_per_EM);
 
qreal m_descent = face->descender / uniEM;
// qreal m_descent = face->descender / uniEM;
qreal m_height = qMax(face->height / uniEM, (face->bbox.yMax - face->bbox.yMin) / uniEM);
// if (m_height == 0)
// m_height = (face->bbox.yMax - face->bbox.yMin) / uniEM;
/trunk/Scribus/scribus/gtaction.h
72,7 → 72,7
void applyFrameStyle(gtFrameStyle* fstyle);
void createParagraphStyle(gtParagraphStyle* pstyle);
void setCharStyleAttributes(gtFont *font, CharStyle& style);
void setParaStyleAttributes(gtParagraphStyle *gtstyle, ParagraphStyle& style);
void setParaStyleAttributes(gtParagraphStyle *pstyle, ParagraphStyle& style);
void updateParagraphStyle(const QString& pstyleName, gtParagraphStyle* pstyle);
void removeParagraphStyle(const QString& name);
void removeParagraphStyle(int index);
/trunk/Scribus/scribus/gtfont.cpp
69,31 → 69,7
 
gtFont::gtFont()
{
m_setflags = 0;
noEffects();
m_name = "";
m_family = "";
m_weight = "";
m_slant = "";
m_width = "";
m_append = "";
m_size = 120;
m_color = "Black";
m_shade = 100;
m_strokeColor = "Black";
m_strokeShade = 100;
m_hscale = 1000;
m_kerning = 0;
m_useFullName = true;
m_weightIndex = 0;
m_slantIndex = 1;
m_widthIndex = 2;
m_smallestIndex = -1;
m_biggestIndex = - 1;
m_index = -1;
m_tmpWeightIndex = -1;
m_tmpSlantIndex = -1;
m_tmpWidthIndex = -1;
}
 
gtFont::gtFont(const gtFont& f)
/trunk/Scribus/scribus/gtfont.h
5,23 → 5,23
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
* Copyright (C) 2004 by Riku Leino *
* tsoots@gmail.com *
* Copyright (C) 2004 by Riku Leino *
* tsoots@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
 
#ifndef GTFONT_H
91,7 → 91,7
class SCRIBUS_API gtFont
{
private:
int m_setflags;
int m_setflags {0};
QString m_name;
QString m_family;
QString m_weight;
98,25 → 98,25
QString m_slant;
QString m_width;
QString m_append;
int m_size;
bool m_fontEffects[FontEffectMAX];
QString m_color;
int m_shade;
QString m_strokeColor;
int m_strokeShade;
int m_size {120};
bool m_fontEffects[FontEffectMAX];
QString m_color {"Black"};
int m_shade {100};
QString m_strokeColor {"Black"};
int m_strokeShade {100};
/* Width of a character in percentages to it's "real width" */
int m_hscale;
int m_kerning;
bool m_useFullName;
int m_weightIndex;
int m_slantIndex;
int m_widthIndex;
int m_smallestIndex;
int m_biggestIndex;
int m_index;
int m_tmpWeightIndex;
int m_tmpSlantIndex;
int m_tmpWidthIndex;
int m_hscale {1000};
int m_kerning {0};
bool m_useFullName {true};
int m_weightIndex {0};
int m_slantIndex {1};
int m_widthIndex {2};
int m_smallestIndex {-1};
int m_biggestIndex {-1};
int m_index {-1};
int m_tmpWeightIndex {-1};
int m_tmpSlantIndex {-1};
int m_tmpWidthIndex {-1};
void initArrays();
void parseName();
void parseWeight();
123,7 → 123,7
void parseSlant();
void parseWidth();
void parseFamily();
int find(const QString& where, const QString& what);
int find(const QString& where, const QString& what);
 
public:
 
133,13 → 133,13
weightWasSet = 2,
slantWasSet = 4,
widthWasSet = 8,
sizeWasSet = 16,
sizeWasSet = 16,
effectWasSet = 32,
fillColorWasSet = 64,
fillShadeWasSet = 128,
strokeColorWasSet = 256,
strokeShadeWasSet = 512,
hscaleWasSet = 1024,
hscaleWasSet = 1024,
kerningWasSet = 2048
} wasSetFlags;
 
147,41 → 147,41
static const QString fontSlants[];
static const QString fontWidths[];
 
void noEffects();
bool isToggled(FontEffect fe);
bool toggleEffect(FontEffect fe);
int getFlags();
int getEffectsValue();
void noEffects();
bool isToggled(FontEffect fe);
bool toggleEffect(FontEffect fe);
int getFlags();
int getEffectsValue();
void setName(const QString& newName);
void setFamily(const QString& newFamily);
void setFamily(const QString& newFamily);
QString getFamily();
void setWeight(FontWeight newWeight);
void setWeight(const QString& newWeight);
void setWeight(FontWeight newWeight);
void setWeight(const QString& newWeight);
QString getWeight();
void setSlant(FontSlant newSlant);
void setSlant(const QString& newSlant);
void setSlant(FontSlant newSlant);
void setSlant(const QString& newSlant);
QString getSlant();
void setWidth(FontWidth newWidth);
void setWidth(const QString& newWidth);
void setWidth(FontWidth newWidth);
void setWidth(const QString& newWidth);
QString getWidth();
void setSize(int newSize);
void setSize(double newSize);
void setColor(const QString& newColor);
void setShade(int newShade);
void setStrokeColor(const QString& newColor);
void setStrokeShade(int newShade);
void setSize(int newSize);
void setSize(double newSize);
void setColor(const QString& newColor);
void setShade(int newShade);
void setStrokeColor(const QString& newColor);
void setStrokeShade(int newShade);
QString getName();
QString getName(uint i);
static const int NAMECOUNT = 14;
int getSize();
int getSize();
QString getColor();
int getShade();
int getShade();
QString getStrokeColor();
int getStrokeShade();
int getHscale();
void setHscale(int newHscale);
int getKerning();
void setKerning(int newKerning);
int getStrokeShade();
int getHscale();
void setHscale(int newHscale);
int getKerning();
void setKerning(int newKerning);
gtFont();
gtFont(const gtFont& f);
~gtFont();
/trunk/Scribus/scribus/nodeeditcontext.cpp
73,8 → 73,7
if (nodeTransaction)
return (oldClip ? FPointArray(*oldClip) : Clip);
 
if (oldClip)
delete oldClip;
delete oldClip;
oldClip = new FPointArray(Clip);
 
m_oldItemX = currItem->xPos();
/trunk/Scribus/scribus/notesstyles.cpp
23,7 → 23,7
}
 
 
const QString TextNote::numString()
QString TextNote::numString()
{
return notesStyle()->numString(m_number);
}
/trunk/Scribus/scribus/notesstyles.h
28,9 → 28,7
class SCRIBUS_API NotesStyle
{
public:
NotesStyle() : m_nameStr ("Default"), m_startNum(1), m_endNotesStyle(false), m_numeration(), m_numRange(NSRdocument), m_suffixStr(")"),
m_autoNotesHeight(true), m_autoNotesWidth(true), m_autoRemoveEmptyNotesFrames(true), m_autoWeldNotesFrames(true),
m_superscriptInNote(true), m_superscriptInMaster(true) {}
NotesStyle() {}
~NotesStyle() {}
bool operator!=(const NotesStyle& n2);
 
70,18 → 68,18
void setEndNotes(bool);
 
private:
QString m_nameStr; //unique name of notes style
int m_startNum; //numeration starts with that number
QString m_nameStr {"Default"}; //unique name of notes style
int m_startNum {1}; //numeration starts with that number
 
bool m_endNotesStyle; //if not true this is set of footnotes
bool m_endNotesStyle {false}; //if not true this is set of footnotes
Numeration m_numeration;
NumerationRange m_numRange; //range of numeration for current set
NumerationRange m_numRange {NSRdocument}; //range of numeration for current set
QString m_prefixStr;
QString m_suffixStr;
bool m_autoNotesHeight; //change height of notes frames to its content automaticaly?
bool m_autoNotesWidth; //change width of notes frames automaticaly if width of master frame changes?
bool m_autoRemoveEmptyNotesFrames;
bool m_autoWeldNotesFrames;
QString m_suffixStr {")"};
bool m_autoNotesHeight {true}; //change height of notes frames to its content automaticaly?
bool m_autoNotesWidth {true}; //change width of notes frames automaticaly if width of master frame changes?
bool m_autoRemoveEmptyNotesFrames {true};
bool m_autoWeldNotesFrames {true};
bool m_superscriptInNote;
bool m_superscriptInMaster;
QString m_marksCharStyle;
95,14 → 93,14
 
private:
//only ScribusDoc can create and delete notes
TextNote(NotesStyle *nStyle) : m_notesStyle(nStyle), m_noteMasterMark(NULL), m_noteFrameMark(NULL), m_number(0) { }
TextNote(NotesStyle *nStyle) : m_notesStyle(nStyle) { }
~TextNote() {}
public:
void setNotesStyle (NotesStyle* ns) { m_notesStyle = ns; }
NotesStyle* notesStyle() { return m_notesStyle; }
int num() { return m_number; }
int num() { return m_number; }
void setNum(const int i) { m_number = i; }
const QString numString();
QString numString();
Mark* masterMark() { return m_noteMasterMark; }
void setMasterMark(Mark* m) { m_noteMasterMark = m; }
Mark* noteMark() { return m_noteFrameMark; }
114,11 → 112,11
int textLen {0};
 
protected:
NotesStyle *m_notesStyle;
NotesStyle *m_notesStyle {nullptr};
QString m_noteSaxedText;
Mark *m_noteMasterMark;
Mark *m_noteFrameMark;
int m_number;
Mark *m_noteMasterMark {nullptr};
Mark *m_noteFrameMark {nullptr};
int m_number {0};
};
 
#endif // NOTESSTYLES_H
/trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
215,19 → 215,16
 
bool XPSExPlug::doExport(const QString& fName)
{
zip = new ScZipHandler(true);
if (!zip->open(fName))
{
delete zip;
ScZipHandler zip(true);
if (!zip.open(fName))
return false;
}
dir = new QTemporaryDir();
if (dir->isValid())
QTemporaryDir dir;
if (dir.isValid())
{
imageCounter = 0;
fontCounter = 0;
xps_fontMap.clear();
baseDir = dir->path();
baseDir = dir.path();
// Create directory tree
QDir outDir(baseDir);
outDir.mkdir("_rels");
288,11 → 285,9
s.writeRawData(utf8wr.data(), utf8wr.length());
fdo.close();
}
zip->write(baseDir);
zip.write(baseDir);
}
zip->close();
delete zip;
delete dir;
zip.close();
return true;
}
 
/trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.h
107,9 → 107,7
QString MatrixToStr(QTransform &mat, double factor);
int hex2int(char hex);
bool checkForFallback(PageItem *Item);
ScribusDoc* m_Doc;
ScZipHandler *zip;
QTemporaryDir *dir;
ScribusDoc* m_Doc {nullptr};
QString baseDir;
QDomDocument f_docu;
QDomDocument p_docu;
121,13 → 119,13
struct txtRunItem
{
QChar chr;
GlyphLayout* glyphs;
GlyphLayout* glyphs {nullptr};
CharStyle style;
int index;
double CurX;
PageItem* embItem;
int index {0};
double CurX {0.0};
PageItem* embItem {nullptr};
};
double m_dpi;
double m_dpi {0.0};
};
 
#endif
/trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.h
63,7 → 63,7
bool newReplacement {false};
QMap<QString,QString> ReplacedFonts;
QMap<uint,QString> DoVorl;
uint VorlC;
uint VorlC {0};
QList<PDFPresentationData> EffVal;
};
 
/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
80,16 → 80,16
class ItemInfo
{
public:
ItemInfo(void) { groupLastItem = nextItem = ownLink = ownWeld = ownNr = itemID = 0; item = nullptr; isGroupFlag = isWeldFlag = false; };
PageItem* item;
int groupLastItem;
int nextItem;
int ownLink;
int ownWeld;
int ownNr;
int itemID;
bool isGroupFlag;
bool isWeldFlag;
ItemInfo(void);
PageItem* item {nullptr};
int groupLastItem {0};
int nextItem {0};
int ownLink {0};
int ownWeld {0};
int ownNr {0};
int itemID {0};
bool isGroupFlag {false};
bool isWeldFlag {false};
};
 
class ReadObjectParams
220,17 → 220,17
QList<PageItem*> FrameItems;
QMap<PageItem*, QString> itemsWeld; //item* and master name
 
int itemCount;
int itemCountM;
bool layerFound;
int LayerToPaste;
double Xp;
double GrX;
double Yp;
double GrY;
QFile aFile;
QString clipPath;
bool isNewFormat;
QFile aFile;
bool isNewFormat {false};
bool layerFound {false};
double GrX {0.0};
double GrY {0.0};
double Xp {0.0};
double Yp {0.0};
int LayerToPaste {0};
int itemCount {0};
int itemCountM {0};
};
 
extern "C" PLUGIN_API int scribus150format_getPluginAPIVersion();
/trunk/Scribus/scribus/undomanager.cpp
41,31 → 41,31
#include "undostack.h"
#include "undotransaction.h"
 
UndoManager* UndoManager::instance_ = nullptr;
bool UndoManager::undoEnabled_ = true;
int UndoManager::undoEnabledCounter_ = 0;
UndoManager* UndoManager::m_instance = nullptr;
bool UndoManager::m_undoEnabled = true;
int UndoManager::m_undoEnabledCounter = 0;
 
UndoManager* UndoManager::instance()
{
if (instance_ == nullptr)
instance_ = new UndoManager();
if (m_instance == nullptr)
m_instance = new UndoManager();
 
return instance_;
return m_instance;
}
 
void UndoManager::setUndoEnabled(bool isEnabled)
{
if (isEnabled && undoEnabledCounter_ == 0)
if (isEnabled && m_undoEnabledCounter == 0)
return; // nothing to do undo is already enabled.
if (isEnabled && undoEnabledCounter_ > 0)
--undoEnabledCounter_;
if (isEnabled && m_undoEnabledCounter > 0)
--m_undoEnabledCounter;
else if (!isEnabled)
++undoEnabledCounter_;
++m_undoEnabledCounter;
 
undoEnabled_ = undoEnabledCounter_ == 0;
if (undoEnabled_)
m_undoEnabled = m_undoEnabledCounter == 0;
if (m_undoEnabled)
connectGuis();
else if (undoEnabledCounter_ == 1)
else if (m_undoEnabledCounter == 1)
disconnectGuis(); // disconnect only once when setUndoEnabled(false) has been called
// no need to call again if next setUndoEnabled() call will also be false.
}
72,12 → 72,12
 
bool UndoManager::undoEnabled()
{
return undoEnabled_;
return m_undoEnabled;
}
 
UndoManager::UndoManager()
{
currentUndoObjectId_ = -1;
m_currentUndoObjectId = -1;
if (!UndoManager::IGuides)
initIcons();
prefs_ = PrefsManager::instance().prefsFile->getContext("undo");
97,7 → 97,7
const QString &description,
QPixmap *actionPixmap)
{
if (!undoEnabled_)
if (!m_undoEnabled)
return UndoTransaction(nullptr);
/** @brief Dummy object for storing transaction target's name */
117,10 → 117,10
TransactionData *transaction = new TransactionData();
transaction->transactionObject = transactionTarget_;
transaction->transactionState = transactionState_;
transaction->stackLevel = transactions_.size();
transaction->stackLevel = m_transactions.size();
transaction->UM = this;
transactions_.push_back(transaction);
m_transactions.push_back(transaction);
// qDebug() << "UndoManager::beginTransaction" << targetName << name << transaction;
return UndoTransaction(transaction);
128,7 → 128,7
 
bool UndoManager::isTransactionMode()
{
return !transactions_.empty();
return !m_transactions.empty();
}
 
void UndoManager::registerGui(UndoGui* gui)
138,7 → 138,7
 
setUndoEnabled(false);
setState(gui);
undoGuis_.push_back(gui);
m_undoGuis.push_back(gui);
setUndoEnabled(true);
}
 
146,10 → 146,10
{
gui->clear();
 
if ( stacks_[currentDoc_].size() == 0 )
if ( m_stacks[m_currentDoc].size() == 0 )
return;
 
UndoStack& currentStack = stacks_[currentDoc_];
UndoStack& currentStack = m_stacks[m_currentDoc];
 
StateList::iterator itstartU = currentStack.m_undoActions_.begin(); // undo actions
StateList::iterator itendU = currentStack.m_undoActions_.end();
221,9 → 221,9
 
void UndoManager::connectGuis()
{
for (uint i = 0; i < undoGuis_.size(); ++i)
for (uint i = 0; i < m_undoGuis.size(); ++i)
{
UndoGui *gui = undoGuis_[i];
UndoGui *gui = m_undoGuis[i];
 
connect(gui, SIGNAL(undo(int)), this, SLOT(undo(int)));
connect(gui, SIGNAL(redo(int)), this, SLOT(redo(int)));
239,9 → 239,9
 
void UndoManager::disconnectGuis()
{
for (uint i = 0; i < undoGuis_.size(); ++i)
for (uint i = 0; i < m_undoGuis.size(); ++i)
{
UndoGui *gui = undoGuis_[i];
UndoGui *gui = m_undoGuis[i];
 
disconnect(gui, SIGNAL(undo(int)), this, SLOT(undo(int)));
disconnect(gui, SIGNAL(redo(int)), this, SLOT(redo(int)));
257,11 → 257,11
 
void UndoManager::removeGui(UndoGui* gui)
{
std::vector<UndoGui*>::iterator it = undoGuis_.begin();
while (it != undoGuis_.end())
std::vector<UndoGui*>::iterator it = m_undoGuis.begin();
while (it != m_undoGuis.end())
{
if (*it == gui)
it = undoGuis_.erase(it);
it = m_undoGuis.erase(it);
else
++it;
}
270,15 → 270,15
 
void UndoManager::switchStack(const QString& stackName)
{
if (stackName == currentDoc_)
if (stackName == m_currentDoc)
return; // already current stack
currentDoc_ = stackName;
if (!stacks_.contains(currentDoc_))
stacks_[currentDoc_] = UndoStack();
m_currentDoc = stackName;
if (!m_stacks.contains(m_currentDoc))
m_stacks[m_currentDoc] = UndoStack();
 
stacks_[currentDoc_].setMaxSize(prefs_->getInt("historylength", 100));
for (size_t i = 0; i < undoGuis_.size(); ++i)
setState(undoGuis_[i]);
m_stacks[m_currentDoc].setMaxSize(prefs_->getInt("historylength", 100));
for (size_t i = 0; i < m_undoGuis.size(); ++i)
setState(m_undoGuis[i]);
 
setTexts();
}
285,32 → 285,32
 
void UndoManager::renameStack(const QString& newName)
{
if (currentDoc_ == newName)
if (m_currentDoc == newName)
return;
 
if (stacks_[currentDoc_].size() == 0)
if (m_stacks[m_currentDoc].size() == 0)
{
currentDoc_ = newName;
m_currentDoc = newName;
return;
}
UndoStack tmp(stacks_[currentDoc_]);
stacks_.remove(currentDoc_);
stacks_[newName] = tmp;
currentDoc_ = newName;
UndoStack tmp(m_stacks[m_currentDoc]);
m_stacks.remove(m_currentDoc);
m_stacks[newName] = tmp;
m_currentDoc = newName;
}
 
void UndoManager::removeStack(const QString& stackName)
{
if (stacks_.contains(stackName))
if (m_stacks.contains(stackName))
{
stacks_[stackName].clear();
stacks_.remove(stackName);
if (currentDoc_ == stackName)
m_stacks[stackName].clear();
m_stacks.remove(stackName);
if (m_currentDoc == stackName)
{
for (size_t i = 0; i < undoGuis_.size(); ++i)
undoGuis_[i]->clear();
currentDoc_ = "__no_name__";
for (size_t i = 0; i < m_undoGuis.size(); ++i)
m_undoGuis[i]->clear();
m_currentDoc = "__no_name__";
}
}
}
317,11 → 317,11
 
void UndoManager::clearStack()
{
stacks_[currentDoc_].clear();
for (size_t i = 0; i < undoGuis_.size(); ++i)
m_stacks[m_currentDoc].clear();
for (size_t i = 0; i < m_undoGuis.size(); ++i)
{
undoGuis_[i]->clear();
setState(undoGuis_[i]);
m_undoGuis[i]->clear();
setState(m_undoGuis[i]);
}
}
 
334,7 → 334,7
target->setUPixmap(targetPixmap);
}
 
if (!undoEnabled_) // if so flush down the state
if (!m_undoEnabled) // if so flush down the state
{
TransactionState *ts = dynamic_cast<TransactionState*>(state);
if (ts) // flush the TransactionObject too
344,7 → 344,7
}
 
if (!isTransactionMode() &&
(currentUndoObjectId_ == -1 || currentUndoObjectId_ == static_cast<long>(target->getUId())))
(m_currentUndoObjectId == -1 || m_currentUndoObjectId == static_cast<long>(target->getUId())))
{
// qDebug() << "UndoManager: new Action" << state->getName() << "for" << currentUndoObjectId_;
emit newAction(target, state); // send action to the guis
356,13 → 356,13
if (isTransactionMode())
{
// qDebug() << "UndoManager: Action stored for transaction:" << transactions_.back() << target->getUName() << state->getName();
transactions_.back()->transactionState->pushBack(target, state);
m_transactions.back()->transactionState->pushBack(target, state);
}
else
{
// qDebug() << "UndoManager: Action executed:" << target->getUName() << state->getName();
state->setUndoObject(target);
if (stacks_[currentDoc_].action(state))
if (m_stacks[m_currentDoc].action(state))
emit popBack();
}
if (targetPixmap)
381,19 → 381,20
target->setUName(oldName);
}
 
UndoState* UndoManager::getLastUndo(){
UndoState* state = stacks_[currentDoc_].getNextUndo(Um::GLOBAL_UNDO_MODE);
UndoState* UndoManager::getLastUndo()
{
UndoState* state = m_stacks[m_currentDoc].getNextUndo(Um::GLOBAL_UNDO_MODE);
return state;
}
 
void UndoManager::undo(int steps)
{
if (!undoEnabled_)
if (!m_undoEnabled)
return;
 
emit undoRedoBegin();
setUndoEnabled(false);
stacks_[currentDoc_].undo(steps, currentUndoObjectId_);
m_stacks[m_currentDoc].undo(steps, m_currentUndoObjectId);
setUndoEnabled(true);
emit undoSignal(steps);
emit undoRedoDone();
402,12 → 403,12
 
void UndoManager::redo(int steps)
{
if (!undoEnabled_)
if (!m_undoEnabled)
return;
 
emit undoRedoBegin();
setUndoEnabled(false);
stacks_[currentDoc_].redo(steps, currentUndoObjectId_);
m_stacks[m_currentDoc].redo(steps, m_currentUndoObjectId);
setUndoEnabled(true);
emit redoSignal(steps);
emit undoRedoDone();
417,27 → 418,27
bool UndoManager::hasUndoActions(int )
{
// TODO Needs to fixed for object specific mode
return stacks_[currentDoc_].undoItems() > 0;
return m_stacks[m_currentDoc].undoItems() > 0;
}
 
bool UndoManager::hasRedoActions(int )
{
// TODO Needs to be fixed for object specific mode
return stacks_[currentDoc_].redoItems() > 0;
return m_stacks[m_currentDoc].redoItems() > 0;
}
 
void UndoManager::showObject(int uid)
{
if (currentUndoObjectId_ == uid)
if (m_currentUndoObjectId == uid)
return;
setUndoEnabled(false);
currentUndoObjectId_ = uid;
for (uint i = 0; i < undoGuis_.size(); ++i)
m_currentUndoObjectId = uid;
for (uint i = 0; i < m_undoGuis.size(); ++i)
{
if (uid == -2)
undoGuis_[i]->clear();
m_undoGuis[i]->clear();
else
setState(undoGuis_[i], currentUndoObjectId_);
setState(m_undoGuis[i], m_currentUndoObjectId);
}
setUndoEnabled(true);
setTexts();
447,11 → 448,11
{
UndoObject *tmp = nullptr;
TransactionState* transaction_ = nullptr;
if (!transactions_.empty())
transaction_ = transactions_.at(transactions_.size()-1)->transactionState;
for (uint i = 0; i < stacks_[currentDoc_].m_undoActions_.size(); ++i)
if (!m_transactions.empty())
transaction_ = m_transactions.at(m_transactions.size()-1)->transactionState;
for (uint i = 0; i < m_stacks[m_currentDoc].m_undoActions_.size(); ++i)
{
UndoState *tmpState = stacks_[currentDoc_].m_undoActions_[i];
UndoState *tmpState = m_stacks[m_currentDoc].m_undoActions_[i];
TransactionState *ts = dynamic_cast<TransactionState*>(tmpState);
if (ts)
tmp = ts->replace(uid, newUndoObject);
461,9 → 462,9
tmpState->setUndoObject(newUndoObject);
}
}
for (uint i = 0; i < stacks_[currentDoc_].m_redoActions_.size(); ++i)
for (uint i = 0; i < m_stacks[m_currentDoc].m_redoActions_.size(); ++i)
{
UndoState *tmpState = stacks_[currentDoc_].m_redoActions_[i];
UndoState *tmpState = m_stacks[m_currentDoc].m_redoActions_[i];
TransactionState *ts = dynamic_cast<TransactionState*>(tmpState);
if (ts)
tmp = ts->replace(uid, newUndoObject);
482,8 → 483,8
{
if (steps >= 0)
{
stacks_[currentDoc_].setMaxSize(static_cast<uint>(steps));
prefs_->set("historylength", stacks_[currentDoc_].maxSize());
m_stacks[m_currentDoc].setMaxSize(static_cast<uint>(steps));
prefs_->set("historylength", m_stacks[m_currentDoc].maxSize());
}
}
 
491,7 → 492,7
{
if (steps >= 0)
{
for (StackMap::Iterator it = stacks_.begin(); it != stacks_.end(); ++it )
for (StackMap::Iterator it = m_stacks.begin(); it != m_stacks.end(); ++it )
{
it.value().setMaxSize(static_cast<uint>(steps));
}
501,24 → 502,24
 
int UndoManager::getHistoryLength()
{
if (!stacks_.empty() && stacks_[currentDoc_].redoItems() > 0)
if (!m_stacks.empty() && m_stacks[m_currentDoc].redoItems() > 0)
return -1;
return static_cast<int>(stacks_[currentDoc_].maxSize());
return static_cast<int>(m_stacks[m_currentDoc].maxSize());
}
 
bool UndoManager::isGlobalMode()
{
return currentUndoObjectId_ == -1;
return m_currentUndoObjectId == -1;
}
 
void UndoManager::setTexts()
{
ScribusMainWindow* scMW = ScCore->primaryMainWindow();
UndoStack& currentStack = stacks_[currentDoc_];
UndoStack& currentStack = m_stacks[m_currentDoc];
 
if (currentStack.undoItems() > 0)
{
UndoState *state = currentStack.getNextUndo(currentUndoObjectId_);
UndoState *state = currentStack.getNextUndo(m_currentUndoObjectId);
if (state)
scMW->scrActions["editUndoAction"]->setTexts(QString(Um::MenuUndo).arg(state->getName()));
else
529,7 → 530,7
 
if (currentStack.redoItems() > 0)
{
UndoState *state = currentStack.getNextRedo(currentUndoObjectId_);
UndoState *state = currentStack.getNextRedo(m_currentUndoObjectId);
if (state)
scMW->scrActions["editRedoAction"]->setTexts(QString(Um::MenuRedo).arg(state->getName()));
else
541,14 → 542,14
 
void UndoManager::deleteInstance()
{
delete instance_;
instance_ = nullptr;
delete m_instance;
m_instance = nullptr;
}
 
UndoManager::~UndoManager()
{
StackMap::iterator it;
for (it = stacks_.begin(); it != stacks_.end(); ++it)
for (it = m_stacks.begin(); it != m_stacks.end(); ++it)
{
for (uint i = 0; i < (*it).size(); ++i)
{
555,7 → 556,7
(*it).clear();
}
}
stacks_.clear();
m_stacks.clear();
}
 
/*************************************************************************************/
/trunk/Scribus/scribus/undomanager.h
52,13 → 52,13
class SCRIBUS_API TransactionSettings
{
public:
QString targetName;
QPixmap *targetPixmap;
QString actionName;
QString description;
QPixmap *actionPixmap;
QPixmap* actionPixmap {nullptr};
QPixmap* targetPixmap {nullptr};
QString actionName;
QString description;
QString targetName;
 
TransactionSettings(void) { targetPixmap = actionPixmap = nullptr; }
TransactionSettings(void) {}
};
 
/**
272,10 → 272,10
* UndoManager is singleton and the instance can be queried with the method
* instance().
*/
static UndoManager* instance_;
static UndoManager* m_instance;
 
/** @brief Should undo states be stored or ignored */
static bool undoEnabled_;
static bool m_undoEnabled;
 
/**
* @brief Tracks the state of _undoEnabled.
286,24 → 286,24
* calls this way guarantees that undo is not enabled accidentally calling
* setUndoEnabled(true) even it has been set false before this false-true pair touched it.
*/
static int undoEnabledCounter_;
static int m_undoEnabledCounter;
 
PrefsContext *prefs_;
 
/** @brief Doc to which the currently active stack belongs */
QString currentDoc_;
QString m_currentDoc;
 
/**
* @brief Id number of the object for what the object specific undo is shown
* @brief or -1 if global undo is used.
*/
int currentUndoObjectId_;
int m_currentUndoObjectId;
 
/**
* @brief Stores the transactions which are currently started but not
* @brief canceled or committed.
*/
std::vector<TransactionData*> transactions_;
std::vector<TransactionData*> m_transactions;
 
/**
* @brief UndoGuis attached to this UndoManager
311,7 → 311,7
* @sa UndoWidget
* @sa UndoPalette
*/
std::vector<UndoGui*> undoGuis_;
std::vector<UndoGui*> m_undoGuis;
 
/**
* @brief Undo stacks for all open document
318,7 → 318,7
*
* Whenever current stack is used it's referred with <code>stacks_[currentDoc_]</code>
*/
StackMap stacks_;
StackMap m_stacks;
 
/**
* @brief Initializes the UndoGui.
784,14 → 784,16
 
class SCRIBUS_API UndoBlocker
{
public:
UndoBlocker() {
UndoManager::instance()->setUndoEnabled(false);
}
public:
UndoBlocker()
{
UndoManager::instance()->setUndoEnabled(false);
}
 
~UndoBlocker() {
UndoManager::instance()->setUndoEnabled(true);
}
~UndoBlocker()
{
UndoManager::instance()->setUndoEnabled(true);
}
};
 
#endif
/trunk/Scribus/scribus/undotransaction.cpp
67,10 → 67,10
delete data->transactionState;
data->transactionState = nullptr;
//brutal for now:
assert (stackLevel + 1 == signed(UM->transactions_.size()));
if (stackLevel < signed(UM->transactions_.size()))
assert (stackLevel + 1 == signed(UM->m_transactions.size()));
if (stackLevel < signed(UM->m_transactions.size()))
{
UM->transactions_.erase(UM->transactions_.begin() + stackLevel);
UM->m_transactions.erase(UM->m_transactions.begin() + stackLevel);
}
return true;
default:
112,14 → 112,14
UndoManager* UM = data->UM;
int stackLevel = data->stackLevel;
 
if (!UM->undoEnabled_)
if (!UM->m_undoEnabled)
{
cancel();
return false;
}
UndoObject *tmpu = UM->transactions_.at(stackLevel)->transactionObject;
TransactionState *tmps = UM->transactions_.at(stackLevel)->transactionState;
UndoObject *tmpu = UM->m_transactions.at(stackLevel)->transactionObject;
TransactionState *tmps = UM->m_transactions.at(stackLevel)->transactionState;
switch (m_data->m_status)
{
128,11 → 128,11
m_data->m_status = Transaction::STATE_COMMITTED;
 
// brutal for now:
assert (stackLevel + 1 == signed(UM->transactions_.size()));
assert (stackLevel + 1 == signed(UM->m_transactions.size()));
if (stackLevel < signed(UM->transactions_.size()))
if (stackLevel < signed(UM->m_transactions.size()))
{
UM->transactions_.erase(UM->transactions_.begin() + stackLevel);
UM->m_transactions.erase(UM->m_transactions.begin() + stackLevel);
}
if (tmps->sizet() > 0) // are there any actions inside the committed transaction