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