***************************************************************************/
#include "dolphincontroller.h"
+#include "zoomlevelinfo.h"
#include <kdirmodel.h>
#include <QAbstractProxyModel>
#include <QApplication>
+#include <QClipboard>
+#include <QDir>
DolphinController::DolphinController(DolphinView* dolphinView) :
QObject(dolphinView),
- m_zoomInPossible(false),
- m_zoomOutPossible(false),
+ m_zoomLevel(0),
m_openTab(false),
m_url(),
m_dolphinView(dolphinView),
m_itemView = view;
- // TODO: this is a workaround until Qt-issue 176832 has been fixed
- connect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
- this, SLOT(updateOpenTabState()));
+ if (m_itemView != 0) {
+ m_zoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_itemView->iconSize());
+
+ // TODO: this is a workaround until Qt-issue 176832 has been fixed
+ connect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
+ this, SLOT(updateOpenTabState()));
+ }
}
void DolphinController::triggerUrlChangeRequest(const KUrl& url)
emit activationChanged(active);
}
-void DolphinController::triggerZoomIn()
-{
- emit zoomIn();
-}
-
-void DolphinController::triggerZoomOut()
+void DolphinController::setZoomLevel(int level)
{
- emit zoomOut();
+ Q_ASSERT(level >= ZoomLevelInfo::minimumLevel());
+ Q_ASSERT(level <= ZoomLevelInfo::maximumLevel());
+ if (level != m_zoomLevel) {
+ m_zoomLevel = level;
+ emit zoomLevelChanged(m_zoomLevel);
+ }
}
void DolphinController::handleKeyPressEvent(QKeyEvent* event)
}
}
+void DolphinController::replaceUrlByClipboard()
+{
+ const QClipboard* clipboard = QApplication::clipboard();
+ QString text;
+ if (clipboard->mimeData(QClipboard::Selection)->hasText()) {
+ text = clipboard->mimeData(QClipboard::Selection)->text();
+ } else if (clipboard->mimeData(QClipboard::Clipboard)->hasText()) {
+ text = clipboard->mimeData(QClipboard::Clipboard)->text();
+ }
+ if (!text.isEmpty() && QDir::isAbsolutePath(text)) {
+ m_dolphinView->setUrl(KUrl(text));
+ }
+}
+
KFileItem DolphinController::itemForIndex(const QModelIndex& index) const
{
Q_ASSERT(m_itemView != 0);
} else {
m_itemView->clearSelection();
if (!openTab) {
- emit itemEntered(item);
+ emit itemEntered(KFileItem());
}
}
}