diff options
Diffstat (limited to 'library')
-rw-r--r-- | library/CustomGrid.cpp | 69 | ||||
-rw-r--r-- | library/CustomGrid.h | 3 | ||||
-rw-r--r-- | library/errorLogging.cpp | 25 | ||||
-rw-r--r-- | library/errorLogging.h | 9 | ||||
-rw-r--r-- | library/statusHandler.h | 3 |
5 files changed, 90 insertions, 19 deletions
diff --git a/library/CustomGrid.cpp b/library/CustomGrid.cpp index fdb26eb5..74ceb07f 100644 --- a/library/CustomGrid.cpp +++ b/library/CustomGrid.cpp @@ -10,6 +10,7 @@ #include "../ui/gridView.h" #include "../synchronization.h" #include "../shared/customTooltip.h" +#include <wx/dcclient.h> #ifdef FFS_WIN #include <wx/timer.h> @@ -81,7 +82,7 @@ public: } - virtual bool IsEmptyCell( int row, int col ) + virtual bool IsEmptyCell(int row, int col) { return false; //avoid overlapping cells @@ -895,11 +896,11 @@ std::set<unsigned int> CustomGrid::getAllSelectedRows() const { wxGridCellCoordsArray tmpArrayBottom = this->GetSelectionBlockBottomRight(); - unsigned int arrayCount = tmpArrayTop.GetCount(); + size_t arrayCount = tmpArrayTop.GetCount(); if (arrayCount == tmpArrayBottom.GetCount()) { - for (unsigned int i = 0; i < arrayCount; ++i) + for (size_t i = 0; i < arrayCount; ++i) { const int rowTop = tmpArrayTop[i].GetRow(); const int rowBottom = tmpArrayBottom[i].GetRow(); @@ -1037,7 +1038,6 @@ private: //---------------------------------------------------------------------------------------- - CustomGridRim::CustomGridRim(wxWindow *parent, wxWindowID id, const wxPoint& pos, @@ -1182,7 +1182,7 @@ void CustomGridRim::setColumnAttributes(const xmlAccess::ColumnAttributes& attr) if (getTypeAtPos(i) == xmlAccess::SIZE) { wxGridCellAttr* cellAttributes = GetOrCreateCellAttr(0, i); - cellAttributes->SetAlignment(wxALIGN_RIGHT,wxALIGN_CENTRE); + cellAttributes->SetAlignment(wxALIGN_RIGHT, wxALIGN_CENTRE); SetColAttr(i, cellAttributes); //make filesize right justified on grids break; } @@ -1228,6 +1228,60 @@ CustomGridTableRim* CustomGridRim::getGridDataTable() } +void CustomGridRim::autoSizeColumns() //performance optimized column resizer (analog to wxGrid::AutoSizeColumns() +{ + for (int col = 0; col < GetNumberCols(); ++col) + { + if (col < 0) + return; + + int rowMax = -1; + size_t lenMax = 0; + for (int row = 0; row < GetNumberRows(); ++row) + if (GetCellValue(row, col).size() > lenMax) + { + lenMax = GetCellValue(row, col).size(); + rowMax = row; + } + + wxCoord extentMax = 0; + + //calculate width of (most likely) widest cell + wxClientDC dc(GetGridWindow()); + if (rowMax > -1) + { + wxGridCellAttr* attr = GetCellAttr(rowMax, col); + if (attr) + { + wxGridCellRenderer* renderer = attr->GetRenderer(this, rowMax, col); + if (renderer) + { + const wxSize size = renderer->GetBestSize(*this, *attr, dc, rowMax, col); + extentMax = std::max(extentMax, size.x); + renderer->DecRef(); + } + attr->DecRef(); + } + } + + //consider column label + dc.SetFont(GetLabelFont()); + wxCoord w = 0; + wxCoord h = 0; + dc.GetMultiLineTextExtent(GetColLabelValue(col), &w, &h ); + if (GetColLabelTextOrientation() == wxVERTICAL) + w = h; + extentMax = std::max(extentMax, w); + + extentMax += 15; //leave some space around text + + SetColSize(col, extentMax); + + } + Refresh(); +} + + #ifdef FFS_WIN void CustomGridRim::enableFileIcons(const bool value) { @@ -1897,3 +1951,8 @@ const wxBitmap& FreeFileSync::getSyncOpImage(SyncOperation syncOp) return wxNullBitmap; //dummy } + + + + + diff --git a/library/CustomGrid.h b/library/CustomGrid.h index 59bc97c0..d5db71a1 100644 --- a/library/CustomGrid.h +++ b/library/CustomGrid.h @@ -149,6 +149,9 @@ public: xmlAccess::ColumnTypes getTypeAtPos(unsigned pos) const; static wxString getTypeName(xmlAccess::ColumnTypes colType); + void autoSizeColumns(); //performance optimized column resizer + void autoSizeColumns(int col, bool doRefresh = true); // + #ifdef FFS_WIN void enableFileIcons(const bool value); #endif diff --git a/library/errorLogging.cpp b/library/errorLogging.cpp index 000dce4d..9424a6c5 100644 --- a/library/errorLogging.cpp +++ b/library/errorLogging.cpp @@ -6,12 +6,10 @@ using FreeFileSync::ErrorLogging; -void ErrorLogging::logError(const wxString& errorMessage) +void ErrorLogging::logInfo(const wxString& infoMessage) { - ++errorCount; - - const wxString prefix = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + _("Error") + wxT(": "); - formattedMessages.push_back(assembleMessage(prefix, errorMessage)); + const wxString prefix = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + _("Info") + wxT(": "); + formattedMessages.push_back(assembleMessage(prefix, infoMessage)); } @@ -22,10 +20,21 @@ void ErrorLogging::logWarning(const wxString& warningMessage) } -void ErrorLogging::logInfo(const wxString& infoMessage) +void ErrorLogging::logError(const wxString& errorMessage) { - const wxString prefix = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + _("Info") + wxT(": "); - formattedMessages.push_back(assembleMessage(prefix, infoMessage)); + ++errorCount; + + const wxString prefix = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + _("Error") + wxT(": "); + formattedMessages.push_back(assembleMessage(prefix, errorMessage)); +} + + +void ErrorLogging::logFatalError(const wxString& errorMessage) +{ + ++errorCount; + + const wxString prefix = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + _("Fatal Error") + wxT(": "); + formattedMessages.push_back(assembleMessage(prefix, errorMessage)); } diff --git a/library/errorLogging.h b/library/errorLogging.h index 7b2b32c1..24b4a992 100644 --- a/library/errorLogging.h +++ b/library/errorLogging.h @@ -13,16 +13,17 @@ class ErrorLogging public: ErrorLogging() : errorCount(0) {} - void logError(const wxString& errorMessage); - void logWarning(const wxString& warningMessage); - void logInfo(const wxString& infoMessage); + void logInfo( const wxString& infoMessage); + void logWarning( const wxString& warningMessage); + void logError( const wxString& errorMessage); + void logFatalError(const wxString& errorMessage); int errorsTotal() { return errorCount; } - const std::vector<wxString>& getFormattedMessages() + const std::vector<wxString>& getFormattedMessages() const { return formattedMessages; } diff --git a/library/statusHandler.h b/library/statusHandler.h index d4163d2f..cefb129b 100644 --- a/library/statusHandler.h +++ b/library/statusHandler.h @@ -46,8 +46,8 @@ public: }; //these methods have to be implemented in the derived classes to handle error and status information - virtual void updateStatusText(const Zstring& text) = 0; virtual void initNewProcess(int objectsTotal, wxLongLong dataTotal, Process processID) = 0; //informs about the total amount of data that will be processed from now on + virtual void updateStatusText(const Zstring& text) = 0; virtual void updateProcessedData(int objectsProcessed, wxLongLong dataProcessed) = 0; //called periodically after data was processed //this method is triggered repeatedly by requestUiRefresh() and can be used to refresh the ui by dispatching pending events @@ -57,7 +57,6 @@ public: void requestAbortion(); //this does NOT call abortThisProcess immediately, but when appropriate (e.g. async. processes finished) bool abortIsRequested(); - //error handling: virtual ErrorHandler::Response reportError(const wxString& errorMessage) = 0; //recoverable error situation virtual void reportFatalError(const wxString& errorMessage) = 0; //non-recoverable error situation, implement abort! |