Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:52

0001 // -*- C++ -*-
0002 //
0003 // Package:     TableWidget
0004 // Class  :     FWAdapterHeaderTableManager
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Mon Feb  2 16:44:45 EST 2009
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "Fireworks/TableWidget/src/FWAdapterHeaderTableManager.h"
0017 #include "Fireworks/TableWidget/interface/FWColumnLabelCellRenderer.h"
0018 //
0019 // constants, enums and typedefs
0020 //
0021 
0022 //
0023 // static data member definitions
0024 //
0025 
0026 //
0027 // constructors and destructor
0028 //
0029 FWAdapterHeaderTableManager::FWAdapterHeaderTableManager(const FWTableManagerBase* iTable)
0030     : m_table(iTable),
0031       m_renderer(
0032           new FWColumnLabelCellRenderer(&(FWTextTableCellRenderer::getDefaultGC()), iTable->cellDataIsSortable())),
0033       m_sortedColumn(-1),
0034       m_descendingSort(true) {}
0035 
0036 // FWAdapterHeaderTableManager::FWAdapterHeaderTableManager(const FWAdapterHeaderTableManager& rhs)
0037 // {
0038 //    // do actual copying here;
0039 // }
0040 
0041 FWAdapterHeaderTableManager::~FWAdapterHeaderTableManager() {}
0042 
0043 //
0044 // assignment operators
0045 //
0046 // const FWAdapterHeaderTableManager& FWAdapterHeaderTableManager::operator=(const FWAdapterHeaderTableManager& rhs)
0047 // {
0048 //   //An exception safe implementation is
0049 //   FWAdapterHeaderTableManager temp(rhs);
0050 //   swap(rhs);
0051 //
0052 //   return *this;
0053 // }
0054 
0055 //
0056 // member functions
0057 //
0058 void FWAdapterHeaderTableManager::implSort(int col, bool sortOrder) {
0059   m_sortedColumn = col;
0060   m_descendingSort = sortOrder;
0061 }
0062 
0063 //
0064 // const member functions
0065 //
0066 int FWAdapterHeaderTableManager::numberOfRows() const { return 1; }
0067 
0068 int FWAdapterHeaderTableManager::numberOfColumns() const { return m_table->numberOfColumns(); }
0069 
0070 int FWAdapterHeaderTableManager::unsortedRowNumber(int iRow) const { return iRow; }
0071 
0072 std::vector<std::string> FWAdapterHeaderTableManager::getTitles() const { return m_table->getTitles(); }
0073 
0074 FWTableCellRendererBase* FWAdapterHeaderTableManager::cellRenderer(int /*iRow*/, int iCol) const {
0075   if (iCol == m_sortedColumn) {
0076     if (m_descendingSort) {
0077       m_renderer->setSortOrder(fireworks::table::kDescendingSort);
0078     } else {
0079       m_renderer->setSortOrder(fireworks::table::kAscendingSort);
0080     }
0081   } else {
0082     m_renderer->setSortOrder(fireworks::table::kNotSorted);
0083   }
0084   if (iCol < m_table->numberOfColumns()) {
0085     m_renderer->setData(*(getTitles().begin() + iCol), false);
0086   } else {
0087     m_renderer->setData("", false);
0088   }
0089   return m_renderer;
0090 }
0091 
0092 //
0093 // static member functions
0094 //