Commit bfdb518b authored by Eike Hein's avatar Eike Hein

On an auto-who interval change reschedule to match the setting as close as possible.

parent 464f5f45
...@@ -4,6 +4,13 @@ Changes since 1.4: ...@@ -4,6 +4,13 @@ Changes since 1.4:
Previously, enabling the lookup would not actually start it, and disabling it Previously, enabling the lookup would not actually start it, and disabling it
would only take effect after one last lookup was performed. Both now take would only take effect after one last lookup was performed. Both now take
effect immediately. effect immediately.
* The reaction to a change of the Automatic User Information Lookup interval
setting has been improved considerably: Whereas previously Konversation would
simply wait out the current interval scheduled using the old setting value and
only then schedule the next lookup using the new value, it now reschedules the
next lookup to occur as if the new value had been set all along, or, if the
time elapsed since the last lookup was performed already exceeds the new value,
comes as close as possible by performing a lookup immediately.
Changes from 1.4-beta1 to 1.4: Changes from 1.4-beta1 to 1.4:
......
...@@ -2311,7 +2311,7 @@ void Channel::setAutoUserhost(bool state) ...@@ -2311,7 +2311,7 @@ void Channel::setAutoUserhost(bool state)
} }
} }
void Channel::scheduleAutoWho() void Channel::scheduleAutoWho(int msec)
{ {
// The first auto-who is scheduled by ENDOFNAMES in InputFilter, which means // The first auto-who is scheduled by ENDOFNAMES in InputFilter, which means
// the first auto-who occurs one interval after it. This has two desirable // the first auto-who occurs one interval after it. This has two desirable
...@@ -2331,7 +2331,12 @@ void Channel::scheduleAutoWho() ...@@ -2331,7 +2331,12 @@ void Channel::scheduleAutoWho()
m_whoTimer.stop(); m_whoTimer.stop();
if (Preferences::self()->autoWhoContinuousEnabled()) if (Preferences::self()->autoWhoContinuousEnabled())
m_whoTimer.start(Preferences::self()->autoWhoContinuousInterval() * 1000); {
if (msec > 0)
m_whoTimer.start(msec);
else
m_whoTimer.start(Preferences::self()->autoWhoContinuousInterval() * 1000);
}
} }
void Channel::autoWho() void Channel::autoWho()
...@@ -2354,6 +2359,49 @@ void Channel::updateAutoWho() ...@@ -2354,6 +2359,49 @@ void Channel::updateAutoWho()
m_whoTimer.stop(); m_whoTimer.stop();
else if (Preferences::self()->autoWhoContinuousEnabled() && !m_whoTimer.isActive()) else if (Preferences::self()->autoWhoContinuousEnabled() && !m_whoTimer.isActive())
autoWho(); autoWho();
else if (m_whoTimer.isActive())
{
// The below tries to meet user expectations on an interval settings change,
// making two assumptions:
// - If the new interval is lower than the old one, the user may be impatient
// and desires an information update.
// - If the new interval is longer than the old one, the user may be trying to
// avoid Konversation producing too much traffic in a given timeframe, and
// wants it to stop doing so sooner rather than later.
// Both require rescheduling the next auto-who request.
int interval = Preferences::self()->autoWhoContinuousInterval() * 1000;
if (interval != m_whoTimer.interval())
{
if (m_whoTimerStarted.elapsed() >= interval)
{
// If the time since the last auto-who request is longer than (or
// equal to) the new interval setting, it follows that the new
// setting is lower than the old setting. In this case issue a new
// request immediately, which is the closest we can come to acting
// as if the new setting had been active all along, short of tra-
// velling back in time to change history. This handles the impa-
// tient user.
// FIXME: Adjust algorithm when time machine becomes available.
m_whoTimer.stop();
autoWho();
}
else
{
// If on the other hand the elapsed time is shorter than the new
// interval setting, the new setting could be either shorter or
// _longer_ than the old setting. Happily, this time we can actually
// behave as if the new setting had been active all along, by sched-
// uling the next request to happen in the new interval time minus
// the already elapsed time, meeting user expecations for both cases
// originally laid out.
scheduleAutoWho(interval - m_whoTimerStarted.elapsed());
}
}
}
} }
void Channel::fadeActivity() void Channel::fadeActivity()
......
...@@ -117,7 +117,7 @@ class Channel : public ChatWindow ...@@ -117,7 +117,7 @@ class Channel : public ChatWindow
public slots: public slots:
void setNickname(const QString& newNickname); void setNickname(const QString& newNickname);
void scheduleAutoWho(); void scheduleAutoWho(int msec = -1);
void setAutoUserhost(bool state); void setAutoUserhost(bool state);
void rejoin(); void rejoin();
...@@ -358,6 +358,8 @@ class Channel : public ChatWindow ...@@ -358,6 +358,8 @@ class Channel : public ChatWindow
bool topicAuthorUnknown; ///< Stores whether the "<author>" bit is there or not. bool topicAuthorUnknown; ///< Stores whether the "<author>" bit is there or not.
QTimer m_whoTimer; ///< For continuous auto /WHO QTimer m_whoTimer; ///< For continuous auto /WHO
QTime m_whoTimerStarted;
QTimer m_fadeActivityTimer; ///< For the smoothing function used in activity sorting QTimer m_fadeActivityTimer; ///< For the smoothing function used in activity sorting
QList<QStringList> m_pendingChannelNickLists; QList<QStringList> m_pendingChannelNickLists;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment