[Roberto] Passed the modified kmcomposewin with NNTP headers support to

kmail.
          BTW: there is a bug in KMComposeWin::rethinkFields().
          If you hide headers one by one, it fails an assert when you
          hide the next-to-last one.
          I committed the changes anyway, because that error seems to have
          existed since before.

svn path=/trunk/kdenetwork/kmail/; revision=2982
wilder-work
Roberto Alsina 29 years ago
parent 01bf234613
commit 759571c82c
  1. 61
      kmcomposewin.cpp
  2. 13
      kmcomposewin.h

@ -64,10 +64,15 @@ extern KMIdentity *identity;
#define HDR_CC 0x08
#define HDR_BCC 0x10
#define HDR_SUBJECT 0x20
#define HDR_STANDARD (HDR_SUBJECT|HDR_TO|HDR_CC)
#define HDR_ALL 0x3f
#define HDR_NEWSGROUPS 0x40
#define HDR_FOLLOWUP_TO 0x80
#define HDR_ALL 0xff
#ifdef KRN
#define HDR_STANDARD (HDR_SUBJECT|HDR_NEWSGROUPS)
#else
#define HDR_STANDARD (HDR_SUBJECT|HDR_TO|HDR_CC)
#endif
//-----------------------------------------------------------------------------
KMComposeWin::KMComposeWin(KMMessage *aMsg) : KMComposeWinInherited(),
@ -76,6 +81,10 @@ KMComposeWin::KMComposeWin(KMMessage *aMsg) : KMComposeWinInherited(),
mEdtCc(&mMainWidget), mEdtBcc(&mMainWidget), mEdtSubject(&mMainWidget),
mLblFrom(&mMainWidget), mLblReplyTo(&mMainWidget), mLblTo(&mMainWidget),
mLblCc(&mMainWidget), mLblBcc(&mMainWidget), mLblSubject(&mMainWidget)
/* start added for KRN */
,mEdtNewsgroups(&mMainWidget),mEdtFollowupTo(&mMainWidget),
mLblNewsgroups(&mMainWidget),mLblFollowupTo(&mMainWidget)
/* end added for KRN */
{
mGrid = NULL;
@ -224,6 +233,10 @@ void KMComposeWin::rethinkFields(void)
&mLblBcc, &mEdtBcc);
rethinkHeaderLine(showHeaders,HDR_SUBJECT, row, nls->translate("&Subject:"),
&mLblSubject, &mEdtSubject);
rethinkHeaderLine(showHeaders,HDR_NEWSGROUPS, row, nls->translate("&Newsgroups:"),
&mLblNewsgroups, &mEdtNewsgroups);
rethinkHeaderLine(showHeaders,HDR_FOLLOWUP_TO, row, nls->translate("&Followup-To:"),
&mLblFollowupTo, &mEdtFollowupTo);
assert(row<=mNumHeaders);
mGrid->addMultiCellWidget(mEditor, row, mNumHeaders, 0, 2);
@ -352,6 +365,8 @@ void KMComposeWin::setupMenuBar(void)
menu->insertItem(nls->translate("&Cc"), HDR_CC);
menu->insertItem(nls->translate("&Bcc"), HDR_BCC);
menu->insertItem(nls->translate("&Subject"), HDR_SUBJECT);
menu->insertItem(nls->translate("&Newsgroups"), HDR_NEWSGROUPS); //added for KRN
menu->insertItem(nls->translate("&Followup-To"), HDR_FOLLOWUP_TO); //added for KRN
mMenuBar->insertItem(nls->translate("&View"), menu);
//---------- Menu: Attach
@ -365,6 +380,7 @@ void KMComposeWin::setupMenuBar(void)
menu->insertItem(nls->translate("Pr&operties..."),
this, SLOT(slotAttachProperties()));
mMenuBar->insertItem(nls->translate("&Attach"), menu);
//---------- Menu: Help
menu = app->getHelpMenu(TRUE, aboutText);
mMenuBar->insertSeparator();
@ -480,6 +496,8 @@ void KMComposeWin::setMsg(KMMessage* newMsg)
mEdtSubject.setText(mMsg->subject());
mEdtReplyTo.setText(mMsg->replyTo());
mEdtBcc.setText(mMsg->bcc());
mEdtNewsgroups.setText(mMsg->groups());
mEdtFollowupTo.setText(mMsg->followup());
num = mMsg->numBodyParts();
if (num > 0)
@ -513,6 +531,8 @@ void KMComposeWin::applyChanges(void)
if (!subject().isEmpty()) mMsg->setSubject(subject());
if (!replyTo().isEmpty()) mMsg->setReplyTo(replyTo());
if (!bcc().isEmpty()) mMsg->setBcc(bcc());
if (!followupTo().isEmpty()) mMsg->setFollowup(followupTo());
if (!newsgroups().isEmpty()) mMsg->setGroups(newsgroups());
// we should do some multipart work here (attachments)
mMsg->setBody(mEditor->text());
@ -943,48 +963,15 @@ void KMComposeWin::slotHelp()
//Class KMLineEdit ------------------------------------------------------------
static const int myBlinkTime = 500;
// Oh man not as trivial as I thought....:-(
static int myXPosToCursorPos(char *s, const QFontMetrics &fm,
int xPos, int width)
{
char *tmp;
int dist;
if( xPos > width)
xPos = width;
if( xPos <= width)
return 0;
dist = xPos;
tmp = s;
while (*tmp && dist > 0)
dist -= fm.width( tmp++,1);
if( dist < 0 && ( xPos - dist > width || fm.width( tmp -1,1)/2 < -dist))
tmp--;
return tmp -s ;
}
KMLineEdit::KMLineEdit(QWidget *parent = NULL, const char *name = NULL)
:QLineEdit(parent,name)
{
initMetaObject();
}
//-----------------------------------------------------------------------------
void KMLineEdit::mousePressEvent(QMouseEvent *e)
{
killTimers();
int margin = frame() ? 4 : 2;
// not as trivial as I thought but eventually I will solve this problem
/*cursorPos = offset + myXPosToCursorPos( &tbuf[(int)offset], fontMetrics(),
e->pos().x() - margin,
width() - 2*margin);*/
if(e->button() == LeftButton)
deselect();
if(e->button() == MidButton) {
QKeyEvent k( Event_KeyPress, Key_V, 0 , ControlButton);
keyPressEvent(&k);
@ -998,8 +985,6 @@ void KMLineEdit::mousePressEvent(QMouseEvent *e)
p->insertItem("Mark all",this,SLOT(markAll()));
p->popup(QCursor::pos());
}
repaint(!hasFocus());
startTimer(myBlinkTime);
}
//-----------------------------------------------------------------------------

