Sankore 1224 z-layer reordering amended Delegate button progressbar added retrieving data from the internet

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
parent 65dfcec73d
commit c1e2636719
  1. 9
      src/board/UBFeaturesController.cpp
  2. 1
      src/board/UBFeaturesController.h
  3. 59
      src/domain/UBGraphicsItemDelegate.cpp
  4. 12
      src/domain/UBGraphicsItemDelegate.h
  5. 17
      src/domain/UBGraphicsScene.cpp
  6. 25
      src/gui/UBFeaturesWidget.cpp

@ -251,7 +251,14 @@ bool UBFeature::operator !=( const UBFeature &f )const
bool UBFeature::isFolder() const bool UBFeature::isFolder() const
{ {
return elementType == FEATURE_CATEGORY || elementType == FEATURE_TRASH || elementType == FEATURE_FAVORITE return elementType == FEATURE_CATEGORY || elementType == FEATURE_TRASH || elementType == FEATURE_FAVORITE
|| elementType == FEATURE_FOLDER; || elementType == FEATURE_FOLDER || elementType == FEATURE_SEARCH;
}
bool UBFeature::allowedCopy() const
{
return isFolder()
&& elementType != FEATURE_CATEGORY
&& elementType != FEATURE_SEARCH;
} }
bool UBFeature::isDeletable() const bool UBFeature::isDeletable() const

@ -106,6 +106,7 @@ public:
UBFeatureElementType getType() const { return elementType; } UBFeatureElementType getType() const { return elementType; }
bool isFolder() const; bool isFolder() const;
bool allowedCopy() const;
bool isDeletable() const; bool isDeletable() const;
bool inTrash() const; bool inTrash() const;
bool operator ==( const UBFeature &f )const; bool operator ==( const UBFeature &f )const;

@ -54,6 +54,10 @@ DelegateButton::DelegateButton(const QString & fileName, QGraphicsItem* pDelegat
: QGraphicsSvgItem(fileName, parent) : QGraphicsSvgItem(fileName, parent)
, mDelegated(pDelegated) , mDelegated(pDelegated)
, mIsTransparentToMouseEvent(false) , mIsTransparentToMouseEvent(false)
, mIsPressed(false)
, mProgressTimerId(-1)
, mPressProgres(0)
, mShowProgressIndicator(false)
, mButtonAlignmentSection(section) , mButtonAlignmentSection(section)
{ {
setAcceptedMouseButtons(Qt::LeftButton); setAcceptedMouseButtons(Qt::LeftButton);
@ -71,26 +75,75 @@ void DelegateButton::setFileName(const QString & fileName)
QGraphicsSvgItem::setSharedRenderer(new QSvgRenderer (fileName, this)); QGraphicsSvgItem::setSharedRenderer(new QSvgRenderer (fileName, this));
} }
void DelegateButton::mousePressEvent(QGraphicsSceneMouseEvent *event) void DelegateButton::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mShowProgressIndicator) {
QTimer::singleShot(300, this, SLOT(startShowProgress()));
}
mIsPressed = true;
// make sure delegate is selected, to avoid control being hidden // make sure delegate is selected, to avoid control being hidden
mPressedTime = QTime::currentTime(); mPressedTime = QTime::currentTime();
event->setAccepted(!mIsTransparentToMouseEvent); event->setAccepted(!mIsTransparentToMouseEvent);
} }
void DelegateButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void DelegateButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mShowProgressIndicator && mProgressTimerId != -1) {
killTimer(mProgressTimerId);
mPressProgres = 0;
}
mIsPressed = false;
int timeto = qAbs(QTime::currentTime().msecsTo(mPressedTime)); int timeto = qAbs(QTime::currentTime().msecsTo(mPressedTime));
if (timeto < UBSettings::longClickInterval) { if (timeto < UBSettings::longClickInterval) {
emit clicked(); emit clicked();
qDebug() << "clicked";
} else { } else {
emit longClicked(); emit longClicked();
qDebug() << "longClicked";
} }
event->setAccepted(!mIsTransparentToMouseEvent); event->setAccepted(!mIsTransparentToMouseEvent);
update();
}
void DelegateButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QGraphicsSvgItem::paint(painter, option, widget);
if (mIsPressed && mShowProgressIndicator) {
QPen pen;
pen.setBrush(Qt::darkRed);
pen.setWidth(3);
painter->save();
painter->setPen(pen);
int spanAngle = qMin(mPressProgres, UBSettings::longClickInterval) * 360 / UBSettings::longClickInterval;
painter->drawArc(option->rect.adjusted(pen.width(), pen.width(), -pen.width(), -pen.width()), 16 * 90, -16 * spanAngle);
painter->restore();
}
}
void DelegateButton::timerEvent(QTimerEvent *event)
{
if (event->timerId() == mProgressTimerId) {
mPressProgres = qAbs(QTime::currentTime().msecsTo(mPressedTime));
update();
}
}
void DelegateButton::startShowProgress()
{
if (mIsPressed) {
mProgressTimerId = startTimer(37);
}
} }
UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent, bool respectRatio, bool canRotate, bool useToolBar) UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent, bool respectRatio, bool canRotate, bool useToolBar)
@ -139,11 +192,13 @@ void UBGraphicsItemDelegate::init()
mButtons << mMenuButton; mButtons << mMenuButton;
mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", mDelegated, mFrame, Qt::BottomLeftSection); mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", mDelegated, mFrame, Qt::BottomLeftSection);
mZOrderUpButton->setShowProgressIndicator(true);
connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp())); connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp()));
connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop())); connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop()));
mButtons << mZOrderUpButton; mButtons << mZOrderUpButton;
mZOrderDownButton = new DelegateButton(":/images/z_layer_down.svg", mDelegated, mFrame, Qt::BottomLeftSection); mZOrderDownButton = new DelegateButton(":/images/z_layer_down.svg", mDelegated, mFrame, Qt::BottomLeftSection);
mZOrderDownButton->setShowProgressIndicator(true);
connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown())); connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown()));
connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom())); connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
mButtons << mZOrderDownButton; mButtons << mZOrderDownButton;

