[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-05 7:39:22
Message-ID: 1188977962.974006.29004.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 708617 by ternisien:

Add page config validation

 M  +27 -6     configurationDialog.cpp  
 M  +7 -2      configurationDialog.h  
 M  +5 -9      generalConfigurationWidget.cpp  
 M  +7 -6      generalConfigurationWidget.h  
 M  +12 -1     lib/logManager.cpp  
 M  +2 -0      lib/logManager.h  
 M  +7 -0      lib/logModeConfigurationWidget.cpp  
 M  +6 -6      lib/logModeConfigurationWidget.h  
 M  +3 -10     modes/apache/apacheConfigurationWidget.cpp  
 M  +2 -3      modes/apache/apacheConfigurationWidget.h  
 M  +4 -0      modes/generic/fileList.cpp  
 M  +2 -0      modes/generic/fileList.h  
 M  +3 -10     modes/system/systemConfigurationWidget.cpp  
 M  +1 -5      modes/system/systemConfigurationWidget.h  


--- trunk/playground/sysadmin/ksystemlog/src/configurationDialog.cpp #708616:708617
@@ -48,6 +48,8 @@
 	QList<LogModeConfigurationWidget*> logModeConfigurations;
 	
 	bool changed;
+	
+	bool configurationProblem;
 };
 
 ConfigurationDialog::ConfigurationDialog(KSystemLog::MainWindow* mainWindow) :
@@ -56,12 +58,14 @@
 	{
 	
 	d->changed = false;
+	d->configurationProblem = false;
 
 	setupGeneralConfiguration();
 	
 	setupLogModeConfigurations();
+	
+	connect(this, SIGNAL(settingsChanged(const QString&)), mainWindow, \
SLOT(reloadAll()));  
-	//connect(this, SIGNAL(settingsChanged(const QString&)), mainWindow, \
SLOT(reloadAll()));  }
 
 ConfigurationDialog::~ConfigurationDialog() {
@@ -79,13 +83,13 @@
 		
 		addPage(logModeConfigurationWidget, logModeConfigurationWidget->itemName(), \
logModeConfigurationWidget->iconName(), logModeConfigurationWidget->header(), false); \
                
-		connect(logModeConfigurationWidget, SIGNAL(optionsChanged(bool)), this, \
SLOT(updateButtons())); +		connect(logModeConfigurationWidget, \
SIGNAL(configurationChanged()), this, SLOT(updateConfiguration()));  }
 }
 
 void ConfigurationDialog::showConfiguration() {
 	logDebug() << "Showing Configuration dialog..." << endl;
-	
+
 	KConfigDialog::updateButtons();
 	
 	show();
@@ -96,13 +100,13 @@
 	
 	addPage(d->generalConfiguration, i18n("General"), KSYSTEMLOG_ICON, i18n("General"), \
false);  
-	connect(d->generalConfiguration, SIGNAL(optionsChanged(bool)), this, \
SLOT(updateButtons())); +	connect(d->generalConfiguration, \
SIGNAL(configurationChanged()), this, SLOT(updateConfiguration()));  
 }
 
 void ConfigurationDialog::updateSettings() {
 	logDebug() << "Saving configuration..." << endl;
-
+	
 	d->changed = false;
 	
 	d->generalConfiguration->saveConfig();
@@ -121,8 +125,25 @@
 	return d->changed;
 }
 
