27 #include <tdelocale.h>
30 #include <tqintdict.h>
34 TQString CellItem::label()
const
36 return i18n(
"<undefined>");
39 TQPtrList<CellItem> CellItem::placeItem( TQPtrList<CellItem> cells,
42 kdDebug(5855) <<
"Placing " << placeItem->label() << endl;
44 TQPtrList<KOrg::CellItem> conflictItems;
46 TQIntDict<KOrg::CellItem> subCellDict;
49 TQPtrListIterator<KOrg::CellItem> it2( cells );
50 for( it2.toFirst(); it2.current(); ++it2 ) {
51 KOrg::CellItem *item = it2.current();
52 if ( item == placeItem )
continue;
54 if ( item->overlaps( placeItem ) ) {
55 kdDebug(5855) <<
" Overlaps: " << item->label() << endl;
57 conflictItems.append( item );
58 if ( item->subCells() > maxSubCells ) maxSubCells = item->subCells();
59 subCellDict.insert( item->subCell(), item );
63 if ( conflictItems.count() > 0 ) {
66 for( i = 0; i < maxSubCells; ++i ) {
67 kdDebug(5855) <<
" Trying subcell " << i << endl;
68 if ( !subCellDict.find( i ) ) {
69 kdDebug(5855) <<
" Use subcell " << i << endl;
70 placeItem->setSubCell( i );
74 if ( i == maxSubCells ) {
75 kdDebug(5855) <<
" New subcell " << i << endl;
76 placeItem->setSubCell( maxSubCells );
80 kdDebug(5855) <<
" Sub cells: " << maxSubCells << endl;
83 conflictItems.append( placeItem );
84 placeItem->setSubCells( maxSubCells );
86 TQPtrListIterator<KOrg::CellItem> it3( conflictItems );
87 for( it3.toFirst(); it3.current(); ++it3 ) {
88 (*it3)->setSubCells( maxSubCells );
92 kdDebug(5855) <<
" no conflicts" << endl;
93 placeItem->setSubCell( 0 );
94 placeItem->setSubCells( 1 );