-rw-r--r-- | noncore/apps/opie-console/TEWidget.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp index 1c83710..3d010cb 100644 --- a/noncore/apps/opie-console/TEWidget.cpp +++ b/noncore/apps/opie-console/TEWidget.cpp | |||
@@ -1091,188 +1091,192 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1091 | return true; // stop the event | 1091 | return true; // stop the event |
1092 | } | 1092 | } |
1093 | if ( e->type() == QEvent::Enter ) { | 1093 | if ( e->type() == QEvent::Enter ) { |
1094 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1094 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1095 | this, SLOT(onClearSelection()) ); | 1095 | this, SLOT(onClearSelection()) ); |
1096 | } | 1096 | } |
1097 | if ( e->type() == QEvent::Leave ) { | 1097 | if ( e->type() == QEvent::Leave ) { |
1098 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1098 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1099 | this, SLOT(onClearSelection()) ); | 1099 | this, SLOT(onClearSelection()) ); |
1100 | } | 1100 | } |
1101 | return QFrame::eventFilter( obj, e ); | 1101 | return QFrame::eventFilter( obj, e ); |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | /* ------------------------------------------------------------------------- */ | 1104 | /* ------------------------------------------------------------------------- */ |
1105 | /* */ | 1105 | /* */ |
1106 | /* Frame */ | 1106 | /* Frame */ |
1107 | /* */ | 1107 | /* */ |
1108 | /* ------------------------------------------------------------------------- */ | 1108 | /* ------------------------------------------------------------------------- */ |
1109 | 1109 | ||
1110 | void TEWidget::frameChanged() | 1110 | void TEWidget::frameChanged() |
1111 | { | 1111 | { |
1112 | propagateSize(); | 1112 | propagateSize(); |
1113 | update(); | 1113 | update(); |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | /* ------------------------------------------------------------------------- */ | 1116 | /* ------------------------------------------------------------------------- */ |
1117 | /* */ | 1117 | /* */ |
1118 | /* Sound */ | 1118 | /* Sound */ |
1119 | /* */ | 1119 | /* */ |
1120 | /* ------------------------------------------------------------------------- */ | 1120 | /* ------------------------------------------------------------------------- */ |
1121 | 1121 | ||
1122 | void TEWidget::Bell() | 1122 | void TEWidget::Bell() |
1123 | { | 1123 | { |
1124 | QApplication::beep(); | 1124 | QApplication::beep(); |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | /* ------------------------------------------------------------------------- */ | 1127 | /* ------------------------------------------------------------------------- */ |
1128 | /* */ | 1128 | /* */ |
1129 | /* Auxiluary */ | 1129 | /* Auxiluary */ |
1130 | /* */ | 1130 | /* */ |
1131 | /* ------------------------------------------------------------------------- */ | 1131 | /* ------------------------------------------------------------------------- */ |
1132 | 1132 | ||
1133 | void TEWidget::clearImage() | 1133 | void TEWidget::clearImage() |
1134 | // initialize the image | 1134 | // initialize the image |
1135 | // for internal use only | 1135 | // for internal use only |
1136 | { | 1136 | { |
1137 | for (int y = 0; y < lines; y++) | 1137 | for (int y = 0; y < lines; y++) |
1138 | for (int x = 0; x < columns; x++) | 1138 | for (int x = 0; x < columns; x++) |
1139 | { | 1139 | { |
1140 | image[loc(x,y)].c = 0xff; //' '; | 1140 | image[loc(x,y)].c = 0xff; //' '; |
1141 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1141 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1142 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1142 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1143 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1143 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | // Create Image /////////////////////////////////////////////////////// | 1147 | // Create Image /////////////////////////////////////////////////////// |
1148 | 1148 | ||
1149 | void TEWidget::calcGeometry() | 1149 | void TEWidget::calcGeometry() |
1150 | { | 1150 | { |
1151 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | 1151 | //FIXME: set rimX == rimY == 0 when running in full screen mode. |
1152 | 1152 | ||
1153 | int showhscrollbar = 1; | 1153 | int showhscrollbar = 1; |
1154 | int hwidth = 0; | 1154 | int hwidth = 0; |
1155 | int dcolumns; | ||
1155 | 1156 | ||
1156 | if(vcolumns == 0) showhscrollbar = 0; | 1157 | if(vcolumns == 0) showhscrollbar = 0; |
1157 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | 1158 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); |
1158 | 1159 | ||
1159 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1160 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1160 | contentsRect().height() - hwidth); | 1161 | contentsRect().height() - hwidth); |
1161 | 1162 | ||
1162 | if(!showhscrollbar) cornerButton()->move(0, 0); | 1163 | if(!showhscrollbar) cornerButton()->move(0, 0); |
1163 | else cornerButton()->move(contentsRect().width() - hwidth, contentsRect().height() - hwidth); | 1164 | else cornerButton()->move(contentsRect().width() - hwidth, contentsRect().height() - hwidth); |
1164 | 1165 | ||
1165 | 1166 | ||
1166 | if(showhscrollbar == 1) | ||
1167 | { | ||
1168 | hscrollbar->resize(contentsRect().width() - hwidth, hwidth); | ||
1169 | hscrollbar->setRange(0, 40); | ||
1170 | |||
1171 | QPoint p = contentsRect().bottomLeft(); | ||
1172 | hscrollbar->move(QPoint(p.x(), p.y() - hwidth)); | ||
1173 | hscrollbar->show(); | ||
1174 | } | ||
1175 | else hscrollbar->hide(); | ||
1176 | |||
1177 | switch(scrollLoc) | 1167 | switch(scrollLoc) |
1178 | { | 1168 | { |
1179 | case SCRNONE : | 1169 | case SCRNONE : |
1180 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1170 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1171 | dcolumns = columns; | ||
1181 | if(vcolumns) columns = vcolumns; | 1172 | if(vcolumns) columns = vcolumns; |
1182 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1173 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1183 | if(showhscrollbar) | 1174 | if(showhscrollbar) |
1184 | blX = -hposition * font_w; | 1175 | blX = -hposition * font_w; |
1185 | brX = blX; | 1176 | brX = blX; |
1186 | scrollbar->hide(); | 1177 | scrollbar->hide(); |
1187 | break; | 1178 | break; |
1188 | case SCRLEFT : | 1179 | case SCRLEFT : |
1189 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1180 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1181 | dcolumns = columns; | ||
1190 | if(vcolumns) columns = vcolumns; | 1182 | if(vcolumns) columns = vcolumns; |
1191 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1183 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1192 | if(showhscrollbar) | 1184 | if(showhscrollbar) |
1193 | brX = -hposition * font_w; | 1185 | brX = -hposition * font_w; |
1194 | blX = brX + scrollbar->width(); | 1186 | blX = brX + scrollbar->width(); |
1195 | scrollbar->move(contentsRect().topLeft()); | 1187 | scrollbar->move(contentsRect().topLeft()); |
1196 | scrollbar->show(); | 1188 | scrollbar->show(); |
1197 | break; | 1189 | break; |
1198 | case SCRRIGHT: | 1190 | case SCRRIGHT: |
1199 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1191 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1192 | dcolumns = columns; | ||
1200 | if(vcolumns) columns = vcolumns; | 1193 | if(vcolumns) columns = vcolumns; |
1201 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1194 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1202 | if(showhscrollbar) | 1195 | if(showhscrollbar) |
1203 | blX = -hposition * font_w; | 1196 | blX = -hposition * font_w; |
1204 | brX = blX; | 1197 | brX = blX; |
1205 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1198 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1206 | scrollbar->show(); | 1199 | scrollbar->show(); |
1207 | break; | 1200 | break; |
1208 | } | 1201 | } |
1209 | //FIXME: support 'rounding' styles | 1202 | //FIXME: support 'rounding' styles |
1210 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1203 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1211 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1204 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1212 | 1205 | ||
1213 | if(showhscrollbar == 1) | 1206 | if(showhscrollbar == 1) |
1214 | { | 1207 | { |
1208 | hscrollbar->resize(contentsRect().width() - hwidth, hwidth); | ||
1209 | hscrollbar->setRange(0, vcolumns - dcolumns); | ||
1210 | |||
1211 | QPoint p = contentsRect().bottomLeft(); | ||
1212 | hscrollbar->move(QPoint(p.x(), p.y() - hwidth)); | ||
1213 | hscrollbar->show(); | ||
1214 | } | ||
1215 | else hscrollbar->hide(); | ||
1216 | |||
1217 | if(showhscrollbar == 1) | ||
1218 | { | ||
1215 | lines = lines - (hwidth / font_h) - 1; | 1219 | lines = lines - (hwidth / font_h) - 1; |
1216 | if(lines < 1) lines = 1; | 1220 | if(lines < 1) lines = 1; |
1217 | } | 1221 | } |
1218 | } | 1222 | } |
1219 | 1223 | ||
1220 | void TEWidget::makeImage() | 1224 | void TEWidget::makeImage() |
1221 | //FIXME: rename 'calcGeometry? | 1225 | //FIXME: rename 'calcGeometry? |
1222 | { | 1226 | { |
1223 | calcGeometry(); | 1227 | calcGeometry(); |
1224 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1228 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1225 | clearImage(); | 1229 | clearImage(); |
1226 | } | 1230 | } |
1227 | 1231 | ||
1228 | // calculate the needed size | 1232 | // calculate the needed size |
1229 | QSize TEWidget::calcSize(int cols, int lins) const | 1233 | QSize TEWidget::calcSize(int cols, int lins) const |
1230 | { | 1234 | { |
1231 | int frw = width() - contentsRect().width(); | 1235 | int frw = width() - contentsRect().width(); |
1232 | int frh = height() - contentsRect().height(); | 1236 | int frh = height() - contentsRect().height(); |
1233 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1237 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1234 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1238 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1235 | } | 1239 | } |
1236 | 1240 | ||
1237 | QSize TEWidget::sizeHint() const | 1241 | QSize TEWidget::sizeHint() const |
1238 | { | 1242 | { |
1239 | return size(); | 1243 | return size(); |
1240 | } | 1244 | } |
1241 | 1245 | ||
1242 | void TEWidget::styleChange(QStyle &) | 1246 | void TEWidget::styleChange(QStyle &) |
1243 | { | 1247 | { |
1244 | propagateSize(); | 1248 | propagateSize(); |
1245 | } | 1249 | } |
1246 | 1250 | ||
1247 | #ifndef QT_NO_DRAGANDDROP | 1251 | #ifndef QT_NO_DRAGANDDROP |
1248 | 1252 | ||
1249 | /* --------------------------------------------------------------------- */ | 1253 | /* --------------------------------------------------------------------- */ |
1250 | /* */ | 1254 | /* */ |
1251 | /* Drag & Drop */ | 1255 | /* Drag & Drop */ |
1252 | /* */ | 1256 | /* */ |
1253 | /* --------------------------------------------------------------------- */ | 1257 | /* --------------------------------------------------------------------- */ |
1254 | 1258 | ||
1255 | 1259 | ||
1256 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1260 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1257 | { | 1261 | { |
1258 | e->accept(QTextDrag::canDecode(e) || | 1262 | e->accept(QTextDrag::canDecode(e) || |
1259 | QUriDrag::canDecode(e)); | 1263 | QUriDrag::canDecode(e)); |
1260 | } | 1264 | } |
1261 | 1265 | ||
1262 | void TEWidget::dropEvent(QDropEvent* event) | 1266 | void TEWidget::dropEvent(QDropEvent* event) |
1263 | { | 1267 | { |
1264 | // The current behaviour when url(s) are dropped is | 1268 | // The current behaviour when url(s) are dropped is |
1265 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1269 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1266 | // * in all other cases, just paste | 1270 | // * in all other cases, just paste |
1267 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1271 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1268 | QStrList strlist; | 1272 | QStrList strlist; |
1269 | int file_count = 0; | 1273 | int file_count = 0; |
1270 | dropText = ""; | 1274 | dropText = ""; |
1271 | bool bPopup = true; | 1275 | bool bPopup = true; |
1272 | 1276 | ||
1273 | if(QUriDrag::decode(event, strlist)) { | 1277 | if(QUriDrag::decode(event, strlist)) { |
1274 | if (strlist.count()) { | 1278 | if (strlist.count()) { |
1275 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1279 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1276 | if(file_count++ > 0) { | 1280 | if(file_count++ > 0) { |
1277 | dropText += " "; | 1281 | dropText += " "; |
1278 | bPopup = false; // more than one file, don't popup | 1282 | bPopup = false; // more than one file, don't popup |