setSpacing(spacing);
setMargin(margin);
-
+
// Create "Icon" properties
m_iconSizeGroupBox = new IconSizeGroupBox(this);
m_iconSizeGroupBox->setSizePolicy(sizePolicy);
-
+
const int min = ZoomLevelInfo::minimumLevel();
const int max = ZoomLevelInfo::maximumLevel();
m_iconSizeGroupBox->setDefaultSizeRange(min, max);
m_iconSizeGroupBox->setPreviewSizeRange(min, max);
-
+
connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)),
this, SIGNAL(changed()));
connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)),
const QSize iconSize(settings->iconSize(), settings->iconSize());
const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
-
+
const QSize previewSize(settings->previewSize(), settings->previewSize());
const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
// Create "Icon" properties
m_iconSizeGroupBox = new IconSizeGroupBox(this);
m_iconSizeGroupBox->setSizePolicy(sizePolicy);
-
+
const int min = ZoomLevelInfo::minimumLevel();
const int max = ZoomLevelInfo::maximumLevel();
m_iconSizeGroupBox->setDefaultSizeRange(min, max);
m_iconSizeGroupBox->setPreviewSizeRange(min, max);
-
+
connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)),
this, SIGNAL(changed()));
connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)),
// create "Text" properties
QWidget* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
textGroup->setSizePolicy(sizePolicy);
-
+
QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
m_fontRequester = new DolphinFontRequester(textGroup);
connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
QHBoxLayout* textLayout = new QHBoxLayout(textGroup);
textLayout->addWidget(fontLabel, 0, Qt::AlignRight);
textLayout->addWidget(m_fontRequester);
-
+
// create "Expandable Folders" checkbox
m_expandableFolders = new QCheckBox(i18nc("@option:check", "Expandable folders"), this);
connect(m_expandableFolders, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
const QSize iconSize(settings->iconSize(), settings->iconSize());
const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
-
+
const QSize previewSize(settings->previewSize(), settings->previewSize());
const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
-
+
if (settings->useSystemFont()) {
m_fontRequester->setMode(DolphinFontRequester::SystemFont);
} else {
}
}
-
int DolphinApplication::newInstance()
{
KCmdLineArgs::setCwd(QDir::currentPath().toUtf8());
{
const int size = ZoomLevelInfo::iconSizeForZoomLevel(level);
ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
-
+
const bool showPreview = m_controller->dolphinView()->showPreview();
if (showPreview) {
settings->setPreviewSize(size);
} else {
settings->setIconSize(size);
}
-
+
updateDecorationSize(showPreview);
}
}
column->disconnect();
column->deleteLater();
- }
+ }
}
#include "dolphincolumnview.moc"
setVerticalScrollMode(QListView::ScrollPerPixel);
setHorizontalScrollMode(QListView::ScrollPerPixel);
-
+
new DolphinViewAutoScroller(this);
// apply the column mode settings to the widget
connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
this, SLOT(updateFont()));
-
+
FolderExpander* folderExpander = new FolderExpander(this, m_proxyModel);
folderExpander->setEnabled(DolphinSettings::instance().generalSettings()->autoExpandFolders());
connect (folderExpander, SIGNAL(enterDir(const QModelIndex&)),
event->ignore();
return;
}
-
+
const int height = m_decorationSize.height();
const int step = (height >= KIconLoader::SizeHuge) ? height / 10 : (KIconLoader::SizeHuge - height) / 2;
verticalScrollBar()->setSingleStep(step);
KFileItem itemAt(const QPoint& pos) const;
KFileItemList selectedItems() const;
-
+
/**
* Returns the MIME data for the selected items.
*/
newMenu->slotCheckUpToDate();
newMenu->setPopupFiles(m_fileInfo.url());
newMenu->setEnabled(capabilities().supportsWriting());
-
+
KMenu* menu = newMenu->menu();
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
menu->setIcon(KIcon("document-new"));
popup->addMenu(newMenu->menu());
popup->addSeparator();
-
+
// insert 'Open in new window' and 'Open in new tab' entries
popup->addAction(m_mainWindow->actionCollection()->action("open_in_new_window"));
popup->addAction(m_mainWindow->actionCollection()->action("open_in_new_tab"));
QAction* action = popup->exec(QCursor::pos());
if (action == propertiesAction) {
const KUrl& url = m_mainWindow->activeViewContainer()->url();
-
+
KPropertiesDialog* dialog = new KPropertiesDialog(url, m_mainWindow);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
KConfigGroup configGroup(globalConfig, "KDE");
bool showDeleteCommand = configGroup.readEntry("ShowDeleteCommand", false);
-
+
const KUrl& url = m_mainWindow->activeViewContainer()->url();
if (url.isLocalFile()) {
QAction* moveToTrashAction = collection->action("move_to_trash");
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(updateMouseButtonState()));
/**
* Sets the zoom level to \a level and emits the signal zoomLevelChanged().
- * It must be assured that the used level is inside the range
+ * It must be assured that the used level is inside the range
* DolphinController::zoomLevelMinimum() and
* DolphinController::zoomLevelMaximum().
* Is invoked by the abstract Dolphin view.
*/
void setZoomLevel(int level);
int zoomLevel() const;
-
+
/**
* Tells the view implementation to zoom out by emitting the signal zoomOut()
* and is invoked by the abstract Dolphin view.
* nothing will be done.
*/
void replaceUrlByClipboard();
-
+
/** Emits the signal hideToolTip(). */
void emitHideToolTip();
* user has triggered an item.
*/
void triggerItem(const QModelIndex& index);
-
+
/**
* Emits the signal tabRequested(), if the file item for the index \a index
* represents a directory and when the middle mouse button has been pressed.
* must connect to this signal if it supports zooming.
*/
void zoomLevelChanged(int level);
-
+
/**
* Is emitted if the abstract view should hide an open tooltip.
*/
setVerticalScrollMode(QTreeView::ScrollPerPixel);
setHorizontalScrollMode(QTreeView::ScrollPerPixel);
-
+
const DolphinView* view = controller->dolphinView();
connect(view, SIGNAL(showPreviewChanged()),
this, SLOT(slotShowPreviewChanged()));
connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
this, SLOT(updateFont()));
-
+
m_useDefaultIndexAt = false;
}
m_band.destination = m_band.origin;
m_band.originalSelection = selectionModel()->selection();
}
- }
+ }
}
void DolphinDetailsView::mouseMoveEvent(QMouseEvent* event)
event->ignore();
return;
}
-
+
const int height = m_decorationSize.height();
const int step = (height >= KIconLoader::SizeHuge) ? height / 10 : (KIconLoader::SizeHuge - height) / 2;
verticalScrollBar()->setSingleStep(step);
void DolphinDetailsView::updateElasticBand()
{
if (m_band.show) {
- QRect dirtyRegion(elasticBandRect());
+ QRect dirtyRegion(elasticBandRect());
const QPoint scrollPos(horizontalScrollBar()->value(), verticalScrollBar()->value());
m_band.destination = viewport()->mapFromGlobal(QCursor::pos()) + scrollPos;
// Going above the (logical) top-left of the view causes complications during selection;
m_band.destination.setY(0);
if (m_band.destination.x() < 0)
m_band.destination.setX(0);
-
+
dirtyRegion = dirtyRegion.united(elasticBandRect());
setDirtyRegion(dirtyRegion);
}
{
const int size = ZoomLevelInfo::iconSizeForZoomLevel(level);
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
-
+
const bool showPreview = m_controller->dolphinView()->showPreview();
if (showPreview) {
settings->setPreviewSize(size);
} else {
settings->setIconSize(size);
}
-
+
updateDecorationSize(showPreview);
}
// Do some quick checks to see if we can rule out the need to
// update the selection.
Q_ASSERT(uniformRowHeights());
- QModelIndex dummyIndex = model()->index(0, 0);
+ QModelIndex dummyIndex = model()->index(0, 0);
if (!dummyIndex.isValid()) {
// No items in the model presumably.
return;
(selRect.top() / rowHeight == oldSelRect.top() / rowHeight) &&
(selRect.bottom() / rowHeight == oldSelRect.bottom() / rowHeight);
if (coveringSameRows) {
- // Covering the same rows, but have we moved far enough horizontally
+ // Covering the same rows, but have we moved far enough horizontally
// that we might have (de)selected some other items?
const bool itemSelectionChanged =
((selRect.left() > oldSelRect.left()) &&
(selRect.left() > m_band.insideNearestLeftEdge)) ||
- ((selRect.left() < oldSelRect.left()) &&
+ ((selRect.left() < oldSelRect.left()) &&
(selRect.left() <= m_band.outsideNearestLeftEdge)) ||
((selRect.right() < oldSelRect.right()) &&
(selRect.left() >= m_band.insideNearestRightEdge)) ||
// Go through all indexes between the top and bottom of boundingRect, and
// update the selection.
- const int verticalCutoff = boundingRect.bottom();
+ const int verticalCutoff = boundingRect.bottom();
QModelIndex currIndex = startIndex;
QModelIndex lastIndex;
bool allItemsInBoundDone = false;
- // Calling selectionModel()->select(...) for each item that needs to be
+ // Calling selectionModel()->select(...) for each item that needs to be
// toggled is slow as each call emits selectionChanged(...) so store them
// and do the selection toggle in one batch.
QItemSelection itemsToToggle;
- // QItemSelection's deal with continuous ranges of indexes better than
+ // QItemSelection's deal with continuous ranges of indexes better than
// single indexes, so try to portion items that need to be toggled into ranges.
bool formingToggleIndexRange = false;
QModelIndex toggleIndexRangeBegin = QModelIndex();
const int cl = currIndexRect.left();
const int sl = selRect.left();
const int sr = selRect.right();
- // "The right edge of the name is outside of the rect but nearer than m_outsideNearestLeft", etc
+ // "The right edge of the name is outside of the rect but nearer than m_outsideNearestLeft", etc
if ((cr < sl && cr > m_band.outsideNearestLeftEdge)) {
m_band.outsideNearestLeftEdge = cr;
}
formingToggleIndexRange = false;
// If this is the last item in the bounds and it is also the beginning of a range,
// don't toggle lastIndex - it will already have been dealt with.
- if (!allItemsInBoundDone || toggleIndexRangeBegin != currIndex) {
+ if (!allItemsInBoundDone || toggleIndexRangeBegin != currIndex) {
itemsToToggle.select(toggleIndexRangeBegin, lastIndex);
}
// Need to start a new range immediately with currIndex?
QRect elasticBandRect() const;
void setZoomLevel(int level);
-
+
void slotShowPreviewChanged();
/**
* with the mouse.
*/
void slotHeaderSectionResized(int logicalIndex, int oldSize, int newSize);
-
+
/**
* Changes the alternating row colors setting depending from
* the activation state \a active.
void updateFont();
/**
- * If the elastic band is currently shown, update the elastic band based on
- * the current mouse position and ensure that the selection is the set of items
+ * If the elastic band is currently shown, update the elastic band based on
+ * the current mouse position and ensure that the selection is the set of items
* intersecting it.
*/
void updateElasticBandSelection();
struct ElasticBand
{
ElasticBand();
-
+
// Elastic band origin and destination coordinates are relative to t
// he origin of the view, not the viewport.
bool show;
// on the last elastic band shape.
QPoint lastSelectionOrigin;
QPoint lastSelectionDestination;
-
+
// If true, compute the set of selected elements from scratch (slower)
bool ignoreOldInfo;
-
+
// Edges of the filenames that are closest to the edges of oldSelectionRect.
// Used to decide whether horizontal changes in the elastic band are likely
// to require us to re-check which items are selected.
{
if (m_hasMinimizedNameColumn && (index.column() == KDirModel::Name)) {
QStyleOptionViewItemV4 opt(option);
-
+
const QAbstractProxyModel* proxyModel = static_cast<const QAbstractProxyModel*>(index.model());
const KDirModel* dirModel = static_cast<const KDirModel*>(proxyModel->sourceModel());
const QModelIndex dirIndex = proxyModel->mapToSource(index);
{
QFontMetrics fontMetrics(option.font);
int width = option.decorationSize.width() + fontMetrics.width(name) + 16;
-
+
const int defaultWidth = option.rect.width();
if ((defaultWidth > 0) && (defaultWidth < width)) {
width = defaultWidth;
*/
void setMinimizedNameColumn(bool minimized);
bool hasMinimizedNameColumn() const;
-
+
virtual void paint(QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const;
-
+
/**
* Returns the minimized width of the name column for the name \a name. This method
* is also used in DolphinDetailsView to handle the selection of items correctly.
*/
static int nameColumnWidth(const QString& name, const QStyleOptionViewItem& option);
-
+
private:
bool m_hasMinimizedNameColumn;
};
event->ignore();
return;
}
-
+
horizontalScrollBar()->setSingleStep(m_itemSize.width() / 10);
verticalScrollBar()->setSingleStep(m_itemSize.height() / 10);
-
+
KCategorizedView::wheelEvent(event);
// if the icons are aligned left to right, the vertical wheel event should
// be applied to the horizontal scrollbar
// shown due to DolphinViewContainer::restoreView().
return;
}
-
+
DolphinViewContainer* view = activeViewContainer();
if (view != 0) {
view->setUrl(url);
{
openNewTab(m_activeViewContainer->url());
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
-
+
KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
if (navigator->isUrlEditable()) {
// if a new tab is opened and the URL is editable, assure that
openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab"));
openInNewTab->setIcon(KIcon("tab-new"));
connect(openInNewTab, SIGNAL(triggered()), this, SLOT(openInNewTab()));
-
+
KAction* openInNewWindow = actionCollection()->addAction("open_in_new_window");
openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
openInNewWindow->setIcon(KIcon("window-new"));
* view is replaced by \a url.
*/
void handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons);
-
+
/**
- * Is connected to the KTabBar signal testCanDecode() and adjusts
+ * Is connected to the KTabBar signal testCanDecode() and adjusts
* the output parameter \a accept.
*/
void slotTestCanDecode(const QDragMoveEvent* event, bool& accept);
// initialize message label
m_messageLabel = new StatusBarMessageLabel(this);
m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-
+
// initialize zoom slider
m_zoomWidget = new QWidget(this);
m_zoomOut = new QToolButton(m_zoomWidget);
m_zoomOut->setIcon(KIcon("zoom-out"));
m_zoomOut->setAutoRaise(true);
-
+
m_zoomSlider = new QSlider(Qt::Horizontal, m_zoomWidget);
m_zoomSlider->setPageStep(1);
-
+
const int min = ZoomLevelInfo::minimumLevel();
const int max = ZoomLevelInfo::maximumLevel();
m_zoomSlider->setRange(min, max);
m_zoomSlider->setValue(view->zoomLevel());
-
+
m_zoomIn = new QToolButton(m_zoomWidget);
m_zoomIn->setIcon(KIcon("zoom-in"));
m_zoomIn->setAutoRaise(true);
-
+
QHBoxLayout* zoomWidgetLayout = new QHBoxLayout(m_zoomWidget);
zoomWidgetLayout->setSpacing(0);
zoomWidgetLayout->setMargin(0);
zoomWidgetLayout->addWidget(m_zoomOut);
zoomWidgetLayout->addWidget(m_zoomSlider);
zoomWidgetLayout->addWidget(m_zoomIn);
-
+
connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoomLevel(int)));
connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(showZoomSliderToolTip(int)));
connect(m_view, SIGNAL(zoomLevelChanged(int)), m_zoomSlider, SLOT(setValue(int)));
connect(m_zoomOut, SIGNAL(clicked()), this, SLOT(zoomOut()));
connect(m_zoomIn, SIGNAL(clicked()), this, SLOT(zoomIn()));
-
+
// initialize space information
m_spaceInfo = new StatusBarSpaceInfo(this);
m_spaceInfo->setUrl(m_view->url());
-
+
// initialize progress information
m_progressText = new QLabel(this);
m_progressText->hide();
m_spaceInfo->setFixedHeight(contentHeight);
m_progressBar->setFixedSize(200, contentHeight);
m_zoomWidget->setFixedSize(150, contentHeight);
-
+
setExtensionsVisible(true);
}
if ((msg == m_messageLabel->text()) && (type == m_messageLabel->type())) {
return;
}
-
+
m_messageLabel->setMessage(msg, type);
const int widthGap = m_messageLabel->widthGap();
const int spaceInfoWidth = settings->showSpaceInfo() ? m_spaceInfo->minimumWidth() : 0;
const int zoomWidgetWidth = settings->showZoomSlider() ? m_zoomWidget->minimumWidth() : 0;
const int widgetsWidth = spaceInfoWidth + zoomWidgetWidth;
-
+
if (widthGap + widgetsWidth <= 0) {
setExtensionsVisible(true);
}
QPoint global = m_zoomSlider->rect().topLeft();
global.ry() += m_zoomSlider->height() / 2;
QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
- QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
+ QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
}
void DolphinStatusBar::setExtensionsVisible(bool visible)
spaceInfoVisible = settings->showSpaceInfo();
zoomSliderVisible = settings->showZoomSlider();
}
-
+
m_spaceInfo->setVisible(spaceInfoVisible);
m_zoomWidget->setVisible(zoomSliderVisible);
}
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-
+
#include "dolphintooltip.h"
#include <kicon.h>
}
void DolphinBalloonTooltipDelegate::paint(QPainter* painter, const KStyleOptionToolTip* option, const KToolTipItem* item) const
-{
+{
KStyleOptionToolTip updatedStyleOption = *option;
updatedStyleOption.decorationSize = QSize(PREVIEW_WIDTH, PREVIEW_HEIGHT);
return KFormattedBalloonTipDelegate::paint(painter, &updatedStyleOption, item);
}
emit modeChanged();
-
+
updateZoomLevel(oldZoomLevel);
if (m_showPreview) {
loadDirectory(viewPropsUrl);
const QString name = list.first().name();
text = (folderCount == 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name) :
i18nc("@info:status", "<filename>%1</filename> selected (%2)",
- name, KIO::convertSize(totalFileSize));
+ name, KIO::convertSize(totalFileSize));
} else {
// at least 2 items are selected
const QString foldersText = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount);
// TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
// as one operation instead of n rename operations like it is done now...
Q_ASSERT(newName.contains('#'));
-
+
// currently the items are sorted by the selection order, resort
// them by the file name
qSort(items.begin(), items.end(), lessThan);
disconnect(view);
m_controller->disconnect(view);
view->disconnect();
-
+
bool deleteView = true;
foreach (const QAbstractItemView* expandedView, m_expandedViews) {
if (view == expandedView) {
{
/**
* The directory items are shown as icons including an
- * icon name.
+ * icon name.
*/
IconsView = 0,
*/
void setZoomLevel(int level);
int zoomLevel() const;
-
+
/**
* Returns true, if zooming in is possible. If false is returned,
* the maximum zooming level has been reached.
* filtering and hierarchical previews into account.
*/
void calculateItemCount(int& fileCount, int& folderCount, KIO::filesize_t& totalFileSize) const;
-
+
/**
* Returns a textual representation of the state of the current
* folder or selected items, suitable for use in the status bar.
/** Is emitted if the additional information shown for this view has been changed. */
void additionalInfoChanged();
-
+
/** Is emitted if the zoom level has been changed by zooming in or out. */
void zoomLevelChanged(int level);
* to m_currentItemUrl.
*/
void restoreCurrentItem();
-
+
/**
* Is connected to the enterDir() signal from the FolderExpander
* and triggers the entering of the directory indicated by \a index.
* Pastes the clipboard data into the URL \a url.
*/
void pasteToUrl(const KUrl& url);
-
+
/**
* Checks whether the current item view has the same zoom level
* as \a oldZoomLevel. If this is not the case, the zoom level
* is emitted.
*/
void updateZoomLevel(int oldZoomLevel);
-
+
/**
* Returns a list of URLs for all selected items. The list is
* simplified, so that when the URLs are part of different tree
* this method has been introduced for convenience.
*/
bool isColumnViewActive() const;
-
+
/**
* Deletes all views from m_expandedViews except if the view
* is currently shown.
*/
void deleteExpandedViews();
-
+
/**
* Returns the MIME data for all selected items.
*/
KUrl m_rootUrl;
KUrl m_currentItemUrl;
-
+
QList<QAbstractItemView*> m_expandedViews;
};
* Updates the state of the 'Sort by' actions.
*/
void slotSortingChanged(DolphinView::Sorting sorting);
-
+
/**
* Updates the state of the 'Zoom In' and 'Zoom Out' actions.
- */
+ */
void slotZoomLevelChanged(int level);
/**
m_itemView->setAutoScroll(false);
m_itemView->viewport()->installEventFilter(this);
m_itemView->installEventFilter(this);
-
+
m_timer = new QTimer(this);
m_timer->setSingleShot(false);
m_timer->setInterval(1000 / 25); // 25 frames per second
m_rubberBandSelection = true;
}
break;
-
+
case QEvent::MouseMove:
if (m_rubberBandSelection) {
triggerAutoScroll();
}
break;
-
+
case QEvent::MouseButtonRelease:
m_rubberBandSelection = false;
stopAutoScroll();
break;
-
+
case QEvent::DragEnter:
case QEvent::DragMove:
m_rubberBandSelection = false;
triggerAutoScroll();
break;
-
+
case QEvent::Drop:
case QEvent::DragLeave:
m_rubberBandSelection = false;
stopAutoScroll();
break;
-
+
default:
break;
}
default:
break;
}
- }
-
+ }
+
return QObject::eventFilter(watched, event);
}
if (verticalScrollBar != 0) {
const int value = verticalScrollBar->value();
verticalScrollBar->setValue(value + m_scrollInc);
-
+
}
QScrollBar* horizontalScrollBar = m_itemView->horizontalScrollBar();
if (horizontalScrollBar != 0) {
const int value = horizontalScrollBar->value();
horizontalScrollBar->setValue(value + m_scrollInc);
-
+
}
-
+
if (m_rubberBandSelection) {
// The scrolling does not lead to an update of the rubberband
// selection. Fake a mouse move event to let the QAbstractItemView
// no scrollbars are shown at all, so no autoscrolling is necessary
return;
}
-
+
QWidget* viewport = m_itemView->viewport();
const QPoint pos = viewport->mapFromGlobal(QCursor::pos());
if (verticalScrolling) {
if (horizontalScrolling) {
calculateScrollIncrement(pos.x(), viewport->width());
}
-
+
if (m_timer->isActive()) {
if (m_scrollInc == 0) {
m_timer->stop();
const int maxSpeed = 32;
const int speedLimiter = 8;
const int autoScrollBorder = 32;
-
+
if (cursorPos < autoScrollBorder) {
m_scrollInc = -minSpeed + (cursorPos - autoScrollBorder) / speedLimiter;
if (m_scrollInc < -maxSpeed) {
public:
DolphinViewAutoScroller(QAbstractItemView* parent);
virtual ~DolphinViewAutoScroller();
-
+
protected:
virtual bool eventFilter(QObject* watched, QEvent* event);
private slots:
void scrollViewport();
void scrollToCurrentIndex();
-
+
private:
void triggerAutoScroll();
void stopAutoScroll();
-
+
/**
* Calculates the scroll increment m_scrollInc dependent from
* the cursor position \a cursorPos and the range 0 - \a rangeSize - 1.
*/
void calculateScrollIncrement(int cursorPos, int rangeSize);
-
+
private:
bool m_rubberBandSelection;
int m_scrollInc;
}
} else {
showErrorMessage(i18nc("@info:status",
- "Protocol not supported by Dolphin, Konqueror has been launched"));
+ "Protocol not supported by Dolphin, Konqueror has been launched"));
}
const QString command = app + ' ' + url.pathOrUrl();
KRun::runCommand(command, app, app, this);
const DolphinView* view() const;
DolphinView* view();
-
+
/**
* Refreshes the view container to get synchronized with the (updated) Dolphin settings.
*/
* into the URL navigator.
*/
void saveRootUrl(const KUrl& url);
-
+
/**
* Is connected with the URL navigator and drops the URLs
* above the destination \a destination.
*/
void dropUrls(const KUrl& destination, QDropEvent* event);
-
+
/**
* Is invoked when a redirection is done and changes the
* URL of the URL navigator to \a newUrl without triggering
if (data == 0) {
return;
}
-
+
if (controller != 0) {
controller->emitHideToolTip();
}
{
const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile());
const KUrl destination = dropToItem ? destItem.url() : destPath;
-
+
const QMimeData* mimeData = event->mimeData();
if (mimeData->hasFormat("application/x-kde-dndextract")) {
QString remoteDBusClient = mimeData->data("application/x-kde-dndextract");
"org.kde.DndExtract", "extractFilesTo");
message.setArguments(QVariantList() << destination.path());
QDBusConnection::sessionBus().call(message);
- } else {
+ } else {
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if ((urls.count() == 1) && (urls.first() == destination)) {
emit errorMessage(i18nc("@info:status", "A folder cannot be dropped into itself"));
public:
static DragAndDropHelper& instance();
-
+
/**
* Returns true, if Dolphin supports the dragging of
* the given mime data.
*/
bool isMimeDataSupported(const QMimeData* mimeData) const;
-
+
/**
* Creates a drag object for the view \a itemView for all selected items.
*/
void startDrag(QAbstractItemView* itemView,
Qt::DropActions supportedActions,
DolphinController* controller = 0);
-
+
/**
* Handles the dropping of URLs to the given
* destination. A context menu with the options
QWidget* widget);
signals:
void errorMessage(const QString& msg);
-
+
private:
DragAndDropHelper();
-
+
friend class DragAndDropHelperSingleton;
};
kWarning() << "Need a proxyModel!";
return; // Not valid.
}
- KDirModel *m_dirModel = qobject_cast< KDirModel* >( m_proxyModel->sourceModel() );
+ KDirModel *m_dirModel = qobject_cast< KDirModel* >( m_proxyModel->sourceModel() );
if (m_dirModel == 0) {
kWarning() << "Expected m_proxyModel's sourceModel() to be a KDirModel!";
return; // Not valid.
// Initialise auto-expand timer.
m_autoExpandTriggerTimer = new QTimer(this);
m_autoExpandTriggerTimer->setSingleShot(true);
- connect(m_autoExpandTriggerTimer, SIGNAL(timeout()),
+ connect(m_autoExpandTriggerTimer, SIGNAL(timeout()),
this, SLOT(autoExpandTimeout()));
// The view scrolling complicates matters, so we want to
// needing to pass in m_proxyModel that has a KDirModel as its sourceModel() ... ?
QModelIndex proxyIndexToExpand = m_view->indexAt(m_autoExpandPos);
QModelIndex indexToExpand = m_proxyModel->mapToSource(proxyIndexToExpand);
- KDirModel* m_dirModel = qobject_cast< KDirModel* >(m_proxyModel->sourceModel());
+ KDirModel* m_dirModel = qobject_cast< KDirModel* >(m_proxyModel->sourceModel());
Q_ASSERT(m_dirModel != 0);
KFileItem itemToExpand = m_dirModel->itemForIndex(indexToExpand );
class LIBDOLPHINPRIVATE_EXPORT FolderExpander : public QObject
{
Q_OBJECT
-
+
public:
FolderExpander(QAbstractItemView* view, QSortFilterProxyModel* proxyModel);
virtual ~FolderExpander();
-
+
void setEnabled(bool enabled);
bool enabled() const;
-
+
signals:
/**
* Is emitted if the directory \a dirModelIndex should be entered. The
* the directory is already provided by expanding the tree node.
*/
void enterDir(const QModelIndex& dirModelIndex, QAbstractItemView* view);
-
-
+
+
private slots:
void viewScrolled();
void autoExpandTimeout();
-private:
+private:
bool m_enabled;
-
+
QAbstractItemView* m_view;
QSortFilterProxyModel* m_proxyModel;
QVBoxLayout* contextMenuBoxLayout = new QVBoxLayout(contextMenuBox);
contextMenuBoxLayout->addWidget(m_showDeleteCommand);
contextMenuBoxLayout->addWidget(m_showCopyMoveMenu);
-
+
QGroupBox* statusBarBox = new QGroupBox(i18nc("@title:group", "Status Bar"), vBox);
-
+
m_showZoomSlider = new QCheckBox(i18nc("@option:check", "Show zoom slider"), statusBarBox);
connect(m_showZoomSlider, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
m_renameInline = new QCheckBox(i18nc("@option:check", "Rename inline"), vBox);
connect(m_renameInline, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
-
+
m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox);
connect(m_autoExpandFolders, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
KConfigGroup configGroup(globalConfig, "KDE");
m_showDeleteCommand->setChecked(configGroup.readEntry("ShowDeleteCommand", false));
-
+
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
m_showCopyMoveMenu->setChecked(settings->showCopyMoveMenu());
m_showZoomSlider->setChecked(settings->showZoomSlider());
QCheckBox* m_showDeleteCommand;
QCheckBox* m_showCopyMoveMenu;
-
+
QCheckBox* m_showZoomSlider;
QCheckBox* m_showSpaceInfo;
-
+
QCheckBox* m_browseThroughArchives;
QCheckBox* m_renameInline;
QCheckBox* m_autoExpandFolders;
m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow);
connect(m_defaultSizeSlider, SIGNAL(sliderMoved(int)),
this, SLOT(slotDefaultSliderMoved(int)));
-
+
QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this);
m_previewSizeSlider = new QSlider(Qt::Horizontal, this);
m_previewSizeSlider->setPageStep(1);
m_previewSizeSlider->setTickPosition(QSlider::TicksBelow);
connect(m_previewSizeSlider, SIGNAL(sliderMoved(int)),
this, SLOT(slotPreviewSliderMoved(int)));
-
+
QGridLayout* layout = new QGridLayout(this);
layout->addWidget(defaultLabel, 0, 0, Qt::AlignRight);
layout->addWidget(m_defaultSizeSlider, 0, 1);
QPoint global = slider->rect().topLeft();
global.ry() += slider->height() / 2;
QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), slider->mapToGlobal(global));
- QApplication::sendEvent(slider, &toolTipEvent);
+ QApplication::sendEvent(slider, &toolTipEvent);
}
#include "iconsizegroupbox.moc"
public:
explicit IconSizeGroupBox(QWidget* parent);
virtual ~IconSizeGroupBox();
-
+
void setDefaultSizeRange(int min, int max);
void setPreviewSizeRange(int min, int max);
-
+
void setDefaultSizeValue(int value);
int defaultSizeValue() const;
-
+
void setPreviewSizeValue(int value);
int previewSizeValue() const;
-
+
signals:
void defaultSizeChanged(int value);
void previewSizeChanged(int value);
-
+
private slots:
void slotDefaultSliderMoved(int value);
void slotPreviewSliderMoved(int value);
-
+
private:
void showToolTip(QSlider* slider, int value);
-
+
private:
QSlider* m_defaultSizeSlider;
QSlider* m_previewSizeSlider;
// Create "Icon" properties
m_iconSizeGroupBox = new IconSizeGroupBox(this);
m_iconSizeGroupBox->setSizePolicy(sizePolicy);
-
+
const int min = ZoomLevelInfo::minimumLevel();
const int max = ZoomLevelInfo::maximumLevel();
m_iconSizeGroupBox->setDefaultSizeRange(min, max);
m_iconSizeGroupBox->setPreviewSizeRange(min, max);
-
+
connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)),
this, SIGNAL(changed()));
connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)),
this, SIGNAL(changed()));
-
+
// create 'Text' group for selecting the font, the number of lines
// and the text width
QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
const QSize iconSize(settings->iconSize(), settings->iconSize());
const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
-
+
const QSize previewSize(settings->previewSize(), settings->previewSize());
const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
m_textWidthBox->setCurrentIndex(textWidthIndex);
m_arrangementBox->setCurrentIndex(leftToRightArrangement ? 0 : 1);
-
+
const int spacing = settings->gridSpacing();
const int index = (spacing <= 0) ? 0 : 1 + (spacing - GridSpacingBase) / GridSpacingInc;
m_gridSpacingBox->setCurrentIndex(index);
m_urlCandidate = item.url();
m_fileItem = item;
m_infoTimer->start();
- }
+ }
}
}
{
QTextOption textOption;
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
-
+
QTextLayout textLayout(text);
textLayout.setFont(m_nameLabel->font());
textLayout.setTextOption(textOption);
-
+
QString wrappedText;
wrappedText.reserve(text.length());
-
+
// wrap the text to fit into the width of m_nameLabel
textLayout.beginLayout();
QTextLine line = textLayout.createLine();
while (line.isValid()) {
line.setLineWidth(m_nameLabel->width());
wrappedText += text.mid(line.textStart(), line.textLength());
-
+
line = textLayout.createLine();
if (line.isValid()) {
wrappedText += QChar::LineSeparator;
}
- }
+ }
textLayout.endLayout();
m_nameLabel->setText(wrappedText);
* InfosidebarPage::fileUrl();
*/
bool showMultipleSelectionInfo() const;
-
+
/**
* Returns true, if \a url is equal to the shown URL m_shownUrl.
*/
bool isEqualToShownUrl(const KUrl& url) const;
-
+
/**
* Sets the text for the label \a m_nameLabel and assures that the
* text is split in a way that it can be wrapped within the
QTextDocument doc;
doc.setHtml(item->text());
const QIcon icon = item->icon();
-
+
const QSize iconSize = icon.isNull() ? QSize(0, 0) : icon.actualSize(option->decorationSize);
const QSize docSize = doc.size().toSize();
QSize contentSize = iconSize + docSize;
-
+
// assure that the content height is large enough for the icon and the document
contentSize.setHeight(iconSize.height() > doc.size().height() ? iconSize.height() : doc.size().height());
return contentSize + QSize(Border * 3, Border * 2);
const QColor toColor = option->palette.brush(QPalette::ToolTipBase).color();
const QColor fromColor = KColorScheme::shade(toColor, KColorScheme::LightShade, 0.2);
-
+
QLinearGradient gradient(option->rect.topLeft(), option->rect.bottomLeft());
gradient.setColorAt(0.0, fromColor);
gradient.setColorAt(1.0, toColor);
bitmap.fill(Qt::transparent);
QPainter p(&bitmap);
doc.drawContents(&p);
-
+
const QRect docRect(QPoint(x, y), doc.size().toSize());
painter->drawPixmap(docRect, bitmap);
}
private:
QPainterPath createPath(const KStyleOptionToolTip& option) const;
-
+
private:
enum { Border = 8 };
};
if (!isVisible()) {
return;
}
-
+
// KDiskFreeSpace is for local paths only
if (!m_url.isLocalFile()) {
setText(i18nc("@info:status", "Unknown size"));
if (valuesChanged) {
setText(i18nc("@info:status Free disk space", "%1 free",
KIO::convertSize(job.available())));
-
+
setUpdatesEnabled(false);
m_kBSize = kBSize;
setValue(kBSize > 0 ? (kBUsed * 100) / kBSize : 0);
protected:
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
-
+
private slots:
/** Refreshes the space information for the current set URL. */
void refresh();
m_emptyRenderedKToolTipItem = toolTip; // make toolTip accessible everywhere
showToolTip(toolTip);
}
-
+
++m_previewPass;
m_waitOnPreviewTimer->start(250);
} else {
m_emptyRenderedKToolTipItem = 0;
return;
}
-
+
KStyleOptionToolTip option;
// TODO: get option content from KToolTip or add KToolTip::sizeHint() method
option.direction = QApplication::layoutDirection();
const bool hasRoomToLeft = (m_itemRect.left() - size.width() >= desktop.left());
const bool hasRoomToRight = (m_itemRect.right() + size.width() <= desktop.right());
const bool hasRoomAbove = (m_itemRect.top() - size.height() >= desktop.top());
- const bool hasRoomBelow = (m_itemRect.bottom() + size.height() <= desktop.bottom());
+ const bool hasRoomBelow = (m_itemRect.bottom() + size.height() <= desktop.bottom());
if (!hasRoomAbove && !hasRoomBelow && !hasRoomToLeft && !hasRoomToRight) {
delete tip;
tip = 0;
return;
}
- int x = 0;
+ int x = 0;
int y = 0;
if (hasRoomBelow || hasRoomAbove) {
x = QCursor::pos().x() + 16; // TODO: use mouse pointer width instead of the magic value of 16
} else {
Q_ASSERT(hasRoomToLeft || hasRoomToRight);
x = hasRoomToRight ? m_itemRect.right() : m_itemRect.left() - size.width();
-
+
// Put the tooltip at the bottom of the screen. The x-coordinate has already
// been adjusted, so that no overlapping with m_itemRect occurs.
y = desktop.bottom() - size.height();
m_generatingPreview = false;
return;
}
-
+
if (m_previewIsLate) {
// always use the maximal width
QPixmap paddedImage(QSize(PREVIEW_WIDTH, pixmap.height()));
m_treeView->setModel(m_proxyModel);
m_proxyModel->setSorting(DolphinView::SortByName);
m_proxyModel->setSortOrder(Qt::AscendingOrder);
-
+
new FolderExpander(m_treeView, m_proxyModel);
connect(m_treeView, SIGNAL(clicked(const QModelIndex&)),
* to the index \a index.
*/
void dropUrls(const QModelIndex& index, QDropEvent* event);
-
+
/**
* Expands the treeview to show the directory
* specified by \a index.
{
int size = KIconLoader::SizeMedium;
switch (level) {
- case 0: size = KIconLoader::SizeSmall; break;
+ case 0: size = KIconLoader::SizeSmall; break;
case 1: size = KIconLoader::SizeSmallMedium; break;
case 2: size = KIconLoader::SizeMedium; break;
case 3: size = KIconLoader::SizeLarge; break;