23#include <tqpaintdevicemetrics.h>
24#include <tqsimplerichtext.h>
27#include <tdeglobalsettings.h>
33#include "KPrNoteBar.h"
35#include "KPrDocument.h"
39KPrNoteBar::KPrNoteBar( TQWidget *_parent, KPrView *_view )
40 : TQWidget( _parent ),
44 TQBoxLayout *topLayout =
new TQVBoxLayout(
this, KDialog::marginHint(), KDialog::spacingHint() );
46 label =
new TQLabel(i18n(
"Note"),
this);
48 textEdit =
new KTextEdit(
this );
50 TQFont font = KoGlobal::defaultFont();
51 textEdit->setCurrentFont( font );
53 int currentPageNum = view->getCurrentPresPage();
54 TQString text=TQString();
55 if (currentPageNum!=-1)
56 text = view->kPresenterDoc()->pageList().at(currentPageNum - 1)->noteText( );
57 textEdit->setText( text );
59 connect( textEdit, TQ_SIGNAL( textChanged() ),
60 this, TQ_SLOT( slotTextChanged() ) );
62 connect( textEdit, TQ_SIGNAL( selectionChanged() ),
63 this, TQ_SLOT( slotSelectionChanged() ) );
65 connect( textEdit, TQ_SIGNAL( copyAvailable(
bool ) ),
66 this, TQ_SLOT( slotSelectionChanged() ) );
68 connect( textEdit, TQ_SIGNAL( undoAvailable(
bool ) ),
69 this, TQ_SLOT( slotUndoAvailable(
bool ) ) );
71 connect( textEdit, TQ_SIGNAL( redoAvailable(
bool ) ),
72 this, TQ_SLOT( slotRedoAvailable(
bool ) ) );
74 topLayout->addWidget( label );
75 topLayout->addWidget( textEdit );
78KPrNoteBar::~KPrNoteBar()
83void KPrNoteBar::setCurrentNoteText(
const TQString &_text )
86 textEdit->setText( _text );
90void KPrNoteBar::slotTextChanged()
92 int currentPageNum = view->getCurrPgNum();
93 if ( currentPageNum > 0 && !initialize ) {
94 if ( view->editMaster() )
95 view->kPresenterDoc()->refreshAllNoteBarMasterPage(textEdit->text() , view);
97 view->kPresenterDoc()->refreshAllNoteBar(currentPageNum -1,textEdit->text() , view);
98 textEdit->setModified(
true );
102void KPrNoteBar::slotSelectionChanged()
104 kdDebug(33001) <<
"slotSelectionChanged(): " << textEdit->hasSelectedText() << endl;
107void KPrNoteBar::slotCopyAvailable(
bool yes )
109 kdDebug(33001) <<
"slotCopyAvailable( " << yes <<
" )" << endl;
112void KPrNoteBar::slotUndoAvailable(
bool )
117void KPrNoteBar::slotRedoAvailable(
bool )
122void KPrNoteBar::printNotes( TQPainter *_painter, KPrinter *_printer, TQValueList<int> _list )
127 TQPaintDeviceMetrics metrics( _painter->device() );
128 int dpix = metrics.logicalDpiX();
129 int dpiy = metrics.logicalDpiY();
131 const int margin = 72;
132 TQRect body( margin * dpix / 72, margin * dpiy / 72,
133 metrics.width() - margin * dpix / 72 * 2,
134 metrics.height() - margin * dpiy / 72 * 2 );
136 TQFont font = KoGlobal::defaultFont();
137 TQString allText = getNotesTextForPrinting(_list);
138 TQString str = TQStyleSheet::convertFromPlainText( allText );
140 TQSimpleRichText richText( str, font, TQString(), TQStyleSheet::defaultSheet(),
141 TQMimeSourceFactory::defaultFactory(), body.height() );
143 richText.setWidth( _painter, body.width() );
145 TQRect viewRect( body );
147 richText.draw( _painter, body.left(), body.top(), viewRect, colorGroup() );
148 viewRect.moveBy( 0, body.height() );
149 _painter->translate( 0, -body.height() );
150 _painter->setFont( font );
152 if ( viewRect.top() >= richText.height() )
161TQString KPrNoteBar::getNotesTextForPrinting(TQValueList<int> _list)
const
163 TQString allText = TQString();
164 bool firstText =
true;
165 bool noteIsEmpty =
true;
167 KPrDocument *doc=view->kPresenterDoc();
168 for (
int i = 0; i < static_cast<int>( doc->pageList().count() ); i++, ++pageCount )
170 if (_list.contains(i+1)==0)
174 allText += TQString(
"\n\n");
176 allText += i18n(
"Slide Note %1:\n" ).arg( pageCount );
177 if(noteIsEmpty && !doc->pageList().at(i)->noteText().isEmpty())
179 allText += doc->pageList().at(i)->noteText();
185 allText += TQString(
"\n\n");
186 allText += i18n(
"Master Page Note:\n" );
187 if ( !doc->masterPage()->noteText().isEmpty() )
189 allText += doc->masterPage()->noteText();
196#include "KPrNoteBar.moc"