mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-30 17:15:01 +01:00
Expand correct node and set it as current after drag-drop action.
This commit is contained in:
parent
0bf6a2436d
commit
57e05f34d8
@ -97,7 +97,6 @@ bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
|
||||
|
||||
if (action == Qt::IgnoreAction) {
|
||||
return true;
|
||||
}
|
||||
@ -134,6 +133,8 @@ bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
||||
|
||||
feed_new->setParent(target_item);
|
||||
editFeed(actual_feed, feed_new);
|
||||
|
||||
emit requireItemValidationAfterDragDrop(indexForItem(actual_feed));
|
||||
}
|
||||
else if (dragged_item->kind() == FeedsModelRootItem::Category) {
|
||||
qDebug("Drag-drop action for category '%s' detected, editing the feed.", qPrintable(dragged_item->title()));
|
||||
@ -144,6 +145,8 @@ bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
||||
category_new->clearChildren();
|
||||
category_new->setParent(target_item);
|
||||
editCategory(actual_category, category_new);
|
||||
|
||||
emit requireItemValidationAfterDragDrop(indexForItem(actual_category));
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,10 +176,6 @@ Qt::ItemFlags FeedsModel::flags(const QModelIndex &index) const {
|
||||
default:
|
||||
return base_flags | Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Pokračovat tady: http://qt-project.org/doc/qt-4.8/model-view-programming.html#using-drag-and-drop-with-item-views
|
||||
// neumožnit drag ani drop nad odpadkovým košem
|
||||
}
|
||||
|
||||
QVariant FeedsModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
|
@ -179,6 +179,9 @@ class FeedsModel : public QAbstractItemModel {
|
||||
void assembleCategories(CategoryAssignment categories);
|
||||
void assembleFeeds(FeedAssignment feeds);
|
||||
|
||||
signals:
|
||||
void requireItemValidationAfterDragDrop(const QModelIndex &source_index);
|
||||
|
||||
private:
|
||||
FeedsModelRootItem *m_rootItem;
|
||||
FeedsModelRecycleBin *m_recycleBin;
|
||||
|
@ -53,7 +53,8 @@ FeedsView::FeedsView(QWidget *parent)
|
||||
m_proxyModel = new FeedsProxyModel(this);
|
||||
m_sourceModel = m_proxyModel->sourceModel();
|
||||
|
||||
// Timed actions.
|
||||
// Connections.
|
||||
connect(m_sourceModel, SIGNAL(requireItemValidationAfterDragDrop(QModelIndex)), this, SLOT(validateItemAfterDragDrop(QModelIndex)));
|
||||
connect(m_autoUpdateTimer, SIGNAL(timeout()), this, SLOT(executeNextAutoUpdate()));
|
||||
|
||||
setModel(m_proxyModel);
|
||||
@ -685,3 +686,12 @@ void FeedsView::contextMenuEvent(QContextMenuEvent *event) {
|
||||
m_contextMenuEmptySpace->exec(event->globalPos());
|
||||
}
|
||||
}
|
||||
|
||||
void FeedsView::validateItemAfterDragDrop(const QModelIndex &source_index) {
|
||||
QModelIndex mapped = m_proxyModel->mapFromSource(source_index);
|
||||
|
||||
if (mapped.isValid()) {
|
||||
setExpanded(mapped, true);
|
||||
setCurrentIndex(mapped);
|
||||
}
|
||||
}
|
||||
|
@ -131,9 +131,7 @@ class FeedsView : public QTreeView {
|
||||
// Notifies other components about messages
|
||||
// counts.
|
||||
inline void notifyWithCounts() {
|
||||
emit messageCountsChanged(m_sourceModel->countOfUnreadMessages(),
|
||||
m_sourceModel->countOfAllMessages(),
|
||||
m_sourceModel->hasAnyFeedNewMessages());
|
||||
emit messageCountsChanged(m_sourceModel->countOfUnreadMessages(), m_sourceModel->countOfAllMessages(), m_sourceModel->hasAnyFeedNewMessages());
|
||||
}
|
||||
|
||||
// Selects next/previous item (feed/category) in the list.
|
||||
@ -162,6 +160,9 @@ class FeedsView : public QTreeView {
|
||||
// Show custom context menu.
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
private slots:
|
||||
void validateItemAfterDragDrop(const QModelIndex &source_index);
|
||||
|
||||
signals:
|
||||
// Emitted if user/application requested updating of some feeds.
|
||||
void feedsUpdateRequested(const QList<FeedsModelFeed*> feeds);
|
||||
|
Loading…
x
Reference in New Issue
Block a user