@ -50,6 +50,9 @@ class DelegateButton: public QGraphicsSvgItem
void setFileName(const QString & fileName); void setFileName(const QString & fileName);
void setShowProgressIndicator(bool pShow) {mShowProgressIndicator = pShow;}
bool testShowProgresIndicator() const {return mShowProgressIndicator;}
void setSection(Qt::WindowFrameSection section) {mButtonAlignmentSection = section;} void setSection(Qt::WindowFrameSection section) {mButtonAlignmentSection = section;}
Qt::WindowFrameSection getSection() const {return mButtonAlignmentSection;} Qt::WindowFrameSection getSection() const {return mButtonAlignmentSection;}
@ -57,15 +60,24 @@ class DelegateButton: public QGraphicsSvgItem
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void timerEvent(QTimerEvent *event);
void modified(); void modified();
private slots:
void startShowProgress();
private: private:
QGraphicsItem* mDelegated; QGraphicsItem* mDelegated;
QTime mPressedTime; QTime mPressedTime;
bool mIsTransparentToMouseEvent; bool mIsTransparentToMouseEvent;
bool mIsPressed;
int mProgressTimerId;
int mPressProgres;
bool mShowProgressIndicator;
Qt::WindowFrameSection mButtonAlignmentSection; Qt::WindowFrameSection mButtonAlignmentSection;
signals: signals:

