when panel is hidden.
{
qDebug() << __PRETTY_FUNCTION__;
+ QListWidgetItem::setSelected(selected);
m_selected = selected;
setData(ITEM_EXPANDED_INDEX, m_selected);
m_friendListHeaderWidget->setAutoFillBackground(true);
m_routeButton = new QPushButton(tr("Route to friend"));
+ m_routeButton->setDisabled(true);
QPalette labelPalette = m_friendListHeaderWidget->palette();
labelPalette.setColor(QPalette::Background, Qt::black);
m_friendListView->setItemDelegate(new FriendListItemDelegate(this));
QVBoxLayout *listViewLayout = new QVBoxLayout;
- listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, 0, PANEL_MARGIN_RIGHT, 0);
+ listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
+ PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
listViewLayout->addWidget(m_friendListView);
friendListPanelLayout->addWidget(m_routeButton);
connect(m_routeButton, SIGNAL(clicked()),
this, SLOT(routeToSelectedFriend()));
+ connect(m_friendListView, SIGNAL(clicked(QModelIndex)),
+ this, SLOT(setRouteButtonDisabled()));
+
/// @todo remove old filterLayout when new panel are merged
//////////////////////////////////////////////////////////////////////////
QWidget::hideEvent(event);
updateKeyboardGrabbing();
clearFiltering();
+
+ m_friendListView->clearSelection();
}
void FriendListPanel::routeToSelectedFriend()
}
}
+void FriendListPanel::setRouteButtonDisabled()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_routeButton->setDisabled(m_friendListView->selectedItems().isEmpty());
+}
+
void FriendListPanel::showEvent(QShowEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
void routeToSelectedFriend();
/**
+ * @brief Sets route button disabled.
+ *
+ * Disabled if there isn't any list item selected.
+ */
+ void setRouteButtonDisabled();
+
+ /**
* @brief Slot to show friends in list.
*
* Shows only friends that are on userIDs list
ListItem *ListView::selectedItem()
{
qDebug() << __PRETTY_FUNCTION__;
+ QList<QListWidgetItem *> selectedListItems = selectedItems();
- return m_previousItem;
+ if (!selectedListItems.isEmpty())
+ return dynamic_cast<ListItem *>(selectedListItems.first());
+ else
+ return 0;
}
void ListView::setSelectedItem(ListItem *item)
this,
SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
+ connect(m_locationListView, SIGNAL(clicked(QModelIndex)),
+ this, SLOT(setRouteButtonDisabled()));
+
connect(m_routeButton, SIGNAL(clicked()),
this, SLOT(routeToSelectedLocation()));
this, SIGNAL(requestSearchLocation()));
}
+void RoutingPanel::hideEvent(QHideEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ Q_UNUSED(event);
+
+ m_locationListView->clearSelection();
+ m_routeWaypointListView->clearSelection();
+}
+
void RoutingPanel::populateLocationListView(const QList<Location> &locations)
{
qDebug() << __PRETTY_FUNCTION__;
emit showPanelRequested(this);
}
+
+void RoutingPanel::setRouteButtonDisabled()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_routeButton->setDisabled(m_locationListView->selectedItems().isEmpty());
+}
RoutingPanel(QWidget *parent = 0);
/*******************************************************************************
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
+protected:
+ /**
+ * @brief Re-implemented from QWidget::hideEvent()
+ *
+ * Clears lists' selections.
+ *
+ * @param event
+ */
+ void hideEvent(QHideEvent *event);
+
+/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
private slots:
*/
void setRoute(Route &route);
+ /**
+ * @brief Sets route button disabled.
+ *
+ * Disabled if there isn't any list item selected.
+ */
+ void setRouteButtonDisabled();
+
/*******************************************************************************
* SIGNALS
******************************************************************************/