somewhat fixed qt4 selection problems
This commit is contained in:
parent
5cde51a522
commit
492c34a2d3
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: plaintorich.cpp,v 1.23 2007-06-12 10:32:43 dockes Exp $ (C) 2005 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: plaintorich.cpp,v 1.24 2007-06-12 13:31:38 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -317,7 +317,7 @@ string termAnchorName(int i)
|
|||||||
// http://unicode.org/faq/char_combmark.html#17
|
// http://unicode.org/faq/char_combmark.html#17
|
||||||
// We are counting on the fact that a sequence of two such chars should be
|
// We are counting on the fact that a sequence of two such chars should be
|
||||||
// extremely unlikely in normal text and not affecting the display.
|
// extremely unlikely in normal text and not affecting the display.
|
||||||
const char *firstTermBeacon = "\xcd\x8f\xcd\x8f";
|
const char *firstTermBeacon = " \xcd\x8f\xcd\x8f ";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static string termBeacon(int i)
|
static string termBeacon(int i)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.19 2007-06-01 05:44:40 dockes Exp $ (C) 2005 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.20 2007-06-12 13:31:38 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -47,7 +47,8 @@ using std::pair;
|
|||||||
#include <qlayout.h>
|
#include <qlayout.h>
|
||||||
#include <qtooltip.h>
|
#include <qtooltip.h>
|
||||||
#include <qwhatsthis.h>
|
#include <qwhatsthis.h>
|
||||||
#include "qapplication.h"
|
#include <qapplication.h>
|
||||||
|
#include <qclipboard.h>
|
||||||
|
|
||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
@ -88,8 +89,6 @@ void Preview::init()
|
|||||||
this, SLOT(currentChanged(QWidget *)));
|
this, SLOT(currentChanged(QWidget *)));
|
||||||
connect(bt, SIGNAL(clicked()), this, SLOT(closeCurrentTab()));
|
connect(bt, SIGNAL(clicked()), this, SLOT(closeCurrentTab()));
|
||||||
|
|
||||||
searchTextLine->installEventFilter(this);
|
|
||||||
pvEdit->installEventFilter(this);
|
|
||||||
dynSearchActive = false;
|
dynSearchActive = false;
|
||||||
canBeep = true;
|
canBeep = true;
|
||||||
tabData.push_back(TabData(pvTab->currentPage()));
|
tabData.push_back(TabData(pvTab->currentPage()));
|
||||||
@ -98,6 +97,7 @@ void Preview::init()
|
|||||||
resize(prefs.pvwidth, prefs.pvheight);
|
resize(prefs.pvwidth, prefs.pvheight);
|
||||||
}
|
}
|
||||||
m_loading = false;
|
m_loading = false;
|
||||||
|
currentChanged(pvTab->currentPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preview::destroy()
|
void Preview::destroy()
|
||||||
@ -116,7 +116,7 @@ void Preview::closeEvent(QCloseEvent *e)
|
|||||||
bool Preview::eventFilter(QObject *target, QEvent *event)
|
bool Preview::eventFilter(QObject *target, QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() != QEvent::KeyPress)
|
if (event->type() != QEvent::KeyPress)
|
||||||
return QWidget::eventFilter(target, event);
|
return false;
|
||||||
|
|
||||||
LOGDEB1(("Preview::eventFilter: keyEvent\n"));
|
LOGDEB1(("Preview::eventFilter: keyEvent\n"));
|
||||||
QKeyEvent *keyEvent = (QKeyEvent *)event;
|
QKeyEvent *keyEvent = (QKeyEvent *)event;
|
||||||
@ -174,7 +174,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QWidget::eventFilter(target, event);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preview::searchTextLine_textChanged(const QString & text)
|
void Preview::searchTextLine_textChanged(const QString & text)
|
||||||
@ -295,20 +295,60 @@ void Preview::currentChanged(QWidget * tw)
|
|||||||
|
|
||||||
if (edit == 0) {
|
if (edit == 0) {
|
||||||
LOGERR(("Editor child not found\n"));
|
LOGERR(("Editor child not found\n"));
|
||||||
} else {
|
return;
|
||||||
tw->installEventFilter(this);
|
}
|
||||||
edit->installEventFilter(this);
|
edit->setFocus();
|
||||||
edit->setFocus();
|
// Connect doubleclick but cleanup first just in case this was
|
||||||
connect(edit, SIGNAL(doubleClicked(int, int)),
|
// already connected.
|
||||||
this, SLOT(textDoubleClicked(int, int)));
|
disconnect(edit, SIGNAL(doubleClicked(int, int)), this, 0);
|
||||||
TabData *d = tabDataForCurrent();
|
connect(edit, SIGNAL(doubleClicked(int, int)),
|
||||||
if (d)
|
this, SLOT(textDoubleClicked(int, int)));
|
||||||
emit(previewExposed(m_searchId, d->docnum));
|
#if (QT_VERSION >= 0x040000)
|
||||||
|
connect(edit, SIGNAL(selectionChanged()), this, SLOT(selecChanged()));
|
||||||
|
#endif
|
||||||
|
tw->installEventFilter(this);
|
||||||
|
edit->installEventFilter(this);
|
||||||
|
TabData *d = tabDataForCurrent();
|
||||||
|
if (d)
|
||||||
|
emit(previewExposed(m_searchId, d->docnum));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (QT_VERSION >= 0x040000)
|
||||||
|
// I have absolutely no idea why this nonsense is needed to get
|
||||||
|
// q3textedit to copy to x11 primary selection when text is
|
||||||
|
// selected. This used to be automatic, and, looking at the code, it
|
||||||
|
// should happen inside q3textedit (the code here is copied from the
|
||||||
|
// private copyToClipboard method). To be checked again with a later
|
||||||
|
// qt version.
|
||||||
|
void Preview::selecChanged()
|
||||||
|
{
|
||||||
|
LOGDEB1(("Selection changed\n"));
|
||||||
|
if (!currentW)
|
||||||
|
return;
|
||||||
|
QTextEdit *edit = (QTextEdit *)currentW->child("pvEdit");
|
||||||
|
if (edit == 0) {
|
||||||
|
LOGERR(("Editor child not found\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
if (edit->hasSelectedText()) {
|
||||||
|
LOGDEB1(("Copying [%s] to primary selection.Clipboard sel supp: %d\n",
|
||||||
|
(const char *)edit->selectedText().ascii(),
|
||||||
|
clipboard->supportsSelection()));
|
||||||
|
disconnect(QApplication::clipboard(), SIGNAL(selectionChanged()),
|
||||||
|
edit, 0);
|
||||||
|
clipboard->setText(edit->selectedText(), QClipboard::Selection);
|
||||||
|
connect(QApplication::clipboard(), SIGNAL(selectionChanged()),
|
||||||
|
edit, SLOT(clipboardChanged()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void Preview::selecChanged(){}
|
||||||
|
#endif
|
||||||
|
|
||||||
void Preview::textDoubleClicked(int, int)
|
void Preview::textDoubleClicked(int, int)
|
||||||
{
|
{
|
||||||
|
LOGDEB2(("Preview::textDoubleClicked\n"));
|
||||||
if (!currentW)
|
if (!currentW)
|
||||||
return;
|
return;
|
||||||
QTextEdit *edit = (QTextEdit *)currentW->child("pvEdit");
|
QTextEdit *edit = (QTextEdit *)currentW->child("pvEdit");
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#ifndef _PREVIEW_W_H_INCLUDED_
|
#ifndef _PREVIEW_W_H_INCLUDED_
|
||||||
#define _PREVIEW_W_H_INCLUDED_
|
#define _PREVIEW_W_H_INCLUDED_
|
||||||
/* @(#$Id: preview_w.h,v 1.10 2007-05-23 09:19:48 dockes Exp $ (C) 2006 J.F.Dockes */
|
/* @(#$Id: preview_w.h,v 1.11 2007-06-12 13:31:38 dockes Exp $ (C) 2006 J.F.Dockes */
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -95,6 +95,9 @@ public slots:
|
|||||||
int docnum);
|
int docnum);
|
||||||
virtual void textDoubleClicked(int, int);
|
virtual void textDoubleClicked(int, int);
|
||||||
|
|
||||||
|
virtual void selecChanged();
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void previewClosed(QWidget *);
|
void previewClosed(QWidget *);
|
||||||
void wordSelect(QString);
|
void wordSelect(QString);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.28 2007-06-12 08:50:19 dockes Exp $ (C) 2005 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.29 2007-06-12 13:31:38 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -600,25 +600,24 @@ void RclMain::previewExposed(int sid, int docnum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add term to simple search. Term comes out of double-click in
|
// Add term to simple search. Term comes out of double-click in
|
||||||
// reslist or preview. The cleanup code is really horrible. Selection
|
// reslist or preview.
|
||||||
// out of the reslist will typically look like
|
|
||||||
// <!-- Fragment -->sometext
|
|
||||||
// It would probably be better to cleanup in preview.ui.h and
|
// It would probably be better to cleanup in preview.ui.h and
|
||||||
// reslist.cpp and do the proper html stuff in the latter case
|
// reslist.cpp and do the proper html stuff in the latter case
|
||||||
// (which is different because it's format is explicit richtext
|
// (which is different because it format is explicit richtext
|
||||||
// instead of auto as for preview, needed because it's built by
|
// instead of auto as for preview, needed because it's built by
|
||||||
// fragments?).
|
// fragments?).
|
||||||
static const char* punct = " \t()<>\"'[]{}!^*,\n\r";
|
static const char* punct = " \t()<>\"'[]{}!^*.,:;\n\r";
|
||||||
void RclMain::ssearchAddTerm(QString term)
|
void RclMain::ssearchAddTerm(QString term)
|
||||||
{
|
{
|
||||||
|
LOGDEB(("RclMain::ssearchAddTerm: [%s]\n", (const char *)term.utf8()));
|
||||||
string t = (const char *)term.utf8();
|
string t = (const char *)term.utf8();
|
||||||
string::size_type pos = t.find_last_not_of(punct);
|
string::size_type pos = t.find_last_not_of(punct);
|
||||||
if (pos == string::npos)
|
if (pos == string::npos)
|
||||||
return;
|
return;
|
||||||
t = t.substr(0, pos+1);
|
t = t.substr(0, pos+1);
|
||||||
pos = t.find_last_of(punct);
|
pos = t.find_first_not_of(punct);
|
||||||
if (pos != string::npos)
|
if (pos != string::npos)
|
||||||
t = t.substr(pos+1);
|
t = t.substr(pos);
|
||||||
if (t.empty())
|
if (t.empty())
|
||||||
return;
|
return;
|
||||||
term = QString::fromUtf8(t.c_str());
|
term = QString::fromUtf8(t.c_str());
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.24 2007-05-30 12:29:38 dockes Exp $ (C) 2005 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.25 2007-06-12 13:31:38 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -51,7 +51,6 @@ ResList::ResList(QWidget* parent, const char* name)
|
|||||||
{
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
setName("resList");
|
setName("resList");
|
||||||
setTextFormat(Qt::RichText);
|
|
||||||
setReadOnly(TRUE);
|
setReadOnly(TRUE);
|
||||||
setUndoRedoEnabled(FALSE);
|
setUndoRedoEnabled(FALSE);
|
||||||
languageChange();
|
languageChange();
|
||||||
@ -59,12 +58,14 @@ ResList::ResList(QWidget* parent, const char* name)
|
|||||||
setTabChangesFocus(true);
|
setTabChangesFocus(true);
|
||||||
|
|
||||||
// signals and slots connections
|
// signals and slots connections
|
||||||
connect(this, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)));
|
|
||||||
connect(this, SIGNAL(linkClicked(const QString &, int)),
|
connect(this, SIGNAL(linkClicked(const QString &, int)),
|
||||||
this, SLOT(linkWasClicked(const QString &, int)));
|
this, SLOT(linkWasClicked(const QString &, int)));
|
||||||
connect(this, SIGNAL(headerClicked()), this, SLOT(showQueryDetails()));
|
connect(this, SIGNAL(headerClicked()), this, SLOT(showQueryDetails()));
|
||||||
connect(this, SIGNAL(doubleClicked(int,int)),
|
connect(this, SIGNAL(doubleClicked(int,int)),
|
||||||
this, SLOT(doubleClicked(int, int)));
|
this, SLOT(doubleClicked(int, int)));
|
||||||
|
#if (QT_VERSION >= 0x040000)
|
||||||
|
connect(this, SIGNAL(selectionChanged()), this, SLOT(selecChanged()));
|
||||||
|
#endif
|
||||||
m_winfirst = -1;
|
m_winfirst = -1;
|
||||||
m_curPvDoc = -1;
|
m_curPvDoc = -1;
|
||||||
m_lstClckMod = 0;
|
m_lstClckMod = 0;
|
||||||
@ -85,7 +86,7 @@ void ResList::resetSearch()
|
|||||||
// following helps making sure that the textedit is really
|
// following helps making sure that the textedit is really
|
||||||
// blank. Else, there are often icons or text left around
|
// blank. Else, there are often icons or text left around
|
||||||
clear();
|
clear();
|
||||||
append(".");
|
QTEXTBROWSER::append(".");
|
||||||
clear();
|
clear();
|
||||||
#if (QT_VERSION < 0x040000)
|
#if (QT_VERSION < 0x040000)
|
||||||
XFlush(qt_xdisplay());
|
XFlush(qt_xdisplay());
|
||||||
@ -553,25 +554,6 @@ void ResList::resultPageNext()
|
|||||||
ensureCursorVisible();
|
ensureCursorVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Single click in result list use this for document selection, if no
|
|
||||||
// text selection active:
|
|
||||||
void ResList::clicked(int par, int)
|
|
||||||
{
|
|
||||||
LOGDEB2(("ResList::clicked\n"));
|
|
||||||
|
|
||||||
// It's very ennoying, textBrowser always has selected text. This
|
|
||||||
// is bound to change with qt releases!
|
|
||||||
if (hasSelectedText()&& selectedText().compare("<!--StartFragment-->")) {
|
|
||||||
// Give priority to text selection, do nothing
|
|
||||||
LOGDEB2(("%s\n", (const char *)(selectedText().ascii())));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LOGDEB(("click at par %d (with %s %s)\n", par,
|
|
||||||
(m_lstClckMod & Qt::ControlButton) ? "Ctrl" : "",
|
|
||||||
(m_lstClckMod & Qt::ShiftButton) ? "Shft" : ""));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Color paragraph (if any) of currently visible preview
|
// Color paragraph (if any) of currently visible preview
|
||||||
void ResList::previewExposed(int docnum)
|
void ResList::previewExposed(int docnum)
|
||||||
{
|
{
|
||||||
@ -598,6 +580,32 @@ void ResList::previewExposed(int docnum)
|
|||||||
setParagraphBackgroundColor(par, color);
|
setParagraphBackgroundColor(par, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SELECTION BEWARE: these emit simple text if the list format is
|
||||||
|
// Auto. If we get back to using Rich for some reason, there will be
|
||||||
|
// need to extract the simple text here.
|
||||||
|
|
||||||
|
#if (QT_VERSION >= 0x040000)
|
||||||
|
// I have absolutely no idea why this nonsense is needed to get
|
||||||
|
// q3textedit to copy to x11 primary selection when text is
|
||||||
|
// selected. This used to be automatic, and, looking at the code, it
|
||||||
|
// should happen inside q3textedit (the code here is copied from the
|
||||||
|
// private copyToClipboard method). To be checked again with a later
|
||||||
|
// qt version. Seems to be needed at least up to 4.2.3
|
||||||
|
void ResList::selecChanged()
|
||||||
|
{
|
||||||
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
if (hasSelectedText()) {
|
||||||
|
disconnect(QApplication::clipboard(), SIGNAL(selectionChanged()),
|
||||||
|
this, 0);
|
||||||
|
clipboard->setText(selectedText(), QClipboard::Selection);
|
||||||
|
connect(QApplication::clipboard(), SIGNAL(selectionChanged()),
|
||||||
|
this, SLOT(clipboardChanged()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void ResList::selecChanged(){}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Double click in res list: add selection to simple search
|
// Double click in res list: add selection to simple search
|
||||||
void ResList::doubleClicked(int, int)
|
void ResList::doubleClicked(int, int)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#ifndef _RESLIST_H_INCLUDED_
|
#ifndef _RESLIST_H_INCLUDED_
|
||||||
#define _RESLIST_H_INCLUDED_
|
#define _RESLIST_H_INCLUDED_
|
||||||
/* @(#$Id: reslist.h,v 1.10 2007-05-30 12:29:38 dockes Exp $ (C) 2005 J.F.Dockes */
|
/* @(#$Id: reslist.h,v 1.11 2007-06-12 13:31:38 dockes Exp $ (C) 2005 J.F.Dockes */
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
@ -44,7 +44,6 @@ class ResList : public QTEXTBROWSER
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void resetSearch();
|
virtual void resetSearch();
|
||||||
virtual void clicked(int, int);
|
|
||||||
virtual void doubleClicked(int, int);
|
virtual void doubleClicked(int, int);
|
||||||
virtual void resPageUpOrBack(); // Page up pressed
|
virtual void resPageUpOrBack(); // Page up pressed
|
||||||
virtual void resPageDownOrNext(); // Page down pressed
|
virtual void resPageDownOrNext(); // Page down pressed
|
||||||
@ -58,6 +57,8 @@ class ResList : public QTEXTBROWSER
|
|||||||
virtual void menuSeeParent();
|
virtual void menuSeeParent();
|
||||||
virtual void previewExposed(int);
|
virtual void previewExposed(int);
|
||||||
virtual void append(const QString &text);
|
virtual void append(const QString &text);
|
||||||
|
// Only used for qt ver >=4 but seems we cant undef it
|
||||||
|
virtual void selecChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nextPageAvailable(bool);
|
void nextPageAvailable(bool);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user