@ -190,7 +190,6 @@ qreal UBZLayerController::changeZLevelTo(QGraphicsItem *item, moveDestination de
iCurElement.toBack(); iCurElement.toBack();
if (iCurElement.findPrevious(item)) { if (iCurElement.findPrevious(item)) {
if (iCurElement.hasPrevious()) { if (iCurElement.hasPrevious()) {
// qreal oldz = iCurElement.peekPrevious().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal();
qreal oldz = item->data(UBGraphicsItemData::ItemOwnZValue).toReal(); qreal oldz = item->data(UBGraphicsItemData::ItemOwnZValue).toReal();
iCurElement.toFront(); iCurElement.toFront();
qreal nextZ = iCurElement.next().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal(); qreal nextZ = iCurElement.next().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal();
@ -199,11 +198,12 @@ qreal UBZLayerController::changeZLevelTo(QGraphicsItem *item, moveDestination de
// //
//if we have some free space between lowest graphics item and layer's bottom bound, //if we have some free space between lowest graphics item and layer's bottom bound,
//insert element close to first element in layer //insert element close to first element in layer
if (nextZ >= curItemLayerTypeData.bottomLimit + curItemLayerTypeData.incStep) { if (nextZ > curItemLayerTypeData.bottomLimit + curItemLayerTypeData.incStep) {
qreal result = nextZ - curItemLayerTypeData.incStep; qreal result = nextZ - curItemLayerTypeData.incStep;
UBGraphicsItem::assignZValue(item, result); UBGraphicsItem::assignZValue(item, result);
} else { } else {
UBGraphicsItem::assignZValue(item, nextZ); UBGraphicsItem::assignZValue(item, nextZ);
bool doubleGap = false; //to detect if we can finish rundown since we can insert item to the free space bool doubleGap = false; //to detect if we can finish rundown since we can insert item to the free space
while (iCurElement.peekNext().value() != item) { while (iCurElement.peekNext().value() != item) {
@ -214,7 +214,8 @@ qreal UBZLayerController::changeZLevelTo(QGraphicsItem *item, moveDestination de
doubleGap = true; doubleGap = true;
break; break;
} else { } else {
UBGraphicsItem::assignZValue(iCurElement.value(), iCurElement.next().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal()); UBGraphicsItem::assignZValue(iCurElement.value(), curNextZ);
iCurElement.next();
} }
} }
if (!doubleGap) { if (!doubleGap) {
@ -237,6 +238,7 @@ qreal UBZLayerController::changeZLevelTo(QGraphicsItem *item, moveDestination de
//Return new z value assigned to item //Return new z value assigned to item
return item->data(UBGraphicsItemData::ItemOwnZValue).toReal(); return item->data(UBGraphicsItemData::ItemOwnZValue).toReal();
} }
itemLayerType::Enum UBZLayerController::typeForData(QGraphicsItem *item) const itemLayerType::Enum UBZLayerController::typeForData(QGraphicsItem *item) const
@ -297,7 +299,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
} }
// Just for debug. Do not delete please // Just for debug. Do not delete please
// connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing())); connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
connect(this, SIGNAL(selectionChanged()), this, SLOT(updateGroupButtonState())); connect(this, SIGNAL(selectionChanged()), this, SLOT(updateGroupButtonState()));
} }
@ -315,10 +317,9 @@ UBGraphicsScene::~UBGraphicsScene()
void UBGraphicsScene::selectionChangedProcessing() void UBGraphicsScene::selectionChangedProcessing()
{ {
if (selectedItems().count()){ if (selectedItems().count()){
// UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is " UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is "
// + QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f')); + QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f'));
qDebug() << "flippable" << selectedItems().first()->data(UBGraphicsItemData::ItemFlippable).toBool() << endl
<< "rotatable" << selectedItems().first()->data(UBGraphicsItemData::ItemRotatable).toBool();
} }
} }

@ -127,12 +127,21 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
} else if (feature.getType() == FEATURE_TRASH) { } else if (feature.getType() == FEATURE_TRASH) {
mActionBar->setCurrentState(IN_TRASH); mActionBar->setCurrentState(IN_TRASH);
} else if (feature.getType() == FEATURE_SEARCH) {
//The search feature behavior is not standard. If features list clicked - show empty element
//else show existing saved features search QWebView
if (sender()->objectName() == objNameFeatureList) {
centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturesWebView);
} else if (sender()->objectName() == objNamePathList) {
centralWidget->switchTo(UBFeaturesCentralWidget::FeaturesWebView);
}
} else { } else {
mActionBar->setCurrentState(IN_FOLDER); mActionBar->setCurrentState(IN_FOLDER);
} }
} else if (feature.getType() == FEATURE_SEARCH) { // } else if (feature.getType() == FEATURE_SEARCH) {
centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturesWebView); // centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturesWebView);
} else { } else {
centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList); centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList);
@ -1067,7 +1076,15 @@ void UBFeatureProperties::onAddToLib()
desc.name = mpElement->getMetadata().value("Title", QString()); desc.name = mpElement->getMetadata().value("Title", QString());
qDebug() << desc.name; qDebug() << desc.name;
desc.srcUrl = mpElement->getFullPath().toString(); desc.srcUrl = mpElement->getFullPath().toString();
qDebug() << desc.srcUrl; QString str1 = mpElement->getFullPath().toString().normalized(QString::NormalizationForm_C);
QString str2 = mpElement->getFullPath().toString().normalized(QString::NormalizationForm_D);
QString str3 = mpElement->getFullPath().toString().normalized(QString::NormalizationForm_KC);
QString str4 = mpElement->getFullPath().toString().normalized(QString::NormalizationForm_KD);
qDebug() << desc.srcUrl << endl
<< "str1" << str1 << endl
<< "str2" << str2 << endl
<< "str3" << str3 << endl
<< "str4" << str4 << endl;
UBDownloadManager::downloadManager()->addFileToDownload(desc); UBDownloadManager::downloadManager()->addFileToDownload(desc);
} }
} }
@ -1411,7 +1428,7 @@ bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelInde
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>(); UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>();
return feature.isFolder() && path.startsWith( feature.getFullVirtualPath() ); return feature.isFolder() && path.startsWith( feature.getFullVirtualPath()) ;
} }
QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLocale & locale ) const QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLocale & locale ) const

Loading…
Cancel
Save