+void ConfigurationDialog::updateConfiguration() {
+	logDebug() << "Updating configuration : " << endl;
+	
+	//TODO Fill valid with isValid() methods
+/*	
+	if (valid == true) {
+		enableButtonOk(true);
+		
+		updateButtons();
+	}
+	else {
+		enableButtonOk(false);
+		enableButtonApply(false);
+	}
+*/
+}
+
 void ConfigurationDialog::updateButtons() {
-	//logDebug() << "Updating configuration buttons..." << endl;
+	logDebug() << "Updating configuration buttons..." << endl;
 
 	d->changed = true;
 	
--- trunk/playground/sysadmin/ksystemlog/src/configurationDialog.h #708616:708617
@@ -41,19 +41,24 @@
 		~ConfigurationDialog();
 
 		void showConfiguration();
+
+	protected slots:
 		
-	protected slots:
 		void updateWidgets();
 		void updateWidgetsDefault();
 		void updateSettings();
 		void updateButtons();
 		
+	private slots:
+		void updateConfiguration();
+		
 	private:
+
 		bool hasChanged();
 		bool isDefault();
 		
 		ConfigurationDialogPrivate* const d;
-		
+
 		void setupGeneralConfiguration();
 
 		void setupLogModeConfigurations();
--- trunk/playground/sysadmin/ksystemlog/src/generalConfigurationWidget.cpp \
#708616:708617 @@ -56,7 +56,7 @@
 	maxLines->setMinimum(10);
 	maxLines->setMaximum(30000);
 	maxLines->setSingleStep(10);
-	connect(maxLines, SIGNAL(valueChanged(int)), this, SLOT(onOptionsChanged()));
+	connect(maxLines, SIGNAL(valueChanged(int)), this, SIGNAL(configurationChanged()));
 	
 	maxLines->setToolTip(i18n("<qt>Choose here the maximum number of log lines \
displayed in the main view.</qt>"));  maxLines->setWhatsThis(i18n("<qt>You can choose \
here the maximum number of log lines displayed in the main view.</qt>")); @@ -68,7 \
+68,7 @@  logLinesLayout->addWidget(maxLines);
 
 	deleteDuplicatedLines=new QCheckBox(i18n("Delete &duplicated log lines (may be \
                slower)"));
-	connect(deleteDuplicatedLines, SIGNAL(clicked()), this, SLOT(onOptionsChanged()));
+	connect(deleteDuplicatedLines, SIGNAL(clicked()), this, \
SIGNAL(configurationChanged()));  
 	deleteDuplicatedLines->setToolTip(i18n("<qt>Select this option if you want to \
delete duplicated log lines <b>(may be slow)</b>.</qt>"));  \
deleteDuplicatedLines->setWhatsThis(i18n("<qt>You can select this option if you want \
to delete duplicated log lines. <b>This option can slow the reading</b>.</qt>")); @@ \
-79,14 +79,14 @@  options->setLayout(optionsLayout);
 	
 	deleteProcessId=new QCheckBox(i18n("Delete &process identifier from process \
                name"));
-	connect(deleteProcessId, SIGNAL(clicked()), this, SLOT(onOptionsChanged()));
+	connect(deleteProcessId, SIGNAL(clicked()), this, SIGNAL(configurationChanged()));
 	
 	deleteProcessId->setToolTip(i18n("<qt>Delete process identifier from process \
name.</qt>"));  deleteProcessId->setWhatsThis(i18n("<qt>You can select this option if \
you want to delete the process identifier from process name. For example, you will \
sometimes see in the <b>Process</b> column something like <i>cron<b>[3433]</b></i>. \
If this option is activated, the annoying bold part will be erased.</qt>"));  \
optionsLayout->addWidget(deleteProcessId);  
 	colorizeLogLines=new QCheckBox(i18n("&Colorize log lines"), options);
-	connect(colorizeLogLines, SIGNAL(clicked()), this, SLOT(onOptionsChanged()));
+	connect(colorizeLogLines, SIGNAL(clicked()), this, SIGNAL(configurationChanged()));
 	
 	colorizeLogLines->setToolTip(i18n("<qt>This option allows the colorization of log \
lines, depending on their log level.</qt>"));  \
colorizeLogLines->setWhatsThis(i18n("<qt>This option allows the colorization of log \
lines, depending on their log level. For example, an error will be in red, a warning \
in orange... This will help you to better see problems.</qt>")); @@ -103,7 +103,7 @@
 
 
 GeneralConfigurationWidget::~GeneralConfigurationWidget() {
-	//TODO delete the future d-pointer
+
 }
 
 void GeneralConfigurationWidget::readConfig() {
@@ -135,8 +135,4 @@
 	return (maxLines->value()>0);
 }
 
-void GeneralConfigurationWidget::onOptionsChanged() {
-	emit optionsChanged(true);
-}
-
 #include "generalConfigurationWidget.moc"
--- trunk/playground/sysadmin/ksystemlog/src/generalConfigurationWidget.h \
#708616:708617 @@ -27,6 +27,9 @@
 class QCheckBox;
 class QSpinBox;
 
+/**
+ * TODO Parent this class to a Qt Designer file
+ */
 class GeneralConfigurationWidget : public QWidget {
 	
 	Q_OBJECT
@@ -44,15 +47,13 @@
 		void defaultConfig();
 
 		void readConfig();
-
+		
 	signals:
-		void optionsChanged(bool valid);
-	
-	private slots:
-		void onOptionsChanged();
+		void configurationChanged();
 		
 	private:
-		//TODO Move this to a D-pointer
+		
+		//TODO Move to the UI file
 		QSpinBox* maxLines;
 		QCheckBox* deleteDuplicatedLines;
 		
--- trunk/playground/sysadmin/ksystemlog/src/lib/logManager.cpp #708616:708617
@@ -69,7 +69,7 @@
 }
 
 LogManager::~LogManager() {
-	delete d->reader;
+	cleanPreviousLogMode();
 	
 	//usedView is managed by MainWindow
 	//logMode is managed by Globals
@@ -138,9 +138,20 @@
 	
 	emit logUpdated(d->usedView, lineCount);
 }
+
+void LogManager::cleanPreviousLogMode() {
+	logDebug() << "Cleaning previous LogMode..." << endl;
+
+	d->logMode = NULL;
 	
+	delete d->reader;
+	d->reader = NULL;
+}
+
 void LogManager::initialize(LogMode* mode) {
 	logDebug() << "Initializing LogManager..." << endl;
+	
+	cleanPreviousLogMode();
 
 	//Use the new mode
 	d->logMode=mode;
--- trunk/playground/sysadmin/ksystemlog/src/lib/logManager.h #708616:708617
@@ -91,6 +91,8 @@
 		void logUpdated(View* view, int addedLines);
 		
 	private:
+		void cleanPreviousLogMode();
+			
 		LogManagerPrivate* d;
 
 };
--- trunk/playground/sysadmin/ksystemlog/src/lib/logModeConfigurationWidget.cpp \
#708616:708617 @@ -53,4 +53,11 @@
 	return d->header;
 }
 
