00001 #ifndef VideoExcel_TableFilter_h 00002 #define VideoExcel_TableFilter_h 00003 00004 #include "TableFilterUpdateListener.h" 00005 00006 namespace Impala { 00007 namespace Application { 00008 namespace VideoExcel { 00009 00010 class TableFilter 00011 { 00012 public: 00013 00014 TableFilter(TableFilterUpdateListener *source, String column) 00015 { 00016 mColumn = column; 00017 mSource = source; 00018 mType = 0; 00019 } 00020 00021 void SetTextFilter(String substring) 00022 { 00023 ILOG_DEBUG("SetTextFilter: " << substring); 00024 mType = 1; 00025 mSubstring = substring; 00026 mSource->ApplyFilters(); 00027 } 00028 00029 void SetValueFilter(double value, bool greaterThen=true) 00030 { 00031 ILOG_DEBUG("SetValueFilter: " << value << "(gt=" << greaterThen << ")"); 00032 mType = 2; 00033 mValue = value; 00034 mGreaterThen = greaterThen; 00035 mSource->ApplyFilters(); 00036 } 00037 00038 void Disable(bool callApply=true) 00039 { 00040 ILOG_DEBUG("Disable filter"); 00041 mType = 0; 00042 if (callApply) 00043 mSource->ApplyFilters(); 00044 } 00045 00046 bool IsFilteredByText(String data) 00047 { 00048 if (mType==1) 00049 return data.find(mSubstring,0)==String::npos; 00050 return false; 00051 } 00052 00053 bool IsFilteredByValue(double data) 00054 { 00055 if (mType==2) 00056 { 00057 if (mGreaterThen) 00058 return data > mValue; 00059 else 00060 return data < mValue; 00061 } 00062 return false; 00063 } 00064 00065 String GetColumn() 00066 { 00067 return mColumn; 00068 } 00069 00070 int GetType() 00071 { 00072 return mType; 00073 } 00074 00075 private: 00076 00077 bool mGreaterThen; 00078 int mType; 00079 double mValue; // type 2: lt or gt a value 00080 String mSubstring; // type 1: textual substring search 00081 String mColumn; 00082 00083 TableFilterUpdateListener* mSource; 00084 00085 ILOG_VAR_DEC; 00086 }; 00087 00088 ILOG_VAR_INIT(TableFilter, Application.VideoExcel); 00089 00090 } // namespace VideoExcel 00091 } // namespace Application 00092 } // namespace Impala 00093 00094 #endif // TableFilter_h