*/
#include "dolphinpart.h"
-#include "dolphinviewactionhandler.h"
-#include "dolphinsortfilterproxymodel.h"
-#include "dolphinview.h"
-#include "dolphinmodel.h"
-#include "dolphinnewmenuobserver.h"
-#include "dolphinremoteencoding.h"
#include <kfileitemlistproperties.h>
#include <konq_operations.h>
#include <kio/netaccess.h>
#include <ktoolinvocation.h>
#include <kauthorized.h>
-#include <knewmenu.h>
+#include <knewfilemenu.h>
#include <kmenu.h>
+#include <kinputdialog.h>
#include "settings/dolphinsettings.h"
+#include "views/dolphinview.h"
+#include "views/dolphinviewactionhandler.h"
+#include "views/dolphinsortfilterproxymodel.h"
+#include "views/dolphinmodel.h"
+#include "views/dolphinnewmenuobserver.h"
+#include "views/dolphinremoteencoding.h"
#include <QActionGroup>
#include <QApplication>
this, SLOT(slotSelectionChanged(KFileItemList)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
this, SLOT(slotRequestItemInfo(KFileItem)));
- connect(m_view, SIGNAL(requestUrlChange(KUrl)),
- this, SLOT(slotRequestUrlChange(KUrl)));
connect(m_view, SIGNAL(modeChanged()),
this, SIGNAL(viewModeChanged())); // relay signal
connect(m_view, SIGNAL(redirection(KUrl, KUrl)),
{
// Edit menu
- m_newMenu = new KNewMenu(actionCollection(), widget(), "new_menu");
+ m_newMenu = new KNewFileMenu(actionCollection(), "new_menu", this);
+ m_newMenu->setParentWidget(widget());
DolphinNewMenuObserver::instance().attach(m_newMenu);
connect(m_newMenu->menu(), SIGNAL(aboutToShow()),
this, SLOT(updateNewMenu()));
editMimeTypeAction->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
connect(editMimeTypeAction, SIGNAL(triggered()), SLOT(slotEditMimeType()));
+ KAction* selectItemsMatching = actionCollection()->addAction("select_items_matching");
+ selectItemsMatching->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
+ selectItemsMatching->setShortcut(Qt::CTRL | Qt::Key_S);
+ connect(selectItemsMatching, SIGNAL(triggered()), this, SLOT(slotSelectItemsMatchingPattern()));
+
+ KAction* unselectItemsMatching = actionCollection()->addAction("unselect_items_matching");
+ unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
+ connect(unselectItemsMatching, SIGNAL(triggered()), this, SLOT(slotUnselectItemsMatchingPattern()));
+
+ actionCollection()->addAction(KStandardAction::SelectAll, "select_all", m_view, SLOT(selectAll()));
+
+ KAction* unselectAll = actionCollection()->addAction("unselect_all");
+ unselectAll->setText(i18nc("@action:inmenu Edit", "Unselect All"));
+ connect(unselectAll, SIGNAL(triggered()), m_view, SLOT(clearSelection()));
+
+ KAction* invertSelection = actionCollection()->addAction("invert_selection");
+ invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
+ invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
+ connect(invertSelection, SIGNAL(triggered()), m_view, SLOT(invertSelection()));
+
// View menu: all done by DolphinViewActionHandler
// Go menu
void DolphinPart::slotItemTriggered(const KFileItem& item)
{
KParts::OpenUrlArguments args;
- args.setMimeType(item.mimetype());
+ // Forget about the known mimetype if a target URL is used.
+ // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
+ if (item.targetUrl() == item.url()) {
+ args.setMimeType(item.mimetype());
+ }
// Ideally, konqueror should be changed to not require trustedSource for directory views,
// since the idea was not to need BrowserArguments for non-browser stuff...
// TODO: We should change the signature of the slots (and signals) for being able
// to tell for which items we want a popup.
- const KFileItemList items = (m_view->selectedItems().count() ? m_view->selectedItems()
- : KFileItemList() << item);
+ KFileItemList items;
+ if (m_view->selectedItems().isEmpty()) {
+ items.append(item);
+ } else {
+ items = m_view->selectedItems();
+ }
+
KFileItemListProperties capabilities(items);
KParts::BrowserExtension::ActionGroupMap actionGroups;
QList<QAction *> editActions;
-
+ editActions += m_view->versionControlActions(m_view->selectedItems());
editActions += customActions;
if (!_item.isNull()) { // only for context menu on one or more items
}
}
-void DolphinPart::slotRequestUrlChange(const KUrl& url)
-{
- if (m_view->url() != url) {
- // If the view URL is not equal to 'url', then an inner URL change has
- // been done (e. g. by activating an existing column in the column view).
- openUrl(url);
- emit m_extension->openUrlNotify();
- }
-}
-
////
void DolphinPartBrowserExtension::restoreState(QDataStream &stream)
}
}
+void DolphinPart::slotSelectItemsMatchingPattern()
+{
+ openSelectionDialog(i18nc("@title:window", "Select"),
+ i18n("Select all items matching this pattern:"),
+ QItemSelectionModel::Select);
+}
+
+void DolphinPart::slotUnselectItemsMatchingPattern()
+{
+ openSelectionDialog(i18nc("@title:window", "Unselect"),
+ i18n("Unselect all items matching this pattern:"),
+ QItemSelectionModel::Deselect);
+}
+
+void DolphinPart::openSelectionDialog(const QString& title, const QString& text, QItemSelectionModel::SelectionFlags command)
+{
+ bool okClicked;
+ QString pattern = KInputDialog::getText(title, text, "*", &okClicked, m_view);
+
+ if (okClicked && !pattern.isEmpty()) {
+ QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
+ QItemSelection matchingIndexes = childrenMatchingPattern(QModelIndex(), patternRegExp);
+ m_view->selectionModel()->select(matchingIndexes, command);
+ }
+}
+
+QItemSelection DolphinPart::childrenMatchingPattern(const QModelIndex& parent, const QRegExp& patternRegExp)
+{
+ QItemSelection matchingIndexes;
+ int numRows = m_proxyModel->rowCount(parent);
+
+ for (int row = 0; row < numRows; row++) {
+ QModelIndex index = m_proxyModel->index(row, 0, parent);
+ QModelIndex sourceIndex = m_proxyModel->mapToSource(index);
+
+ if (sourceIndex.isValid() && patternRegExp.exactMatch(m_dolphinModel->data(sourceIndex).toString())) {
+ matchingIndexes += QItemSelectionRange(index);
+ }
+
+ if (m_proxyModel->hasChildren(index)) {
+ matchingIndexes += childrenMatchingPattern(index, patternRegExp);
+ }
+ }
+
+ return matchingIndexes;
+}
+
void DolphinPart::setCurrentViewMode(const QString& viewModeName)
{
QAction* action = actionCollection()->action(viewModeName);
void DolphinPart::updateNewMenu()
{
- // As requested by KNewMenu :
- m_newMenu->slotCheckUpToDate();
+ // As requested by KNewFileMenu :
+ m_newMenu->checkUpToDate();
+ m_newMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles());
// And set the files that the menu apply on :
m_newMenu->setPopupFiles(url());
}
void DolphinPart::createDirectory()
{
+ m_newMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles());
m_newMenu->setPopupFiles(url());
m_newMenu->createDirectory();
}
+void DolphinPart::setFilesToSelect(const KUrl::List& files)
+{
+ m_view->markUrlsAsSelected(files);
+}
+
#include "dolphinpart.moc"