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

List:       kde-commits
Subject:    [plasmate/terietor/konsolepreviewer] /: Simplify the code and don't bother the Previewer with stuff
From:       Giorgos Tsiapaliokas <terietor () gmail ! com>
Date:       2012-08-16 7:46:06
Message-ID: 20120816074606.B514BA60CD () git ! kde ! org
[Download RAW message or body]

Git commit 46983170adb22acfbb665484eafe98c85bbe199f by Giorgos Tsiapaliokas.
Committed on 16/08/2012 at 09:43.
Pushed by tsiapaliwkas into branch 'terietor/konsolepreviewer'.

Simplify the code and don't bother the Previewer with stuff relevant
to customMessageHandler

M  +16   -2    konsole/konsolepreviewer.cpp
M  +2    -1    konsole/konsolepreviewer.h
M  +6    -20   mainwindow.cpp
M  +0    -1    mainwindow.h
M  +0    -12   previewer/previewer.cpp
M  +0    -6    previewer/previewer.h

http://commits.kde.org/plasmate/46983170adb22acfbb665484eafe98c85bbe199f

diff --git a/konsole/konsolepreviewer.cpp b/konsole/konsolepreviewer.cpp
index 29095b5..711b4a3 100644
--- a/konsole/konsolepreviewer.cpp
+++ b/konsole/konsolepreviewer.cpp
@@ -64,9 +64,10 @@ void KonsolePreviewer::clearTmpFile()
 }
 
 
-void KonsolePreviewer::setOutput(const QString& output)
+void KonsolePreviewer::populateKonsole()
 {
-    m_textEdit->setText(output);
+    m_textEdit->setText(takeOutput());
+
 
     //move the scrollbar automatically,
     //in the end of the output
@@ -75,6 +76,19 @@ void KonsolePreviewer::setOutput(const QString& output)
     m_textEdit->setTextCursor(c);
 }
 
+QString KonsolePreviewer::takeOutput() const
+{
+    QFile file("/var/tmp/plasmatepreviewerlog.txt");
+    if (file.open(QIODevice::ReadOnly)) {
+        QString content = file.readAll();
+        file.close();
+        return content;
+    }
+
+    return QString();
+}
+
+
 void KonsolePreviewer::saveOutput()
 {
     KUser user;
diff --git a/konsole/konsolepreviewer.h b/konsole/konsolepreviewer.h
index 6e7f3de..8dd4369 100644
--- a/konsole/konsolepreviewer.h
+++ b/konsole/konsolepreviewer.h
@@ -34,11 +34,12 @@ public:
 public Q_SLOTS:
     void clearOutput();
     void clearTmpFile();
-    void setOutput(const QString& output);
+    void populateKonsole();
     void saveOutput();
 
 private:
     KTextEdit *m_textEdit;
+    QString takeOutput() const;
 };
 
 #endif // KONSOLEPREVIEWER_H
diff --git a/mainwindow.cpp b/mainwindow.cpp
index c3d2d4a..b4eef08 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -663,24 +663,6 @@ void MainWindow::showKonsolePreviewer()
     }
 }
 
-void MainWindow::reloadKonsolePreviewer()
-{
-
-    if (m_konsole) {
-        m_konsole->setOutput(m_previewerWidget->takeOutput());
-    }
-
-    //at the main.cpp we made the plasmatepreviewerlog.txt
-    //file handler to append the data, because customMessageHandler
-    //is called with every q/kDebug what plasmate calls.
-    //but now with have added the data in our widget, and
-    //we don't want the plasmatepreviewerlog.txt to have the same
-    //date multiple times. So clear its data and in the refreshPreview
-    //it will take again the data that it wants, because the previewer
-    //will be recreated and the customMessageHandler event loop will
-    //take place for once more
-}
-
 void MainWindow::loadMetaDataEditor(KUrl target)
 {
     // save any previous editor content
@@ -828,7 +810,7 @@ void MainWindow::loadProject(const QString &path)
         m_previewerWidget->setVisible(showPreview);
 
         //now do the relative stuff for the konsole
-        m_konsole->setOutput(m_previewerWidget->takeOutput());
+        m_konsole->populateKonsole();
         m_konsole->setObjectName("Previewer Output");
         connect(m_previewerWidget, SIGNAL(showKonsole()), this, SLOT(showKonsolePreviewer()));
         addDockWidget(Qt::BottomDockWidgetArea, m_konsole);
@@ -984,6 +966,10 @@ void MainWindow::customMessageHandler(QtMsgType type, const QString& msg)
         QTextStream ts(&outFile);
         ts << txt << endl;
         outFile.close();
-        reloadKonsolePreviewer();
+
+        //populate the konsole
+        if (m_konsole) {
+            m_konsole->populateKonsole();
+        }
     }
 }
\ No newline at end of file
diff --git a/mainwindow.h b/mainwindow.h
index 4b65fd2..f25b30e 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -112,7 +112,6 @@ private Q_SLOTS:
     void toggleFileList();
     void installPackage();
     void showKonsolePreviewer();
-    void reloadKonsolePreviewer();
 
     // refreshes editor, killing all local changes
     void editorDestructiveRefresh();
diff --git a/previewer/previewer.cpp b/previewer/previewer.cpp
index 86f8c8b..6f07098 100644
--- a/previewer/previewer.cpp
+++ b/previewer/previewer.cpp
@@ -37,15 +37,3 @@ void Previewer::emitShowKonsole()
 {
     emit showKonsole();
 }
-
-QString Previewer::takeOutput() const
-{
-    QFile file("/var/tmp/plasmatepreviewerlog.txt");
-    if (file.open(QIODevice::ReadOnly)) {
-        QString content = file.readAll();
-        file.close();
-        return content;
-    }
-
-    return QString();
-}
\ No newline at end of file
diff --git a/previewer/previewer.h b/previewer/previewer.h
index d91f0a2..271bab8 100644
--- a/previewer/previewer.h
+++ b/previewer/previewer.h
@@ -40,12 +40,6 @@ public:
     virtual void showPreview(const QString &packagePath) = 0;
 
     /**
-     * Subclasses should override this method with the actual code which
-     * will take the output
-     **/
-    QString takeOutput() const;
-
-    /**
      * Subclasses should override this method with code that refreshes the preview
      */
     virtual void refreshPreview() = 0;
[prev in list] [next in list] [prev in thread] [next in thread] 

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