When new emails are added to the current folder re-init the view to

show any new email that would otherwise have appeared outside of the
widget.

BUG: 49292

svn path=/trunk/KDE/kdepim/; revision=425948
wilder-work
Thomas Zander 21 years ago
parent a6065b70b3
commit 5b0ba3b85e
  1. 59
      kmheaders.cpp
  2. 5
      kmheaders.h
  3. 5
      kmmainwidget.cpp

@ -778,7 +778,7 @@ void KMHeaders::msgChanged()
QValueList<int> curItems = selectedItems();
updateMessageList(); // do not change the selection
// restore the old state
setTopItemByIndex( i );
setTopItemByIndex( i, true);
setCurrentMsg( cur );
setSelectedByIndex( curItems, true );
connect(this,SIGNAL(currentChanged(QListViewItem*)),
@ -2352,37 +2352,40 @@ void KMHeaders::setCurrentItemByIndex(int msgIdx)
//-----------------------------------------------------------------------------
int KMHeaders::topItemIndex()
{
HeaderItem *item = static_cast<HeaderItem*>(itemAt(QPoint(1,1)));
if (item)
return item->msgId();
else
return -1;
}
// If sorting ascending by date/ooa then try to scroll list when new mail
// arrives to show it, but don't scroll current item out of view.
void KMHeaders::showNewMail()
{
if (mSortCol != mPaintInfo.dateCol)
return;
for( int i = 0; i < (int)mItems.size(); ++i)
if (mFolder->getMsgBase(i)->isNew()) {
if (!mSortDescending)
setTopItemByIndex( currentItemIndex() );
break;
}
int i=0;
HeaderItem *topItem = static_cast<HeaderItem*>(itemAt(QPoint(1,1)));
QListViewItem *item = firstChild();
while(item && item != topItem) {
item = item->itemBelow();
i++;
}
if(item)
return i;
return -1;
}
//-----------------------------------------------------------------------------
void KMHeaders::setTopItemByIndex( int aMsgIdx)
void KMHeaders::setTopItemByIndex( int aMsgIdx, bool fuzzy)
{
int msgIdx = aMsgIdx;
if (msgIdx < 0)
msgIdx = 0;
else if (msgIdx >= (int)mItems.size())
msgIdx = mItems.size() - 1;
if ((msgIdx >= 0) && (msgIdx < (int)mItems.size()))
setContentsPos( 0, itemPos( mItems[msgIdx] ));
int y = 0;
QListViewItem *item = firstChild();
while(item) {
if(aMsgIdx-- <= 0)
break;
y += item->totalHeight();
item = item->itemBelow();
}
if(fuzzy) {
item = item->itemAbove();
while(item) {
int mesgId = static_cast<HeaderItem*>(item)->msgId();
if( !mFolder->getMsgBase(mesgId)->isUnread() )
break;
y -= item->totalHeight();
item = item->itemAbove();
}
}
setContentsPos( 0, y );
}
//-----------------------------------------------------------------------------

@ -125,9 +125,6 @@ public:
/** Read color options and set palette. */
virtual void readColorConfig(void);
/** Scroll to show new mail */
void showNewMail();
/** Return the current message */
virtual KMMessage* currentMsg();
/** Return the current list view item */
@ -142,7 +139,7 @@ public:
virtual int topItemIndex();
/** Make the item corresponding to the message with the given id the
top most visible item. */
virtual void setTopItemByIndex( int aMsgIdx );
virtual void setTopItemByIndex( int aMsgIdx, bool fuzzy=false);
virtual void setNestedOverride( bool override );
virtual void setSubjectThreading( bool subjThreading );
/** Double force items to always be open */

@ -847,11 +847,6 @@ void KMMainWidget::slotMailChecked( bool newMail, bool sendOnCheck,
if (mBeepOnNew) {
KNotifyClient::beep();
}
// Todo:
// scroll mHeaders to show new items if current item would
// still be visible
// mHeaders->showNewMail();
}

Loading…
Cancel
Save