From 15855fa84a09fd1fd486d357c38db0f2bd181e74 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 4 Mar 2014 23:23:45 +0000 Subject: HistoryStats compiles ok now git-svn-id: http://svn.miranda-ng.org/main/trunk@8399 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/HistoryStats/src/column.cpp | 181 ++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 plugins/HistoryStats/src/column.cpp (limited to 'plugins/HistoryStats/src/column.cpp') diff --git a/plugins/HistoryStats/src/column.cpp b/plugins/HistoryStats/src/column.cpp new file mode 100644 index 0000000000..82429700bf --- /dev/null +++ b/plugins/HistoryStats/src/column.cpp @@ -0,0 +1,181 @@ +#include "_globals.h" +#include "column.h" + +#include "column_rank.h" +#include "column_nick.h" +#include "column_protocol.h" +#include "column_group.h" +#include "column_inout.h" +#include "column_inoutgraph.h" +#include "column_chatduration.h" +#include "column_words.h" +#include "column_wordcount.h" +#include "column_events.h" +#include "column_split.h" +#include "column_timeline.h" +#include "column_splittimeline.h" + +/* + * Column::FactoryList + */ + +Column::FactoryList::FactoryList() +{ +} + +Column::FactoryList::~FactoryList() +{ + vector_each_(i, m_List) + { + delete m_List[i].m_pFactory; + } +} + +void Column::FactoryList::initList() +{ + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory ); + registerUID(new Factory); +} + +/* + * Column::IDProvider + */ + +ext::string Column::IDProvider::getID() +{ + ext::string s = muT("q"); + int val = m_nNextID++; + + while (val > 0) + { + int digit = val % 36; + + if (digit < 10) + { + s += (muC('0') + digit); + } + else + { + s += (muC('a') + digit - 10); + } + + val /= 36; + } + + return s; +} + +/* + * Column + */ + +Column::FactoryList Column::m_Factories; + +Column* Column::fromUID(const ext::string& guid) +{ + upto_each_(i, countColInfo()) + { + if (getColInfo(i).m_UID == guid) + { + return getColInfo(i).m_pFactory->makeInstance(); + } + } + + return NULL; +} + +void Column::registerUID(FactoryBase* pFactory) +{ + Column* pDummy = pFactory->makeInstance(); + + ColumnInfo ci; + + ci.m_UID = pDummy->getUID(); + ci.m_Title = pDummy->getTitle(); + ci.m_Description = pDummy->getDescription(); + ci.m_pFactory = pFactory; + + m_Factories.m_List.push_back(ci); + + delete pDummy; +} + +void Column::writeRowspanTD(ext::ostream& tos, const ext::string& innerHTML, int row /* = 1 */, int numRows /* = 1 */, int rowSpan /* = 1 */, int colSpan /* = 1 */) const +{ + int curRowSpan = (row < numRows) ? 1 : (rowSpan - numRows + 1); + + tos << muT(" 1) + { + tos << muT(" colspan=\"") << colSpan << muT("\""); + } + + if (curRowSpan > 1) + { + tos << muT(" rowspan=\"") << curRowSpan << muT("\""); + } + + tos << muT(">") << innerHTML << muT("") << ext::endl; +} + +void Column::copyAttrib(const Column* pSource) +{ + m_bEnabled = pSource->m_bEnabled; + m_CustomTitle = pSource->m_CustomTitle; + m_nContactDataSlot = pSource->m_nContactDataSlot; + m_nContactDataTransformSlot = pSource->m_nContactDataTransformSlot; +} + +const ext::string Column::getCustomTitle(const ext::string& strShort, const ext::string& strLong) const +{ + ext::string strTitle = utils::htmlEscape(m_CustomTitle.empty() ? (m_pSettings->m_TableHeaderVerbose ? strLong : strShort) : m_CustomTitle); + + if (m_pSettings->m_HeaderTooltips && (!m_pSettings->m_HeaderTooltipsIfCustom || !m_CustomTitle.empty() || (!m_pSettings->m_TableHeaderVerbose && strShort != strLong))) + { + strTitle = muT("") + strTitle + muT(""); + } + + return strTitle; +} + +Column* Column::clone() const +{ + Column* pClone = fromUID(getUID()); + + pClone->copyAttrib(this); + pClone->copyConfig(this); + + return pClone; +} + +void Column::outputBegin() +{ + int restrictions = configGetRestrictions(NULL); + + m_bUsePNG = + m_pSettings->isPNGOutputActiveAndAvailable() && // do we want PNG output? + (restrictions & crPNGMask) && // has PNG capability at all? + !(m_pSettings->m_PNGMode == Settings::pmPreferHTML && (restrictions & crHTMLMask) == crHTMLFull) && // still prefer HTML? + (m_pSettings->m_PNGMode == Settings::pmEnforcePNG || (restrictions & crPNGMask) == crPNGFull); // force or fallback but with no restrictions + + impl_outputBegin(); +} + +SIZE Column::impl_outputMeasureHeader() const +{ + SIZE defaultSize = { 1, 1 }; + + return defaultSize; +} -- cgit v1.2.3