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

List:       kde-commits
Subject:    KDE/kdevelop
From:       Adam Treat <treat () kde ! org>
Date:       2005-10-18 4:17:41
Message-ID: 1129609061.590446.9481.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 471551 by treat:

* Track document changes in the document view part


 M  +2 -2      languages/cpp/parsejob.cpp  
 M  +2 -1      parts/documentview/kdevdocumentmodel.cpp  
 M  +32 -13    parts/documentview/kdevdocumentmodel.h  
 M  +12 -2     parts/documentview/kdevdocumentview_part.cpp  
 M  +4 -22     src/documentcontroller.cpp  
 M  +1 -1      src/documentcontroller.h  


--- trunk/KDE/kdevelop/languages/cpp/parsejob.cpp #471550:471551
@@ -98,8 +98,8 @@
 //     m_translationUnit = m_parser->parse( preprocessed, pre_size, m_memoryPool );
     m_translationUnit = m_parser->parse( contents, size, m_memoryPool );
 
-    DumpTree dumpTree;
-    dumpTree.dump( m_translationUnit );
+//     DumpTree dumpTree;
+//     dumpTree.dump( m_translationUnit );
 
     if ( readFromDisk )
         munmap( contents, size );
--- trunk/KDE/kdevelop/parts/documentview/kdevdocumentmodel.cpp #471550:471551
@@ -21,7 +21,8 @@
 #include <QtCore/qdebug.h>
 
 KDevDocumentItem::KDevDocumentItem( const QString &name, KDevItemGroup *parent )
-        : KDevItemCollection( name, parent )
+        : KDevItemCollection( name, parent ),
+        m_documentState( Clean )
 {}
 
 KDevDocumentItem::~KDevDocumentItem()
--- trunk/KDE/kdevelop/parts/documentview/kdevdocumentmodel.h #471550:471551
@@ -21,6 +21,8 @@
 #define KDEVDOCUMENTMODEL_H
 
 #include <kdevitemmodel.h>
+#include <kdevdocumentcontroller.h>
+
 #include <kurl.h>
 #include <kiconloader.h>
 
@@ -44,6 +46,36 @@
     {
         return 0;
     }
+
+    QIcon icon() const
+    {
+        switch ( m_documentState )
+        {
+        case Clean:
+            return QIcon();
+        case Modified:
+            return QIcon( SmallIcon( "filesave" ) );
+        case Dirty:
+            return QIcon( SmallIcon( "revert" ) );
+        case DirtyAndModified:
+            return QIcon( SmallIcon( "stop" ) );
+        default:
+            return QIcon();
+        }
+    }
+
+    DocumentState documentState() const
+    {
+        return m_documentState;
+    }
+
+    void setDocumentState( DocumentState state )
+    {
+        m_documentState = state;
+    }
+
+private:
+    DocumentState m_documentState;
 };
 
 class KDevMimeTypeItem: public KDevDocumentItem
@@ -82,21 +114,8 @@
         m_url = url;
     }
 
-    QIcon icon() const
-    {
-        return m_icon;
-    }
-
-    void KDevFileItem::setIcon( const QString &icon )
-    {
-        QPixmap pixmap = SmallIcon( icon );
-        Q_ASSERT( !pixmap.isNull() );
-        m_icon = QIcon( pixmap );
-    }
-
 private:
     KURL m_url;
-    QIcon m_icon;
 };
 
 class KDevDocumentModel: public KDevItemModel
--- trunk/KDE/kdevelop/parts/documentview/kdevdocumentview_part.cpp #471550:471551
@@ -172,10 +172,20 @@
     kdDebug() << k_funcinfo << endl;
 }
 
-void KDevDocumentViewPart::stateChanged( const KURL & /*url*/,
+void KDevDocumentViewPart::stateChanged( const KURL & url,
         DocumentState state )
 {
-/*    kdDebug() << url.fileName() << " STATE CHANGED " << state << endl;*/
+    KDevDocumentItem * documentItem =
+        m_documentModel->item( m_url2index[ url.path() ] );
+
+    if ( !documentItem )
+        return ;
+
+    if ( documentItem->documentState() == state )
+        return;
+
+    documentItem->setDocumentState( state );
+    m_documentView->doItemsLayout();
 }
 
 void KDevDocumentViewPart::pressed( const QModelIndex & index )
--- trunk/KDE/kdevelop/src/documentcontroller.cpp #471550:471551
@@ -652,19 +652,8 @@
 
 void DocumentController::integrateTextEditorPart( KTextEditor::Document* doc )
 {
-    //EditorProxy::getInstance()->installPopup(doc, contextPopupMenu());
-
-    // What's potentially problematic is that this signal isn't officially part
-    // of the KTextEditor::View interface. It is nevertheless there, and used in
-    // kate and kwrite. There doesn't seem to be any othere way of making this
-    // work with katepart, and since signals are dynamic, if we try to connect
-    // to an editorpart that lacks this signal, all we get is a runtime warning.
-    // At this point in time we are only really supported by katepart anyway so
-    // IMHO this hack is justified.
-    //teatime
-    QList<KDocument::View *> list = doc->views();
-    foreach( KDocument::View * view, list )
-    connect( view, SIGNAL( newStatus() ), this, SLOT( slotNewStatus() ) );
+    connect( doc, SIGNAL( textChanged( KTextEditor::Document* ) ),
+             this, SLOT( slotNewStatus( KTextEditor::Document* ) ) );
 }
 
 void DocumentController::slotPartAdded( KParts::Part * part )
@@ -1401,16 +1390,9 @@
                                DocumentState( status ) );
 }
 
-void DocumentController::slotNewStatus( )
+void DocumentController::slotNewStatus( KTextEditor::Document * doc )
 {
-    kdDebug( 9000 ) << k_funcinfo << endl;
-
-    QObject * senderobj = const_cast<QObject*>( sender() );
-    KTextEditor::View * view = dynamic_cast<KTextEditor::View*>( senderobj );
-    if ( view )
-    {
-        doEmitState( view->document() ->url() );
-    }
+    doEmitState( doc ->url() );
 }
 
 DocumentState DocumentController::documentState( KURL const & url )
--- trunk/KDE/kdevelop/src/documentcontroller.h #471550:471551
@@ -130,7 +130,7 @@
     void slotDocumentDirty( KTextEditor::Document * doc,
                             bool isModified,
                             ModifiedOnDiskReason reason );
-    void slotNewStatus();
+    void slotNewStatus( KTextEditor::Document * doc );
     void slotNewDesignerStatus( const QString &formName, int status );
 
 private:
[prev in list] [next in list] [prev in thread] [next in thread] 

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