~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to kmail/searchwindow.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
 *
20
20
 */
21
 
#ifndef searchwindow_h
22
 
#define searchwindow_h
23
 
 
24
 
#include <QList>
25
 
#include <QPointer>
26
 
#include <QTimer>
27
 
#include <QTreeWidget>
28
 
 
29
 
#include <KDialog>
30
 
#include <KXMLGUIClient>
 
21
 
 
22
#ifndef KMAIL_SEARCHWINDOW_H
 
23
#define KMAIL_SEARCHWINDOW_H
 
24
 
 
25
#include "mailcommon/searchpattern.h"
 
26
 
 
27
#include <akonadi/collection.h>
 
28
#include <akonadi/item.h>
 
29
#include <kdialog.h>
 
30
#include <kxmlguiclient.h>
 
31
 
 
32
#include <QtCore/QTimer>
31
33
 
32
34
class QCheckBox;
33
35
class QCloseEvent;
35
37
class QLabel;
36
38
class QRadioButton;
37
39
class KActionMenu;
 
40
class KJob;
38
41
class KLineEdit;
39
 
class KMFolder;
40
 
class KMFolderSearch;
41
42
class KMMainWidget;
42
 
class KMMessage;
43
 
class KMMsgBase;
44
 
class KMSearchPattern;
45
 
class KMSearchPatternEdit;
46
43
class KStatusBar;
47
44
 
48
 
namespace KMail {
49
 
  class FolderRequester;
50
 
