equal
deleted
inserted
replaced
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef AUTOSAVER_H |
|
21 #define AUTOSAVER_H |
|
22 |
|
23 #include <QtCore/QObject> |
|
24 #include <QtCore/QBasicTimer> |
|
25 #include <QtCore/QTime> |
|
26 #include "wrttypes.h" |
|
27 |
|
28 namespace WRT { |
|
29 |
|
30 /* |
|
31 This class will call the save() slot on the parent object when the parent changes. |
|
32 It will wait several seconds after changed() to combining multiple changes and |
|
33 prevent continuous writing to disk. |
|
34 */ |
|
35 class AutoSaver : public QObject { |
|
36 |
|
37 Q_OBJECT |
|
38 |
|
39 public: |
|
40 AutoSaver(QObject *parent); |
|
41 ~AutoSaver(); |
|
42 virtual void saveIfNeccessary()=0; |
|
43 |
|
44 public slots: |
|
45 void changeOccurred(); |
|
46 |
|
47 protected: |
|
48 void timerEvent(QTimerEvent *event); |
|
49 |
|
50 protected: |
|
51 QBasicTimer m_timer; |
|
52 QTime m_firstChange; |
|
53 }; |
|
54 |
|
55 class BookmarkAutoSaver : public AutoSaver { |
|
56 |
|
57 Q_OBJECT |
|
58 |
|
59 public: |
|
60 BookmarkAutoSaver(QObject *parent); |
|
61 ~BookmarkAutoSaver(); |
|
62 void saveIfNeccessary(); |
|
63 }; |
|
64 |
|
65 |
|
66 class HistoryAutoSaver : public AutoSaver { |
|
67 |
|
68 Q_OBJECT |
|
69 |
|
70 public: |
|
71 HistoryAutoSaver(QObject *parent); |
|
72 ~HistoryAutoSaver(); |
|
73 void saveIfNeccessary(); |
|
74 }; |
|
75 |
|
76 } |
|
77 #endif // AUTOSAVER_H |
|
78 |
|