Lines 1-5
Link Here
|
1 |
--- src/mymodel.cpp.orig 2012-03-09 05:00:54.000000000 -0600 |
1 |
--- src/mymodel.cpp.orig 2012-07-11 18:21:24.302333223 -0500 |
2 |
+++ src/mymodel.cpp 2012-04-29 16:13:57.725169164 -0500 |
2 |
+++ src/mymodel.cpp 2012-07-11 18:59:06.428956406 -0500 |
3 |
@@ -21,7 +21,6 @@ |
3 |
@@ -21,7 +21,6 @@ |
4 |
|
4 |
|
5 |
#include <mainwindow.h> |
5 |
#include <mainwindow.h> |
Lines 8-26
Link Here
|
8 |
#include <unistd.h> |
8 |
#include <unistd.h> |
9 |
#include <sys/ioctl.h> |
9 |
#include <sys/ioctl.h> |
10 |
|
10 |
|
11 |
@@ -63,9 +62,8 @@ myModel::myModel(bool realMime) |
11 |
@@ -63,10 +62,8 @@ myModel::myModel(bool realMime) |
12 |
|
12 |
|
13 |
iconFactory = new QFileIconProvider(); |
13 |
iconFactory = new QFileIconProvider(); |
14 |
|
14 |
|
15 |
- inotifyFD = inotify_init(); |
15 |
- inotifyFD = inotify_init(); |
16 |
- notifier = new QSocketNotifier(inotifyFD, QSocketNotifier::Read, this); |
16 |
- notifier = new QSocketNotifier(inotifyFD, QSocketNotifier::Read, this); |
17 |
- connect(notifier, SIGNAL(activated(int)), this, SLOT(notifyChange())); |
17 |
- connect(notifier, SIGNAL(activated(int)), this, SLOT(notifyChange())); |
|
|
18 |
- connect(&eventTimer,SIGNAL(timeout()),this,SLOT(eventTimeout())); |
18 |
+ watcher = new QFileSystemWatcher(this); |
19 |
+ watcher = new QFileSystemWatcher(this); |
19 |
+ connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(notifyChange(QString))); |
20 |
+ connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(notifyChange(QString))); |
20 |
|
21 |
|
21 |
realMimeTypes = realMime; |
22 |
realMimeTypes = realMime; |
22 |
} |
23 |
} |
23 |
@@ -188,28 +186,9 @@ QString myModel::getMimeType(const QMode |
24 |
@@ -189,62 +186,9 @@ QString myModel::getMimeType(const QMode |
24 |
} |
25 |
} |
25 |
|
26 |
|
26 |
//--------------------------------------------------------------------------------------- |
27 |
//--------------------------------------------------------------------------------------- |
Lines 44-81
Link Here
|
44 |
- |
45 |
- |
45 |
- int w = event->wd; |
46 |
- int w = event->wd; |
46 |
- |
47 |
- |
47 |
- if(watchers.contains(w)) |
48 |
- if(eventTimer.isActive()) |
48 |
- { |
49 |
- { |
49 |
- myModelItem *parent = rootItem->matchPath(watchers.value(w).split(SEPARATOR)); |
50 |
- if(w == lastEventID) |
50 |
+ myModelItem *parent = rootItem->matchPath(path.split(SEPARATOR)); |
51 |
- eventTimer.start(40); |
51 |
|
52 |
- else |
52 |
if(parent) |
53 |
- { |
53 |
{ |
54 |
- eventTimer.stop(); |
54 |
@@ -230,9 +209,7 @@ void myModel::notifyChange() |
55 |
- notifyProcess(lastEventID); |
55 |
//must of been deleted, remove from model |
56 |
- lastEventID = w; |
56 |
if(child->fileInfo().isDir()) |
57 |
- eventTimer.start(40); |
57 |
{ |
58 |
- } |
58 |
- int wd = watchers.key(child->absoluteFilePath()); |
59 |
- } |
59 |
- inotify_rm_watch(inotifyFD,wd); |
60 |
- else |
60 |
- watchers.remove(wd); |
61 |
- { |
61 |
+ watcher->removePath(child->absoluteFilePath()); |
62 |
- lastEventID = w; |
62 |
} |
63 |
- eventTimer.start(40); |
63 |
beginRemoveRows(index(parent->absoluteFilePath()),child->childNumber(),child->childNumber()); |
|
|
64 |
parent->removeChild(child); |
65 |
@@ -249,23 +226,17 @@ void myModel::notifyChange() |
66 |
} |
67 |
else |
68 |
{ |
69 |
- inotify_rm_watch(inotifyFD,w); |
70 |
- watchers.remove(w); |
71 |
+ watcher->removePath(path); |
72 |
} |
73 |
- } |
64 |
- } |
74 |
- |
65 |
- |
75 |
- at += sizeof(inotify_event) + event->len; |
66 |
- at += sizeof(inotify_event) + event->len; |
76 |
- } |
67 |
- } |
77 |
- |
68 |
- |
78 |
- notifier->setEnabled(1); |
69 |
- notifier->setEnabled(1); |
|
|
70 |
-} |
71 |
- |
72 |
-//--------------------------------------------------------------------------------------- |
73 |
-void myModel::eventTimeout() |
74 |
-{ |
75 |
- notifyProcess(lastEventID); |
76 |
- eventTimer.stop(); |
77 |
-} |
78 |
- |
79 |
-//--------------------------------------------------------------------------------------- |
80 |
-void myModel::notifyProcess(int eventID) |
81 |
-{ |
82 |
- if(watchers.contains(eventID)) |
83 |
- { |
84 |
- myModelItem *parent = rootItem->matchPath(watchers.value(eventID).split(SEPARATOR)); |
85 |
+ myModelItem *parent = rootItem->matchPath(path.split(SEPARATOR)); |
86 |
|
87 |
if(parent) |
88 |
{ |
89 |
@@ -265,9 +209,7 @@ void myModel::notifyProcess(int eventID) |
90 |
//must of been deleted, remove from model |
91 |
if(child->fileInfo().isDir()) |
92 |
{ |
93 |
- int wd = watchers.key(child->absoluteFilePath()); |
94 |
- inotify_rm_watch(inotifyFD,wd); |
95 |
- watchers.remove(wd); |
96 |
+ watcher->removePath(child->absoluteFilePath()); |
97 |
} |
98 |
beginRemoveRows(index(parent->absoluteFilePath()),child->childNumber(),child->childNumber()); |
99 |
parent->removeChild(child); |
100 |
@@ -282,20 +224,19 @@ void myModel::notifyProcess(int eventID) |
101 |
endInsertRows(); |
102 |
} |
103 |
} |
104 |
- } |
105 |
- else |
106 |
- { |
107 |
- inotify_rm_watch(inotifyFD,eventID); |
108 |
- watchers.remove(eventID); |
109 |
- } |
110 |
+ else |
111 |
+ { |
112 |
+ watcher->removePath(path); |
113 |
+ } |
79 |
} |
114 |
} |
80 |
|
115 |
|
81 |
//--------------------------------------------------------------------------------- |
116 |
//--------------------------------------------------------------------------------- |
Lines 90-96
Link Here
|
90 |
item->watched = 1; |
125 |
item->watched = 1; |
91 |
item = item->parent(); |
126 |
item = item->parent(); |
92 |
} |
127 |
} |
93 |
@@ -278,7 +249,7 @@ bool myModel::setRootPath(const QString& |
128 |
@@ -308,7 +249,7 @@ bool myModel::setRootPath(const QString& |
94 |
|
129 |
|
95 |
myModelItem *item = rootItem->matchPath(path.split(SEPARATOR)); |
130 |
myModelItem *item = rootItem->matchPath(path.split(SEPARATOR)); |
96 |
|
131 |
|
Lines 99-105
Link Here
|
99 |
|
134 |
|
100 |
if(item->walked == 0) |
135 |
if(item->walked == 0) |
101 |
{ |
136 |
{ |
102 |
@@ -352,10 +323,7 @@ void myModel::refresh() |
137 |
@@ -382,10 +323,7 @@ void myModel::refresh() |
103 |
{ |
138 |
{ |
104 |
myModelItem *item = rootItem->matchPath(QStringList("/")); |
139 |
myModelItem *item = rootItem->matchPath(QStringList("/")); |
105 |
|
140 |
|
Lines 111-117
Link Here
|
111 |
|
146 |
|
112 |
beginResetModel(); |
147 |
beginResetModel(); |
113 |
item->clearAll(); |
148 |
item->clearAll(); |
114 |
@@ -811,9 +779,7 @@ bool myModel::remove(const QModelIndex & |
149 |
@@ -840,9 +778,7 @@ bool myModel::remove(const QModelIndex & |
115 |
QFileInfo info(children.at(i)); |
150 |
QFileInfo info(children.at(i)); |
116 |
if(info.isDir()) |
151 |
if(info.isDir()) |
117 |
{ |
152 |
{ |