Changeset View
Changeset View
Standalone View
Standalone View
src/core-impl/logger/ProxyLogger.cpp
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 74 | { | |||
---|---|---|---|---|---|
75 | QMutexLocker locker( &m_lock ); | 75 | QMutexLocker locker( &m_lock ); | ||
76 | LongMessage msg; | 76 | LongMessage msg; | ||
77 | msg.first = text; | 77 | msg.first = text; | ||
78 | msg.second = type; | 78 | msg.second = type; | ||
79 | m_longMessageQueue.enqueue( msg ); | 79 | m_longMessageQueue.enqueue( msg ); | ||
80 | emit startTimer(); | 80 | emit startTimer(); | ||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | void | 83 | void ProxyLogger::newProgressOperationImpl( KJob* job, const QString& text, QObject* context, const std::function<void ()> &function, Qt::ConnectionType type ) | ||
84 | ProxyLogger::newProgressOperation( KJob *job, const QString &text, QObject *obj, const char *slot, Qt::ConnectionType type ) | | |||
85 | { | 84 | { | ||
86 | QMutexLocker locker( &m_lock ); | 85 | QMutexLocker locker( &m_lock ); | ||
87 | ProgressData data; | 86 | ProgressData data; | ||
88 | data.job = job; | 87 | data.job = job; | ||
89 | data.text = text; | 88 | data.text = text; | ||
90 | data.cancelObject = obj; | 89 | data.cancelObject = context; | ||
91 | data.slot = slot; | 90 | data.function = function; | ||
92 | data.type = type; | 91 | data.type = type; | ||
93 | m_progressQueue.enqueue( data ); | 92 | m_progressQueue.enqueue( data ); | ||
94 | emit startTimer(); | 93 | emit startTimer(); | ||
95 | } | 94 | } | ||
96 | 95 | | |||
97 | void | 96 | void | ||
98 | ProxyLogger::newProgressOperation( QNetworkReply *reply, const QString &text, QObject *obj, const char *slot, Qt::ConnectionType type ) | 97 | ProxyLogger::newProgressOperationImpl( QNetworkReply *reply, const QString &text, QObject *obj, const std::function<void ()> &function, Qt::ConnectionType type ) | ||
99 | { | 98 | { | ||
100 | QMutexLocker locker( &m_lock ); | 99 | QMutexLocker locker( &m_lock ); | ||
101 | ProgressData data; | 100 | ProgressData data; | ||
102 | data.reply = reply; | 101 | data.reply = reply; | ||
103 | data.text = text; | 102 | data.text = text; | ||
104 | data.cancelObject = obj; | 103 | data.cancelObject = obj; | ||
105 | data.slot = slot; | 104 | data.function = function; | ||
106 | data.type = type; | 105 | data.type = type; | ||
107 | m_progressQueue.enqueue( data ); | 106 | m_progressQueue.enqueue( data ); | ||
108 | emit startTimer(); | 107 | emit startTimer(); | ||
109 | } | 108 | } | ||
110 | 109 | | |||
111 | void | 110 | void | ||
112 | ProxyLogger::newProgressOperation( QObject *sender, const QString &text, int maximum, QObject *obj, | 111 | ProxyLogger::newProgressOperationImpl( QObject *sender, const QMetaMethod &increment, const QMetaMethod &end, const QString &text, | ||
113 | const char *slot, Qt::ConnectionType type ) | 112 | int maximum, QObject *obj, const std::function<void ()> &function, Qt::ConnectionType type ) | ||
114 | { | 113 | { | ||
115 | QMutexLocker locker( &m_lock ); | 114 | QMutexLocker locker( &m_lock ); | ||
116 | ProgressData data; | 115 | ProgressData data; | ||
117 | data.sender = sender; | 116 | data.sender = sender; | ||
117 | data.increment = increment; | ||||
118 | data.end = end; | ||||
118 | data.text = text; | 119 | data.text = text; | ||
119 | data.maximum = maximum; | 120 | data.maximum = maximum; | ||
120 | data.cancelObject = obj; | 121 | data.cancelObject = obj; | ||
121 | data.slot = slot; | 122 | data.function = function; | ||
122 | data.type = type; | 123 | data.type = type; | ||
123 | m_progressQueue.enqueue( data ); | 124 | m_progressQueue.enqueue( data ); | ||
125 | if( sender->staticMetaObject.indexOfSignal( SIGNAL(totalSteps(int)) ) != -1 ) | ||||
124 | connect( sender, SIGNAL(totalSteps(int)), SLOT(slotTotalSteps(int)) ); | 126 | connect( sender, SIGNAL(totalSteps(int)), SLOT(slotTotalSteps(int)) ); | ||
125 | emit startTimer(); | 127 | emit startTimer(); | ||
126 | } | 128 | } | ||
127 | 129 | | |||
128 | void | 130 | void | ||
129 | ProxyLogger::forwardNotifications() | 131 | ProxyLogger::forwardNotifications() | ||
130 | { | 132 | { | ||
131 | QMutexLocker locker( &m_lock ); | 133 | QMutexLocker locker( &m_lock ); | ||
Show All 9 Lines | 142 | { | |||
141 | LongMessage msg = m_longMessageQueue.dequeue(); | 143 | LongMessage msg = m_longMessageQueue.dequeue(); | ||
142 | m_logger->longMessage( msg.first, msg.second ); | 144 | m_logger->longMessage( msg.first, msg.second ); | ||
143 | } | 145 | } | ||
144 | while( !m_progressQueue.isEmpty() ) | 146 | while( !m_progressQueue.isEmpty() ) | ||
145 | { | 147 | { | ||
146 | ProgressData d = m_progressQueue.dequeue(); | 148 | ProgressData d = m_progressQueue.dequeue(); | ||
147 | if( d.job ) | 149 | if( d.job ) | ||
148 | { | 150 | { | ||
149 | m_logger->newProgressOperation( d.job.data(), d.text, d.cancelObject.data(), | 151 | m_logger->newProgressOperationImpl( d.job.data(), d.text, d.cancelObject.data(), | ||
150 | d.cancelObject.data() ? d.slot : 0 , d.type ); | 152 | d.function, d.type ); | ||
151 | } | 153 | } | ||
152 | else if( d.reply ) | 154 | else if( d.reply ) | ||
153 | { | 155 | { | ||
154 | m_logger->newProgressOperation( d.reply.data(), d.text, d.cancelObject.data(), | 156 | m_logger->newProgressOperationImpl( d.reply.data(), d.text, d.cancelObject.data(), | ||
155 | d.cancelObject.data() ? d.slot : 0 , d.type ); | 157 | d.function, d.type ); | ||
156 | } | 158 | } | ||
157 | else if( d.sender ) | 159 | else if( d.sender ) | ||
158 | { | 160 | { | ||
159 | // m_logger handles the signals from now on | 161 | // m_logger handles the signals from now on | ||
160 | disconnect( d.sender.data(), 0, this, 0 ); | 162 | disconnect( d.sender.data(), 0, this, 0 ); | ||
161 | m_logger->newProgressOperation( d.sender.data(), d.text, d.maximum, | 163 | m_logger->newProgressOperationImpl( d.sender.data(), d.increment, d.end, d.text, | ||
162 | d.cancelObject.data(), | 164 | d.maximum, d.cancelObject.data(), | ||
163 | d.cancelObject.data() ? d.slot : 0 , d.type ); | 165 | d.function, d.type ); | ||
164 | } | 166 | } | ||
165 | } | 167 | } | ||
166 | } | 168 | } | ||
167 | 169 | | |||
168 | void | 170 | void | ||
169 | ProxyLogger::slotTotalSteps( int totalSteps ) | 171 | ProxyLogger::slotTotalSteps( int totalSteps ) | ||
170 | { | 172 | { | ||
171 | QObject *operation = sender(); | 173 | QObject *operation = sender(); | ||
Show All 15 Lines |