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

List:       kde-commits
Subject:    [kate] kate/plugins/project: mark tab captions as i18n and a simple project based notes taking tool
From:       Joseph Wenninger <jowenn () kde ! org>
Date:       2012-10-24 22:35:58
Message-ID: 20121024223558.43AB9A6078 () git ! kde ! org
[Download RAW message or body]

Git commit dc20ea18cfe994280d3a7aaa16e6c32b21dbb4bb by Joseph Wenninger.
Committed on 25/10/2012 at 00:28.
Pushed by jowenn into branch 'master'.

mark tab captions as i18n and a simple project based notes taking tool

M  +1    -0    kate/plugins/project/CMakeLists.txt
M  +49   -1    kate/plugins/project/kateproject.cpp
M  +7    -1    kate/plugins/project/kateproject.h
M  +6    -2    kate/plugins/project/kateprojectinfoview.cpp
C  +16   -14   kate/plugins/project/kateprojectinfoviewnotes.cpp [from: \
kate/plugins/project/kateprojectinfoview.cpp - 064% similarity] A  +79   -0    \
kate/plugins/project/kateprojectinfoviewnotes.h     [License: LGPL (v2+)]

http://commits.kde.org/kate/dc20ea18cfe994280d3a7aaa16e6c32b21dbb4bb

diff --git a/kate/plugins/project/CMakeLists.txt \
b/kate/plugins/project/CMakeLists.txt index edab1c9..54af386 100644
--- a/kate/plugins/project/CMakeLists.txt
+++ b/kate/plugins/project/CMakeLists.txt
@@ -24,6 +24,7 @@ set(kateprojectplugin_PART_SRCS
   kateprojectindex.cpp
   kateprojectinfoviewindex.cpp
   kateprojectinfoviewterminal.cpp
+  kateprojectinfoviewnotes.cpp
 )
 
 kde4_add_plugin(kateprojectplugin ${kateprojectplugin_PART_SRCS})
diff --git a/kate/plugins/project/kateproject.cpp \
b/kate/plugins/project/kateproject.cpp index f62731b..b1bfe77 100644
--- a/kate/plugins/project/kateproject.cpp
+++ b/kate/plugins/project/kateproject.cpp
@@ -26,13 +26,14 @@
 #include <QDir>
 #include <QFile>
 #include <QFileInfo>
-
+#include <QPlainTextDocumentLayout>
 #include <qjson/parser.h>
 
 KateProject::KateProject ()
   : QObject ()
   , m_worker (new KateProjectWorker (this))
   , m_thread (m_worker)
+  , m_notesDocument(0)
 {
   /**
    * move worker object over and start our worker thread
@@ -60,6 +61,19 @@ KateProject::~KateProject ()
    * marks as deleted
    */
   m_worker = 0;
+  
+  if (m_notesDocument) {
+    QString notesFile=dataFile("notes.txt");
+    if (!notesFile.isEmpty()) {
+      QFile outFile(notesFile);
+      outFile.open(QIODevice::Text | QIODevice::WriteOnly);
+      if (outFile.isOpen()) {
+        QTextStream outStream(&outFile);
+        outStream<<m_notesDocument->toPlainText();
+        outFile.close();
+      }
+    }
+  }
 }
 
 bool KateProject::load (const QString &fileName)
@@ -165,4 +179,38 @@ void KateProject::loadIndexDone (KateProjectSharedProjectIndex \
projectIndex)  m_projectIndex = projectIndex;
 }
 
+QString KateProject::dataFile(const QString& filename) {
+  QString dirPath(m_fileName+".user.d");
+  QDir d;
+  if (d.mkpath(dirPath)) {
+    QString fullFilePath=dirPath+QDir::separator()+filename;
+    QFile f(fullFilePath);
+    if (!f.exists()) {
+      f.open(QIODevice::Text | QIODevice::WriteOnly);
+      f.close();
+    }
+    return fullFilePath;
+  } //else error
+  return QString();
+ 
+}
+
+
+QTextDocument* KateProject::notesDocument() {
+    if (!m_notesDocument) {
+      m_notesDocument=new QTextDocument(this);
+      m_notesDocument->setDocumentLayout(new \
QPlainTextDocumentLayout(m_notesDocument)); +      QString \
notesFile=dataFile("notes.txt"); +      if (!notesFile.isEmpty()) {
+        QFile inFile(notesFile);
+        inFile.open(QIODevice::Text | QIODevice::ReadOnly);
+        if (inFile.isOpen()) {
+          QTextStream inStream(&inFile);
+          m_notesDocument->setPlainText(inStream.readAll());
+          inFile.close();
+        }
+      }
+    }
+    return m_notesDocument;
+}
 // kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/plugins/project/kateproject.h b/kate/plugins/project/kateproject.h
index 866d2d7..185e2a2 100644
--- a/kate/plugins/project/kateproject.h
+++ b/kate/plugins/project/kateproject.h
@@ -24,6 +24,7 @@
 #include <QThread>
 #include <QMap>
 #include <QSharedPointer>
+#include <QTextDocument>
 
 #include "kateprojectindex.h"
 
@@ -181,6 +182,8 @@ class KateProject : public QObject
       return m_projectIndex.data();
     }
 
+    QTextDocument *notesDocument();
+    
   private Q_SLOTS:
     /**
      * Used for worker to send back the results of project loading
@@ -207,7 +210,7 @@ class KateProject : public QObject
      * This includes the files list, itemForFile mapping!
      */
     void modelChanged ();
-
+    
   private:
     /**
      * the worker inside the background thread
@@ -252,6 +255,9 @@ class KateProject : public QObject
      * project index, if any
      */
     KateProjectSharedProjectIndex m_projectIndex;
+    
+    QTextDocument *m_notesDocument;
+    QString dataFile(const QString& filename);
 };
 
 #endif
diff --git a/kate/plugins/project/kateprojectinfoview.cpp \
b/kate/plugins/project/kateprojectinfoview.cpp index 06c55ed..02b563e 100644
--- a/kate/plugins/project/kateprojectinfoview.cpp
+++ b/kate/plugins/project/kateprojectinfoview.cpp
@@ -22,6 +22,8 @@
 #include "kateprojectpluginview.h"
 #include "kateprojectinfoviewterminal.h"
 #include "kateprojectinfoviewindex.h"
+#include "kateprojectinfoviewnotes.h"
+#include "klocale.h"
 
 KateProjectInfoView::KateProjectInfoView (KateProjectPluginView *pluginView, \
KateProject *project)  : QTabWidget ()
@@ -31,12 +33,14 @@ KateProjectInfoView::KateProjectInfoView (KateProjectPluginView \
*pluginView, Kat  /**
    * add terminal view
    */
-  addTab (new KateProjectInfoViewTerminal (pluginView, project), "Terminal");
+  addTab (new KateProjectInfoViewTerminal (pluginView, project), i18n("Terminal"));
   
   /**
    * add index view
    */
-  addTab (new KateProjectInfoViewIndex (pluginView, project), "Index");
+  addTab (new KateProjectInfoViewIndex (pluginView, project), i18n("Index"));
+  
+  addTab (new KateProjectInfoViewNotes (pluginView, project), i18n("Notes"));
 }
 
 KateProjectInfoView::~KateProjectInfoView ()
diff --git a/kate/plugins/project/kateprojectinfoview.cpp \
b/kate/plugins/project/kateprojectinfoviewnotes.cpp similarity index 64%
copy from kate/plugins/project/kateprojectinfoview.cpp
copy to kate/plugins/project/kateprojectinfoviewnotes.cpp
index 06c55ed..7f93bc4 100644
--- a/kate/plugins/project/kateprojectinfoview.cpp
+++ b/kate/plugins/project/kateprojectinfoviewnotes.cpp
@@ -1,6 +1,6 @@
 /*  This file is part of the Kate project.
  *
- *  Copyright (C) 2012 Christoph Cullmann <cullmann@kde.org>
+ *  Copyright (C) 2012 Joseph Wenninger <jowenn@kde.org>
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Library General Public
@@ -18,29 +18,31 @@
  *  Boston, MA 02110-1301, USA.
  */
 
-#include "kateprojectinfoview.h"
+#include "kateprojectinfoviewnotes.h"
 #include "kateprojectpluginview.h"
-#include "kateprojectinfoviewterminal.h"
-#include "kateprojectinfoviewindex.h"
 
-KateProjectInfoView::KateProjectInfoView (KateProjectPluginView *pluginView, \
                KateProject *project)
-  : QTabWidget ()
+#include <QVBoxLayout>
+
+KateProjectInfoViewNotes::KateProjectInfoViewNotes (KateProjectPluginView \
*pluginView, KateProject *project) +  : QWidget ()
   , m_pluginView (pluginView)
   , m_project (project)
+  , m_edit (new QPlainTextEdit())
 {
-  /**
-   * add terminal view
+  /*
+   * layout widget
    */
-  addTab (new KateProjectInfoViewTerminal (pluginView, project), "Terminal");
+  QVBoxLayout *layout = new QVBoxLayout;
+  layout->setSpacing (0);
+  layout->addWidget (m_edit);
+  setLayout (layout);
+  m_edit->setDocument(project->notesDocument());
   
-  /**
-   * add index view
-   */
-  addTab (new KateProjectInfoViewIndex (pluginView, project), "Index");
 }
 
-KateProjectInfoView::~KateProjectInfoView ()
+KateProjectInfoViewNotes::~KateProjectInfoViewNotes ()
 {
 }
 
+
 // kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/plugins/project/kateprojectinfoviewnotes.h \
b/kate/plugins/project/kateprojectinfoviewnotes.h new file mode 100644
index 0000000..e2d60a5
--- /dev/null
+++ b/kate/plugins/project/kateprojectinfoviewnotes.h
@@ -0,0 +1,79 @@
+/*  This file is part of the Kate project.
+ *
+ *  Copyright (C) 2012 Joseph Wenninger <jowenn@kde.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KATE_PROJECT_INFO_VIEW_NOTES_H
+#define KATE_PROJECT_INFO_VIEW_NOTES_H
+
+#include "kateproject.h"
+
+#include <QPlainTextEdit>
+
+class KateProjectPluginView;
+
+/**
+ * Class representing a view of a project.
+ * A tree like view of project content.
+ */
+class KateProjectInfoViewNotes : public QWidget
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * construct project info view for given project
+     * @param pluginView our plugin view
+     * @param project project this view is for
+     */
+    KateProjectInfoViewNotes (KateProjectPluginView *pluginView, KateProject \
*project); +
+    /**
+     * deconstruct info view
+     */
+    ~KateProjectInfoViewNotes ();
+
+    /**
+     * our project.
+     * @return project
+     */
+    KateProject *project () const
+    {
+      return m_project;
+    }
+    
+
+
+  private:
+    /**
+     * our plugin view
+     */
+    KateProjectPluginView *m_pluginView;
+
+    /**
+     * our project
+     */
+    KateProject *m_project;
+    
+    QPlainTextEdit *m_edit;
+
+};
+
+#endif
+
+// kate: space-indent on; indent-width 2; replace-tabs on;


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

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