summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-01 13:07:01 (UTC)
committer zautrix <zautrix>2005-04-01 13:07:01 (UTC)
commit93003b1f8348f112648d3cc20acb21b062220e21 (patch) (unidiff)
tree901bebe154a15f05296158db5da3689b849e8281
parentf8e027db1d950ec27a3c47fc2a5ea2fe49ae9772 (diff)
downloadkdepimpi-93003b1f8348f112648d3cc20acb21b062220e21.zip
kdepimpi-93003b1f8348f112648d3cc20acb21b062220e21.tar.gz
kdepimpi-93003b1f8348f112648d3cc20acb21b062220e21.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp2
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp32
-rw-r--r--microkde/KDGanttMinimizeSplitter.h2
3 files changed, 34 insertions, 2 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 09d70f1..15e094d 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1122,121 +1122,121 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1122 ensureItemVisible ( cn ); 1122 ensureItemVisible ( cn );
1123 } 1123 }
1124 emit showIncidence( ci->data()); 1124 emit showIncidence( ci->data());
1125 } 1125 }
1126 } 1126 }
1127 e->accept(); 1127 e->accept();
1128 } 1128 }
1129 break; 1129 break;
1130 case Qt::Key_Return: 1130 case Qt::Key_Return:
1131 case Qt::Key_Enter: 1131 case Qt::Key_Enter:
1132 { 1132 {
1133 QListViewItem* cn; 1133 QListViewItem* cn;
1134 cn = currentItem(); 1134 cn = currentItem();
1135 if ( cn ) { 1135 if ( cn ) {
1136 KOListViewItem* ci = (KOListViewItem*)( cn ); 1136 KOListViewItem* ci = (KOListViewItem*)( cn );
1137 if ( ci ){ 1137 if ( ci ){
1138 if ( e->state() == ShiftButton ) 1138 if ( e->state() == ShiftButton )
1139 ci->setSelected( false ); 1139 ci->setSelected( false );
1140 else 1140 else
1141 ci->setSelected( true ); 1141 ci->setSelected( true );
1142 cn = cn->nextSibling(); 1142 cn = cn->nextSibling();
1143 if ( cn ) { 1143 if ( cn ) {
1144 setCurrentItem ( cn ); 1144 setCurrentItem ( cn );
1145 ensureItemVisible ( cn ); 1145 ensureItemVisible ( cn );
1146 } 1146 }
1147 } 1147 }
1148 } 1148 }
1149 e->accept(); 1149 e->accept();
1150 } 1150 }
1151 break; 1151 break;
1152 default: 1152 default:
1153 e->ignore(); 1153 e->ignore();
1154 } 1154 }
1155} 1155}
1156KOListViewListView::KOListViewListView(KOListView * lv ) 1156KOListViewListView::KOListViewListView(KOListView * lv )
1157 : KListView( lv, "kolistlistview", false ) 1157 : KListView( lv, "kolistlistview", false )
1158{ 1158{
1159 mPopupTimer = new QTimer(this); 1159 mPopupTimer = new QTimer(this);
1160 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1160 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1161#ifndef DESKTOP_VERSION 1161#ifndef DESKTOP_VERSION
1162 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1162 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1163#endif 1163#endif
1164 setSelectionMode( QListView::Multi ); 1164 setSelectionMode( QListView::Multi );
1165 setMultiSelection( true); 1165 setMultiSelection( true);
1166} 1166}
1167void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1167void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1168{ 1168{
1169 if (!e) return; 1169 if (!e) return;
1170 QPoint vp = contentsToViewport(e->pos()); 1170 QPoint vp = contentsToViewport(e->pos());
1171 QListViewItem *item = itemAt(vp); 1171 QListViewItem *item = itemAt(vp);
1172 if (!item) { 1172 if (!item) {
1173 emit newEvent(); 1173 emit newEvent();
1174 return; 1174 return;
1175 } 1175 }
1176 KListView::contentsMouseDoubleClickEvent(e); 1176 KListView::contentsMouseDoubleClickEvent(e);
1177} 1177}
1178#if 0 1178#if 0
1179void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1179void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1180{ 1180{
1181 //qDebug("contentsMousePressEvent++++ "); 1181 //qDebug("contentsMousePressEvent++++ ");
1182 KListView::contentsMousePressEvent( e ); 1182 KListView::contentsMousePressEvent( e );
1183 if ( e->button() == RightButton ) { 1183 if ( e->button() == RightButton ) {
1184 QListViewItem* ci = currentItem(); 1184 QListViewItem* ci = currentItem();
1185 clearSelection () ; 1185 clearSelection () ;
1186 if ( ci ) 1186 if ( ci )
1187 ci->setSelected( true ); 1187 ci->setSelected( true );
1188 } 1188 }
1189} 1189}
1190void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1190void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1191{ 1191{
1192 KListView::contentsMouseReleaseEvent(e); 1192 KListView::contentsMouseReleaseEvent(e);
1193} 1193}
1194void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1194void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1195{ 1195{
1196 KListView::contentsMouseMoveEvent(e); 1196 KListView::contentsMouseMoveEvent(e);
1197} 1197}
1198#endif 1198#endif
1199void KOListViewListView::popupMenu() 1199void KOListViewListView::popupMenu()
1200{ 1200{
1201 mPopupTimer->stop(); 1201 mPopupTimer->stop();
1202 //qDebug("HUUUUUUUUUUUUUUUUUUUU "); 1202 //qDebug("HUUUUUUUUUUUUUUUUUUUU ");
1203 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1203 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1204 QApplication::postEvent( this->viewport(), e ); 1204 QApplication::postEvent( this->viewport(), e );
1205} 1205}
1206void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1206void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1207{ 1207{
1208 //qDebug("contentsMousePressEvent++++ "); 1208 //qDebug("contentsMousePressEvent++++ ");
1209 mYMousePos = mapToGlobal( (e->pos())).y(); 1209 mYMousePos = mapToGlobal( (e->pos())).y();
1210 if ( e->button() == LeftButton ) { 1210 if ( e->button() == LeftButton ) {
1211 mPopupTimer->start( 600 ); 1211 mPopupTimer->start( 600 );
1212 mEventPos = e->pos(); 1212 mEventPos = e->pos();
1213 mEventGlobalPos = e->globalPos(); 1213 mEventGlobalPos = e->globalPos();
1214 } 1214 }
1215 KListView::contentsMousePressEvent( e ); 1215 KListView::contentsMousePressEvent( e );
1216 if ( e->button() == RightButton ) { 1216 if ( e->button() == RightButton ) {
1217 QListViewItem* ci = currentItem(); 1217 QListViewItem* ci = currentItem();
1218 clearSelection(); 1218 //clearSelection();
1219 if ( ci ) 1219 if ( ci )
1220 ci->setSelected( true ); 1220 ci->setSelected( true );
1221 } 1221 }
1222} 1222}
1223void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1223void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1224{ 1224{
1225 mPopupTimer->stop(); 1225 mPopupTimer->stop();
1226 KListView::contentsMouseReleaseEvent(e); 1226 KListView::contentsMouseReleaseEvent(e);
1227} 1227}
1228void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1228void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1229{ 1229{
1230 // qDebug("contentsMouseMoveEv....... "); 1230 // qDebug("contentsMouseMoveEv....... ");
1231 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1231 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1232 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1232 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1233 if ( diff < 0 ) diff = -diff; 1233 if ( diff < 0 ) diff = -diff;
1234 if ( diff > 15 ) 1234 if ( diff > 15 )
1235 mPopupTimer->stop(); 1235 mPopupTimer->stop();
1236 else { 1236 else {
1237 mEventPos = e->pos(); 1237 mEventPos = e->pos();
1238 mEventGlobalPos = e->globalPos(); 1238 mEventGlobalPos = e->globalPos();
1239 } 1239 }
1240 KListView::contentsMouseMoveEvent(e); 1240 KListView::contentsMouseMoveEvent(e);
1241} 1241}
1242 1242
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index 029f14b..ea3a329 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -96,192 +96,194 @@ void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
96 if ( o == KDGanttMinimizeSplitter::Horizontal ) 96 if ( o == KDGanttMinimizeSplitter::Horizontal )
97 setCursor( splitHCursor ); 97 setCursor( splitHCursor );
98 else 98 else
99 setCursor( splitVCursor ); 99 setCursor( splitVCursor );
100#endif 100#endif
101} 101}
102 102
103 103
104void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 104void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
105{ 105{
106 updateCursor( e->pos() ); 106 updateCursor( e->pos() );
107 if ( !(e->state()&LeftButton) ) 107 if ( !(e->state()&LeftButton) )
108 return; 108 return;
109 109
110 if ( _activeButton != 0) 110 if ( _activeButton != 0)
111 return; 111 return;
112 112
113 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 113 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
114 - mouseOffset; 114 - mouseOffset;
115 if ( opaque() ) { 115 if ( opaque() ) {
116 s->moveSplitter( pos, id() ); 116 s->moveSplitter( pos, id() );
117 } else { 117 } else {
118 int min = pos; int max = pos; 118 int min = pos; int max = pos;
119 s->getRange( id(), &min, &max ); 119 s->getRange( id(), &min, &max );
120 s->setRubberband( QMAX( min, QMIN(max, pos ))); 120 s->setRubberband( QMAX( min, QMIN(max, pos )));
121 } 121 }
122 _collapsed = false; 122 _collapsed = false;
123} 123}
124 124
125void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) 125void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
126{ 126{
127 if ( e->button() == LeftButton ) { 127 if ( e->button() == LeftButton ) {
128 _activeButton = onButton( e->pos() ); 128 _activeButton = onButton( e->pos() );
129 mouseOffset = s->pick(e->pos()); 129 mouseOffset = s->pick(e->pos());
130 mMouseDown = true; 130 mMouseDown = true;
131 repaint(); 131 repaint();
132 updateCursor( e->pos() ); 132 updateCursor( e->pos() );
133 } 133 }
134} 134}
135 135
136void KDGanttSplitterHandle::updateCursor( const QPoint& p) 136void KDGanttSplitterHandle::updateCursor( const QPoint& p)
137{ 137{
138 if ( onButton( p ) != 0 ) { 138 if ( onButton( p ) != 0 ) {
139 setCursor( arrowCursor ); 139 setCursor( arrowCursor );
140 } 140 }
141 else { 141 else {
142 if ( orient == KDGanttMinimizeSplitter::Horizontal ) 142 if ( orient == KDGanttMinimizeSplitter::Horizontal )
143 setCursor( splitHCursor ); 143 setCursor( splitHCursor );
144 else 144 else
145 setCursor( splitVCursor ); 145 setCursor( splitVCursor );
146 } 146 }
147} 147}
148void KDGanttSplitterHandle::toggle() 148void KDGanttSplitterHandle::toggle()
149{ 149{
150 int pos; 150 int pos;
151 int min, max; 151 int min, max;
152 if ( !_collapsed ) { 152 if ( !_collapsed ) {
153 s->expandPos( id(), &min, &max ); 153 s->expandPos( id(), &min, &max );
154 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left 154 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
155 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 155 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
156 pos = min; 156 pos = min;
157 } 157 }
158 else { 158 else {
159 pos = max; 159 pos = max;
160 } 160 }
161 161
162 _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); 162 _origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
163 s->moveSplitter( pos, id() ); 163 s->moveSplitter( pos, id() );
164 _collapsed = true; 164 _collapsed = true;
165 } 165 }
166 else { 166 else {
167 s->moveSplitter( _origPos, id() ); 167 s->moveSplitter( _origPos, id() );
168 _collapsed = false; 168 _collapsed = false;
169 } 169 }
170 repaint(); 170 repaint();
171} 171}
172 172
173void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 173void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
174{ 174{
175 mMouseDown = false; 175 mMouseDown = false;
176 if ( _activeButton != 0 ) { 176 if ( _activeButton != 0 ) {
177 if ( onButton( e->pos() ) == _activeButton ) 177 if ( onButton( e->pos() ) == _activeButton )
178 { 178 {
179 toggle(); 179 toggle();
180 } 180 }
181 _activeButton = 0; 181 _activeButton = 0;
182 updateCursor( e->pos() ); 182 updateCursor( e->pos() );
183 } 183 }
184 else { 184 else {
185 if ( !opaque() && e->button() == LeftButton ) { 185 if ( !opaque() && e->button() == LeftButton ) {
186 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 186 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
187 - mouseOffset; 187 - mouseOffset;
188 s->setRubberband( -1 ); 188 s->setRubberband( -1 );
189 s->moveSplitter( pos, id() ); 189 s->moveSplitter( pos, id() );
190 } 190 }
191 } 191 }
192 if ( s->rubberBand() )
193 s->rubberBand()->hide();
192 repaint(); 194 repaint();
193} 195}
194 196
195int KDGanttSplitterHandle::onButton( const QPoint& p ) 197int KDGanttSplitterHandle::onButton( const QPoint& p )
196{ 198{
197 QValueList<QPointArray> list = buttonRegions(); 199 QValueList<QPointArray> list = buttonRegions();
198 int index = 1; 200 int index = 1;
199 int add = 12; 201 int add = 12;
200 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 202 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
201 QRect rect = (*it).boundingRect(); 203 QRect rect = (*it).boundingRect();
202 rect.setLeft( rect.left()- add ); 204 rect.setLeft( rect.left()- add );
203 rect.setRight( rect.right() + add); 205 rect.setRight( rect.right() + add);
204 rect.setTop( rect.top()- add ); 206 rect.setTop( rect.top()- add );
205 rect.setBottom( rect.bottom() + add); 207 rect.setBottom( rect.bottom() + add);
206 if ( rect.contains( p ) ) { 208 if ( rect.contains( p ) ) {
207 return index; 209 return index;
208 } 210 }
209 index++; 211 index++;
210 } 212 }
211 return 0; 213 return 0;
212} 214}
213 215
214 216
215QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() 217QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
216{ 218{
217 QValueList<QPointArray> list; 219 QValueList<QPointArray> list;
218 220
219 int sw = 8; 221 int sw = 8;
220 int yyy = 1; 222 int yyy = 1;
221 int xxx = 1; 223 int xxx = 1;
222 int voffset[] = { (int) -sw*3, (int) sw*3 }; 224 int voffset[] = { (int) -sw*3, (int) sw*3 };
223 for ( int i = 0; i < 2; i++ ) { 225 for ( int i = 0; i < 2; i++ ) {
224 QPointArray arr; 226 QPointArray arr;
225 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || 227 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ||
226 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { 228 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) {
227 int mid = height()/2 + voffset[i]; 229 int mid = height()/2 + voffset[i];
228 arr.setPoints( 3, 230 arr.setPoints( 3,
229 1-xxx, mid - sw + 4, 231 1-xxx, mid - sw + 4,
230 sw-3-xxx, mid, 232 sw-3-xxx, mid,
231 1-xxx, mid + sw -4); 233 1-xxx, mid + sw -4);
232 } 234 }
233 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 235 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
234 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 236 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
235 int mid = height()/2 + voffset[i]; 237 int mid = height()/2 + voffset[i];
236 arr.setPoints( 3, 238 arr.setPoints( 3,
237 sw-4, mid - sw + 4, 239 sw-4, mid - sw + 4,
238 0, mid, 240 0, mid,
239 sw-4, mid + sw - 4); 241 sw-4, mid + sw - 4);
240 } 242 }
241 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 243 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
242 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { 244 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) {
243 int mid = width()/2 + voffset[i]; 245 int mid = width()/2 + voffset[i];
244 arr.setPoints( 3, 246 arr.setPoints( 3,
245 mid - sw + 4, sw-4, 247 mid - sw + 4, sw-4,
246 mid, 0, 248 mid, 0,
247 mid + sw - 4, sw-4 ); 249 mid + sw - 4, sw-4 );
248 } 250 }
249 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || 251 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down ||
250 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 252 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
251 int mid = width()/2 + voffset[i]; 253 int mid = width()/2 + voffset[i];
252 arr.setPoints( 3, 254 arr.setPoints( 3,
253 mid - sw + 4, 1-yyy, 255 mid - sw + 4, 1-yyy,
254 mid, sw-3-yyy, 256 mid, sw-3-yyy,
255 mid + sw -4, 1-yyy); 257 mid + sw -4, 1-yyy);
256 } 258 }
257 list.append( arr ); 259 list.append( arr );
258 } 260 }
259 return list; 261 return list;
260} 262}
261 263
262void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) 264void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
263{ 265{
264 QPixmap buffer( size() ); 266 QPixmap buffer( size() );
265 QPainter p( &buffer ); 267 QPainter p( &buffer );
266 268
267 //LR 269 //LR
268 // Draw the splitter rectangle 270 // Draw the splitter rectangle
269 p.setBrush( colorGroup().background() ); 271 p.setBrush( colorGroup().background() );
270 p.setPen( colorGroup().foreground() ); 272 p.setPen( colorGroup().foreground() );
271 //p.drawRect( rect() ); 273 //p.drawRect( rect() );
272 buffer.fill( colorGroup().background() ); 274 buffer.fill( colorGroup().background() );
273 //buffer.fill( backgroundColor() ); 275 //buffer.fill( backgroundColor() );
274 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); 276 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup());
275 277
276 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size 278 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size
277 279
278 // arrow color 280 // arrow color
279 QColor col; 281 QColor col;
280 if ( _activeButton ) 282 if ( _activeButton )
281 col = colorGroup().background().dark( 250 ); 283 col = colorGroup().background().dark( 250 );
282 else { 284 else {
283 if ( mMouseDown ) 285 if ( mMouseDown )
284 col = Qt::white; 286 col = Qt::white;
285 else 287 else
286 col = colorGroup().background().dark( 150 ); 288 col = colorGroup().background().dark( 150 );
287 } 289 }
@@ -341,425 +343,453 @@ void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
341} 343}
342#endif 344#endif
343 345
344class QSplitterLayoutStruct 346class QSplitterLayoutStruct
345{ 347{
346public: 348public:
347 KDGanttMinimizeSplitter::ResizeMode mode; 349 KDGanttMinimizeSplitter::ResizeMode mode;
348 QCOORD sizer; 350 QCOORD sizer;
349 bool isSplitter; 351 bool isSplitter;
350 QWidget *wid; 352 QWidget *wid;
351}; 353};
352 354
353class QSplitterData 355class QSplitterData
354{ 356{
355public: 357public:
356 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} 358 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
357 359
358 QPtrList<QSplitterLayoutStruct> list; 360 QPtrList<QSplitterLayoutStruct> list;
359 bool opaque; 361 bool opaque;
360 bool firstShow; 362 bool firstShow;
361}; 363};
362 364
363void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 365void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
364 int space, int spacer ); 366 int space, int spacer );
365#endif // DOXYGEN_SKIP_INTERNAL 367#endif // DOXYGEN_SKIP_INTERNAL
366 368
367 369
368/*! 370/*!
369 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h 371 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h
370 \brief The KDGanttMinimizeSplitter class implements a splitter 372 \brief The KDGanttMinimizeSplitter class implements a splitter
371 widget with minimize buttons. 373 widget with minimize buttons.
372 374
373 This class (and its documentation) is largely a copy of Qt's 375 This class (and its documentation) is largely a copy of Qt's
374 QSplitter; the copying was necessary because QSplitter is not 376 QSplitter; the copying was necessary because QSplitter is not
375 extensible at all. QSplitter and its documentation are licensed 377 extensible at all. QSplitter and its documentation are licensed
376 according to the GPL and the Qt Professional License (if you hold 378 according to the GPL and the Qt Professional License (if you hold
377 such a license) and are (C) Trolltech AS. 379 such a license) and are (C) Trolltech AS.
378 380
379 A splitter lets the user control the size of child widgets by 381 A splitter lets the user control the size of child widgets by
380 dragging the boundary between the children. Any number of widgets 382 dragging the boundary between the children. Any number of widgets
381 may be controlled. 383 may be controlled.
382 384
383 To show a QListBox, a QListView and a QTextEdit side by side: 385 To show a QListBox, a QListView and a QTextEdit side by side:
384 386
385 \code 387 \code
386 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); 388 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent );
387 QListBox *lb = new QListBox( split ); 389 QListBox *lb = new QListBox( split );
388 QListView *lv = new QListView( split ); 390 QListView *lv = new QListView( split );
389 QTextEdit *ed = new QTextEdit( split ); 391 QTextEdit *ed = new QTextEdit( split );
390 \endcode 392 \endcode
391 393
392 In KDGanttMinimizeSplitter, the boundary can be either horizontal or 394 In KDGanttMinimizeSplitter, the boundary can be either horizontal or
393 vertical. The default is horizontal (the children are side by side) 395 vertical. The default is horizontal (the children are side by side)
394 but you can use setOrientation( QSplitter::Vertical ) to set it to 396 but you can use setOrientation( QSplitter::Vertical ) to set it to
395 vertical. 397 vertical.
396 398
397 Use setResizeMode() to specify 399 Use setResizeMode() to specify
398 that a widget should keep its size when the splitter is resized. 400 that a widget should keep its size when the splitter is resized.
399 401
400 Although KDGanttMinimizeSplitter normally resizes the children only 402 Although KDGanttMinimizeSplitter normally resizes the children only
401 at the end of a resize operation, if you call setOpaqueResize( TRUE 403 at the end of a resize operation, if you call setOpaqueResize( TRUE
402 ) the widgets are resized as often as possible. 404 ) the widgets are resized as often as possible.
403 405
404 The initial distribution of size between the widgets is determined 406 The initial distribution of size between the widgets is determined
405 by the initial size of each widget. You can also use setSizes() to 407 by the initial size of each widget. You can also use setSizes() to
406 set the sizes of all the widgets. The function sizes() returns the 408 set the sizes of all the widgets. The function sizes() returns the
407 sizes set by the user. 409 sizes set by the user.
408 410
409 If you hide() a child, its space will be distributed among the other 411 If you hide() a child, its space will be distributed among the other
410 children. It will be reinstated when you show() it again. It is also 412 children. It will be reinstated when you show() it again. It is also
411 possible to reorder the widgets within the splitter using 413 possible to reorder the widgets within the splitter using
412 moveToFirst() and moveToLast(). 414 moveToFirst() and moveToLast().
413*/ 415*/
414 416
415 417
416 418
417static QSize minSize( const QWidget* /*w*/ ) 419static QSize minSize( const QWidget* /*w*/ )
418{ 420{
419 return QSize(0,0); 421 return QSize(0,0);
420} 422}
421 423
422// This is the original version of minSize 424// This is the original version of minSize
423static QSize minSizeHint( const QWidget* w ) 425static QSize minSizeHint( const QWidget* w )
424{ 426{
425 QSize min = w->minimumSize(); 427 QSize min = w->minimumSize();
426 QSize s; 428 QSize s;
427 if ( min.height() <= 0 || min.width() <= 0 ) 429 if ( min.height() <= 0 || min.width() <= 0 )
428 s = w->minimumSizeHint(); 430 s = w->minimumSizeHint();
429 if ( min.height() > 0 ) 431 if ( min.height() > 0 )
430 s.setHeight( min.height() ); 432 s.setHeight( min.height() );
431 if ( min.width() > 0 ) 433 if ( min.width() > 0 )
432 s.setWidth( min.width() ); 434 s.setWidth( min.width() );
433 return s.expandedTo(QSize(0,0)); 435 return s.expandedTo(QSize(0,0));
434} 436}
435 437
436 438
437
438/*! 439/*!
439 Constructs a horizontal splitter with the \a parent and \a 440 Constructs a horizontal splitter with the \a parent and \a
440 name arguments being passed on to the QFrame constructor. 441 name arguments being passed on to the QFrame constructor.
441*/ 442*/
442KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) 443KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
443 :QFrame(parent,name,WPaintUnclipped) 444 :QFrame(parent,name,WPaintUnclipped)
444{ 445{
446 mRubberBand = 0;
445 mFirstHandle = 0; 447 mFirstHandle = 0;
446#if QT_VERSION >= 232 448#if QT_VERSION >= 232
447 orient = Horizontal; 449 orient = Horizontal;
448 init(); 450 init();
449#endif 451#endif
450} 452}
451 453
452/*! 454/*!
453 Constructs a splitter with orientation \a o with the \a parent 455 Constructs a splitter with orientation \a o with the \a parent
454 and \a name arguments being passed on to the QFrame constructor. 456 and \a name arguments being passed on to the QFrame constructor.
455*/ 457*/
456KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 458KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
457 :QFrame(parent,name,WPaintUnclipped) 459 :QFrame(parent,name,WPaintUnclipped)
458{ 460{
461
462 mRubberBand = 0;
459 mFirstHandle = 0; 463 mFirstHandle = 0;
460#if QT_VERSION >= 232 464#if QT_VERSION >= 232
461 orient = o; 465 orient = o;
462 init(); 466 init();
463#endif 467#endif
464} 468}
465 469
466/*! 470/*!
467 Destroys the splitter and any children. 471 Destroys the splitter and any children.
468*/ 472*/
469KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 473KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
470{ 474{
471#if QT_VERSION >= 232 475#if QT_VERSION >= 232
472 data->list.setAutoDelete( TRUE ); 476 data->list.setAutoDelete( TRUE );
473 delete data; 477 delete data;
474#endif 478#endif
479 if ( mRubberBand )
480 delete mRubberBand;
475} 481}
476 482
477 483
478#if QT_VERSION >= 232 484#if QT_VERSION >= 232
479void KDGanttMinimizeSplitter::init() 485void KDGanttMinimizeSplitter::init()
480{ 486{
481 data = new QSplitterData; 487 data = new QSplitterData;
482 if ( orient == Horizontal ) 488 if ( orient == Horizontal )
483 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); 489 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
484 else 490 else
485 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); 491 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
486#ifndef DESKTOP_VERSION 492#ifndef DESKTOP_VERSION
487 setOpaqueResize( false ); 493 setOpaqueResize( false );
488#else 494#else
489 setOpaqueResize( true ); 495 setOpaqueResize( true );
490#endif 496#endif
491} 497}
492#endif 498#endif
493 499
494 500
495void KDGanttMinimizeSplitter::toggle() 501void KDGanttMinimizeSplitter::toggle()
496{ 502{
497 if ( mFirstHandle ) 503 if ( mFirstHandle )
498 mFirstHandle->toggle(); 504 mFirstHandle->toggle();
499 else 505 else
500 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); 506 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available ");
501 507
502} 508}
503 509
504 510
505/*! 511/*!
506 \brief the orientation of the splitter 512 \brief the orientation of the splitter
507 513
508 By default the orientation is horizontal (the widgets are side by side). 514 By default the orientation is horizontal (the widgets are side by side).
509 The possible orientations are Qt:Vertical and Qt::Horizontal (the default). 515 The possible orientations are Qt:Vertical and Qt::Horizontal (the default).
510*/ 516*/
511void KDGanttMinimizeSplitter::setOrientation( Orientation o ) 517void KDGanttMinimizeSplitter::setOrientation( Orientation o )
512{ 518{
513#if QT_VERSION >= 232 519#if QT_VERSION >= 232
514 if ( orient == o ) 520 if ( orient == o )
515 return; 521 return;
516 orient = o; 522 orient = o;
517 523
518 if ( orient == Horizontal ) 524 if ( orient == Horizontal )
519 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 525 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
520 else 526 else
521 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 527 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
522 528
523 QSplitterLayoutStruct *s = data->list.first(); 529 QSplitterLayoutStruct *s = data->list.first();
524 while ( s ) { 530 while ( s ) {
525 if ( s->isSplitter ) 531 if ( s->isSplitter )
526 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); 532 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o );
527 s = data->list.next(); // ### next at end of loop, no iterator 533 s = data->list.next(); // ### next at end of loop, no iterator
528 } 534 }
529 recalc( isVisible() ); 535 recalc( isVisible() );
530#endif 536#endif
531} 537}
532 538
533 539
534#if QT_VERSION >= 232 540#if QT_VERSION >= 232
535/*! 541/*!
536 \reimp 542 \reimp
537*/ 543*/
538void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) 544void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * )
539{ 545{
540 doResize(); 546 doResize();
541} 547}
542 548
543 549
544/* 550/*
545 Inserts the widget \a w at the end (or at the beginning if \a first 551 Inserts the widget \a w at the end (or at the beginning if \a first
546 is TRUE) of the splitter's list of widgets. 552 is TRUE) of the splitter's list of widgets.
547 553
548 It is the responsibility of the caller of this function to make sure 554 It is the responsibility of the caller of this function to make sure
549 that \a w is not already in the splitter and to call recalcId if 555 that \a w is not already in the splitter and to call recalcId if
550 needed. (If \a first is TRUE, then recalcId is very probably 556 needed. (If \a first is TRUE, then recalcId is very probably
551 needed.) 557 needed.)
552*/ 558*/
553QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) 559QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first )
554{ 560{
555 QSplitterLayoutStruct *s; 561 QSplitterLayoutStruct *s;
556 KDGanttSplitterHandle *newHandle = 0; 562 KDGanttSplitterHandle *newHandle = 0;
557 if ( data->list.count() > 0 ) { 563 if ( data->list.count() > 0 ) {
558 s = new QSplitterLayoutStruct; 564 s = new QSplitterLayoutStruct;
559 s->mode = KeepSize; 565 s->mode = KeepSize;
560 QString tmp = "qt_splithandle_"; 566 QString tmp = "qt_splithandle_";
561 tmp += w->name(); 567 tmp += w->name();
562 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); 568 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() );
563 if ( ! mFirstHandle ) 569 if ( ! mFirstHandle )
564 mFirstHandle = newHandle; 570 mFirstHandle = newHandle;
565 s->wid = newHandle; 571 s->wid = newHandle;
566 newHandle->setId(data->list.count()); 572 newHandle->setId(data->list.count());
567 s->isSplitter = TRUE; 573 s->isSplitter = TRUE;
568 s->sizer = pick( newHandle->sizeHint() ); 574 s->sizer = pick( newHandle->sizeHint() );
569 if ( first ) 575 if ( first )
570 data->list.insert( 0, s ); 576 data->list.insert( 0, s );
571 else 577 else
572 data->list.append( s ); 578 data->list.append( s );
573 } 579 }
574 s = new QSplitterLayoutStruct; 580 s = new QSplitterLayoutStruct;
575 s->mode = Stretch; 581 s->mode = Stretch;
576 s->wid = w; 582 s->wid = w;
577 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 583 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
578 s->sizer = pick( w->sizeHint() ); 584 s->sizer = pick( w->sizeHint() );
579 else 585 else
580 s->sizer = pick( w->size() ); 586 s->sizer = pick( w->size() );
581 s->isSplitter = FALSE; 587 s->isSplitter = FALSE;
582 if ( first ) 588 if ( first )
583 data->list.insert( 0, s ); 589 data->list.insert( 0, s );
584 else 590 else
585 data->list.append( s ); 591 data->list.append( s );
586 if ( newHandle && isVisible() ) 592 if ( newHandle && isVisible() )
587 newHandle->show(); //will trigger sending of post events 593 newHandle->show(); //will trigger sending of post events
588 return s; 594 return s;
589} 595}
590 596
591 597
592/*! 598/*!
593 Tells the splitter that a child widget has been inserted or removed. 599 Tells the splitter that a child widget has been inserted or removed.
594 The event is passed in \a c. 600 The event is passed in \a c.
595*/ 601*/
596void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) 602void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
597{ 603{
598 if ( c->type() == QEvent::ChildInserted ) { 604 if ( c->type() == QEvent::ChildInserted ) {
599 if ( !c->child()->isWidgetType() ) 605 if ( !c->child()->isWidgetType() )
600 return; 606 return;
601 607
602 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) 608 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
603 return; 609 return;
604 610
605 QSplitterLayoutStruct *s = data->list.first(); 611 QSplitterLayoutStruct *s = data->list.first();
606 while ( s ) { 612 while ( s ) {
607 if ( s->wid == c->child() ) 613 if ( s->wid == c->child() )
608 return; 614 return;
609 s = data->list.next(); 615 s = data->list.next();
610 } 616 }
611 addWidget( (QWidget*)c->child() ); 617 addWidget( (QWidget*)c->child() );
612 recalc( isVisible() ); 618 recalc( isVisible() );
613 619
614 } else if ( c->type() == QEvent::ChildRemoved ) { 620 } else if ( c->type() == QEvent::ChildRemoved ) {
615 QSplitterLayoutStruct *p = 0; 621 QSplitterLayoutStruct *p = 0;
616 if ( data->list.count() > 1 ) 622 if ( data->list.count() > 1 )
617 p = data->list.at(1); //remove handle _after_ first widget. 623 p = data->list.at(1); //remove handle _after_ first widget.
618 QSplitterLayoutStruct *s = data->list.first(); 624 QSplitterLayoutStruct *s = data->list.first();
619 while ( s ) { 625 while ( s ) {
620 if ( s->wid == c->child() ) { 626 if ( s->wid == c->child() ) {
621 data->list.removeRef( s ); 627 data->list.removeRef( s );
622 delete s; 628 delete s;
623 if ( p && p->isSplitter ) { 629 if ( p && p->isSplitter ) {
624 data->list.removeRef( p ); 630 data->list.removeRef( p );
625 delete p->wid; //will call childEvent 631 delete p->wid; //will call childEvent
626 delete p; 632 delete p;
627 } 633 }
628 recalcId(); 634 recalcId();
629 doResize(); 635 doResize();
630 return; 636 return;
631 } 637 }
632 p = s; 638 p = s;
633 s = data->list.next(); 639 s = data->list.next();
634 } 640 }
635 } 641 }
636} 642}
637 643
638 644
639/*! 645/*!
640 Shows a rubber band at position \a p. If \a p is negative, the 646 Shows a rubber band at position \a p. If \a p is negative, the
641 rubber band is removed. 647 rubber band is removed.
642*/ 648*/
643void KDGanttMinimizeSplitter::setRubberband( int p ) 649void KDGanttMinimizeSplitter::setRubberband( int p )
644{ 650{
651#ifdef DESKTOP_VERSION
645 QPainter paint( this ); 652 QPainter paint( this );
646 paint.setPen( gray ); 653 paint.setPen( gray );
647 paint.setBrush( gray ); 654 paint.setBrush( gray );
648 paint.setRasterOp( XorROP ); 655 paint.setRasterOp( XorROP );
649 QRect r = contentsRect(); 656 QRect r = contentsRect();
650 const int rBord = 3; //Themable???? 657 const int rBord = 3; //Themable????
651#if QT_VERSION >= 0x030000 658#if QT_VERSION >= 0x030000
652 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 659 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
653#else 660#else
654 int sw = style().splitterWidth(); 661 int sw = style().splitterWidth();
655#endif 662#endif
656 if ( orient == Horizontal ) { 663 if ( orient == Horizontal ) {
657 if ( opaqueOldPos >= 0 ) 664 if ( opaqueOldPos >= 0 )
658 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 665 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
659 2*rBord, r.height() ); 666 2*rBord, r.height() );
660 if ( p >= 0 ) 667 if ( p >= 0 )
661 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 668 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
662 } else { 669 } else {
663 if ( opaqueOldPos >= 0 ) 670 if ( opaqueOldPos >= 0 )
664 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 671 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
665 r.width(), 2*rBord ); 672 r.width(), 2*rBord );
666 if ( p >= 0 ) 673 if ( p >= 0 )
667 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 674 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
668 } 675 }
669 opaqueOldPos = p; 676 opaqueOldPos = p;
677#else
678 if ( !mRubberBand ) {
679 mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop);
680 mRubberBand->setFrameStyle( Box | Raised );
681 mRubberBand->setPalette( QPalette ( Qt::green.light(),Qt::green.dark() ) );
682 }
683 QRect r = contentsRect();
684 const int rBord = 5; //Themable????
685 int sw = style().splitterWidth();
686 if ( orient == Horizontal ) {
687 if ( p >= 0 ) {
688 QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y()));
689 mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() );
690 }
691 } else {
692 if ( p >= 0 ) {
693 QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord));
694 mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord);
695 }
696 }
697 opaqueOldPos = p;
698 mRubberBand->show();
699#endif
670} 700}
671 701
672 702
673/*! \reimp */ 703/*! \reimp */
674bool KDGanttMinimizeSplitter::event( QEvent *e ) 704bool KDGanttMinimizeSplitter::event( QEvent *e )
675{ 705{
676 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 706 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
677 recalc( isVisible() ); 707 recalc( isVisible() );
678 if ( e->type() == QEvent::Show ) 708 if ( e->type() == QEvent::Show )
679 data->firstShow = FALSE; 709 data->firstShow = FALSE;
680 } 710 }
681 return QWidget::event( e ); 711 return QWidget::event( e );
682} 712}
683 713
684 714
685/*! 715/*!
686 \obsolete 716 \obsolete
687 717
688 Draws the splitter handle in the rectangle described by \a x, \a y, 718 Draws the splitter handle in the rectangle described by \a x, \a y,
689 \a w, \a h using painter \a p. 719 \a w, \a h using painter \a p.
690 \sa QStyle::drawPrimitive() 720 \sa QStyle::drawPrimitive()
691*/ 721*/
692void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, 722void KDGanttMinimizeSplitter::drawSplitter( QPainter *p,
693 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 723 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
694{ 724{
695#if 0 725#if 0
696 // LR 726 // LR
697 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), 727 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(),
698 (orientation() == Qt::Horizontal ? 728 (orientation() == Qt::Horizontal ?
699 QStyle::Style_Horizontal : 0)); 729 QStyle::Style_Horizontal : 0));
700#endif 730#endif
701} 731}
702 732
703 733
704/*! 734/*!
705 Returns the id of the splitter to the right of or below the widget \a w, 735 Returns the id of the splitter to the right of or below the widget \a w,
706 or 0 if there is no such splitter 736 or 0 if there is no such splitter
707 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). 737 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end).
708*/ 738*/
709int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const 739int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const
710{ 740{
711 QSplitterLayoutStruct *s = data->list.first(); 741 QSplitterLayoutStruct *s = data->list.first();
712 bool seen_w = FALSE; 742 bool seen_w = FALSE;
713 while ( s ) { 743 while ( s ) {
714 if ( s->isSplitter && seen_w ) 744 if ( s->isSplitter && seen_w )
715 return data->list.at(); 745 return data->list.at();
716 if ( !s->isSplitter && s->wid == w ) 746 if ( !s->isSplitter && s->wid == w )
717 seen_w = TRUE; 747 seen_w = TRUE;
718 s = data->list.next(); 748 s = data->list.next();
719 } 749 }
720 return 0; 750 return 0;
721} 751}
722 752
723 753
724/*! 754/*!
725 Moves the left/top edge of the splitter handle with id \a id as 755 Moves the left/top edge of the splitter handle with id \a id as
726 close as possible to position \a p, which is the distance from the 756 close as possible to position \a p, which is the distance from the
727 left (or top) edge of the widget. 757 left (or top) edge of the widget.
728 758
729 For Arabic and Hebrew the layout is reversed, and using this 759 For Arabic and Hebrew the layout is reversed, and using this
730 function to set the position of the splitter might lead to 760 function to set the position of the splitter might lead to
731 unexpected results, since in Arabic and Hebrew the position of 761 unexpected results, since in Arabic and Hebrew the position of
732 splitter one is to the left of the position of splitter zero. 762 splitter one is to the left of the position of splitter zero.
733 763
734 \sa idAfter() 764 \sa idAfter()
735*/ 765*/
736void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) 766void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id )
737{ 767{
738 p = adjustPos( p, id ); 768 p = adjustPos( p, id );
739 QSplitterLayoutStruct *s = data->list.at(id); 769 QSplitterLayoutStruct *s = data->list.at(id);
740 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); 770 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y();
741 bool upLeft; 771 bool upLeft;
742 if ( false && orient == Horizontal ) { 772 if ( false && orient == Horizontal ) {
743 p += s->wid->width(); 773 p += s->wid->width();
744 upLeft = p > oldP; 774 upLeft = p > oldP;
745 } else 775 } else
746 upLeft = p < oldP; 776 upLeft = p < oldP;
747 777
748 moveAfter( p, id, upLeft ); 778 moveAfter( p, id, upLeft );
749 moveBefore( p-1, id-1, upLeft ); 779 moveBefore( p-1, id-1, upLeft );
750 780
751 storeSizes(); 781 storeSizes();
752} 782}
753 783
754 784
755void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) 785void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter )
756{ 786{
757 if ( orient == Horizontal ) { 787 if ( orient == Horizontal ) {
758 if ( false && orient == Horizontal && !isSplitter ) 788 if ( false && orient == Horizontal && !isSplitter )
759 p = contentsRect().width() - p - s; 789 p = contentsRect().width() - p - s;
760 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); 790 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() );
761 } else 791 } else
762 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); 792 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s );
763} 793}
764 794
765 795
diff --git a/microkde/KDGanttMinimizeSplitter.h b/microkde/KDGanttMinimizeSplitter.h
index 84d3d8e..585298d 100644
--- a/microkde/KDGanttMinimizeSplitter.h
+++ b/microkde/KDGanttMinimizeSplitter.h
@@ -1,189 +1,191 @@
1/* -*- Mode: C++ -*- 1/* -*- Mode: C++ -*-
2 $Id$ 2 $Id$
3*/ 3*/
4 4
5/**************************************************************************** 5/****************************************************************************
6 ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved. 6 ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 ** 7 **
8 ** This file is part of the KDGantt library. 8 ** This file is part of the KDGantt library.
9 ** 9 **
10 ** This file may be distributed and/or modified under the terms of the 10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software 11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the 12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file. 13 ** packaging of this file.
14 ** 14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in 15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with 16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software. 17 ** the Software.
18 ** 18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 23 ** information about KDGantt Commercial License Agreements.
24 ** 24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 26 ** licensing are not clear to you.
27 ** 27 **
28 ** As a special exception, permission is given to link this program 28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 30 ** without including the source code for Qt in the source distribution.
31 ** 31 **
32 **********************************************************************/ 32 **********************************************************************/
33 33
34#ifndef KDGANTTMINIMIZESPLITTER_H 34#ifndef KDGANTTMINIMIZESPLITTER_H
35#define KDGANTTMINIMIZESPLITTER_H 35#define KDGANTTMINIMIZESPLITTER_H
36 36
37#ifndef QT_H 37#ifndef QT_H
38#include "qframe.h" 38#include "qframe.h"
39#include "qvaluelist.h" 39#include "qvaluelist.h"
40#endif // QT_H 40#endif // QT_H
41 41
42#ifndef QT_NO_SPLITTER___ 42#ifndef QT_NO_SPLITTER___
43class QSplitterData; 43class QSplitterData;
44class QSplitterLayoutStruct; 44class QSplitterLayoutStruct;
45class KDGanttSplitterHandle; 45class KDGanttSplitterHandle;
46class KDGanttMinimizeSplitter : public QFrame 46class KDGanttMinimizeSplitter : public QFrame
47{ 47{
48 Q_OBJECT 48 Q_OBJECT
49 // Q_ENUMS( Direction ) 49 // Q_ENUMS( Direction )
50 // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) 50 // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
51 // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection ) 51 // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection )
52 52
53public: 53public:
54 enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; 54 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
55 enum Direction { Left, Right, Up, Down }; 55 enum Direction { Left, Right, Up, Down };
56 56
57 KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 ); 57 KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 );
58 KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 ); 58 KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 );
59 ~KDGanttMinimizeSplitter(); 59 ~KDGanttMinimizeSplitter();
60 60
61 virtual void setOrientation( Orientation ); 61 virtual void setOrientation( Orientation );
62 Orientation orientation() const { return orient; } 62 Orientation orientation() const { return orient; }
63 63
64 void setMinimizeDirection( Direction ); 64 void setMinimizeDirection( Direction );
65 Direction minimizeDirection() const; 65 Direction minimizeDirection() const;
66 66
67#if QT_VERSION >= 232 67#if QT_VERSION >= 232
68 virtual void setResizeMode( QWidget *w, ResizeMode ); 68 virtual void setResizeMode( QWidget *w, ResizeMode );
69 virtual void setOpaqueResize( bool = TRUE ); 69 virtual void setOpaqueResize( bool = TRUE );
70 bool opaqueResize() const; 70 bool opaqueResize() const;
71 71
72 void moveToFirst( QWidget * ); 72 void moveToFirst( QWidget * );
73 void moveToLast( QWidget * ); 73 void moveToLast( QWidget * );
74 74
75 void refresh() { recalc( TRUE ); } 75 void refresh() { recalc( TRUE ); }
76 QSize sizeHint() const; 76 QSize sizeHint() const;
77 QSize minimumSizeHint() const; 77 QSize minimumSizeHint() const;
78 78
79 QValueList<int> sizes() const; 79 QValueList<int> sizes() const;
80 void setSizes( QValueList<int> ); 80 void setSizes( QValueList<int> );
81 KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;} 81 KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;}
82 void expandPos( int id, int* min, int* max ); 82 void expandPos( int id, int* min, int* max );
83 QFrame* rubberBand() { return mRubberBand ;}
83public slots: 84public slots:
84 void toggle(); 85 void toggle();
85protected: 86protected:
86 void childEvent( QChildEvent * ); 87 void childEvent( QChildEvent * );
87 88
88 bool event( QEvent * ); 89 bool event( QEvent * );
89 void resizeEvent( QResizeEvent * ); 90 void resizeEvent( QResizeEvent * );
90 91
91 int idAfter( QWidget* ) const; 92 int idAfter( QWidget* ) const;
92 93
93 void moveSplitter( QCOORD pos, int id ); 94 void moveSplitter( QCOORD pos, int id );
94 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y, 95 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
95 QCOORD w, QCOORD h ); 96 QCOORD w, QCOORD h );
96 void styleChange( QStyle& ); 97 void styleChange( QStyle& );
97 int adjustPos( int , int ); 98 int adjustPos( int , int );
98 virtual void setRubberband( int ); 99 virtual void setRubberband( int );
99 void getRange( int id, int*, int* ); 100 void getRange( int id, int*, int* );
100 101
101private: 102private:
103 QFrame* mRubberBand;
102 void init(); 104 void init();
103 void recalc( bool update = FALSE ); 105 void recalc( bool update = FALSE );
104 void doResize(); 106 void doResize();
105 void storeSizes(); 107 void storeSizes();
106 void processChildEvents(); 108 void processChildEvents();
107 QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE ); 109 QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE );
108 void recalcId(); 110 void recalcId();
109 void moveBefore( int pos, int id, bool upLeft ); 111 void moveBefore( int pos, int id, bool upLeft );
110 void moveAfter( int pos, int id, bool upLeft ); 112 void moveAfter( int pos, int id, bool upLeft );
111 void setG( QWidget *w, int p, int s, bool isSplitter = FALSE ); 113 void setG( QWidget *w, int p, int s, bool isSplitter = FALSE );
112 114
113 QCOORD pick( const QPoint &p ) const 115 QCOORD pick( const QPoint &p ) const
114 { return orient == Horizontal ? p.x() : p.y(); } 116 { return orient == Horizontal ? p.x() : p.y(); }
115 QCOORD pick( const QSize &s ) const 117 QCOORD pick( const QSize &s ) const
116 { return orient == Horizontal ? s.width() : s.height(); } 118 { return orient == Horizontal ? s.width() : s.height(); }
117 119
118 QCOORD trans( const QPoint &p ) const 120 QCOORD trans( const QPoint &p ) const
119 { return orient == Vertical ? p.x() : p.y(); } 121 { return orient == Vertical ? p.x() : p.y(); }
120 QCOORD trans( const QSize &s ) const 122 QCOORD trans( const QSize &s ) const
121 { return orient == Vertical ? s.width() : s.height(); } 123 { return orient == Vertical ? s.width() : s.height(); }
122 KDGanttSplitterHandle* mFirstHandle; 124 KDGanttSplitterHandle* mFirstHandle;
123 QSplitterData *data; 125 QSplitterData *data;
124#endif 126#endif
125 127
126private: 128private:
127 Orientation orient; 129 Orientation orient;
128 Direction _direction; 130 Direction _direction;
129#ifndef DOXYGEN_SKIP_INTERNAL 131#ifndef DOXYGEN_SKIP_INTERNAL
130 friend class KDGanttSplitterHandle; 132 friend class KDGanttSplitterHandle;
131#endif 133#endif
132 private:// Disabled copy constructor and operator= 134 private:// Disabled copy constructor and operator=
133#if defined(Q_DISABLE_COPY) 135#if defined(Q_DISABLE_COPY)
134 KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & ); 136 KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & );
135 KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & ); 137 KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & );
136#endif 138#endif
137}; 139};
138 140
139#ifndef DOXYGEN_SKIP_INTERNAL 141#ifndef DOXYGEN_SKIP_INTERNAL
140// This class was continued from a verbatim copy of the 142// This class was continued from a verbatim copy of the
141// QSplitterHandle pertaining to the Qt Enterprise License and the 143// QSplitterHandle pertaining to the Qt Enterprise License and the
142// GPL. It has only been renamed to KDGanttSplitterHandler in order to 144// GPL. It has only been renamed to KDGanttSplitterHandler in order to
143// avoid a symbol clash on some platforms. 145// avoid a symbol clash on some platforms.
144class KDGanttSplitterHandle : public QWidget 146class KDGanttSplitterHandle : public QWidget
145{ 147{
146 Q_OBJECT 148 Q_OBJECT
147#if QT_VERSION >= 232 149#if QT_VERSION >= 232
148public: 150public:
149 KDGanttSplitterHandle( Qt::Orientation o, 151 KDGanttSplitterHandle( Qt::Orientation o,
150 KDGanttMinimizeSplitter *parent, const char* name=0 ); 152 KDGanttMinimizeSplitter *parent, const char* name=0 );
151 void setOrientation( Qt::Orientation o ); 153 void setOrientation( Qt::Orientation o );
152 Qt::Orientation orientation() const { return orient; } 154 Qt::Orientation orientation() const { return orient; }
153 155
154 bool opaque() const { return s->opaqueResize(); } 156 bool opaque() const { return s->opaqueResize(); }
155 157
156 QSize sizeHint() const; 158 QSize sizeHint() const;
157 void toggle(); 159 void toggle();
158 160
159 int id() const { return myId; } // data->list.at(id())->wid == this 161 int id() const { return myId; } // data->list.at(id())->wid == this
160 void setId( int i ) { myId = i; } 162 void setId( int i ) { myId = i; }
161 163
162protected: 164protected:
163 QValueList<QPointArray> buttonRegions(); 165 QValueList<QPointArray> buttonRegions();
164 void paintEvent( QPaintEvent * ); 166 void paintEvent( QPaintEvent * );
165 void mouseMoveEvent( QMouseEvent * ); 167 void mouseMoveEvent( QMouseEvent * );
166 void mousePressEvent( QMouseEvent * ); 168 void mousePressEvent( QMouseEvent * );
167 void mouseReleaseEvent( QMouseEvent * ); 169 void mouseReleaseEvent( QMouseEvent * );
168 int onButton( const QPoint& p ); 170 int onButton( const QPoint& p );
169 void updateCursor( const QPoint& p ); 171 void updateCursor( const QPoint& p );
170 172
171private: 173private:
172 bool mMouseDown; 174 bool mMouseDown;
173 QSize mSizeHint; 175 QSize mSizeHint;
174 bool mUseOffset; 176 bool mUseOffset;
175 Qt::Orientation orient; 177 Qt::Orientation orient;
176 bool opaq; 178 bool opaq;
177 int myId; 179 int myId;
178 180
179 KDGanttMinimizeSplitter *s; 181 KDGanttMinimizeSplitter *s;
180 int _activeButton; 182 int _activeButton;
181 bool _collapsed; 183 bool _collapsed;
182 int _origPos; 184 int _origPos;
183#endif 185#endif
184}; 186};
185#endif 187#endif
186 188
187#endif // QT_NO_SPLITTER 189#endif // QT_NO_SPLITTER
188 190
189#endif // KDGANTTMINIMIZESPLITTER_H 191#endif // KDGANTTMINIMIZESPLITTER_H