some modification on directory implementation

preferencesAboutTextFull
Claudio Valerio 13 years ago
commit 4abdacd054
  1. 2
      src/adaptors/UBImportAdaptor.cpp
  2. 13
      src/adaptors/UBSvgSubsetAdaptor.h
  3. 31
      src/core/UBSettings.cpp
  4. 10
      src/domain/UBGraphicsProxyWidget.cpp
  5. 2
      src/domain/UBGraphicsProxyWidget.h
  6. 24
      src/domain/UBGraphicsWidgetItem.cpp
  7. 8
      src/domain/UBGraphicsWidgetItem.h

@ -35,7 +35,7 @@ UBImportAdaptor::~UBImportAdaptor()
UBDocumentProxy* UBImportAdaptor::importFile(const QFile& pFile, const QString& pGroup) UBDocumentProxy* UBImportAdaptor::importFile(const QFile& pFile, const QString& pGroup)
{ {
QString documentName = QFileInfo(pFile.fileName()).baseName(); QString documentName = QFileInfo(pFile.fileName()).completeBaseName();
UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName); UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName);

@ -171,20 +171,15 @@ class UBSvgSubsetAdaptor
int pointsCount = crashedPoints.size(); int pointsCount = crashedPoints.size();
QString svgPoints; QString svgPoints;
static const int maxBufferLengthPerPoint = 30;
int maxBufferLength = maxBufferLengthPerPoint * pointsCount;
char *buffer = new char[maxBufferLength];
int length = 0; int length = 0;
QString sBuf;
for(int j = 0; j < pointsCount; j++) for(int j = 0; j < pointsCount; j++)
{ {
const QPointF & point = crashedPoints.at(j); const QPointF & point = crashedPoints.at(j);
int n = sprintf(buffer + length, "%.2f,%.2f ", point.x(), point.y()); sBuf.sprintf("%.2f,%.2f ", point.x(), point.y());
length += n; svgPoints.insert(length, sBuf);
length += sBuf.length();
} }
svgPoints = QString::fromAscii(buffer, length);
delete buffer;
return svgPoints; return svgPoints;
} }

@ -855,8 +855,8 @@ QString UBSettings::userFavoriteListFilePath()
static QString filePath = ""; static QString filePath = "";
if(filePath.isEmpty()){ if(filePath.isEmpty()){
QString dirPath = userDataDirectory() + "/libraryPalette"; QString dirPath = userDataDirectory() + "/libraryPalette";
filePath = dirPath + "/favorite.dat";
checkDirectory(dirPath); checkDirectory(dirPath);
filePath = dirPath + "/favorite.dat";
} }
return filePath; return filePath;
} }
@ -865,7 +865,7 @@ QString UBSettings::userTrashDirPath()
{ {
static QString trashPath = ""; static QString trashPath = "";
if(trashPath.isEmpty()){ if(trashPath.isEmpty()){
QString trashPath = userDataDirectory() + "/libraryPalette/trash"; trashPath = userDataDirectory() + "/libraryPalette/trash";
checkDirectory(trashPath); checkDirectory(trashPath);
} }
return trashPath; return trashPath;
@ -878,12 +878,10 @@ QString UBSettings::applicationShapeLibraryDirectory()
QString configPath = value("Library/ShapeDirectory", QVariant(defaultRelativePath)).toString(); QString configPath = value("Library/ShapeDirectory", QVariant(defaultRelativePath)).toString();
if (configPath.startsWith(".")) if (configPath.startsWith(".")) {
{
return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1); return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1);
} }
else else {
{
return configPath; return configPath;
} }
} }
@ -914,12 +912,10 @@ QString UBSettings::applicationImageLibraryDirectory()
QString configPath = value("Library/ImageDirectory", QVariant(defaultRelativePath)).toString(); QString configPath = value("Library/ImageDirectory", QVariant(defaultRelativePath)).toString();
if (configPath.startsWith(".")) if (configPath.startsWith(".")) {
{
return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1); return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1);
} }
else else {
{
return configPath; return configPath;
} }
} }
@ -959,12 +955,10 @@ QString UBSettings::applicationInteractivesDirectory()
QString configPath = value("Library/InteractivitiesDirectory", QVariant(defaultRelativePath)).toString(); QString configPath = value("Library/InteractivitiesDirectory", QVariant(defaultRelativePath)).toString();
if (configPath.startsWith(".")) if (configPath.startsWith(".")) {
{
return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1); return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1);
} }
else else {
{
return configPath; return configPath;
} }
} }
@ -975,12 +969,10 @@ QString UBSettings::applicationApplicationsLibraryDirectory()
QString configPath = value("Library/ApplicationsDirectory", QVariant(defaultRelativePath)).toString(); QString configPath = value("Library/ApplicationsDirectory", QVariant(defaultRelativePath)).toString();
if (configPath.startsWith(".")) if (configPath.startsWith(".")) {
{
return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1); return UBPlatformUtils::applicationResourcesDirectory() + configPath.right(configPath.size() - 1);
} }
else else {
{
return configPath; return configPath;
} }
} }
@ -1132,6 +1124,9 @@ QString UBSettings::replaceWildcard(QString& path)
else if(result.startsWith("{Home}")) { else if(result.startsWith("{Home}")) {
result = result.replace("{Home}", QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); result = result.replace("{Home}", QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
} }
else if(result.startsWith("{Desktop}")) {
result = result.replace("{Desktop}", QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
}
if(result.contains("{UserLoginName}") && UBPlatformUtils::osUserLoginName().length() > 0) { if(result.contains("{UserLoginName}") && UBPlatformUtils::osUserLoginName().length() > 0) {
result = result.replace("{UserLoginName}", UBPlatformUtils::osUserLoginName()); result = result.replace("{UserLoginName}", UBPlatformUtils::osUserLoginName());

@ -111,6 +111,16 @@ void UBGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
} }
} }
void UBGraphicsProxyWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
// NOOP
}
void UBGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
// NOOP
}
void UBGraphicsProxyWidget::setDelegate(UBGraphicsItemDelegate* pDelegate) void UBGraphicsProxyWidget::setDelegate(UBGraphicsItemDelegate* pDelegate)
{ {

@ -51,6 +51,8 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent *event); virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);

