r14807 by fschmid - Removed the use of an existing ScribusDoc from the SampleItem class.
scribus-commit
scribus-commit at lists.scribus.net
Wed Feb 24 12:40:30 CET 2010
Revision: 14807
Author: fschmid
Date: 2010-02-24T11:38:43.391409Z
Commit message: Removed the use of an existing ScribusDoc from the SampleItem class.
Changeset:
M /trunk/Scribus/scribus/ui/prefs_itemtools.cpp
M /trunk/Scribus/scribus/sampleitem.cpp
M /trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp
M /trunk/Scribus/scribus/ui/tabtools.cpp
M /trunk/Scribus/scribus/sampleitem.h
Diffs:
Index: scribus/sampleitem.cpp
===================================================================
--- scribus/sampleitem.cpp (revision 14806)
+++ scribus/sampleitem.cpp (revision 14807)
@@ -20,35 +20,15 @@
#include <QPixmap>
#include "text/nlsconfig.h"
-SampleItem::SampleItem(ScribusDoc* doc) :
- QObject()
+SampleItem::SampleItem() : QObject()
{
- used = true;
- m_Doc=doc;
-
- if (doc==0)
- {
- qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
- // FIXME: main preformance issue here! PV
- m_Doc=ScCore->primaryMainWindow()->doFileNew(//pageWidth, pageHeight,
- 0,0,
- //topMargin, leftMargin, rightMargin, bottomMargin,
- 1, 1, 1, 1,
- // autoframes. It's disabled in python
- // columnDistance, numberCols, autoframes,
- 0, 1, false,
- //pagesType, unit, firstPageOrder,
- 1, 1, 1,
- //orientation, firstPageNr, "Custom", requires gui, page count, showview);
- 1, 1, "custom", false, 1, false);
- //m_Doc = new ScribusDoc();
- Q_ASSERT(m_Doc!=0);
- if (!m_Doc)
- return;
- m_Doc->pageSets[1/*pagesType*/].FirstPage = 1;//firstPageOrder;
- used = false;
- qApp->changeOverrideCursor(Qt::ArrowCursor);
- }
+ m_Doc = new ScribusDoc();
+ if (!m_Doc)
+ return;
+ m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setPage(1, 1, 0, 0, 0, 0, 0, 0, false, false);
+ m_Doc->addPage(0);
+ m_Doc->setGUI(false, ScCore->primaryMainWindow(), 0);
// tmp colors. to be removed in descrictor
m_Doc->PageColors.insert("__blackforpreview__", ScColor(0, 0, 0, 255));
m_Doc->PageColors.insert("__whiteforpreview__", ScColor(0, 0, 0, 0));
@@ -91,20 +71,7 @@
SampleItem::~SampleItem()
{
- cleanupTemporary();
- // clean tmp document
- if (used == false)
- {
- m_Doc->setModified(false);
- //Do this manually as the sample item's doc was never put into the main windows workspace and doc list etc
- //m_Doc->scMW()->slotFileClose();
- m_Doc->view()->disconnect();
- m_Doc->WinHan->disconnect();
- m_Doc->disconnect();
- delete m_Doc->view();
- delete m_Doc->WinHan;
- delete m_Doc;
- }
+ delete m_Doc;
}
void SampleItem::setText(QString aText)
@@ -317,23 +284,12 @@
PageItem_TextFrame *previewItem = new PageItem_TextFrame(m_Doc, 0, 0, width, height, 0, "__whiteforpreviewbg__", "__whiteforpreview__");
QImage pm(width, height, QImage::Format_ARGB32);
ScPainter *painter = new ScPainter(&pm, width, height, 1.0, 0);
- double sca = 1.0; // original scale to set back at the end...
- int userAppMode = m_Doc->appMode; // We need to be in normal when creating/repainting items
- m_Doc->appMode = modeNormal;
+ painter->setZoomFactor(PrefsManager::instance()->appPrefs.displayPrefs.displayScale);
- if (m_Doc->view() != NULL)
- {
- sca = m_Doc->view()->scale();
- m_Doc->view()->setScale(1.0 * PrefsManager::instance()->appPrefs.displayPrefs.displayScale);
- }
- painter->setZoomFactor(m_Doc->view()->scale());
-
if (m_Doc->UsedFonts.contains(tmpStyle.charStyle().font().scName()))
previouslyUsedFont = true;
m_Doc->AddFont(tmpStyle.charStyle().font().scName(), qRound(m_Doc->itemToolPrefs.textSize / 10.0));
-// m_Doc->docParagraphStyles.create(tmpStyle);
-// int tmpIndex = m_Doc->docParagraphStyles.count() - 1;
previewItem->FrameType = PageItem::TextFrame;
previewItem->itemText.clear();
@@ -358,18 +314,7 @@
(*m_Doc->AllFonts)[fontName].decreaseUsage(); // was increased by AddFont()
m_Doc->UsedFonts.remove(fontName);
}
- if (m_Doc->view() != NULL)
- m_Doc->view()->setScale(sca);
- m_Doc->appMode = userAppMode;
// m_Doc->docParagraphStyles.remove(tmpIndex);
UndoManager::instance()->setUndoEnabled(true);
return QPixmap::fromImage(pm);
}
-
-void SampleItem::cleanupTemporary()
-{
- // clear tmp colors
- m_Doc->PageColors.remove("__blackforpreview__");
- m_Doc->PageColors.remove("__whiteforpreview__");
- m_Doc->PageColors.remove("__whiteforpreviewbg__");
-}
Index: scribus/ui/prefs_itemtools.cpp
===================================================================
--- scribus/ui/prefs_itemtools.cpp (revision 14806)
+++ scribus/ui/prefs_itemtools.cpp (revision 14807)
@@ -315,7 +315,7 @@
if (!showFontPreview)
return;
- SampleItem si(m_doc);
+ SampleItem si;
si.setText( tr("Woven silk pyjamas exchanged for blue quartz"));
if (textFrameFillColorComboBox->currentText() != CommonStrings::tr_NoneColor)
{
Index: scribus/ui/tabtools.cpp
===================================================================
--- scribus/ui/tabtools.cpp (revision 14806)
+++ scribus/ui/tabtools.cpp (revision 14807)
@@ -916,7 +916,7 @@
if (!fontPreview)
return;
- SampleItem si(docu);
+ SampleItem si;
si.setText( tr("Woven silk pyjamas exchanged for blue quartz"));
if (colorComboTextBackground->currentText() != CommonStrings::tr_NoneColor)
{
Index: scribus/sampleitem.h
===================================================================
--- scribus/sampleitem.h (revision 14806)
+++ scribus/sampleitem.h (revision 14807)
@@ -20,15 +20,6 @@
/*! \brief Provides sample "text frame" as pixmap.
You can create a pixmap with standard Scribus text frame
here. It can be used as a kind of preview.
-It needs at least one existing ScribusDoc - so there
-is one created if ScWM->doc is null (then it's destroyed
-of course).
-SampleItem creates 2 temporary colors in scribus document -
-Black and white - to be sure to display B/W preview correctly
-every time. These color are renoved in descructor. Or used
-cleanupTemporary() method.
-\warning Be sure there will be called destructor or cleanupTemporary()
-at the end of work with it!
\author Petr Vanek <petr at yarpen.cz>
*/
class SCRIBUS_API SampleItem : QObject
@@ -36,7 +27,7 @@
Q_OBJECT
public:
- SampleItem(ScribusDoc* doc);
+ SampleItem();
~SampleItem();
/*! \brief Set sample text.
@@ -114,7 +105,6 @@
Existing or created one */
ScribusDoc *m_Doc;
//! \brief Is the doc created used only? true = used
- bool used;
int bgShade;
};
Index: scribus/plugins/fontpreview/fontpreview.cpp
===================================================================
--- scribus/plugins/fontpreview/fontpreview.cpp (revision 14806)
+++ scribus/plugins/fontpreview/fontpreview.cpp (revision 14807)
@@ -26,7 +26,7 @@
setWindowIcon(loadIcon("AppIcon.png"));
m_Doc=doc;
- sampleItem = new SampleItem(m_Doc);
+ sampleItem = new SampleItem();
languageChange();
More information about the scribus-commit
mailing list