Extended iwb editable prop new file version available

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent cb8cfcf8ab
commit b87a39b9b8
  1. 26
      src/adaptors/UBCFFSubsetAdaptor.cpp
  2. 34
      src/adaptors/UBSvgSubsetAdaptor.cpp
  3. 2
      src/core/UBSettings.cpp
  4. 5
      src/domain/UBGraphicsTextItemDelegate.cpp

@ -28,6 +28,7 @@
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItemDelegate.h"
#include "domain/UBW3CWidget.h"
#include "frameworks/UBFileSystemUtils.h"
@ -95,6 +96,7 @@ static QString aRef = "ref";
static QString aHref = "href";
static QString aBackground = "background";
static QString aLocked = "locked";
static QString aEditable = "editable";
//attributes part names
static QString apRotate = "rotate";
@ -647,6 +649,12 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgTextarea(const QDomElement &
hastransform = true;
}
//by default all the textAreas are not editable
UBGraphicsTextItemDelegate *curDelegate = dynamic_cast<UBGraphicsTextItemDelegate*>(svgItem->Delegate());
if (curDelegate) {
curDelegate->setEditable(false);
}
repositionSvgItem(svgItem, width, height, x, y, hastransform, transform);
hashSceneItem(element, svgItem);
@ -914,18 +922,32 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbElement(QDomElement &element
return false;
}
bool locked = false, isBackground = false;
bool locked = false;
bool isBackground = false;
bool isEditableItem = false;
bool isEditable = false; //Text items to convert to UBGraphicsTextItem only
QString IDRef = element.attribute(aRef);
if (!IDRef.isNull()) {
isBackground = element.hasAttribute(aBackground) ? strToBool(element.attribute(aBackground)) : false;
locked = element.hasAttribute(aBackground) ? strToBool(element.attribute(aBackground)) : false;
isEditableItem = element.hasAttribute(aEditable);
if (isEditableItem)
isEditable = strToBool(element.attribute(aEditable));
UBGraphicsItem *referedItem(0);
QHash<QString, UBGraphicsItem*>::iterator iReferedItem;
iReferedItem = persistedItems.find(IDRef);
if (iReferedItem != persistedItems.end()) {
UBGraphicsItem *referedItem = *iReferedItem;
referedItem = *iReferedItem;
referedItem->Delegate()->lock(locked);
}
if (isEditableItem) {
UBGraphicsTextItemDelegate *textDelegate = dynamic_cast<UBGraphicsTextItemDelegate*>(referedItem->Delegate());
if (textDelegate) {
textDelegate->setEditable(isEditable);
}
}
}
return true;

@ -309,7 +309,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
UBGraphicsWidgetItem *currentWidget = 0;
int mFileVersion = 40100; // default to 4.1.0
mFileVersion = 40100; // default to 4.1.0
UBGraphicsStroke* annotationGroup = 0;
@ -878,7 +878,8 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene()
buffer.open(QBuffer::WriteOnly);
mXmlWriter.setDevice(&buffer);
QTime timer = QTime::currentTime();
//Unused variable
//QTime timer = QTime::currentTime();
mXmlWriter.setAutoFormatting(true);
@ -1383,8 +1384,6 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
}
UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromLineSvg(const QColor& pDefaultColor)
{
QStringRef svgX1 = mXmlReader.attributes().value("x1");
@ -1491,12 +1490,8 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromLin
}
return polygonItem;
}
QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemsFromPolylineSvg(const QColor& pDefaultColor)
{
QStringRef strokeWidth = mXmlReader.attributes().value("stroke-width");
@ -1966,6 +1961,14 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g
gItem->setData(UBGraphicsItemData::ItemLocked, QVariant(isLocked));
}
QStringRef ubEditable = mXmlReader.attributes().value(mNamespaceUri, "editable");
if (!ubEditable.isNull())
{
bool isEditable = (ubEditable.toString() == xmlTrue || ubEditable.toString() == "1");
gItem->setData(UBGraphicsItemData::ItemEditable, QVariant(isEditable));
}
//deprecated as of 4.4.a.12
QStringRef ubLayer = mXmlReader.attributes().value(mNamespaceUri, "layer");
if (!ubLayer.isNull())
@ -2020,9 +2023,18 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsItemToSvg(QGraphicsItem* ite
if (!locked.isNull() && locked.toBool())
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "locked", xmlTrue);
QVariant editable = item->data(UBGraphicsItemData::ItemEditable);
if (!editable.isNull()) {
if (editable.toBool())
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "editable", xmlTrue);
else
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "editable", xmlFalse);
}
}
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsAppleWidgetToSvg(UBGraphicsAppleWidgetItem* item)
{
graphicsWidgetToSvg(item);
@ -2290,13 +2302,9 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
if (mXmlReader.isStartElement())
{
//for new documents from version 4.5.0
if (true) {
if (mFileVersion >= 40500) {
if (mXmlReader.name() == "itemTextContent") {
QString text = mXmlReader.readElementText();
// QtLogger::start("/home/ilia/Documents/tmp/10/log.log");
// QtLogger::appendl(text);
// QtLogger::finish();
// textItem->setPlainText("");
textItem->setHtml(text);
break;
}

@ -47,7 +47,7 @@ QString UBSettings::uniboardApplicationNamespaceUri = "http://uniboard.mnemis.co
const int UBSettings::sDefaultFontPixelSize = 36;
const char *UBSettings::sDefaultFontFamily = "Arial";
QString UBSettings::currentFileVersion = "4.4.0";
QString UBSettings::currentFileVersion = "4.5.0";
QColor UBSettings::crossDarkBackground = QColor(44, 44, 44, 200);
QColor UBSettings::crossLightBackground = QColor(165, 225, 255);

@ -50,6 +50,7 @@ UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDele
delegated()->adjustSize();
delegated()->contentsChanged();
// QTextCursor defcursor(createDefaultCursor());
// defcursor.movePosition(QTextCursor::Start);
// delegated()->setTextCursor(defcursor);
@ -229,11 +230,7 @@ void UBGraphicsTextItemDelegate::pickColor()
QTextCursor curCursor = delegated()->textCursor();
QTextCharFormat format;
format.setForeground(QBrush(selectedColor));
// format.setBackground(Qt::yellow);
curCursor.mergeCharFormat(format);
QTextBlockFormat blFormat;
blFormat.setAlignment(Qt::AlignCenter);
curCursor.setBlockFormat(blFormat);
delegated()->setTextCursor(curCursor);
UBGraphicsTextItem::lastUsedTextColor = selectedColor;

Loading…
Cancel
Save