X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/fc5cb366c2b96bc9fc170a5a45308dde0fc64375..5070666ad2cd5fe3e559adca00a52aed5d137153:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 53171966c..7cb594d8e 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -22,10 +22,12 @@ #include #include +#include #include +#include +#include #include #include -#include #include #include @@ -60,8 +62,10 @@ #include "dolphin_detailsmodesettings.h" #include "dolphin_generalsettings.h" #include "dolphinitemlistcontainer.h" +#include "draganddrophelper.h" #include "renamedialog.h" #include "settings/dolphinsettings.h" +#include "versioncontrol/versioncontrolobserver.h" #include "viewmodecontroller.h" #include "viewproperties.h" #include "views/tooltips/tooltipmanager.h" @@ -89,7 +93,8 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : m_currentItemIndex(-1), m_restoredContentsPosition(), m_createdItemUrl(), - m_selectedItems() + m_selectedItems(), + m_versionControlObserver(0) { m_topLayout = new QVBoxLayout(this); m_topLayout->setSpacing(0); @@ -172,6 +177,8 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : connect(controller, SIGNAL(itemExpansionToggleClicked(int)), this, SLOT(slotItemExpansionToggleClicked(int))); connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int))); connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int))); + connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*))); + connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*))); KItemListSelectionManager* selectionManager = controller->selectionManager(); connect(selectionManager, SIGNAL(selectionChanged(QSet,QSet)), @@ -179,6 +186,12 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : m_toolTipManager = new ToolTipManager(this); + m_versionControlObserver = new VersionControlObserver(this); + m_versionControlObserver->setModel(fileItemModel()); + connect(m_versionControlObserver, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString))); + connect(m_versionControlObserver, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); + connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(QString)), this, SIGNAL(operationCompletedMessage(QString))); + applyViewProperties(); m_topLayout->addWidget(m_container); @@ -505,8 +518,16 @@ QString DolphinView::statusBarText() const QList DolphinView::versionControlActions(const KFileItemList& items) const { - Q_UNUSED(items); - return QList(); //m_dolphinViewController->versionControlActions(items); + QList actions; + + if (items.isEmpty()) { + const KFileItem item = fileItemModel()->rootItem(); + actions = m_versionControlObserver->actions(KFileItemList() << item); + } else { + actions = m_versionControlObserver->actions(items); + } + + return actions; } void DolphinView::setUrl(const KUrl& url) @@ -776,6 +797,28 @@ void DolphinView::slotItemUnhovered(int index) emit requestItemInfo(KFileItem()); } +void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) +{ + const KFileItem destItem = fileItemModel()->fileItem(index); + + QDropEvent dropEvent(event->pos().toPoint(), + event->possibleActions(), + event->mimeData(), + event->buttons(), + event->modifiers()); + + DragAndDropHelper::dropUrls(destItem, url(), &dropEvent, this); +} + +void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous) +{ + Q_UNUSED(previous); + Q_ASSERT(qobject_cast(current)); + + KFileItemModel* fileItemModel = static_cast(current); + m_versionControlObserver->setModel(fileItemModel); +} + void DolphinView::slotSelectionChanged(const QSet& current, const QSet& previous) { const int currentCount = current.count();