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

List:       kde-commits
Subject:    KDE/kdebase/workspace/kcontrol/input
From:       Laurent Montel <montel () kde ! org>
Date:       2009-07-20 21:15:46
Message-ID: 1248124546.058724.19111.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1000121 by mlaurent:

QT3Support--


 M  +2 -2      CMakeLists.txt  
 M  +57 -41    core/themepage.cpp  
 M  +4 -4      core/themepage.h  


--- trunk/KDE/kdebase/workspace/kcontrol/input/CMakeLists.txt #1000120:1000121
@@ -5,6 +5,7 @@
 macro_optional_find_package(USB)
 macro_bool_to_01(LIBUSB_FOUND HAVE_LIBUSB)
 macro_log_feature(LIBUSB_FOUND "libusb" "User level access to USB devices" \
"http://libusb.sourceforge.net/" FALSE "" "Provides Logitech mouse support in \
KControl.") +
 configure_file (config-kcontrol-input.h.cmake \
${CMAKE_CURRENT_BINARY_DIR}/config-kcontrol-input.h )  
 include_directories( ${KDE4_INCLUDES} )
@@ -14,6 +15,7 @@
   include_directories( ${LIBUSB_INCLUDE_DIR} )
 endif (LIBUSB_FOUND)
 
+
 if(X11_Xcursor_FOUND)
   set( libnoinst_SRCS
     xcursor/themepage.cpp
@@ -66,8 +68,6 @@
 endif (LIBUSB_FOUND)
 if (X11_Xcursor_FOUND)
    target_link_libraries(kcm_input ${X11_Xcursor_LIB})
-else(X11_Xcursor_FOUND)
-   target_link_libraries(kcm_input ${KDE4_KDE3SUPPORT_LIBS} ${QT_QT3SUPPORT_LIBRARY} \
)  endif (X11_Xcursor_FOUND)
 if (X11_Xfixes_FOUND)
    target_link_libraries(kcm_input ${X11_Xfixes_LIB})
--- trunk/KDE/kdebase/workspace/kcontrol/input/core/themepage.cpp #1000120:1000121
@@ -28,7 +28,6 @@
 #include <kmessagebox.h>
 #include <klocale.h>
 #include <kconfig.h>
-#include <k3listview.h>
 #include <kdialog.h>
 
 #include <QBoxLayout>
@@ -37,17 +36,13 @@
 #include <QPixmap>
 
 #include "themepage.h"
+#include <QTreeWidget>
 #include "themepage.moc"
 
 #include "bitmaps.h"
 
 
-namespace {
-	// Listview columns
-	enum Columns { NameColumn = 0, DescColumn, /* hidden */ DirColumn };
-}
 
-
 ThemePage::ThemePage( QWidget* parent, const char* name )
 	: QWidget( parent )
 {
@@ -59,17 +54,15 @@
 	layout->addWidget(new QLabel( i18n("Select the cursor theme you want to use:"), \
this ));  
 	// Create the theme list view
-	listview = new K3ListView( this );
-	listview->setFullWidth( true );
-	listview->setAllColumnsShowFocus( true );
-	listview->setSelectionModeExt( K3ListView::Single );
-	listview->addColumn( i18n("Name") );
-	listview->addColumn( i18n("Description") );
-	layout->addWidget(listview);
-
-	connect( listview, SIGNAL(selectionChanged(Q3ListViewItem*)),
-			SLOT(selectionChanged(Q3ListViewItem*)) );
-
+	listview = new QTreeWidget( this );
+        QStringList lstHeader;
+        lstHeader<<i18n("Name")<<i18n("Description");
+        listview->setHeaderLabels( lstHeader );
+        listview->setSelectionMode( QAbstractItemView::SingleSelection );
+        listview->setRootIsDecorated( false );
+        connect( listview, SIGNAL(currentItemChanged ( QTreeWidgetItem *, \
QTreeWidgetItem *) ) +                 , this, SLOT( selectionChanged( \
QTreeWidgetItem*, QTreeWidgetItem* ) ) ); +        layout->addWidget( listview );
 	insertThemes();
 }
 
@@ -79,10 +72,11 @@
 }
 
 
-void ThemePage::selectionChanged( Q3ListViewItem *item )
+void ThemePage::selectionChanged( QTreeWidgetItem*current,QTreeWidgetItem*previous )
 {
-	selectedTheme = item->text( DirColumn );
-	emit changed( selectedTheme != currentTheme );
+    Q_UNUSED( previous );
+    selectedTheme = current->data( 0, Qt::UserRole + 1 ).toString();
+    emit changed( selectedTheme != currentTheme );
 }
 
 
@@ -124,42 +118,64 @@
 		currentTheme = whiteCursor ? "SmallWhite" : "SmallBlack";
 
 	selectedTheme = currentTheme;