@ -44,9 +44,7 @@ public slots:
void markAll();
private:
/*int cursorPos;
int offset;
QString tbuf;*/
protected:
virtual void mousePressEvent(QMouseEvent *);
};
@ -144,7 +142,10 @@ protected:
virtual const QString bcc(void) const { return mEdtBcc.text(); }
virtual const QString from(void) const { return mEdtFrom.text(); }
virtual const QString replyTo(void) const { return mEdtReplyTo.text(); }
virtual const QString newsgroups(void) const { return mEdtNewsgroups.text(); }
virtual const QString followupTo(void) const { return mEdtFollowupTo.text(); }
/** Save settings upon close. */
virtual void closeEvent(QCloseEvent*);
@ -164,7 +165,11 @@ protected:
QWidget mMainWidget;
KMLineEdit mEdtFrom, mEdtReplyTo, mEdtTo, mEdtCc, mEdtBcc, mEdtSubject;
QLabel mLblFrom, mLblReplyTo, mLblTo, mLblCc, mLblBcc, mLblSubject;
/* start Added for KRN */
KMLineEdit mEdtNewsgroups, mEdtFollowupTo;
QLabel mLblNewsgroups, mLblFollowupTo;
/* end Added for KRN */
QPopupMenu* mMnuView;
KEdit* mEditor;
QGridLayout* mGrid;

Loading…
Cancel
Save