allow Konqueror to open also files inside a new tab, not only directories

CCMAIL: faure@kde.org

svn path=/trunk/KDE/kdebase/apps/; revision=805184
This commit is contained in:
Peter Penz 2008-05-07 20:02:37 +00:00
parent 9f60cbdb63
commit d4287eb8e3
4 changed files with 29 additions and 7 deletions

View file

@ -150,7 +150,7 @@ void DolphinController::triggerItem(const QModelIndex& index)
const KFileItem item = itemForIndex(index); const KFileItem item = itemForIndex(index);
if (index.isValid() && (index.column() == KDirModel::Name)) { if (index.isValid() && (index.column() == KDirModel::Name)) {
if (openTab && item.isDir()) { if (openTab && (item.isDir() || m_dolphinView->isTabsForFilesEnabled())) {
emit tabRequested(item.url()); emit tabRequested(item.url());
} else { } else {
emit itemTriggered(item); emit itemTriggered(item);

View file

@ -77,6 +77,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
m_dirLister, m_dirLister,
m_dolphinModel, m_dolphinModel,
m_proxyModel); m_proxyModel);
m_view->setTabsForFilesEnabled(true);
setWidget(m_view); setWidget(m_view);
setXMLFile("dolphinpart.rc"); setXMLFile("dolphinpart.rc");
@ -284,7 +285,6 @@ void DolphinPart::createNewWindow(const KUrl& url)
// TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
// should be moved into DolphinPart::slotItemTriggered() // should be moved into DolphinPart::slotItemTriggered()
KFileItem item(S_IFDIR, (mode_t)-1, url); KFileItem item(S_IFDIR, (mode_t)-1, url);
Q_ASSERT(item.mimeTypePtr()->is("inode/directory")); // the signal 'tabRequested' is only emitted for dirs
KParts::OpenUrlArguments args; KParts::OpenUrlArguments args;
args.setMimeType(item.mimetype()); args.setMimeType(item.mimetype());
emit m_extension->createNewWindow(url, args); emit m_extension->createNewWindow(url, args);

View file

@ -70,6 +70,7 @@ DolphinView::DolphinView(QWidget* parent,
m_showPreview(false), m_showPreview(false),
m_loadingDirectory(false), m_loadingDirectory(false),
m_storedCategorizedSorting(false), m_storedCategorizedSorting(false),
m_tabsForFiles(false),
m_isContextMenuOpen(false), m_isContextMenuOpen(false),
m_mode(DolphinView::IconsView), m_mode(DolphinView::IconsView),
m_topLayout(0), m_topLayout(0),
@ -913,6 +914,16 @@ QPair<bool, QString> DolphinView::pasteInfo() const
return ret; return ret;
} }
void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
{
m_tabsForFiles = tabsForFiles;
}
bool DolphinView::isTabsForFilesEnabled() const
{
return m_tabsForFiles;
}
void DolphinView::emitContentsMoved() void DolphinView::emitContentsMoved()
{ {
// only emit the contents moved signal if: // only emit the contents moved signal if:

View file

@ -316,6 +316,15 @@ public:
*/ */
QPair<bool, QString> pasteInfo() const; QPair<bool, QString> pasteInfo() const;
/**
* If \a tabsForFiles is true, the signal tabRequested() will also
* emitted also for files. Per default tabs for files is disabled
* and hence the signal tabRequested() will only be emitted for
* directories.
*/
void setTabsForFilesEnabled(bool tabsForFiles);
bool isTabsForFilesEnabled() const;
public slots: public slots:
/** /**
* Changes the directory to \a url. If the current directory is equal to * Changes the directory to \a url. If the current directory is equal to
@ -641,11 +650,13 @@ private:
} }
private: private:
bool m_active; bool m_active : 1;
bool m_showPreview; bool m_showPreview : 1;
bool m_loadingDirectory; bool m_loadingDirectory : 1;
bool m_storedCategorizedSorting; bool m_storedCategorizedSorting : 1;
bool m_isContextMenuOpen; // TODO: workaround for Qt-issue xxxxxx bool m_tabsForFiles : 1;
bool m_isContextMenuOpen : 1; // TODO: workaround for Qt-issue xxxxxx
Mode m_mode; Mode m_mode;
DolphinMainWindow* m_mainWindow; DolphinMainWindow* m_mainWindow;