@ -78,6 +78,16 @@ void UBGraphicsWidgetItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
UBGraphicsProxyWidget::mouseReleaseEvent(event); UBGraphicsProxyWidget::mouseReleaseEvent(event);
} }
void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
sendJSEnterEvent();
UBGraphicsProxyWidget::hoverEnterEvent(event);
}
void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
sendJSLeaveEvent();
UBGraphicsProxyWidget::hoverLeaveEvent(event);
}
bool UBGraphicsWidgetItem::eventFilter(QObject *obj, QEvent *event) bool UBGraphicsWidgetItem::eventFilter(QObject *obj, QEvent *event)
{ {
@ -247,6 +257,20 @@ void UBGraphicsWidgetItem::removeScript()
mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onremove) { widget.onremove();}"); mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onremove) { widget.onremove();}");
} }
} }
void UBGraphicsWidgetItem::sendJSEnterEvent()
{
if (mWebKitWidget && mWebKitWidget->page() && mWebKitWidget->page()->mainFrame())
{
mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onenter) { widget.onenter();}");
}
}
void UBGraphicsWidgetItem::sendJSLeaveEvent()
{
if (mWebKitWidget && mWebKitWidget->page() && mWebKitWidget->page()->mainFrame())
{
mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onleave) { widget.onleave();}");
}
}
void UBGraphicsWidgetItem::clearSource() void UBGraphicsWidgetItem::clearSource()
{ {

@ -66,6 +66,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void remove(); virtual void remove();
void removeScript(); void removeScript();
QString downloadUrl(const QString &fileUrl, const QString &extention); QString downloadUrl(const QString &fileUrl, const QString &extention);
QString downloadWeb(const QString &fileUrl); QString downloadWeb(const QString &fileUrl);
void processDropEvent(QDropEvent *event); void processDropEvent(QDropEvent *event);
@ -77,13 +78,20 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void clearSource(); virtual void clearSource();
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual bool eventFilter(QObject *obj, QEvent *event); virtual bool eventFilter(QObject *obj, QEvent *event);
virtual void sendJSEnterEvent();
virtual void sendJSLeaveEvent();
UBAbstractWidget* mWebKitWidget; UBAbstractWidget* mWebKitWidget;
QMap<QString, QString> mPreferences; QMap<QString, QString> mPreferences;

Loading…
Cancel
Save