From 4bcc29c6e17f373db5d8156eba11431a015c8445 Mon Sep 17 00:00:00 2001 From: dockes Date: Mon, 8 Jan 2007 10:01:55 +0000 Subject: [PATCH] reslist menu openParent opens containing folder if not a subdoc --- src/qtgui/rclmain_w.cpp | 12 +++++++--- src/qtgui/rclmain_w.h | 1 + src/qtgui/reslist.cpp | 50 ++++++++++++++++++++++------------------- src/qtgui/reslist.h | 3 ++- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index fea2b4ad..58259cf7 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.19 2007-01-08 07:02:25 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.20 2007-01-08 10:01:55 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -122,9 +122,11 @@ void RclMain::init() this, SLOT(enablePrevPage(bool))); connect(resList, SIGNAL(docEditClicked(int)), this, SLOT(startNativeViewer(int))); + connect(resList, SIGNAL(editRequested(Rcl::Doc)), + this, SLOT(startNativeViewer(Rcl::Doc))); + connect(resList, SIGNAL(docPreviewClicked(int, int)), this, SLOT(startPreview(int, int))); - connect(resList, SIGNAL(previewRequested(Rcl::Doc)), this, SLOT(startPreview(Rcl::Doc))); @@ -700,7 +702,11 @@ void RclMain::startNativeViewer(int docnum) " from database")); return; } - + startNativeViewer(doc); +} + +void RclMain::startNativeViewer(Rcl::Doc doc) +{ // Look for appropriate viewer string cmd = rclconfig->getMimeViewerDef(doc.mimetype); if (cmd.length() == 0) { diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index 9a17c820..d3740854 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -90,6 +90,7 @@ public slots: virtual void startPreview(int docnum, int); virtual void startPreview(Rcl::Doc doc); virtual void startNativeViewer(int docnum); + virtual void startNativeViewer(Rcl::Doc doc); virtual void previewNextInTab(int sid, int docnum); virtual void previewPrevInTab(int sid, int docnum); virtual void previewExposed(int sid, int docnum); diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index e8367c77..d7d22643 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: reslist.cpp,v 1.17 2007-01-08 07:01:39 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: reslist.cpp,v 1.18 2007-01-08 10:01:55 dockes Exp $ (C) 2005 J.F.Dockes"; #endif #include @@ -610,12 +610,8 @@ RCLPOPUP *ResList::createPopupMenu(const QPoint& pos) popup->insertItem(tr("Copy &File Name"), this, SLOT(menuCopyFN())); popup->insertItem(tr("Copy &Url"), this, SLOT(menuCopyURL())); popup->insertItem(tr("Find &similar documents"), this, SLOT(menuExpand())); - Rcl::Doc doc; - if (getDoc(m_popDoc, doc)) { - if (!doc.ipath.empty()) - popup->insertItem(tr("P&arent document"), - this, SLOT(menuSeeParent())); - } + popup->insertItem(tr("P&arent document/folder"), + this, SLOT(menuSeeParent())); return popup; } @@ -623,31 +619,39 @@ void ResList::menuPreview() { emit docPreviewClicked(m_popDoc, 0); } + void ResList::menuSeeParent() { Rcl::Doc doc; if (getDoc(m_popDoc, doc)) { - if (doc.ipath.empty()) - return; Rcl::Doc doc1; - doc1.url = doc.url; - doc1.ipath = doc.ipath; - string::size_type colon; - LOGDEB(("Ipath: [%s]\n", doc1.ipath.c_str())); - if ((colon=doc1.ipath.find_last_of(":")) != string::npos) { - doc1.ipath.erase(colon); + if (doc.ipath.empty()) { + // No parent doc: show enclosing folder with app configured for + // directories + doc1.url = path_getfather(doc.url); + doc1.mimetype = "application/x-fsdirectory"; + emit editRequested(doc1); } else { - doc1.ipath.erase(); - } - LOGDEB(("Ipath after: [%s]\n", doc1.ipath.c_str())); + doc1.url = doc.url; + doc1.ipath = doc.ipath; + string::size_type colon; + LOGDEB(("Ipath: [%s]\n", doc1.ipath.c_str())); + if ((colon=doc1.ipath.find_last_of(":")) != string::npos) { + doc1.ipath.erase(colon); + } else { + doc1.ipath.erase(); + } + LOGDEB(("Ipath after: [%s]\n", doc1.ipath.c_str())); - list lipath; - stringToTokens(doc.ipath, lipath, ":"); - if (lipath.size() >= 1) - lipath.pop_back(); - emit previewRequested(doc1); + list lipath; + stringToTokens(doc.ipath, lipath, ":"); + if (lipath.size() >= 1) + lipath.pop_back(); + emit previewRequested(doc1); + } } } + void ResList::menuEdit() { emit docEditClicked(m_popDoc); diff --git a/src/qtgui/reslist.h b/src/qtgui/reslist.h index 808b9f6d..59aafaec 100644 --- a/src/qtgui/reslist.h +++ b/src/qtgui/reslist.h @@ -1,6 +1,6 @@ #ifndef _RESLIST_H_INCLUDED_ #define _RESLIST_H_INCLUDED_ -/* @(#$Id: reslist.h,v 1.7 2006-12-20 13:55:46 dockes Exp $ (C) 2005 J.F.Dockes */ +/* @(#$Id: reslist.h,v 1.8 2007-01-08 10:01:55 dockes Exp $ (C) 2005 J.F.Dockes */ #include @@ -69,6 +69,7 @@ class ResList : public QTEXTBROWSER void docEditClicked(int); void docPreviewClicked(int, int); void previewRequested(Rcl::Doc); + void editRequested(Rcl::Doc); void headerClicked(); void docExpand(int); void wordSelect(QString);