00001 // ***************************************************************************** 00002 // 00003 // Copyright (c) 2015, Southwest Research Institute® (SwRI®) 00004 // All rights reserved. 00005 // 00006 // Redistribution and use in source and binary forms, with or without 00007 // modification, are permitted provided that the following conditions are met: 00008 // * Redistributions of source code must retain the above copyright 00009 // notice, this list of conditions and the following disclaimer. 00010 // * Redistributions in binary form must reproduce the above copyright 00011 // notice, this list of conditions and the following disclaimer in the 00012 // documentation and/or other materials provided with the distribution. 00013 // * Neither the name of Southwest Research Institute® (SwRI®) nor the 00014 // names of its contributors may be used to endorse or promote products 00015 // derived from this software without specific prior written permission. 00016 // 00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 // ARE DISCLAIMED. IN NO EVENT SHALL Southwest Research Institute® BE LIABLE 00021 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00023 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00024 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00025 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00027 // DAMAGE. 00028 // 00029 // ***************************************************************************** 00030 00031 #ifndef SWRI_CONSOLE_CONSOLE_WINDOW_H_ 00032 #define SWRI_CONSOLE_CONSOLE_WINDOW_H_ 00033 00034 #include <QtWidgets/QMainWindow> 00035 #include <QColor> 00036 #include <QPushButton> 00037 #include <QSettings> 00038 #include "ui_console_window.h" 00039 00040 #include "node_click_handler.h" 00041 00042 namespace swri_console 00043 { 00044 class LogDatabase; 00045 class LogDatabaseProxyModel; 00046 class NodeListModel; 00047 class ConsoleWindow : public QMainWindow { 00048 Q_OBJECT 00049 00050 public: 00051 ConsoleWindow(LogDatabase *db); 00052 ~ConsoleWindow(); 00053 00054 void closeEvent(QCloseEvent *event); // Overloaded function 00055 00056 Q_SIGNALS: 00057 void createNewWindow(); 00058 void readBagFile(); 00059 void readLogFile(); 00060 void readLogDirectory(); 00061 void selectFont(); 00062 00063 public Q_SLOTS: 00064 void clearAll(); 00065 void clearMessages(); 00066 void saveLogs(); 00067 void connected(bool); 00068 void setSeverityFilter(); 00069 void nodeSelectionChanged(); 00070 void messagesAdded(); 00071 void showLogContextMenu(const QPoint& point); 00072 void selectAllLogs(); 00073 void copyLogs(); 00074 void copyExtendedLogs(); 00075 void setFollowNewest(bool); 00076 void toggleAlternateRowColors(bool); 00077 00078 void userScrolled(int); 00079 00080 void includeFilterUpdated(const QString &); 00081 void excludeFilterUpdated(const QString &); 00082 void searchIndex(); // VM 4/13/2017 00083 void updateIncludeLabel(); 00084 void updateExcludeLabel(); 00085 00086 void setFont(const QFont &font); 00087 00088 void setDebugColor(); 00089 void setInfoColor(); 00090 void setWarnColor(); 00091 void setErrorColor(); 00092 void setFatalColor(); 00093 void prevIndex(); 00094 void nextIndex(); 00095 00096 private: 00097 enum function{NEXT,PREV,SEARCH}; 00098 function searchFunction_; 00099 void updateCurrentIndex(function sF); 00100 void chooseButtonColor(QPushButton* widget); 00101 QColor getButtonColor(const QPushButton* button) const; 00102 void updateButtonColor(QPushButton* widget, const QColor& color); 00103 00104 template <typename T> 00105 void loadBooleanSetting(const QString& key, T* element){ 00106 QSettings settings; 00107 bool val = settings.value(key, element->isChecked()).toBool(); 00108 if (val != element->isChecked()) { 00109 element->setChecked(val); 00110 } 00111 }; 00112 void loadColorButtonSetting(const QString& key, QPushButton* button); 00113 void loadSettings(); 00114 00115 00116 Ui::ConsoleWindow ui; 00117 LogDatabase *db_; 00118 LogDatabaseProxyModel *db_proxy_; 00119 NodeListModel *node_list_model_; 00120 NodeClickHandler *node_click_handler_; 00121 }; // class ConsoleWindow 00122 } // namespace swri_console 00123 00124 #endif // SWRI_CONSOLE_CONSOLE_WINDOW_H_