factorized GUI result popup menu code
This commit is contained in:
parent
974541f6c1
commit
3def1e444c
9 changed files with 219 additions and 206 deletions
|
@ -81,6 +81,7 @@ using std::pair;
|
|||
#include "indexer.h"
|
||||
#include "rclzg.h"
|
||||
#include "fileudi.h"
|
||||
#include "snippets_w.h"
|
||||
|
||||
using namespace confgui;
|
||||
|
||||
|
@ -90,6 +91,7 @@ using namespace confgui;
|
|||
|
||||
QString g_stringAllStem, g_stringNoStem;
|
||||
static const QKeySequence quitKeySeq("Ctrl+q");
|
||||
static const QKeySequence closeKeySeq("Ctrl+w");
|
||||
|
||||
void RclMain::init()
|
||||
{
|
||||
|
@ -294,6 +296,8 @@ void RclMain::init()
|
|||
this, SLOT(startPreview(int, Rcl::Doc, int)));
|
||||
connect(restable, SIGNAL(docExpand(Rcl::Doc)),
|
||||
this, SLOT(docExpand(Rcl::Doc)));
|
||||
connect(restable, SIGNAL(showSubDocs(Rcl::Doc)),
|
||||
this, SLOT(showSubDocs(Rcl::Doc)));
|
||||
connect(restable, SIGNAL(previewRequested(Rcl::Doc)),
|
||||
this, SLOT(startPreview(Rcl::Doc)));
|
||||
connect(restable, SIGNAL(editRequested(Rcl::Doc)),
|
||||
|
@ -329,6 +333,8 @@ void RclMain::init()
|
|||
this, SLOT(enablePrevPage(bool)));
|
||||
connect(reslist, SIGNAL(docEditClicked(Rcl::Doc)),
|
||||
this, SLOT(startNativeViewer(Rcl::Doc)));
|
||||
connect(reslist, SIGNAL(showSnippets(Rcl::Doc)),
|
||||
this, SLOT(showSnippets(Rcl::Doc)));
|
||||
connect(reslist, SIGNAL(showSubDocs(Rcl::Doc)),
|
||||
this, SLOT(showSubDocs(Rcl::Doc)));
|
||||
connect(reslist, SIGNAL(docSaveToFileClicked(Rcl::Doc)),
|
||||
|
@ -1541,6 +1547,18 @@ static bool lookForHtmlBrowser(string &exefile)
|
|||
return false;
|
||||
}
|
||||
|
||||
void RclMain::showSnippets(Rcl::Doc doc)
|
||||
{
|
||||
SnippetsW *sp = new SnippetsW(doc, m_source);
|
||||
connect(sp, SIGNAL(startNativeViewer(Rcl::Doc, int, QString)),
|
||||
this, SLOT(startNativeViewer(Rcl::Doc, int, QString)));
|
||||
connect(new QShortcut(quitKeySeq, sp), SIGNAL (activated()),
|
||||
this, SLOT (fileExit()));
|
||||
connect(new QShortcut(closeKeySeq, sp), SIGNAL (activated()),
|
||||
sp, SLOT (close()));
|
||||
sp->show();
|
||||
}
|
||||
|
||||
void RclMain::showSubDocs(Rcl::Doc doc)
|
||||
{
|
||||
LOGDEB(("RclMain::showSubDocs\n"));
|
||||
|
|
|
@ -119,6 +119,7 @@ public slots:
|
|||
virtual void enablePrevPage(bool);
|
||||
virtual void docExpand(Rcl::Doc);
|
||||
virtual void showSubDocs(Rcl::Doc);
|
||||
virtual void showSnippets(Rcl::Doc);
|
||||
virtual void startPreview(int docnum, Rcl::Doc doc, int keymods);
|
||||
virtual void startPreview(Rcl::Doc);
|
||||
virtual void startNativeViewer(Rcl::Doc, int pagenum = -1,
|
||||
|
|
|
@ -48,6 +48,7 @@ SOURCES += \
|
|||
rclhelp.cpp \
|
||||
rclmain_w.cpp \
|
||||
rclzg.cpp \
|
||||
respopup.cpp \
|
||||
reslist.cpp \
|
||||
restable.cpp \
|
||||
rtitool.cpp \
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <qtimer.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qimage.h>
|
||||
#include <qclipboard.h>
|
||||
#include <qscrollbar.h>
|
||||
#include <QTextBlock>
|
||||
#include <QShortcut>
|
||||
|
@ -59,6 +58,7 @@
|
|||
#ifdef RCL_USE_ASPELL
|
||||
#include "rclaspell.h"
|
||||
#endif
|
||||
#include "respopup.h"
|
||||
|
||||
static const QKeySequence quitKeySeq("Ctrl+q");
|
||||
static const QKeySequence closeKeySeq("Ctrl+w");
|
||||
|
@ -815,20 +815,6 @@ void ResList::mouseDoubleClickEvent(QMouseEvent *event)
|
|||
#endif
|
||||
}
|
||||
|
||||
void ResList::newSnippetsW(const Rcl::Doc& doc)
|
||||
{
|
||||
SnippetsW *sp = new SnippetsW(doc, m_source);
|
||||
if (m_rclmain) {
|
||||
connect(sp, SIGNAL(startNativeViewer(Rcl::Doc, int, QString)),
|
||||
m_rclmain, SLOT(startNativeViewer(Rcl::Doc, int, QString)));
|
||||
connect(new QShortcut(quitKeySeq, sp), SIGNAL (activated()),
|
||||
m_rclmain, SLOT (fileExit()));
|
||||
}
|
||||
connect(new QShortcut(closeKeySeq, sp), SIGNAL (activated()),
|
||||
sp, SLOT (close()));
|
||||
sp->show();
|
||||
}
|
||||
|
||||
void ResList::newDupsW(const Rcl::Doc&, const vector<Rcl::Doc>& dups)
|
||||
{
|
||||
ListDialog dialog;
|
||||
|
@ -886,7 +872,7 @@ void ResList::linkWasClicked(const QUrl &url)
|
|||
LOGERR(("ResList::linkWasClicked: can't get doc for %d\n", i));
|
||||
return;
|
||||
}
|
||||
newSnippetsW(doc);
|
||||
emit(showSnippets(doc));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -990,45 +976,12 @@ void ResList::createPopupMenu(const QPoint& pos)
|
|||
if (m_popDoc < 0)
|
||||
return;
|
||||
Rcl::Doc doc;
|
||||
bool havedoc = getDoc(m_popDoc, doc);
|
||||
string apptag;
|
||||
if (havedoc)
|
||||
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
|
||||
|
||||
QMenu *popup = new QMenu(this);
|
||||
|
||||
popup->addAction(tr("&Preview"), this, SLOT(menuPreview()));
|
||||
|
||||
if (havedoc &&
|
||||
!theconfig->getMimeViewerDef(doc.mimetype, apptag, 0).empty()) {
|
||||
popup->addAction(tr("&Open"), this, SLOT(menuEdit()));
|
||||
}
|
||||
popup->addAction(tr("Copy &File Name"), this, SLOT(menuCopyFN()));
|
||||
popup->addAction(tr("Copy &URL"), this, SLOT(menuCopyURL()));
|
||||
if (havedoc && !doc.ipath.empty()) {
|
||||
popup->addAction(tr("&Write to File"), this, SLOT(menuSaveToFile()));
|
||||
}
|
||||
|
||||
if (!getDoc(m_popDoc, doc))
|
||||
return;
|
||||
int options = 0;
|
||||
if (m_ismainlist)
|
||||
popup->addAction(tr("Find &similar documents"),
|
||||
this, SLOT(menuExpand()));
|
||||
|
||||
Rcl::Doc pdoc;
|
||||
if (m_source.isNotNull() && m_source->getEnclosing(doc, pdoc))
|
||||
popup->addAction(tr("Preview P&arent document/folder"),
|
||||
this, SLOT(menuPreviewParent()));
|
||||
|
||||
popup->addAction(tr("&Open Parent document/folder"),
|
||||
this, SLOT(menuOpenParent()));
|
||||
|
||||
if (havedoc && doc.haspages && m_source->snippetsCapable())
|
||||
popup->addAction(tr("Open &Snippets window"),
|
||||
this, SLOT(menuOpenSnippets()));
|
||||
|
||||
if (havedoc && rcldb && rcldb->hasSubDocs(doc))
|
||||
popup->addAction(tr("Show subdocuments / attachments"),
|
||||
this, SLOT(menuShowSubDocs()));
|
||||
|
||||
options |= ResultPopup::showExpand;
|
||||
QMenu *popup = ResultPopup::create(this, options, m_source, doc);
|
||||
popup->popup(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
@ -1054,45 +1007,28 @@ void ResList::menuSaveToFile()
|
|||
void ResList::menuPreviewParent()
|
||||
{
|
||||
Rcl::Doc doc;
|
||||
if (!getDoc(m_popDoc, doc) || m_source.isNull())
|
||||
return;
|
||||
Rcl::Doc pdoc;
|
||||
if (m_source->getEnclosing(doc, pdoc)) {
|
||||
emit previewRequested(pdoc);
|
||||
} else {
|
||||
// No parent doc: show enclosing folder with app configured for
|
||||
// directories
|
||||
pdoc.url = path_getfather(doc.url);
|
||||
pdoc.mimetype = "inode/directory";
|
||||
emit editRequested(pdoc);
|
||||
if (getDoc(m_popDoc, doc) && !m_source.isNull()) {
|
||||
Rcl::Doc pdoc = ResultPopup::getParent(m_source, doc);
|
||||
if (pdoc.mimetype == "inode/directory") {
|
||||
emit editRequested(pdoc);
|
||||
} else {
|
||||
emit previewRequested(pdoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResList::menuOpenParent()
|
||||
{
|
||||
Rcl::Doc doc;
|
||||
if (!getDoc(m_popDoc, doc) || m_source.isNull())
|
||||
return;
|
||||
Rcl::Doc pdoc;
|
||||
if (m_source->getEnclosing(doc, pdoc)) {
|
||||
emit editRequested(pdoc);
|
||||
} else {
|
||||
// No parent doc: show enclosing folder with app configured for
|
||||
// directories
|
||||
pdoc.url = path_getfather(doc.url);
|
||||
pdoc.meta[Rcl::Doc::keychildurl] = doc.url;
|
||||
pdoc.meta[Rcl::Doc::keyapptg] = "parentopen";
|
||||
pdoc.mimetype = "inode/directory";
|
||||
emit editRequested(pdoc);
|
||||
}
|
||||
if (getDoc(m_popDoc, doc) && m_source.isNotNull())
|
||||
emit editRequested(ResultPopup::getParent(m_source, doc));
|
||||
}
|
||||
|
||||
void ResList::menuOpenSnippets()
|
||||
void ResList::menuShowSnippets()
|
||||
{
|
||||
Rcl::Doc doc;
|
||||
if (!getDoc(m_popDoc, doc) || m_source.isNull())
|
||||
return;
|
||||
newSnippetsW(doc);
|
||||
if (getDoc(m_popDoc, doc))
|
||||
emit showSnippets(doc);
|
||||
}
|
||||
|
||||
void ResList::menuShowSubDocs()
|
||||
|
@ -1111,34 +1047,16 @@ void ResList::menuEdit()
|
|||
|
||||
void ResList::menuCopyFN()
|
||||
{
|
||||
LOGDEB(("menuCopyFN\n"));
|
||||
Rcl::Doc doc;
|
||||
if (getDoc(m_popDoc, doc)) {
|
||||
LOGDEB(("menuCopyFN: Got doc, fn: [%s]\n", doc.url.c_str()));
|
||||
// Our urls currently always begin with "file://"
|
||||
//
|
||||
// Problem: setText expects a QString. Passing a (const char*)
|
||||
// as we used to do causes an implicit conversion from
|
||||
// latin1. File are binary and the right approach would be no
|
||||
// conversion, but it's probably better (less worse...) to
|
||||
// make a "best effort" tentative and try to convert from the
|
||||
// locale's charset than accept the default conversion.
|
||||
QString qfn = QString::fromLocal8Bit(doc.url.c_str()+7);
|
||||
QApplication::clipboard()->setText(qfn, QClipboard::Selection);
|
||||
QApplication::clipboard()->setText(qfn, QClipboard::Clipboard);
|
||||
}
|
||||
if (getDoc(m_popDoc, doc))
|
||||
ResultPopup::copyFN(doc);
|
||||
}
|
||||
|
||||
void ResList::menuCopyURL()
|
||||
{
|
||||
Rcl::Doc doc;
|
||||
if (getDoc(m_popDoc, doc)) {
|
||||
string url = url_encode(doc.url, 7);
|
||||
QApplication::clipboard()->setText(url.c_str(),
|
||||
QClipboard::Selection);
|
||||
QApplication::clipboard()->setText(url.c_str(),
|
||||
QClipboard::Clipboard);
|
||||
}
|
||||
if (getDoc(m_popDoc, doc))
|
||||
ResultPopup::copyURL(doc);
|
||||
}
|
||||
|
||||
void ResList::menuExpand()
|
||||
|
|
|
@ -92,7 +92,7 @@ class ResList : public RESLIST_PARENTCLASS
|
|||
virtual void menuExpand();
|
||||
virtual void menuPreviewParent();
|
||||
virtual void menuOpenParent();
|
||||
virtual void menuOpenSnippets();
|
||||
virtual void menuShowSnippets();
|
||||
virtual void menuShowSubDocs();
|
||||
virtual void previewExposed(int);
|
||||
virtual void append(const QString &text);
|
||||
|
@ -108,6 +108,7 @@ class ResList : public RESLIST_PARENTCLASS
|
|||
void docPreviewClicked(int, Rcl::Doc, int);
|
||||
void docSaveToFileClicked(Rcl::Doc);
|
||||
void previewRequested(Rcl::Doc);
|
||||
void showSnippets(Rcl::Doc);
|
||||
void showSubDocs(Rcl::Doc);
|
||||
void editRequested(Rcl::Doc);
|
||||
void docExpand(Rcl::Doc);
|
||||
|
@ -153,7 +154,6 @@ class ResList : public RESLIST_PARENTCLASS
|
|||
bool scrollIsAtTop();
|
||||
bool scrollIsAtBottom();
|
||||
void setupArrows();
|
||||
void newSnippetsW(const Rcl::Doc &doc);
|
||||
void newDupsW(const Rcl::Doc& doc, const std::vector<Rcl::Doc>& dups);
|
||||
};
|
||||
|
||||
|
|
105
src/qtgui/respopup.cpp
Normal file
105
src/qtgui/respopup.cpp
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qmenu.h>
|
||||
#include <qclipboard.h>
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "smallut.h"
|
||||
#include "recoll.h"
|
||||
#include "docseq.h"
|
||||
#include "respopup.h"
|
||||
|
||||
namespace ResultPopup {
|
||||
|
||||
QMenu *create(QWidget *me, int opts, RefCntr<DocSequence> source, Rcl::Doc& doc)
|
||||
{
|
||||
QMenu *popup = new QMenu(me);
|
||||
|
||||
string apptag;
|
||||
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
|
||||
popup->addAction(me->tr("&Preview"), me, SLOT(menuPreview()));
|
||||
if (!theconfig->getMimeViewerDef(doc.mimetype, apptag, 0).empty()) {
|
||||
popup->addAction(me->tr("&Open"), me, SLOT(menuEdit()));
|
||||
}
|
||||
popup->addAction(me->tr("Copy &File Name"), me, SLOT(menuCopyFN()));
|
||||
popup->addAction(me->tr("Copy &URL"), me, SLOT(menuCopyURL()));
|
||||
if (!doc.ipath.empty())
|
||||
popup->addAction(me->tr("&Write to File"), me, SLOT(menuSaveToFile()));
|
||||
|
||||
Rcl::Doc pdoc;
|
||||
if (source.isNotNull() && source->getEnclosing(doc, pdoc)) {
|
||||
popup->addAction(me->tr("Preview P&arent document/folder"),
|
||||
me, SLOT(menuPreviewParent()));
|
||||
popup->addAction(me->tr("&Open Parent document/folder"),
|
||||
me, SLOT(menuOpenParent()));
|
||||
}
|
||||
if (opts & showExpand)
|
||||
popup->addAction(me->tr("Find &similar documents"),
|
||||
me, SLOT(menuExpand()));
|
||||
if (doc.haspages && source->snippetsCapable())
|
||||
popup->addAction(me->tr("Open &Snippets window"),
|
||||
me, SLOT(menuOpenSnippets()));
|
||||
|
||||
if (rcldb && rcldb->hasSubDocs(doc))
|
||||
popup->addAction(me->tr("Show subdocuments / attachments"),
|
||||
me, SLOT(menuShowSubDocs()));
|
||||
return popup;
|
||||
}
|
||||
|
||||
Rcl::Doc getParent(RefCntr<DocSequence> source,
|
||||
Rcl::Doc& doc)
|
||||
{
|
||||
Rcl::Doc pdoc;
|
||||
if (source.isNull() || !source->getEnclosing(doc, pdoc)) {
|
||||
// No parent doc: show enclosing folder with app configured for
|
||||
// directories
|
||||
pdoc.url = path_getfather(doc.url);
|
||||
pdoc.meta[Rcl::Doc::keychildurl] = doc.url;
|
||||
pdoc.meta[Rcl::Doc::keyapptg] = "parentopen";
|
||||
pdoc.mimetype = "inode/directory";
|
||||
}
|
||||
return pdoc;
|
||||
}
|
||||
|
||||
void copyFN(const Rcl::Doc &doc)
|
||||
{
|
||||
// Our urls currently always begin with "file://"
|
||||
//
|
||||
// Problem: setText expects a QString. Passing a (const char*)
|
||||
// as we used to do causes an implicit conversion from
|
||||
// latin1. File are binary and the right approach would be no
|
||||
// conversion, but it's probably better (less worse...) to
|
||||
// make a "best effort" tentative and try to convert from the
|
||||
// locale's charset than accept the default conversion.
|
||||
QString qfn = QString::fromLocal8Bit(doc.url.c_str()+7);
|
||||
QApplication::clipboard()->setText(qfn, QClipboard::Selection);
|
||||
QApplication::clipboard()->setText(qfn, QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
void copyURL(const Rcl::Doc &doc)
|
||||
{
|
||||
string url = url_encode(doc.url, 7);
|
||||
QApplication::clipboard()->setText(url.c_str(),
|
||||
QClipboard::Selection);
|
||||
QApplication::clipboard()->setText(url.c_str(),
|
||||
QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
}
|
31
src/qtgui/respopup.h
Normal file
31
src/qtgui/respopup.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* Copyright (C) 2006 J.F.Dockes
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _RESPOPUP_H_INCLUDED_
|
||||
#define _RESPOPUP_H_INCLUDED_
|
||||
|
||||
namespace ResultPopup {
|
||||
enum Options {showExpand = 0x1};
|
||||
extern QMenu *create(QWidget *me, int opts,
|
||||
RefCntr<DocSequence> source,
|
||||
Rcl::Doc& doc);
|
||||
extern Rcl::Doc getParent(RefCntr<DocSequence> source,
|
||||
Rcl::Doc& doc);
|
||||
extern void copyFN(const Rcl::Doc &doc);
|
||||
extern void copyURL(const Rcl::Doc &doc);
|
||||
};
|
||||
|
||||
#endif /* _RESPOPUP_H_INCLUDED_ */
|
|
@ -31,7 +31,6 @@
|
|||
#include <QTextDocument>
|
||||
#include <QPainter>
|
||||
#include <QSplitter>
|
||||
#include <QClipboard>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
@ -46,6 +45,7 @@
|
|||
#include "rclconfig.h"
|
||||
#include "plaintorich.h"
|
||||
#include "indexer.h"
|
||||
#include "respopup.h"
|
||||
|
||||
// Compensate for the default and somewhat bizarre vertical placement
|
||||
// of text in cells
|
||||
|
@ -137,18 +137,9 @@ void ResTableDetailArea::createPopupMenu(const QPoint& pos)
|
|||
LOGDEB(("ResTableDetailArea::createPopupMenu: no table/detaildoc\n"));
|
||||
return;
|
||||
}
|
||||
QMenu *popup = new QMenu(this);
|
||||
popup->addAction(tr("&Preview"), m_table, SLOT(menuPreview()));
|
||||
popup->addAction(tr("&Open"), m_table, SLOT(menuEdit()));
|
||||
popup->addAction(tr("Copy &File Name"), m_table, SLOT(menuCopyFN()));
|
||||
popup->addAction(tr("Copy &URL"), m_table, SLOT(menuCopyURL()));
|
||||
if (!m_table->m_detaildoc.ipath.empty())
|
||||
popup->addAction(tr("&Write to File"), m_table, SLOT(menuSaveToFile()));
|
||||
popup->addAction(tr("Find &similar documents"), m_table, SLOT(menuExpand()));
|
||||
popup->addAction(tr("Preview P&arent document/folder"),
|
||||
m_table, SLOT(menuPreviewParent()));
|
||||
popup->addAction(tr("&Open Parent document/folder"),
|
||||
m_table, SLOT(menuOpenParent()));
|
||||
QMenu *popup = ResultPopup::create(m_table, ResultPopup::showExpand,
|
||||
m_table->m_model->getDocSource(),
|
||||
m_table->m_detaildoc);
|
||||
popup->popup(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
@ -503,6 +494,7 @@ void ResTable::init()
|
|||
header->setSortIndicatorShown(true);
|
||||
header->setSortIndicator(-1, Qt::AscendingOrder);
|
||||
header->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
header->setStretchLastSection(1);
|
||||
connect(header, SIGNAL(sectionResized(int,int,int)),
|
||||
this, SLOT(saveColState()));
|
||||
connect(header, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||
|
@ -740,25 +732,9 @@ void ResTable::createPopupMenu(const QPoint& pos)
|
|||
LOGDEB(("ResTable::createPopupMenu: m_detaildocnum %d\n", m_detaildocnum));
|
||||
if (m_detaildocnum < 0)
|
||||
return;
|
||||
QMenu *popup = new QMenu(this);
|
||||
popup->addAction(tr("&Preview"), this, SLOT(menuPreview()));
|
||||
popup->addAction(tr("&Open"), this, SLOT(menuEdit()));
|
||||
popup->addAction(tr("Copy &File Name"), this, SLOT(menuCopyFN()));
|
||||
popup->addAction(tr("Copy &URL"), this, SLOT(menuCopyURL()));
|
||||
|
||||
if (m_detaildoc.ipath.empty())
|
||||
popup->addAction(tr("&Write to File"), this, SLOT(menuSaveToFile()));
|
||||
|
||||
popup->addAction(tr("Find &similar documents"), this, SLOT(menuExpand()));
|
||||
|
||||
RefCntr<DocSequence> source = m_model->getDocSource();
|
||||
Rcl::Doc pdoc;
|
||||
if (source.isNotNull() && source->getEnclosing(m_detaildoc, pdoc))
|
||||
popup->addAction(tr("Preview P&arent document/folder"),
|
||||
this, SLOT(menuPreviewParent()));
|
||||
|
||||
popup->addAction(tr("&Open Parent document/folder"),
|
||||
this, SLOT(menuOpenParent()));
|
||||
QMenu *popup = ResultPopup::create(this, ResultPopup::showExpand,
|
||||
m_model->getDocSource(),
|
||||
m_detaildoc);
|
||||
popup->popup(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
@ -771,98 +747,59 @@ void ResTable::menuPreview()
|
|||
|
||||
void ResTable::menuSaveToFile()
|
||||
{
|
||||
if (m_detaildocnum < 0)
|
||||
return;
|
||||
emit docSaveToFileClicked(m_detaildoc);
|
||||
if (m_detaildocnum >= 0)
|
||||
emit docSaveToFileClicked(m_detaildoc);
|
||||
}
|
||||
|
||||
void ResTable::menuPreviewParent()
|
||||
{
|
||||
if (!m_model || m_detaildocnum < 0)
|
||||
return;
|
||||
RefCntr<DocSequence> source = m_model->getDocSource();
|
||||
if (source.isNull())
|
||||
return;
|
||||
Rcl::Doc& doc = m_detaildoc;
|
||||
Rcl::Doc pdoc;
|
||||
if (source->getEnclosing(doc, pdoc)) {
|
||||
emit previewRequested(pdoc);
|
||||
} else {
|
||||
// No parent doc: show enclosing folder with app configured for
|
||||
// directories
|
||||
pdoc.url = path_getfather(doc.url);
|
||||
pdoc.meta[Rcl::Doc::keychildurl] = doc.url;
|
||||
pdoc.meta[Rcl::Doc::keyapptg] = "parentopen";
|
||||
pdoc.mimetype = "inode/directory";
|
||||
emit editRequested(pdoc);
|
||||
if (m_detaildocnum >= 0 && m_model &&
|
||||
m_model->getDocSource().isNotNull()) {
|
||||
Rcl::Doc pdoc = ResultPopup::getParent(m_model->getDocSource(),
|
||||
m_detaildoc);
|
||||
if (pdoc.mimetype == "inode/directory") {
|
||||
emit editRequested(pdoc);
|
||||
} else {
|
||||
emit previewRequested(pdoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResTable::menuOpenParent()
|
||||
{
|
||||
if (!m_model || m_detaildocnum < 0)
|
||||
return;
|
||||
RefCntr<DocSequence> source = m_model->getDocSource();
|
||||
if (source.isNull())
|
||||
return;
|
||||
Rcl::Doc& doc = m_detaildoc;
|
||||
Rcl::Doc pdoc;
|
||||
if (source->getEnclosing(doc, pdoc)) {
|
||||
emit editRequested(pdoc);
|
||||
} else {
|
||||
// No parent doc: show enclosing folder with app configured for
|
||||
// directories
|
||||
pdoc.url = path_getfather(doc.url);
|
||||
pdoc.meta[Rcl::Doc::keychildurl] = doc.url;
|
||||
pdoc.meta[Rcl::Doc::keyapptg] = "parentopen";
|
||||
pdoc.mimetype = "inode/directory";
|
||||
emit editRequested(pdoc);
|
||||
}
|
||||
if (m_detaildocnum >= 0 && m_model && m_model->getDocSource().isNotNull())
|
||||
emit editRequested(
|
||||
ResultPopup::getParent(m_model->getDocSource(), m_detaildoc));
|
||||
}
|
||||
|
||||
void ResTable::menuEdit()
|
||||
{
|
||||
if (m_detaildocnum < 0)
|
||||
return;
|
||||
emit docEditClicked(m_detaildoc);
|
||||
if (m_detaildocnum >= 0)
|
||||
emit docEditClicked(m_detaildoc);
|
||||
}
|
||||
|
||||
void ResTable::menuCopyFN()
|
||||
{
|
||||
if (m_detaildocnum < 0)
|
||||
return;
|
||||
Rcl::Doc &doc = m_detaildoc;
|
||||
|
||||
// Our urls currently always begin with "file://"
|
||||
//
|
||||
// Problem: setText expects a QString. Passing a (const char*)
|
||||
// as we used to do causes an implicit conversion from
|
||||
// latin1. File are binary and the right approach would be no
|
||||
// conversion, but it's probably better (less worse...) to
|
||||
// make a "best effort" tentative and try to convert from the
|
||||
// locale's charset than accept the default conversion.
|
||||
QString qfn = QString::fromLocal8Bit(doc.url.c_str()+7);
|
||||
QApplication::clipboard()->setText(qfn, QClipboard::Selection);
|
||||
QApplication::clipboard()->setText(qfn, QClipboard::Clipboard);
|
||||
if (m_detaildocnum >= 0)
|
||||
ResultPopup::copyFN(m_detaildoc);
|
||||
}
|
||||
|
||||
void ResTable::menuCopyURL()
|
||||
{
|
||||
if (m_detaildocnum < 0)
|
||||
return;
|
||||
Rcl::Doc &doc = m_detaildoc;
|
||||
string url = url_encode(doc.url, 7);
|
||||
QApplication::clipboard()->setText(url.c_str(),
|
||||
QClipboard::Selection);
|
||||
QApplication::clipboard()->setText(url.c_str(),
|
||||
QClipboard::Clipboard);
|
||||
if (m_detaildocnum >= 0)
|
||||
ResultPopup::copyURL(m_detaildoc);
|
||||
}
|
||||
|
||||
void ResTable::menuExpand()
|
||||
{
|
||||
if (m_detaildocnum < 0)
|
||||
return;
|
||||
emit docExpand(m_detaildoc);
|
||||
if (m_detaildocnum >= 0)
|
||||
emit docExpand(m_detaildoc);
|
||||
}
|
||||
|
||||
void ResTable::menuShowSubDocs()
|
||||
{
|
||||
if (m_detaildocnum >= 0)
|
||||
emit showSubDocs(m_detaildoc);
|
||||
}
|
||||
|
||||
void ResTable::createHeaderPopupMenu(const QPoint& pos)
|
||||
|
|
|
@ -136,6 +136,7 @@ public slots:
|
|||
virtual void menuExpand();
|
||||
virtual void menuPreviewParent();
|
||||
virtual void menuOpenParent();
|
||||
virtual void menuShowSubDocs();
|
||||
virtual void createHeaderPopupMenu(const QPoint&);
|
||||
virtual void deleteColumn();
|
||||
virtual void addColumn();
|
||||
|
@ -152,6 +153,7 @@ signals:
|
|||
void editRequested(Rcl::Doc);
|
||||
void headerClicked();
|
||||
void docExpand(Rcl::Doc);
|
||||
void showSubDocs(Rcl::Doc);
|
||||
|
||||
friend class ResTablePager;
|
||||
friend class ResTableDetailArea;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue