+void KItemListContainer::setEnabledFrame(bool enable)
+{
+ QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(viewport());
+ if (enable) {
+ setFrameShape(QFrame::StyledPanel);
+ graphicsView->setPalette(palette());
+ graphicsView->viewport()->setAutoFillBackground(true);
+ } else {
+ setFrameShape(QFrame::NoFrame);
+ // Make the background of the container transparent and apply the window-text color
+ // to the text color, so that enough contrast is given for all color
+ // schemes
+ QPalette p = graphicsView->palette();
+ p.setColor(QPalette::Active, QPalette::Text, p.color(QPalette::Active, QPalette::WindowText));
+ p.setColor(QPalette::Inactive, QPalette::Text, p.color(QPalette::Inactive, QPalette::WindowText));
+ p.setColor(QPalette::Disabled, QPalette::Text, p.color(QPalette::Disabled, QPalette::WindowText));
+ graphicsView->setPalette(p);
+ graphicsView->viewport()->setAutoFillBackground(false);
+ }
+}
+
+bool KItemListContainer::enabledFrame() const
+{
+ const QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(viewport());
+ return graphicsView->autoFillBackground();
+}
+
+void KItemListContainer::keyPressEvent(QKeyEvent *event)
+{
+ // TODO: We should find a better way to handle the key press events in the view.
+ // The reasons why we need this hack are:
+ // 1. Without reimplementing keyPressEvent() here, the event would not reach the QGraphicsView.
+ // 2. By default, the KItemListView does not have the keyboard focus in the QGraphicsScene, so
+ // simply sending the event to the QGraphicsView which is the KItemListContainer's viewport
+ // does not work.
+ KItemListView *view = m_controller->view();
+ if (view) {
+ QApplication::sendEvent(view, event);
+ }
+}
+
+void KItemListContainer::contextMenuEvent(QContextMenuEvent *event)
+{
+ // Note copied from the keyPressEvent() method above because the same reasons probably also apply here.
+ // TODO: We should find a better way to handle the context menu events in the view.
+ // The reasons why we need this hack are:
+ // 1. Without reimplementing contextMenuEvent() here, the event would not reach the QGraphicsView.
+ // 2. By default, the KItemListView does not have the keyboard focus in the QGraphicsScene, so
+ // simply sending the event to the QGraphicsView which is the KItemListContainer's viewport
+ // does not work.
+ KItemListView *view = m_controller->view();
+ if (view) {
+ QApplication::sendEvent(view, event);
+ }
+}
+
+void KItemListContainer::showEvent(QShowEvent *event)