-rw-r--r-- | korganizer/kolistview.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index b378330..192f8c0 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1025,414 +1025,434 @@ void KOListView::showCompletedTodos() | |||
1025 | mForceShowCompletedTodos = true; | 1025 | mForceShowCompletedTodos = true; |
1026 | } | 1026 | } |
1027 | void KOListView::addIncidence(Incidence *incidence) | 1027 | void KOListView::addIncidence(Incidence *incidence) |
1028 | { | 1028 | { |
1029 | if ( mUidDict.find( incidence->uid() ) ) return; | 1029 | if ( mUidDict.find( incidence->uid() ) ) return; |
1030 | 1030 | ||
1031 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 1031 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
1032 | if ( incidence->typeID() == todoID ) { | 1032 | if ( incidence->typeID() == todoID ) { |
1033 | if ( ! mForceShowCompletedTodos ) { | 1033 | if ( ! mForceShowCompletedTodos ) { |
1034 | if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) | 1034 | if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) |
1035 | return; | 1035 | return; |
1036 | } | 1036 | } |
1037 | } | 1037 | } |
1038 | mUidDict.insert( incidence->uid(), incidence ); | 1038 | mUidDict.insert( incidence->uid(), incidence ); |
1039 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 1039 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
1040 | ListItemVisitor v(item, mStartDate ); | 1040 | ListItemVisitor v(item, mStartDate ); |
1041 | if (incidence->accept(v)) { | 1041 | if (incidence->accept(v)) { |
1042 | return; | 1042 | return; |
1043 | } | 1043 | } |
1044 | else delete item; | 1044 | else delete item; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | void KOListView::showEvents(QPtrList<Event> eventList) | 1047 | void KOListView::showEvents(QPtrList<Event> eventList) |
1048 | { | 1048 | { |
1049 | clear(); | 1049 | clear(); |
1050 | 1050 | ||
1051 | addEvents(eventList); | 1051 | addEvents(eventList); |
1052 | 1052 | ||
1053 | // After new creation of list view no events are selected. | 1053 | // After new creation of list view no events are selected. |
1054 | emit incidenceSelected( 0 ); | 1054 | emit incidenceSelected( 0 ); |
1055 | } | 1055 | } |
1056 | int KOListView::count() | 1056 | int KOListView::count() |
1057 | { | 1057 | { |
1058 | return mListView->childCount(); | 1058 | return mListView->childCount(); |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | void KOListView::changeEventDisplay(Event *event, int action) | 1061 | void KOListView::changeEventDisplay(Event *event, int action) |
1062 | { | 1062 | { |
1063 | KOListViewItem *item; | 1063 | KOListViewItem *item; |
1064 | 1064 | ||
1065 | switch(action) { | 1065 | switch(action) { |
1066 | case KOGlobals::EVENTADDED: | 1066 | case KOGlobals::EVENTADDED: |
1067 | addIncidence( event ); | 1067 | addIncidence( event ); |
1068 | break; | 1068 | break; |
1069 | case KOGlobals::EVENTEDITED: | 1069 | case KOGlobals::EVENTEDITED: |
1070 | item = getItemForEvent(event); | 1070 | item = getItemForEvent(event); |
1071 | if (item) { | 1071 | if (item) { |
1072 | ListItemVisitor v(item, mStartDate ); | 1072 | ListItemVisitor v(item, mStartDate ); |
1073 | ((Incidence*)event)->accept(v); | 1073 | ((Incidence*)event)->accept(v); |
1074 | } | 1074 | } |
1075 | break; | 1075 | break; |
1076 | case KOGlobals::EVENTDELETED: | 1076 | case KOGlobals::EVENTDELETED: |
1077 | item = getItemForEvent(event); | 1077 | item = getItemForEvent(event); |
1078 | if (item) { | 1078 | if (item) { |
1079 | mUidDict.remove( event->uid() ); | 1079 | mUidDict.remove( event->uid() ); |
1080 | delete item; | 1080 | delete item; |
1081 | } | 1081 | } |
1082 | break; | 1082 | break; |
1083 | default: | 1083 | default: |
1084 | ; | 1084 | ; |
1085 | } | 1085 | } |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | KOListViewItem *KOListView::getItemForEvent(Incidence *event) | 1088 | KOListViewItem *KOListView::getItemForEvent(Incidence *event) |
1089 | { | 1089 | { |
1090 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 1090 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
1091 | while (item) { | 1091 | while (item) { |
1092 | if (item->data() == event) return item; | 1092 | if (item->data() == event) return item; |
1093 | item = (KOListViewItem *)item->nextSibling(); | 1093 | item = (KOListViewItem *)item->nextSibling(); |
1094 | } | 1094 | } |
1095 | return 0; | 1095 | return 0; |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | void KOListView::defaultItemAction(QListViewItem *i) | 1098 | void KOListView::defaultItemAction(QListViewItem *i) |
1099 | { | 1099 | { |
1100 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 1100 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
1101 | if ( item ) defaultAction( item->data() ); | 1101 | if ( item ) defaultAction( item->data() ); |
1102 | 1102 | ||
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 1105 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
1106 | { | 1106 | { |
1107 | mActiveItem = (KOListViewItem *)item; | 1107 | mActiveItem = (KOListViewItem *)item; |
1108 | if (mActiveItem) { | 1108 | if (mActiveItem) { |
1109 | Incidence *incidence = mActiveItem->data(); | 1109 | Incidence *incidence = mActiveItem->data(); |
1110 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); | 1110 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); |
1111 | mPopupMenu->showIncidencePopup(incidence); | 1111 | mPopupMenu->showIncidencePopup(incidence); |
1112 | 1112 | ||
1113 | /* | 1113 | /* |
1114 | if ( incidence && incidence->type() == "Event" ) { | 1114 | if ( incidence && incidence->type() == "Event" ) { |
1115 | Event *event = static_cast<Event *>( incidence ); | 1115 | Event *event = static_cast<Event *>( incidence ); |
1116 | mPopupMenu->showEventPopup(event); | 1116 | mPopupMenu->showEventPopup(event); |
1117 | } | 1117 | } |
1118 | */ | 1118 | */ |
1119 | } | 1119 | } |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | void KOListView::readSettings(KConfig *config, QString setting) | 1122 | void KOListView::readSettings(KConfig *config, QString setting) |
1123 | { | 1123 | { |
1124 | // qDebug("KOListView::readSettings "); | 1124 | // qDebug("KOListView::readSettings "); |
1125 | mListView->restoreLayout(config,setting); | 1125 | mListView->restoreLayout(config,setting); |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | void KOListView::writeSettings(KConfig *config, QString setting) | 1128 | void KOListView::writeSettings(KConfig *config, QString setting) |
1129 | { | 1129 | { |
1130 | // qDebug("KOListView::writeSettings "); | 1130 | // qDebug("KOListView::writeSettings "); |
1131 | mListView->saveLayout(config, setting); | 1131 | mListView->saveLayout(config, setting); |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | void KOListView::processSelectionChange(QListViewItem *) | 1134 | void KOListView::processSelectionChange(QListViewItem *) |
1135 | { | 1135 | { |
1136 | 1136 | ||
1137 | KOListViewItem *item = | 1137 | KOListViewItem *item = |
1138 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 1138 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
1139 | 1139 | ||
1140 | if ( !item ) { | 1140 | if ( !item ) { |
1141 | emit incidenceSelected( 0 ); | 1141 | emit incidenceSelected( 0 ); |
1142 | } else { | 1142 | } else { |
1143 | emit incidenceSelected( item->data() ); | 1143 | emit incidenceSelected( item->data() ); |
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | void KOListView::clearSelection() | 1147 | void KOListView::clearSelection() |
1148 | { | 1148 | { |
1149 | mListView->selectAll( false ); | 1149 | mListView->selectAll( false ); |
1150 | } | 1150 | } |
1151 | void KOListView::allSelection() | 1151 | void KOListView::allSelection() |
1152 | { | 1152 | { |
1153 | mListView->selectAll( true ); | 1153 | mListView->selectAll( true ); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | void KOListView::clear() | 1156 | void KOListView::clear() |
1157 | { | 1157 | { |
1158 | mListView->clear(); | 1158 | mListView->clear(); |
1159 | mUidDict.clear(); | 1159 | mUidDict.clear(); |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | Incidence* KOListView::currentItem() | 1162 | Incidence* KOListView::currentItem() |
1163 | { | 1163 | { |
1164 | if ( mListView->currentItem() ) | 1164 | if ( mListView->currentItem() ) |
1165 | return ((KOListViewItem*) mListView->currentItem())->data(); | 1165 | return ((KOListViewItem*) mListView->currentItem())->data(); |
1166 | return 0; | 1166 | return 0; |
1167 | } | 1167 | } |
1168 | void KOListView::keyPressEvent ( QKeyEvent *e) | 1168 | void KOListView::keyPressEvent ( QKeyEvent *e) |
1169 | { | 1169 | { |
1170 | 1170 | ||
1171 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { | 1171 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { |
1172 | deleteAll(); | 1172 | deleteAll(); |
1173 | return; | 1173 | return; |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | e->ignore(); | 1176 | e->ignore(); |
1177 | } | 1177 | } |
1178 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 1178 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) |
1179 | { | 1179 | { |
1180 | 1180 | ||
1181 | switch ( e->key() ) { | 1181 | switch ( e->key() ) { |
1182 | case Qt::Key_Down: | 1182 | case Qt::Key_Down: |
1183 | if ( e->state() == ShiftButton ) { | 1183 | if ( e->state() == ShiftButton ) { |
1184 | QListViewItem* cn = currentItem(); | 1184 | QListViewItem* cn = currentItem(); |
1185 | if ( !cn ) | 1185 | if ( !cn ) |
1186 | cn = firstChild(); | 1186 | cn = firstChild(); |
1187 | if ( !cn ) | 1187 | if ( !cn ) |
1188 | return; | 1188 | return; |
1189 | while ( cn->nextSibling() ) | 1189 | while ( cn->nextSibling() ) |
1190 | cn = cn->nextSibling(); | 1190 | cn = cn->nextSibling(); |
1191 | setCurrentItem ( cn ); | 1191 | setCurrentItem ( cn ); |
1192 | ensureItemVisible ( cn ); | 1192 | ensureItemVisible ( cn ); |
1193 | 1193 | ||
1194 | e->accept(); | 1194 | e->accept(); |
1195 | return; | 1195 | return; |
1196 | } | 1196 | } |
1197 | if ( e->state() == ControlButton ) { | 1197 | if ( e->state() == ControlButton ) { |
1198 | int count = childCount (); | 1198 | int count = childCount (); |
1199 | int jump = count / 5; | 1199 | int jump = count / 5; |
1200 | QListViewItem* cn; | 1200 | QListViewItem* cn; |
1201 | cn = currentItem(); | 1201 | cn = currentItem(); |
1202 | if ( ! cn ) | 1202 | if ( ! cn ) |
1203 | return; | 1203 | return; |
1204 | if ( jump == 0 ) | 1204 | if ( jump == 0 ) |
1205 | jump = 1; | 1205 | jump = 1; |
1206 | while ( jump && cn->nextSibling() ) { | 1206 | while ( jump && cn->nextSibling() ) { |
1207 | cn = cn->nextSibling(); | 1207 | cn = cn->nextSibling(); |
1208 | --jump; | 1208 | --jump; |
1209 | } | 1209 | } |
1210 | setCurrentItem ( cn ); | 1210 | setCurrentItem ( cn ); |
1211 | ensureItemVisible ( cn ); | 1211 | ensureItemVisible ( cn ); |
1212 | 1212 | ||
1213 | } else | 1213 | } else |
1214 | QListView::keyPressEvent ( e ) ; | 1214 | QListView::keyPressEvent ( e ) ; |
1215 | e->accept(); | 1215 | e->accept(); |
1216 | break; | 1216 | break; |
1217 | 1217 | ||
1218 | case Qt::Key_Up: | 1218 | case Qt::Key_Up: |
1219 | if ( e->state() == ShiftButton ) { | 1219 | if ( e->state() == ShiftButton ) { |
1220 | QListViewItem* cn = firstChild(); | 1220 | QListViewItem* cn = firstChild(); |
1221 | if ( cn ) { | 1221 | if ( cn ) { |
1222 | setCurrentItem ( cn ); | 1222 | setCurrentItem ( cn ); |
1223 | ensureItemVisible ( cn ); | 1223 | ensureItemVisible ( cn ); |
1224 | } | 1224 | } |
1225 | e->accept(); | 1225 | e->accept(); |
1226 | return; | 1226 | return; |
1227 | } | 1227 | } |
1228 | if ( e->state() == ControlButton ) { | 1228 | if ( e->state() == ControlButton ) { |
1229 | int count = childCount (); | 1229 | int count = childCount (); |
1230 | int jump = count / 5; | 1230 | int jump = count / 5; |
1231 | QListViewItem* cn; | 1231 | QListViewItem* cn; |
1232 | cn = currentItem(); | 1232 | cn = currentItem(); |
1233 | if ( ! cn ) | 1233 | if ( ! cn ) |
1234 | return; | 1234 | return; |
1235 | if ( jump == 0 ) | 1235 | if ( jump == 0 ) |
1236 | jump = 1; | 1236 | jump = 1; |
1237 | while ( jump && cn->itemAbove ()) { | 1237 | while ( jump && cn->itemAbove ()) { |
1238 | cn = cn->itemAbove (); | 1238 | cn = cn->itemAbove (); |
1239 | --jump; | 1239 | --jump; |
1240 | } | 1240 | } |
1241 | setCurrentItem ( cn ); | 1241 | setCurrentItem ( cn ); |
1242 | ensureItemVisible ( cn ); | 1242 | ensureItemVisible ( cn ); |
1243 | } else | 1243 | } else |
1244 | QListView::keyPressEvent ( e ) ; | 1244 | QListView::keyPressEvent ( e ) ; |
1245 | e->accept(); | 1245 | e->accept(); |
1246 | break; | 1246 | break; |
1247 | case Qt::Key_I: { | 1247 | case Qt::Key_I: { |
1248 | QListViewItem* cn; | 1248 | QListViewItem* cn; |
1249 | cn = currentItem(); | 1249 | cn = currentItem(); |
1250 | if ( cn ) { | 1250 | if ( cn ) { |
1251 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1251 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1252 | if ( ci ){ | 1252 | if ( ci ){ |
1253 | //emit showIncidence( ci->data()); | 1253 | //emit showIncidence( ci->data()); |
1254 | cn = cn->nextSibling(); | 1254 | cn = cn->nextSibling(); |
1255 | if ( cn ) { | 1255 | if ( cn ) { |
1256 | setCurrentItem ( cn ); | 1256 | setCurrentItem ( cn ); |
1257 | ensureItemVisible ( cn ); | 1257 | ensureItemVisible ( cn ); |
1258 | } | 1258 | } |
1259 | emit showIncidence( ci->data()); | 1259 | emit showIncidence( ci->data()); |
1260 | } | 1260 | } |
1261 | } | 1261 | } |
1262 | e->accept(); | 1262 | e->accept(); |
1263 | } | 1263 | } |
1264 | break; | 1264 | break; |
1265 | case Qt::Key_Return: | 1265 | case Qt::Key_Return: |
1266 | case Qt::Key_Enter: | 1266 | case Qt::Key_Enter: |
1267 | { | 1267 | { |
1268 | QListViewItem* cn; | 1268 | QListViewItem* cn; |
1269 | cn = currentItem(); | 1269 | cn = currentItem(); |
1270 | if ( cn ) { | 1270 | if ( cn ) { |
1271 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1271 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1272 | if ( ci ){ | 1272 | if ( ci ){ |
1273 | if ( e->state() == ShiftButton ) | 1273 | if ( e->state() == ShiftButton ) |
1274 | ci->setSelected( false ); | 1274 | ci->setSelected( false ); |
1275 | else | 1275 | else |
1276 | ci->setSelected( true ); | 1276 | ci->setSelected( true ); |
1277 | cn = cn->nextSibling(); | 1277 | cn = cn->nextSibling(); |
1278 | if ( cn ) { | 1278 | if ( cn ) { |
1279 | setCurrentItem ( cn ); | 1279 | setCurrentItem ( cn ); |
1280 | ensureItemVisible ( cn ); | 1280 | ensureItemVisible ( cn ); |
1281 | } else { | 1281 | } else { |
1282 | emit currentChanged( ci ); | 1282 | emit currentChanged( ci ); |
1283 | } | 1283 | } |
1284 | } | 1284 | } |
1285 | } | 1285 | } |
1286 | e->accept(); | 1286 | e->accept(); |
1287 | } | 1287 | } |
1288 | break; | 1288 | break; |
1289 | default: | 1289 | default: |
1290 | e->ignore(); | 1290 | e->ignore(); |
1291 | } | 1291 | } |
1292 | } | 1292 | } |
1293 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1293 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1294 | : KListView( lv, "kolistlistview", false ) | 1294 | : KListView( lv, "kolistlistview", false ) |
1295 | { | 1295 | { |
1296 | mYMousePos = 0; | 1296 | mYMousePos = 0; |
1297 | setAllColumnsShowFocus( true ); | 1297 | setAllColumnsShowFocus( true ); |
1298 | mPopupTimer = new QTimer(this); | 1298 | mPopupTimer = new QTimer(this); |
1299 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 1299 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
1300 | #ifndef DESKTOP_VERSION | 1300 | #ifndef DESKTOP_VERSION |
1301 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1301 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1302 | #endif | 1302 | #endif |
1303 | setSelectionMode( QListView::Multi ); | 1303 | setSelectionMode( QListView::Multi ); |
1304 | setMultiSelection( true); | 1304 | setMultiSelection( true); |
1305 | } | 1305 | } |
1306 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) | 1306 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) |
1307 | { | 1307 | { |
1308 | QListViewItem *qitem = firstChild (); | 1308 | QListViewItem *qitem = firstChild (); |
1309 | while ( qitem ) { | 1309 | while ( qitem ) { |
1310 | if ( qitem->isSelected() && item != qitem ) | 1310 | if ( qitem->isSelected() && item != qitem ) |
1311 | return true; | 1311 | return true; |
1312 | qitem = qitem->nextSibling(); | 1312 | qitem = qitem->nextSibling(); |
1313 | } | 1313 | } |
1314 | return false; | 1314 | return false; |
1315 | } | 1315 | } |
1316 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1316 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1317 | { | 1317 | { |
1318 | if (!e) return; | 1318 | if (!e) return; |
1319 | QPoint vp = contentsToViewport(e->pos()); | 1319 | QPoint vp = contentsToViewport(e->pos()); |
1320 | QListViewItem *item = itemAt(vp); | 1320 | QListViewItem *item = itemAt(vp); |
1321 | if (!item) { | 1321 | if (!item) { |
1322 | emit newEvent(); | 1322 | emit newEvent(); |
1323 | return; | 1323 | return; |
1324 | } | 1324 | } |
1325 | KListView::contentsMouseDoubleClickEvent(e); | 1325 | KListView::contentsMouseDoubleClickEvent(e); |
1326 | } | 1326 | } |
1327 | #if 0 | 1327 | #if 0 |
1328 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1328 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1329 | { | 1329 | { |
1330 | //qDebug("contentsMousePressEvent++++ "); | 1330 | //qDebug("contentsMousePressEvent++++ "); |
1331 | KListView::contentsMousePressEvent( e ); | 1331 | KListView::contentsMousePressEvent( e ); |
1332 | if ( e->button() == RightButton ) { | 1332 | if ( e->button() == RightButton ) { |
1333 | QListViewItem* ci = currentItem(); | 1333 | QListViewItem* ci = currentItem(); |
1334 | clearSelection () ; | 1334 | clearSelection () ; |
1335 | if ( ci ) | 1335 | if ( ci ) |
1336 | ci->setSelected( true ); | 1336 | ci->setSelected( true ); |
1337 | } | 1337 | } |
1338 | } | 1338 | } |
1339 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1339 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1340 | { | 1340 | { |
1341 | KListView::contentsMouseReleaseEvent(e); | 1341 | KListView::contentsMouseReleaseEvent(e); |
1342 | } | 1342 | } |
1343 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1343 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1344 | { | 1344 | { |
1345 | KListView::contentsMouseMoveEvent(e); | 1345 | KListView::contentsMouseMoveEvent(e); |
1346 | } | 1346 | } |
1347 | #endif | 1347 | #endif |
1348 | void KOListViewListView::popupMenu() | 1348 | void KOListViewListView::popupMenu() |
1349 | { | 1349 | { |
1350 | mPopupTimer->stop(); | 1350 | mPopupTimer->stop(); |
1351 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); | 1351 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); |
1352 | QApplication::postEvent( this->viewport(), e ); | 1352 | QApplication::postEvent( this->viewport(), e ); |
1353 | 1353 | ||
1354 | } | 1354 | } |
1355 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1355 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1356 | { | 1356 | { |
1357 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); | 1357 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); |
1358 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1358 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1359 | if ( e->button() == LeftButton ) { | 1359 | if ( e->button() == LeftButton ) { |
1360 | mPopupTimer->start( 600 ); | 1360 | mPopupTimer->start( 600 ); |
1361 | mEventPos = contentsToViewport(e->pos()); | 1361 | mEventPos = contentsToViewport(e->pos()); |
1362 | mEventGlobalPos = e->globalPos(); | 1362 | mEventGlobalPos = e->globalPos(); |
1363 | } | 1363 | } |
1364 | KListView::contentsMousePressEvent( e ); | 1364 | KListView::contentsMousePressEvent( e ); |
1365 | if ( e->button() == RightButton ) { | 1365 | if ( e->button() == RightButton ) { |
1366 | QListViewItem* ci = currentItem(); | 1366 | QListViewItem* ci = currentItem(); |
1367 | //clearSelection(); | 1367 | //clearSelection(); |
1368 | if ( ci ) | 1368 | if ( ci ) |
1369 | ci->setSelected( true ); | 1369 | ci->setSelected( true ); |
1370 | } | 1370 | } |
1371 | } | 1371 | } |
1372 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1372 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1373 | { | 1373 | { |
1374 | mPopupTimer->stop(); | 1374 | mPopupTimer->stop(); |
1375 | KListView::contentsMouseReleaseEvent(e); | 1375 | KListView::contentsMouseReleaseEvent(e); |
1376 | } | 1376 | } |
1377 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1377 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1378 | { | 1378 | { |
1379 | // qDebug("contentsMouseMoveEv....... "); | 1379 | // qDebug("contentsMouseMoveEv....... "); |
1380 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1380 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
1381 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); | 1381 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); |
1382 | if ( diff < 0 ) diff = -diff; | 1382 | if ( diff < 0 ) diff = -diff; |
1383 | if ( diff > 15 ) | 1383 | if ( diff > 15 ) |
1384 | mPopupTimer->stop(); | 1384 | mPopupTimer->stop(); |
1385 | else { | 1385 | else { |
1386 | mEventPos = contentsToViewport(e->pos()); | 1386 | mEventPos = contentsToViewport(e->pos()); |
1387 | mEventGlobalPos = e->globalPos(); | 1387 | mEventGlobalPos = e->globalPos(); |
1388 | } | 1388 | } |
1389 | KListView::contentsMouseMoveEvent(e); | 1389 | KListView::contentsMouseMoveEvent(e); |
1390 | } | 1390 | } |
1391 | 1391 | ||
1392 | #define protected public | 1392 | #define protected public |
1393 | #include <qheader.h> | 1393 | #include <qheader.h> |
1394 | #undef protected | 1394 | #undef protected |
1395 | void KOListViewListView::printList() | 1395 | void KOListViewListView::printList() |
1396 | { | 1396 | { |
1397 | #ifdef DESKTOP_VERSION | 1397 | #ifdef DESKTOP_VERSION |
1398 | KOPrintPrefs pp ( this ); | 1398 | KOPrintPrefs pp ( this ); |
1399 | if (!pp.exec() ) | 1399 | if (!pp.exec() ) |
1400 | return; | 1400 | return; |
1401 | int scaleval = pp.printMode() ; | 1401 | int scaleval = pp.printMode() ; |
1402 | 1402 | ||
1403 | QPrinter printer; | 1403 | QPrinter printer; |
1404 | if (!printer.setup() ) | 1404 | if (!printer.setup() ) |
1405 | return; | 1405 | return; |
1406 | clearSelection (); | 1406 | clearSelection (); |
1407 | QPainter p; | 1407 | QPainter p; |
1408 | p.begin ( &printer ); | 1408 | p.begin ( &printer ); |
1409 | p.setFont(font()); | ||
1409 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 1410 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
1410 | float dx, dy; | 1411 | float dx, dy; |
1411 | int wid = (m.width() * 9)/10; | 1412 | int wid = (m.width() * 9)/10; |
1412 | dx = (float) wid/(float)contentsWidth (); | 1413 | dx = (float) wid/(float)contentsWidth (); |
1413 | dy = (float)(m.height()) / (float)contentsHeight (); | 1414 | dy = (float)(m.height()) / (float)contentsHeight (); |
1414 | float scale; | 1415 | float scale; |
1415 | // scale to fit the width or height of the paper | 1416 | // scale to fit the width or height of the paper |
1416 | if ( dx < dy ) | 1417 | if ( dx < dy ) |
1417 | scale = dx; | 1418 | scale = dx; |
1418 | else | 1419 | else |
1419 | scale = dy; | 1420 | scale = dy; |
1420 | 1421 | ||
1421 | p.translate( m.width()/10,m.width()/10 ); | 1422 | p.translate( m.width()/10,m.width()/10 ); |
1422 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 1423 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
1423 | p.scale( scale, scale ); | 1424 | p.scale( scale, scale ); |
1424 | } | 1425 | } |
1425 | 1426 | ||
1426 | int cou = header()->count(); | 1427 | int cou = header()->count(); |
1427 | int iii; | 1428 | int iii; |
1428 | QRect rect ( 0,0,0, header()->height()); | 1429 | QRect rect ( 0,0,0, header()->height()); |
1429 | for ( iii = 0; iii < cou; ++iii ) { | 1430 | for ( iii = 0; iii < cou; ++iii ) { |
1430 | rect.setLeft ( header()->sectionPos( iii ) ); | 1431 | rect.setLeft ( header()->sectionPos( iii ) ); |
1431 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); | 1432 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); |
1432 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); | 1433 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); |
1433 | } | 1434 | } |
1434 | p.translate( 0, header()->height()); | 1435 | p.translate( 0, header()->height()); |
1435 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); | 1436 | //drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); |
1437 | |||
1438 | const QColorGroup &cg = colorGroup(); | ||
1439 | KOListViewItem* item = (KOListViewItem* )firstChild(); | ||
1440 | int yOff = 0; | ||
1441 | while ( item ) { | ||
1442 | p.translate( 0, yOff ); | ||
1443 | p.save(); | ||
1444 | for ( iii = 0; iii < cou; ++iii ) { | ||
1445 | int align = columnAlignment( iii ); | ||
1446 | if ( align == AlignAuto ) align = AlignLeft; | ||
1447 | p.restore(); | ||
1448 | p.save(); | ||
1449 | p.translate( header()->sectionPos( iii ), 0); | ||
1450 | item->paintCell( &p, cg, iii, header()->sectionSize (iii), align ); | ||
1451 | } | ||
1452 | yOff = item->height(); | ||
1453 | item = (KOListViewItem* )(item->itemBelow()); | ||
1454 | p.restore(); | ||
1455 | } | ||
1436 | p.end(); | 1456 | p.end(); |
1437 | #endif | 1457 | #endif |
1438 | } | 1458 | } |