- Determine group of a new entry dependent from the protocol
- Allow panels to forward error-messages to the view-container
(also applied to Folders Panel)
m_updateToolBarTimer->start();
}
m_updateToolBarTimer->start();
}
+void DolphinMainWindow::slotPanelErrorMessage(const QString& error)
+{
+ activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
+}
+
void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
{
Q_ASSERT(viewContainer);
void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
{
Q_ASSERT(viewContainer);
this, SLOT(changeUrl(KUrl)));
connect(foldersPanel, SIGNAL(folderMiddleClicked(KUrl)),
this, SLOT(openNewActivatedTab(KUrl)));
this, SLOT(changeUrl(KUrl)));
connect(foldersPanel, SIGNAL(folderMiddleClicked(KUrl)),
this, SLOT(openNewActivatedTab(KUrl)));
+ connect(foldersPanel, SIGNAL(errorMessage(QString)),
+ this, SLOT(slotPanelErrorMessage(QString)));
// Setup "Terminal"
#ifndef Q_OS_WIN
// Setup "Terminal"
#ifndef Q_OS_WIN
this, SLOT(changeUrl(KUrl)));
connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)),
this, SLOT(openNewActivatedTab(KUrl)));
this, SLOT(changeUrl(KUrl)));
connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)),
this, SLOT(openNewActivatedTab(KUrl)));
+ connect(placesPanel, SIGNAL(errorMessage(QString)),
+ this, SLOT(slotPanelErrorMessage(QString)));
connect(this, SIGNAL(urlChanged(KUrl)),
placesPanel, SLOT(setUrl(KUrl)));
connect(placesDock, SIGNAL(visibilityChanged(bool)),
connect(this, SIGNAL(urlChanged(KUrl)),
placesPanel, SLOT(setUrl(KUrl)));
connect(placesDock, SIGNAL(visibilityChanged(bool)),
void updateToolBar();
void slotControlButtonDeleted();
void updateToolBar();
void slotControlButtonDeleted();
+ /**
+ * Is called if a panel emits an error-message and shows
+ * the error-message in the active view-container.
+ */
+ void slotPanelErrorMessage(const QString& error);
+
private:
/**
* Activates the given view, which means that
private:
/**
* Activates the given view, which means that
event->buttons(),
event->modifiers());
event->buttons(),
event->modifiers());
- DragAndDropHelper::dropUrls(destItem, destItem.url(), &dropEvent);
+ const QString error = DragAndDropHelper::dropUrls(destItem, destItem.url(), &dropEvent);
+ if (!error.isEmpty()) {
+ emit errorMessage(error);
+ }
signals:
void folderActivated(const KUrl& url);
void folderMiddleClicked(const KUrl& url);
signals:
void folderActivated(const KUrl& url);
void folderMiddleClicked(const KUrl& url);
+ void errorMessage(const QString& error);
protected:
/** @see Panel::urlChanged() */
protected:
/** @see Panel::urlChanged() */
#include <KAboutData>
#include <KComponentData>
#include <KAboutData>
#include <KComponentData>
#include <KFile>
#include <KIconButton>
#include <KLineEdit>
#include <KFile>
#include <KIconButton>
#include <KLineEdit>
QString PlacesItemEditDialog::text() const
{
QString PlacesItemEditDialog::text() const
{
- return m_textEdit->text().isEmpty() ? m_urlEdit->url().fileName() : m_textEdit->text();
+ QString text = m_textEdit->text();
+ if (text.isEmpty()) {
+ const KUrl url = m_urlEdit->url();
+ text = url.fileName().isEmpty() ? url.prettyUrl() : url.fileName();
+ }
+ return text;
}
void PlacesItemEditDialog::setUrl(const KUrl& url)
}
void PlacesItemEditDialog::setUrl(const KUrl& url)
#include <KBookmarkGroup>
#include <KBookmarkManager>
#include <KComponentData>
#include <KBookmarkGroup>
#include <KBookmarkManager>
#include <KComponentData>
#include <KIcon>
#include <kitemviews/kstandarditem.h>
#include <KLocale>
#include <KIcon>
#include <kitemviews/kstandarditem.h>
#include <KLocale>
PlacesItemModel::PlacesItemModel(QObject* parent) :
KStandardItemModel(parent),
m_nepomukRunning(false),
PlacesItemModel::PlacesItemModel(QObject* parent) :
KStandardItemModel(parent),
m_nepomukRunning(false),
+ m_hiddenItemsShown(false),
m_availableDevices(),
m_bookmarkManager(0),
m_systemBookmarks(),
m_availableDevices(),
m_bookmarkManager(0),
m_systemBookmarks(),
+void PlacesItemModel::setHiddenItemsShown(bool show)
+{
+ if (m_hiddenItemsShown != show) {
+ m_hiddenItemsShown = show;
+ }
+}
+
+bool PlacesItemModel::hiddenItemsShown() const
+{
+ return m_hiddenItemsShown;
+}
+
bool PlacesItemModel::isSystemItem(int index) const
{
if (index >= 0 && index < count()) {
bool PlacesItemModel::isSystemItem(int index) const
{
if (index >= 0 && index < count()) {
-QString PlacesItemModel::placesGroupName() const
+QString PlacesItemModel::groupName(const KUrl &url) const
- return i18nc("@item", "Places");
-}
+ const QString protocol = url.protocol();
-QString PlacesItemModel::recentlyAccessedGroupName() const
-{
- return i18nc("@item", "Recently Accessed");
-}
+ if (protocol.contains(QLatin1String("search"))) {
+ return searchForGroupName();
+ }
-QString PlacesItemModel::searchForGroupName() const
-{
- return i18nc("@item", "Search For");
+ if (protocol == QLatin1String("timeline")) {
+ return recentlyAccessedGroupName();
+ }
+
+ return placesGroupName();
}
QAction* PlacesItemModel::ejectAction(int index) const
}
QAction* PlacesItemModel::ejectAction(int index) const
+QString PlacesItemModel::placesGroupName()
+{
+ return i18nc("@item", "Places");
+}
+
+QString PlacesItemModel::recentlyAccessedGroupName()
+{
+ return i18nc("@item", "Recently Accessed");
+}
+
+QString PlacesItemModel::searchForGroupName()
+{
+ return i18nc("@item", "Search For");
+}
-KUrl PlacesItemModel::translatedSystemBookmarkUrl(const KUrl& url) const
+KUrl PlacesItemModel::translatedSystemBookmarkUrl(const KUrl& url)
{
KUrl translatedUrl = url;
if (url.protocol() == QLatin1String("timeline")) {
{
KUrl translatedUrl = url;
if (url.protocol() == QLatin1String("timeline")) {
explicit PlacesItemModel(QObject* parent = 0);
virtual ~PlacesItemModel();
explicit PlacesItemModel(QObject* parent = 0);
virtual ~PlacesItemModel();
+ void setHiddenItemsShown(bool show);
+ bool hiddenItemsShown() const;
+
int hiddenCount() const;
/**
int hiddenCount() const;
/**
*/
int closestItem(const KUrl& url) const;
*/
int closestItem(const KUrl& url) const;
- QString placesGroupName() const;
- QString recentlyAccessedGroupName() const;
- QString searchForGroupName() const;
+ /**
+ * @return Name of the group where the item with the URL
+ * \a URL belongs to.
+ */
+ QString groupName(const KUrl& url) const;
QAction* ejectAction(int index) const;
QAction* tearDownAction(int index) const;
QAction* ejectAction(int index) const;
QAction* tearDownAction(int index) const;
void createSystemBookmarks();
void createSystemBookmarks();
- KUrl translatedSystemBookmarkUrl(const KUrl& url) const;
+ static QString placesGroupName();
+ static QString recentlyAccessedGroupName();
+ static QString searchForGroupName();
+
+ static KUrl translatedSystemBookmarkUrl(const KUrl& url);
/**
* @return URL using the timeline-protocol for searching.
/**
* @return URL using the timeline-protocol for searching.
private:
bool m_nepomukRunning;
private:
bool m_nepomukRunning;
+ bool m_hiddenItemsShown;
QSet<QString> m_availableDevices;
KBookmarkManager* m_bookmarkManager;
QSet<QString> m_availableDevices;
KBookmarkManager* m_bookmarkManager;
void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
{
Q_UNUSED(parent);
void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
{
Q_UNUSED(parent);
- DragAndDropHelper::dropUrls(KFileItem(), dest, event);
+ const QString error = DragAndDropHelper::dropUrls(KFileItem(), dest, event);
+ if (!error.isEmpty()) {
+ emit errorMessage(error);
+ }
+
}
void PlacesPanel::slotTrashUpdated(KJob* job)
}
void PlacesPanel::slotTrashUpdated(KJob* job)
if (dialog->exec() == QDialog::Accepted) {
KStandardItem* item = createStandardItemFromDialog(dialog);
if (dialog->exec() == QDialog::Accepted) {
KStandardItem* item = createStandardItemFromDialog(dialog);
- // Insert the item as last item of the "Places" group
- bool inserted = false;
+ // Insert the item as last item of the corresponding group.
+ while (i < m_model->count() && m_model->item(i)->group() != item->group()) {
+ ++i;
+ }
+
+ bool inserted = false;
while (!inserted && i < m_model->count()) {
while (!inserted && i < m_model->count()) {
- if (m_model->item(i)->group() != m_model->placesGroupName()) {
+ if (m_model->item(i)->group() != item->group()) {
m_model->insertItem(i, item);
inserted = true;
}
m_model->insertItem(i, item);
inserted = true;
}
KStandardItem* oldItem = m_model->item(index);
if (oldItem) {
KStandardItem* item = createStandardItemFromDialog(dialog);
KStandardItem* oldItem = m_model->item(index);
if (oldItem) {
KStandardItem* item = createStandardItemFromDialog(dialog);
+ // Although the user might have changed the URL of the item in a way
+ // that another group should be assigned, we still apply the old
+ // group to keep the same position for the item.
item->setGroup(oldItem->group());
m_model->replaceItem(index, item);
}
item->setGroup(oldItem->group());
m_model->replaceItem(index, item);
}
+ const KUrl newUrl = dialog->url();
KStandardItem* item = new KStandardItem();
item->setIcon(KIcon(dialog->icon()));
item->setText(dialog->text());
KStandardItem* item = new KStandardItem();
item->setIcon(KIcon(dialog->icon()));
item->setText(dialog->text());
- item->setDataValue("url", dialog->url());
- item->setGroup(m_model->placesGroupName());
+ item->setDataValue("url", newUrl);
+ item->setGroup(m_model->groupName(newUrl));
signals:
void placeActivated(const KUrl& url);
void placeMiddleClicked(const KUrl& url);
signals:
void placeActivated(const KUrl& url);
void placeMiddleClicked(const KUrl& url);
+ void errorMessage(const QString& error);
protected:
virtual bool urlChanged();
protected:
virtual bool urlChanged();