summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/TEWidget.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp
index bf9a313..2db214c 100644
--- a/noncore/apps/opie-console/TEWidget.cpp
+++ b/noncore/apps/opie-console/TEWidget.cpp
@@ -922,428 +922,434 @@ bool TEWidget::focusNextPrevChild( bool next )
922int TEWidget::charClass(char ch) const 922int TEWidget::charClass(char ch) const
923{ 923{
924 // This might seem like overkill, but imagine if ch was a Unicode 924 // This might seem like overkill, but imagine if ch was a Unicode
925 // character (Qt 2.0 QChar) - it might then be sensible to separate 925 // character (Qt 2.0 QChar) - it might then be sensible to separate
926 // the different language ranges, etc. 926 // the different language ranges, etc.
927 927
928 if ( isspace(ch) ) return ' '; 928 if ( isspace(ch) ) return ' ';
929 929
930 static const char *word_characters = ":@-./_~"; 930 static const char *word_characters = ":@-./_~";
931 if ( isalnum(ch) || strchr(word_characters, ch) ) 931 if ( isalnum(ch) || strchr(word_characters, ch) )
932 return 'a'; 932 return 'a';
933 933
934 // Everything else is weird 934 // Everything else is weird
935 return 1; 935 return 1;
936} 936}
937 937
938void TEWidget::setMouseMarks(bool on) 938void TEWidget::setMouseMarks(bool on)
939{ 939{
940 mouse_marks = on; 940 mouse_marks = on;
941 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 941 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
942} 942}
943 943
944/* ------------------------------------------------------------------------- */ 944/* ------------------------------------------------------------------------- */
945/* */ 945/* */
946/* Clipboard */ 946/* Clipboard */
947/* */ 947/* */
948/* ------------------------------------------------------------------------- */ 948/* ------------------------------------------------------------------------- */
949 949
950#undef KeyPress 950#undef KeyPress
951 951
952void TEWidget::emitSelection() 952void TEWidget::emitSelection()
953// Paste Clipboard by simulating keypress events 953// Paste Clipboard by simulating keypress events
954{ 954{
955#ifndef QT_NO_CLIPBOARD 955#ifndef QT_NO_CLIPBOARD
956 QString text = QApplication::clipboard()->text(); 956 QString text = QApplication::clipboard()->text();
957 if ( ! text.isNull() ) 957 if ( ! text.isNull() )
958 { 958 {
959 text.replace(QRegExp("\n"), "\r"); 959 text.replace(QRegExp("\n"), "\r");
960 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 960 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
961 emit keyPressedSignal(&e); // expose as a big fat keypress event 961 emit keyPressedSignal(&e); // expose as a big fat keypress event
962 emit clearSelectionSignal(); 962 emit clearSelectionSignal();
963 } 963 }
964#endif 964#endif
965} 965}
966 966
967void TEWidget::emitText(QString text) 967void TEWidget::emitText(QString text)
968{ 968{
969 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 969 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
970 emit keyPressedSignal(&e); // expose as a big fat keypress event 970 emit keyPressedSignal(&e); // expose as a big fat keypress event
971} 971}
972 972
973void TEWidget::pasteClipboard( ) 973void TEWidget::pasteClipboard( )
974{ 974{
975 emitSelection(); 975 emitSelection();
976} 976}
977 977
978void TEWidget::setSelection(const QString& t) 978void TEWidget::setSelection(const QString& t)
979{ 979{
980#ifndef QT_NO_CLIPBOARD 980#ifndef QT_NO_CLIPBOARD
981 // Disconnect signal while WE set the clipboard 981 // Disconnect signal while WE set the clipboard
982 QObject *cb = QApplication::clipboard(); 982 QObject *cb = QApplication::clipboard();
983 QObject::disconnect( cb, SIGNAL(dataChanged()), 983 QObject::disconnect( cb, SIGNAL(dataChanged()),
984 this, SLOT(onClearSelection()) ); 984 this, SLOT(onClearSelection()) );
985 985
986 QApplication::clipboard()->setText(t); 986 QApplication::clipboard()->setText(t);
987 987
988 QObject::connect( cb, SIGNAL(dataChanged()), 988 QObject::connect( cb, SIGNAL(dataChanged()),
989 this, SLOT(onClearSelection()) ); 989 this, SLOT(onClearSelection()) );
990#endif 990#endif
991} 991}
992 992
993void TEWidget::onClearSelection() 993void TEWidget::onClearSelection()
994{ 994{
995 emit clearSelectionSignal(); 995 emit clearSelectionSignal();
996} 996}
997 997
998/* ------------------------------------------------------------------------- */ 998/* ------------------------------------------------------------------------- */
999/* */ 999/* */
1000/* Keyboard */ 1000/* Keyboard */
1001/* */ 1001/* */
1002/* ------------------------------------------------------------------------- */ 1002/* ------------------------------------------------------------------------- */
1003 1003
1004//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 1004//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
1005// due to a bug in `QT' or the ignorance of the author to prevent 1005// due to a bug in `QT' or the ignorance of the author to prevent
1006// repaint events being emitted to the screen whenever one leaves 1006// repaint events being emitted to the screen whenever one leaves
1007// or reenters the screen to/from another application. 1007// or reenters the screen to/from another application.
1008// 1008//
1009// Troll says one needs to change focusInEvent() and focusOutEvent(), 1009// Troll says one needs to change focusInEvent() and focusOutEvent(),
1010// which would also let you have an in-focus cursor and an out-focus 1010// which would also let you have an in-focus cursor and an out-focus
1011// cursor like xterm does. 1011// cursor like xterm does.
1012 1012
1013// for the auto-hide cursor feature, I added empty focusInEvent() and 1013// for the auto-hide cursor feature, I added empty focusInEvent() and
1014// focusOutEvent() so that update() isn't called. 1014// focusOutEvent() so that update() isn't called.
1015// For auto-hide, we need to get keypress-events, but we only get them when 1015// For auto-hide, we need to get keypress-events, but we only get them when
1016// we have focus. 1016// we have focus.
1017 1017
1018void TEWidget::doScroll(int lines) 1018void TEWidget::doScroll(int lines)
1019{ 1019{
1020 scrollbar->setValue(scrollbar->value()+lines); 1020 scrollbar->setValue(scrollbar->value()+lines);
1021} 1021}
1022 1022
1023bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 1023bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1024{ 1024{
1025 if ( (e->type() == QEvent::Accel || 1025 if ( (e->type() == QEvent::Accel ||
1026 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 1026 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
1027 static_cast<QKeyEvent *>( e )->ignore(); 1027 static_cast<QKeyEvent *>( e )->ignore();
1028 return true; 1028 return true;
1029 } 1029 }
1030 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 1030 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
1031 return FALSE; // not us 1031 return FALSE; // not us
1032 if ( e->type() == QEvent::Wheel) { 1032 if ( e->type() == QEvent::Wheel) {
1033 QApplication::sendEvent(scrollbar, e); 1033 QApplication::sendEvent(scrollbar, e);
1034 } 1034 }
1035 1035
1036#ifdef FAKE_CTRL_AND_ALT 1036#ifdef FAKE_CTRL_AND_ALT
1037 static bool control = FALSE; 1037 static bool control = FALSE;
1038 static bool alt = FALSE; 1038 static bool alt = FALSE;
1039// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1039// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
1040 bool dele=FALSE; 1040 bool dele=FALSE;
1041 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1041 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1042 QKeyEvent* ke = (QKeyEvent*)e; 1042 QKeyEvent* ke = (QKeyEvent*)e;
1043 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1043 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1044 switch (ke->key()) { 1044 switch (ke->key()) {
1045 case Key_F9: // let this be "Control" 1045 case Key_F9: // let this be "Control"
1046 control = keydown; 1046 control = keydown;
1047 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1047 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1048 dele=TRUE; 1048 dele=TRUE;
1049 break; 1049 break;
1050 case Key_F13: // let this be "Alt" 1050 case Key_F13: // let this be "Alt"
1051 alt = keydown; 1051 alt = keydown;
1052 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1052 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1053 dele=TRUE; 1053 dele=TRUE;
1054 break; 1054 break;
1055 default: 1055 default:
1056 if ( control ) { 1056 if ( control ) {
1057 int a = toupper(ke->ascii())-64; 1057 int a = toupper(ke->ascii())-64;
1058 if ( a >= 0 && a < ' ' ) { 1058 if ( a >= 0 && a < ' ' ) {
1059 e = new QKeyEvent(e->type(), ke->key(), 1059 e = new QKeyEvent(e->type(), ke->key(),
1060 a, ke->state()|ControlButton, QChar(a,0)); 1060 a, ke->state()|ControlButton, QChar(a,0));
1061 dele=TRUE; 1061 dele=TRUE;
1062 } 1062 }
1063 } 1063 }
1064 if ( alt ) { 1064 if ( alt ) {
1065 e = new QKeyEvent(e->type(), ke->key(), 1065 e = new QKeyEvent(e->type(), ke->key(),
1066 ke->ascii(), ke->state()|AltButton, ke->text()); 1066 ke->ascii(), ke->state()|AltButton, ke->text());
1067 dele=TRUE; 1067 dele=TRUE;
1068 } 1068 }
1069 } 1069 }
1070 } 1070 }
1071#endif 1071#endif
1072 1072
1073 if ( e->type() == QEvent::KeyPress ) { 1073 if ( e->type() == QEvent::KeyPress ) {
1074 QKeyEvent* ke = (QKeyEvent*)e; 1074 QKeyEvent* ke = (QKeyEvent*)e;
1075 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1075 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1076 // know where the current selection is. 1076 // know where the current selection is.
1077 1077
1078// qDebug("key pressed is 0x%x",ke->key()); 1078// qDebug("key pressed is 0x%x",ke->key());
1079 1079
1080 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 1080 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
1081 1081
1082// qDebug("key pressed 2 is 0x%x",ke->key()); 1082// qDebug("key pressed 2 is 0x%x",ke->key());
1083 emitText("\\"); // expose 1083 emitText("\\"); // expose
1084 } else 1084 } else
1085 emit keyPressedSignal(ke); // expose 1085 emit keyPressedSignal(ke); // expose
1086 ke->accept(); 1086 ke->accept();
1087#ifdef FAKE_CTRL_AND_ALT 1087#ifdef FAKE_CTRL_AND_ALT
1088 if ( dele ) delete e; 1088 if ( dele ) delete e;
1089#endif 1089#endif
1090 return true; // stop the event 1090 return true; // stop the event
1091 } 1091 }
1092 if ( e->type() == QEvent::Enter ) { 1092 if ( e->type() == QEvent::Enter ) {
1093 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1093 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1094 this, SLOT(onClearSelection()) ); 1094 this, SLOT(onClearSelection()) );
1095 } 1095 }
1096 if ( e->type() == QEvent::Leave ) { 1096 if ( e->type() == QEvent::Leave ) {
1097 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1097 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1098 this, SLOT(onClearSelection()) ); 1098 this, SLOT(onClearSelection()) );
1099 } 1099 }
1100 return QFrame::eventFilter( obj, e ); 1100 return QFrame::eventFilter( obj, e );
1101} 1101}
1102 1102
1103/* ------------------------------------------------------------------------- */ 1103/* ------------------------------------------------------------------------- */
1104/* */ 1104/* */
1105/* Frame */ 1105/* Frame */
1106/* */ 1106/* */
1107/* ------------------------------------------------------------------------- */ 1107/* ------------------------------------------------------------------------- */
1108 1108
1109void TEWidget::frameChanged() 1109void TEWidget::frameChanged()
1110{ 1110{
1111 propagateSize(); 1111 propagateSize();
1112 update(); 1112 update();
1113} 1113}
1114 1114
1115/* ------------------------------------------------------------------------- */ 1115/* ------------------------------------------------------------------------- */
1116/* */ 1116/* */
1117/* Sound */ 1117/* Sound */
1118/* */ 1118/* */
1119/* ------------------------------------------------------------------------- */ 1119/* ------------------------------------------------------------------------- */
1120 1120
1121void TEWidget::Bell() 1121void TEWidget::Bell()
1122{ 1122{
1123 QApplication::beep(); 1123 QApplication::beep();
1124} 1124}
1125 1125
1126/* ------------------------------------------------------------------------- */ 1126/* ------------------------------------------------------------------------- */
1127/* */ 1127/* */
1128/* Auxiluary */ 1128/* Auxiluary */
1129/* */ 1129/* */
1130/* ------------------------------------------------------------------------- */ 1130/* ------------------------------------------------------------------------- */
1131 1131
1132void TEWidget::clearImage() 1132void TEWidget::clearImage()
1133// initialize the image 1133// initialize the image
1134// for internal use only 1134// for internal use only
1135{ 1135{
1136 for (int y = 0; y < lines; y++) 1136 for (int y = 0; y < lines; y++)
1137 for (int x = 0; x < columns; x++) 1137 for (int x = 0; x < columns; x++)
1138 { 1138 {
1139 image[loc(x,y)].c = 0xff; //' '; 1139 image[loc(x,y)].c = 0xff; //' ';
1140 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1140 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1141 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1141 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1142 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1142 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1143 } 1143 }
1144} 1144}
1145 1145
1146// Create Image /////////////////////////////////////////////////////// 1146// Create Image ///////////////////////////////////////////////////////
1147 1147
1148void TEWidget::calcGeometry() 1148void TEWidget::calcGeometry()
1149{ 1149{
1150 //FIXME: set rimX == rimY == 0 when running in full screen mode. 1150 //FIXME: set rimX == rimY == 0 when running in full screen mode.
1151 1151
1152 int showhscrollbar = 1; 1152 int showhscrollbar = 1;
1153 int hwidth = 0; 1153 int hwidth = 0;
1154 1154
1155 if(vcolumns == 0) showhscrollbar = 0; 1155 if(vcolumns == 0) showhscrollbar = 0;
1156 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); 1156 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
1157 1157
1158 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1158 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1159 contentsRect().height() - hwidth); 1159 contentsRect().height() - hwidth);
1160 1160
1161 if(showhscrollbar == 1) 1161 if(showhscrollbar == 1)
1162 { 1162 {
1163 hscrollbar->resize(contentsRect().width() - hwidth, hwidth); 1163 hscrollbar->resize(contentsRect().width() - hwidth, hwidth);
1164 hscrollbar->setRange(0, 40); 1164 hscrollbar->setRange(0, 40);
1165 1165
1166 QPoint p = contentsRect().bottomLeft(); 1166 QPoint p = contentsRect().bottomLeft();
1167 hscrollbar->move(QPoint(p.x(), p.y() - hwidth)); 1167 hscrollbar->move(QPoint(p.x(), p.y() - hwidth));
1168 hscrollbar->show(); 1168 hscrollbar->show();
1169 } 1169 }
1170 else hscrollbar->hide(); 1170 else hscrollbar->hide();
1171 1171
1172 switch(scrollLoc) 1172 switch(scrollLoc)
1173 { 1173 {
1174 case SCRNONE : 1174 case SCRNONE :
1175 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1175 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1176 if(vcolumns) columns = vcolumns; 1176 if(vcolumns) columns = vcolumns;
1177 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1177 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1178 if(showhscrollbar)
1179 blX = -hposition * font_w;
1178 brX = blX; 1180 brX = blX;
1179 scrollbar->hide(); 1181 scrollbar->hide();
1180 break; 1182 break;
1181 case SCRLEFT : 1183 case SCRLEFT :
1182 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1184 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1183 if(vcolumns) columns = vcolumns; 1185 if(vcolumns) columns = vcolumns;
1184 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1186 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1187 if(showhscrollbar)
1188 brX = -hposition * font_w;
1185 blX = brX + scrollbar->width(); 1189 blX = brX + scrollbar->width();
1186 scrollbar->move(contentsRect().topLeft()); 1190 scrollbar->move(contentsRect().topLeft());
1187 scrollbar->show(); 1191 scrollbar->show();
1188 break; 1192 break;
1189 case SCRRIGHT: 1193 case SCRRIGHT:
1190 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1194 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1191 if(vcolumns) columns = vcolumns; 1195 if(vcolumns) columns = vcolumns;
1192 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1196 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1193 if(showhscrollbar) 1197 if(showhscrollbar)
1194 blX = -hposition * font_w; 1198 blX = -hposition * font_w;
1195 brX = blX; 1199 brX = blX;
1196 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1200 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1197 scrollbar->show(); 1201 scrollbar->show();
1198 break; 1202 break;
1199 } 1203 }
1200 //FIXME: support 'rounding' styles 1204 //FIXME: support 'rounding' styles
1201 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1205 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1202 bY = (contentsRect().height() - (lines *font_h)) / 2; 1206 bY = (contentsRect().height() - (lines *font_h)) / 2;
1203 1207
1204 if(showhscrollbar == 1) 1208 if(showhscrollbar == 1)
1205 { 1209 {
1206 //bY = bY - 10; 1210 //bY = bY - 10;
1207 lines = lines - 1; 1211 lines = lines - 1;
1208 } 1212 }
1209} 1213}
1210 1214
1211void TEWidget::makeImage() 1215void TEWidget::makeImage()
1212//FIXME: rename 'calcGeometry? 1216//FIXME: rename 'calcGeometry?
1213{ 1217{
1214 calcGeometry(); 1218 calcGeometry();
1215 image = (ca*) malloc(lines*columns*sizeof(ca)); 1219 image = (ca*) malloc(lines*columns*sizeof(ca));
1216 clearImage(); 1220 clearImage();
1217} 1221}
1218 1222
1219// calculate the needed size 1223// calculate the needed size
1220QSize TEWidget::calcSize(int cols, int lins) const 1224QSize TEWidget::calcSize(int cols, int lins) const
1221{ 1225{
1222 int frw = width() - contentsRect().width(); 1226 int frw = width() - contentsRect().width();
1223 int frh = height() - contentsRect().height(); 1227 int frh = height() - contentsRect().height();
1224 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1228 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1225 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1229 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1226} 1230}
1227 1231
1228QSize TEWidget::sizeHint() const 1232QSize TEWidget::sizeHint() const
1229{ 1233{
1230 return size(); 1234 return size();
1231} 1235}
1232 1236
1233void TEWidget::styleChange(QStyle &) 1237void TEWidget::styleChange(QStyle &)
1234{ 1238{
1235 propagateSize(); 1239 propagateSize();
1236} 1240}
1237 1241
1238#ifndef QT_NO_DRAGANDDROP 1242#ifndef QT_NO_DRAGANDDROP
1239 1243
1240/* --------------------------------------------------------------------- */ 1244/* --------------------------------------------------------------------- */
1241/* */ 1245/* */
1242/* Drag & Drop */ 1246/* Drag & Drop */
1243/* */ 1247/* */
1244/* --------------------------------------------------------------------- */ 1248/* --------------------------------------------------------------------- */
1245 1249
1246 1250
1247void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1251void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1248{ 1252{
1249 e->accept(QTextDrag::canDecode(e) || 1253 e->accept(QTextDrag::canDecode(e) ||
1250 QUriDrag::canDecode(e)); 1254 QUriDrag::canDecode(e));
1251} 1255}
1252 1256
1253void TEWidget::dropEvent(QDropEvent* event) 1257void TEWidget::dropEvent(QDropEvent* event)
1254{ 1258{
1255 // The current behaviour when url(s) are dropped is 1259 // The current behaviour when url(s) are dropped is
1256 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1260 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1257 // * in all other cases, just paste 1261 // * in all other cases, just paste
1258 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1262 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1259 QStrList strlist; 1263 QStrList strlist;
1260 int file_count = 0; 1264 int file_count = 0;
1261 dropText = ""; 1265 dropText = "";
1262 bool bPopup = true; 1266 bool bPopup = true;
1263 1267
1264 if(QUriDrag::decode(event, strlist)) { 1268 if(QUriDrag::decode(event, strlist)) {
1265 if (strlist.count()) { 1269 if (strlist.count()) {
1266 for(const char* p = strlist.first(); p; p = strlist.next()) { 1270 for(const char* p = strlist.first(); p; p = strlist.next()) {
1267 if(file_count++ > 0) { 1271 if(file_count++ > 0) {
1268 dropText += " "; 1272 dropText += " ";
1269 bPopup = false; // more than one file, don't popup 1273 bPopup = false; // more than one file, don't popup
1270 } 1274 }
1271 1275
1272/* 1276/*
1273 KURL url(p); 1277 KURL url(p);
1274 if (url.isLocalFile()) { 1278 if (url.isLocalFile()) {
1275 dropText += url.path(); // local URL : remove protocol 1279 dropText += url.path(); // local URL : remove protocol
1276 } 1280 }
1277 else { 1281 else {
1278 dropText += url.prettyURL(); 1282 dropText += url.prettyURL();
1279 bPopup = false; // a non-local file, don't popup 1283 bPopup = false; // a non-local file, don't popup
1280 } 1284 }
1281*/ 1285*/
1282 1286
1283 } 1287 }
1284 1288
1285 if (bPopup) 1289 if (bPopup)
1286 // m_drop->popup(pos() + event->pos()); 1290 // m_drop->popup(pos() + event->pos());
1287 m_drop->popup(mapToGlobal(event->pos())); 1291 m_drop->popup(mapToGlobal(event->pos()));
1288 else 1292 else
1289 { 1293 {
1290 if (currentSession) { 1294 if (currentSession) {
1291 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1295 currentSession->getEmulation()->sendString(dropText.local8Bit());
1292 } 1296 }
1293// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1297// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1294 } 1298 }
1295 } 1299 }
1296 } 1300 }
1297 else if(QTextDrag::decode(event, dropText)) { 1301 else if(QTextDrag::decode(event, dropText)) {
1298// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1302// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1299 if (currentSession) { 1303 if (currentSession) {
1300 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1304 currentSession->getEmulation()->sendString(dropText.local8Bit());
1301 } 1305 }
1302 // Paste it 1306 // Paste it
1303 } 1307 }
1304} 1308}
1305#endif 1309#endif
1306 1310
1307 1311
1308void TEWidget::drop_menu_activated(int) 1312void TEWidget::drop_menu_activated(int)
1309{ 1313{
1310#ifndef QT_NO_DRAGANDDROP 1314#ifndef QT_NO_DRAGANDDROP
1311 switch (item) 1315 switch (item)
1312 { 1316 {
1313 case 0: // paste 1317 case 0: // paste
1314 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1318 currentSession->getEmulation()->sendString(dropText.local8Bit());
1315// KWM::activate((Window)this->winId()); 1319// KWM::activate((Window)this->winId());
1316 break; 1320 break;
1317 case 1: // cd ... 1321 case 1: // cd ...
1318 currentSession->getEmulation()->sendString("cd "); 1322 currentSession->getEmulation()->sendString("cd ");
1319 struct stat statbuf; 1323 struct stat statbuf;
1320 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1324 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1321 { 1325 {
1322 if ( !S_ISDIR(statbuf.st_mode) ) 1326 if ( !S_ISDIR(statbuf.st_mode) )
1323 { 1327 {
1324/* 1328/*
1325 KURL url; 1329 KURL url;
1326 url.setPath( dropText ); 1330 url.setPath( dropText );
1327 dropText = url.directory( true, false ); // remove filename 1331 dropText = url.directory( true, false ); // remove filename
1328*/ 1332*/
1329 } 1333 }
1330 } 1334 }
1331 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1335 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1332 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1336 currentSession->getEmulation()->sendString(dropText.local8Bit());
1333 currentSession->getEmulation()->sendString("\n"); 1337 currentSession->getEmulation()->sendString("\n");
1334// KWM::activate((Window)this->winId()); 1338// KWM::activate((Window)this->winId());
1335 break; 1339 break;
1336 } 1340 }
1337#endif 1341#endif
1338} 1342}
1339 1343
1340QPushButton* TEWidget::cornerButton() { 1344QPushButton* TEWidget::cornerButton() {
1341 return m_cornerButton; 1345 return m_cornerButton;
1342} 1346}
1343 1347
1344void TEWidget::setWrapAt(int columns) 1348void TEWidget::setWrapAt(int columns)
1345{ 1349{
1346 vcolumns = columns; 1350 vcolumns = columns;
1351 propagateSize();
1352 update();
1347} 1353}
1348 1354
1349 1355