[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/sysadmin/ksystemlog/src
From:       Nicolas Ternisien <nicolas.ternisien () gmail ! com>
Date:       2007-09-10 0:44:10
Message-ID: 1189385050.417382.32674.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 710458 by ternisien:

Add header config
New status bar
Two bad hacks removed

 M  +2 -0      CMakeLists.txt  
 M  +1 -1      generalConfigurationWidgetBase.ui  
 M  +4 -2      lib/defaults.h  
 M  +0 -6      lib/logLine.h  
 M  +7 -2      lib/logModeAction.h  
 M  +2 -0      lib/logViewModel.cpp  
 M  +0 -1      lib/logViewModel.h  
 M  +51 -13    lib/logViewWidget.cpp  
 M  +3 -0      lib/logViewWidget.h  
 M  +13 -15    lib/multipleActions.cpp  
 M  +7 -5      lib/multipleActions.h  
 M  +2 -0      lib/reader.h  
 M  +16 -13    lib/simpleAction.cpp  
 M  +6 -4      lib/simpleAction.h  
 M  +15 -20    mainWindow.cpp  
 M  +0 -4      mainWindow.h  
 M  +3 -9      modes/acpid/acpidFactory.h  
 M  +0 -1      modes/apache/apacheFactory.h  
 M  +2 -1      modes/apache/apacheReader.cpp  
 M  +4 -23     modes/generic/parsingHelper.h  
 M  +0 -5      modes/generic/specificFileList.h  
 M  +3 -9      modes/system/systemFactory.h  
 A             statusBar.cpp   [License: GPL (v2+)]
 A             statusBar.h   [License: GPL (v2+)]


--- trunk/playground/sysadmin/ksystemlog/src/CMakeLists.txt #710457:710458
@@ -38,6 +38,8 @@
 
 	tabLogViewsWidget.cpp
 	tabLogManager.cpp
+	
+	statusBar.cpp
 
 )
 
--- trunk/playground/sysadmin/ksystemlog/src/generalConfigurationWidgetBase.ui \
#710457:710458 @@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>394</width>
+    <width>368</width>
     <height>497</height>
    </rect>
   </property>
--- trunk/playground/sysadmin/ksystemlog/src/lib/defaults.h #710457:710458
@@ -41,6 +41,8 @@
 	EMERGENCY_LOG_LEVEL_ID
 };
 
+//TODO Need a rewritting
+/*
 enum GroupByType {
 	NO_GROUP_BY=0,
 	GROUP_BY_LOG_LEVEL,
@@ -64,8 +66,8 @@
 
 //Icon of the Group By action
 #define GROUP_BY_ICON "view_tree"
+*/
 
-
 /**
  * Icon names of different existing modes
  */
@@ -95,4 +97,4 @@
 #define XSESSION_MODE_ICON "kwin"
 */
 
-#endif //_DEFAULTS_H_
+#endif // _DEFAULTS_H_
--- trunk/playground/sysadmin/ksystemlog/src/lib/logLine.h #710457:710458
@@ -39,12 +39,6 @@
 class LogViewWidgetItem;
 class LogModeItemBuilder;
 
