1 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net>
3 This file is part of the Trojita Qt IMAP e-mail client,
4 http://trojita.flaska.net/
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of
9 the License or (at your option) version 3 or any later version
10 accepted by the membership of KDE e.V. (or its successor approved
11 by the membership of KDE e.V.), which shall act as a proxy
12 defined in Section 14 of version 3 of the license.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include <QHeaderView>
27 #include "Imap/Model/FavoriteTagsModel.h"
33 class PrettyMsgListModel
;
39 /** @short A slightly tweaked QTreeView optimized for showing a list of messages in one mailbox
41 The optimizations (or rather modifications) include:
42 - automatically expanding a whole subtree when root item is expanded
43 - setting up reasonable size hints for all columns
45 class MsgListView
: public QTreeView
49 explicit MsgListView(QWidget
*parent
, Imap::Mailbox::FavoriteTagsModel
*m_favoriteTagsModel
);
50 virtual ~MsgListView() {}
51 void setModel(QAbstractItemModel
*model
);
52 void setAutoActivateAfterKeyNavigation(bool enabled
);
53 void updateActionsAfterRestoredState();
54 virtual int sizeHintForColumn(int column
) const;
55 QHeaderView::ResizeMode
resizeModeForColumn(const int column
) const;
57 void keyPressEvent(QKeyEvent
*ke
);
58 void keyReleaseEvent(QKeyEvent
*ke
);
59 virtual void startDrag(Qt::DropActions supportedActions
);
60 bool event(QEvent
*event
);
61 /** @short Returns a list of all selected and related (collapsed) message indexes for column 0 */
62 QModelIndexList
selectedTree() const;
65 /** @short Expand all items below current root index */
66 void slotExpandWholeSubtree(const QModelIndex
&rootIndex
);
67 /** @short Update header actions for showing/hiding columns */
68 void slotUpdateHeaderActions();
69 /** @short Show/hide a corresponding column */
70 void slotHeaderSectionVisibilityToggled(int section
);
71 /** @short Get ThreadingMsgListModel index and call the next handler */
72 void slotMsgListModelRowsAboutToBeRemoved(const QModelIndex
&parent
, int start
, int end
);
73 /** @short Keep the cursor in place for better keyboard usability */
74 void slotThreadingMsgListModelRowAboutToBeRemoved(const QModelIndex
&index
);
75 /** @short Pick up the change of the sort critera */
76 void slotHandleSortCriteriaChanged(int column
, Qt::SortOrder order
);
77 /** @short conditionally emits activated(currentIndex()) for keyboard events */
78 void slotCurrentActivated();
79 void slotHandleNewColumns(int oldCount
, int newCount
);
81 /** @short Try to move the cursor to next message */
82 void setCurrentIndexToNextValid(const QModelIndex
¤t
);
83 static Imap::Mailbox::PrettyMsgListModel
*findPrettyMsgListModel(QAbstractItemModel
*model
);
85 QSignalMapper
*headerFieldsMapper
;
86 QTimer
*m_naviActivationTimer
;
87 bool m_autoActivateAfterKeyNavigation
;
88 bool m_autoResizeSections
;
90 friend class MainWindow
; // needs access to slotHandleNewColumns
95 #endif // MSGLISTVIEW_H