• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

knode

  • sources
  • kde-4.14
  • kdepim
  • knode
kncomposer.cpp
Go to the documentation of this file.
1 /*
2  KNode, the KDE newsreader
3  Copyright (c) 1999-2006 the KNode authors.
4  See file AUTHORS for details
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  You should have received a copy of the GNU General Public License
11  along with this program; if not, write to the Free Software Foundation,
12  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
13 */
14 
15 #include "kncomposer.h"
16 
17 #include <KPIMUtils/Email>
18 #include <KPIMIdentities/Identity>
19 #include <KPIMIdentities/IdentityManager>
20 #include <QVBoxLayout>
21 #include <QLabel>
22 #include <QtDBus/QtDBus>
23 #include <qgroupbox.h>
24 #include "libkdepim/addressline/recentaddress/recentaddresses.h"
25 #include "libkdepim/addressline/recentaddress/recentaddressdialog.h"
26 using KPIM::RecentAddresses;
27 #include <akonadi/contact/emailaddressselectiondialog.h>
28 #include <kcharsets.h>
29 #include <kmessagebox.h>
30 #include <kactioncollection.h>
31 #include <kstandardaction.h>
32 #include <kshortcutsdialog.h>
33 #include <kedittoolbar.h>
34 #include <kmenu.h>
35 #include <kdebug.h>
36 #include <kcombobox.h>
37 #include <ktemporaryfile.h>
38 #include <libkpgp/kpgpblock.h>
39 #include <kcompletionbox.h>
40 #include <kxmlguifactory.h>
41 #include <kstatusbar.h>
42 #include <klocale.h>
43 #include <kselectaction.h>
44 #include <ktoggleaction.h>
45 #include "kngroupselectdialog.h"
46 #include "utilities.h"
47 #include "knglobals.h"
48 #include "knmainwidget.h"
49 #include "knaccountmanager.h"
50 #include "knnntpaccount.h"
51 #include "settings.h"
52 #include "kncomposerview.h"
53 #include "utils/locale.h"
54 
55 using namespace KNode::Utilities;
56 using namespace KNode::Composer;
57 
58 
59 KNLineEdit::KNLineEdit( View *parent, bool useCompletion )
60  : KABC::AddressLineEdit( parent, useCompletion ),
61  composerView( parent )
62 {
63 }
64 
65 KNLineEdit::KNLineEdit( QWidget *parent, bool useCompletion )
66  : KABC::AddressLineEdit( parent, useCompletion ), composerView(0)
67 {
68 }
69 
70 
71 void KNLineEdit::contextMenuEvent( QContextMenuEvent*e )
72 {
73  QMenu *popup = KLineEdit::createStandardContextMenu();
74  popup->addSeparator();
75  popup->addAction( i18n( "Edit Recent Addresses..." ),
76  this, SLOT(editRecentAddresses()) );
77  popup->exec( e->globalPos() );
78  delete popup;
79 }
80 
81 void KNLineEdit::editRecentAddresses()
82 {
83  KPIM::RecentAddressDialog dlg( this );
84  dlg.setAddresses( RecentAddresses::self( knGlobals.config() )->addresses() );
85  if ( dlg.exec() ) {
86  RecentAddresses::self( knGlobals.config() )->clear();
87  dlg.storeAddresses(knGlobals.config());
88  loadAddresses();
89  }
90 }
91 
92 void KNLineEdit::loadAddresses()
93 {
94  KABC::AddressLineEdit::loadAddresses();
95 
96  QStringList recent = RecentAddresses::self(knGlobals.config())->addresses();
97  QStringList::Iterator it = recent.begin();
98  for ( ; it != recent.end(); ++it )
99  addAddress( *it );
100 }
101 
102 void KNLineEdit::keyPressEvent(QKeyEvent *e)
103 {
104  // ---sven's Return is same Tab and arrow key navigation start ---
105  if ((e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) &&
106  !completionBox()->isVisible())
107  {
108  composerView->focusNextPrevEdit( this, true );
109  return;
110  }
111  if (e->key() == Qt::Key_Up)
112  {
113  composerView->focusNextPrevEdit( this, false ); // Go up
114  return;
115  }
116  if (e->key() == Qt::Key_Down)
117  {
118  composerView->focusNextPrevEdit( this, true ); // Go down
119  return;
120  }
121  // ---sven's Return is same Tab and arrow key navigation end ---
122  KABC::AddressLineEdit::keyPressEvent(e);
123 }
124 
125 
126 KNLineEditSpell::KNLineEditSpell( View *parent, bool useCompletion )
127  : KNLineEdit( parent, useCompletion )
128 {
129 }
130 
131 KNLineEditSpell::KNLineEditSpell( QWidget *parent, bool useCompletion )
132  : KNLineEdit( parent, useCompletion )
133 {
134 }
135 
136 void KNLineEditSpell::highLightWord( unsigned int length, unsigned int pos )
137 {
138  setSelection ( pos, length );
139 }
140 
141 void KNLineEditSpell::spellCheckDone( const QString &s )
142 {
143  if( s != text() )
144  setText( s );
145 }
146 
147 void KNLineEditSpell::spellCheckerMisspelling( const QString &_text, const QStringList &, unsigned int pos)
148 {
149  highLightWord( _text.length(),pos );
150 }
151 
152 void KNLineEditSpell::spellCheckerCorrected( const QString &old, const QString &corr, unsigned int pos)
153 {
154  if( old!= corr )
155  {
156  setSelection ( pos, old.length() );
157  insert( corr );
158  setSelection ( pos, corr.length() );
159  }
160 }
161 
162 
163 KNComposer::KNComposer( KNLocalArticle::Ptr a, const QString &text, const QString &unwraped, bool firstEdit, bool dislikesCopies, bool createCopy, bool allowMail )
164  : KXmlGuiWindow(0), r_esult(CRsave), a_rticle(a),
165  u_nwraped(unwraped),
166  n_eeds8Bit(true), v_alidated(false), a_uthorDislikesMailCopies(dislikesCopies), e_xternalEdited(false), e_xternalEditor(0),
167  e_ditorTempfile(0), a_ttChanged(false),
168  mFirstEdit( firstEdit )
169 {
170  setObjectName( "composerWindow" );
171 
172  if( knGlobals.componentData().isValid() )
173  setComponentData( knGlobals.componentData() );
174 
175  // activate dnd of attachments...
176  setAcceptDrops(true);
177 
178  //init v_iew
179  v_iew = new View( this );
180  setCentralWidget(v_iew);
181 
182  connect( v_iew, SIGNAL(closeExternalEditor()), this, SLOT(slotCancelEditor()) );
183 
184  //statusbar
185  KStatusBar *sb=statusBar();
186  sb->insertItem( QString(), 1, 1 ); // type
187  sb->setItemAlignment( 1, Qt::AlignLeft | Qt::AlignVCenter );
188  sb->insertItem( QString(), 2, 1 ); // charset
189  sb->setItemAlignment( 2, Qt::AlignLeft | Qt::AlignVCenter );
190  sb->insertItem( QString(), 3, 1 ); // write mode
191  sb->setItemAlignment(3, Qt::AlignCenter | Qt::AlignVCenter );
192  sb->insertItem( QString(), 4, 1 ); // column
193  sb->setItemAlignment(4, Qt::AlignCenter | Qt::AlignVCenter );
194  sb->insertItem( QString(), 5, 1 ); // line
195  sb->setItemAlignment( 5, Qt::AlignCenter | Qt::AlignVCenter );
196  connect(v_iew->editor(), SIGNAL(cursorPositionChanged()), SLOT(slotUpdateCursorPos()));
197  connect(v_iew->editor(), SIGNAL(insertModeChanged()), SLOT(slotUpdateStatusBar()));
198 
199  QDBusConnection::sessionBus().registerObject( "/Composer", this, QDBusConnection::ExportScriptableSlots );
200  //------------------------------- <Actions> --------------------------------------
201 
202  //file menu
203  KAction *action = actionCollection()->addAction("send_now");
204  action->setIcon(KIcon("mail-send"));
205  action->setText(i18n("&Send Now"));
206  connect(action, SIGNAL(triggered(bool)), SLOT(slotSendNow()));
207  action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return));
208 
209  action = actionCollection()->addAction("send_later");
210  action->setIcon(KIcon("mail-queue"));
211  action->setText(i18n("Send &Later"));
212  connect(action, SIGNAL(triggered(bool)), SLOT(slotSendLater()));
213 
214  action = actionCollection()->addAction("save_as_draft");
215  action->setIcon(KIcon("document-save"));
216  action->setText(i18n("Save as &Draft"));
217  connect(action, SIGNAL(triggered(bool)), SLOT(slotSaveAsDraft()));
218 
219  action = actionCollection()->addAction("art_delete");
220  action->setIcon(KIcon("edit-delete"));
221  action->setText(i18n("D&elete"));
222  connect(action, SIGNAL(triggered(bool)), SLOT(slotArtDelete()));
223 
224  KStandardAction::close(this, SLOT(close()),actionCollection());
225 
226  //edit menu
227  KStandardAction::undo(this, SLOT(slotUndo()), actionCollection());
228  KStandardAction::redo(this, SLOT(slotRedo()), actionCollection());
229 
230  KStandardAction::cut(this, SLOT(slotCut()), actionCollection());
231 
232 
233  KStandardAction::copy(this, SLOT(slotCopy()), actionCollection());
234 
235  KStandardAction::pasteText(this, SLOT(slotPaste()), actionCollection());
236 
237  action = actionCollection()->addAction("paste_quoted");
238  action->setText(i18n("Paste as &Quotation"));
239  connect(action, SIGNAL(triggered(bool)), v_iew->editor(), SLOT(slotPasteAsQuotation()));
240 
241  KStandardAction::selectAll(this, SLOT(slotSelectAll()), actionCollection());
242 
243  KStandardAction::find(v_iew->editor(), SLOT(slotFind()), actionCollection());
244  KStandardAction::findNext(v_iew->editor(), SLOT(slotFindNext()), actionCollection());
245 
246  KStandardAction::replace(v_iew->editor(), SLOT(slotReplace()), actionCollection());
247 
248  //attach menu
249  action = actionCollection()->addAction("append_signature");
250  action->setText(i18n("Append &Signature"));
251  connect( action, SIGNAL(triggered(bool)), v_iew, SLOT(appendSignature()) );
252 
253  action = actionCollection()->addAction("insert_file");
254  action->setText(i18n("&Insert File..."));
255  connect(action, SIGNAL(triggered(bool)), SLOT(slotInsertFile()));
256 
257  action = actionCollection()->addAction("insert_file_boxed");
258  action->setText(i18n("Insert File (in a &box)..."));
259  connect(action, SIGNAL(triggered(bool)), SLOT(slotInsertFileBoxed()));
260 
261  action = actionCollection()->addAction("attach_file");
262  action->setIcon(KIcon("mail-attachment"));
263  action->setText(i18n("Attach &File..."));
264  connect(action, SIGNAL(triggered(bool)), SLOT(slotAttachFile()));
265 
266  a_ctPGPsign = actionCollection()->add<KToggleAction>("sign_article");
267  a_ctPGPsign->setText(i18n("Sign Article with &PGP"));
268  a_ctPGPsign->setIcon(KIcon("document-sign"));
269 
270  a_ctRemoveAttachment = actionCollection()->addAction("remove_attachment");
271  a_ctRemoveAttachment->setText(i18n("&Remove"));
272  connect( a_ctRemoveAttachment, SIGNAL(triggered(bool)), v_iew, SLOT(removeCurrentAttachment()) );
273 
274  a_ctAttachmentProperties = actionCollection()->addAction("attachment_properties");
275  a_ctAttachmentProperties->setText(i18n("&Properties"));
276  connect( a_ctAttachmentProperties, SIGNAL(triggered(bool)), v_iew, SLOT(editCurrentAttachment()) );
277 
278  //options menu
279 
280  a_ctDoPost = actionCollection()->add<KToggleAction>("send_news");
281  a_ctDoPost->setIcon(KIcon("document-new"));
282  a_ctDoPost->setText(i18n("Send &News Article"));
283  connect(a_ctDoPost, SIGNAL(triggered(bool)), SLOT(slotToggleDoPost()));
284 
285  a_ctDoMail = actionCollection()->add<KToggleAction>("send_mail");
286  a_ctDoMail->setIcon(KIcon("mail-send"));
287  a_ctDoMail->setText(i18n("Send E&mail"));
288  a_ctDoMail->setEnabled(allowMail);
289  connect(a_ctDoMail, SIGNAL(triggered(bool)), SLOT(slotToggleDoMail()));
290 
291  a_ctSetCharset = actionCollection()->add<KSelectAction>("set_charset");
292  a_ctSetCharset->setText(i18n("Set &Charset"));
293  a_ctSetCharset->setItems( Locale::encodings() );
294  a_ctSetCharset->setShortcutConfigurable(false);
295  connect(a_ctSetCharset, SIGNAL(triggered(QString)),
296  this, SLOT(slotSetCharset(QString)));
297 
298  a_ctSetCharsetKeyb = actionCollection()->addAction("set_charset_keyboard");
299  a_ctSetCharsetKeyb->setText(i18n("Set Charset"));
300  connect(a_ctSetCharsetKeyb, SIGNAL(triggered(bool)), SLOT(slotSetCharsetKeyboard()));
301  addAction( a_ctSetCharsetKeyb );
302 
303 
304  a_ctWordWrap = actionCollection()->add<KToggleAction>("toggle_wordwrap");
305  a_ctWordWrap->setText(i18n("&Word Wrap"));
306  connect(a_ctWordWrap, SIGNAL(triggered(bool)), SLOT(slotToggleWordWrap()));
307 
308  a_ctAutoSpellChecking = new KToggleAction( KIcon( "tools-check-spelling" ), i18n("&Automatic Spellchecking"), this );
309  actionCollection()->addAction( "options_auto_spellchecking", a_ctAutoSpellChecking );
310  a_ctAutoSpellChecking->setChecked( knGlobals.settings()->autoSpellChecking() );
311  slotUpdateCheckSpellChecking( knGlobals.settings()->autoSpellChecking() );
312  slotAutoSpellCheckingToggled();
313  connect(a_ctAutoSpellChecking, SIGNAL(triggered(bool)), SLOT(slotAutoSpellCheckingToggled()));
314  connect( v_iew->editor(), SIGNAL(checkSpellingChanged(bool)), this, SLOT(slotUpdateCheckSpellChecking(bool)));
315 
316 
317  //tools menu
318 
319  action = actionCollection()->addAction("tools_quote");
320  action->setText(i18n("Add &Quote Characters"));
321  connect(action, SIGNAL(triggered(bool)), v_iew->editor(), SLOT(slotAddQuotes()));
322 
323  action = actionCollection()->addAction("tools_unquote");
324  action->setText(i18n("&Remove Quote Characters"));
325  connect(action, SIGNAL(triggered(bool)), v_iew->editor(), SLOT(slotRemoveQuotes()));
326 
327  action = actionCollection()->addAction("tools_box");
328  action->setText(i18n("Add &Box"));
329  connect(action, SIGNAL(triggered(bool)), v_iew->editor(), SLOT(slotAddBox()));
330 
331  action = actionCollection()->addAction("tools_unbox");
332  action->setText(i18n("Re&move Box"));
333  connect(action, SIGNAL(triggered(bool)), v_iew->editor(), SLOT(slotRemoveBox()));
334 
335  QAction *undoRewrap = actionCollection()->addAction("tools_undoRewrap");
336  undoRewrap->setText(i18n("Get &Original Text (not re-wrapped)"));
337  connect(undoRewrap, SIGNAL(triggered(bool)), SLOT(slotUndoRewrap()));
338  undoRewrap->setEnabled(!u_nwraped.isNull());
339 
340  QAction *rot13 = actionCollection()->addAction("tools_rot13");
341  rot13->setIcon(KIcon("document-encrypt"));
342  rot13->setText(i18n("S&cramble (Rot 13)"));
343  connect(rot13, SIGNAL(triggered(bool)), v_iew->editor(), SLOT(slotRot13()));
344  rot13->setEnabled(false);
345  connect(v_iew->editor(), SIGNAL(copyAvailable(bool)), rot13, SLOT(setEnabled(bool)));
346 
347  a_ctExternalEditor = actionCollection()->addAction("external_editor");
348  a_ctExternalEditor->setIcon(KIcon("system-run"));
349  a_ctExternalEditor->setText(i18n("Start &External Editor"));
350  connect(a_ctExternalEditor, SIGNAL(triggered(bool)), SLOT(slotExternalEditor()));
351 
352  a_ctSpellCheck = KStandardAction::spelling ( v_iew->editor(), SLOT(checkSpelling()), actionCollection());
353 
354  //settings menu
355  createStandardStatusBarAction();
356  setStandardToolBarMenuEnabled(true);
357 
358  KStandardAction::keyBindings(this, SLOT(slotConfKeys()), actionCollection());
359 
360  KStandardAction::configureToolbars(this, SLOT(slotConfToolbar()), actionCollection());
361 
362  KStandardAction::preferences(knGlobals.top, SLOT(slotSettings()), actionCollection());
363 
364 
365  createGUI("kncomposerui.rc");
366 
367  //---------------------------------- </Actions> ----------------------------------------
368 
369  //init
370  initData(text);
371 
372  //apply configuration
373  setConfig(false);
374 
375  if (createCopy && (m_ode==news)) {
376  a_ctDoMail->setChecked(true);
377  slotToggleDoMail();
378  }
379 
380  v_iew->completeSetup( firstEdit, m_ode );
381 
382  // restore window & toolbar configuration
383  resize(535,450); // default optimized for 800x600
384  applyMainWindowSettings(knGlobals.config()->group("composerWindow_options"));
385 
386  // starting the external editor
387  if ( knGlobals.settings()->useExternalEditor() )
388  slotExternalEditor();
389 }
390 
391 
392 KNComposer::~KNComposer()
393 {
394  // prevent slotEditorFinished from being called
395  if (e_xternalEditor)
396  e_xternalEditor->disconnect();
397  delete e_xternalEditor; // this also kills the editor process if it's still running
398 
399  delete e_ditorTempfile;
400 
401  saveMainWindowSettings(knGlobals.config()->group("composerWindow_options"));
402 
403  KNGlobals::self()->settings()->setAutoSpellChecking( a_ctAutoSpellChecking->isChecked() );
404  KNGlobals::self()->settings()->writeConfig();
405 }
406 
407 void KNComposer::slotUpdateCheckSpellChecking(bool _b)
408 {
409  a_ctAutoSpellChecking->setChecked(_b);
410 }
411 
412 
413 void KNComposer::slotUndo()
414 {
415  QWidget* fw = focusWidget();
416  if (!fw) return;
417 
418  if (fw->inherits("KTextEdit"))
419  ((KTextEdit*)fw)->undo();
420  else if (fw->inherits("QLineEdit"))
421  ((QLineEdit*)fw)->undo();
422 }
423 
424 void KNComposer::slotRedo()
425 {
426  QWidget* fw = focusWidget();
427  if (!fw) return;
428 
429  if (fw->inherits("KTextEdit"))
430  ((KTextEdit*)fw)->redo();
431  else if (fw->inherits("QLineEdit"))
432  ((QLineEdit*)fw)->redo();
433 }
434 
435 void KNComposer::slotCut()
436 {
437  QWidget* fw = focusWidget();
438  if (!fw) return;
439 
440  if (fw->inherits("KTextEdit"))
441  ((KTextEdit*)fw)->cut();
442  else if (fw->inherits("QLineEdit"))
443  ((QLineEdit*)fw)->cut();
444  else kDebug(5003) <<"wrong focus widget";
445 }
446 
447 void KNComposer::slotCopy()
448 {
449  QWidget* fw = focusWidget();
450  if (!fw) return;
451 
452  if (fw->inherits("KTextEdit"))
453  ((KTextEdit*)fw)->copy();
454  else if (fw->inherits("QLineEdit"))
455  ((QLineEdit*)fw)->copy();
456  else kDebug(5003) <<"wrong focus widget";
457 
458 }
459 
460 
461 void KNComposer::slotPaste()
462 {
463  QWidget* fw = focusWidget();
464  if (!fw) return;
465 
466  if (fw->inherits("KTextEdit"))
467  ((KTextEdit*)fw)->paste();
468  else if (fw->inherits("QLineEdit"))
469  ((QLineEdit*)fw)->paste();
470  else kDebug(5003) <<"wrong focus widget";
471 }
472 
473 void KNComposer::slotSelectAll()
474 {
475  QWidget* fw = focusWidget();
476  if (!fw) return;
477 
478  if (fw->inherits("QLineEdit"))
479  ((QLineEdit*)fw)->selectAll();
480  else if (fw->inherits("KTextEdit"))
481  ((KTextEdit*)fw)->selectAll();
482 }
483 
484 
485 void KNComposer::setConfig(bool onlyFonts)
486 {
487  if (!onlyFonts) {
488  a_ctWordWrap->setChecked( knGlobals.settings()->wordWrap() );
489  slotToggleWordWrap();
490 
491  a_ctAutoSpellChecking->setChecked( knGlobals.settings()->autoSpellChecking() );
492  Kpgp::Module *pgp = Kpgp::Module::getKpgp();
493  a_ctPGPsign->setEnabled(pgp->usePGP());
494  }
495 
496  v_iew->setComposingFont( knGlobals.settings()->composerFont() );
497 
498  slotUpdateStatusBar();
499 }
500 
501 
502 void KNComposer::setMessageMode(MessageMode mode)
503 {
504  m_ode = mode;
505  a_ctDoPost->setChecked(m_ode!=mail);
506  a_ctDoMail->setChecked(m_ode!=news);
507  v_iew->setMessageMode(m_ode);
508  //Laurent fixme
509 #if 0
510  QString s = v_iew->editor()->document ()->begin().text ();
511  if (m_ode == news_mail) {
512  if (!s.contains(i18n("<posted & mailed>"))) {
513  QTextCursor cursor(v_iew->editor()->document ()->begin());
514  cursor.setPosition(0);
515  cursor.insertText(i18n("<posted & mailed>\n\n"));
516  v_iew->editor()->setTextCursor(cursor);
517  }
518  } else {
519  if (s == i18n("<posted & mailed>")) {
520  v_iew->editor()->removeLine(0);
521  if (v_iew->editor()->textLine(0).isEmpty())
522  v_iew->editor()->removeLine(0);
523  }
524  }
525 #endif
526  slotUpdateStatusBar();
527 }
528 
529 
530 bool KNComposer::hasValidData()
531 {
532  v_alidated=false;
533  n_eeds8Bit=false;
534 
535  // header checks
536  if ( KPIMUtils::isValidAddress( v_iew->from() ) != KPIMUtils::AddressOk ) {
537  KMessageBox::sorry( this, i18n( "Your email address does not appears to be valid. Please modify it." ) );
538  return false;
539  }
540 
541  if ( v_iew->subject().isEmpty() ) {
542  KMessageBox::sorry(this, i18n("Please enter a subject."));
543  return false;
544  }
545  if ( !n_eeds8Bit && !KMime::isUsAscii( v_iew->subject() ) ) {
546  n_eeds8Bit=true;
547  }
548 
549  if (m_ode != mail) {
550  int groupCount = v_iew->groups().count();
551  if ( groupCount == 0 ) {
552  KMessageBox::sorry(this, i18n("Please enter a newsgroup."));
553  return false;
554  }
555 
556  if (groupCount>12) {
557  KMessageBox::sorry(this, i18n("You are crossposting to more than 12 newsgroups.\nPlease remove all newsgroups in which your article is off-topic."));
558  return false;
559  }
560 
561  if (groupCount>5)
562  if ( KMessageBox::warningYesNo( this, i18n("You are crossposting to more than five newsgroups.\nPlease reconsider whether this is really useful\nand remove groups in which your article is off-topic.\nDo you want to re-edit the article or send it anyway?"),
563  QString(), KGuiItem(i18n("&Send")), KGuiItem(i18nc("edit article","&Edit")) ) != KMessageBox::Yes )
564  return false;
565 
566  int fupCount = v_iew->followupTo().count();
567  if ( fupCount == 0 && groupCount > 2 ) {
568  if ( KMessageBox::warningYesNo( this,
569  i18n("You are crossposting to more than two newsgroups.\n"
570  "Please use the \"Followup-To\" header to direct the replies "
571  "to your article into one group.\n"
572  "Do you want to re-edit the article or send it anyway?"),
573  QString(), KGuiItem(i18n("&Send")), KGuiItem(i18nc("edit article","&Edit")), "missingFollowUpTo" )
574  != KMessageBox::Yes )
575  return false;
576  }
577 
578  if (fupCount>12) {
579  KMessageBox::sorry(this, i18n("You are directing replies to more than 12 newsgroups.\nPlease remove some newsgroups from the \"Followup-To\" header."));
580  return false;
581  }
582 
583  if (fupCount>5)
584  if ( KMessageBox::warningYesNo( this, i18n("You are directing replies to more than five newsgroups.\nPlease reconsider whether this is really useful.\nDo you want to re-edit the article or send it anyway?"),
585  QString(), KGuiItem(i18n("&Send")),KGuiItem(i18nc("edit article","&Edit")) ) != KMessageBox::Yes )
586  return false;
587  }
588 
589  if (m_ode != news) {
590  if ( v_iew->emailRecipient().isEmpty() ) {
591  KMessageBox::sorry(this, i18n("Please enter the email address."));
592  return false;
593  }
594  if ( !n_eeds8Bit && !KMime::isUsAscii( v_iew->emailRecipient() ) ) {
595  n_eeds8Bit=true;
596  }
597  }
598 
599  //GNKSA body checks
600  bool firstLine = true;
601  bool empty = true;
602  bool longLine = false;
603  bool hasAttributionLine = false;
604  int sigLength = 0;
605  int notQuoted = 0;
606  int textLines = 0;
607  QStringList text = v_iew->editor()->toWrappedPlainText().split('\n');
608 
609  for (QStringList::Iterator it = text.begin(); it != text.end(); ++it) {
610 
611  if (!n_eeds8Bit && !KMime::isUsAscii(*it))
612  n_eeds8Bit=true;
613 
614  if (*it == "-- ") { // signature text
615  for (++it; it != text.end(); ++it) {
616 
617  if (!n_eeds8Bit && !KMime::isUsAscii(*it))
618  n_eeds8Bit=true;
619 
620  sigLength++;
621  if((*it).length()>80) {
622  longLine = true;
623  }
624  }
625  break;
626  }
627 
628  if(!(*it).isEmpty()) {
629  empty = false;
630  textLines++;
631  if ((*it)[0]!='>') {
632  notQuoted++;
633  if (firstLine) hasAttributionLine = true;
634  }
635  }
636  if((*it).length()>80) {
637  longLine = true;
638  }
639 
640  firstLine = false;
641  }
642 
643  if (n_eeds8Bit && ( mCharset.toLower()=="us-ascii" )) {
644  KMessageBox::sorry(this, i18n("Your message contains characters which are not included\nin the \"us-ascii\" character set; please choose\na suitable character set from the \"Options\" menu."));
645  return false;
646  }
647 
648  if (empty) {
649  KMessageBox::sorry(this, i18n("You cannot post an empty message."));
650  return false;
651  }
652 
653  if ((textLines>1)&&(notQuoted==1)) {
654  if (hasAttributionLine)
655  if ( KMessageBox::warningYesNo( this, i18n("Your article seems to consist entirely of quoted text;\ndo you want to re-edit the article or send it anyway?"),
656  QString(), KGuiItem(i18n("&Send")), KGuiItem(i18nc("edit article","&Edit")) ) != KMessageBox::Yes )
657  return false;
658  } else {
659  if (notQuoted==0) {
660  KMessageBox::sorry(this, i18n("You cannot post an article consisting\n"
661  "entirely of quoted text."));
662  return false;
663  }
664  }
665 
666  if (longLine)
667  if ( KMessageBox::warningYesNo( this,
668  i18n("Your article contains lines longer than 80 characters.\n"
669  "Do you want to re-edit the article or send it anyway?"),
670  QString(), KGuiItem(i18n("&Send")),
671  KGuiItem(i18nc("edit article","&Edit")) ) != KMessageBox::Yes )
672  return false;
673 
674  if (sigLength>8) {
675  if ( KMessageBox::warningYesNo( this, i18n("Your signature is more than 8 lines long.\nYou should shorten it to match the widely accepted limit of 4 lines.\nDo you want to re-edit the article or send it anyway?"),
676  QString(), KGuiItem(i18n("&Send")), KGuiItem(i18nc("edit article","&Edit")) ) != KMessageBox::Yes )
677  return false;
678  } else
679  if (sigLength>4)
680  KMessageBox::information( this, i18n("Your signature exceeds the widely-accepted limit of 4 lines:\nplease consider shortening your signature;\notherwise, you will probably annoy your readers."),
681  QString(), "longSignatureWarning" );
682 
683  // check if article can be signed
684  if ( a_ctPGPsign->isChecked() ) {
685  // try to get the signing key
686  QByteArray signingKey = KNGlobals::self()->settings()->identity().pgpSigningKey();
687  KNNntpAccount::Ptr acc = knGlobals.accountManager()->account( a_rticle->serverId() );
688  if ( acc ) {
689  KMime::Headers::Newsgroups *grps = a_rticle->newsgroups();
690  if ( !grps->isEmpty() ) {
691  KNGroup::Ptr grp = knGlobals.groupManager()->group( grps->groups().first(), acc );
692  if ( grp && !grp->identity().isNull() ) {
693  signingKey = grp->identity().pgpSigningKey();
694  } else if ( !acc->identity().isNull() ) {
695  signingKey = acc->identity().pgpSigningKey();
696  }
697  }
698  }
699 
700  // the article can only be signed if we have a key
701  if (signingKey.isEmpty()) {
702  if ( KMessageBox::warningContinueCancel( this,
703  i18n("You have not configured your preferred "
704  "signing key yet;\n"
705  "please specify it in the global "
706  "identity configuration,\n"
707  "in the account properties or in the "
708  "group properties.\n"
709  "The article will be sent unsigned." ),
710  QString(), KGuiItem(i18n( "Send Unsigned" )),
711  KStandardGuiItem::cancel(), "sendUnsignedDialog" )
712  == KMessageBox::Cancel )
713  return false;
714  }
715  }
716 
717  v_alidated=true;
718  return true;
719 }
720 
721 
722 bool KNComposer::applyChanges()
723 {
724  KMime::Content *text=0;
725  bool result = true; // no error occurs ?
726 
727 
728  // Identity (for later edition)
729  const KPIMIdentities::Identity identity = KNGlobals::self()->identityManager()->identityForUoid( v_iew->selectedIdentity() );
730  if ( !identity.isNull() ) {
731  KMime::Headers::Generic *xKnodeIdentity = new KMime::Headers::Generic( "X-KNode-Identity",
732  a_rticle.get(),
733  QByteArray::number( identity.uoid() ) );
734  a_rticle->setHeader( xKnodeIdentity );
735  }
736 
737  //From
738  if ( KPIMUtils::isValidAddress( v_iew->from() ) != KPIMUtils::AddressOk ) {
739  result = false;
740  }
741  // FIXME: if v_iew->from() is not valid, the following call is a
742  // no-op: the content of the from keeps its previous value! (thanks KMime)
743  a_rticle->from()->fromUnicodeString( v_iew->from(), mCharset.toLatin1() );
744 
745  //Reply-To
746  if ( KPIMUtils::isValidAddress( identity.replyToAddr() ) == KPIMUtils::AddressOk ) {
747  a_rticle->replyTo()->fromUnicodeString( identity.replyToAddr(), mCharset.toLatin1() );
748  } else {
749  a_rticle->removeHeader( "Reply-To" );
750  }
751 
752  //Mail-Copies-To
753  if ( !identity.property( "Mail-Copies-To" ).toString().trimmed().isEmpty() ) {
754  a_rticle->mailCopiesTo()->fromUnicodeString( identity.property( "Mail-Copies-To" ).toString(), mCharset.toLatin1() );
755  } else {
756  a_rticle->removeHeader( "Mail-Copies-To" );
757  }
758 
759  //Organization
760  if ( !identity.organization().trimmed().isEmpty() ) {
761  a_rticle->organization()->fromUnicodeString( identity.organization(), mCharset.toLatin1() );
762  } else {
763  a_rticle->removeHeader( "Organization" );
764  }
765 
766  //Date
767  a_rticle->date()->setDateTime( KDateTime::currentLocalDateTime() ); //set current date+time
768 
769  //Subject
770  a_rticle->subject()->fromUnicodeString( v_iew->subject(), mCharset.toLatin1() );
771 
772  //Newsgroups
773  if (m_ode != mail) {
774  a_rticle->newsgroups()->fromUnicodeString( v_iew->groups().join( QString( ',' ) ), KMime::Headers::Latin1 );
775  a_rticle->setDoPost(true);
776  } else {
777  a_rticle->setDoPost(false);
778  a_rticle->removeHeader( "Newsgroups" );
779  }
780 
781  //To
782  if (m_ode != news) {
783  a_rticle->to()->fromUnicodeString( v_iew->emailRecipient(), mCharset.toLatin1() );
784  a_rticle->setDoMail(true);
785  } else {
786  a_rticle->setDoMail(false);
787  a_rticle->removeHeader( "To" );
788  a_rticle->removeHeader( "Cc" );
789  }
790 
791  //Followup-To
792  if ( a_rticle->doPost() && !v_iew->followupTo().isEmpty() ) {
793  a_rticle->followUpTo()->fromUnicodeString( v_iew->followupTo().join( QString( ',' ) ), KMime::Headers::Latin1 );
794  } else {
795  a_rticle->removeHeader("Followup-To");
796  }
797 
798 
799  // Attachments
800  if ( a_ttChanged ) {
801  const QList<KNAttachment::Ptr> l = v_iew->attachments();
802  foreach ( const KNAttachment::Ptr a, l ) {
803  if(a->hasChanged()) {
804  if(a->isAttached())
805  a->updateContentInfo();
806  else
807  a->attach( a_rticle.get() );
808  }
809  }
810  }
811 
812  for ( QList<KNAttachment::Ptr>::Iterator it = mDeletedAttachments.begin(); it != mDeletedAttachments.end(); ++it )
813  if ( (*it)->isAttached() )
814  (*it)->detach( a_rticle.get() );
815 
816  text=a_rticle->textContent();
817 
818  if(!text) {
819  text=new KMime::Content();
820  KMime::Headers::ContentType *type=text->contentType();
821  KMime::Headers::ContentTransferEncoding *enc=text->contentTransferEncoding();
822  type->setMimeType("text/plain");
823  enc->setDecoded(true);
824  text->assemble();
825  a_rticle->addContent(text, true);
826  }
827 
828  //set text
829  if (v_alidated) {
830  if (n_eeds8Bit) {
831  text->contentType()->setCharset( mCharset.toLatin1() );
832  if ( knGlobals.settings()->allow8BitBody() )
833  text->contentTransferEncoding()->setEncoding(KMime::Headers::CE8Bit);
834  else
835  text->contentTransferEncoding()->setEncoding(KMime::Headers::CEquPr);
836  } else {
837  setCharset( "us-ascii" ); // fall back to us-ascii
838  text->contentType()->setCharset( mCharset.toLatin1() );
839  text->contentTransferEncoding()->setEncoding(KMime::Headers::CE7Bit);
840  }
841  } else { // save as draft
842  text->contentType()->setCharset( mCharset.toLatin1() );
843  if ( mCharset.toLower()=="us-ascii" ) {
844  text->contentTransferEncoding()->setEncoding(KMime::Headers::CE7Bit);
845  } else {
846  text->contentTransferEncoding()->setEncoding( knGlobals.settings()->allow8BitBody()
847  ? KMime::Headers::CE8Bit : KMime::Headers::CEquPr );
848  }
849  }
850 
851  QString tmp = v_iew->editor()->toWrappedPlainText();
852 
853  // Sign article if needed
854  if ( a_ctPGPsign->isChecked() ) {
855  QByteArray signingKey = identity.pgpSigningKey();
856  if (!signingKey.isEmpty()) {
857  QString tmpText = tmp;
858  Kpgp::Block block;
859  bool ok=true;
860  QTextCodec *codec=KGlobal::charsets()->codecForName( mCharset, ok);
861  if(!ok) // no suitable codec found => try local settings and hope the best ;-)
862  codec=KGlobal::locale()->codecForEncoding();
863 
864  block.setText( codec->fromUnicode(tmpText) );
865  kDebug(5003) <<"signing article from" << article()->from()->addresses();
866  if( block.clearsign( signingKey, codec->name() ) == Kpgp::Ok ) {
867  QByteArray result = block.text();
868  tmp = codec->toUnicode(result.data(), result.length() );
869  } else {
870  result = false;
871  }
872  }
873  }
874 
875  text->fromUnicodeString(tmp);
876 
877  //text is set and all attached contents have been assembled => now set lines
878  a_rticle->lines()->setNumberOfLines(a_rticle->lineCount());
879 
880  a_rticle->assemble();
881  a_rticle->updateListItem();
882 
883  return result;
884 }
885 
886 void KNComposer::setCharset( const QString &charset )
887 {
888  mCharset = Locale::toMimeCharset( charset );
889  slotUpdateStatusBar();
890 }
891 
892 
893 void KNComposer::closeEvent(QCloseEvent *e)
894 {
895  if(!v_iew->editor()->document()->isModified() && !a_ttChanged) { // nothing to save, don't show nag screen
896  if(a_rticle->id()==-1)
897  r_esult=CRdel;
898  else
899  r_esult=CRcancel;
900  }
901  else {
902  switch ( KMessageBox::warningYesNoCancel( this, i18n("Do you want to save this article in the draft folder?"),
903  QString(), KStandardGuiItem::save(), KStandardGuiItem::discard() ) ) {
904  case KMessageBox::Yes :
905  r_esult=CRsave;
906  break;
907  case KMessageBox::No :
908  if (a_rticle->id()==-1) r_esult=CRdel;
909  else r_esult=CRcancel;
910  break;
911  default: // cancel
912  e->ignore();
913  return;
914  }
915  }
916 
917  e->accept();
918  emit composerDone(this);
919  // we're dead at this point, don't access members!
920 }
921 
922 
923 void KNComposer::initData(const QString &text)
924 {
925  // Identity
926  KPIMIdentities::IdentityManager *idManager = KNGlobals::self()->identityManager();
927  KPIMIdentities::Identity identity = idManager->defaultIdentity();
928  KMime::Headers::Base* xKnodeIdentity = a_rticle->headerByType( "X-KNode-Identity" );
929  if ( xKnodeIdentity && !xKnodeIdentity->isEmpty() ) {
930  uint uoid = xKnodeIdentity->asUnicodeString().toUInt();
931  // Note: this ensure the identity exists even if it was removed
932  identity = idManager->identityForUoidOrDefault( uoid );
933  }
934  v_iew->setIdentity( identity.uoid() );
935 
936  //From
937  KMime::Headers::From *from = a_rticle->from( false );
938  if ( from ) {
939  v_iew->setFrom( from->asUnicodeString() );
940  } else {
941  v_iew->setFrom( identity.fullEmailAddr() );
942  }
943 
944  //Subject
945  if(a_rticle->subject()->isEmpty())
946  slotSubjectChanged( QString() );
947  else
948  v_iew->setSubject( a_rticle->subject()->asUnicodeString() );
949 
950  //Newsgroups
951  KMime::Headers::Newsgroups *hNewsgroup = a_rticle->newsgroups( false );
952  if ( hNewsgroup && !hNewsgroup->isEmpty() ) {
953  v_iew->setGroups( hNewsgroup->asUnicodeString() );
954  }
955 
956  //To
957  KMime::Headers::To *hTo = a_rticle->to( false );
958  if ( hTo && !hTo->isEmpty() ) {
959  v_iew->setEmailRecipient( hTo->asUnicodeString() );
960  }
961 
962  //Followup-To
963  KMime::Headers::FollowUpTo *fup2=a_rticle->followUpTo(false);
964  if( fup2 && !fup2->isEmpty() ) {
965  v_iew->setFollowupTo( fup2->asUnicodeString() );
966  }
967 
968  KMime::Content *textContent=a_rticle->textContent();
969  QString s;
970 
971  if(text.isEmpty()) {
972  if(textContent)
973  s = textContent->decodedText();
974  } else
975  s = text;
976 
977  v_iew->editor()->setText(s);
978 
979  // initialize the charset select action
980  if(textContent) {
981  setCharset( textContent->contentType()->charset() );
982  } else {
983  setCharset( knGlobals.settings()->charset() );
984  }
985 
986  QString charsetDesc = KGlobal::charsets()->descriptionForEncoding( mCharset );
987  a_ctSetCharset->setCurrentItem( a_ctSetCharset->items().indexOf( charsetDesc ) );
988 
989  // initialize the message type select action
990  if (a_rticle->doPost() && a_rticle->doMail())
991  m_ode = news_mail;
992  else
993  if (a_rticle->doPost())
994  m_ode = news;
995  else
996  m_ode = mail;
997  setMessageMode(m_ode);
998 
999  if(a_rticle->contentType()->isMultipart()) {
1000  v_iew->showAttachmentView();
1001  const KMime::Content::List attList = a_rticle->attachments();
1002  foreach ( KMime::Content *c, attList ) {
1003  v_iew->addAttachment( KNAttachment::Ptr( new KNAttachment( c ) ) );
1004  }
1005  }
1006 }
1007 
1008 // inserts at cursor position if clear is false, replaces content otherwise
1009 // puts the file content into a box if box==true
1010 // "file" is already open for reading
1011 void KNComposer::insertFile( QFile *file, bool clear, bool box, const QString &boxTitle )
1012 {
1013  QString temp;
1014  bool ok=true;
1015  QTextCodec *codec=KGlobal::charsets()->codecForName( mCharset, ok);
1016  QTextStream ts(file);
1017  ts.setCodec(codec);
1018 
1019  if (box)
1020  temp = QString::fromLatin1(",----[ %1 ]\n").arg(boxTitle);
1021  //Laurent fixme
1022  if (box && (v_iew->editor()->wordWrapMode()!=QTextOption::NoWrap)) {
1023  int wrapAt = v_iew->editor()->lineWrapColumnOrWidth();
1024  QStringList lst;
1025  QString line;
1026  while(!ts.atEnd()) {
1027  line=ts.readLine();
1028  if (!ts.atEnd())
1029  line+='\n';
1030  lst.append(line);
1031  }
1032  temp+=KNHelper::rewrapStringList(lst, wrapAt, '|', false, true);
1033  } else {
1034  while(!ts.atEnd()) {
1035  if (box)
1036  temp+="| ";
1037  temp+=ts.readLine();
1038  if (!ts.atEnd())
1039  temp += '\n';
1040  }
1041  }
1042  if (box)
1043  temp += QString::fromLatin1("`----");
1044 
1045  if(clear)
1046  v_iew->editor()->setText(temp);
1047  else
1048  v_iew->editor()->insertPlainText(temp);
1049 }
1050 
1051 
1052 // ask for a filename, handle network urls
1053 void KNComposer::insertFile(bool clear, bool box)
1054 {
1055  KNLoadHelper helper(this);
1056  QFile *file = helper.getFile(i18n("Insert File"));
1057  KUrl url;
1058  QString boxName;
1059 
1060  if (file) {
1061  url = helper.getURL();
1062 
1063  if (url.isLocalFile())
1064  boxName = url.toLocalFile();
1065  else
1066  boxName = url.prettyUrl();
1067 
1068  insertFile(file,clear,box,boxName);
1069  }
1070 }
1071 
1072 
1073 //-------------------------------- <Actions> ------------------------------------
1074 
1075 
1076 void KNComposer::addRecentAddress()
1077 {
1078  if ( m_ode == mail || m_ode == news_mail ) {
1079  RecentAddresses::self( knGlobals.config() )->add( v_iew->emailRecipient() );
1080  }
1081 }
1082 
1083 void KNComposer::slotSendNow()
1084 {
1085  r_esult=CRsendNow;
1086  addRecentAddress();
1087  emit composerDone(this);
1088 }
1089 
1090 
1091 void KNComposer::slotSendLater()
1092 {
1093  r_esult=CRsendLater;
1094  addRecentAddress();
1095  emit composerDone(this);
1096 }
1097 
1098 
1099 void KNComposer::slotSaveAsDraft()
1100 {
1101  r_esult=CRsave;
1102  addRecentAddress();
1103  emit composerDone(this);
1104 }
1105 
1106 
1107 void KNComposer::slotArtDelete()
1108 {
1109  r_esult=CRdelAsk;
1110  emit composerDone(this);
1111 }
1112 
1113 
1114 void KNComposer::slotInsertFile()
1115 {
1116  insertFile(false,false);
1117 }
1118 
1119 
1120 void KNComposer::slotInsertFileBoxed()
1121 {
1122  insertFile(false,true);
1123 }
1124 
1125 void KNComposer::slotAttachFile()
1126 {
1127  KNLoadHelper *helper = new KNLoadHelper(this);
1128 
1129  if (helper->getFile(i18n("Attach File"))) {
1130  if ( !v_iew->isAttachmentViewVisible() ) {
1131  KNHelper::saveWindowSize("composer", size());
1132  v_iew->showAttachmentView();
1133  }
1134  v_iew->addAttachment( KNAttachment::Ptr( new KNAttachment( helper ) ) );
1135  a_ttChanged=true;
1136  } else {
1137  delete helper;
1138  }
1139 }
1140 
1141 
1142 void KNComposer::slotAttachmentRemoved( KNAttachment::Ptr attachment, bool last )
1143 {
1144  if( !attachment ) {
1145  return;
1146  }
1147 
1148  if ( attachment->isAttached() ) {
1149  mDeletedAttachments.append( attachment );
1150  }
1151 
1152  if ( last ) {
1153  KNHelper::saveWindowSize( "composerAtt", size() );
1154  v_iew->hideAttachmentView();
1155  }
1156 
1157  a_ttChanged = true;
1158 }
1159 
1160 void KNComposer::slotAttachmentChanged()
1161 {
1162  a_ttChanged = true;
1163 }
1164 
1165 
1166 
1167 void KNComposer::slotToggleDoPost()
1168 {
1169  if (a_ctDoPost->isChecked()) {
1170  if (a_ctDoMail->isChecked())
1171  m_ode=news_mail;
1172  else
1173  m_ode=news;
1174  } else {
1175  if (a_ctDoMail->isChecked())
1176  m_ode=mail;
1177  else { // invalid
1178  a_ctDoPost->setChecked(true); //revert
1179  return;
1180  }
1181  }
1182  setMessageMode(m_ode);
1183 }
1184 
1185 
1186 void KNComposer::slotToggleDoMail()
1187 {
1188  if (a_ctDoMail->isChecked()) {
1189  if (a_uthorDislikesMailCopies) {
1190  if ( KMessageBox::warningContinueCancel( this, i18n("The poster does not want a mail copy of your reply (Mail-Copies-To: nobody);\nplease respect their request."),
1191  QString(), KGuiItem(i18n("&Send Copy")) ) != KMessageBox::Continue ) {
1192  a_ctDoMail->setChecked(false); //revert
1193  return;
1194  }
1195  }
1196  }
1197 //Laurent fix me
1198 #if 0
1199  if ( knGlobals.settings()->useExternalMailer() ) {
1200  QString s = v_iew->editor()->textLine(0);
1201  if (!s.contains(i18n("<posted & mailed>")))
1202  v_iew->editor()->insertAt(i18n("<posted & mailed>\n\n"),0,0);
1203  QString tmp;
1204  QStringList textLines = v_iew->editor()->processedText();
1205  for (QStringList::Iterator it = textLines.begin(); it != textLines.end(); ++it) {
1206  if (*it == "-- ") // try to be smart, don't include the signature,
1207  break; // kmail will append one, too.
1208  tmp+=*it+'\n';
1209  }
1210  knGlobals.artFactory->sendMailExternal( v_iew->t_o->text(), v_iew->subject(), tmp );
1211  a_ctDoMail->setChecked(false); //revert
1212  return;
1213  } else {
1214 #endif
1215  if (a_ctDoMail->isChecked()) {
1216  if (a_ctDoPost->isChecked())
1217  m_ode=news_mail;
1218  else
1219  m_ode=mail;
1220  } else {
1221  if (a_ctDoPost->isChecked())
1222  m_ode=news;
1223  else { // invalid
1224  a_ctDoMail->setChecked(true); //revert
1225  return;
1226  }
1227  }
1228  setMessageMode(m_ode);
1229 }
1230 
1231 
1232 void KNComposer::slotSetCharset(const QString &s)
1233 {
1234  if(s.isEmpty())
1235  return;
1236 
1237  QString charset = KGlobal::charsets()->encodingForName( s );
1238  setCharset( charset );
1239 }
1240 
1241 
1242 void KNComposer::slotSetCharsetKeyboard()
1243 {
1244  int newCS = KNHelper::selectDialog(this, i18n("Select Charset"), a_ctSetCharset->items(), a_ctSetCharset->currentItem());
1245  if (newCS != -1) {
1246  a_ctSetCharset->setCurrentItem(newCS);
1247  QString charset = KGlobal::charsets()->encodingForName( a_ctSetCharset->items()[ newCS ] );
1248  setCharset( charset );
1249  }
1250 }
1251 
1252 
1253 void KNComposer::slotToggleWordWrap()
1254 {
1255  if ( a_ctWordWrap->isChecked() )
1256  v_iew->editor()->enableWordWrap( knGlobals.settings()->maxLineLength() );
1257  else
1258  v_iew->editor()->disableWordWrap();
1259 }
1260 
1261 void KNComposer::slotAutoSpellCheckingToggled()
1262 {
1263  v_iew->editor()->setCheckSpellingEnabled( a_ctAutoSpellChecking->isChecked() );
1264 }
1265 
1266 
1267 void KNComposer::slotUndoRewrap()
1268 {
1269  if (KMessageBox::warningContinueCancel( this, i18n("This will replace all text you have written.")) == KMessageBox::Continue) {
1270  v_iew->editor()->setText(u_nwraped);
1271  v_iew->appendSignature();
1272  }
1273 }
1274 
1275 void KNComposer::slotExternalEditor()
1276 {
1277  if(e_xternalEditor) // in progress...
1278  return;
1279 
1280  QString editorCommand = knGlobals.settings()->externalEditor();
1281 
1282  if(editorCommand.isEmpty())
1283  KMessageBox::sorry(this, i18n("No editor configured.\nPlease do this in the settings dialog."));
1284 
1285  delete e_ditorTempfile;
1286  e_ditorTempfile=new KTemporaryFile();
1287 
1288  if(!e_ditorTempfile->open()) {
1289  KNHelper::displayTempFileError(this);
1290  delete e_ditorTempfile;
1291  e_ditorTempfile=0;
1292  return;
1293  }
1294 
1295  bool ok=true;
1296  QTextCodec *codec=KGlobal::charsets()->codecForName( mCharset, ok );
1297 
1298  QString tmp = v_iew->editor()->toWrappedPlainText();
1299 
1300  QByteArray local = codec->fromUnicode(tmp);
1301  e_ditorTempfile->write(local.data(),local.length());
1302  e_ditorTempfile->flush();
1303 
1304  if(!e_ditorTempfile->open()) {
1305  KNHelper::displayTempFileError(this);
1306  delete e_ditorTempfile;
1307  e_ditorTempfile=0;
1308  return;
1309  }
1310 
1311  e_xternalEditor=new KProcess();
1312 
1313  // construct command line...
1314  QStringList command = editorCommand.split(' ', QString::SkipEmptyParts);
1315  bool filenameAdded=false;
1316  for ( QStringList::Iterator it = command.begin(); it != command.end(); ++it ) {
1317  if ((*it).contains("%f")) {
1318  (*it).replace(QRegExp("%f"),e_ditorTempfile->fileName());
1319  filenameAdded=true;
1320  }
1321  (*e_xternalEditor) << (*it);
1322  }
1323  if(!filenameAdded) // no %f in the editor command
1324  (*e_xternalEditor) << e_ditorTempfile->fileName();
1325 
1326  connect(e_xternalEditor, SIGNAL(finished(int,QProcess::ExitStatus)),this, SLOT(slotEditorFinished(int,QProcess::ExitStatus)));
1327  e_xternalEditor->start();
1328  if(!e_xternalEditor->waitForStarted()) {
1329  KMessageBox::error(this, i18n("Unable to start external editor.\nPlease check your configuration in the settings dialog."));
1330  delete e_xternalEditor;
1331  e_xternalEditor=0;
1332  delete e_ditorTempfile;
1333  e_ditorTempfile=0;
1334  return;
1335  }
1336 
1337  a_ctExternalEditor->setEnabled(false); // block other edit action while the editor is running...
1338  a_ctSpellCheck->setEnabled(false);
1339  v_iew->showExternalNotification();
1340 }
1341 
1342 void KNComposer::slotUpdateStatusBar()
1343 {
1344  QString typeDesc;
1345  switch (m_ode) {
1346  case news: typeDesc = i18n("News Article");
1347  break;
1348  case mail: typeDesc = i18n("Email");
1349  break;
1350  default : typeDesc = i18n("News Article & Email");
1351  }
1352  QString overwriteDesc;
1353  if (v_iew->editor()->overwriteMode ())
1354  overwriteDesc = i18n(" OVR ");
1355  else
1356  overwriteDesc = i18n(" INS ");
1357 
1358  statusBar()->changeItem(i18n(" Type: %1 ", typeDesc), 1);
1359  statusBar()->changeItem(i18n(" Charset: %1 ", mCharset ), 2);
1360  statusBar()->changeItem(overwriteDesc, 3);
1361  statusBar()->changeItem(i18n(" Column: %1 ", v_iew->editor()->columnNumber () + 1), 4);
1362  statusBar()->changeItem(i18n(" Line: %1 ", v_iew->editor()->linePosition() + 1), 5);
1363 }
1364 
1365 
1366 void KNComposer::slotUpdateCursorPos()
1367 {
1368  statusBar()->changeItem(i18n(" Column: %1 ", v_iew->editor()->columnNumber () + 1), 4);
1369  statusBar()->changeItem(i18n(" Line: %1 ", v_iew->editor()->linePosition() + 1), 5);
1370 }
1371 
1372 
1373 void KNComposer::slotConfKeys()
1374 {
1375  KShortcutsDialog::configure(actionCollection(), KShortcutsEditor::LetterShortcutsAllowed, this, true);
1376 }
1377 
1378 
1379 void KNComposer::slotConfToolbar()
1380 {
1381  saveMainWindowSettings(knGlobals.config()->group( "composerWindow_options") );
1382  KEditToolBar dlg(guiFactory(),this);
1383  connect(&dlg,SIGNAL(newToolBarConfig()), this, SLOT(slotNewToolbarConfig()));
1384  dlg.exec();
1385 }
1386 
1387 void KNComposer::slotNewToolbarConfig()
1388 {
1389  createGUI("kncomposerui.rc");
1390 
1391  applyMainWindowSettings(knGlobals.config()->group("composerWindow_options"));
1392 }
1393 
1394 //-------------------------------- </Actions> -----------------------------------
1395 
1396 
1397 void KNComposer::slotSubjectChanged(const QString &t)
1398 {
1399  // replace newlines
1400  QString subject = t;
1401  subject.replace( '\n', ' ' );
1402  subject.replace( '\r', ' ' );
1403  if ( subject != t ) // setText() sets the cursor to the end
1404  v_iew->setSubject( subject );
1405  // update caption
1406  if( !subject.isEmpty() )
1407  setCaption( subject );
1408  else
1409  setCaption( i18n("No Subject") );
1410 }
1411 
1412 
1413 void KNComposer::slotToBtnClicked()
1414 {
1415  Akonadi::EmailAddressSelectionDialog dlg( this );
1416  dlg.view()->view()->setSelectionMode( QAbstractItemView::MultiSelection );
1417 
1418  if ( !dlg.exec() )
1419  return;
1420 
1421  QStringList addresses;
1422  foreach ( const Akonadi::EmailAddressSelection &selection, dlg.selectedAddresses() )
1423  addresses << selection.quotedEmail();
1424 
1425  QString to = v_iew->emailRecipient();
1426  if ( !to.isEmpty() )
1427  to += ", ";
1428  to += addresses.join( ", " );
1429 
1430  v_iew->setEmailRecipient( to );
1431 }
1432 
1433 
1434 void KNComposer::slotGroupsBtnClicked()
1435 {
1436  int id=a_rticle->serverId();
1437  KNNntpAccount::Ptr nntp;
1438 
1439  if(id!=-1)
1440  nntp=knGlobals.accountManager()->account(id);
1441 
1442  if(!nntp)
1443  nntp=knGlobals.accountManager()->first();
1444 
1445  if(!nntp) {
1446  KMessageBox::error(this, i18n("You have no valid news accounts configured."));
1447  v_iew->setGroups( QString() );
1448  return;
1449  }
1450 
1451  if(id==-1)
1452  a_rticle->setServerId(nntp->id());
1453 
1454  KNGroupSelectDialog *dlg = new KNGroupSelectDialog( this, nntp, v_iew->groups() );
1455 
1456  connect( dlg, SIGNAL(loadList(KNNntpAccount::Ptr)),
1457  knGlobals.groupManager(), SLOT(slotLoadGroupList(KNNntpAccount::Ptr)) );
1458  connect( KNGlobals::self()->groupManager(), SIGNAL(newListReady(KNGroupListData::Ptr)),
1459  dlg, SLOT(slotReceiveList(KNGroupListData::Ptr)) );
1460 
1461  if(dlg->exec())
1462  v_iew->setGroups( dlg->selectedGroups() );
1463 
1464  delete dlg;
1465 }
1466 
1467 void KNComposer::slotEditorFinished(int, QProcess::ExitStatus exitStatus)
1468 {
1469  if(exitStatus == QProcess::NormalExit) {
1470  e_ditorTempfile->flush();
1471  e_ditorTempfile->seek(0);
1472  insertFile(e_ditorTempfile, true);
1473  e_xternalEdited=true;
1474  }
1475 
1476  slotCancelEditor(); // cleanup...
1477 }
1478 
1479 
1480 void KNComposer::slotCancelEditor()
1481 {
1482  if (e_xternalEditor)
1483  e_xternalEditor->deleteLater(); // this also kills the editor process if it's still running
1484  e_xternalEditor=0;
1485  delete e_ditorTempfile;
1486  e_ditorTempfile=0;
1487 
1488  a_ctExternalEditor->setEnabled(true);
1489  a_ctSpellCheck->setEnabled(true);
1490  v_iew->hideExternalNotification();
1491 }
1492 
1493 
1494 void KNComposer::slotAttachmentPopup( const QPoint &point )
1495 {
1496  QMenu *menu = static_cast<QMenu*>( factory()->container( "attachment_popup", this ) );
1497  if ( menu ) {
1498  menu->popup( point );
1499  }
1500 }
1501 
1502 void KNComposer::dragEnterEvent( QDragEnterEvent *event )
1503 {
1504  if ( KUrl::List::canDecode( event->mimeData() ) ) {
1505  event->setDropAction( Qt::CopyAction );
1506  event->accept();
1507  }
1508 }
1509 
1510 void KNComposer::dropEvent( QDropEvent *event )
1511 {
1512  KUrl::List urls = KUrl::List::fromMimeData( event->mimeData() );
1513 
1514  foreach ( const KUrl &url, urls ) {
1515  KNLoadHelper *helper = new KNLoadHelper(this);
1516 
1517  if (helper->setURL(url)) {
1518  if ( !v_iew->isAttachmentViewVisible() ) {
1519  KNHelper::saveWindowSize("composer", size());
1520  v_iew->showAttachmentView();
1521  }
1522  v_iew->addAttachment( KNAttachment::Ptr( new KNAttachment( helper ) ) );
1523  a_ttChanged=true;
1524  } else {
1525  delete helper;
1526  }
1527  }
1528 }
1529 
1530 
1531 //=====================================================================================
1532 
1533 
1534 KNComposer::AttachmentPropertiesDlg::AttachmentPropertiesDlg( KNAttachment::Ptr a, QWidget *parent ) :
1535  KDialog( parent ), a_ttachment(a),
1536  n_onTextAsText(false)
1537 {
1538  //init GUI
1539  setCaption( i18n("Attachment Properties") );
1540  setButtons( Help | Ok | Cancel );
1541  QWidget *page=new QWidget(this);
1542  setMainWidget(page);
1543  QVBoxLayout *topL=new QVBoxLayout(page);
1544 
1545  //file info
1546  QGroupBox *fileGB = new QGroupBox( i18n("File"), page );
1547  QGridLayout *fileL=new QGridLayout(fileGB);
1548  fileL->setSpacing(5);
1549  fileL->setMargin(15);
1550 
1551  fileL->addItem( new QSpacerItem( 0, fontMetrics().lineSpacing()-9), 0, 0 );
1552  fileL->addWidget(new QLabel(i18n("Name:"), fileGB) ,1,0);
1553  fileL->addWidget(new QLabel(QString("<b>%1</b>").arg(a->name()), fileGB), 1,1, Qt::AlignLeft);
1554  fileL->addWidget(new QLabel(i18n("Size:"), fileGB), 2,0);
1555  fileL->addWidget(new QLabel(a->contentSize(), fileGB), 2,1, Qt::AlignLeft);
1556 
1557  fileL->setColumnStretch(1,1);
1558  topL->addWidget(fileGB);
1559 
1560  //mime info
1561  QGroupBox *mimeGB = new QGroupBox( i18n("Mime"), page );
1562  QGridLayout *mimeL=new QGridLayout(mimeGB);
1563  mimeL->setSpacing(5);
1564  mimeL->setMargin(15);
1565 
1566  mimeL->addItem( new QSpacerItem( 0, fontMetrics().lineSpacing()-9), 0, 0 );
1567  m_imeType=new KLineEdit(mimeGB);
1568  m_imeType->setText(a->mimeType());
1569  mimeL->addWidget(m_imeType, 1,1);
1570  QLabel *label = new QLabel(i18n("&Mime-Type:"), mimeGB);
1571  label->setBuddy(m_imeType);
1572  mimeL->addWidget(label, 1,0);
1573 
1574  d_escription=new KLineEdit(mimeGB);
1575  d_escription->setText(a->description());
1576  mimeL->addWidget(d_escription, 2,1);
1577  label=new QLabel(i18n("&Description:"), mimeGB);
1578  label->setBuddy(d_escription);
1579  mimeL->addWidget(label, 2,0);
1580 
1581  e_ncoding=new QComboBox(mimeGB);
1582  e_ncoding->setEditable(false);
1583  e_ncoding->addItem("7Bit");
1584  e_ncoding->addItem("8Bit");
1585  e_ncoding->addItem("quoted-printable");
1586  e_ncoding->addItem("base64");
1587  if(a->isFixedBase64()) {
1588  e_ncoding->setCurrentIndex(3);
1589  e_ncoding->setEnabled(false);
1590  }
1591  else
1592  e_ncoding->setCurrentIndex(a->cte());
1593  mimeL->addWidget(e_ncoding, 3,1);
1594  label=new QLabel(i18n("&Encoding:"), mimeGB);
1595  label->setBuddy(e_ncoding);
1596  mimeL->addWidget(label, 3,0);
1597 
1598  mimeL->setColumnStretch(1,1);
1599  topL->addWidget(mimeGB);
1600 
1601  //connections
1602  connect(m_imeType, SIGNAL(textChanged(QString)),
1603  this, SLOT(slotMimeTypeTextChanged(QString)));
1604 
1605  //finish GUI
1606  setFixedHeight(sizeHint().height());
1607  KNHelper::restoreWindowSize("attProperties", this, QSize(300,250));
1608  setHelp("anc-knode-editor-advanced");
1609 }
1610 
1611 
1612 KNComposer::AttachmentPropertiesDlg::~AttachmentPropertiesDlg()
1613 {
1614  KNHelper::saveWindowSize("attProperties", this->size());
1615 }
1616 
1617 
1618 void KNComposer::AttachmentPropertiesDlg::apply()
1619 {
1620  a_ttachment->setDescription(d_escription->text());
1621  a_ttachment->setMimeType(m_imeType->text());
1622  a_ttachment->setCte(e_ncoding->currentIndex());
1623 }
1624 
1625 
1626 void KNComposer::AttachmentPropertiesDlg::accept()
1627 {
1628  if ( m_imeType->text().indexOf('/') == -1 ) {
1629  KMessageBox::sorry(this, i18n("You have set an invalid mime-type.\nPlease change it."));
1630  return;
1631  }
1632  else if ( n_onTextAsText && m_imeType->text().indexOf( "text/", 0, Qt::CaseInsensitive ) != -1 &&
1633  KMessageBox::warningContinueCancel(this,
1634  i18n("You have changed the mime-type of this non-textual attachment\nto text. This might cause an error while loading or encoding the file.\nProceed?")
1635  ) == KMessageBox::Cancel) return;
1636 
1637  // update the attachment
1638  apply();
1639 
1640  KDialog::accept();
1641 }
1642 
1643 
1644 void KNComposer::AttachmentPropertiesDlg::slotMimeTypeTextChanged(const QString &text)
1645 {
1646  enableButtonOk( !text.isEmpty() );
1647  if(text.left(5)!="text/") {
1648  n_onTextAsText=a_ttachment->isFixedBase64();
1649  e_ncoding->setCurrentIndex(3);
1650  e_ncoding->setEnabled(false);
1651  }
1652  else {
1653  e_ncoding->setCurrentIndex(a_ttachment->cte());
1654  e_ncoding->setEnabled(true);
1655  }
1656 }
1657 
1658 
1659 //--------------------------------
1660 
1661 
1662 // kate: space-indent on; indent-width 2;
KNode::Composer::View::emailRecipient
const QString emailRecipient() const
Returns the email recipient of this message (as type by the user in the To: field).
Definition: kncomposerview.cpp:273
KNode::Composer::View::focusNextPrevEdit
void focusNextPrevEdit(const QWidget *aCur, bool aNext)
Gives the focus to the next/previous edition widget (group, to, subject, body, etc.)
Definition: kncomposerview.cpp:151
QSpacerItem
QTextStream::setCodec
void setCodec(QTextCodec *codec)
KNComposer::result
composerResult result() const
Definition: kncomposer.h:76
QAction::setText
void setText(const QString &text)
KNComposer::a_ctExternalEditor
QAction * a_ctExternalEditor
Definition: kncomposer.h:135
KNLineEditSpell::spellCheckerCorrected
void spellCheckerCorrected(const QString &old, const QString &corr, unsigned int pos)
Definition: kncomposer.cpp:152
QTextCodec::fromUnicode
QByteArray fromUnicode(const QString &str) const
KNode::Composer::View::isAttachmentViewVisible
bool isAttachmentViewVisible() const
Indicates whether the attachment view is visible or not.
Definition: kncomposerview.h:92
KNLineEdit::contextMenuEvent
virtual void contextMenuEvent(QContextMenuEvent *e)
Definition: kncomposer.cpp:71
QWidget
KNComposer::setConfig
void setConfig(bool onlyFonts)
Definition: kncomposer.cpp:485
KNode::Composer::View::from
const QString from()
Returns the sender full name and email address to use in a From: header of a message.
Definition: kncomposerview.cpp:224
KNode::Composer::View::setIdentity
void setIdentity(uint uoid)
Changes the selected identity and update related edit lines.
Definition: kncomposerview.cpp:206
KNLocalArticle::Ptr
boost::shared_ptr< KNLocalArticle > Ptr
Shared pointer to a KNLocalArticle. To be used instead of raw KNLocalArticle*.
Definition: knarticle.h:216
QTextCursor
KNComposer::slotConfToolbar
void slotConfToolbar()
Definition: kncomposer.cpp:1379
KNComposer::AttachmentPropertiesDlg::~AttachmentPropertiesDlg
~AttachmentPropertiesDlg()
Destructor.
Definition: kncomposer.cpp:1612
QDropEvent::mimeData
const QMimeData * mimeData() const
KNode::Composer::View::appendSignature
void appendSignature()
Appends the signature to the editor.
Definition: kncomposerview.cpp:345
QTextCodec::name
virtual QByteArray name() const =0
KNHelper::saveWindowSize
static void saveWindowSize(const QString &name, const QSize &s)
Definition: utilities.cpp:205
KNode::Composer::View
Message composer view.
Definition: kncomposerview.h:33
KNComposer::initData
Q_SCRIPTABLE void initData(const QString &text)
Definition: kncomposer.cpp:923
KNComposer::a_ctSetCharset
KSelectAction * a_ctSetCharset
Definition: kncomposer.h:142
QTextStream::readLine
QString readLine(qint64 maxlen)
QGridLayout::addWidget
void addWidget(QWidget *widget, int row, int column, QFlags< Qt::AlignmentFlag > alignment)
QByteArray
utilities.h
KNComposer::AttachmentPropertiesDlg::apply
void apply()
Apply the change to the attachment passed to the constructor.
Definition: kncomposer.cpp:1618
text
virtual QByteArray text(quint32 serialNumber) const =0
QString::split
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
KNComposer::a_ctPGPsign
KToggleAction * a_ctPGPsign
Definition: kncomposer.h:140
KNGroupListData::Ptr
boost::shared_ptr< KNGroupListData > Ptr
Shared pointer to a KNGroupListData.
Definition: kngroupmanager.h:59
KNComposer::CRsave
Definition: kncomposer.h:48
QAction::setIcon
void setIcon(const QIcon &icon)
KNode::Composer::View::setEmailRecipient
void setEmailRecipient(const QString &to)
Sets the email recipient list as a string.
Definition: kncomposerview.cpp:278
QMenu::addAction
void addAction(QAction *action)
KNComposer::a_ctAutoSpellChecking
KToggleAction * a_ctAutoSpellChecking
Definition: kncomposer.h:140
QDBusConnection::registerObject
bool registerObject(const QString &path, QObject *object, QFlags< QDBusConnection::RegisterOption > options)
QByteArray::isEmpty
bool isEmpty() const
KNComposer::slotEditorFinished
void slotEditorFinished(int, QProcess::ExitStatus)
Definition: kncomposer.cpp:1467
KNHelper::restoreWindowSize
static void restoreWindowSize(const QString &name, QWidget *d, const QSize &defaultSize)
Definition: utilities.cpp:212
knaccountmanager.h
KNComposer::slotToggleDoMail
void slotToggleDoMail()
Definition: kncomposer.cpp:1186
KNComposer::CRdelAsk
Definition: kncomposer.h:47
KNComposer::slotAttachmentRemoved
void slotAttachmentRemoved(KNAttachment::Ptr attachment, bool last)
Called by the View when an attachment was removed.
Definition: kncomposer.cpp:1142
KNComposer::a_ctWordWrap
KToggleAction * a_ctWordWrap
Definition: kncomposer.h:140
QDBusConnection::sessionBus
QDBusConnection sessionBus()
KNComposer::slotSaveAsDraft
void slotSaveAsDraft()
Definition: kncomposer.cpp:1099
QGridLayout
KNGlobals::self
static KNGlobals * self()
Return the KNGlobals instance.
Definition: knglobals.cpp:72
KNComposer::slotToggleWordWrap
void slotToggleWordWrap()
Definition: kncomposer.cpp:1253
QPoint
KDialog
KNComposer::slotGroupsBtnClicked
void slotGroupsBtnClicked()
Definition: kncomposer.cpp:1434
KNComposer::slotUndoRewrap
void slotUndoRewrap()
Definition: kncomposer.cpp:1267
QStringList::join
QString join(const QString &separator) const
QByteArray::length
int length() const
KNComposer::slotAttachFile
void slotAttachFile()
Definition: kncomposer.cpp:1125
KNComposer::v_iew
View * v_iew
Definition: kncomposer.h:104
KNAttachment
KNAttachment represents a file that is or will be attached to an article.
Definition: knarticle.h:277
QComboBox::setEditable
void setEditable(bool editable)
from
QString from() const
QContextMenuEvent::globalPos
const QPoint & globalPos() const
KNode::Composer::View::setMessageMode
void setMessageMode(KNComposer::MessageMode mode)
Set the message mode to.
Definition: kncomposerview.cpp:192
KNNntpAccount::Ptr
boost::shared_ptr< KNNntpAccount > Ptr
Shared pointer to a KNNntpAccount.
Definition: knnntpaccount.h:62
QFile
KNLoadHelper
File open helper (includes file open dialog and network download).
Definition: utilities.h:55
QTextStream
QGridLayout::setSpacing
void setSpacing(int spacing)
KNComposer::r_esult
composerResult r_esult
Definition: kncomposer.h:110
QString::isNull
bool isNull() const
KNComposer::e_xternalEditor
KProcess * e_xternalEditor
Definition: kncomposer.h:126
knnntpaccount.h
KNLineEdit
Line edit for addresses used in the composer.
Definition: kncomposer.h:272
KNComposer::slotSetCharset
void slotSetCharset(const QString &s)
Definition: kncomposer.cpp:1232
KNode::Composer::View::hideExternalNotification
void hideExternalNotification()
Definition: kncomposerview.cpp:494
KNComposer::setCharset
void setCharset(const QString &charset)
Sets the character set to used to encode this message.
Definition: kncomposer.cpp:886
QComboBox::addItem
void addItem(const QString &text, const QVariant &userData)
QLabel::setBuddy
void setBuddy(QWidget *buddy)
KNComposer::hasValidData
bool hasValidData()
Definition: kncomposer.cpp:530
KNLineEdit::keyPressEvent
void keyPressEvent(QKeyEvent *e)
Definition: kncomposer.cpp:102
QCloseEvent
KNHelper::displayTempFileError
static void displayTempFileError(QWidget *w=0)
use this for error on temporary files
Definition: utilities.cpp:362
QRegExp
KNode::Composer::View::setFrom
void setFrom(const QString &from)
Set the name and email address of the sender of the message.
Definition: kncomposerview.cpp:229
KNComposer::AttachmentPropertiesDlg::slotMimeTypeTextChanged
void slotMimeTypeTextChanged(const QString &text)
Definition: kncomposer.cpp:1644
QWidget::setEnabled
void setEnabled(bool)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
KNLoadHelper::getURL
KUrl getURL() const
Definition: utilities.h:69
QList::count
int count(const T &value) const
fromMimeData
static MailList fromMimeData(const QMimeData *md)
QList::append
void append(const T &value)
KNComposer::AttachmentPropertiesDlg::accept
void accept()
Definition: kncomposer.cpp:1626
QEvent::ignore
void ignore()
KXmlGuiWindow
QTextStream::atEnd
bool atEnd() const
KNComposer::AttachmentPropertiesDlg::d_escription
KLineEdit * d_escription
Definition: kncomposer.h:258
QMenu::popup
void popup(const QPoint &p, QAction *atAction)
QGroupBox
KNGlobals::identityManager
KPIMIdentities::IdentityManager * identityManager()
Returns the identity manager.
Definition: knglobals.cpp:167
KNComposer::MessageMode
MessageMode
Definition: kncomposer.h:50
QObject::inherits
bool inherits(const char *className) const
KNLineEditSpell::KNLineEditSpell
KNLineEditSpell(View *parent, bool useCompletion=true)
Constructor.
Definition: kncomposer.cpp:126
QContextMenuEvent
KNode::Composer::View::followupTo
const QStringList followupTo() const
Returns the followup-to list of groups (name are trimmed).
Definition: kncomposerview.cpp:284
QDropEvent
KNComposer::slotNewToolbarConfig
void slotNewToolbarConfig()
Definition: kncomposer.cpp:1387
QList::isEmpty
bool isEmpty() const
QString::isEmpty
bool isEmpty() const
QByteArray::number
QByteArray number(int n, int base)
KNode::Composer::View::subject
const QString subject() const
Returns the subject text.
Definition: kncomposerview.cpp:327
KNode::Settings::identity
virtual const KPIMIdentities::Identity & identity() const
Returns the global identity (or the default one when none is set yet).
Definition: settings.cpp:91
KNLoadHelper::getFile
QFile * getFile(const QString &dialogTitle)
opens a file dialog and returns a file open for reading
Definition: utilities.cpp:113
KNLineEdit::loadAddresses
virtual void loadAddresses()
Definition: kncomposer.cpp:92
to
QString to() const
subject
QString subject() const
KNComposer::AttachmentPropertiesDlg::AttachmentPropertiesDlg
AttachmentPropertiesDlg(KNAttachment::Ptr a, QWidget *parent=0)
Create a dialog to edit attribute of a message attachment.
Definition: kncomposer.cpp:1534
QVBoxLayout
KNComposer::v_alidated
bool v_alidated
Definition: kncomposer.h:114
QList::Iterator
typedef Iterator
KNComposer::news_mail
Message is to be sent by e-mail and to a newsgroup.
Definition: kncomposer.h:53
locale.h
KNComposer::slotExternalEditor
void slotExternalEditor()
Definition: kncomposer.cpp:1275
KNComposer::a_ctAttachmentProperties
QAction * a_ctAttachmentProperties
Definition: kncomposer.h:135
knmainwidget.h
QMenu::addSeparator
QAction * addSeparator()
KNLineEditSpell::highLightWord
void highLightWord(unsigned int length, unsigned int pos)
Definition: kncomposer.cpp:136
QString
KNode::Composer::View::showAttachmentView
void showAttachmentView()
Definition: kncomposerview.cpp:396
KNGlobals::settings
KNode::Settings * settings()
Returns the KConfigXT generated settings object.
Definition: knglobals.cpp:182
KNode::Settings::writeConfig
virtual void writeConfig()
Reimplemented to hide writeConfig() from SettingsContainerInterface and delegate call to SettingsBase...
Definition: settings.h:102
QList< KNAttachment::Ptr >
QTextCodec
KNComposer::e_xternalEdited
bool e_xternalEdited
Definition: kncomposer.h:125
KNComposer::slotPaste
void slotPaste()
Definition: kncomposer.cpp:461
KNComposer::CRsendNow
Definition: kncomposer.h:47
QLayout::setMargin
void setMargin(int margin)
QMenu::exec
QAction * exec()
KNComposer::AttachmentPropertiesDlg::m_imeType
KLineEdit * m_imeType
Definition: kncomposer.h:258
canDecode
static bool canDecode(const QMimeData *md)
KNComposer::a_ttChanged
bool a_ttChanged
Definition: kncomposer.h:131
QStringList
KNComposer::~KNComposer
~KNComposer()
Definition: kncomposer.cpp:392
QList::end
iterator end()
QString::toLower
QString toLower() const
QKeyEvent::key
int key() const
QMenu
QEvent::accept
void accept()
KNode::Composer::View::setComposingFont
void setComposingFont(const QFont &font)
Changes the font used in edition widget within this ComposerView.
Definition: kncomposerview.cpp:182
kngroupselectdialog.h
KNLineEdit::KNLineEdit
KNLineEdit(View *parent, bool useCompletion=true)
Constructor.
Definition: kncomposer.cpp:59
KPIM::RecentAddressDialog
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
QSize
KNComposer::slotCut
void slotCut()
Definition: kncomposer.cpp:435
KNComposer::article
KNLocalArticle::Ptr article() const
Definition: kncomposer.h:77
KNode::Composer::View::setFollowupTo
void setFollowupTo(const QString &followupTo)
Sets the followup-to list as a string (must be a coma separated list of groups).
Definition: kncomposerview.cpp:290
KNComposer::mail
Message is to be sent by e-mail.
Definition: kncomposer.h:52
KNComposer::setMessageMode
void setMessageMode(MessageMode mode)
Definition: kncomposer.cpp:502
KNHelper::rewrapStringList
static QString rewrapStringList(const QStringList &text, int wrapAt, QChar quoteChar, bool stopAtSig, bool alwaysSpace)
used for rewarping a text when replying to a message or inserting a file into a box ...
Definition: utilities.cpp:286
knglobals.h
KNode::Composer::View::showExternalNotification
void showExternalNotification()
Definition: kncomposerview.cpp:488
KNode::Composer::View::groups
const QStringList groups() const
Returns the followup-to list of groups (name are trimmed).
Definition: kncomposerview.cpp:235
KNComposer::dropEvent
virtual void dropEvent(QDropEvent *event)
Reimplemented to add the dropped files as attachments.
Definition: kncomposer.cpp:1510
KNode::Composer::View::attachments
const QList< KNAttachment::Ptr > attachments() const
Returns the list of attachments of this message.
Definition: kncomposerview.cpp:464
KNComposer::a_ctSetCharsetKeyb
QAction * a_ctSetCharsetKeyb
Definition: kncomposer.h:135
QString::replace
QString & replace(int position, int n, QChar after)
QKeyEvent
KNComposer::slotAttachmentPopup
void slotAttachmentPopup(const QPoint &point)
Open a popup menu to do action on an attachment.
Definition: kncomposer.cpp:1494
KLineEdit
KNComposer::n_eeds8Bit
bool n_eeds8Bit
Definition: kncomposer.h:114
QString::toLatin1
QByteArray toLatin1() const
KNComposer::mDeletedAttachments
QList< KNAttachment::Ptr > mDeletedAttachments
Definition: kncomposer.h:130
KNComposer::slotAutoSpellCheckingToggled
void slotAutoSpellCheckingToggled()
Definition: kncomposer.cpp:1261
KNode::Composer::View::addAttachment
void addAttachment(KNAttachment::Ptr attachment)
Adds an attachment to the message.
Definition: kncomposerview.cpp:458
QDragEnterEvent
settings.h
KNComposer::slotConfKeys
void slotConfKeys()
Definition: kncomposer.cpp:1373
KNode::Composer::View::editor
KNComposerEditor * editor() const
Returns the main text editor.
Definition: kncomposerview.cpp:338
KNComposer::addRecentAddress
void addRecentAddress()
Definition: kncomposer.cpp:1076
QKeySequence
kncomposer.h
KNComposer::CRdel
Definition: kncomposer.h:48
KNComposer::slotInsertFile
void slotInsertFile()
Definition: kncomposer.cpp:1114
QGridLayout::setColumnStretch
void setColumnStretch(int column, int stretch)
kncomposerview.h
KNode::Composer::View::hideAttachmentView
void hideAttachmentView()
Definition: kncomposerview.cpp:453
KNComposer::slotAttachmentChanged
void slotAttachmentChanged()
Called by the View to notify that an attachment was modified.
Definition: kncomposer.cpp:1160
KNComposer::slotSelectAll
void slotSelectAll()
Definition: kncomposer.cpp:473
QGridLayout::addItem
void addItem(QLayoutItem *item, int row, int column, int rowSpan, int columnSpan, QFlags< Qt::AlignmentFlag > alignment)
KNComposer::slotUndo
void slotUndo()
Definition: kncomposer.cpp:413
KNComposer::composerDone
void composerDone(KNComposer *)
QAction
QTextCodec::codecForName
QTextCodec * codecForName(const QByteArray &name)
KNLineEditSpell::spellCheckerMisspelling
void spellCheckerMisspelling(const QString &text, const QStringList &, unsigned int pos)
Definition: kncomposer.cpp:147
KNComposer::slotUpdateCursorPos
void slotUpdateCursorPos()
Definition: kncomposer.cpp:1366
KNComposer::a_ctSpellCheck
QAction * a_ctSpellCheck
Definition: kncomposer.h:135
KNComposer::slotSendNow
void slotSendNow()
Definition: kncomposer.cpp:1083
KNComposer::applyChanges
bool applyChanges()
Applies changes from the editor into the article being edited.
Definition: kncomposer.cpp:722
KNComposer::closeEvent
void closeEvent(QCloseEvent *e)
Definition: kncomposer.cpp:893
KNComposer::CRsendLater
Definition: kncomposer.h:47
KNComposer::slotRedo
void slotRedo()
Definition: kncomposer.cpp:424
QComboBox::setCurrentIndex
void setCurrentIndex(int index)
KNComposer::slotSubjectChanged
void slotSubjectChanged(const QString &t)
Definition: kncomposer.cpp:1397
QString::length
int length() const
KNComposer::slotSetCharsetKeyboard
void slotSetCharsetKeyboard()
Definition: kncomposer.cpp:1242
KNComposer::a_ctDoMail
KToggleAction * a_ctDoMail
Definition: kncomposer.h:140
QByteArray::data
char * data()
QString::left
QString left(int n) const
KNHelper::selectDialog
static int selectDialog(QWidget *parent, const QString &caption, const QStringList &options, int initialValue)
list selection dialog, used instead of a popup menu when a select action is called via the keyboard...
Definition: utilities.cpp:163
recentaddressdialog.h
KNComposer::e_ditorTempfile
KTemporaryFile * e_ditorTempfile
Definition: kncomposer.h:127
KNComposer::slotInsertFileBoxed
void slotInsertFileBoxed()
Definition: kncomposer.cpp:1120
QString::fromLatin1
QString fromLatin1(const char *str, int size)
KNComposer::slotCancelEditor
void slotCancelEditor()
Definition: kncomposer.cpp:1480
KNComposer::AttachmentPropertiesDlg::e_ncoding
QComboBox * e_ncoding
Definition: kncomposer.h:260
KNComposer::slotUpdateStatusBar
void slotUpdateStatusBar()
Definition: kncomposer.cpp:1342
KNComposer::u_nwraped
QString u_nwraped
Definition: kncomposer.h:112
KNLoadHelper::setURL
QFile * setURL(const KUrl &url)
tries to access the file specified by the url and returns a file open for reading ...
Definition: utilities.cpp:129
QLineEdit
KNComposer::slotToBtnClicked
void slotToBtnClicked()
Definition: kncomposer.cpp:1413
KNComposer::dragEnterEvent
virtual void dragEnterEvent(QDragEnterEvent *event)
Reimplemented to accept list of URI as drag content.
Definition: kncomposer.cpp:1502
KNode::Composer::View::setSubject
void setSubject(const QString &subject)
Sets the subject.
Definition: kncomposerview.cpp:332
KNComposer::a_uthorDislikesMailCopies
bool a_uthorDislikesMailCopies
Definition: kncomposer.h:114
KNComposer::slotSendLater
void slotSendLater()
Definition: kncomposer.cpp:1091
KNComposer::m_ode
MessageMode m_ode
Definition: kncomposer.h:113
QLabel
knGlobals
#define knGlobals
Keep compatibility with the old way.
Definition: knglobals.h:28
KPIM::RecentAddresses
KNComposer::insertFile
void insertFile(QFile *file, bool clear=false, bool box=false, const QString &boxTitle=QString())
Inserts at cursor position if clear is false, replaces content otherwise puts the file content into a...
Definition: kncomposer.cpp:1011
KNComposer::slotCopy
void slotCopy()
Definition: kncomposer.cpp:447
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
KNAttachment::Ptr
boost::shared_ptr< KNAttachment > Ptr
Shared pointer to a KNAttachment.
Definition: knarticle.h:283
KNComposer::slotToggleDoPost
void slotToggleDoPost()
Definition: kncomposer.cpp:1167
KNComposer::news
Message is to be sent to a newsgroup.
Definition: kncomposer.h:51
KNLineEditSpell::spellCheckDone
void spellCheckDone(const QString &s)
Definition: kncomposer.cpp:141
QList::begin
iterator begin()
KNode::Composer::View::completeSetup
void completeSetup(bool firstEdit, KNComposer::MessageMode mode)
Completes the setup of this view.
Definition: kncomposerview.cpp:108
KNode::Composer::View::selectedIdentity
uint selectedIdentity() const
Return the UOID of the selected identity.
Definition: kncomposerview.cpp:201
KNComposer::a_ctRemoveAttachment
QAction * a_ctRemoveAttachment
Definition: kncomposer.h:135
KNComposer::a_ctDoPost
KToggleAction * a_ctDoPost
Definition: kncomposer.h:140
QAction::setEnabled
void setEnabled(bool)
QTextCodec::toUnicode
QString toUnicode(const QByteArray &a) const
KNGroupSelectDialog::selectedGroups
QString selectedGroups() const
Definition: kngroupselectdialog.cpp:85
KNComposer::a_rticle
KNLocalArticle::Ptr a_rticle
Definition: kncomposer.h:111
KTextEdit
KNComposer::slotArtDelete
void slotArtDelete()
Definition: kncomposer.cpp:1107
KNode::Composer::View::setGroups
void setGroups(const QString &groups)
Sets the group list as a string (must be coma separated).
Definition: kncomposerview.cpp:241
KNGroupSelectDialog
Group selection dialog (used in the composer).
Definition: kngroupselectdialog.h:24
KNGroup::Ptr
boost::shared_ptr< KNGroup > Ptr
Shared pointer to a KNGroup.
Definition: kngroup.h:47
KNComposer::slotUpdateCheckSpellChecking
void slotUpdateCheckSpellChecking(bool _b)
Definition: kncomposer.cpp:407
recentaddresses.h
QList::replace
void replace(int i, const T &value)
KNComposer::CRcancel
Definition: kncomposer.h:48
KNComposer::KNComposer
KNComposer(KNLocalArticle::Ptr a, const QString &text=QString(), const QString &unwraped=QString(), bool firstEdit=false, bool dislikesCopies=false, bool createCopy=false, bool allowMail=true)
Create a composer for a message (e-mail or newsgroup post).
Definition: kncomposer.cpp:163
QComboBox
QTextCursor::setPosition
void setPosition(int pos, MoveMode m)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knode

Skip menu "knode"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal