summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Matyushin <[email protected]>2015-08-18 01:14:36 +0300
committerVyacheslav Matyushin <[email protected]>2015-08-18 01:14:36 +0300
commitceaa80dc8185bb3f0c5dfab1c9bac19b4f3a40ab (patch)
tree899db324f5bc4d9b1f0c87d2bbaf5ea56e91d90c
parente4fd0cbf5f9f5733eb5a04e5e3c1bed221a50544 (diff)
Added routine to regenerate Logs submenu.
-rw-r--r--src/lib/globals.cpp46
-rw-r--r--src/lib/globals.h2
-rw-r--r--src/mainWindow.cpp13
-rw-r--r--src/mainWindow.h1
4 files changed, 39 insertions, 23 deletions
diff --git a/src/lib/globals.cpp b/src/lib/globals.cpp
index 887129c..4517251 100644
--- a/src/lib/globals.cpp
+++ b/src/lib/globals.cpp
@@ -63,6 +63,8 @@ public:
*/
QList<LogLevel *> logLevels;
+ QList<LogModeFactory *> factories;
+
/**
* These value are only pointers to item of the previous vector,
* they are provided for convenience
@@ -101,28 +103,13 @@ Globals::~Globals()
}
d->logLevels.clear();
- delete d;
-}
-
-/*
-void Globals::setupLogModes() {
- d->noMode=new LogMode("noLogMode", i18n("No Log"), NO_MODE_ICON);
- d->logModes.append(d->noMode);
-
- d->sambaMode=new LogMode("sambaLogMode", i18n("Samba Log"), SAMBA_MODE_ICON);
- d->logModes.append(d->sambaMode);
-
- d->cupsMode=new LogMode("cupsLogMode", i18n("CUPS Log"), CUPS_MODE_ICON);
- d->logModes.append(d->cupsMode);
-
- d->cupsAccessMode=new LogMode("cupsAccessLogMode", i18n("CUPS Access Log"), CUPS_ACCESS_MODE_ICON);
- d->logModes.append(d->cupsAccessMode);
-
- d->postfixMode=new LogMode("postfixLogMode", i18n("Postfix Log"), POSTFIX_MODE_ICON);
- d->logModes.append(d->postfixMode);
+ foreach (LogModeFactory *factory, d->factories) {
+ delete factory;
+ }
+ d->factories.clear();
+ delete d;
}
-*/
void Globals::setupLogLevels()
{
@@ -265,7 +252,7 @@ void Globals::registerLogModeFactory(LogModeFactory *logModeFactory)
d->logModeActions.append(logModeAction);
}
- delete logModeFactory;
+ d->factories.append(logModeFactory);
}
LogMode *Globals::findLogMode(const QString &logModeName)
@@ -273,6 +260,23 @@ LogMode *Globals::findLogMode(const QString &logModeName)
return d->logModes.value(logModeName);
}
+void Globals::recreateLogModeActions()
+{
+ // Delete existing log mode actions.
+ foreach (LogModeAction *logModeAction, d->logModeActions) {
+ delete logModeAction;
+ }
+ d->logModeActions.clear();
+
+ // Create new log mode action for each log mode.
+ foreach (LogModeFactory *factory, d->factories) {
+ LogModeAction *logModeAction = factory->createLogModeAction();
+ if (logModeAction != NULL) {
+ d->logModeActions.append(logModeAction);
+ }
+ }
+}
+
QList<LogModeAction *> Globals::logModeActions()
{
return d->logModeActions;
diff --git a/src/lib/globals.h b/src/lib/globals.h
index 8584363..1fd2132 100644
--- a/src/lib/globals.h
+++ b/src/lib/globals.h
@@ -88,6 +88,8 @@ public:
LogMode *findLogMode(const QString &logModeName);
+ void recreateLogModeActions();
+
private:
explicit Globals();
diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp
index c5d429e..2f965f0 100644
--- a/src/mainWindow.cpp
+++ b/src/mainWindow.cpp
@@ -824,6 +824,14 @@ void MainWindow::selectLogModeAction(bool)
d->tabs->load(currentMode, d->tabs->activeLogManager(), actionData.analyzerOptions);
}
+void MainWindow::recreateActions()
+{
+ unplugActionList(QLatin1String("log_mode_list"));
+ Globals::instance().recreateLogModeActions();
+ setupLogActions();
+ setupLogModeMenu();
+}
+
void MainWindow::setupLogModeMenu()
{
// Sets up the Logs menu.
@@ -865,9 +873,10 @@ void MainWindow::setupLogActions()
foreach (LogModeAction *logModeAction, Globals::instance().logModeActions()) {
foreach (QAction *action, logModeAction->innerActions()) {
ActionData actionData = action->data().value<ActionData>();
- logDebug() << "Adding action" << actionData.id;
- if (actionData.addToActionCollection)
+ if (actionData.addToActionCollection) {
+ logDebug() << "Adding action" << actionData.id;
action = actionCollection()->addAction(actionData.id, action);
+ }
connect(action, SIGNAL(triggered(bool)), this, SLOT(selectLogModeAction(bool)));
}
}
diff --git a/src/mainWindow.h b/src/mainWindow.h
index 6bb3f96..982e335 100644
--- a/src/mainWindow.h
+++ b/src/mainWindow.h
@@ -117,6 +117,7 @@ private slots:
void changeResumePauseAction(bool paused);
void selectLogModeAction(bool);
+ void recreateActions();
private:
void loadLogModePlugins();