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

List:       kde-commits
Subject:    KDE/kdevplatform/plugins/cvs
From:       Robert Gruber <rgruber () users ! sourceforge ! net>
Date:       2007-12-08 17:54:43
Message-ID: 1197136483.110855.3043.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 746322 by rgruber:

Use VcsAnnotationModel for CVS' AnnotateView


 M  +1 -0      CMakeLists.txt  
 M  +19 -12    annotateview.cpp  
 M  +5 -1      annotateview.h  
 M  +12 -10    annotateview.ui  


--- trunk/KDE/kdevplatform/plugins/cvs/CMakeLists.txt #746321:746322
@@ -6,6 +6,7 @@
     ${CMAKE_SOURCE_DIR}/project
     ${CMAKE_SOURCE_DIR}/vcs
     ${CMAKE_SOURCE_DIR}/vcs/interfaces
+    ${CMAKE_SOURCE_DIR}/vcs/models
 )
 
 
--- trunk/KDE/kdevplatform/plugins/cvs/annotateview.cpp #746321:746322
@@ -13,8 +13,11 @@
 #include <QTextBrowser>
 #include <QRegExp>
 #include <QDir>
+#include <QHeaderView>
 #include <KDebug>
 
+#include <vcsannotationmodel.h>
+
 #include "cvsplugin.h"
 #include "cvsjob.h"
 
@@ -24,6 +27,16 @@
 {
     Ui::AnnotateViewBase::setupUi(this);
 
+    m_model = new KDevelop::VcsAnnotationModel( KUrl() );
+    annotations->setModel( m_model );
+
+    annotations->verticalHeader()->setVisible(false);
+
+    QHeaderView* header = annotations->horizontalHeader();
+    header->setResizeMode(0, QHeaderView::ResizeToContents);
+    header->setResizeMode(1, QHeaderView::ResizeToContents);
+    header->setResizeMode(2, QHeaderView::Stretch);
+
     if (job) {
         connect(job, SIGNAL( result(KJob*) ),
                 this, SLOT( slotJobFinished(KJob*) ));
@@ -38,7 +51,6 @@
 {
     if ( job->error() )
     {
-        textbrowser->append( i18n("Listing annotations failed") );
         return;
     }
 
@@ -48,24 +60,19 @@
     }
 
 
+    // Convert job's output into KDevelop::VcsAnnotation
     KDevelop::VcsAnnotation annotateInfo;
-
     parseOutput(cvsjob->output(), cvsjob->getDirectory(), annotateInfo);
 
-    /// @todo better us a QModel and a QTableView here
-    QString html;
-
-    html += annotateInfo.location().path()+"\n\n";
-    for(int i=1; i <= annotateInfo.lineCount(); i++) {
+    QList<KDevelop::VcsAnnotationLine> lines;
+    for(int i=0; i < annotateInfo.lineCount(); i++) {
         KDevelop::VcsAnnotationLine line = annotateInfo.line(i);
 
-        html += QString::number(line.lineNumber())+":";
-        html += line.revision().revisionValue().toString()+":";
-        html += line.author()+":";
-        html += line.text()+"\n";
+        lines << line;
     }
 
-    textbrowser->setPlainText( html );
+    // Fill model with data
+    m_model->addLines( lines );
 }
 
 void AnnotateView::parseOutput(const QString& jobOutput, const QString& \
                workingDirectory, KDevelop::VcsAnnotation& annotateInfo)
--- trunk/KDE/kdevplatform/plugins/cvs/annotateview.h #746321:746322
@@ -20,6 +20,10 @@
 
 class CvsPlugin;
 class CvsJob;
+namespace KDevelop
+{
+class VcsAnnotationModel;
+}
 
 /**
  * Shows the output from @code cvs annotate @endcode in a nice way.
@@ -56,7 +60,7 @@
 
 private:
     CvsPlugin* m_plugin;
-    QString m_output;
+    KDevelop::VcsAnnotationModel* m_model;
 };
 
 #endif
--- trunk/KDE/kdevplatform/plugins/cvs/annotateview.ui #746321:746322
@@ -12,9 +12,9 @@
   <property name="windowTitle" >
    <string>Annotate</string>
   </property>
-  <layout class="QVBoxLayout" >
+  <layout class="QHBoxLayout" >
    <property name="spacing" >
-    <number>0</number>
+    <number>-1</number>
    </property>
    <property name="leftMargin" >
     <number>0</number>
@@ -29,23 +29,25 @@
     <number>0</number>
    </property>
    <item>
-    <widget class="KTextBrowser" name="textbrowser" >
+    <widget class="QTableView" name="annotations" >
      <property name="frameShape" >
       <enum>QFrame::NoFrame</enum>
      </property>
+     <property name="selectionMode" >
+      <enum>QAbstractItemView::SingleSelection</enum>
+     </property>
+     <property name="selectionBehavior" >
+      <enum>QAbstractItemView::SelectRows</enum>
+     </property>
+     <property name="showGrid" >
+      <bool>false</bool>
+     </property>
     </widget>
    </item>
   </layout>
  </widget>
  <layoutdefault spacing="6" margin="11" />
  <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
- <customwidgets>
-  <customwidget>
-   <class>KTextBrowser</class>
-   <extends>QTextBrowser</extends>
-   <header>ktextbrowser.h</header>
-  </customwidget>
- </customwidgets>
  <resources/>
  <connections/>
 </ui>


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

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