-	Q3ListViewItem *item = listview->findItem( currentTheme, DirColumn );
-	item->setSelected( true );
+        for ( int i = 0;i <listview->topLevelItemCount();++i )
+        {
+            QTreeWidgetItem *item = listview->topLevelItem( i );
+            if ( item && item->data(0, Qt::UserRole + 1 ) == currentTheme )
+            {
+                listview->setCurrentItem( item );
+            }
+        }
 }
 
 
 void ThemePage::defaults()
 {
 	currentTheme = selectedTheme = "SmallBlack";
-	Q3ListViewItem *item = listview->findItem( currentTheme, DirColumn );
-	item->setSelected( true );
+        for ( int i = 0;i <listview->topLevelItemCount();++i )
+        {
+            QTreeWidgetItem *item = listview->topLevelItem( i );
+            if ( item && item->data(0, Qt::UserRole + 1 ) == currentTheme )
+            {
+                listview->setCurrentItem( item );
+            }
+        }
 }
 
 
 void ThemePage::insertThemes()
 {
-	K3ListViewItem *item;
+    QList<QTreeWidgetItem *> lstChildren;
+    QTreeWidgetItem *item = new QTreeWidgetItem(listview );
 
-	item = new K3ListViewItem( listview, i18n("Small black"),
-			i18n("Small black cursors"), "SmallBlack" );
-	item->setPixmap( 0, QPixmap( arrow_small_black_xpm ) );
-	listview->insertItem( item );
+    item->setData( 0, Qt::DisplayRole,i18n("Small black")  );
+    item->setData( 1, Qt::DisplayRole, i18n("Small black cursors") );
+    item->setData( 0, Qt::DecorationRole, QPixmap( arrow_small_black_xpm ) );
+    item->setData( 0, Qt::UserRole + 1,"SmallBlack" );
+    lstChildren<<item;
 
-	item = new K3ListViewItem( listview, i18n("Large black"),
-			i18n("Large black cursors"), "LargeBlack" );
-	item->setPixmap( 0, QPixmap( arrow_large_black_xpm ) );
-	listview->insertItem( item );
+    item = new QTreeWidgetItem(listview );
+    item->setData( 0, Qt::DisplayRole, i18n("Large black") );
+    item->setData( 1, Qt::DisplayRole, i18n("Large black cursors") );
+    item->setData( 0, Qt::DecorationRole, QPixmap( arrow_large_black_xpm ) );
+    item->setData( 0, Qt::UserRole + 1,"LargeBlack"  );
+    lstChildren<<item;
 
-	item = new K3ListViewItem( listview, i18n("Small white"),
-			i18n("Small white cursors"), "SmallWhite" );
-	item->setPixmap( 0, QPixmap( arrow_small_white_xpm ) );
-	listview->insertItem( item );
+    item = new QTreeWidgetItem(listview );
+    item->setData( 0, Qt::DisplayRole, i18n("Small white") );
+    item->setData( 1, Qt::DisplayRole, i18n("Small white cursors") );
+    item->setData( 0, Qt::DecorationRole, QPixmap(arrow_small_white_xpm  ) );
+    item->setData( 0, Qt::UserRole + 1,"SmallWhite" );
+    lstChildren<<item;
 
-	item = new K3ListViewItem( listview, i18n("Large white"),
-			i18n("Large white cursors"), "LargeWhite" );
-	item->setPixmap( 0, QPixmap( arrow_large_white_xpm ) );
-	listview->insertItem( item );
+    item = new QTreeWidgetItem(listview );
+    item->setData( 0, Qt::DisplayRole, i18n("Large white") );
+    item->setData( 1, Qt::DisplayRole, i18n("Large white cursors") );
+    item->setData( 0, Qt::DecorationRole, QPixmap( arrow_large_white_xpm ) );
+    item->setData( 0, Qt::UserRole + 1, "LargeWhite" );
+    lstChildren<<item;
+
+    listview->addTopLevelItems( lstChildren );
 }
 
 
--- trunk/KDE/kdebase/workspace/kcontrol/input/core/themepage.h #1000120:1000121
@@ -19,8 +19,8 @@
 #ifndef __THEMEPAGE_H
 #define __THEMEPAGE_H
 
-class K3ListView;
-class Q3ListViewItem;
+class QTreeWidget;
+class QTreeWidgetItem;
 
 class ThemePage : public QWidget
 {
@@ -39,13 +39,13 @@
 		void changed( bool );
 
 	private Q_SLOTS:
-		void selectionChanged( Q3ListViewItem * );
+		void selectionChanged( QTreeWidgetItem *,QTreeWidgetItem* );
 
 	private:
 		void insertThemes();
 		void fixCursorFile();
 
-		K3ListView *listview;
+		QTreeWidget *listview;
 		QString currentTheme, selectedTheme;
 };
 


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

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