  class MatchListView;
 
45
namespace Akonadi {
 
46
class EntityTreeView;
 
47
class ItemModel;
 
48
class StandardMailActionManager;
 
49
}
 
50
 
 
51
namespace KMime {
 
52
class Message;
 
53
}
 
54
 
 
55
namespace MailCommon {
 
56
class FolderRequester;
 
57
class SearchPatternEdit;
51
58
}
52
59
 
53
60
namespace KMail {
62
69
{
63
70
  Q_OBJECT
64
71
 
65
 
public:
66
 
  /**
67
 
   * Creates a new search window.
68
 
   * @param parent The parent widget.
69
 
   * @param name The (widget) name of the dialog.
70
 
   * @param curFolder The folder which will be pre-selected as the base folder
71
 
   * of search operations.
72
 
   * @param modal Whether the dialog is to be shown modal.
73
 
   */
74
 
  explicit SearchWindow( KMMainWidget* parent, KMFolder *curFolder=0 );
75
 
  virtual ~SearchWindow();
76
 
 
77
 
  /**
78
 
   * Changes the base folder for search operations to a different folder.
79
 
   * @param curFolder The folder to use as the new base for searches.
80
 
   */
81
 
  void activateFolder( KMFolder* curFolder );
82
 
 
83
 
  /**
84
 
   * Provides access to the list of currently selected message in the listview.
85
 
   * @return The list of currently selected search result messages.
86
 
   */
87
 
  QList<KMMsgBase*> selectedMessages();
88
 
 
89
 
  /**
90
 
   * Provides access to the currently selected message.
91
 
   * @return the currently selected message.
92
 
   */
93
 
  KMMessage* message();
94
 
 
95
 
  void setSearchPattern( const KMSearchPattern &pattern );
96
 
protected:
97
 
  bool canMoveSelectedMessages();
98
 
 
99
 
protected slots:
100
 
  /** Update status line widget. */
101
 
  virtual void updStatus(void);
102
 
 
103
 
  virtual void slotClose();
104
 
  virtual void slotSearch();
105
 
  virtual void slotStop();
106
 
  void scheduleRename(const QString &);
107
 
  void renameSearchFolder();
108
 
  void openSearchFolder();
109
 
  void folderInvalidated(KMFolder *);
110
 
  virtual bool slotShowMsg(QTreeWidgetItem *,int);
111
 
  void slotViewSelectedMsg();
112
 
  virtual bool slotViewMsg( QTreeWidgetItem *, int );
113
 
  void slotCurrentChanged(QTreeWidgetItem *);
114
 
  virtual void updateContextMenuActions();
115
 
  virtual void slotContextMenuRequested( QTreeWidgetItem* );
116
 
  void slotCopySelectedMessagesToFolder( QAction* );
117
 
  void slotMoveSelectedMessagesToFolder( QAction* );
118
 
  virtual void slotFolderActivated();
119
 
  void slotClearSelection();
120
 
  void slotReplyToMsg();
121
 
  void slotReplyAllToMsg();
122
 
  void slotReplyListToMsg();
123
 
  void slotForwardMsg();
124
 
  void slotForwardAttachedMsg();
125
 
  void slotSaveMsg();
126
 
  void slotSaveAttachments();
127
 
  void slotPrintMsg();
128
 
  void slotCopyMsgs();
129
 
  void slotCutMsgs();
130
 
 
131
 
  /** GUI cleanup after search */
132
 
  virtual void searchDone();
133
 
  virtual void slotAddMsg(int idx);
134
 
  virtual void slotRemoveMsg(KMFolder *, quint32 serNum);
135
 
  void enableGUI();
136
 
 
137
 
  void setEnabledSearchButton(bool);
138
 
 
139
 
protected:
140
 
 
141
 
  /** Reimplemented to react to Escape. */
142
 
  virtual void keyPressEvent(QKeyEvent*);
143
 
 
144
 
  /** Reimplemented to stop searching when the window is closed */
145
 
  virtual void closeEvent(QCloseEvent*);
146
 
 
147
 
protected:
148
 
  bool mStopped;
149
 
  bool mCloseRequested;
150
 
  int mFetchingInProgress;
151
 
  int mSortColumn;
152
 
  Qt::SortOrder mSortOrder;
153
 
  QPointer<KMFolderSearch> mFolder;
154
 
  QTimer *mTimer;
155
 
 
156
 
  // GC'd by Qt
157
 
  QRadioButton *mChkbxAllFolders;
158
 
  QRadioButton *mChkbxSpecificFolders;
159
 
  KMail::FolderRequester *mCbxFolders;
160
 
  QCheckBox *mChkSubFolders;
161
 
  MatchListView* mLbxMatches;
162
 
  QLabel *mSearchFolderLbl;
163
 
  KLineEdit *mSearchFolderEdt;
164
 
  KPushButton *mSearchFolderOpenBtn;
165
 
  KPushButton *mSearchResultOpenBtn;
166
 
  KStatusBar* mStatusBar;
167
 
  QWidget* mLastFocus; // to remember the position of the focus
168
 
  QAction *mReplyAction, *mReplyAllAction, *mReplyListAction, *mSaveAsAction,
169
 
    *mForwardInlineAction, *mForwardAttachedAction, *mPrintAction, *mClearAction,
170
 
    *mSaveAtchAction, *mCopyAction, *mCutAction;
171
 
  KActionMenu *mForwardActionMenu;
172
 
  QList<QPointer<KMFolder> > mFolders;
173
 
  QTimer mRenameTimer;
174
 
 
175
 
  // not owned by us
176
 
  KMMainWidget* mKMMainWidget;
177
 
  KMSearchPatternEdit *mPatternEdit;
178
 
  KMSearchPattern *mSearchPattern;
179
 
 
180
 
  static const int MSGID_COLUMN;
181
 
 
182
 
private:
183
 
  KMMessage *indexToMessage( QTreeWidgetItem *item );
184
 
 
185
 
};
186
 
 
187
 
class SearchWidgetItem : public QTreeWidgetItem
188
 
{
189
 
public:
190
 
  SearchWidgetItem(QTreeWidget* parent);
191
 
  ~SearchWidgetItem();
192
 
  enum SearchWidgetItemType {
193
 
    dateItemType = Qt::UserRole + 1
194
 
  };
195
 
private:
196
 
  bool operator<(const QTreeWidgetItem &other)const;
197
 
 
198
 
};
199
 
 
200
 
// QTreeWidget sub-class for dnd support
201
 
// Internal, only used by SearchWindow.
202
 
class MatchListView : public QTreeWidget
203
 
{
204
 
  Q_OBJECT
205
 
 
206
72
  public:
207
 
    MatchListView( QWidget *parent, SearchWindow* sw );
 
73
    /**
 
74
     * Creates a new search window.
 
75
     *
 
76
     * @param parent The parent widget.
 
77
     * @param collection The folder which will be pre-selected as the base folder
 
78
     *                   of search operations.
 
79
     */
 
80
    explicit SearchWindow( KMMainWidget* parent, const Akonadi::Collection &collection = Akonadi::Collection() );
 
81
 
 
82
    /**
 
83
     * Destroys the search window.
 
84
     */
 
85
    virtual ~SearchWindow();
 
86
 
 
87
    /**
 
88
     * Changes the base folder for search operations to a different folder.
 
89
     *
 
90
     * @param folder The folder to use as the new base for searches.
 
91
     */
 
92
    void activateFolder( const Akonadi::Collection &folder );
 
93
 
 
94
    /**
 
95
     * Provides access to the list of currently selected message in the listview.
 
96
     *
 
97
     * @return The list of currently selected search result messages.
 
98
     */
 
99
    Akonadi::Item::List selectedMessages() const;
 
100
 
 
101
    /**
 
102
     * Provides access to the currently selected message.
 
103
     *
 
104
     * @return the currently selected message.
 
105
     */
 
106
    Akonadi::Item selectedMessage() const;
 
107
 
 
108
    /**
 
109
     * Loads a search pattern into the search window, replacing the current one.
 
110
     */
 
111
    void setSearchPattern( const MailCommon::SearchPattern &pattern );
 
112
 
 
113
    /**
 
114
     * Loads a search pattern into the search window, appending its rules to the current one.
 
115
     */
 
116
    void addRulesToSearchPattern( const MailCommon::SearchPattern &pattern );
208
117
 
209
118
  protected:
210
 
 
211
 
    virtual void contextMenuEvent( QContextMenuEvent* event );
212
 
    virtual void startDrag( Qt::DropActions supportedActions );
 
119
    /** Reimplemented to react to Escape. */
 
120
    virtual void keyPressEvent( QKeyEvent* );
 
121
 
 
122
    /** Reimplemented to stop searching when the window is closed */
 
123
    virtual void closeEvent( QCloseEvent* );
 
124
 
 
125
  private Q_SLOTS:
 
126
    virtual void updateStatusLine();
 
127
 
 
128
    void updateCollectionStatisticsFinished( KJob* );
 
129
 
 
130
    virtual void slotClose();
 
131
    virtual void slotSearch();
 
132
    virtual void slotStop();
 
133
    void scheduleRename( const QString& );
 
134
    void renameSearchFolder();
 
135
    void openSearchFolder();
 
136
    virtual bool slotShowMsg( const Akonadi::Item& );
 
137
    void slotViewSelectedMsg();
 
138
    virtual bool slotViewMsg( const Akonadi::Item& );
 
139
    void slotCurrentChanged( const Akonadi::Item& );
 
140
    virtual void updateContextMenuActions();
 
141
    virtual void slotFolderActivated();
 
142
    void slotClearSelection();
 
143
    void slotReplyToMsg();
 
144
    void slotReplyAllToMsg();
 
145
    void slotReplyListToMsg();
 
146
    void slotForwardMsg();
 
147
    void slotForwardAttachedMsg();
 
148
    void slotSaveMsg();
 
149
    void slotSaveAttachments();
 
150
    void slotPrintMsg();
 
151
 
 
152
    /** GUI cleanup after search */
 
153
    void searchDone( KJob* );
 
154
    void enableGUI();
 
155
 
 
156
    void setEnabledSearchButton( bool );
 
157
    void slotSearchFolderRenameDone( KJob* );
 
158
 
 
159
    void slotContextMenuRequested( const QPoint& );
213
160
 
214
161
  private:
215
 
    SearchWindow* mSearchWindow;
216
 
  signals:
217
 
    void contextMenuRequested( QTreeWidgetItem* item );
 
162
    bool mStopped;
 
163
    bool mCloseRequested;
 
164
    int mSortColumn;
 
165
    Qt::SortOrder mSortOrder;
 
166
    Akonadi::Collection mFolder;
 
167
    KJob *mSearchJob;
 
168
    QTimer *mTimer;
 
169
 
 
170
    // GC'd by Qt
 
171
    QRadioButton *mChkbxAllFolders;
 
172
    QRadioButton *mChkbxSpecificFolders;
 
173
    MailCommon::FolderRequester *mCbxFolders;
 
174
    QCheckBox *mChkSubFolders;
 
175
    Akonadi::ItemModel *mResultModel;
 
176
    Akonadi::EntityTreeView *mLbxMatches;
 
177
    QLabel *mSearchFolderLbl;
 
178
    KLineEdit *mSearchFolderEdt;
 
179
    KPushButton *mSearchFolderOpenBtn;
 
180
    KPushButton *mSearchResultOpenBtn;
 
181
    KStatusBar* mStatusBar;
 
182
    QWidget* mLastFocus; // to remember the position of the focus
 
183
    QAction *mReplyAction, *mReplyAllAction, *mReplyListAction, *mSaveAsAction,
 
184
      *mForwardInlineAction, *mForwardAttachedAction, *mPrintAction, *mClearAction,
 
185
      *mSaveAtchAction;
 
186
    KActionMenu *mForwardActionMenu;
 
187
    QTimer mRenameTimer;
 
188
    QByteArray mHeaderState;
 
189
    // not owned by us
 
190
    KMMainWidget* mKMMainWidget;
 
191
    MailCommon::SearchPatternEdit *mPatternEdit;
 
192
    MailCommon::SearchPattern mSearchPattern;
 
193
 
 
194
    Akonadi::StandardMailActionManager *mAkonadiStandardAction;
 
195
 
 
196
    static const int MSGID_COLUMN;
218
197
};
219
198
 
220
 
} // namespace KMail
221
 
#endif /*searchwindow_h*/
 
199
}
 
200
 
 
201
#endif