-//TODO Need a rewritting
-/*
-class ParentLogLine;
-class ChildLogLine;
-*/
-
 class LogLinePrivate;
 
 class LogLine {
--- trunk/playground/sysadmin/ksystemlog/src/lib/logModeAction.h #710457:710458
@@ -22,15 +22,20 @@
 #ifndef _LOG_MODE_ACTION_H_
 #define _LOG_MODE_ACTION_H_
 
+#include <QObject>
 #include <QList>
 #include <QAction>
 
-class LogModeAction {
+class LogModeAction : public QObject {
 	
+	Q_OBJECT
+	
 public:
 	virtual ~LogModeAction();
 	
-	virtual QList<QAction*> actions() = 0;
+	virtual QList<QAction*> innerActions() = 0;
+	
+	virtual QAction* actionMenu() = 0;
 };
 
 #endif // _LOG_MODE_ACTION_H_
--- trunk/playground/sysadmin/ksystemlog/src/lib/logViewModel.cpp #710457:710458
@@ -30,6 +30,8 @@
 #include "logViewWidget.h"
 #include "logModeItemBuilder.h"
 
+#include "logging.h"
+
 #include "ksystemlogConfig.h"
 
 class LogViewModelPrivate {
--- trunk/playground/sysadmin/ksystemlog/src/lib/logViewModel.h #710457:710458
@@ -24,7 +24,6 @@
 
 #include <QObject>
 
-#include "logging.h"
 #include "globals.h"
 
 class LogLine;
--- trunk/playground/sysadmin/ksystemlog/src/lib/logViewWidget.cpp #710457:710458
@@ -29,6 +29,8 @@
 
 #include "logging.h"
 
+#include "logViewColumn.h"
+
 #include "logViewWidgetItem.h"
 #include "logLine.h"
 #include "logViewModel.h"
@@ -38,6 +40,8 @@
 	LogViewModel* logViewModel;
 	
 	bool newLinesDisplayed;
+	
+	QActionGroup* headersTogglingActions;
 
 };
 
@@ -54,23 +58,15 @@
 	
 	d->logViewModel = new LogViewModel(this);
 	d->newLinesDisplayed = true;
+	d->headersTogglingActions = new QActionGroup(this);
+	d->headersTogglingActions->setExclusive(false);
+	connect(d->headersTogglingActions, SIGNAL(triggered(QAction*)), this, \
SLOT(toggleHeader(QAction*)));  
 	setHeaderLabels(headerLabels);
-
-
-	//TODO Add a context menu to the Header
-	/*
+	
 	//Header
 	header()->setContextMenuPolicy(Qt::ActionsContextMenu);
-	
-	QAction* helloAction = new QAction(this);
-	helloAction->setText(i18n("Resu&me"));
-	helloAction->setIcon(KIcon("media-playback-start"));
-	helloAction->setShortcut(Qt::CTRL + Qt::Key_M);
-	helloAction->setToolTip(i18n("Resume the watching of the current log"));
-	helloAction->setWhatsThis(i18n("Resumes the watching of the current log. This \
                action is only available when the user has already paused the \
                reading."));
-	header()->addAction(helloAction);
-	*/
+	header()->setMovable(true);
 
 	setSortingEnabled(true);
 	sortItems(0, Qt::AscendingOrder);
@@ -103,7 +99,40 @@
 	setHeaderLabels(columns.toStringList());
 	
 	sortItems(0, Qt::AscendingOrder);
+	
+	//Remove previous header actions
+	QListIterator<QAction*> it(d->headersTogglingActions->actions());
+	it.toBack();
+	while (it.hasPrevious()) {
+		QAction* action = it.previous();
+		
+		header()->removeAction( action );
+		d->headersTogglingActions->removeAction( action );
+		
+		delete action;
+	}
+	
+	//Add new actions
+	int columnIndex = 0;
+	
+	foreach(LogViewColumn column, columns.columns()) {
+		QAction* action = new QAction(this);
+		action->setText(column.columnName());
+		//helloAction->setIcon(KIcon("media-playback-start"));
+		//helloAction->setShortcut(Qt::CTRL + Qt::Key_M);
+		action->setCheckable(true);
+		action->setChecked(true);
+		action->setToolTip(i18n("Display/Hide the '%1' column", column.columnName()));
+		action->setData(QVariant(columnIndex));
+		
+		d->headersTogglingActions->addAction(action);
+		
+		++columnIndex;
+	}
+	
+	header()->addActions(d->headersTogglingActions->actions());
 
+
 	emit columnsChanged(columns);
 	
 	logDebug() << "Log View Widget updated..." << endl;
@@ -267,6 +296,15 @@
 	return count;
 }
 
+void LogViewWidget::toggleHeader(QAction* action) {
+	logDebug() << "Toggling header" << endl;
+	
+	int columnIndex = action->data().toInt();
+	if (header()->isSectionHidden(columnIndex) == true)
+		header()->setSectionHidden(columnIndex, false);
+	else
+		header()->setSectionHidden(columnIndex, true);
+}
 
 
 #include "logViewWidget.moc"
--- trunk/playground/sysadmin/ksystemlog/src/lib/logViewWidget.h #710457:710458
@@ -77,6 +77,9 @@
 
 	signals:
 		void columnsChanged(const LogViewColumns& columns);
+	
+	private slots:
+		void toggleHeader(QAction* action);
 		
 	private:
 		LogViewWidgetPrivate* const d;
--- trunk/playground/sysadmin/ksystemlog/src/lib/multipleActions.cpp #710457:710458
@@ -25,29 +25,27 @@
 
 #include "logging.h"
 
-class MultipleActionsPrivate {
-public:
-	QList<QAction*> actions;
+MultipleActions::MultipleActions(const KIcon& icon, const QString& text, QObject* \
parent) { +	action = new KActionMenu(icon, text, parent);
 
-};
-
-MultipleActions::MultipleActions(const KIcon& icon, const QString& text, QObject* \
                parent) :
-	KActionMenu(icon, text, parent),
-	d(new MultipleActionsPrivate()) {
-	
 }
 
 MultipleActions::~MultipleActions() {
-	delete d;
+	delete action;
 }
 
-QList<QAction*> MultipleActions::actions() {
-	return d->actions;
+QList<QAction*> MultipleActions::innerActions() {
+	return actions;
 }
 
-void MultipleActions::addInnerAction(QAction* action) {
-	addAction(action);
-	d->actions.append(action);
+QAction* MultipleActions::actionMenu() {
+	return action;
 }
 
+void MultipleActions::addInnerAction(QAction* innerAction) {
+	action->addAction(innerAction);
+	actions.append(innerAction);
+	
+}
+
 #include "multipleActions.moc"
--- trunk/playground/sysadmin/ksystemlog/src/lib/multipleActions.h #710457:710458
@@ -35,14 +35,12 @@
 
 class QAction;
 
-class MultipleActionsPrivate;
-
 /**
  * This class is used by LogModeFactory to provide multiple actions
  * and be able to retrieve them when necessary, using actions().
  * This method will return QAction added using addInnerAction().
  */
-class MultipleActions : public KActionMenu, public LogModeAction {
+class MultipleActions : public LogModeAction {
 	
 	Q_OBJECT
 	
@@ -51,7 +49,9 @@
 		
 		virtual ~MultipleActions();
 		
-		QList<QAction*> actions();
+		QList<QAction*> innerActions();
+
+		QAction* actionMenu();
 		
 		/**
 		 * This method is not called addAction() to avoid name collision with
@@ -60,7 +60,9 @@
 		void addInnerAction(QAction* action);
 
 	private:
-		MultipleActionsPrivate* const d;
+		QList<QAction*> actions;
+		
+		KActionMenu* action; 
 };
 
 #endif // _MULTIPLE_ACTIONS_H_
--- trunk/playground/sysadmin/ksystemlog/src/lib/reader.h #710457:710458
@@ -51,9 +51,11 @@
 		
 		~Reader();
 		
+		//TODO Add a mutex to lock the LogViewModel and find a solution to be able to stop \
the process when loading and reloading  virtual void readLogFiles()=0;
 		virtual LogViewColumns initColumns()=0;
 
+		//TODO Add a mutex to lock the LogViewModel and find a solution to be able to stop \
the process when loading and reloading  virtual void logFileChanged(LogFile* \
logFile);  
 		void setLogFiles(const QList<LogFile>& files);
--- trunk/playground/sysadmin/ksystemlog/src/lib/simpleAction.cpp #710457:710458
@@ -25,30 +25,33 @@
 
 #include "logging.h"
 
-SimpleAction::SimpleAction(const QIcon& icon, const QString& text, QObject* parent) \
                :
-	QAction(icon, text, parent) {
-	
+SimpleAction::SimpleAction(const QIcon& icon, const QString& text, QObject* parent) \
{ +	action = new QAction(icon, text, parent);
 }
 
-SimpleAction::SimpleAction(QAction* action, QObject* parent) :
-	QAction(parent) {
-	setIcon(action->icon());
-	setText(action->text());
-	setData(action->data());
-	setToolTip(action->toolTip());
-	setWhatsThis(action->whatsThis());
+SimpleAction::SimpleAction(QAction* originAction, QObject* parent) {
+	
+	action = new QAction(parent);
+	action->setIcon(originAction->icon());
+	action->setText(originAction->text());
+	action->setData(originAction->data());
+	action->setToolTip(originAction->toolTip());
+	action->setWhatsThis(originAction->whatsThis());
 }
 
 SimpleAction::~SimpleAction() {
-	
+	delete action;
 }
 
-QList<QAction*> SimpleAction::actions() {
+QList<QAction*> SimpleAction::innerActions() {
 	QList<QAction*> actions;
-	actions.append(this);
+	actions.append(action);
 	
 	return actions;
 }
 
+QAction* SimpleAction::actionMenu() {
+	return action;
+}
 
 #include "simpleAction.moc"
--- trunk/playground/sysadmin/ksystemlog/src/lib/simpleAction.h #710457:710458
@@ -26,15 +26,13 @@
 #include <QList>
 #include <QIcon>
 
-#include <QAction>
-
 #include "globals.h"
 
 #include "logModeAction.h"
 
 class QAction;
 
-class SimpleAction : public QAction, public LogModeAction {
+class SimpleAction : public LogModeAction {
 	
 	Q_OBJECT
 	
@@ -45,8 +43,12 @@
 		
 		virtual ~SimpleAction();
 		
-		QList<QAction*> actions();
+		QList<QAction*> innerActions();
+		
+		QAction* actionMenu();
 
+	private:
+		QAction* action; 
 };
 
 #endif // _SIMPLE_ACTIONS_H_
--- trunk/playground/sysadmin/ksystemlog/src/mainWindow.cpp #710457:710458
@@ -50,8 +50,8 @@
 
 #include <ktoggleaction.h>
 #include <kmenubar.h>
-#include <kstatusbar.h>
 
+
 #include <kfiledialog.h>
 
 #include <kconfig.h>
@@ -69,6 +69,8 @@
 //Project includes
 #include "ksystemlogConfig.h"
 
+#include "statusBar.h"
+
 #include "logViewWidget.h"
 #include "tabLogViewsWidget.h"
 #include "configurationDialog.h"
@@ -150,6 +152,8 @@
 	 * Tab widget managing different views
 	 */
 	TabLogViewsWidget* tabs;
+	
+	KSystemLog::StatusBar* statusBar;
 
 };
 
@@ -162,6 +166,7 @@
 	d->detailDialog = NULL;
 	d->configurationDialog = NULL;
 	d->tabs = NULL;
+	d->statusBar = NULL;
 	
 	logDebug() << "Starting KSystemLog..." << endl;
 	
@@ -249,17 +254,9 @@
 
 
 void MainWindow::setupStatusBar() {
-	//Stretch to 0 -> resizing the window will not resize this element
-	statusBar()->insertItem("", STATUS_BAR_LINE_COUNT, 1);
-	statusBar()->setItemAlignment(STATUS_BAR_LINE_COUNT, Qt::AlignLeft);
-
-	//Stretch to 0 -> resizing the window will not resize this element
-	statusBar()->insertItem("", STATUS_BAR_MESSAGE, 2);
-	statusBar()->setItemAlignment(STATUS_BAR_MESSAGE, Qt::AlignLeft);
-
-	//Stretch to 1 -> resizing the window will resize this element
-	statusBar()->insertItem("", STATUS_BAR_LAST_MODIFICATION, 1);
-	statusBar()->setItemAlignment(STATUS_BAR_LAST_MODIFICATION, Qt::AlignRight);
+	d->statusBar = new KSystemLog::StatusBar(this);
+	
+	setStatusBar(d->statusBar);
 }
 
 void MainWindow::prepareCreatedLogManager(LogManager* manager) {
@@ -394,13 +391,13 @@
 	int notHiddenItemCount = \
currentManager->usedView()->logViewWidget()->notHiddenItemCount();  
 	if (itemCount == notHiddenItemCount) {
-		statusBar()->changeItem(i18ncp("Total displayed lines", "1 line.", "%1 lines.", \
currentManager->usedView()->logViewWidget()->itemCount()), STATUS_BAR_LINE_COUNT); \
+		d->statusBar->changeLineCountMessage(i18ncp("Total displayed lines", "1 line.", \
"%1 lines.", currentManager->usedView()->logViewWidget()->itemCount()));  }
 	else {
-		statusBar()->changeItem(i18ncp("Line not hidden by search / Total displayed \
lines", "1 line / %2 total.", "%1 lines / %2 total.", notHiddenItemCount, itemCount), \
STATUS_BAR_LINE_COUNT); +		d->statusBar->changeLineCountMessage(i18ncp("Line not \
hidden by search / Total displayed lines", "1 line / %2 total.", "%1 lines / %2 \
total.", notHiddenItemCount, itemCount));  }
 	
-	statusBar()->changeItem(i18n("Last updated: %1.", \
KGlobal::locale()->formatTime(currentManager->lastUpdate(), true, false) ), \
STATUS_BAR_LAST_MODIFICATION); \
+	d->statusBar->changeLastModification(currentManager->lastUpdate());  
 }
 
@@ -471,8 +468,7 @@
 }
 
 void MainWindow::changeStatusBar(const QString& text) {
-	//Display this text on the status bar
-	statusBar()->changeItem(text, STATUS_BAR_MESSAGE);
+	d->statusBar->changeMessage(text);
 }
 
 void MainWindow::changeWindowTitle(const QString& text) {
@@ -780,12 +776,11 @@
 	connect(d->logModesActionGroup, SIGNAL(triggered(QAction*)), this, \
SLOT(selectLogModeAction(QAction*)));  
 	foreach(LogModeAction* logModeAction, Globals::instance()->logModeActions()) {
-		foreach(QAction* action, logModeAction->actions()) {
+		foreach(QAction* action, logModeAction->innerActions()) {
 			d->logModesActionGroup->addAction(action);
 		}
 		
-		//TODO Improve this ugly code
-		dynamicLogModeActions.append( dynamic_cast<QAction*>(logModeAction) );
+		dynamicLogModeActions.append( logModeAction->actionMenu() );
 	}
 
 	unplugActionList("log_mode_list");
--- trunk/playground/sysadmin/ksystemlog/src/mainWindow.h #710457:710458
@@ -34,10 +34,6 @@
 
 #include <ktoggleaction.h>
 
-#define STATUS_BAR_LINE_COUNT 0
-#define STATUS_BAR_MESSAGE 1
-#define STATUS_BAR_LAST_MODIFICATION 2
-
 class QAction;
 
 class LogManager;
--- trunk/playground/sysadmin/ksystemlog/src/modes/acpid/acpidFactory.h \
#710457:710458 @@ -22,19 +22,13 @@
 #ifndef _ACPID_FACTORY_H_
 #define _ACPID_FACTORY_H_
 
-#include <QString>
 #include <QList>
 
-#include <QAction>
-
-#include <kicon.h>
-#include <klocale.h>
-
-#include "logMode.h"
-#include "logging.h"
-
 #include "logModeFactory.h"
 
+class LogModeAction;
+class LogMode;
+
 class AcpidLogModeFactory : public LogModeFactory {
 	
 	Q_OBJECT
--- trunk/playground/sysadmin/ksystemlog/src/modes/apache/apacheFactory.h \
#710457:710458 @@ -22,7 +22,6 @@
 #ifndef _APACHE_LOG_MODE_FACTORY_H_
 #define _APACHE_LOG_MODE_FACTORY_H_
 
-
 #include <QString>
 #include <QList>
 
--- trunk/playground/sysadmin/ksystemlog/src/modes/apache/apacheReader.cpp \
#710457:710458 @@ -23,8 +23,9 @@
 
 #include <klocale.h>
 
+#include "logging.h"
+
 #include "parsingHelper.h"
-
 #include "apacheLogMode.h"
 
 ApacheReader::ApacheReader(LogMode* logMode) :
--- trunk/playground/sysadmin/ksystemlog/src/modes/generic/parsingHelper.h \
#710457:710458 @@ -22,31 +22,12 @@
 #ifndef _PARSING_HELPER_H_
 #define _PARSING_HELPER_H_
 
-#include <qobject.h>
-#include <qstringlist.h>
-#include <qfile.h>
-#include <qmap.h>
-#include <qpair.h>
+#include <QDateTime>
 
-#include <kdirwatch.h>
-#include <kurl.h>
-#include <kvbox.h>
+#include <QString>
+#include <QMap>
 
-
-#include "globals.h"
-
-//TODO Need a rewritting
-//#include "logListItem.h"
-
-#include "logLine.h"
-#include "logManager.h"
-
-#include "logFile.h"
-#include "logViewColumn.h"
-#include "logViewColumns.h"
-
 class ParsingHelper {
-	
 
 	public:
 		/**
@@ -65,7 +46,7 @@
 
 		
 	private:
-	
+		//TODO Remove those static maps using a Singleton and (of course) a d-pointer
 		/**
 		 * Map used by the static parseMonthNumber() method
 		 */
--- trunk/playground/sysadmin/ksystemlog/src/modes/generic/specificFileList.h \
#710457:710458 @@ -22,11 +22,6 @@
 #ifndef _SPECIFIC_FILE_LIST_H_
 #define _SPECIFIC_FILE_LIST_H_
 
-
-#include <QMap>
-
-#include "globals.h"
-
 #include "fileList.h"
 
 class QPushButton;
--- trunk/playground/sysadmin/ksystemlog/src/modes/system/systemFactory.h \
#710457:710458 @@ -22,19 +22,13 @@
 #ifndef _SYSTEM_FACTORY_H_
 #define _SYSTEM_FACTORY_H_
 
-#include <QString>
 #include <QList>
 
-#include <QAction>
-
-#include <kicon.h>
-#include <klocale.h>
-
-#include "logMode.h"
-#include "logging.h"
-
 #include "logModeFactory.h"
 
+class LogModeAction;
+class LogMode;
+
 class SystemLogModeFactory : public LogModeFactory {
 	
 	Q_OBJECT


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic