Mailinglist Archive: yast-commit (1056 mails)
| < Previous | Next > |
[yast-commit] r44968 - in /branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings: kcmodulemodel.cpp menuitem.cpp menuitem.h
- From: tgoettlicher@xxxxxxxxxxxxxxxx
- Date: Sat, 23 Feb 2008 13:18:33 -0000
- Message-id: <20080223131833.6B18E36A85@xxxxxxxxxxxxxxxx>
Author: tgoettlicher
Date: Sat Feb 23 14:18:33 2008
New Revision: 44968
URL: http://svn.opensuse.org/viewcvs/yast?rev=44968&view=rev
Log:
data structure access cleaned up
Modified:
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.cpp
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h
Modified:
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp?rev=44968&r1=44967&r2=44968&view=diff
==============================================================================
---
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp
(original)
+++
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp
Sat Feb 23 14:18:33 2008
@@ -107,7 +107,6 @@
if ( index.isValid() ) {
mi = static_cast<MenuItem *>( index.internalPointer() );
} else {
-// mi = d->rootItem->children[0];
mi = d->rootItem;
}
if ( mi )
@@ -115,7 +114,6 @@
if ( i )
foreach ( MenuItem * j, i->children )
count += j->children.count();
-// count += i->children.count();
std::cout << "rowCount: " << count << std::endl;
@@ -135,22 +133,48 @@
return QModelIndex();
}
MenuItem * parentItem;
+
+ int rowOffset=0;
+
+ if ( !parent.isValid() )
+ {
+ for (int child = 0; child < d->rootItem->children.count(); child++)
+ {
+ parentItem = d->rootItem->children[child];
+
+ MenuItem * foundItem = parentItem->grandChildAt( row - rowOffset
);
+ if ( foundItem ) {
+ QModelIndex index = createIndex( row, column, (void*)foundItem
);
+ return index;
+ }
+ rowOffset += parentItem->rowCount(row);
+ }
+ }
+ else
+ {
+ parentItem = static_cast<MenuItem*>( parent.internalPointer() );
+ MenuItem * foundItem = parentItem->grandChildAt( row );
+ if ( foundItem ) {
+ QModelIndex index = createIndex( row, column, (void*)foundItem );
+ return index;
+ }
+ }
+/*
+
if ( !parent.isValid() ) {
- parentItem = d->rootItem->children[0];
- // parentItem = d->rootItem;
+ parentItem = d->rootItem;
} else {
parentItem = static_cast<MenuItem*>( parent.internalPointer() );
}
-// MenuItem * foundItem = parentItem->greatGrandChildAt( row );
- MenuItem * foundItem = parentItem->grandChildAt( row );
+
+ MenuItem * foundItem = parentItem->greatGrandChildAt( row );
if ( foundItem ) {
QModelIndex index = createIndex( row, column, (void*)foundItem );
return index;
}
-
+/*
if ( !parent.isValid() ) {
parentItem = d->rootItem->children[1];
- // parentItem = d->rootItem;
} else {
parentItem = static_cast<MenuItem*>( parent.internalPointer() );
}
@@ -159,17 +183,37 @@
QModelIndex index = createIndex( row, column, (void*)foundItem );
return index;
}
+*/
+/*
+MenuItem * MenuItem::grandChildAt( int index )
+{
+ int count = 0;
+ MenuItem * foundItem = 0;
+ foreach ( MenuItem * child, children ) {
+ foreach ( MenuItem * grandChild, child->children ) {
+ if ( count == index ) {
+ foundItem = grandChild;
+ break;
+ }
+ count++;
+ }
+ if ( foundItem ) {
+ break;
+ }
+ }
+ return foundItem;
+}
+*/
+ return QModelIndex();
-
- return QModelIndex();
}
Modified:
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.cpp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.cpp?rev=44968&r1=44967&r2=44968&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.cpp
(original)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.cpp Sat
Feb 23 14:18:33 2008
@@ -79,3 +79,16 @@
return foundItem;
}
+int MenuItem::rowCount( int index )
+{
+ int count = 0;
+ MenuItem * foundItem = 0;
+ foreach ( MenuItem * child, children ) {
+ foreach ( MenuItem * grandChild, child->children ) {
+ count++;
+ }
+ }
+ return count;
+}
+
+
Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h?rev=44968&r1=44967&r2=44968&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h
(original)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h Sat
Feb 23 14:18:33 2008
@@ -33,6 +33,7 @@
MenuItem( bool isMenu, MenuItem * parent );
~MenuItem();
MenuItem * grandChildAt( int index );
+ int rowCount (int index);
MenuItem * greatGrandChildAt( int index );
MenuItem * parent;
QList< MenuItem * > children;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
Date: Sat Feb 23 14:18:33 2008
New Revision: 44968
URL: http://svn.opensuse.org/viewcvs/yast?rev=44968&view=rev
Log:
data structure access cleaned up
Modified:
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.cpp
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h
Modified:
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp?rev=44968&r1=44967&r2=44968&view=diff
==============================================================================
---
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp
(original)
+++
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp
Sat Feb 23 14:18:33 2008
@@ -107,7 +107,6 @@
if ( index.isValid() ) {
mi = static_cast<MenuItem *>( index.internalPointer() );
} else {
-// mi = d->rootItem->children[0];
mi = d->rootItem;
}
if ( mi )
@@ -115,7 +114,6 @@
if ( i )
foreach ( MenuItem * j, i->children )
count += j->children.count();
-// count += i->children.count();
std::cout << "rowCount: " << count << std::endl;
@@ -135,22 +133,48 @@
return QModelIndex();
}
MenuItem * parentItem;
+
+ int rowOffset=0;
+
+ if ( !parent.isValid() )
+ {
+ for (int child = 0; child < d->rootItem->children.count(); child++)
+ {
+ parentItem = d->rootItem->children[child];
+
+ MenuItem * foundItem = parentItem->grandChildAt( row - rowOffset
);
+ if ( foundItem ) {
+ QModelIndex index = createIndex( row, column, (void*)foundItem
);
+ return index;
+ }
+ rowOffset += parentItem->rowCount(row);
+ }
+ }
+ else
+ {
+ parentItem = static_cast<MenuItem*>( parent.internalPointer() );
+ MenuItem * foundItem = parentItem->grandChildAt( row );
+ if ( foundItem ) {
+ QModelIndex index = createIndex( row, column, (void*)foundItem );
+ return index;
+ }
+ }
+/*
+
if ( !parent.isValid() ) {
- parentItem = d->rootItem->children[0];
- // parentItem = d->rootItem;
+ parentItem = d->rootItem;
} else {
parentItem = static_cast<MenuItem*>( parent.internalPointer() );
}
-// MenuItem * foundItem = parentItem->greatGrandChildAt( row );
- MenuItem * foundItem = parentItem->grandChildAt( row );
+
+ MenuItem * foundItem = parentItem->greatGrandChildAt( row );
if ( foundItem ) {
QModelIndex index = createIndex( row, column, (void*)foundItem );
return index;
}
-
+/*
if ( !parent.isValid() ) {
parentItem = d->rootItem->children[1];
- // parentItem = d->rootItem;
} else {
parentItem = static_cast<MenuItem*>( parent.internalPointer() );
}
@@ -159,17 +183,37 @@
QModelIndex index = createIndex( row, column, (void*)foundItem );
return index;
}
+*/
+/*
+MenuItem * MenuItem::grandChildAt( int index )
+{
+ int count = 0;
+ MenuItem * foundItem = 0;
+ foreach ( MenuItem * child, children ) {
+ foreach ( MenuItem * grandChild, child->children ) {
+ if ( count == index ) {
+ foundItem = grandChild;
+ break;
+ }
+ count++;
+ }
+ if ( foundItem ) {
+ break;
+ }
+ }
+ return foundItem;
+}
+*/
+ return QModelIndex();
-
- return QModelIndex();
}
Modified:
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.cpp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.cpp?rev=44968&r1=44967&r2=44968&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.cpp
(original)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.cpp Sat
Feb 23 14:18:33 2008
@@ -79,3 +79,16 @@
return foundItem;
}
+int MenuItem::rowCount( int index )
+{
+ int count = 0;
+ MenuItem * foundItem = 0;
+ foreach ( MenuItem * child, children ) {
+ foreach ( MenuItem * grandChild, child->children ) {
+ count++;
+ }
+ }
+ return count;
+}
+
+
Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h?rev=44968&r1=44967&r2=44968&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h
(original)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h Sat
Feb 23 14:18:33 2008
@@ -33,6 +33,7 @@
MenuItem( bool isMenu, MenuItem * parent );
~MenuItem();
MenuItem * grandChildAt( int index );
+ int rowCount (int index);
MenuItem * greatGrandChildAt( int index );
MenuItem * parent;
QList< MenuItem * > children;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
| < Previous | Next > |