svn path=/trunk/KDE/kdebase/apps/; revision=634228
#include <QDir>
DolphinContextMenu::DolphinContextMenu(DolphinView* parent,
#include <QDir>
DolphinContextMenu::DolphinContextMenu(DolphinView* parent,
- KFileItem* fileInfo,
- const QPoint& pos) :
- m_fileInfo(fileInfo),
- m_pos(pos)
QAction* propertiesAction = popup->addAction(i18n("Properties..."));
QAction* propertiesAction = popup->addAction(i18n("Properties..."));
- QAction* activatedAction = popup->exec(m_pos);
+ QAction* activatedAction = popup->exec(QCursor::pos());
if (activatedAction == propertiesAction) {
new KPropertiesDialog(dolphin->activeView()->url());
}
if (activatedAction == propertiesAction) {
new KPropertiesDialog(dolphin->activeView()->url());
}
QAction* propertiesAction = dolphin->actionCollection()->action("properties");
popup->addAction(propertiesAction);
QAction* propertiesAction = dolphin->actionCollection()->action("properties");
popup->addAction(propertiesAction);
- QAction* activatedAction = popup->exec(m_pos);
+ QAction* activatedAction = popup->exec(QCursor::pos());
if ((bookmarkAction!= 0) && (activatedAction == bookmarkAction)) {
const KUrl selectedUrl(m_fileInfo->url());
if ((bookmarkAction!= 0) && (activatedAction == bookmarkAction)) {
const KUrl selectedUrl(m_fileInfo->url());
* @fileInfo Pointer to the file item the context menu
* is applied. If 0 is passed, the context menu
* is above the viewport.
* @fileInfo Pointer to the file item the context menu
* is applied. If 0 is passed, the context menu
* is above the viewport.
- * @pos Position of the upper left edge of the context menu.
*/
DolphinContextMenu(DolphinView* parent,
*/
DolphinContextMenu(DolphinView* parent,
- KFileItem* fileInfo,
- const QPoint& pos);
virtual ~DolphinContextMenu();
virtual ~DolphinContextMenu();
DolphinView* m_dolphinView;
KFileItem* m_fileInfo;
DolphinView* m_dolphinView;
KFileItem* m_fileInfo;
-void DolphinController::triggerContextMenuRequest(const QPoint& pos,
- const QPoint& globalPos)
+void DolphinController::triggerContextMenuRequest(const QPoint& pos)
- emit requestContextMenu(pos, globalPos);
+ emit requestContextMenu(pos);
}
void DolphinController::triggerActivation()
}
void DolphinController::triggerActivation()
+void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
+ const QPoint& pos)
+{
+ emit urlsDropped(urls, pos);
+}
+
+
void DolphinController::indicateSortingChange(DolphinView::Sorting sorting)
{
emit sortingChanged(sorting);
void DolphinController::indicateSortingChange(DolphinView::Sorting sorting)
{
emit sortingChanged(sorting);
void setUrl(const KUrl& url) { m_url = url; }
const KUrl& url() const { return m_url; }
void setUrl(const KUrl& url) { m_url = url; }
const KUrl& url() const { return m_url; }
- void triggerContextMenuRequest(const QPoint& pos,
- const QPoint& globalPos);
+ void triggerContextMenuRequest(const QPoint& pos);
void triggerActivation();
void triggerActivation();
+ void indicateDroppedUrls(const KUrl::List& urls,
+ const QPoint& pos);
+
void indicateSortingChange(DolphinView::Sorting sorting);
void indicateSortOrderChange(Qt::SortOrder order);
void indicateSortingChange(DolphinView::Sorting sorting);
void indicateSortOrderChange(Qt::SortOrder order);
* context menu should be opened. It is recommended
* to get the corresponding model index from
* this position.
* context menu should be opened. It is recommended
* to get the corresponding model index from
* this position.
- * @param globalPos Global position where the context menu should
- * be opened.
- void requestContextMenu(const QPoint& pos,
- const QPoint& globalPos);
+ void requestContextMenu(const QPoint& pos);
/**
* Is emitted if the view has been activated by e. g. a mouse click.
*/
void activated();
/**
* Is emitted if the view has been activated by e. g. a mouse click.
*/
void activated();
+ /**
+ * Is emitted if the URLs \a urls have been dropped.
+ * @param pos Position relative to the view widget where the
+ * dropping has been done. It is recommended
+ * to get the corresponding model index from
+ * this position to find out the destination.
+ */
+ void urlsDropped(const KUrl::List& urls,
+ const QPoint& pos);
+
/** Is emitted if the sorting has been changed to \a sorting. */
void sortingChanged(DolphinView::Sorting sorting);
/** Is emitted if the sorting has been changed to \a sorting. */
void sortingChanged(DolphinView::Sorting sorting);
void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
{
QTreeView::contextMenuEvent(event);
void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
{
QTreeView::contextMenuEvent(event);
- m_controller->triggerContextMenuRequest(event->pos(),
- event->globalPos());
+ m_controller->triggerContextMenuRequest(event->pos());
}
void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
}
void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
void DolphinDetailsView::dropEvent(QDropEvent* event)
{
void DolphinDetailsView::dropEvent(QDropEvent* event)
{
- QTreeView::dropEvent(event);
- // TODO: temporary deactivated until DolphinController will support this
-
- /*const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
- if (!urls.isEmpty()) {
+ const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
+ if (urls.isEmpty() || (event->source() == this)) {
+ QTreeView::dropEvent(event);
+ }
+ else {
event->acceptProposedAction();
event->acceptProposedAction();
-
- // TODO: handle dropping above a directory
-
- const KUrl& destination = m_controller->url();
- m_controller->emitDropUrlsSignal(urls, destination);
- }*/
+ m_controller->indicateDroppedUrls(urls, event->pos());
+ }
}
void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
}
void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
{
QListView::contextMenuEvent(event);
void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
{
QListView::contextMenuEvent(event);
- m_controller->triggerContextMenuRequest(event->pos(),
- event->globalPos());
+ m_controller->triggerContextMenuRequest(event->pos());
}
void DolphinIconsView::mouseReleaseEvent(QMouseEvent* event)
}
void DolphinIconsView::mouseReleaseEvent(QMouseEvent* event)
void DolphinIconsView::dropEvent(QDropEvent* event)
{
void DolphinIconsView::dropEvent(QDropEvent* event)
{
- QListView::dropEvent(event);
- // TODO: temporary deactivated until DolphinController will support this
-
- /* KFileItem* directory = 0;
- bool dropIntoDirectory = false;
- const QModelIndex index = indexAt(event->pos());
- if (index.isValid()) {
- KFileItem* item = m_dolphinView->fileItem(index);
- assert(item != 0);
- dropIntoDirectory = item->isDir();
- if (dropIntoDirectory) {
- directory = item;
- }
- }
-
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
- if (urls.isEmpty() || (event->source() == this) && !dropIntoDirectory) {
+ if (urls.isEmpty() || (event->source() == this)) {
QListView::dropEvent(event);
}
else {
event->acceptProposedAction();
QListView::dropEvent(event);
}
else {
event->acceptProposedAction();
- const KUrl& destination = (directory == 0) ? m_dolphinView->url() :
- directory->url();
- m_dolphinView->mainWindow()->dropUrls(urls, destination);
- }*/
+ m_controller->indicateDroppedUrls(urls, event->pos());
+ }
}
#include "dolphiniconsview.moc"
}
#include "dolphiniconsview.moc"
m_proxyModel->setSourceModel(m_dirModel);
m_controller = new DolphinController(this);
m_proxyModel->setSourceModel(m_dirModel);
m_controller = new DolphinController(this);
- connect(m_controller, SIGNAL(requestContextMenu(const QPoint&, const QPoint&)),
- this, SLOT(openContextMenu(const QPoint&, const QPoint&)));
+ connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
+ this, SLOT(openContextMenu(const QPoint&)));
+ connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const QPoint&)),
+ this, SLOT(dropUrls(const KUrl::List&, const QPoint&)));
connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
this, SLOT(updateSorting(DolphinView::Sorting)));
connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
this, SLOT(updateSorting(DolphinView::Sorting)));
connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
-void DolphinView::openContextMenu(const QPoint& pos, const QPoint& globalPos)
+void DolphinView::openContextMenu(const QPoint& pos)
item = fileItem(index);
}
item = fileItem(index);
}
- DolphinContextMenu contextMenu(this, item, globalPos);
+ DolphinContextMenu contextMenu(this, item);
+void DolphinView::dropUrls(const KUrl::List& urls,
+ const QPoint& pos)
+{
+ KFileItem* directory = 0;
+ const QModelIndex index = itemView()->indexAt(pos);
+ if (index.isValid()) {
+ KFileItem* item = fileItem(index);
+ assert(item != 0);
+ if (item->isDir()) {
+ // the URLs are dropped above a directory
+ directory = item;
+ }
+ }
+
+ const KUrl& destination = (directory == 0) ? url() :
+ directory->url();
+ m_mainWindow->dropUrls(urls, destination);
+}
+
void DolphinView::updateSorting(DolphinView::Sorting sorting)
{
ViewProperties props(url());
void DolphinView::updateSorting(DolphinView::Sorting sorting)
{
ViewProperties props(url());
*/
void changeNameFilter(const QString& nameFilter);
*/
void changeNameFilter(const QString& nameFilter);
- void openContextMenu(const QPoint& pos, const QPoint& globalPos);
+ /**
+ * Opens the context menu on position \a pos. The position
+ * is used to check whether the context menu is related to an
+ * item or to the viewport.
+ */
+ void openContextMenu(const QPoint& pos);
+
+ /**
+ * Drops the URLs \a urls at the position \a pos.
+ * The position is used to check whether the dropping
+ * is done above an item or above the viewport.
+ */
+ void dropUrls(const KUrl::List& urls,
+ const QPoint& pos);
/**
* Updates the view properties of the current URL to the
/**
* Updates the view properties of the current URL to the