Rather heavy rework of the foldertree. It's now based on a new widget "KFolderTree" in libkdenetwork.

DnD improvements and fixes by Ingo.

svn path=/trunk/kdenetwork/kmail/; revision=163927
wilder-work
Carsten Burghardt 24 years ago
parent 07f0eeec88
commit 4d416f2a6f
  1. 52
      configuredialog.cpp
  2. 4
      configuredialog_p.h
  3. 2
      kmacctimap.cpp
  4. 836
      kmfoldertree.cpp
  5. 166
      kmfoldertree.h
  6. 81
      kmheaders.cpp
  7. 46
      kmheaders.h
  8. 143
      kmmainwin.cpp
  9. 8
      kmmainwin.h

@ -3776,6 +3776,11 @@ MiscPageFoldersTab::MiscPageFoldersTab( QWidget * parent, const char * name )
connect(mDelayedMarkAsRead, SIGNAL(toggled(bool)), mDelayedMarkTime,
SLOT(setEnabled(bool)));
// "show popup after Drag'n'Drop" checkbox: stretch 0
mShowPopupAfterDnD =
new QCheckBox( i18n("Ask for action after dragging messages to another folder"), this );
vlay->addWidget( mShowPopupAfterDnD );
// "default mailbox format" combo + label: stretch 0
hlay = new QHBoxLayout( vlay ); // inherits spacing
mMailboxPrefCombo = new QComboBox( false, this );
@ -3791,32 +3796,6 @@ MiscPageFoldersTab::MiscPageFoldersTab( QWidget * parent, const char * name )
hlay->addWidget( label );
hlay->addWidget( mMailboxPrefCombo, 1 );
vlay->addWidget( new KSeparator( KSeparator::HLine, this ) );
// mail Drag'n'Drop actions settings:
mActionWhenDnD = new QVButtonGroup( i18n("In normal mo&de"), this );
mActionWhenDnD->layout()->setSpacing( KDialog::spacingHint() );
mActionWhenDnD->insert(new QRadioButton( i18n("Move message"), mActionWhenDnD));
mActionWhenDnD->insert(new QRadioButton( i18n("Copy message"), mActionWhenDnD));
mActionWhenDnD->insert(new QRadioButton( i18n("Ask me"), mActionWhenDnD));
mActionWhenShiftDnD = new QVButtonGroup( i18n("&SHIFT key pressed"), this );
mActionWhenShiftDnD->layout()->setSpacing( KDialog::spacingHint() );
mActionWhenShiftDnD->insert(new QRadioButton( i18n("Move message"), mActionWhenShiftDnD));
mActionWhenShiftDnD->insert(new QRadioButton( i18n("Copy message"), mActionWhenShiftDnD));
mActionWhenShiftDnD->insert(new QRadioButton( i18n("Ask me"), mActionWhenShiftDnD));
mActionWhenCtrlDnD = new QVButtonGroup( i18n("CT&RL key pressed"), this );
mActionWhenCtrlDnD->layout()->setSpacing( KDialog::spacingHint() );
mActionWhenCtrlDnD->insert(new QRadioButton( i18n("Move message"), mActionWhenCtrlDnD));
mActionWhenCtrlDnD->insert(new QRadioButton( i18n("Copy message"), mActionWhenCtrlDnD));
mActionWhenCtrlDnD->insert(new QRadioButton( i18n("Ask me"), mActionWhenCtrlDnD));
vlay->addWidget(
new QLabel( i18n("On Drag'n'Drop of mail to another folder:"),
this ) );
hlay = new QHBoxLayout( vlay ); // inherits spacing
hlay->addWidget( mActionWhenDnD );
hlay->addWidget( mActionWhenShiftDnD );
hlay->addWidget( mActionWhenCtrlDnD );
// "On exit..." groupbox:
group = new QVGroupBox( i18n("On Program Exit, "
"Perform the Following Tasks"), this );
@ -3870,20 +3849,11 @@ void MiscPage::FoldersTab::setup() {
mJumpToUnread->setChecked( behaviour.readBoolEntry( "JumpToUnread", false ) );
mDelayedMarkAsRead->setChecked( behaviour.readBoolEntry( "DelayedMarkAsRead", true ) );
mDelayedMarkTime->setValue( behaviour.readNumEntry( "DelayedMarkTime", 0 ) );
mShowPopupAfterDnD->setChecked( behaviour.readBoolEntry( "ShowPopupAfterDnD", true ) );
int num = general.readNumEntry("default-mailbox-format", 1 );
if ( num < 0 || num > 1 ) num = 1;
mMailboxPrefCombo->setCurrentItem( num );
num = behaviour.readNumEntry("DnD_action_normal", KMMsgDnDActionASK );
if ( num < 0 || num > 2 ) num = KMMsgDnDActionASK;
mActionWhenDnD->setButton( num );
num = behaviour.readNumEntry("DnD_action_SHIFT", KMMsgDnDActionMOVE );
if ( num < 0 || num > 2 ) num = KMMsgDnDActionMOVE;
mActionWhenShiftDnD->setButton( num );
num = behaviour.readNumEntry("DnD_action_CTRL", KMMsgDnDActionCOPY );
if ( num < 0 || num > 2 ) num = KMMsgDnDActionCOPY;
mActionWhenCtrlDnD->setButton( num );
}
void MiscPage::FoldersTab::apply() {
@ -3899,18 +3869,12 @@ void MiscPage::FoldersTab::apply() {
behaviour.writeEntry( "JumpToUnread", mJumpToUnread->isChecked() );
behaviour.writeEntry( "DelayedMarkAsRead", mDelayedMarkAsRead->isChecked() );
behaviour.writeEntry( "DelayedMarkTime", mDelayedMarkTime->value() );
behaviour.writeEntry( "ShowPopupAfterDnD", mShowPopupAfterDnD->isChecked() );
if ( mExpireAtExit->isChecked() )
general.writeEntry( "when-to-expire", expireAtExit );
else
general.writeEntry( "when-to-expire", expireManual );
behaviour.writeEntry("DnD_action_normal",
mActionWhenDnD->id( mActionWhenDnD->selected() ));
behaviour.writeEntry("DnD_action_SHIFT",
mActionWhenShiftDnD->id( mActionWhenShiftDnD->selected() ));
behaviour.writeEntry("DnD_action_CTRL",
mActionWhenCtrlDnD->id( mActionWhenCtrlDnD->selected() ));
}
@ -4707,8 +4671,8 @@ bool PluginPage::isPluginConfigEqual( int pluginno ) const
kdDebug(5006) << "29) RET = " << ret << endl;
return ret;
}
void PluginPage::savePluginConfig( int pluginno )
{
if ( mCryptPlugList->isEmpty() )

@ -793,9 +793,7 @@ protected:
QCheckBox *mExpireAtExit;
QCheckBox *mDelayedMarkAsRead;
KIntSpinBox *mDelayedMarkTime;
QButtonGroup *mActionWhenDnD;
QButtonGroup *mActionWhenShiftDnD;
QButtonGroup *mActionWhenCtrlDnD;
QCheckBox *mShowPopupAfterDnD;
};
class MiscPageAddressbookTab : public ConfigurationPage {

@ -464,7 +464,7 @@ void KMAcctImap::killJobsForItem(KMFolderTreeItem * fti)
QMap<KIO::Job *, jobData>::Iterator it = mapJobData.begin();
while (it != mapJobData.end())
{
if (it.data().parent == fti->folder)
if (it.data().parent == fti->folder())
{
killAllJobs();
break;

File diff suppressed because it is too large Load Diff

@ -2,82 +2,66 @@
#define __KMFOLDERTREE
#include <qwidget.h>
#include <qlistview.h>
#include <qtimer.h>
#include <qheader.h>
#include <klocale.h>
#include <kpopupmenu.h>
#include <kfoldertree.h>
// Fixme! A temporary dependency
#include "kmheaders.h" // For KMHeaderToFolderDrag & KMPaintInfo
#include "kmheaders.h"
#include "kmfolder.h"
class QDropEvent;
class QPixmap;
class QPainter;
class KMFolderImap;
class KMFolderTree;
class CryptPlugWrapperList;
class KMFolderTreeItem : public QListViewItem
class KMFolderTreeItem : public KFolderTreeItem
{
public:
KMFolder* folder;
QString unread;
KMPaintInfo *mPaintInfo;
/** Construct the root item */
KMFolderTreeItem( QListView *parent,
KMPaintInfo *aPaintInfo )
: QListViewItem( parent, i18n("Mail") ),
folder( 0 ),
unread( QString::null ),
mPaintInfo( aPaintInfo )
/** Construct a root item _without_ folder */
KMFolderTreeItem( KFolderTree *parent,
QString name )
: KFolderTreeItem( parent, name ), mFolder( 0 )
{}
KMFolderTreeItem( QListView *parent,
KMFolder* folder,
KMPaintInfo *aPaintInfo )
: QListViewItem( parent, i18n("Mail") ),
folder( folder ),
unread( QString::null ),
mPaintInfo( aPaintInfo )
/** Construct a root item _with_ folder */
KMFolderTreeItem( KFolderTree *parent, QString name,
KMFolder* folder )
: KFolderTreeItem( parent, name, folder->protocol() ), mFolder( folder )
{}
/** Construct a child item */
KMFolderTreeItem( QListViewItem* parent,
KMFolder* folder,
KMPaintInfo *aPaintInfo )
: QListViewItem( parent, (folder) ? folder->label() : QString::null ),
folder( folder ),
unread( QString::null ),
mPaintInfo( aPaintInfo )
KMFolderTreeItem( KFolderTreeItem* parent, QString name,
KMFolder* folder )
: KFolderTreeItem( parent, folder->protocol(), name ), mFolder( folder )
{}
virtual ~KMFolderTreeItem();
void paintCell( QPainter * p, const QColorGroup & cg,
int column, int width, int align );
/** gets the recursive unread-count */
virtual int countUnreadRecursive();
virtual QString key( int, bool ) const;
/** associated folder */
KMFolder* folder() { return mFolder; }
virtual int compare( QListViewItem * i, int col, bool ascending ) const;
/** dnd */
virtual bool acceptDrag(QDropEvent* ) const;
protected:
KMFolder* mFolder;
};
//==========================================================================
#define KMFolderTreeInherited QListView
class KMFolderTree : public QListView
class KMFolderTree : public KFolderTree
{
Q_OBJECT
protected:
virtual void drawContentsOffset( QPainter * p, int ox, int oy,
int cx, int cy, int cw, int ch );
public:
KMFolderTree( CryptPlugWrapperList * cryptPlugList,
QWidget *parent=0, const char *name=0 );
virtual ~KMFolderTree();
/** Save config options */
void writeConfig();
@ -86,7 +70,7 @@ public:
virtual void reload(bool openFolders = false);
/** Recusively add folders in a folder directory to a listview item. */
virtual void addDirectory( KMFolderDir *fdir, QListViewItem* parent );
virtual void addDirectory( KMFolderDir *fdir, KMFolderTreeItem* parent );
/** Find index of given folder. Returns -1 if not found */
virtual QListViewItem* indexOfFolder(const KMFolder*);
@ -105,9 +89,6 @@ public:
/** Read color options and set palette. */
void readColorConfig(void);
/** Ensure that there is only one selected item */
virtual void setSelected( QListViewItem *, bool );
/** Remove information about not existing folders from the config file */
void cleanupConfigFile();
@ -124,18 +105,6 @@ public:
/** toggles the unread and total columns on/off */
void toggleColumn(int column, bool openFolders = false);
/** returns true when the column is active */
bool isUnreadActive() { return unreadIsActive; }
bool isTotalActive() { return totalIsActive; }
/** returns the current column number (section) */
int getUnreadColumnNumber() { return header()->mapToSection(unreadIndex); }
int getTotalColumnNumber() { return header()->mapToSection(totalIndex); }
/** returns the current column number (section) */
int getUnreadColumIndex() { return unreadIndex; }
int getTotalColumnIndex() { return totalIndex; }
signals:
/** The selected folder has changed */
void folderSelected(KMFolder*);
@ -149,28 +118,35 @@ signals:
/** Messages have been dropped onto a folder with Ctrl */
void folderDropCopy(KMFolder*);
protected:
/** open ancestors and ensure item is visible */
void prepareItem( KMFolderTreeItem* );
public slots:
/** Select the next folder with unread messages */
void nextUnreadFolder();
/** Select the previous folder with unread messages */
void prevUnreadFolder();
/** Increment current folder */
void incCurrentFolder();
/** Decrement current folder */
void decCurrentFolder();
/** Select the current folder */
void selectCurrentFolder();
/** Executes delayed update of folder tree */
void delayedUpdate();
/** Remove all items associated with the given IMAP account */
void slotAccountDeleted(KMFolderImap*);
/** Select the item and switch to the folder */
void doFolderSelected(QListViewItem*);
/** autoscroll support */
void startAutoScroll();
void stopAutoScroll();
protected slots:
// void slotRMB(int, int);
/** called by the folder-manager when the list of folders changed */
@ -203,6 +179,12 @@ protected slots:
void slotToggleUnreadColumn();
void slotToggleTotalColumn();
void autoScroll();
/** right and middle mouse button */
void rightButtonPressed( QListViewItem *, const QPoint &, int);
void mouseButtonPressed( int btn, QListViewItem *, const QPoint &, int);
protected:
/** Catch palette changes */
virtual bool event(QEvent *e);
@ -218,7 +200,6 @@ protected:
bool readIsListViewItemOpen(KMFolderTreeItem *fti);
void writeIsListViewItemOpen(KMFolderTreeItem *fti);
KMFolderNodeList mList;
QTimer mUpdateTimer;
static QPixmap *pixDir, *pixNode, *pixPlain, *pixFld, *pixFull, *pixIn,
*pixOut, *pixTr, *pixSent;
@ -226,7 +207,7 @@ protected:
/** We need out own root, otherwise the @ref QListView will create
its own root of type @ref QListViewItem, hence no overriding
paintBranches and no backing pixmap */
QListViewItem *root;
KMFolderTreeItem *root;
/** Drag and drop methods */
void contentsDragEnterEvent( QDragEnterEvent *e );
@ -245,42 +226,35 @@ protected:
QListViewItem *dropItem;
KMFolderTreeItem *mLastItem;
QTimer autoopen_timer;
KMPaintInfo mPaintInfo;
// filter some rmb-events
// bool eventFilter(QObject*, QEvent*);
bool eventFilter(QObject*, QEvent*);
virtual void drawContentsOffset( QPainter * p, int ox, int oy,
int cx, int cy, int cw, int ch );
/** open ancestors and ensure item is visible */
void prepareItem( KMFolderTreeItem* );
/** connect all signals */
void connectSignals();
// ########### The Trolls may move this Drag and drop stuff to QScrollView
private:
QTimer autoscroll_timer;
int autoscroll_time;
int autoscroll_accel;
CryptPlugWrapperList * mCryptPlugList;
/** unread and total column */
bool unreadIsActive;
bool totalIsActive;
QListViewItemIterator mUpdateIterator;
int unreadIndex;
int totalIndex;
/** popup for unread/total */
KPopupMenu* mPopup;
int mUnreadPop;
int mTotalPop;
// actions for D'n'D from Headers to Folder
int mActionWhenDnD;
int mActionWhenShiftDnD;
int mActionWhenCtrlDnD;
QTimer autoscroll_timer;
int autoscroll_time;
int autoscroll_accel;
CryptPlugWrapperList * mCryptPlugList;
public slots:
void startAutoScroll();
void stopAutoScroll();
protected slots:
void autoScroll();
void rightButtonPressed( QListViewItem *, const QPoint &, int);
void mouseButtonPressed( int btn, QListViewItem *, const QPoint &, int);
/** total column */
QListViewItemIterator mUpdateIterator;
/** popup for unread/total */
KPopupMenu* mPopup;
int mUnreadPop;
int mTotalPop;
/** show popup after D'n'D? */
bool mShowPopupAfterDnD;
};
#endif

@ -82,24 +82,6 @@ QIconSet* KMHeaders::down = 0;
bool KMHeaders::mTrue = true;
bool KMHeaders::mFalse = false;
//-----------------------------------------------------------------------------
// KMHeaderToFolderDrag method definitions
QPixmap* KMHeaderToFolderDrag::dragPix = 0;
KMHeaderToFolderDrag::KMHeaderToFolderDrag( QWidget * parent,
const char * name )
: QStoredDrag( "KMHeaderToFolderDrag/magic", parent, name )
{
dragPix = new QPixmap( DesktopIcon("message",
KIcon::SizeMedium ) );
setPixmap( *dragPix );
}
bool KMHeaderToFolderDrag::canDecode( QDropEvent* e )
{
return e->provides( "KMHeaderToFolderDrag/magic" );
}
//-----------------------------------------------------------------------------
// KMHeaderItem method definitions
@ -381,7 +363,7 @@ public:
_cg.setColor( QColorGroup::Text, c );
}
static QString generate_key( int id, KMHeaders *headers, KMMsgBase *msg, const KMPaintInfo *paintInfo, int sortOrder)
static QString generate_key( int id, KMHeaders *headers, KMMsgBase *msg, const KPaintInfo *paintInfo, int sortOrder)
{
// It appears, that QListView in Qt-3.0 asks for the key
// in QListView::clear(), which is called from
@ -609,10 +591,10 @@ KMHeaders::~KMHeaders ()
bool KMHeaders::eventFilter ( QObject *o, QEvent *e )
{
if ( e->type() == QEvent::MouseButtonPress &&
dynamic_cast<QMouseEvent*>(e)->button() == RightButton &&
static_cast<QMouseEvent*>(e)->button() == RightButton &&
o->isA("QHeader") )
{
mPopup->popup( mapToGlobal( header()->geometry().center() ) );
mPopup->popup( static_cast<QMouseEvent*>(e)->globalPos() );
return true;
}
return KListView::eventFilter(o, e);
@ -742,16 +724,6 @@ void KMHeaders::readConfig (void)
KConfigGroupSaver saver(config, "Behaviour");
mLoopOnGotoUnread = config->readBoolEntry( "LoopOnGotoUnread", true );
mJumpToUnread = config->readBoolEntry( "JumpToUnread", false );
// read D'n'D behavior settings
mActionWhenDnD = config->readNumEntry("DnD_action_normal", KMMsgDnDActionASK );
if ( mActionWhenDnD < 0 || mActionWhenDnD > 2 )
mActionWhenDnD = KMMsgDnDActionASK;
mActionWhenShiftDnD = config->readNumEntry("DnD_action_SHIFT", KMMsgDnDActionMOVE );
if ( mActionWhenShiftDnD < 0 || mActionWhenShiftDnD > 2 )
mActionWhenShiftDnD = KMMsgDnDActionMOVE;
mActionWhenCtrlDnD = config->readNumEntry("DnD_action_CTRL", KMMsgDnDActionCOPY );
if ( mActionWhenCtrlDnD < 0 || mActionWhenCtrlDnD > 2 )
mActionWhenCtrlDnD = KMMsgDnDActionCOPY;
}
restoreLayout(config, "Header-Geometry");
@ -1968,7 +1940,7 @@ void KMHeaders::copyMsgToFolder(KMFolder* destFolder,
// copy the message(s); note: the list is empty afterwards!
KMFolderImap *imapDestFolder = static_cast<KMFolderImap*>(destFolder);
imapDestFolder->copyMsg(list);
if (imapDestFolder->isSelected()) imapDestFolder->getFolder();
imapDestFolder->getFolder();
}
destFolder->close();
@ -2612,30 +2584,27 @@ void KMHeaders::contentsMouseMoveEvent( QMouseEvent* e )
mousePressed = FALSE;
QListViewItem *item = itemAt( contentsToViewport(presspos) );
if ( item ) {
KMHeaderToFolderDrag* d = new KMHeaderToFolderDrag(viewport());
const ButtonState keybstate = e->state();
int actionSettings;
if ( keybstate & Qt::ControlButton )
actionSettings = mActionWhenCtrlDnD;
else if ( keybstate & Qt::ShiftButton )
actionSettings = mActionWhenShiftDnD;
QDragObject *d = new QStoredDrag("x-kmail-drag/message", viewport());
// Are multiple messages selected?
unsigned int count = 0;
for( QListViewItemIterator it(this); (it.current() && count < 2); it++ )
if( it.current()->isSelected() )
count++;
// Set pixmap
QPixmap pixmap;
if( count == 1 )
pixmap = QPixmap( DesktopIcon("message", KIcon::SizeSmall) );
else
actionSettings = mActionWhenDnD;
switch ( actionSettings ) {
case KMMsgDnDActionMOVE:
d->dragMove();
break;
case KMMsgDnDActionCOPY:
d->dragCopy();
break;
default:
// We will ASK the user via PopUp menu.
// But we _must_ call dragMove() since otherwise Qt will
// show the '+' indicator if CTRL key is hold down even if
// our KMail user has specified /not/ to copy via CRTL+D'n'D.
d->dragMove();
pixmap = QPixmap( DesktopIcon("kmultiple", KIcon::SizeSmall) );
// Calculate hotspot (as in Konqueror)
if( !pixmap.isNull() ) {
QPoint hotspot( pixmap.width() / 2, pixmap.height() / 2 );
d->setPixmap( pixmap, hotspot );
}
d->drag();
}
}
}
@ -2683,9 +2652,9 @@ void KMHeaders::slotRMB()
mOwner->updateMessageMenu();
QPopupMenu *msgMoveMenu = new QPopupMenu(menu);
mOwner->folderToPopupMenu( NULL, TRUE, this, &mMenuToFolder, msgMoveMenu );
mOwner->folderToPopupMenu( TRUE, this, &mMenuToFolder, msgMoveMenu );
QPopupMenu *msgCopyMenu = new QPopupMenu(menu);
mOwner->folderToPopupMenu( NULL, FALSE, this, &mMenuToFolder, msgCopyMenu );
mOwner->folderToPopupMenu( FALSE, this, &mMenuToFolder, msgCopyMenu );
bool out_folder = kernel->folderIsDraftOrOutbox(mFolder);
if ( out_folder )

@ -4,6 +4,7 @@
#include <qwidget.h>
#include <qstrlist.h>
#include <klistview.h>
#include <kfoldertree.h>
#include <qmemarray.h>
#include <qmap.h>
#include <qdragobject.h>
@ -28,43 +29,6 @@ class KMScoringManager;
typedef QPtrList<KMMsgBase> KMMessageList;
typedef QMap<int,KMFolder*> KMMenuToFolder;
/** A special drag class for header list to folder tree DnD operations */
class KMHeaderToFolderDrag: public QStoredDrag {
public:
KMHeaderToFolderDrag( QWidget * parent = 0, const char * name = 0 );
~KMHeaderToFolderDrag() {};
static bool canDecode( QDropEvent* e );
protected:
static QPixmap *dragPix;
};
/** Information shared by all items in a list view */
struct KMPaintInfo {
bool pixmapOn;
QPixmap pixmap;
QColor colFore;
QColor colBack;
QColor colNew;
QColor colUnread;
QColor colFlag;
bool showSize; // Do we display the message size?
#ifdef SCORING
bool showScore;
#endif
bool orderOfArrival;
bool status;
int flagCol;
int senderCol;
int subCol;
int dateCol;
#ifdef SCORING
int scoreCol;
#endif
int sizeCol;
bool showCryptoIcons;
};
/** The widget that shows the contents of folders */
#define KMHeadersInherited KListView
class KMHeaders : public KListView
@ -148,7 +112,7 @@ public:
KMMainWin* owner(void) const { return mOwner; }
/** PaintInfo pointer */
const KMPaintInfo *paintInfo(void) const { return &mPaintInfo; }
const KPaintInfo *paintInfo(void) const { return &mPaintInfo; }
/** Read config options. */
virtual void readConfig(void);
@ -374,7 +338,7 @@ private:
/** For shift selection */
QListViewItem *beginSelection, *endSelection;
/** Current colours and backing pixmap */
KMPaintInfo mPaintInfo;
KPaintInfo mPaintInfo;
#ifdef SCORING
KMScoringManager *mScoringManager;
@ -407,10 +371,6 @@ private:
KMime::DateFormatter mDate;
/** value of config key Behaviour/LoopOnGotoUnread */
bool mLoopOnGotoUnread;
// actions for D'n'D from Headers to Folder
int mActionWhenDnD;
int mActionWhenShiftDnD;
int mActionWhenCtrlDnD;
bool mJumpToUnread;
/** popup to switch columns */

@ -287,34 +287,27 @@ void KMMainWin::readConfig(void)
mPanner1Sep[1] = width() - siz.height();
}
if (!mStartupDone)
if (!mStartupDone ||
oldWindowLayout != mWindowLayout ||
oldShowMIMETreeMode != mShowMIMETreeMode )
{
/** unread / total columns */
// get the number (aka section) of the column; -1 is de-activated
int unreadColumn = config->readNumEntry("UnreadColumn", -1);
/** unread / total columns
* as we have some dependencies in this widget
* it's better to manage these here */
int unreadColumn = config->readNumEntry("UnreadColumn", -1);
int totalColumn = config->readNumEntry("TotalColumn", -1);
// activate them
if (unreadColumn != -1) {
/* we need to _activate_ them in the correct order
* this is ugly because we can't use header()->moveSection
* but otherwise the restoreLayout from KMFolderTree
* doesn't know that to do */
if (unreadColumn != -1 && unreadColumn < totalColumn)
mFolderTree->toggleColumn(KMFolderTree::unread);
mFolderTree->setColumnWidth(mFolderTree->getUnreadColumnNumber(), config->readNumEntry("UnreadColumnWidth"));
}
if (totalColumn != -1) {
if (totalColumn != -1)
mFolderTree->toggleColumn(KMFolderTree::total);
mFolderTree->setColumnWidth(mFolderTree->getTotalColumnNumber(), config->readNumEntry("TotalColumnWidth"));
}
// get the correct order back
if (totalColumn < unreadColumn && totalColumn != -1)
mFolderTree->header()->moveSection(2, 1);
// resize the folder column
int foldercolumnsize = config->readNumEntry("FolderColumnWidth", -1);
if (foldercolumnsize == -1) // first start
foldercolumnsize = config->readNumEntry("FolderPaneWidth", 160);
mFolderTree->setColumnWidth(0, foldercolumnsize);
/** unread/total end */
if (unreadColumn != -1 && unreadColumn > totalColumn)
mFolderTree->toggleColumn(KMFolderTree::unread);
}
}
@ -434,22 +427,9 @@ void KMMainWin::writeConfig(void)
break;
}
// width of the folder-column (needed if unread/total-column is active
config->writeEntry("FolderColumnWidth", mFolderTree->columnWidth(0));
// save the state of the unread/total-columns
if (mFolderTree->isUnreadActive())
{
config->writeEntry("UnreadColumn", mFolderTree->getUnreadColumnNumber());
config->writeEntry("UnreadColumnWidth", mFolderTree->columnWidth(mFolderTree->getUnreadColumnNumber()));
} else
config->writeEntry("UnreadColumn", -1);
if (mFolderTree->isTotalActive())
{
config->writeEntry("TotalColumn", mFolderTree->getTotalColumnNumber());
config->writeEntry("TotalColumnWidth", mFolderTree->columnWidth(mFolderTree->getTotalColumnNumber()));
} else
config->writeEntry("TotalColumn", -1);
config->writeEntry("UnreadColumn", mFolderTree->unreadIndex());
config->writeEntry("TotalColumn", mFolderTree->totalIndex());
}
@ -598,7 +578,7 @@ void KMMainWin::createWidgets(void)
// create a mime part tree and store it's pointer in the reader win
mMimePartTree = new KMMimePartTree( mMsgView, mimeParent, "mMimePartTree" );
mMsgView->setMimePartTree( mMimePartTree );
if( 0 < mShowMIMETreeMode )
if( 1 < mShowMIMETreeMode )
mMimePartTree->show();
else
mMimePartTree->hide();
@ -689,7 +669,7 @@ void KMMainWin::activatePanners(void)
break;
}
if( 0 < mShowMIMETreeMode )
if( 1 < mShowMIMETreeMode )
mMimePartTree->show();
else
mMimePartTree->hide();
@ -1727,8 +1707,12 @@ void KMMainWin::folderSelected(KMFolder* aFolder, bool jumpToUnread)
kernel->kbp()->busy();
if( !aFolder && mFolderTree->currentItem() == mFolderTree->firstChild() ) {
slotIntro();
if( !aFolder || aFolder->noContent() ||
aFolder->count() == 0 )
{
mMsgView->setMsg( 0, FALSE );
if( mMimePartTree )
mMimePartTree->hide();
} else if( !mFolder ) {
mMsgView->enableMsgDisplay();
mMsgView->setMsg( 0, TRUE );
@ -3195,8 +3179,7 @@ void KMMainWin::copySelectedToFolder(int menuId )
//-----------------------------------------------------------------------------
QPopupMenu* KMMainWin::folderToPopupMenu(KMFolderTreeItem* fti,
bool move,
QPopupMenu* KMMainWin::folderToPopupMenu(bool move,
QObject *receiver,
KMMenuToFolder *aMenuToFolder,
QPopupMenu *menu )
@ -3210,7 +3193,29 @@ QPopupMenu* KMMainWin::folderToPopupMenu(KMFolderTreeItem* fti,
menu->removeItemAt( 0 );
}
if (!fti) fti = static_cast<KMFolderTreeItem*>(mFolderTree->firstChild());
for (QListViewItem *item = mFolderTree->firstChild();
item; item = item->nextSibling())
{
// operate on top-level items
QString label = item->text(0);
// make a new Submenu
QPopupMenu* subMenu = new QPopupMenu(menu);
subMenu = makeFolderMenu(dynamic_cast<KMFolderTreeItem*>(item),
move, receiver, aMenuToFolder, subMenu);
menu->insertItem( label, subMenu );
}
return menu;
}
//-----------------------------------------------------------------------------
QPopupMenu* KMMainWin::makeFolderMenu(KMFolderTreeItem* item,
bool move,
QObject *receiver,
KMMenuToFolder *aMenuToFolder,
QPopupMenu *menu )
{
// connect the signals
if (move)
{
disconnect(menu, SIGNAL(activated(int)), receiver,
@ -3224,48 +3229,55 @@ QPopupMenu* KMMainWin::folderToPopupMenu(KMFolderTreeItem* fti,
SLOT(copySelectedToFolder(int)));
}
if (fti->folder && !fti->folder->isDir())
if (item->folder() && !item->folder()->isDir()
&& !item->folder()->noContent())
{
int menuId;
if (move)
menuId = menu->insertItem(i18n("Move to this Folder"));
else
menuId = menu->insertItem(i18n("Copy to this Folder"));
aMenuToFolder->insert( menuId, fti->folder );
menu->insertSeparator();
int menuId;
if (move)
menuId = menu->insertItem(i18n("Move to this Folder"));
else
menuId = menu->insertItem(i18n("Copy to this Folder"));
aMenuToFolder->insert( menuId, item->folder() );
menu->insertSeparator();
}
fti = static_cast<KMFolderTreeItem*>(fti->firstChild());
while (fti)
for (QListViewItem *it = item->firstChild();
it; it = it->nextSibling())
{
if (fti->folder)
KMFolderTreeItem* fti = dynamic_cast<KMFolderTreeItem*>(it);
if (fti->folder())
{
QString label = fti->text(0);
label.replace(QRegExp("&"),QString("&&"));
if (fti->firstChild())
{
QPopupMenu *subMenu = folderToPopupMenu(fti, move, receiver,
// descend
QPopupMenu *subMenu = makeFolderMenu(fti, move, receiver,
aMenuToFolder,
new QPopupMenu(menu, "subMenu"));
menu->insertItem(label, subMenu);
} else
if (!fti->folder->isDir())
{
int menuId = menu->insertItem(label);
aMenuToFolder->insert( menuId, fti->folder );
} else {
// insert an item
if (!fti->folder()->isDir())
{
int menuId = menu->insertItem(label);
aMenuToFolder->insert( menuId, fti->folder() );
}
}
}
fti = static_cast<KMFolderTreeItem*>(fti->nextSibling());
}
return menu;
}
//-----------------------------------------------------------------------------
void KMMainWin::updateMessageMenu()
{
mMenuToFolder.clear();
folderToPopupMenu( 0, true, this, &mMenuToFolder, moveActionMenu->popupMenu() );
folderToPopupMenu( 0, false, this, &mMenuToFolder, copyActionMenu->popupMenu() );
folderToPopupMenu( true, this, &mMenuToFolder, moveActionMenu->popupMenu() );
folderToPopupMenu( false, this, &mMenuToFolder, copyActionMenu->popupMenu() );
updateMessageActions();
}
@ -3596,7 +3608,6 @@ void KMMainWin::slotTransferCancelled()
void KMMainWin::slotIntro() {
if ( !mFolderTree || !mMsgView ) return;
// ### select "Mail" in folder tree until Carsten Burghard removes it.
if ( !mFolderTree->firstChild() ) return;
if ( mFolderTree->currentItem() != mFolderTree->firstChild() ) // don't loop
mFolderTree->doFolderSelected( mFolderTree->firstChild() );

@ -79,8 +79,12 @@ public:
be moved into the given folder, otherwise messages will be
copied.
Am empty @ref KMMenuToFolder must be passed in. */
virtual QPopupMenu* folderToPopupMenu(KMFolderTreeItem* fti,
bool move,
virtual QPopupMenu* folderToPopupMenu(bool move,
QObject *receiver,
KMMenuToFolder *aMenuToFolder,
QPopupMenu *menu);
QPopupMenu* makeFolderMenu(KMFolderTreeItem* item,
bool move,
QObject *receiver,
KMMenuToFolder *aMenuToFolder,
QPopupMenu *menu);

Loading…
Cancel
Save