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

List:       kde-commits
Subject:    KDE/kdepim/kpilot/kpilot
From:       Bertjan Broeksema <b.broeksema () home ! nl>
Date:       2007-08-24 12:38:10
Message-ID: 1187959090.978888.31934.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 704240 by bbroeksema:

* Show info of the selected record. The todoviewer is as good
  as complete again now.


 M  +20 -5     todoviewer_page.cc  
 M  +2 -4      todoviewer_page.h  
 M  +20 -1     viewer_page_base.cc  
 M  +14 -5     viewer_page_base.h  
 M  +2 -15     viewer_page_base.ui  


--- trunk/KDE/kdepim/kpilot/kpilot/todoviewer_page.cc #704239:704240
@@ -50,14 +50,10 @@
 
 QListWidgetItem* TodoViewerPage::getListWidgetItem( PilotRecord *rec )
 {
-	FUNCTIONSETUP;
-	
-	PilotTodoEntry *todo;
-	
 	if( !( rec->isDeleted() ) &&
 		( !( rec->isSecret() ) || KPilotSettings::showSecrets() ) )
 	{
-		todo = new PilotTodoEntry( rec );
+		PilotTodoEntry *todo = new PilotTodoEntry( rec );
 		if( todo )
 		{
 			QListWidgetItem *newItem = new QListWidgetItem;
@@ -78,3 +74,22 @@
 	
 	return 0L;
 }
+
+QString TodoViewerPage::getRecordInfo( PilotRecord *rec )
+{
+	if( !( rec->isDeleted() ) &&
+		( !( rec->isSecret() ) || KPilotSettings::showSecrets() ) )
+	{
+		PilotTodoEntry *todo = new PilotTodoEntry( rec );
+		if( todo )
+		{
+			QString text( CSL1( "<qt>" ) );
+			text += todo->getTextRepresentation( Qt::RichText );
+			text += CSL1( "</qt>\n" );
+			
+			return text;
+		}
+	}
+	
+	return QString();
+}
--- trunk/KDE/kdepim/kpilot/kpilot/todoviewer_page.h #704239:704240
@@ -41,11 +41,9 @@
 	 */
 	virtual PilotAppInfoBase* loadAppInfo();
 	
-	/**
-	 * This can be used to change the display of the items in the list. If this
-	 * returns 0 then the default delegate will be used.
-	 */
 	virtual QListWidgetItem* getListWidgetItem( PilotRecord *rec );
+	
+	virtual QString getRecordInfo( PilotRecord *rec );
 };
 
 #endif
--- trunk/KDE/kdepim/kpilot/kpilot/viewer_page_base.cc #704239:704240
@@ -97,6 +97,10 @@
 		
 		connect( fP->fWidgetUi.fCategories, SIGNAL( activated( int ) )
 			, this, SLOT( changeFilter( int ) ) );
+			
+		connect( fP->fWidgetUi.fRecordList
+			, SIGNAL( itemClicked( QListWidgetItem* ) ), this
+			, SLOT( changeInfo( QListWidgetItem* ) ) );
 	}
 	
 	fP->fDatabase = new PilotLocalDatabase( fP->fDbPath, fP->fDbName );
@@ -165,16 +169,31 @@
 				if( item )
 				{
 					fP->fWidgetUi.fRecordList->insertItem( i, item );
+					
+					item->setData( Qt::UserRole, QVariant( (qlonglong) rec->id() ) );
 				}
 			}
 				
-				rec = fP->fDatabase->readRecordByIndex( ++i );
+			rec = fP->fDatabase->readRecordByIndex( ++i );
 		}
 	}
 }
 
 void ViewerPageBase::changeFilter( int index )
 {
+	fP->fWidgetUi.fRecordInfo->clear();
 	fP->fCurrentCategory = fP->fWidgetUi.fCategories->itemData( index ).toInt();
 	populateRecords();
 }
+
+void ViewerPageBase::changeInfo( QListWidgetItem *item )
+{
+	FUNCTIONSETUP;
+	
+	if( fP->fDatabase && fP->fDatabase->isOpen() )
+	{
+		recordid_t id = item->data( Qt::UserRole ).toLongLong();
+		PilotRecord *rec = fP->fDatabase->readRecordById( id );
+		fP->fWidgetUi.fRecordInfo->setText( getRecordInfo( rec ) );
+	}
+}
--- trunk/KDE/kdepim/kpilot/kpilot/viewer_page_base.h #704239:704240
@@ -31,6 +31,8 @@
 
 #include <QtGui/QListWidgetItem>
 
+#include <klocalizedstring.h>
+
 class PilotAppInfoBase;
 class PilotDatabase;
 class PilotRecord;
@@ -58,15 +60,17 @@
 	 */
 	virtual PilotAppInfoBase* loadAppInfo() = 0;
 	
-	/**
-	 * This can be used to change the display of the items in the list. If this
-	 * returns 0 then the default delegate will be used.
-	 */
 	virtual QListWidgetItem* getListWidgetItem( PilotRecord *rec )
 	{
 		Q_UNUSED( rec );
-		return new QListWidgetItem();
+		return new QListWidgetItem( i18n( "not implemented by subclass" ) );
 	}
+	
+	virtual QString getRecordInfo( PilotRecord *rec )
+	{
+		Q_UNUSED( rec );
+		return i18n( "not implemented by subclass" );
+	}
 
 public slots:
 	/**
@@ -88,6 +92,11 @@
 	 * @p index.
 	 */
 	void changeFilter( int index );
+	
+	/**
+	 * Changes the info field with the selected record.
+	 */
+	void changeInfo( QListWidgetItem *item );
 
 private: // methods
 	void populateCategories();
--- trunk/KDE/kdepim/kpilot/kpilot/viewer_page_base.ui #704239:704240
@@ -33,7 +33,7 @@
      </item>
     </layout>
    </item>
-   <item row="0" column="1" colspan="2" >
+   <item row="0" column="1" >
     <layout class="QVBoxLayout" >
      <item>
       <widget class="QLabel" name="fRecordInfoLabel" >
@@ -63,22 +63,9 @@
      </item>
     </layout>
    </item>
-   <item row="0" column="3" >
+   <item row="1" column="1" >
     <spacer>
      <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>31</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="1" column="2" >
-    <spacer>
-     <property name="orientation" >
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" >
[prev in list] [next in list] [prev in thread] [next in thread] 

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