some modification on directory implementation

preferencesAboutTextFull
Claudio Valerio 13 years ago
commit 4abdacd054
  1. 2
      src/adaptors/UBImportAdaptor.cpp
  2. 15
      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)
{
QString documentName = QFileInfo(pFile.fileName()).baseName();
QString documentName = QFileInfo(pFile.fileName()).completeBaseName();
UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName);

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

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

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

@ -78,6 +78,16 @@ void UBGraphicsWidgetItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *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)
{
@ -247,6 +257,20 @@ void UBGraphicsWidgetItem::removeScript()
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()
{

@ -66,6 +66,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void remove();
void removeScript();
QString downloadUrl(const QString &fileUrl, const QString &extention);
QString downloadWeb(const QString &fileUrl);
void processDropEvent(QDropEvent *event);
@ -77,13 +78,20 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void clearSource();
protected:
virtual void mousePressEvent(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 void sendJSEnterEvent();
virtual void sendJSLeaveEvent();
UBAbstractWidget* mWebKitWidget;
QMap<QString, QString> mPreferences;

Loading…
Cancel
Save