From c20f14478a527ec3a4169396d2c1472a8f4020af Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Tue, 21 Nov 2006 21:10:33 +0000 Subject: [PATCH] compile++ Welcome to Dolphin! Trying to help a bit with the porting. If I did something wrong, feel free to blame me. :-) CCMAIL: peter.penz@gmx.at svn path=/trunk/playground/utils/dolphin/; revision=606802 --- src/bookmarkselector.cpp | 6 ++-- src/dolphindetailsview.cpp | 59 ++++++++++++++++++---------------- src/dolphindirlister.cpp | 2 +- src/dolphiniconsview.cpp | 66 ++++++++++++++++++++------------------ src/dolphinsettings.cpp | 22 ++++++------- src/itemeffectsmanager.cpp | 20 ++++++------ src/urlbutton.cpp | 10 +++--- src/viewproperties.cpp | 10 +++--- 8 files changed, 100 insertions(+), 95 deletions(-) diff --git a/src/bookmarkselector.cpp b/src/bookmarkselector.cpp index 4c091d33b5..49267f8738 100644 --- a/src/bookmarkselector.cpp +++ b/src/bookmarkselector.cpp @@ -38,7 +38,7 @@ BookmarkSelector::BookmarkSelector(URLNavigator* parent) : URLButton(parent), m_selectedIndex(0) { - setFocusPolicy(QWidget::NoFocus); + setFocusPolicy(Qt::NoFocus); m_bookmarksMenu = new Q3PopupMenu(this); @@ -83,7 +83,7 @@ void BookmarkSelector::updateSelection(const KUrl& url) while (!bookmark.isNull()) { const KUrl bookmarkURL = bookmark.url(); if (bookmarkURL.isParentOf(url)) { - const int length = bookmarkURL.prettyURL().length(); + const int length = bookmarkURL.prettyUrl().length(); if (length > maxLength) { m_selectedIndex = i; setPixmap(SmallIcon(bookmark.icon())); @@ -144,7 +144,7 @@ void BookmarkSelector::drawButton(QPainter* painter) } // draw button backround - painter->setPen(NoPen); + painter->setPen(Qt::NoPen); painter->setBrush(backgroundColor); painter->drawRect(0, 0, buttonWidth, buttonHeight); diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 1c779b8dc8..bffd134c97 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -20,7 +20,6 @@ #include "dolphindetailsview.h" -#include #include #include #include @@ -35,8 +34,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -51,7 +52,7 @@ #include "detailsmodesettings.h" DolphinDetailsView::DolphinDetailsView(DolphinView* parent) : - KFileDetailView(parent, 0), + KFileDetailView(parent), m_dolphinView(parent), m_resizeTimer(0), m_scrollTimer(0), @@ -195,8 +196,8 @@ void DolphinDetailsView::zoomIn() if (isZoomInPossible()) { DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); switch (settings->iconSize()) { - case KIcon::SizeSmall: settings->setIconSize(KIcon::SizeMedium); break; - case KIcon::SizeMedium: settings->setIconSize(KIcon::SizeLarge); break; + case K3Icon::SizeSmall: settings->setIconSize(K3Icon::SizeMedium); break; + case K3Icon::SizeMedium: settings->setIconSize(K3Icon::SizeLarge); break; default: assert(false); break; } ItemEffectsManager::zoomIn(); @@ -208,8 +209,8 @@ void DolphinDetailsView::zoomOut() if (isZoomOutPossible()) { DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); switch (settings->iconSize()) { - case KIcon::SizeLarge: settings->setIconSize(KIcon::SizeMedium); break; - case KIcon::SizeMedium: settings->setIconSize(KIcon::SizeSmall); break; + case K3Icon::SizeLarge: settings->setIconSize(K3Icon::SizeMedium); break; + case K3Icon::SizeMedium: settings->setIconSize(K3Icon::SizeSmall); break; default: assert(false); break; } ItemEffectsManager::zoomOut(); @@ -219,13 +220,13 @@ void DolphinDetailsView::zoomOut() bool DolphinDetailsView::isZoomInPossible() const { DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); - return settings->iconSize() < KIcon::SizeLarge; + return settings->iconSize() < K3Icon::SizeLarge; } bool DolphinDetailsView::isZoomOutPossible() const { DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); - return settings->iconSize() > KIcon::SizeSmall; + return settings->iconSize() > K3Icon::SizeSmall; } void DolphinDetailsView::resizeContents(int width, int height) @@ -255,7 +256,7 @@ void DolphinDetailsView::slotOnItem(Q3ListViewItem* item) void DolphinDetailsView::slotOnViewport() { resetActivatedItem(); - m_dolphinView->requestItemInfo(KURL()); + m_dolphinView->requestItemInfo(KUrl()); } void DolphinDetailsView::setContextPixmap(void* context, @@ -322,7 +323,8 @@ void DolphinDetailsView::resizeEvent(QResizeEvent* event) bool DolphinDetailsView::acceptDrag(QDropEvent* event) const { - bool accept = KURLDrag::canDecode(event) && + KUrl::List uriList = KUrl::List::fromMimeData( event->mimeData() ); + bool accept = !uriList.isEmpty() && (event->action() == QDropEvent::Copy || event->action() == QDropEvent::Move || event->action() == QDropEvent::Link); @@ -369,9 +371,9 @@ void DolphinDetailsView::contentsDropEvent(QDropEvent* event) } emit dropped(event, 0); - KURL::List urls; - if (KURLDrag::decode(event, urls) && !urls.isEmpty()) { - emit dropped(event, urls, KURL()); + KUrl::List urls = KUrl::List::fromMimeData( event->mimeData() ); + if (!urls.isEmpty()) { + emit dropped(event, urls, KUrl()); sig->dropURLs(0, event, urls); } } @@ -395,9 +397,9 @@ void DolphinDetailsView::contentsMousePressEvent(QMouseEvent* event) KFileDetailView::contentsMousePressEvent(event); } else if (event->button() == Qt::LeftButton) { - const ButtonState keyboardState = KApplication::keyboardMouseState(); - const bool isSelectionActive = (keyboardState & ShiftButton) || - (keyboardState & ControlButton); + const Qt::KeyboardModifiers keyboardState = QApplication::keyboardModifiers(); + const bool isSelectionActive = (keyboardState & Qt::ShiftModifier) || + (keyboardState & Qt::ControlModifier); if (!isSelectionActive) { clearSelection(); } @@ -475,15 +477,16 @@ void DolphinDetailsView::drawRubber() QPainter p; p.begin(viewport()); - p.setRasterOp(NotROP); - p.setPen(QPen(color0, 1)); - p.setBrush(NoBrush); + //p.setRasterOp(NotROP); + p.setPen(QPen(Qt::color0, 1)); + p.setBrush(Qt::NoBrush); QPoint point(m_rubber->x(), m_rubber->y()); point = contentsToViewport(point); - style().drawPrimitive(QStyle::PE_FocusRect, &p, - QRect(point.x(), point.y(), m_rubber->width(), m_rubber->height()), - colorGroup(), QStyle::Style_Default, colorGroup().base()); + QStyleOptionFocusRect option; + option.initFrom(this); + option.rect = QRect(point.x(), point.y(), m_rubber->width(), m_rubber->height()); + style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p); p.end(); } @@ -506,19 +509,19 @@ void DolphinDetailsView::slotActivationUpdate() // TODO: there must be a simpler way to say // "update all children" - const QObjectList* list = children(); - if (list == 0) { + const QList list = children(); + if (list.isEmpty()) { return; } - QObjectListIterator it(*list); + QListIterator it(list); QObject* object = 0; - while ((object = it.current()) != 0) { + while (it.hasNext()) { + object = it.next(); if (object->inherits("QWidget")) { QWidget* widget = static_cast(object); widget->update(); } - ++it; } } @@ -647,7 +650,7 @@ void DolphinDetailsView::slotItemRenamed(Q3ListViewItem* item, int /* column */) { KFileItem* fileInfo = static_cast(item)->fileInfo(); - m_dolphinView->rename(KURL(fileInfo->url()), name); + m_dolphinView->rename(KUrl(fileInfo->url()), name); } void DolphinDetailsView::slotHeaderClicked(int /* section */) diff --git a/src/dolphindirlister.cpp b/src/dolphindirlister.cpp index 160c4193d4..cfb41d3319 100644 --- a/src/dolphindirlister.cpp +++ b/src/dolphindirlister.cpp @@ -25,7 +25,7 @@ #include DolphinDirLister::DolphinDirLister() : - KDirLister(true) + KDirLister() { } diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index 2576abba8e..dbf03491ea 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -31,12 +31,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include "dolphinview.h" #include "viewproperties.h" @@ -52,7 +52,7 @@ DolphinIconsView::DolphinIconsView(DolphinView* parent, LayoutMode layoutMode) : m_dolphinView(parent) { setAcceptDrops(true); - setMode(KIconView::Execute); + setMode(K3IconView::Execute); setSelectionMode(KFile::Extended); Dolphin& dolphin = Dolphin::mainWin(); @@ -216,13 +216,13 @@ bool DolphinIconsView::isZoomInPossible() const { IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); const int size = (m_layoutMode == Icons) ? settings->iconSize() : settings->previewSize(); - return size < KIcon::SizeEnormous; + return size < K3Icon::SizeEnormous; } bool DolphinIconsView::isZoomOutPossible() const { IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); - return settings->iconSize() > KIcon::SizeSmall; + return settings->iconSize() > K3Icon::SizeSmall; } void DolphinIconsView::arrangeItemsInGrid( bool updated ) @@ -309,11 +309,11 @@ void DolphinIconsView::drawBackground(QPainter* painter, const QRect& rect) Q3DragObject* DolphinIconsView::dragObject() { - KURL::List urls; - KFileItemListIterator it(*KFileView::selectedItems()); - while (it.current() != 0) { - urls.append((*it)->url()); - ++it; + KUrl::List urls; + QListIterator it(*KFileView::selectedItems()); + while (it.hasNext()) { + KFileItem *item = it.next(); + urls.append(item->url()); } QPixmap pixmap; @@ -331,9 +331,12 @@ Q3DragObject* DolphinIconsView::dragObject() pixmap = currentFileItem()->pixmap(iconSize()); } + /* This should be ported to QMimeData Q3DragObject* dragObj = new KURLDrag(urls, widget()); dragObj->setPixmap(pixmap); return dragObj; + */ + return 0; } void DolphinIconsView::contentsDragEnterEvent(QDragEnterEvent* event) @@ -351,7 +354,8 @@ void DolphinIconsView::contentsDragEnterEvent(QDragEnterEvent* event) return; } - const bool accept = KURLDrag::canDecode(event) && + KUrl::List uriList = KUrl::List::fromMimeData( event->mimeData() ); + const bool accept = !uriList.isEmpty() && (event->action() == QDropEvent::Copy || event->action() == QDropEvent::Move || event->action() == QDropEvent::Link ); @@ -397,7 +401,8 @@ void DolphinIconsView::contentsDropEvent(QDropEvent* event) } KFileIconViewItem* item = static_cast(findItem(contentsToViewport(event->pos()))); - const bool accept = KURLDrag::canDecode(event) && + KUrl::List urls = KUrl::List::fromMimeData( event->mimeData() ); + const bool accept = !urls.isEmpty() && (event->action() == QDropEvent::Copy || event->action() == QDropEvent::Move || event->action() == QDropEvent::Link ) && @@ -412,9 +417,8 @@ void DolphinIconsView::contentsDropEvent(QDropEvent* event) return; } emit dropped(event, fileItem); - KURL::List urls; - if (KURLDrag::decode(event, urls) && !urls.isEmpty()) { - emit dropped(event, urls, fileItem != 0 ? fileItem->url() : KURL()); + if (!urls.isEmpty()) { + emit dropped(event, urls, fileItem != 0 ? fileItem->url() : KUrl()); sig->dropURLs(fileItem, event, urls); } } @@ -431,7 +435,7 @@ void DolphinIconsView::slotOnItem(Q3IconViewItem* item) void DolphinIconsView::slotOnViewport() { resetActivatedItem(); - m_dolphinView->requestItemInfo(KURL()); + m_dolphinView->requestItemInfo(KUrl()); } void DolphinIconsView::slotContextMenuRequested(Q3IconViewItem* item, @@ -448,7 +452,7 @@ void DolphinIconsView::slotItemRenamed(Q3IconViewItem* item, const QString& name) { KFileItem* fileInfo = static_cast(item)->fileInfo(); - m_dolphinView->rename(KURL(fileInfo->url()), name); + m_dolphinView->rename(KUrl(fileInfo->url()), name); } void DolphinIconsView::slotActivationUpdate() @@ -457,19 +461,19 @@ void DolphinIconsView::slotActivationUpdate() // TODO: there must be a simpler way to say // "update all children" - const QObjectList* list = children(); - if (list == 0) { + const QList list = children(); + if (list.isEmpty()) { return; } - QObjectListIterator it(*list); + QListIterator it(list); QObject* object = 0; - while ((object = it.current()) != 0) { + while (it.hasNext()) { + object = it.next(); if (object->inherits("QWidget")) { QWidget* widget = static_cast(object); widget->update(); } - ++it; } } @@ -482,11 +486,11 @@ int DolphinIconsView::increasedIconSize(int size) const { int incSize = 0; switch (size) { - case KIcon::SizeSmall: incSize = KIcon::SizeSmallMedium; break; - case KIcon::SizeSmallMedium: incSize = KIcon::SizeMedium; break; - case KIcon::SizeMedium: incSize = KIcon::SizeLarge; break; - case KIcon::SizeLarge: incSize = KIcon::SizeHuge; break; - case KIcon::SizeHuge: incSize = KIcon::SizeEnormous; break; + case K3Icon::SizeSmall: incSize = K3Icon::SizeSmallMedium; break; + case K3Icon::SizeSmallMedium: incSize = K3Icon::SizeMedium; break; + case K3Icon::SizeMedium: incSize = K3Icon::SizeLarge; break; + case K3Icon::SizeLarge: incSize = K3Icon::SizeHuge; break; + case K3Icon::SizeHuge: incSize = K3Icon::SizeEnormous; break; default: assert(false); break; } return incSize; @@ -496,11 +500,11 @@ int DolphinIconsView::decreasedIconSize(int size) const { int decSize = 0; switch (size) { - case KIcon::SizeSmallMedium: decSize = KIcon::SizeSmall; break; - case KIcon::SizeMedium: decSize = KIcon::SizeSmallMedium; break; - case KIcon::SizeLarge: decSize = KIcon::SizeMedium; break; - case KIcon::SizeHuge: decSize = KIcon::SizeLarge; break; - case KIcon::SizeEnormous: decSize = KIcon::SizeHuge; break; + case K3Icon::SizeSmallMedium: decSize = K3Icon::SizeSmall; break; + case K3Icon::SizeMedium: decSize = K3Icon::SizeSmallMedium; break; + case K3Icon::SizeLarge: decSize = K3Icon::SizeMedium; break; + case K3Icon::SizeHuge: decSize = K3Icon::SizeLarge; break; + case K3Icon::SizeEnormous: decSize = K3Icon::SizeHuge; break; default: assert(false); break; } return decSize; diff --git a/src/dolphinsettings.cpp b/src/dolphinsettings.cpp index 8e040d7671..ccb9442d25 100644 --- a/src/dolphinsettings.cpp +++ b/src/dolphinsettings.cpp @@ -66,9 +66,9 @@ KBookmarkManager* DolphinSettings::bookmarkManager() const { QString basePath = KGlobal::instance()->instanceName(); basePath.append("/bookmarks.xml"); - const QString file = locateLocal("data", basePath); + const QString file = KStandardDirs::locateLocal("data", basePath); - return KBookmarkManager::managerForFile(file, false); + return KBookmarkManager::managerForFile(file, "dolphin", false); } void DolphinSettings::save() @@ -81,9 +81,9 @@ void DolphinSettings::save() QString basePath = KGlobal::instance()->instanceName(); basePath.append("/bookmarks.xml"); - const QString file = locateLocal( "data", basePath); + const QString file = KStandardDirs::locateLocal( "data", basePath); - KBookmarkManager* manager = KBookmarkManager::managerForFile(file, false); + KBookmarkManager* manager = KBookmarkManager::managerForFile(file, "dolphin", false); manager->save(false); } @@ -100,14 +100,14 @@ void DolphinSettings::calculateGridSize(int hint) int gridHeight = 0; if (arrangement == Q3IconView::LeftToRight) { int widthUnit = maxSize + (maxSize / 2); - if (widthUnit < KIcon::SizeLarge) { - widthUnit = KIcon::SizeLarge; + if (widthUnit < K3Icon::SizeLarge) { + widthUnit = K3Icon::SizeLarge; } - gridWidth = widthUnit + hint * KIcon::SizeLarge; + gridWidth = widthUnit + hint * K3Icon::SizeLarge; gridHeight = iconSize; - if (gridHeight <= KIcon::SizeMedium) { + if (gridHeight <= K3Icon::SizeMedium) { gridHeight = gridHeight * 2; } else { @@ -141,10 +141,10 @@ int DolphinSettings::textWidthHint() const int hint = 0; if (arrangement == Q3IconView::LeftToRight) { int widthUnit = maxSize + (maxSize / 2); - if (widthUnit < KIcon::SizeLarge) { - widthUnit = KIcon::SizeLarge; + if (widthUnit < K3Icon::SizeLarge) { + widthUnit = K3Icon::SizeLarge; } - hint = (gridWidth - widthUnit) / KIcon::SizeLarge; + hint = (gridWidth - widthUnit) / K3Icon::SizeLarge; } else { assert(arrangement == Q3IconView::TopToBottom); diff --git a/src/itemeffectsmanager.cpp b/src/itemeffectsmanager.cpp index f47c439986..8a1c948f75 100644 --- a/src/itemeffectsmanager.cpp +++ b/src/itemeffectsmanager.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "dolphin.h" @@ -76,8 +75,8 @@ void ItemEffectsManager::activateItem(void* context) // apply an icon effect to the item below the mouse pointer KIconEffect iconEffect; QPixmap pixmap = iconEffect.apply(*itemPixmap, - KIcon::Desktop, - KIcon::ActiveState); + K3Icon::Desktop, + K3Icon::ActiveState); setContextPixmap(context, pixmap); } @@ -99,8 +98,8 @@ void ItemEffectsManager::resetActivatedItem() // the highlighted item has been found and is restored to the default state KIconEffect iconEffect; QPixmap pixmap = iconEffect.apply(*m_pixmapCopy, - KIcon::Desktop, - KIcon::DefaultState); + K3Icon::Desktop, + K3Icon::DefaultState); // TODO: KFileIconView does not emit any signal when the preview has been finished. // Hence check the size to prevent that a preview is hidden by restoring a @@ -144,15 +143,14 @@ void ItemEffectsManager::updateDisabledItems() } QClipboard* clipboard = QApplication::clipboard(); - QMimeSource* data = clipboard->data(); - if (!KUrlDrag::canDecode(data)) { + const QMimeData* data = clipboard->mimeData(); + KUrl::List urls = KUrl::List::fromMimeData(data); + if (urls.isEmpty()) { return; } // The clipboard contains items, which have been cutted. Change the pixmaps of all those // items to the disabled state. - KUrl::List urls; - KUrlDrag::decode(data, urls); for (void* context = firstContext(); context != 0; context = nextContext(context)) { const KFileItem* fileInfo = contextFileInfo(context); const KUrl& fileURL = fileInfo->url(); @@ -168,8 +166,8 @@ void ItemEffectsManager::updateDisabledItems() KIconEffect iconEffect; QPixmap disabledPixmap = iconEffect.apply(*itemPixmap, - KIcon::Desktop, - KIcon::DisabledState); + K3Icon::Desktop, + K3Icon::DisabledState); setContextPixmap(context, disabledPixmap); } break; diff --git a/src/urlbutton.cpp b/src/urlbutton.cpp index d441ab1845..057bcff5a3 100644 --- a/src/urlbutton.cpp +++ b/src/urlbutton.cpp @@ -25,8 +25,6 @@ #include //Added by qt3to4: #include -#include -#include #include #include @@ -91,8 +89,8 @@ void URLButton::leaveEvent(QEvent* event) QColor URLButton::mixColors(const QColor& c1, const QColor& c2) const { - const int Qt::red = (c1.Qt::red() + c2.Qt::red()) / 2; - const int Qt::green = (c1.Qt::green() + c2.Qt::green()) / 2; - const int Qt::blue = (c1.Qt::blue() + c2.Qt::blue()) / 2; - return QColor(Qt::red, Qt::green, Qt::blue); + const int red = (c1.red() + c2.red()) / 2; + const int green = (c1.green() + c2.green()) / 2; + const int blue = (c1.blue() + c2.blue()) / 2; + return QColor(red, green, blue); } diff --git a/src/viewproperties.cpp b/src/viewproperties.cpp index 52129bd802..a3a8ec46bb 100644 --- a/src/viewproperties.cpp +++ b/src/viewproperties.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "viewproperties.h" @@ -40,7 +41,7 @@ ViewProperties::ViewProperties(KUrl url) : m_subDirValidityHidden(false), m_node(0) { - url.cleanPath(true); + url.cleanPath(); m_filepath = url.path(); if ((m_filepath.length() < 1) || (m_filepath.at(0) != QChar('/'))) { @@ -58,14 +59,14 @@ ViewProperties::ViewProperties(KUrl url) : if (!info.isWritable()) { QString basePath = KGlobal::instance()->instanceName(); basePath.append("/view_properties/local"); - rootDir = locateLocal("data", basePath); + rootDir = KStandardDirs::locateLocal("data", basePath); m_filepath = rootDir + m_filepath; } } else { QString basePath = KGlobal::instance()->instanceName(); basePath.append("/view_properties/remote/").append(url.host()); - rootDir = locateLocal("data", basePath); + rootDir = KStandardDirs::locateLocal("data", basePath); m_filepath = rootDir + m_filepath; } @@ -86,7 +87,8 @@ ViewProperties::ViewProperties(KUrl url) : (parentNode.timestamp() > m_node->timestamp()); if (inheritProps) { - *m_node = parentNode; + delete m_node; + m_node = new ViewPropertySettings(KSharedConfig::openConfig(dir.path() + FILE_NAME)); break; } }