Commit eed32c76 authored by Enrico Ros's avatar Enrico Ros

FixPack 1: Small fix all over the code. Searwidget rewrite: looks good,

feels better. Updated TODO with interesting things.
Note: I feel performance loss. Need to check carefully all zoom functions,
relayouts and wasted paints. I'll love to do that after merging to HEAD.
Note to all: HEAD merge only after API will be final (the only 2 variables
are MemManager, ThreadedGen and maybe a DocumentDom (if I can make it next
weekend, but I think not)).

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=370404
parent dea9cfdf
......@@ -17,9 +17,8 @@ Things to do in order to merge in HEAD (first item has highest priority):
and rename internals too document->kpdfdocument, page->kpdfpage, etc..)
Higher priority after merge:
-> link thumbnails view with document
-> usability: layout 2PPV [1 2,3 4,5 6] -> [1,2 3,4 5]. add option for 'ebook' style alignemnt. (by Mikolaj)
-> usability: clear search must restore the full thumbs list (by Mikolaj)
-> link thumbnails view with document [first, the 'Viewport' must be defined]
-> usability: layout 2PPV [1 2,3 4,5 6] -> [1,2 3,4 5]. add option for 'ebook' style alignment. (by Mikolaj)
-> usability: trigger redraw on 'filter text' on current page (by Mikolaj)
-> async document generator using Albert's generator thread [0%]
-> watch out for FIXMEs in code
......@@ -34,9 +33,21 @@ More items (first items will enter 'In progress list' first):
custom fields.
-> display current page / total pages (with analog indicator too (progressbar/...))
maybe this can be done on a small widget at the top of the toolbox, displaying
'document' informations (pages, current pg, some metadata, etc..)
'document' informations (pages, current pg, some metadata, etc..).
Tested a 16px ktoolbar in the left-bottom corner.. looks goos and can be used to
insert some actions that aren't so useful in the main (and bigger) toolbar
-> abstract TextPage generation (the last xpdf dependant class!). then go dancing in the
streets.
-> Dom framework to cache document metadata. It should archive those types of data:
- Synopsis will go there after 1st generation (so we can edit it too)
- Document info (after the 1st gen)
- Bookmarked pages
- Edited pages (rotated/with_data for example)
- Overlay editing (hilighting/notations/etc..)
- ..more stuff.. but this isn't a problem, since a QDom is flexible by design
The Object will reside into the Document and must not be accessible by Oservers in
a direct way. Dom format, relations to other classes and accessing must be specified
in a separated diagram or text file.
-> right click and drag while in 'scroll' mode changes to 'selection' mode and selects
-> add kpdf manual in PDF format loaded on the first startup or on menu->help->manual
this visually explains basic usage, mouse buttons functions & more..
......@@ -68,11 +79,11 @@ More items (first items will enter 'In progress list' first):
-> investigate 'Splash' lack of smoothness at low resolutions (see lines in thumbnails)
Done (newest feature comes firts):
-> FIX: FixPack1 [dyn_zoom repaints, initial panel width, zoom_lineedit focus proxy, searchwidget refactor{thumbs restoring on clear, buttons size, less code}, hilight bookmarked thumbnails]
-> FIX: Some fullScreen loving, if we are on fullscreen put an action on RMB menu ti get out of it, if we were on fullScreen mode on exit bring back correctly if we were also seeing toolbar or menubar
-> FIX: When in non continous mode and scrolling up a page, set the viewport at the bottom of the page (Albert)
-> FIX: Dynamic zoom repaints the page while rescaling.
-> ADD: Show the window maximized when the user opens the program for the very first time (Albert)
-> ADD: Use 'Generators' as providers for contents generation.
-> ADD: Use 'Generators' as providers for contents generation
-> ADD: Add properties dialog (Albert)
-> ADD: Support for show/hide menubar in rmb menu, different from HEAD so that supports Konqueror too (Albert)
-> ADD: Watch File option (Albert)
......
......@@ -270,6 +270,11 @@ void KPDFDocument::findText( const QString & string, bool keepCase )
void KPDFDocument::findTextAll( const QString & pattern, bool keepCase )
{
// if pattern is null, clear 'hilighted' attribute in all pages
if ( pattern.isEmpty() )
unHilightPages();
// cache search pattern and perform a linear search/mark
d->filterText = pattern;
d->filterCase = keepCase;
processPageList( false );
......
......@@ -134,7 +134,9 @@ struct DocumentInfo
};
/**
* @short Viewport.
* @short A window on the document.
*
* TODO HACK OVER ME AND FIXME WITH A CHAINSAW
*/
struct DocumentViewport
{
......
......@@ -174,13 +174,13 @@ const DocumentSynopsis * GeneratorPDF::documentSynopsis()
docSyn = DocumentSynopsis();
if ( items->getLength() > 0 )
addDomChildren( &docSyn, items );
addSynopsisChildren( &docSyn, items );
docSynopsisDirty = false;
return &docSyn;
}
void GeneratorPDF::addDomChildren( QDomNode * parent, GList * items )
void GeneratorPDF::addSynopsisChildren( QDomNode * parent, GList * items )
{
int numItems = items->getLength();
for ( int i = 0; i < numItems; ++i )
......@@ -215,7 +215,7 @@ void GeneratorPDF::addDomChildren( QDomNode * parent, GList * items )
outlineItem->open();
GList * children = outlineItem->getKids();
if ( children )
addDomChildren( &item, children );
addSynopsisChildren( &item, children );
}
}
......@@ -484,7 +484,8 @@ QString GeneratorPDF::getDocumentDate( const QString & data ) const
s += 2;
if ( sscanf( s, "%4d%2d%2d%2d%2d%2d", &year, &mon, &day, &hour, &min, &sec ) == 6 )
{
QDate d( year, mon - 1, day );
kdDebug() << s << endl;
QDate d( year, mon, day ); //CHECK: it was mon-1, Jan->0 (??)
QTime t( hour, min, sec );
if ( d.isValid() && t.isValid() )
return KGlobal::locale()->formatDateTime( QDateTime(d, t), false, true );
......
......@@ -56,7 +56,7 @@ class GeneratorPDF : public Generator
QString getDocumentInfo( const QString & data ) const;
QString getDocumentDate( const QString & data ) const;
// private function for creating the document synopsis hieracy
void addDomChildren( QDomNode * parent, GList * items );
void addSynopsisChildren( QDomNode * parent, GList * items );
// private classes
QMutex docLock;
......
......@@ -106,7 +106,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
// widgets: [left toolbox] | []
m_toolBox = new QToolBox( m_splitter );
m_toolBox->setMinimumWidth( 60 );
m_toolBox->setMinimumWidth( 80 );
m_toolBox->setMaximumWidth( 300 );
TOC * tocFrame = new TOC( m_toolBox, m_document );
......@@ -121,12 +121,13 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_toolBox->addItem( thumbsBox, QIconSet(SmallIcon("thumbnail")), i18n("Thumbnails") );
m_toolBox->setCurrentItem( thumbsBox );
QFrame * bookmarksFrame = new QFrame( m_toolBox );
int iIdx = m_toolBox->addItem( bookmarksFrame, QIconSet(SmallIcon("bookmark")), i18n("Bookmarks") );
m_toolBox->setItemEnabled( iIdx, false );
// commented because probably the thumbnaillist will act as the bookmark widget too
// QFrame * bookmarksFrame = new QFrame( m_toolBox );
// int iIdx = m_toolBox->addItem( bookmarksFrame, QIconSet(SmallIcon("bookmark")), i18n("Bookmarks") );
// m_toolBox->setItemEnabled( iIdx, false );
QFrame * editFrame = new QFrame( m_toolBox );
iIdx = m_toolBox->addItem( editFrame, QIconSet(SmallIcon("pencil")), i18n("Annotations") );
int iIdx = m_toolBox->addItem( editFrame, QIconSet(SmallIcon("pencil")), i18n("Annotations") );
m_toolBox->setItemEnabled( iIdx, false );
// widgets: [] | [right 'pageView']
......@@ -177,10 +178,17 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_showProperties->setEnabled( false );
// attach the actions of the 2 children widgets too
m_pageView->setupActions( ac );
m_pageView->setupActions( ac );
// apply configuration (both internal settings and GUI configured items)
m_splitter->setSizes( Settings::splitterSizes() );
// apply configuration (both internal settings and GUI configured items)
QValueList<int> splitterSizes = Settings::splitterSizes();
if ( !splitterSizes.count() )
{
// the first time use 1/10 for the panel and 9/10 for the pageView
splitterSizes.push_back( 50 );
splitterSizes.push_back( 500 );
}
m_splitter->setSizes( splitterSizes );
slotNewConfig();
m_watcher = new KDirWatch( this );
......
......@@ -126,7 +126,7 @@ PageView::PageView( QWidget *parent, KPDFDocument *document )
connect( this, SIGNAL(contentsMoving(int, int)), this, SLOT(slotRequestVisiblePixmaps(int, int)) );
// ### [RELEASE: REMOVE] show initial warning for dev_version > 2004-Dec-04
d->messageWindow->display( "We're in progress of abstracting code. You will see some REGRESSIONS at this stage.", PageViewMessage::Warning, 8000 );
d->messageWindow->display( "kpdf_experiments is taking its way to HEAD! ;-)", PageViewMessage::Warning, 8000 );
// set a corner button to resize the view to the page size
// QPushButton * resizeButton = new QPushButton( viewport() );
......@@ -1337,6 +1337,7 @@ void PageView::slotAutoScoll()
void PageView::slotZoom()
{
setFocus();
updateZoom( ZoomFixed );
}
......
......@@ -23,57 +23,54 @@
#include "document.h"
#include "settings.h"
// uncomment following to enable the case switching button
//#define SW_ENABLE_CASE_BUTTON
#define CLEAR_ID 1
#define LEDIT_ID 2
#define FIND_ID 3
SearchWidget::SearchWidget( QWidget * parent, KPDFDocument * document )
: QHBox( parent ), m_document( document ), m_caseSensitive( false )
: KToolBar( parent, "iSearchBar" ), m_document( document ), m_caseSensitive( false )
{
setMargin( 4 );
// clear button
KToolBarButton * m_clearButton = new KToolBarButton( SmallIcon(QApplication::reverseLayout() ? "clear_left" : "locationbar_erase"), 1, this );
QToolTip::add( m_clearButton, i18n( "Clear filter" ) );
// change toolbar appearance
setMargin( 3 );
setFlat( true );
setIconSize( 16 );
setMovingEnabled( false );
// line edit
m_lineEdit = new KLineEdit( this );
m_lineEdit->setFrame( QFrame::Sunken );
connect( m_lineEdit, SIGNAL(textChanged(const QString &)), SLOT(slotTextChanged(const QString &)) );
connect( m_clearButton, SIGNAL(clicked()), m_lineEdit, SLOT(clear()) );
QToolTip::add( m_lineEdit, i18n( "Enter at least 3 letters to filter pages" ) );
insertLined( QString::null, LEDIT_ID, SIGNAL( textChanged(const QString &) ),
this, SLOT( slotTextChanged(const QString &) ), true,
i18n( "Enter at least 3 letters to filter pages" ), 0/*size*/, 1 );
// clear button (uses a lineEdit slot, so it must be created after)
insertButton( "editclear", CLEAR_ID, SIGNAL( clicked() ),
getLined( LEDIT_ID ), SLOT( clear() ), true,
i18n( "Clear filter" ), 0/*index*/ );
// change case button and menu (commented because there isn't enough space)
#if 0
KToolBarButton * search = new KToolBarButton( SmallIcon("find"), 2, this );
m_caseMenu = new KPopupMenu( search );
#ifdef SW_ENABLE_CASE_BUTTON
// create popup menu for change case button
m_caseMenu = new KPopupMenu( this );
m_caseMenu->insertItem( i18n("Case Insensitive"), 1 );
m_caseMenu->insertItem( i18n("Case Sensitive"), 2 );
m_caseMenu->setItemChecked( 1, true );
connect( m_caseMenu, SIGNAL( activated(int) ), SLOT( slotChangeCase(int) ) );
search->setPopup( m_caseMenu );
#endif
connect( m_caseMenu, SIGNAL( activated(int) ), SLOT( slotCaseChanged(int) ) );
int sideLength = m_lineEdit->sizeHint().height();
m_clearButton->setMinimumSize( QSize( sideLength, sideLength ) );
#if 0
search->setMinimumSize( QSize( sideLength, sideLength ) );
// create the change case button
insertButton( "find", FIND_ID, m_caseMenu, true,
i18n( "Change Case" ), 2/*index*/ );
#endif
}
void SearchWidget::hideEvent( QHideEvent * )
{
m_document->findTextAll( QString::null, m_caseSensitive );
// setStretchableWidget( lineEditWidget );
setItemAutoSized( LEDIT_ID );
}
void SearchWidget::slotTextChanged( const QString & text )
{
if ( text.length() > 2 || text.isEmpty() )
{
m_lineEdit->setPaletteForegroundColor( palette().active().text() );
m_document->findTextAll( text, m_caseSensitive );
}
else
{
m_lineEdit->setPaletteForegroundColor( Qt::red );
m_document->findTextAll( QString::null, m_caseSensitive );
}
// if length<3 set 'red' text and send a blank string to document
QColor color = text.length() < 3 ? Qt::red : palette().active().text();
getLined( LEDIT_ID )->setPaletteForegroundColor( color );
m_document->findTextAll( text.length() < 3 ? QString::null : text, m_caseSensitive );
}
void SearchWidget::slotCaseChanged( int index )
......@@ -84,7 +81,7 @@ void SearchWidget::slotCaseChanged( int index )
m_caseSensitive = newState;
m_caseMenu->setItemChecked( 1, !m_caseSensitive );
m_caseMenu->setItemChecked( 2, m_caseSensitive );
slotTextChanged( m_lineEdit->text() );
slotTextChanged( getLined( LEDIT_ID )->text() );
}
}
......
......@@ -10,31 +10,27 @@
#ifndef _KPDF_SEARCHWIDGET_H_
#define _KPDF_SEARCHWIDGET_H_
#include <qhbox.h>
#include <ktoolbar.h>
class KPopupMenu;
class KLineEdit;
class KPDFDocument;
/**
* @short A search widget for find-as-you-type search.
* @short A widget for find-as-you-type search. Outputs to the Document.
*
* ...
* This widget accepts keyboard input and performs a call to findTextAll(..)
* in the KPDFDocument class when there are 3 or more chars to search for.
* It supports case sensitive/unsensitive(default) and provieds a button
* for switching between the 2 modes.
*/
class SearchWidget : public QHBox
class SearchWidget : public KToolBar
{
Q_OBJECT
public:
SearchWidget( QWidget *parent, KPDFDocument *document );
protected:
void hideEvent( QHideEvent * );
private:
KPDFDocument * m_document;
KLineEdit * m_lineEdit;
KPopupMenu * m_caseMenu;
bool m_caseSensitive;
......
......@@ -373,13 +373,23 @@ void ThumbnailWidget::paintEvent( QPaintEvent * e )
// draw page outline and pixmap
if ( clipRect.top() < m_pixmapHeight + 4 )
{
// if page is bookmarked draw a colored border
bool isBookmarked = m_page->attributes() & KPDFPage::Bookmark;
// draw the inner rect
p.setPen( isBookmarked ? QColor( 0xFF8000 ) : Qt::black );
p.drawRect( 1, 1, m_pixmapWidth + 2, m_pixmapHeight + 2 );
p.setPen( palette().active().base() );
// draw the clear rect
p.setPen( isBookmarked ? QColor( 0x804000 ) : palette().active().base() );
p.drawRect( 0, 0, m_pixmapWidth + 4, m_pixmapHeight + 4 );
p.setPen( Qt::gray );
p.drawLine( 5, m_pixmapHeight + 3, m_pixmapWidth + 3, m_pixmapHeight + 3 );
p.drawLine( m_pixmapWidth + 3, 5, m_pixmapWidth + 3, m_pixmapHeight + 3 );
// draw the bottom and right shadow edges
if ( !isBookmarked )
{
p.setPen( Qt::gray );
p.drawLine( 5, m_pixmapHeight + 3, m_pixmapWidth + 3, m_pixmapHeight + 3 );
p.drawLine( m_pixmapWidth + 3, 5, m_pixmapWidth + 3, m_pixmapHeight + 3 );
}
// draw the page using the shared PagePainter class
p.translate( 2, 2 );
clipRect.moveBy( -2, -2 );
clipRect = clipRect.intersect( QRect( 0, 0, m_pixmapWidth, m_pixmapHeight ) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment