QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(m_d->m_itemsView->rootObject());
connect(rootItem, SIGNAL(itemSelected(int)), this, SLOT(showItemInfo(int)));
connect(rootItem, SIGNAL(itemDragged(int)), this, SLOT(startDragAndDrop(int)));
+ connect(this, SIGNAL(scrollItemsView(QVariant)), rootItem, SLOT(scrollView(QVariant)));
connect(this, SIGNAL(resetItemsView()), rootItem, SLOT(resetView()));
/* create Resources view and its model */
// qDebug() << "showing item info about id" << itemLibId;
}
+void ItemLibrary::wheelEvent(QWheelEvent *event)
+{
+ if (m_d->m_stackedWidget->currentIndex() == 0 &&
+ m_d->m_itemsView->rect().contains(event->pos())) {
+ emit scrollItemsView(event->delta());
+ event->accept();
+ } else
+ QFrame::wheelEvent(event);
+}
+
}
void startDragAndDrop(int itemLibId);
void showItemInfo(int itemLibId);
+protected:
+ void wheelEvent(QWheelEvent *event);
+
signals:
void itemActivated(const QString& itemName);
+ void scrollItemsView(QVariant delta);
void resetItemsView();
private:
// public
+ function scrollView(delta) {
+ scrollbar.scroll(-delta / style.scrollbarWheelDeltaFactor)
+ }
+
function resetView() {
expandAllEntries()
scrollbar.reset()
property string scrollbarGradientMiddleColor: "#656565"
property string scrollbarGradientEndColor: "#888888"
property int scrollbarClickScrollAmount: 40
+ property int scrollbarWheelDeltaFactor: 4
property string itemNameTextColor: "#FFFFFF"
property variant flickable
+ function scroll(delta) {
+ handle.y = Math.max(0, Math.min(scrollHeight, handle.y + delta))
+ }
+
function reset() {
handle.y = 0
}
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: handle.top
- onClicked: handle.y = Math.max(0, handle.y - style.scrollbarClickScrollAmount)
+ onClicked: scroll(-style.scrollbarClickScrollAmount)
}
Item {
anchors.right: parent.right
anchors.top: handle.bottom
anchors.bottom: parent.bottom
- onClicked: handle.y = Math.min(scrollHeight, handle.y + style.scrollbarClickScrollAmount)
+ onClicked: scroll(style.scrollbarClickScrollAmount)
}
}