+/**
+ * Default implementation
+ */
+bool LogModeConfigurationWidget::isValid() const {
+	return true;
+}
+
 #include "logModeConfigurationWidget.moc"
--- trunk/playground/sysadmin/ksystemlog/src/lib/logModeConfigurationWidget.h \
#708616:708617 @@ -36,21 +36,21 @@
 		
 		virtual ~LogModeConfigurationWidget();
 		
-		virtual bool isValid() const = 0;
-
-	public slots:
+		virtual bool isValid() const;
+		
 		virtual void saveConfig() = 0;
 		virtual void defaultConfig() = 0;
+
+	signals:
+		void configurationChanged();
 		
 	public:
 		QString itemName() const;
 		QString iconName() const;
 		QString header() const;
-
-	signals:
-		void optionsChanged(bool valid);
 		
 	private:
+		
 		LogModeConfigurationWidgetPrivate* const d;
 };
 
--- trunk/playground/sysadmin/ksystemlog/src/modes/apache/apacheConfigurationWidget.cpp \
#708616:708617 @@ -44,11 +44,11 @@
 	this->setLayout(layout);
 
 	apacheFileList=new FileList(this, i18n("<p>These files will be analyzed to display \
<b>Apache log</b>.<br />This list also determines the order in which the files are \
                read.</p>"));
