summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelexperiencelog.cpp
diff options
context:
space:
mode:
authordolphin <dolphin@lindenlab.com>2014-03-20 16:32:31 -0700
committerdolphin <dolphin@lindenlab.com>2014-03-20 16:32:31 -0700
commitdba034ee100dae4b62ddf12523835a413a25f189 (patch)
treeeea5d465a7f11d1073b183dc42975ad379503302 /indra/newview/llpanelexperiencelog.cpp
parentb2591ca63c498ab606bf595e0b2e729e76caea24 (diff)
Experience log panel
Diffstat (limited to 'indra/newview/llpanelexperiencelog.cpp')
-rw-r--r--indra/newview/llpanelexperiencelog.cpp246
1 files changed, 189 insertions, 57 deletions
diff --git a/indra/newview/llpanelexperiencelog.cpp b/indra/newview/llpanelexperiencelog.cpp
index 009889a59f..e0e522e276 100644
--- a/indra/newview/llpanelexperiencelog.cpp
+++ b/indra/newview/llpanelexperiencelog.cpp
@@ -27,92 +27,224 @@
#include "llviewerprecompiledheaders.h"
#include "llpanelexperiencelog.h"
-#include "lldispatcher.h"
-#include "llsdserialize.h"
-#include "llviewergenericmessage.h"
-#include "llnotificationsutil.h"
-#include "lltrans.h"
+#include "llexperiencelog.h"
+#include "llexperiencecache.h"
+#include "llbutton.h"
+#include "llscrolllistctrl.h"
+#include "llcombobox.h"
+#include "llspinctrl.h"
+#include "llcheckboxctrl.h"
+#include "llfloaterreg.h"
+#include "llfloaterreporter.h"
+#include "llinventoryfunctions.h"
-class LLExperienceLogDispatchHandler : public LLDispatchHandler
+
+#define BTN_PROFILE_XP "btn_profile_xp"
+#define BTN_REPORT_XP "btn_report_xp"
+
+static LLPanelInjector<LLPanelExperienceLog> register_experiences_panel("experience_log");
+
+
+LLPanelExperienceLog::LLPanelExperienceLog( )
+ : mEventList(NULL)
+ , mPageSize(25)
+ , mCurrentPage(0)
{
-public:
- virtual bool operator()(
- const LLDispatcher* dispatcher,
- const std::string& key,
- const LLUUID& invoice,
- const sparam_t& strings)
+ buildFromFile("panel_experience_log.xml");
+}
+
+BOOL LLPanelExperienceLog::postBuild( void )
+{
+ LLExperienceLog* log = LLExperienceLog::getInstance();
+ mEventList = getChild<LLScrollListCtrl>("experience_log_list");
+ mEventList->setCommitCallback(boost::bind(&LLPanelExperienceLog::onSelectionChanged, this));
+
+ getChild<LLButton>("btn_clear")->setCommitCallback(boost::bind(&LLExperienceLog::clear, log));
+ getChild<LLButton>("btn_clear")->setCommitCallback(boost::bind(&LLPanelExperienceLog::refresh, this));
+
+ getChild<LLButton>(BTN_PROFILE_XP)->setCommitCallback(boost::bind(&LLPanelExperienceLog::onProfileExperience, this));
+ getChild<LLButton>(BTN_REPORT_XP)->setCommitCallback(boost::bind(&LLPanelExperienceLog::onReportExperience, this));
+ getChild<LLButton>("btn_notify")->setCommitCallback(boost::bind(&LLPanelExperienceLog::onNotify, this));
+ getChild<LLButton>("btn_next")->setCommitCallback(boost::bind(&LLPanelExperienceLog::onNext, this));
+ getChild<LLButton>("btn_prev")->setCommitCallback(boost::bind(&LLPanelExperienceLog::onPrev, this));
+
+ LLCheckBoxCtrl* check = getChild<LLCheckBoxCtrl>("notify_all");
+ check->set(log->getNotifyNewEvent());
+ check->setCommitCallback(boost::bind(&LLPanelExperienceLog::notifyChanged, this));
+
+
+ LLSpinCtrl* spin = getChild<LLSpinCtrl>("logsizespinner");
+ spin->set(log->getMaxDays());
+ spin->setCommitCallback(boost::bind(&LLPanelExperienceLog::logSizeChanged, this));
+
+ mPageSize = log->getPageSize();
+ refresh();
+ return TRUE;
+}
+
+LLPanelExperienceLog* LLPanelExperienceLog::create()
+{
+ return new LLPanelExperienceLog();
+}
+
+void LLPanelExperienceLog::refresh()
+{
+ mEventList->deleteAllItems();
+ const LLSD& events = LLExperienceLog::instance().getEvents();
+
+ if(events.size() == 0)
{
- LLSD message;
+ mEventList->setCommentText(getString("no_events"));
+ return;
+ }
- sparam_t::const_iterator it = strings.begin();
- if(it != strings.end()){
- const std::string& llsdRaw = *it++;
- std::istringstream llsdData(llsdRaw);
- if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length()))
- {
- llwarns << "LLExperienceLogDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << llendl;
- }
- }
- message["public_id"] = invoice;
+ setAllChildrenEnabled(FALSE);
+
+ LLSD item;
+ bool waiting = false;
+ LLUUID waiting_id;
- // Object Name
- if(it != strings.end())
+ int itemsToSkip = mPageSize*mCurrentPage;
+ int items = 0;
+ bool moreItems = false;
+
+ for(LLSD::map_const_iterator day = events.beginMap(); day != events.endMap() ; ++day)
+ {
+ const LLSD& dayArray = day->second;
+ int size = dayArray.size();
+ if(itemsToSkip > size)
{
- message["ObjectName"] = *it++;
+ itemsToSkip -= size;
+ continue;
}
-
- // parcel Name
- if(it != strings.end())
+ if(items >= mPageSize && size > 0)
+ {
+ moreItems = true;
+ break;
+ }
+ for(int i = itemsToSkip ; i < dayArray.size(); i++)
{
- message["ParcelName"] = *it++;
+ if(items >= mPageSize)
+ {
+ moreItems = true;
+ break;
+ }
+ const LLSD& event = dayArray[i];
+ LLUUID id = event[LLExperienceCache::EXPERIENCE_ID].asUUID();
+ const LLSD& experience = LLExperienceCache::get(id);
+ if(experience.isUndefined()){
+ waiting = true;
+ waiting_id = id;
+ }
+ if(!waiting)
+ {
+ item["id"] = event;
+
+ LLSD& columns = item["columns"];
+ columns[0]["column"] = "time";
+ columns[0]["value"] = day->first+event["Time"].asString();
+ columns[1]["column"] = "event";
+ columns[1]["value"] = LLExperienceLog::getPermissionString(event, "ExperiencePermissionShort");
+ columns[2]["column"] = "experience_name";
+ columns[2]["value"] = experience[LLExperienceCache::NAME].asString();
+ columns[3]["column"] = "object_name";
+ columns[3]["value"] = event["ObjectName"].asString();
+ mEventList->addElement(item);
+ }
+ ++items;
}
+ }
+ if(waiting)
+ {
+ mEventList->deleteAllItems();
+ mEventList->setCommentText(getString("loading"));
+ LLExperienceCache::get(waiting_id, boost::bind(&LLPanelExperienceLog::refresh, this));
+ }
+ else
+ {
+ setAllChildrenEnabled(TRUE);
- LLExperienceLog::instance().handleExperienceMessage(message);
- return true;
+ mEventList->setEnabled(TRUE);
+ getChild<LLButton>("btn_next")->setEnabled(moreItems);
+ getChild<LLButton>("btn_prev")->setEnabled(mCurrentPage>0);
+ getChild<LLButton>("btn_clear")->setEnabled(mEventList->getItemCount()>0);
+ onSelectionChanged();
}
-};
+}
-static LLExperienceLogDispatchHandler experience_log_dispatch_handler;
+void LLPanelExperienceLog::onProfileExperience()
+{
+ LLSD& event = getSelectedEvent();
+ if(event.isDefined())
+ {
+ LLFloaterReg::showInstance("experience_profile", event[LLExperienceCache::EXPERIENCE_ID].asUUID(), true);
+ }
+}
-void LLExperienceLog::handleExperienceMessage(LLSD& message)
+void LLPanelExperienceLog::onReportExperience()
{
- std::ostringstream str;
- if(message.has("Permission"))
+ LLSD& event = getSelectedEvent();
+ if(event.isDefined())
{
- str << "ExperiencePermission" << message["Permission"].asInteger();
- std::string entry;
- if(LLTrans::findString(entry, str.str()))
- {
- str.str(entry);
- }
- else
- {
- str.str();
- }
+ LLFloaterReporter::showFromExperience(event[LLExperienceCache::EXPERIENCE_ID].asUUID());
}
+}
- if(str.str().empty())
+void LLPanelExperienceLog::onNotify()
+{
+ LLSD& event = getSelectedEvent();
+ if(event.isDefined())
{
- str.str(LLTrans::getString("ExperiencePermissionUnknown", message));
+ LLExperienceLog::instance().notify(event);
}
+}
+
+void LLPanelExperienceLog::onNext()
+{
+ mCurrentPage++;
+ refresh();
+}
- message["EventType"] = str.str();
- if(message.has("IsAttachment") && message["IsAttachment"].asBoolean())
+void LLPanelExperienceLog::onPrev()
+{
+ if(mCurrentPage>0)
{
- LLNotificationsUtil::add("ExperienceEventAttachment", message);
+ mCurrentPage--;
+ refresh();
}
- else
+}
+
+void LLPanelExperienceLog::notifyChanged()
+{
+ LLExperienceLog::instance().setNotifyNewEvent(getChild<LLCheckBoxCtrl>("notify_all")->get());
+}
+
+void LLPanelExperienceLog::logSizeChanged()
+{
+ int value = (int)(getChild<LLSpinCtrl>("logsizespinner")->get());
+ bool dirty = value > 0 && value < LLExperienceLog::instance().getMaxDays();
+ LLExperienceLog::instance().setMaxDays(value);
+ if(dirty)
{
- LLNotificationsUtil::add("ExperienceEvent", message);
+ refresh();
}
}
-LLExperienceLog::LLExperienceLog()
+void LLPanelExperienceLog::onSelectionChanged()
{
+ bool enabled = (1 == mEventList->getNumSelected());
+ getChild<LLButton>(BTN_REPORT_XP)->setEnabled(enabled);
+ getChild<LLButton>(BTN_PROFILE_XP)->setEnabled(enabled);
+ getChild<LLButton>("btn_notify")->setEnabled(enabled);
}
-void LLExperienceLog::initialize()
+LLSD LLPanelExperienceLog::getSelectedEvent()
{
- gGenericDispatcher.addHandler("ExperienceEvent", &experience_log_dispatch_handler);
+ LLScrollListItem* item = mEventList->getFirstSelected();
+ if(item)
+ {
+ return item->getValue();
+ }
+ return LLSD();
}