Changeset View
Changeset View
Standalone View
Standalone View
applets/mediaframe/plugin/mediaframe.cpp
Show First 20 Lines • Show All 318 Lines • ▼ Show 20 Line(s) | 312 | } else { | |||
---|---|---|---|---|---|
319 | } | 319 | } | ||
320 | return; | 320 | return; | ||
321 | } | 321 | } | ||
322 | 322 | | |||
323 | } | 323 | } | ||
324 | 324 | | |||
325 | void MediaFrame::pushHistory(const QString &string) | 325 | void MediaFrame::pushHistory(const QString &string) | ||
326 | { | 326 | { | ||
327 | const int oldCount = m_history.count(); | ||||
328 | | ||||
327 | m_history.prepend(string); | 329 | m_history.prepend(string); | ||
328 | 330 | | |||
329 | // Keep a sane history size | 331 | // Keep a sane history size | ||
330 | if(m_history.length() > 50) | 332 | if (m_history.length() > 50) { | ||
331 | m_history.removeLast(); | 333 | m_history.removeLast(); | ||
332 | } | 334 | } | ||
333 | 335 | | |||
336 | if (oldCount != m_history.count()) { | ||||
davidedmundson: This could have just been an else of the branch above | |||||
And then one day someone adds a check for contains() before prepend(), for instance, and you would need to come back to this structure of the code. So this is more flexible. dfaure: And then one day someone adds a check for contains() before prepend(), for instance, and you… | |||||
337 | emit historyLengthChanged(); | ||||
338 | } | ||||
339 | } | ||||
340 | | ||||
334 | QString MediaFrame::popHistory() | 341 | QString MediaFrame::popHistory() | ||
335 | { | 342 | { | ||
336 | if(m_history.isEmpty()) | 343 | if (m_history.isEmpty()) { | ||
337 | return QString(); | 344 | return QString(); | ||
338 | return m_history.takeFirst(); | | |||
339 | } | 345 | } | ||
340 | 346 | | |||
341 | int MediaFrame::historyLength() | 347 | const QString item = m_history.takeFirst(); | ||
348 | emit historyLengthChanged(); | ||||
349 | return item; | ||||
350 | } | ||||
351 | | ||||
352 | int MediaFrame::historyLength() const | ||||
342 | { | 353 | { | ||
343 | return m_history.length(); | 354 | return m_history.length(); | ||
344 | } | 355 | } | ||
345 | 356 | | |||
346 | void MediaFrame::pushFuture(const QString &string) | 357 | void MediaFrame::pushFuture(const QString &string) | ||
347 | { | 358 | { | ||
348 | m_future.prepend(string); | 359 | m_future.prepend(string); | ||
349 | } | 360 | } | ||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |
This could have just been an else of the branch above