-	connect(apacheFileList, SIGNAL(fileListChanged(int)), this, \
SLOT(changeFileList(int))); +	connect(apacheFileList, SIGNAL(fileListChanged(int)), \
this, SLOT(updateConfiguration()));  layout->addWidget(apacheFileList);
 	
 	apacheAccessFileList=new FileList(this, i18n("<p>These files will be analyzed to \
display <b>Apache Access log</b>.<br />This list also determines the order in which \
                the files are read.</p>"));
-	connect(apacheAccessFileList, SIGNAL(fileListChanged(int)), this, \
SLOT(changeFileList(int))); +	connect(apacheAccessFileList, \
SIGNAL(fileListChanged(int)), this, SLOT(updateConfiguration()));  \
layout->addWidget(apacheAccessFileList);  
 	/*
@@ -68,19 +68,12 @@
 }
 
 bool ApacheConfigurationWidget::isValid() const {
-	if (apacheFileList->count()>0)
+	if (apacheFileList->isEmpty()==false && apacheAccessFileList->isEmpty()==false)
 		return true;
 	else
 		return false;
 }
 
-void ApacheConfigurationWidget::changeFileList(int itemLeft) {
-	if (itemLeft==0)
-		emit optionsChanged(false);
-	else
-		emit optionsChanged(true);
-}
-
 void ApacheConfigurationWidget::saveConfig() {
 	logDebug() << "Saving config from Apache Options..." << endl;
 	
--- trunk/playground/sysadmin/ksystemlog/src/modes/apache/apacheConfigurationWidget.h \
#708616:708617 @@ -34,8 +34,6 @@
 		ApacheConfigurationWidget();
 		~ApacheConfigurationWidget();
 		
-		bool isValid() const;
-		
 	public slots:
 	
 		void saveConfig();
@@ -43,7 +41,8 @@
 		
 		void readConfig();
 
-		void changeFileList(int itemLeft);
+	protected:
+		bool isValid() const;
 
 	private:
 
--- trunk/playground/sysadmin/ksystemlog/src/modes/generic/fileList.cpp \
#708616:708617 @@ -102,6 +102,10 @@
 	return fileList->count();
 }
 
+bool FileList::isEmpty() const {
+	return (fileList->count() == 0);
+}
+
 void FileList::addItem() {
 	//Open a standard Filedialog
 	KUrl::List urlList;
--- trunk/playground/sysadmin/ksystemlog/src/modes/generic/fileList.h #708616:708617
@@ -47,6 +47,8 @@
 		void insertItem(const QPixmap& pixmap, const QString& item);
 		
 		int count() const;
+		
+		bool isEmpty() const;
 	
 		QString text(int i) const;
 		
--- trunk/playground/sysadmin/ksystemlog/src/modes/system/systemConfigurationWidget.cpp \
#708616:708617 @@ -49,7 +49,7 @@
 
 	fileList = new SpecificFileList(this, description);
 	
-	connect(fileList, SIGNAL(fileListChanged(int)), this, SLOT(changeFileList(int)));
+	connect(fileList, SIGNAL(fileListChanged(int)), this, SLOT(updateConfiguration()));
 
 	layout->addWidget(fileList);
 
@@ -60,17 +60,10 @@
 }
 
 bool SystemConfigurationWidget::isValid() const {
-	if (fileList->count()>0)
+	if (fileList->isEmpty() == false)
 		return true;
-	else
-		return false;
-}
 
-void SystemConfigurationWidget::changeFileList(int itemLeft) {
-	if (itemLeft==0)
-		emit optionsChanged(false);
-	else
-		emit optionsChanged(true);
+	return false;
 }
 
 void SystemConfigurationWidget::saveConfig() {
--- trunk/playground/sysadmin/ksystemlog/src/modes/system/systemConfigurationWidget.h \
#708616:708617 @@ -36,15 +36,11 @@
 		
 		bool isValid() const;
 		
-	public slots:
-	
 		void saveConfig();
 		void defaultConfig();
 		
 		void readConfig();
-
-		void changeFileList(int itemLeft);
-
+		
 	private:
 		
 		SpecificFileList* fileList;


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

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