void Plugin::hookEntryStatusChanged (IHookProxy_ptr, QObject *entryObj, QString) { if (!IsGoodEntry (entryObj)) return; ICLEntry *entry = qobject_cast<ICLEntry*> (entryObj); const QString& id = entry->GetEntryID (); const EntryStatus& status = entry->GetStatus (); if (!LastState_.contains (id)) { LastState_ [id] = status.State_; return; } const State oldState = LastState_ [id]; LastState_ [id] = status.State_; switch (oldState) { case SOffline: case SProbe: case SError: case SInvalid: case SConnecting: return; case SOnline: LastAvailable_ [id] = QDateTime::currentDateTime (); default: LastOnline_ [id] = QDateTime::currentDateTime (); ScheduleSave (); } }
void RegexpMatcherManager::Remove (const QModelIndex& index) { items_t::iterator begin = Items_.begin (); std::advance (begin, index.row ()); beginRemoveRows (QModelIndex (), index.row (), index.row ()); Items_.erase (begin); endRemoveRows (); ScheduleSave (); }
void RegexpMatcherManager::Remove (const QString& title) { items_t::iterator found = std::find_if (Items_.begin (), Items_.end (), boost::bind (boost::function<bool (const RegexpMatcherManager::RegexpItem&, const QString)> (&RegexpMatcherManager::RegexpItem::IsEqual), _1, title)); if (found == Items_.end ()) throw NotFound ("Regexp user tried to remove doesn't exist in the RegexpMatcherManager"); int dst = std::distance (Items_.begin (), found); beginRemoveRows (QModelIndex (), dst, dst); Items_.erase (found); endRemoveRows (); ScheduleSave (); }
void RegexpMatcherManager::Modify (const QString& title, const QString& newBody) { if (!IsRegexpValid (title) || !IsRegexpValid (newBody)) throw Malformed ("Regexp is malformed"); items_t::iterator found = std::find_if (Items_.begin (), Items_.end (), boost::bind (boost::function<bool (const RegexpMatcherManager::RegexpItem&, const QString)> (&RegexpMatcherManager::RegexpItem::IsEqual), _1, title)); if (found == Items_.end ()) throw NotFound ("Regexp user tried to modify doesn't exist in the RegexpMatcherManager"); found->Body_ = newBody; int dst = std::distance (Items_.begin (), found); emit dataChanged (index (dst, 1), index (dst, 1)); ScheduleSave (); }
void RegexpMatcherManager::Add (const QString& title, const QString& body) { if (!IsRegexpValid (title) || !IsRegexpValid (body)) throw Malformed ("Regexp is malformed"); items_t::const_iterator found = std::find_if (Items_.begin (), Items_.end (), boost::bind (boost::function<bool (const RegexpMatcherManager::RegexpItem&, const QString)> (&RegexpMatcherManager::RegexpItem::IsEqual), _1, title)); if (found != Items_.end ()) throw AlreadyExists ("Regexp user tries to add already exists in the RegexpMatcherManager"); beginInsertRows (QModelIndex (), rowCount (), rowCount ()); Items_.push_back (RegexpItem (title, body)); endInsertRows (); ScheduleSave (); }