summaryrefslogtreecommitdiff
authorar <ar>2004-05-02 16:22:24 (UTC)
committer ar <ar>2004-05-02 16:22:24 (UTC)
commit34f1234b010fa80f9ca06e65f46130713f7362d9 (patch) (unidiff)
tree6ded6dcd83ed00b436f312f2403f7afc9f399435
parent4e7ab937501b6495ce5635a7515e66a75e04d37e (diff)
downloadopie-34f1234b010fa80f9ca06e65f46130713f7362d9.zip
opie-34f1234b010fa80f9ca06e65f46130713f7362d9.tar.gz
opie-34f1234b010fa80f9ca06e65f46130713f7362d9.tar.bz2
- convert qDebug to odebug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEScreen.cpp2
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp6
-rw-r--r--core/apps/embeddedkonsole/commandeditdialog.cpp4
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp41
-rw-r--r--core/apps/embeddedkonsole/main.cpp8
-rw-r--r--core/apps/embeddedkonsole/playlistselection.cpp11
6 files changed, 38 insertions, 34 deletions
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp
index 3dbcec2..8e69a88 100644
--- a/core/apps/embeddedkonsole/TEScreen.cpp
+++ b/core/apps/embeddedkonsole/TEScreen.cpp
@@ -1,200 +1,200 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TEScreen.C] Screen Data Type */ 3/* [TEScreen.C] Screen Data Type */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12/* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18// enhancements added by L.J. Potter <ljp@llornkcor.com> 18// enhancements added by L.J. Potter <ljp@llornkcor.com>
19 19
20/*! \file 20/*! \file
21*/ 21*/
22 22
23/*! \class TEScreen 23/*! \class TEScreen
24 24
25 \brief The image manipulated by the emulation. 25 \brief The image manipulated by the emulation.
26 26
27 This class implements the operations of the terminal emulation framework. 27 This class implements the operations of the terminal emulation framework.
28 It is a complete passive device, driven by the emulation decoder 28 It is a complete passive device, driven by the emulation decoder
29 (TEmuVT102). By this it forms in fact an ADT, that defines operations 29 (TEmuVT102). By this it forms in fact an ADT, that defines operations
30 on a rectangular image. 30 on a rectangular image.
31 31
32 It does neither know how to display its image nor about escape sequences. 32 It does neither know how to display its image nor about escape sequences.
33 It is further independent of the underlying toolkit. By this, one can even 33 It is further independent of the underlying toolkit. By this, one can even
34 use this module for an ordinary text surface. 34 use this module for an ordinary text surface.
35 35
36 Since the operations are called by a specific emulation decoder, one may 36 Since the operations are called by a specific emulation decoder, one may
37 collect their different operations here. 37 collect their different operations here.
38 38
39 The state manipulated by the operations is mainly kept in `image', though 39 The state manipulated by the operations is mainly kept in `image', though
40 it is a little more complex bejond this. See the header file of the class. 40 it is a little more complex bejond this. See the header file of the class.
41 41
42 \sa TEWidget \sa VT102Emulation 42 \sa TEWidget \sa VT102Emulation
43*/ 43*/
44 44
45#include <stdio.h> 45#include <stdio.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <unistd.h> 47#include <unistd.h>
48// #include <kdebug.h> 48// #include <kdebug.h>
49 49
50#include <assert.h> 50#include <assert.h>
51#include <string.h> 51#include <string.h>
52#include <ctype.h> 52#include <ctype.h>
53 53
54#include <qpe/config.h> 54#include <qpe/config.h>
55#include "TEScreen.h" 55#include "TEScreen.h"
56 56
57#define HERE printf("%s(%d): here\n",__FILE__,__LINE__) 57#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
58 58
59//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI. 59//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI.
60//FIXME: see if we can get this from terminfo. 60//FIXME: see if we can get this from terminfo.
61#define BS_CLEARS FALSE 61#define BS_CLEARS FALSE
62 62
63#define loc(X,Y) ((Y) * columns + (X)) 63#define loc(X,Y) ((Y) * columns + (X))
64 64
65/*! creates a `TEScreen' of `lines' lines and `columns' columns. 65/*! creates a `TEScreen' of `lines' lines and `columns' columns.
66*/ 66*/
67 67
68TEScreen::TEScreen(int lines, int columns) 68TEScreen::TEScreen(int lines, int columns)
69{ 69{
70 this->lines = lines; 70 this->lines = lines;
71 this->columns = columns; 71 this->columns = columns;
72// qDebug("Columns %d", columns); 72// odebug << "Columns " << columns << "" << oendl;
73 73
74 image = (ca*) malloc(lines*columns*sizeof(ca)); 74 image = (ca*) malloc(lines*columns*sizeof(ca));
75 tabstops = NULL; initTabStops(); 75 tabstops = NULL; initTabStops();
76 76
77 histCursor = 0; 77 histCursor = 0;
78 horzCursor = 0; 78 horzCursor = 0;
79 79
80 clearSelection(); 80 clearSelection();
81 reset(); 81 reset();
82} 82}
83 83
84/*! Destructor 84/*! Destructor
85*/ 85*/
86 86
87TEScreen::~TEScreen() 87TEScreen::~TEScreen()
88{ 88{
89 free(image); 89 free(image);
90 if (tabstops) free(tabstops); 90 if (tabstops) free(tabstops);
91} 91}
92 92
93/* ------------------------------------------------------------------------- */ 93/* ------------------------------------------------------------------------- */
94/* */ 94/* */
95/* Normalized Screen Operations */ 95/* Normalized Screen Operations */
96/* */ 96/* */
97/* ------------------------------------------------------------------------- */ 97/* ------------------------------------------------------------------------- */
98 98
99// Cursor Setting -------------------------------------------------------------- 99// Cursor Setting --------------------------------------------------------------
100 100
101/*! \section Cursor 101/*! \section Cursor
102 102
103 The `cursor' is a location within the screen that is implicitely used in 103 The `cursor' is a location within the screen that is implicitely used in
104 many operations. The operations within this section allow to manipulate 104 many operations. The operations within this section allow to manipulate
105 the cursor explicitly and to obtain it's value. 105 the cursor explicitly and to obtain it's value.
106 106
107 The position of the cursor is guarantied to be between (including) 0 and 107 The position of the cursor is guarantied to be between (including) 0 and
108 `columns-1' and `lines-1'. 108 `columns-1' and `lines-1'.
109*/ 109*/
110 110
111/*! 111/*!
112 Move the cursor up. 112 Move the cursor up.
113 113
114 The cursor will not be moved beyond the top margin. 114 The cursor will not be moved beyond the top margin.
115*/ 115*/
116 116
117void TEScreen::cursorUp(int n) 117void TEScreen::cursorUp(int n)
118//=CUU 118//=CUU
119{ 119{
120 if (n == 0) n = 1; // Default 120 if (n == 0) n = 1; // Default
121 int stop = cuY < tmargin ? 0 : tmargin; 121 int stop = cuY < tmargin ? 0 : tmargin;
122 cuX = QMIN(columns-1,cuX); // nowrap! 122 cuX = QMIN(columns-1,cuX); // nowrap!
123 cuY = QMAX(stop,cuY-n); 123 cuY = QMAX(stop,cuY-n);
124} 124}
125 125
126/*! 126/*!
127 Move the cursor down. 127 Move the cursor down.
128 128
129 The cursor will not be moved beyond the bottom margin. 129 The cursor will not be moved beyond the bottom margin.
130*/ 130*/
131 131
132void TEScreen::cursorDown(int n) 132void TEScreen::cursorDown(int n)
133//=CUD 133//=CUD
134{ 134{
135 if (n == 0) n = 1; // Default 135 if (n == 0) n = 1; // Default
136 int stop = cuY > bmargin ? lines-1 : bmargin; 136 int stop = cuY > bmargin ? lines-1 : bmargin;
137 cuX = QMIN(columns-1,cuX); // nowrap! 137 cuX = QMIN(columns-1,cuX); // nowrap!
138 cuY = QMIN(stop,cuY+n); 138 cuY = QMIN(stop,cuY+n);
139} 139}
140 140
141/*! 141/*!
142 Move the cursor left. 142 Move the cursor left.
143 143
144 The cursor will not move beyond the first column. 144 The cursor will not move beyond the first column.
145*/ 145*/
146 146
147void TEScreen::cursorLeft(int n) 147void TEScreen::cursorLeft(int n)
148//=CUB 148//=CUB
149{ 149{
150 if (n == 0) n = 1; // Default 150 if (n == 0) n = 1; // Default
151 cuX = QMIN(columns-1,cuX); // nowrap! 151 cuX = QMIN(columns-1,cuX); // nowrap!
152 cuX = QMAX(0,cuX-n); 152 cuX = QMAX(0,cuX-n);
153} 153}
154 154
155/*! 155/*!
156 Move the cursor left. 156 Move the cursor left.
157 157
158 The cursor will not move beyond the rightmost column. 158 The cursor will not move beyond the rightmost column.
159*/ 159*/
160 160
161void TEScreen::cursorRight(int n) 161void TEScreen::cursorRight(int n)
162//=CUF 162//=CUF
163{ 163{
164 if (n == 0) n = 1; // Default 164 if (n == 0) n = 1; // Default
165 cuX = QMIN(columns-1,cuX+n); 165 cuX = QMIN(columns-1,cuX+n);
166} 166}
167 167
168/*! 168/*!
169 Set top and bottom margin. 169 Set top and bottom margin.
170*/ 170*/
171 171
172void TEScreen::setMargins(int top, int bot) 172void TEScreen::setMargins(int top, int bot)
173//=STBM 173//=STBM
174{ 174{
175 if (top == 0) top = 1; // Default 175 if (top == 0) top = 1; // Default
176 if (bot == 0) bot = lines; // Default 176 if (bot == 0) bot = lines; // Default
177 top = top - 1; // Adjust to internal lineno 177 top = top - 1; // Adjust to internal lineno
178 bot = bot - 1; // Adjust to internal lineno 178 bot = bot - 1; // Adjust to internal lineno
179 if ( !( 0 <= top && top < bot && bot < lines ) ) 179 if ( !( 0 <= top && top < bot && bot < lines ) )
180 { fprintf(stderr,"%s(%d) : setRegion(%d,%d) : bad range.\n", 180 { fprintf(stderr,"%s(%d) : setRegion(%d,%d) : bad range.\n",
181 __FILE__,__LINE__,top,bot); 181 __FILE__,__LINE__,top,bot);
182 return; // Default error action: ignore 182 return; // Default error action: ignore
183 } 183 }
184 tmargin = top; 184 tmargin = top;
185 bmargin = bot; 185 bmargin = bot;
186 cuX = 0; 186 cuX = 0;
187 cuY = getMode(MODE_Origin) ? top : 0; 187 cuY = getMode(MODE_Origin) ? top : 0;
188} 188}
189 189
190/*! 190/*!
191 Move the cursor down one line. 191 Move the cursor down one line.
192 192
193 If cursor is on bottom margin, the region between the 193 If cursor is on bottom margin, the region between the
194 actual top and bottom margin is scrolled up instead. 194 actual top and bottom margin is scrolled up instead.
195*/ 195*/
196 196
197void TEScreen::index() 197void TEScreen::index()
198//=IND 198//=IND
199{ 199{
200 if (cuY == bmargin) 200 if (cuY == bmargin)
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index 93348f4..3cb1c0a 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -816,383 +816,383 @@ void TEWidget::mouseReleaseEvent(QMouseEvent* ev)
816 } 816 }
817 817
818 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); 818 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks);
819 preserve_line_breaks = TRUE; 819 preserve_line_breaks = TRUE;
820 actSel = 0; 820 actSel = 0;
821 821
822 //FIXME: emits a release event even if the mouse is 822 //FIXME: emits a release event even if the mouse is
823 // outside the range. The procedure used in `mouseMoveEvent' 823 // outside the range. The procedure used in `mouseMoveEvent'
824 // applies here, too. 824 // applies here, too.
825 825
826 QPoint tL = contentsRect().topLeft(); 826 QPoint tL = contentsRect().topLeft();
827 int tLx = tL.x(); 827 int tLx = tL.x();
828 int tLy = tL.y(); 828 int tLy = tL.y();
829 829
830 if (!mouse_marks && !(ev->state() & ShiftButton)) 830 if (!mouse_marks && !(ev->state() & ShiftButton))
831 emit mouseSignal( 3, // release 831 emit mouseSignal( 3, // release
832 (ev->x()-tLx-blX)/font_w + 1, 832 (ev->x()-tLx-blX)/font_w + 1,
833 (ev->y()-tLy-bY)/font_h + 1 ); 833 (ev->y()-tLy-bY)/font_h + 1 );
834 releaseMouse(); 834 releaseMouse();
835 } 835 }
836} 836}
837 837
838void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) 838void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
839{ 839{
840 if ( ev->button() != LeftButton) return; 840 if ( ev->button() != LeftButton) return;
841 841
842 QPoint tL = contentsRect().topLeft(); 842 QPoint tL = contentsRect().topLeft();
843 int tLx = tL.x(); 843 int tLx = tL.x();
844 int tLy = tL.y(); 844 int tLy = tL.y();
845 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 845 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
846 846
847 // pass on double click as two clicks. 847 // pass on double click as two clicks.
848 if (!mouse_marks && !(ev->state() & ShiftButton)) 848 if (!mouse_marks && !(ev->state() & ShiftButton))
849 { 849 {
850 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 850 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
851 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release 851 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
852 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 852 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
853 return; 853 return;
854 } 854 }
855 855
856 856
857 emit clearSelectionSignal(); 857 emit clearSelectionSignal();
858 QPoint bgnSel = pos; 858 QPoint bgnSel = pos;
859 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 859 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
860 int i = loc(bgnSel.x(),bgnSel.y()); 860 int i = loc(bgnSel.x(),bgnSel.y());
861 iPntSel = bgnSel; 861 iPntSel = bgnSel;
862 862
863 word_selection_mode = TRUE; 863 word_selection_mode = TRUE;
864 864
865 // find word boundaries... 865 // find word boundaries...
866 int selClass = charClass(image[i].c); 866 int selClass = charClass(image[i].c);
867 { 867 {
868 // set the start... 868 // set the start...
869 int x = bgnSel.x(); 869 int x = bgnSel.x();
870 while ( x > 0 && charClass(image[i-1].c) == selClass ) 870 while ( x > 0 && charClass(image[i-1].c) == selClass )
871 { i--; x--; } 871 { i--; x--; }
872 bgnSel.setX(x); 872 bgnSel.setX(x);
873 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); 873 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );
874 874
875 // set the end... 875 // set the end...
876 i = loc( endSel.x(), endSel.y() ); 876 i = loc( endSel.x(), endSel.y() );
877 x = endSel.x(); 877 x = endSel.x();
878 while( x < columns-1 && charClass(image[i+1].c) == selClass ) 878 while( x < columns-1 && charClass(image[i+1].c) == selClass )
879 { i++; x++ ; } 879 { i++; x++ ; }
880 endSel.setX(x); 880 endSel.setX(x);
881 actSel = 2; // within selection 881 actSel = 2; // within selection
882 emit extendSelectionSignal( endSel.x(), endSel.y() ); 882 emit extendSelectionSignal( endSel.x(), endSel.y() );
883 emit endSelectionSignal(preserve_line_breaks); 883 emit endSelectionSignal(preserve_line_breaks);
884 preserve_line_breaks = TRUE; 884 preserve_line_breaks = TRUE;
885 } 885 }
886} 886}
887 887
888void TEWidget::focusInEvent( QFocusEvent * ) 888void TEWidget::focusInEvent( QFocusEvent * )
889{ 889{
890 890
891 // do nothing, to prevent repainting 891 // do nothing, to prevent repainting
892} 892}
893 893
894 894
895void TEWidget::focusOutEvent( QFocusEvent * ) 895void TEWidget::focusOutEvent( QFocusEvent * )
896{ 896{
897 // do nothing, to prevent repainting 897 // do nothing, to prevent repainting
898} 898}
899 899
900bool TEWidget::focusNextPrevChild( bool next ) 900bool TEWidget::focusNextPrevChild( bool next )
901{ 901{
902 if (next) 902 if (next)
903 return false; // This disables changing the active part in konqueror 903 return false; // This disables changing the active part in konqueror
904 // when pressing Tab 904 // when pressing Tab
905 return QFrame::focusNextPrevChild( next ); 905 return QFrame::focusNextPrevChild( next );
906} 906}
907 907
908 908
909int TEWidget::charClass(char ch) const 909int TEWidget::charClass(char ch) const
910{ 910{
911 // This might seem like overkill, but imagine if ch was a Unicode 911 // This might seem like overkill, but imagine if ch was a Unicode
912 // character (Qt 2.0 QChar) - it might then be sensible to separate 912 // character (Qt 2.0 QChar) - it might then be sensible to separate
913 // the different language ranges, etc. 913 // the different language ranges, etc.
914 914
915 if ( isspace(ch) ) return ' '; 915 if ( isspace(ch) ) return ' ';
916 916
917 static const char *word_characters = ":@-./_~"; 917 static const char *word_characters = ":@-./_~";
918 if ( isalnum(ch) || strchr(word_characters, ch) ) 918 if ( isalnum(ch) || strchr(word_characters, ch) )
919 return 'a'; 919 return 'a';
920 920
921 // Everything else is weird 921 // Everything else is weird
922 return 1; 922 return 1;
923} 923}
924 924
925void TEWidget::setMouseMarks(bool on) 925void TEWidget::setMouseMarks(bool on)
926{ 926{
927 mouse_marks = on; 927 mouse_marks = on;
928 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 928 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
929} 929}
930 930
931/* ------------------------------------------------------------------------- */ 931/* ------------------------------------------------------------------------- */
932/* */ 932/* */
933/* Clipboard */ 933/* Clipboard */
934/* */ 934/* */
935/* ------------------------------------------------------------------------- */ 935/* ------------------------------------------------------------------------- */
936 936
937#undef KeyPress 937#undef KeyPress
938 938
939void TEWidget::emitSelection() 939void TEWidget::emitSelection()
940// Paste Clipboard by simulating keypress events 940// Paste Clipboard by simulating keypress events
941{ 941{
942#ifndef QT_NO_CLIPBOARD 942#ifndef QT_NO_CLIPBOARD
943 QString text = QApplication::clipboard()->text(); 943 QString text = QApplication::clipboard()->text();
944 //qDebug(text); 944 //odebug << text << oendl;
945 if ( ! text.isNull()) 945 if ( ! text.isNull())
946 { 946 {
947 text.replace(QRegExp("\n"), "\r"); 947 text.replace(QRegExp("\n"), "\r");
948 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 948 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
949 emit keyPressedSignal(&e); // expose as a big fat keypress event 949 emit keyPressedSignal(&e); // expose as a big fat keypress event
950 emit clearSelectionSignal(); 950 emit clearSelectionSignal();
951 } 951 }
952#endif 952#endif
953} 953}
954 954
955void TEWidget::emitText(QString text) 955void TEWidget::emitText(QString text)
956{ 956{
957 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 957 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
958 emit keyPressedSignal(&e); // expose as a big fat keypress event 958 emit keyPressedSignal(&e); // expose as a big fat keypress event
959} 959}
960 960
961void TEWidget::pasteClipboard( ) 961void TEWidget::pasteClipboard( )
962{ 962{
963 emitSelection(); 963 emitSelection();
964} 964}
965 965
966void TEWidget::setSelection(const QString& t) 966void TEWidget::setSelection(const QString& t)
967{ 967{
968#ifndef QT_NO_CLIPBOARD 968#ifndef QT_NO_CLIPBOARD
969 // Disconnect signal while WE set the clipboard 969 // Disconnect signal while WE set the clipboard
970 QObject *cb = QApplication::clipboard(); 970 QObject *cb = QApplication::clipboard();
971 QObject::disconnect( cb, SIGNAL(dataChanged()), 971 QObject::disconnect( cb, SIGNAL(dataChanged()),
972 this, SLOT(onClearSelection()) ); 972 this, SLOT(onClearSelection()) );
973 973
974 QApplication::clipboard()->setText(t); 974 QApplication::clipboard()->setText(t);
975 975
976 QObject::connect( cb, SIGNAL(dataChanged()), 976 QObject::connect( cb, SIGNAL(dataChanged()),
977 this, SLOT(onClearSelection()) ); 977 this, SLOT(onClearSelection()) );
978#endif 978#endif
979} 979}
980 980
981void TEWidget::onClearSelection() 981void TEWidget::onClearSelection()
982{ 982{
983 emit clearSelectionSignal(); 983 emit clearSelectionSignal();
984} 984}
985 985
986/* ------------------------------------------------------------------------- */ 986/* ------------------------------------------------------------------------- */
987/* */ 987/* */
988/* Keyboard */ 988/* Keyboard */
989/* */ 989/* */
990/* ------------------------------------------------------------------------- */ 990/* ------------------------------------------------------------------------- */
991 991
992//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 992//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
993// due to a bug in `QT' or the ignorance of the author to prevent 993// due to a bug in `QT' or the ignorance of the author to prevent
994// repaint events being emitted to the screen whenever one leaves 994// repaint events being emitted to the screen whenever one leaves
995// or reenters the screen to/from another application. 995// or reenters the screen to/from another application.
996// 996//
997// Troll says one needs to change focusInEvent() and focusOutEvent(), 997// Troll says one needs to change focusInEvent() and focusOutEvent(),
998// which would also let you have an in-focus cursor and an out-focus 998// which would also let you have an in-focus cursor and an out-focus
999// cursor like xterm does. 999// cursor like xterm does.
1000 1000
1001// for the auto-hide cursor feature, I added empty focusInEvent() and 1001// for the auto-hide cursor feature, I added empty focusInEvent() and
1002// focusOutEvent() so that update() isn't called. 1002// focusOutEvent() so that update() isn't called.
1003// For auto-hide, we need to get keypress-events, but we only get them when 1003// For auto-hide, we need to get keypress-events, but we only get them when
1004// we have focus. 1004// we have focus.
1005 1005
1006void TEWidget::doScroll(int lines) 1006void TEWidget::doScroll(int lines)
1007{ 1007{
1008 scrollbar->setValue(scrollbar->value()+lines); 1008 scrollbar->setValue(scrollbar->value()+lines);
1009} 1009}
1010 1010
1011void TEWidget::doHScroll(int lines) { 1011void TEWidget::doHScroll(int lines) {
1012 hScrollbar->setValue( hScrollbar->value()+lines); 1012 hScrollbar->setValue( hScrollbar->value()+lines);
1013} 1013}
1014 1014
1015bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 1015bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1016{ 1016{
1017 if ( (e->type() == QEvent::Accel || 1017 if ( (e->type() == QEvent::Accel ||
1018 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 1018 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
1019 static_cast<QKeyEvent *>( e )->ignore(); 1019 static_cast<QKeyEvent *>( e )->ignore();
1020 return true; 1020 return true;
1021 } 1021 }
1022 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 1022 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
1023 return FALSE; // not us 1023 return FALSE; // not us
1024 if ( e->type() == QEvent::Wheel) { 1024 if ( e->type() == QEvent::Wheel) {
1025 QApplication::sendEvent(scrollbar, e); 1025 QApplication::sendEvent(scrollbar, e);
1026 } 1026 }
1027 1027
1028#ifdef FAKE_CTRL_AND_ALT 1028#ifdef FAKE_CTRL_AND_ALT
1029 static bool control = FALSE; 1029 static bool control = FALSE;
1030 static bool alt = FALSE; 1030 static bool alt = FALSE;
1031// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1031// odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl;
1032 bool dele=FALSE; 1032 bool dele=FALSE;
1033 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1033 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1034 QKeyEvent* ke = (QKeyEvent*)e; 1034 QKeyEvent* ke = (QKeyEvent*)e;
1035 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1035 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1036 switch (ke->key()) { 1036 switch (ke->key()) {
1037 case Key_F9: // let this be "Control" 1037 case Key_F9: // let this be "Control"
1038 control = keydown; 1038 control = keydown;
1039 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1039 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1040 dele=TRUE; 1040 dele=TRUE;
1041 break; 1041 break;
1042 case Key_F13: // let this be "Alt" 1042 case Key_F13: // let this be "Alt"
1043 alt = keydown; 1043 alt = keydown;
1044 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1044 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1045 dele=TRUE; 1045 dele=TRUE;
1046 break; 1046 break;
1047 default: 1047 default:
1048 if ( control ) { 1048 if ( control ) {
1049 int a = toupper(ke->ascii())-64; 1049 int a = toupper(ke->ascii())-64;
1050 if ( a >= 0 && a < ' ' ) { 1050 if ( a >= 0 && a < ' ' ) {
1051 e = new QKeyEvent(e->type(), ke->key(), 1051 e = new QKeyEvent(e->type(), ke->key(),
1052 a, ke->state()|ControlButton, QChar(a,0)); 1052 a, ke->state()|ControlButton, QChar(a,0));
1053 dele=TRUE; 1053 dele=TRUE;
1054 } 1054 }
1055 } 1055 }
1056 if ( alt ) { 1056 if ( alt ) {
1057 e = new QKeyEvent(e->type(), ke->key(), 1057 e = new QKeyEvent(e->type(), ke->key(),
1058 ke->ascii(), ke->state()|AltButton, ke->text()); 1058 ke->ascii(), ke->state()|AltButton, ke->text());
1059 dele=TRUE; 1059 dele=TRUE;
1060 } 1060 }
1061 } 1061 }
1062 } 1062 }
1063#endif 1063#endif
1064 1064
1065 if ( e->type() == QEvent::KeyPress ) { 1065 if ( e->type() == QEvent::KeyPress ) {
1066 QKeyEvent* ke = (QKeyEvent*)e; 1066 QKeyEvent* ke = (QKeyEvent*)e;
1067 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1067 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1068 // know where the current selection is. 1068 // know where the current selection is.
1069 1069
1070// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); 1070// odebug << "key pressed is 0x" << ke->key() << ", ascii is 0x" << ke->ascii() << ", state " << ke->state() << "" << oendl;
1071 1071
1072 bool special_function = true; 1072 bool special_function = true;
1073 switch(ke->key()) { 1073 switch(ke->key()) {
1074 //case 0x201b: // fn-5 1074 //case 0x201b: // fn-5
1075 //case Key_F1: 1075 //case Key_F1:
1076 // switch sessions (?) 1076 // switch sessions (?)
1077 // emitText("\\"); // expose (??) 1077 // emitText("\\"); // expose (??)
1078 // break; 1078 // break;
1079 1079
1080 case 0x2016: // fn-p 1080 case 0x2016: // fn-p
1081 case Key_F2: 1081 case Key_F2:
1082 pasteClipboard(); 1082 pasteClipboard();
1083 break; 1083 break;
1084 1084
1085 case 0x2018: // fn-S 1085 case 0x2018: // fn-S
1086 case Key_F3: 1086 case Key_F3:
1087 emit changeSession(1); 1087 emit changeSession(1);
1088 break; 1088 break;
1089 1089
1090 case 0x2019: // fn-n 1090 case 0x2019: // fn-n
1091 emit newSession(); 1091 emit newSession();
1092 break; 1092 break;
1093 1093
1094 case Qt::Key_Tab: 1094 case Qt::Key_Tab:
1095 if (ke->state() == ControlButton) { 1095 if (ke->state() == ControlButton) {
1096 emit changeSession(1); 1096 emit changeSession(1);
1097 } else { 1097 } else {
1098 special_function = false; 1098 special_function = false;
1099 } 1099 }
1100 break; 1100 break;
1101 1101
1102#if 0 1102#if 0
1103 case Qt::Key_Left: 1103 case Qt::Key_Left:
1104 if (vcolumns == 0) { 1104 if (vcolumns == 0) {
1105 emit changeSession(-1); 1105 emit changeSession(-1);
1106 } else { 1106 } else {
1107 special_function = false; 1107 special_function = false;
1108 } 1108 }
1109 break; 1109 break;
1110 1110
1111 case Qt::Key_Right: 1111 case Qt::Key_Right:
1112 if (vcolumns == 0) { 1112 if (vcolumns == 0) {
1113 emit changeSession(1); 1113 emit changeSession(1);
1114 } else { 1114 } else {
1115 special_function = false; 1115 special_function = false;
1116 } 1116 }
1117 break; 1117 break;
1118#endif 1118#endif
1119 1119
1120 case 0x201b: // fn-5 1120 case 0x201b: // fn-5
1121 case Key_F4: 1121 case Key_F4:
1122 emit toggleFullScreen(); 1122 emit toggleFullScreen();
1123 break; 1123 break;
1124 1124
1125 case 0x200f: // fn-1 magnify minus 1125 case 0x200f: // fn-1 magnify minus
1126 case Key_F5: 1126 case Key_F5:
1127 emit changeFontSize(-1); 1127 emit changeFontSize(-1);
1128 break; 1128 break;
1129 1129
1130 case 0x2010: // fn-2 magnify plus 1130 case 0x2010: // fn-2 magnify plus
1131 case Key_F6: 1131 case Key_F6:
1132 emit changeFontSize(1); 1132 emit changeFontSize(1);
1133 break; 1133 break;
1134 1134
1135 default: 1135 default:
1136 special_function = false; 1136 special_function = false;
1137 } 1137 }
1138 if (special_function) { 1138 if (special_function) {
1139 return true; 1139 return true;
1140 } 1140 }
1141 // else if( ke->state() == ControlButton && ke->key() == Key_V) { 1141 // else if( ke->state() == ControlButton && ke->key() == Key_V) {
1142 // pasteClipboard(); 1142 // pasteClipboard();
1143 // } 1143 // }
1144 // else if( ke->state() == ControlButton && ke->key() == Key_C) { 1144 // else if( ke->state() == ControlButton && ke->key() == Key_C) {
1145 // pasteClipboard(); 1145 // pasteClipboard();
1146 // } 1146 // }
1147 emit keyPressedSignal(ke); // expose 1147 emit keyPressedSignal(ke); // expose
1148 ke->accept(); 1148 ke->accept();
1149#ifdef FAKE_CTRL_AND_ALT 1149#ifdef FAKE_CTRL_AND_ALT
1150 if ( dele ) delete e; 1150 if ( dele ) delete e;
1151#endif 1151#endif
1152 return true; // stop the event 1152 return true; // stop the event
1153 } 1153 }
1154 if ( e->type() == QEvent::Enter ) { 1154 if ( e->type() == QEvent::Enter ) {
1155 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1155 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1156 this, SLOT(onClearSelection()) ); 1156 this, SLOT(onClearSelection()) );
1157 } 1157 }
1158 if ( e->type() == QEvent::Leave ) { 1158 if ( e->type() == QEvent::Leave ) {
1159 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1159 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1160 this, SLOT(onClearSelection()) ); 1160 this, SLOT(onClearSelection()) );
1161 } 1161 }
1162 return QFrame::eventFilter( obj, e ); 1162 return QFrame::eventFilter( obj, e );
1163} 1163}
1164 1164
1165/* ------------------------------------------------------------------------- */ 1165/* ------------------------------------------------------------------------- */
1166/* */ 1166/* */
1167/* Frame */ 1167/* Frame */
1168/* */ 1168/* */
1169/* ------------------------------------------------------------------------- */ 1169/* ------------------------------------------------------------------------- */
1170 1170
1171void TEWidget::frameChanged() 1171void TEWidget::frameChanged()
1172{ 1172{
1173 propagateSize(); 1173 propagateSize();
1174 update(); 1174 update();
1175} 1175}
1176/* ------------------------------------------------------------------------- */ 1176/* ------------------------------------------------------------------------- */
1177/* */ 1177/* */
1178/* Sound */ 1178/* Sound */
1179/* */ 1179/* */
1180/* ------------------------------------------------------------------------- */ 1180/* ------------------------------------------------------------------------- */
1181 1181
1182void TEWidget::Bell() 1182void TEWidget::Bell()
1183{ 1183{
1184//#ifdef QT_QWS_SL5XXX 1184//#ifdef QT_QWS_SL5XXX
1185//# ifndef QT_NO_COP 1185//# ifndef QT_NO_COP
1186 if(useBeep) 1186 if(useBeep)
1187 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); 1187 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" );
1188 1188
1189//# endif 1189//# endif
1190//#else 1190//#else
1191//# ifndef QT_NO_SOUND 1191//# ifndef QT_NO_SOUND
1192// QSound::play(Resource::findSound("alarm")); 1192// QSound::play(Resource::findSound("alarm"));
1193//# endif 1193//# endif
1194//#endif 1194//#endif
1195 1195
1196// QApplication::beep(); 1196// QApplication::beep();
1197} 1197}
1198 1198
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp
index 6587b26..697bf72 100644
--- a/core/apps/embeddedkonsole/commandeditdialog.cpp
+++ b/core/apps/embeddedkonsole/commandeditdialog.cpp
@@ -26,166 +26,166 @@ CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags f
26 item = new QListViewItem( m_SuggestedCommandList,"gzip "); 26 item = new QListViewItem( m_SuggestedCommandList,"gzip ");
27 item = new QListViewItem( m_SuggestedCommandList,"gunzip "); 27 item = new QListViewItem( m_SuggestedCommandList,"gunzip ");
28 item = new QListViewItem( m_SuggestedCommandList,"chgrp "); 28 item = new QListViewItem( m_SuggestedCommandList,"chgrp ");
29 item = new QListViewItem( m_SuggestedCommandList,"chown "); 29 item = new QListViewItem( m_SuggestedCommandList,"chown ");
30 item = new QListViewItem( m_SuggestedCommandList,"date "); 30 item = new QListViewItem( m_SuggestedCommandList,"date ");
31 item = new QListViewItem( m_SuggestedCommandList,"dd "); 31 item = new QListViewItem( m_SuggestedCommandList,"dd ");
32 item = new QListViewItem( m_SuggestedCommandList,"dmesg "); 32 item = new QListViewItem( m_SuggestedCommandList,"dmesg ");
33 item = new QListViewItem( m_SuggestedCommandList,"fuser "); 33 item = new QListViewItem( m_SuggestedCommandList,"fuser ");
34 item = new QListViewItem( m_SuggestedCommandList,"hostname "); 34 item = new QListViewItem( m_SuggestedCommandList,"hostname ");
35 item = new QListViewItem( m_SuggestedCommandList,"kill "); 35 item = new QListViewItem( m_SuggestedCommandList,"kill ");
36 item = new QListViewItem( m_SuggestedCommandList,"killall "); 36 item = new QListViewItem( m_SuggestedCommandList,"killall ");
37 item = new QListViewItem( m_SuggestedCommandList,"ln "); 37 item = new QListViewItem( m_SuggestedCommandList,"ln ");
38 item = new QListViewItem( m_SuggestedCommandList,"ln -s "); 38 item = new QListViewItem( m_SuggestedCommandList,"ln -s ");
39 item = new QListViewItem( m_SuggestedCommandList,"lsmod"); 39 item = new QListViewItem( m_SuggestedCommandList,"lsmod");
40 item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); 40 item = new QListViewItem( m_SuggestedCommandList,"depmod -a");
41 item = new QListViewItem( m_SuggestedCommandList,"modprobe "); 41 item = new QListViewItem( m_SuggestedCommandList,"modprobe ");
42 item = new QListViewItem( m_SuggestedCommandList,"mount "); 42 item = new QListViewItem( m_SuggestedCommandList,"mount ");
43 item = new QListViewItem( m_SuggestedCommandList,"more "); 43 item = new QListViewItem( m_SuggestedCommandList,"more ");
44 item = new QListViewItem( m_SuggestedCommandList,"sort "); 44 item = new QListViewItem( m_SuggestedCommandList,"sort ");
45 item = new QListViewItem( m_SuggestedCommandList,"touch "); 45 item = new QListViewItem( m_SuggestedCommandList,"touch ");
46 item = new QListViewItem( m_SuggestedCommandList,"umount "); 46 item = new QListViewItem( m_SuggestedCommandList,"umount ");
47 item = new QListViewItem( m_SuggestedCommandList,"mknod "); 47 item = new QListViewItem( m_SuggestedCommandList,"mknod ");
48 item = new QListViewItem( m_SuggestedCommandList,"netstat "); 48 item = new QListViewItem( m_SuggestedCommandList,"netstat ");
49 item = new QListViewItem( m_SuggestedCommandList,"route "); 49 item = new QListViewItem( m_SuggestedCommandList,"route ");
50 item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); 50 item = new QListViewItem( m_SuggestedCommandList,"cardctl eject ");
51 m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); 51 m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE);
52 m_SuggestedCommandList->sort(); 52 m_SuggestedCommandList->sort();
53 53
54 connect( m_SuggestedCommandList, SIGNAL( clicked(QListViewItem*) ), m_PlayListSelection, SLOT( addToSelection(QListViewItem*) ) ); 54 connect( m_SuggestedCommandList, SIGNAL( clicked(QListViewItem*) ), m_PlayListSelection, SLOT( addToSelection(QListViewItem*) ) );
55 55
56 56
57 57
58 ToolButton1->setTextLabel("new"); 58 ToolButton1->setTextLabel("new");
59 ToolButton1->setPixmap(Resource::loadPixmap("new")); 59 ToolButton1->setPixmap(Resource::loadPixmap("new"));
60 ToolButton1->setAutoRaise(TRUE); 60 ToolButton1->setAutoRaise(TRUE);
61 ToolButton1->setFocusPolicy(QWidget::NoFocus); 61 ToolButton1->setFocusPolicy(QWidget::NoFocus);
62 connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); 62 connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog()));
63 63
64 ToolButton2->setTextLabel("edit"); 64 ToolButton2->setTextLabel("edit");
65 ToolButton2->setPixmap(Resource::loadPixmap("edit")); 65 ToolButton2->setPixmap(Resource::loadPixmap("edit"));
66 ToolButton2->setAutoRaise(TRUE); 66 ToolButton2->setAutoRaise(TRUE);
67 ToolButton2->setFocusPolicy(QWidget::NoFocus); 67 ToolButton2->setFocusPolicy(QWidget::NoFocus);
68 connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); 68 connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog()));
69 69
70 ToolButton3->setTextLabel("delete"); 70 ToolButton3->setTextLabel("delete");
71 ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); 71 ToolButton3->setPixmap(Resource::loadPixmap("editdelete"));
72 ToolButton3->setAutoRaise(TRUE); 72 ToolButton3->setAutoRaise(TRUE);
73 ToolButton3->setFocusPolicy(QWidget::NoFocus); 73 ToolButton3->setFocusPolicy(QWidget::NoFocus);
74 connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); 74 connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected()));
75 75
76 ToolButton4->setTextLabel("up"); 76 ToolButton4->setTextLabel("up");
77 ToolButton4->setPixmap(Resource::loadPixmap("up")); 77 ToolButton4->setPixmap(Resource::loadPixmap("up"));
78 ToolButton4->setAutoRaise(TRUE); 78 ToolButton4->setAutoRaise(TRUE);
79 ToolButton4->setFocusPolicy(QWidget::NoFocus); 79 ToolButton4->setFocusPolicy(QWidget::NoFocus);
80 connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); 80 connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp()));
81 81
82 ToolButton5->setTextLabel("down"); 82 ToolButton5->setTextLabel("down");
83 ToolButton5->setPixmap(Resource::loadPixmap("down")); 83 ToolButton5->setPixmap(Resource::loadPixmap("down"));
84 ToolButton5->setAutoRaise(TRUE); 84 ToolButton5->setAutoRaise(TRUE);
85 ToolButton5->setFocusPolicy(QWidget::NoFocus); 85 ToolButton5->setFocusPolicy(QWidget::NoFocus);
86 86
87connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); 87connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown()));
88 88
89 89
90 90
91 91
92 QListViewItem *current = m_SuggestedCommandList->selectedItem(); 92 QListViewItem *current = m_SuggestedCommandList->selectedItem();
93 if ( current ) 93 if ( current )
94 item->moveItem( current ); 94 item->moveItem( current );
95 m_SuggestedCommandList->setSelected( item, TRUE ); 95 m_SuggestedCommandList->setSelected( item, TRUE );
96 m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); 96 m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() );
97 Config cfg( "Konsole" ); 97 Config cfg( "Konsole" );
98 cfg.setGroup("Commands"); 98 cfg.setGroup("Commands");
99 if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { 99 if (cfg.readEntry("Commands Set","FALSE") == "TRUE") {
100 for (int i = 0; i < 100; i++) { 100 for (int i = 0; i < 100; i++) {
101 QString tmp; 101 QString tmp;
102 tmp = cfg.readEntry( QString::number(i),""); 102 tmp = cfg.readEntry( QString::number(i),"");
103 if (!tmp.isEmpty()) 103 if (!tmp.isEmpty())
104 m_PlayListSelection->addStringToSelection(tmp); 104 m_PlayListSelection->addStringToSelection(tmp);
105 } 105 }
106 } else { 106 } else {
107 107
108m_PlayListSelection->addStringToSelection("ls "); 108m_PlayListSelection->addStringToSelection("ls ");
109m_PlayListSelection->addStringToSelection("cardctl eject"); 109m_PlayListSelection->addStringToSelection("cardctl eject");
110m_PlayListSelection->addStringToSelection("cat "); 110m_PlayListSelection->addStringToSelection("cat ");
111m_PlayListSelection->addStringToSelection("cd "); 111m_PlayListSelection->addStringToSelection("cd ");
112m_PlayListSelection->addStringToSelection("chmod "); 112m_PlayListSelection->addStringToSelection("chmod ");
113m_PlayListSelection->addStringToSelection("cp "); 113m_PlayListSelection->addStringToSelection("cp ");
114m_PlayListSelection->addStringToSelection("dc "); 114m_PlayListSelection->addStringToSelection("dc ");
115m_PlayListSelection->addStringToSelection("df "); 115m_PlayListSelection->addStringToSelection("df ");
116m_PlayListSelection->addStringToSelection("dmesg"); 116m_PlayListSelection->addStringToSelection("dmesg");
117m_PlayListSelection->addStringToSelection("echo "); 117m_PlayListSelection->addStringToSelection("echo ");
118m_PlayListSelection->addStringToSelection("env"); 118m_PlayListSelection->addStringToSelection("env");
119m_PlayListSelection->addStringToSelection("find "); 119m_PlayListSelection->addStringToSelection("find ");
120m_PlayListSelection->addStringToSelection("free"); 120m_PlayListSelection->addStringToSelection("free");
121m_PlayListSelection->addStringToSelection("grep "); 121m_PlayListSelection->addStringToSelection("grep ");
122m_PlayListSelection->addStringToSelection("ifconfig "); 122m_PlayListSelection->addStringToSelection("ifconfig ");
123m_PlayListSelection->addStringToSelection("ipkg "); 123m_PlayListSelection->addStringToSelection("ipkg ");
124m_PlayListSelection->addStringToSelection("mkdir "); 124m_PlayListSelection->addStringToSelection("mkdir ");
125m_PlayListSelection->addStringToSelection("mv "); 125m_PlayListSelection->addStringToSelection("mv ");
126m_PlayListSelection->addStringToSelection("nc localhost 7776"); 126m_PlayListSelection->addStringToSelection("nc localhost 7776");
127m_PlayListSelection->addStringToSelection("nc localhost 7777"); 127m_PlayListSelection->addStringToSelection("nc localhost 7777");
128m_PlayListSelection->addStringToSelection("nslookup "); 128m_PlayListSelection->addStringToSelection("nslookup ");
129m_PlayListSelection->addStringToSelection("ping "); 129m_PlayListSelection->addStringToSelection("ping ");
130m_PlayListSelection->addStringToSelection("ps aux"); 130m_PlayListSelection->addStringToSelection("ps aux");
131m_PlayListSelection->addStringToSelection("pwd "); 131m_PlayListSelection->addStringToSelection("pwd ");
132m_PlayListSelection->addStringToSelection("rm "); 132m_PlayListSelection->addStringToSelection("rm ");
133m_PlayListSelection->addStringToSelection("rmdir "); 133m_PlayListSelection->addStringToSelection("rmdir ");
134m_PlayListSelection->addStringToSelection("route "); 134m_PlayListSelection->addStringToSelection("route ");
135m_PlayListSelection->addStringToSelection("set "); 135m_PlayListSelection->addStringToSelection("set ");
136m_PlayListSelection->addStringToSelection("traceroute"); 136m_PlayListSelection->addStringToSelection("traceroute");
137 137
138} 138}
139} 139}
140CommandEditDialog::~CommandEditDialog() 140CommandEditDialog::~CommandEditDialog()
141{ 141{
142} 142}
143 143
144void CommandEditDialog::accept() 144void CommandEditDialog::accept()
145{ 145{
146int i = 0; 146int i = 0;
147 Config *cfg = new Config("Konsole"); 147 Config *cfg = new Config("Konsole");
148 cfg->setGroup("Commands"); 148 cfg->setGroup("Commands");
149 cfg->clearGroup(); 149 cfg->clearGroup();
150 150
151 QListViewItemIterator it( m_PlayListSelection ); 151 QListViewItemIterator it( m_PlayListSelection );
152 152
153 for ( ; it.current(); ++it ) { 153 for ( ; it.current(); ++it ) {
154// qDebug(it.current()->text(0)); 154// odebug << it.current()->text(0) << oendl;
155 cfg->writeEntry(QString::number(i),it.current()->text(0)); 155 cfg->writeEntry(QString::number(i),it.current()->text(0));
156 i++; 156 i++;
157 157
158 } 158 }
159 cfg->writeEntry("Commands Set","TRUE"); 159 cfg->writeEntry("Commands Set","TRUE");
160// qDebug("CommandEditDialog::accept() - written"); 160// odebug << "CommandEditDialog::accept() - written" << oendl;
161 delete cfg; 161 delete cfg;
162 emit commandsEdited(); 162 emit commandsEdited();
163 close(); 163 close();
164 164
165 165
166 166
167 167
168 168
169} 169}
170 170
171void CommandEditDialog::showEditDialog() 171void CommandEditDialog::showEditDialog()
172{ 172{
173editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); 173editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE);
174d->setCaption("Edit command"); 174d->setCaption("Edit command");
175d->TextLabel->setText("Edit command:"); 175d->TextLabel->setText("Edit command:");
176d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); 176d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0));
177int i = d->exec(); 177int i = d->exec();
178if ((i==1) && (!(d->commandEdit->text()).isEmpty())) 178if ((i==1) && (!(d->commandEdit->text()).isEmpty()))
179 m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); 179 m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text()));
180} 180}
181 181
182void CommandEditDialog::showAddDialog() 182void CommandEditDialog::showAddDialog()
183{ 183{
184 184
185editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); 185editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE);
186int i = d->exec(); 186int i = d->exec();
187if ((i==1) && (!(d->commandEdit->text()).isEmpty())) 187if ((i==1) && (!(d->commandEdit->text()).isEmpty()))
188m_PlayListSelection->addStringToSelection(d->commandEdit->text()); 188m_PlayListSelection->addStringToSelection(d->commandEdit->text());
189 189
190} 190}
191 191
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 8207f23..80c8223 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,644 +1,645 @@
1 1
2/* ---------------------------------------------------------------------- */ 2/* ---------------------------------------------------------------------- */
3/* */ 3/* */
4/* [main.C] Konsole */ 4/* [main.C] Konsole */
5/* */ 5/* */
6/* ---------------------------------------------------------------------- */ 6/* ---------------------------------------------------------------------- */
7/* */ 7/* */
8/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 8/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
9/* */ 9/* */
10/* This file is part of Konsole, an X terminal. */ 10/* This file is part of Konsole, an X terminal. */
11/* */ 11/* */
12/* The material contained in here more or less directly orginates from */ 12/* The material contained in here more or less directly orginates from */
13/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 13/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
14/* */ 14/* */
15/* ---------------------------------------------------------------------- */ 15/* ---------------------------------------------------------------------- */
16/* */ 16/* */
17/* Ported Konsole to Qt/Embedded */ 17/* Ported Konsole to Qt/Embedded */
18/* */ 18/* */
19/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 19/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
20/* */ 20/* */
21/* -------------------------------------------------------------------------- */ 21/* -------------------------------------------------------------------------- */
22// enhancements added by L.J. Potter <ljp@llornkcor.com> 22// enhancements added by L.J. Potter <ljp@llornkcor.com>
23// enhancements added by Phillip Kuhn 23// enhancements added by Phillip Kuhn
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26#include <sys/types.h> 26#include <sys/types.h>
27#include <pwd.h> 27#include <pwd.h>
28#include <unistd.h> 28#include <unistd.h>
29 29
30#ifdef QT_QWS_OPIE 30#ifdef QT_QWS_OPIE
31#include <opie2/ocolorpopupmenu.h> 31#include <opie2/ocolorpopupmenu.h>
32#include <opie2/odebug.h>
32using namespace Opie; 33using namespace Opie;
33#endif 34#endif
34 35
35#include <qpe/resource.h> 36#include <qpe/resource.h>
36 37
37#include <qmenubar.h> 38#include <qmenubar.h>
38#include <qtabbar.h> 39#include <qtabbar.h>
39#include <qpe/config.h> 40#include <qpe/config.h>
40#include <qfontdatabase.h> 41#include <qfontdatabase.h>
41#include <qfile.h> 42#include <qfile.h>
42#include <qspinbox.h> 43#include <qspinbox.h>
43#include <qlayout.h> 44#include <qlayout.h>
44 45
45#include <sys/wait.h> 46#include <sys/wait.h>
46#include <stdio.h> 47#include <stdio.h>
47#include <stdlib.h> 48#include <stdlib.h>
48#include <assert.h> 49#include <assert.h>
49 50
50#include "konsole.h" 51#include "konsole.h"
51#include "commandeditdialog.h" 52#include "commandeditdialog.h"
52 53
53class EKNumTabBar : public QTabBar 54class EKNumTabBar : public QTabBar
54{ 55{
55public: 56public:
56 EKNumTabBar(QWidget *parent = 0, const char *name = 0) : 57 EKNumTabBar(QWidget *parent = 0, const char *name = 0) :
57 QTabBar(parent, name) 58 QTabBar(parent, name)
58 {} 59 {}
59 60
60 // QList<QTab> *getTabList() { return(tabList()); } 61 // QList<QTab> *getTabList() { return(tabList()); }
61 62
62 void numberTabs() 63 void numberTabs()
63 { 64 {
64 // Yes, it really is this messy. QTabWidget needs functions 65 // Yes, it really is this messy. QTabWidget needs functions
65 // that provide acces to tabs in a sequential way. 66 // that provide acces to tabs in a sequential way.
66 int m=INT_MIN; 67 int m=INT_MIN;
67 for (int i=0; i<count(); i++) 68 for (int i=0; i<count(); i++)
68 { 69 {
69 QTab* left=0; 70 QTab* left=0;
70 QListIterator<QTab> it(*tabList()); 71 QListIterator<QTab> it(*tabList());
71 int x=INT_MAX; 72 int x=INT_MAX;
72 for( QTab* t; (t=it.current()); ++it ) 73 for( QTab* t; (t=it.current()); ++it )
73 { 74 {
74 int tx = t->rect().x(); 75 int tx = t->rect().x();
75 if ( tx<x && tx>m ) 76 if ( tx<x && tx>m )
76 { 77 {
77 x = tx; 78 x = tx;
78 left = t; 79 left = t;
79 } 80 }
80 } 81 }
81 if ( left ) 82 if ( left )
82 { 83 {
83 left->setText(QString::number(i+1)); 84 left->setText(QString::number(i+1));
84 m = left->rect().x(); 85 m = left->rect().x();
85 } 86 }
86 } 87 }
87 } 88 }
88 89
89 virtual QSize sizeHint() const 90 virtual QSize sizeHint() const
90 { 91 {
91 if (isHidden()) 92 if (isHidden())
92 { 93 {
93 return(QSize(0,0)); 94 return(QSize(0,0));
94 } 95 }
95 else 96 else
96 { 97 {
97 QSize size = QTabBar::sizeHint(); 98 QSize size = QTabBar::sizeHint();
98 int shrink = 5; 99 int shrink = 5;
99 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 100 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
100 { 101 {
101 shrink = 10; 102 shrink = 10;
102 } 103 }
103 size.setHeight(size.height() - shrink); 104 size.setHeight(size.height() - shrink);
104 return(size); 105 return(size);
105 } 106 }
106 } 107 }
107 108
108}; 109};
109 110
110class EKNumTabWidget : public QTabWidget 111class EKNumTabWidget : public QTabWidget
111{ 112{
112public: 113public:
113 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 114 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
114 { 115 {
115 setTabBar(new EKNumTabBar(parent,"EKTabBar")); 116 setTabBar(new EKNumTabBar(parent,"EKTabBar"));
116 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 117 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
117 } 118 }
118 119
119 EKNumTabBar *getTabBar() const 120 EKNumTabBar *getTabBar() const
120 { 121 {
121 return ((EKNumTabBar*)tabBar()); 122 return ((EKNumTabBar*)tabBar());
122 } 123 }
123 124
124 125
125 void addTab(QWidget* w) 126 void addTab(QWidget* w)
126 { 127 {
127 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 128 QTab* t = new QTab(QString::number(tabBar()->count()+1));
128 QTabWidget::addTab(w,t); 129 QTabWidget::addTab(w,t);
129 } 130 }
130 131
131 void removeTab(QWidget* w) 132 void removeTab(QWidget* w)
132 { 133 {
133 removePage(w); 134 removePage(w);
134 ((EKNumTabBar*)tabBar())->numberTabs(); 135 ((EKNumTabBar*)tabBar())->numberTabs();
135 } 136 }
136}; 137};
137 138
138// This could be configurable or dynamicly generated from the bash history 139// This could be configurable or dynamicly generated from the bash history
139// file of the user 140// file of the user
140static const char *commonCmds[] = 141static const char *commonCmds[] =
141 { 142 {
142 "ls ", // I left this here, cause it looks better than the first alpha 143 "ls ", // I left this here, cause it looks better than the first alpha
143 "cardctl eject", 144 "cardctl eject",
144 "cat ", 145 "cat ",
145 "cd ", 146 "cd ",
146 "chmod ", 147 "chmod ",
147 "clear", 148 "clear",
148 "cp ", 149 "cp ",
149 "dc ", 150 "dc ",
150 "df ", 151 "df ",
151 "dmesg", 152 "dmesg",
152 "echo ", 153 "echo ",
153 "env", 154 "env",
154 "find ", 155 "find ",
155 "free", 156 "free",
156 "grep ", 157 "grep ",
157 "ifconfig ", 158 "ifconfig ",
158 "ipkg ", 159 "ipkg ",
159 "mkdir ", 160 "mkdir ",
160 "mv ", 161 "mv ",
161 "nc localhost 7776", 162 "nc localhost 7776",
162 "nc localhost 7777", 163 "nc localhost 7777",
163 "netstat ", 164 "netstat ",
164 "nslookup ", 165 "nslookup ",
165 "ping ", 166 "ping ",
166 "ps aux", 167 "ps aux",
167 "pwd ", 168 "pwd ",
168 "qcop QPE/System 'linkChanged(QString)' ''", 169 "qcop QPE/System 'linkChanged(QString)' ''",
169 "qcop QPE/System 'restart()'", 170 "qcop QPE/System 'restart()'",
170 "qcop QPE/System 'quit()'", 171 "qcop QPE/System 'quit()'",
171 "rm ", 172 "rm ",
172 "rmdir ", 173 "rmdir ",
173 "route ", 174 "route ",
174 "set ", 175 "set ",
175 "traceroute", 176 "traceroute",
176 177
177 /* 178 /*
178 "gzip", 179 "gzip",
179 "gunzip", 180 "gunzip",
180 "chgrp", 181 "chgrp",
181 "chown", 182 "chown",
182 "date", 183 "date",
183 "dd", 184 "dd",
184 "df", 185 "df",
185 "dmesg", 186 "dmesg",
186 "fuser", 187 "fuser",
187 "hostname", 188 "hostname",
188 "kill", 189 "kill",
189 "killall", 190 "killall",
190 "ln", 191 "ln",
191 "ping", 192 "ping",
192 "mount", 193 "mount",
193 "more", 194 "more",
194 "sort", 195 "sort",
195 "touch", 196 "touch",
196 "umount", 197 "umount",
197 "mknod", 198 "mknod",
198 "netstat", 199 "netstat",
199 */ 200 */
200 201
201 "exit", 202 "exit",
202 NULL 203 NULL
203 }; 204 };
204 205
205 206
206static void konsoleInit(const char** shell) { 207static void konsoleInit(const char** shell) {
207 if(setuid(getuid()) !=0) qDebug("setuid failed"); 208 if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl;
208 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges 209 if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges
209 210
210 211
211// QPEApplication::grabKeyboard(); // for CTRL and ALT 212// QPEApplication::grabKeyboard(); // for CTRL and ALT
212 213
213 qDebug("keyboard grabbed"); 214 odebug << "keyboard grabbed" << oendl;
214#ifdef FAKE_CTRL_AND_ALT 215#ifdef FAKE_CTRL_AND_ALT
215 qDebug("Fake Ctrl and Alt defined"); 216 odebug << "Fake Ctrl and Alt defined" << oendl;
216 QPEApplication::grabKeyboard(); // for CTRL and ALT 217 QPEApplication::grabKeyboard(); // for CTRL and ALT
217#endif 218#endif
218 219
219 *shell = getenv("SHELL"); 220 *shell = getenv("SHELL");
220 qWarning("SHell initially is %s", *shell ); 221 owarn << "SHell initially is " << *shell << "" << oendl;
221 222
222 if (shell == NULL || *shell == '\0') { 223 if (shell == NULL || *shell == '\0') {
223 struct passwd *ent = 0; 224 struct passwd *ent = 0;
224 uid_t me = getuid(); 225 uid_t me = getuid();
225 *shell = "/bin/sh"; 226 *shell = "/bin/sh";
226 227
227 while ( (ent = getpwent()) != 0 ) { 228 while ( (ent = getpwent()) != 0 ) {
228 if (ent->pw_uid == me) { 229 if (ent->pw_uid == me) {
229 if (ent->pw_shell != "") 230 if (ent->pw_shell != "")
230 *shell = ent->pw_shell; 231 *shell = ent->pw_shell;
231 break; 232 break;
232 } 233 }
233 } 234 }
234 endpwent(); 235 endpwent();
235 } 236 }
236 237
237 if( putenv((char*)"COLORTERM=") !=0) 238 if( putenv((char*)"COLORTERM=") !=0)
238 qDebug("putenv failed"); // to trigger mc's color detection 239 odebug << "putenv failed" << oendl; // to trigger mc's color detection
239} 240}
240 241
241 242
242Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 243Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
243 QMainWindow(parent, name, fl) 244 QMainWindow(parent, name, fl)
244{ 245{
245 QStrList tmp; const char* shell; 246 QStrList tmp; const char* shell;
246 247
247 konsoleInit( &shell); 248 konsoleInit( &shell);
248 init(shell,tmp); 249 init(shell,tmp);
249} 250}
250 251
251Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 252Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
252 : QMainWindow(0, name) 253 : QMainWindow(0, name)
253{ 254{
254 init(_pgm,_args); 255 init(_pgm,_args);
255} 256}
256 257
257struct HistoryItem 258struct HistoryItem
258{ 259{
259 HistoryItem(int c, const QString &l) 260 HistoryItem(int c, const QString &l)
260 { 261 {
261 count = c; 262 count = c;
262 line = l; 263 line = l;
263 } 264 }
264 int count; 265 int count;
265 QString line; 266 QString line;
266}; 267};
267 268
268class HistoryList : public QList<HistoryItem> 269class HistoryList : public QList<HistoryItem>
269{ 270{
270 virtual int compareItems( QCollection::Item item1, QCollection::Item item2) 271 virtual int compareItems( QCollection::Item item1, QCollection::Item item2)
271 { 272 {
272 int c1 = ((HistoryItem*)item1)->count; 273 int c1 = ((HistoryItem*)item1)->count;
273 int c2 = ((HistoryItem*)item2)->count; 274 int c2 = ((HistoryItem*)item2)->count;
274 if (c1 > c2) 275 if (c1 > c2)
275 return(1); 276 return(1);
276 if (c1 < c2) 277 if (c1 < c2)
277 return(-1); 278 return(-1);
278 return(0); 279 return(0);
279 } 280 }
280}; 281};
281 282
282void Konsole::initCommandList() 283void Konsole::initCommandList()
283{ 284{
284 // qDebug("Konsole::initCommandList"); 285 // odebug << "Konsole::initCommandList" << oendl;
285 Config cfg( "Konsole" ); 286 Config cfg( "Konsole" );
286 cfg.setGroup("Commands"); 287 cfg.setGroup("Commands");
287 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 288 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
288 commonCombo->clear(); 289 commonCombo->clear();
289 290
290 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") 291 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE")
291 { 292 {
292 QString histfilename = QString(getenv("HOME")) + "/.bash_history"; 293 QString histfilename = QString(getenv("HOME")) + "/.bash_history";
293 histfilename = cfg.readEntry("ShellHistoryPath",histfilename); 294 histfilename = cfg.readEntry("ShellHistoryPath",histfilename);
294 QFile histfile(histfilename); 295 QFile histfile(histfilename);
295 // note: compiler barfed on: 296 // note: compiler barfed on:
296 // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); 297 // QFile histfile(QString(getenv("HOME")) + "/.bash_history");
297 if (histfile.open( IO_ReadOnly )) 298 if (histfile.open( IO_ReadOnly ))
298 { 299 {
299 QString line; 300 QString line;
300 uint i; 301 uint i;
301 HistoryList items; 302 HistoryList items;
302 303
303 int lineno = 0; 304 int lineno = 0;
304 while(!histfile.atEnd()) 305 while(!histfile.atEnd())
305 { 306 {
306 if (histfile.readLine(line, 200) < 0) 307 if (histfile.readLine(line, 200) < 0)
307 { 308 {
308 break; 309 break;
309 } 310 }
310 line = line.left(line.length()-1); 311 line = line.left(line.length()-1);
311 lineno++; 312 lineno++;
312 313
313 for(i=0; i<items.count(); i++) 314 for(i=0; i<items.count(); i++)
314 { 315 {
315 if (line == items.at(i)->line) 316 if (line == items.at(i)->line)
316 { 317 {
317 // weight recent commands & repeated commands more 318 // weight recent commands & repeated commands more
318 // by adding up the index of each command 319 // by adding up the index of each command
319 items.at(i)->count += lineno; 320 items.at(i)->count += lineno;
320 break; 321 break;
321 } 322 }
322 } 323 }
323 if (i >= items.count()) 324 if (i >= items.count())
324 { 325 {
325 items.append(new HistoryItem(lineno, line)); 326 items.append(new HistoryItem(lineno, line));
326 } 327 }
327 } 328 }
328 items.sort(); 329 items.sort();
329 int n = items.count(); 330 int n = items.count();
330 if (n > 40) 331 if (n > 40)
331 { 332 {
332 n = 40; 333 n = 40;
333 } 334 }
334 for(int i=0; i<n; i++) 335 for(int i=0; i<n; i++)
335 { 336 {
336 // should insert start of command, but keep whole thing 337 // should insert start of command, but keep whole thing
337 if (items.at(items.count()-i-1)->line.length() < 30) 338 if (items.at(items.count()-i-1)->line.length() < 30)
338 { 339 {
339 commonCombo->insertItem(items.at(items.count()-i-1)->line); 340 commonCombo->insertItem(items.at(items.count()-i-1)->line);
340 } 341 }
341 } 342 }
342 histfile.close(); 343 histfile.close();
343 } 344 }
344 } 345 }
345 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") 346 if (cfg.readEntry("Commands Set","FALSE") == "FALSE")
346 { 347 {
347 for (int i = 0; commonCmds[i] != NULL; i++) 348 for (int i = 0; commonCmds[i] != NULL; i++)
348 { 349 {
349 commonCombo->insertItem(commonCmds[i]); 350 commonCombo->insertItem(commonCmds[i]);
350 } 351 }
351 } 352 }
352 else 353 else
353 { 354 {
354 for (int i = 0; i < 100; i++) 355 for (int i = 0; i < 100; i++)
355 { 356 {
356 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 357 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
357 commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); 358 commonCombo->insertItem(cfg.readEntry( QString::number(i),""));
358 } 359 }
359 } 360 }
360 361
361 362
362} 363}
363 364
364static void sig_handler(int x) 365static void sig_handler(int x)
365{ 366{
366 printf("got signal %d\n",x); 367 printf("got signal %d\n",x);
367} 368}
368 369
369void Konsole::init(const char* _pgm, QStrList & _args) 370void Konsole::init(const char* _pgm, QStrList & _args)
370{ 371{
371 372
372#if 0 373#if 0
373 for(int i=1; i<=31; i++) 374 for(int i=1; i<=31; i++)
374 { 375 {
375 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV 376 if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV
376 && i != SIGINT && i != SIGILL && i != SIGTERM 377 && i != SIGINT && i != SIGILL && i != SIGTERM
377 && i != SIGBUS) 378 && i != SIGBUS)
378 signal(i,sig_handler); 379 signal(i,sig_handler);
379 } 380 }
380#endif 381#endif
381 signal(SIGSTOP, sig_handler); 382 signal(SIGSTOP, sig_handler);
382 signal(SIGCONT, sig_handler); 383 signal(SIGCONT, sig_handler);
383 signal(SIGTSTP, sig_handler); 384 signal(SIGTSTP, sig_handler);
384 385
385 b_scroll = TRUE; // histon; 386 b_scroll = TRUE; // histon;
386 n_keytab = 0; 387 n_keytab = 0;
387 n_render = 0; 388 n_render = 0;
388 startUp=0; 389 startUp=0;
389 fromMenu = FALSE; 390 fromMenu = FALSE;
390 fullscreen = false; 391 fullscreen = false;
391 392
392 setCaption( tr( "Konsole" ) ); 393 setCaption( tr( "Konsole" ) );
393 setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); 394 setIcon( Resource::loadPixmap( "konsole/Terminal" ) );
394 395
395 Config cfg( "Konsole" ); 396 Config cfg( "Konsole" );
396 cfg.setGroup("Font"); 397 cfg.setGroup("Font");
397 QString tmp; 398 QString tmp;
398 399
399 // initialize the list of allowed fonts /////////////////////////////////// 400 // initialize the list of allowed fonts ///////////////////////////////////
400 401
401 QString cfgFontName = cfg.readEntry("FontName","Lcfont"); 402 QString cfgFontName = cfg.readEntry("FontName","Lcfont");
402 int cfgFontSize = cfg.readNumEntry("FontSize",18); 403 int cfgFontSize = cfg.readNumEntry("FontSize",18);
403 404
404 cfont = -1; 405 cfont = -1;
405 406
406 // this code causes repeated access to all the font files 407 // this code causes repeated access to all the font files
407 // which does slow down startup 408 // which does slow down startup
408 QFontDatabase fontDB; 409 QFontDatabase fontDB;
409 QStringList familyNames; 410 QStringList familyNames;
410 familyNames = fontDB.families( FALSE ); 411 familyNames = fontDB.families( FALSE );
411 QString s; 412 QString s;
412 int fontIndex = 0; 413 int fontIndex = 0;
413 int familyNum = 0; 414 int familyNum = 0;
414 fontList = new QPopupMenu( this ); 415 fontList = new QPopupMenu( this );
415 416
416 for(uint j = 0; j < (uint)familyNames.count(); j++) 417 for(uint j = 0; j < (uint)familyNames.count(); j++)
417 { 418 {
418 s = familyNames[j]; 419 s = familyNames[j];
419 if ( s.contains('-') ) 420 if ( s.contains('-') )
420 { 421 {
421 int i = s.find('-'); 422 int i = s.find('-');
422 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; 423 s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]";
423 } 424 }
424 s[0] = s[0].upper(); 425 s[0] = s[0].upper();
425 426
426 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); 427 QValueList<int> sizes = fontDB.pointSizes( familyNames[j] );
427 428
428 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), 429 printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(),
429 sizes.count()); 430 sizes.count());
430 431
431 if (sizes.count() > 0) 432 if (sizes.count() > 0)
432 { 433 {
433 QPopupMenu *sizeMenu; 434 QPopupMenu *sizeMenu;
434 QFont f; 435 QFont f;
435 int last_width = -1; 436 int last_width = -1;
436 sizeMenu = NULL; 437 sizeMenu = NULL;
437 438
438 for(uint i = 0; i < (uint)sizes.count() + 4; i++) 439 for(uint i = 0; i < (uint)sizes.count() + 4; i++)
439 { 440 {
440 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); 441 // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]);
441 // need to divide by 10 on the Z, but not otherwise 442 // need to divide by 10 on the Z, but not otherwise
442 int size; 443 int size;
443 444
444 if (i >= (uint)sizes.count()) 445 if (i >= (uint)sizes.count())
445 { 446 {
446 // try for expandable fonts 447 // try for expandable fonts
447 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); 448 size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1);
448 } 449 }
449 else 450 else
450 { 451 {
451 printf("sizes[%d] = %d\n", i, sizes[i]); 452 printf("sizes[%d] = %d\n", i, sizes[i]);
452 size = sizes[i]; 453 size = sizes[i];
453 } 454 }
454 455
455 f = QFont(familyNames[j], size); 456 f = QFont(familyNames[j], size);
456 f.setFixedPitch(true); 457 f.setFixedPitch(true);
457 QFontMetrics fm(f); 458 QFontMetrics fm(f);
458 // don't trust f.fixedPitch() or f.exactMatch(), they lie!! 459 // don't trust f.fixedPitch() or f.exactMatch(), they lie!!
459 if (fm.width("l") == fm.width("m") 460 if (fm.width("l") == fm.width("m")
460 && (i < (uint)sizes.count() 461 && (i < (uint)sizes.count()
461 || fm.width("m") > last_width)) 462 || fm.width("m") > last_width))
462 { 463 {
463 if (i < (uint)sizes.count()) 464 if (i < (uint)sizes.count())
464 { 465 {
465 last_width = fm.width("m"); 466 last_width = fm.width("m");
466 } 467 }
467 if (sizeMenu == NULL) 468 if (sizeMenu == NULL)
468 { 469 {
469 sizeMenu = new QPopupMenu(); 470 sizeMenu = new QPopupMenu();
470 } 471 }
471 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); 472 int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex);
472 sizeMenu->setItemParameter(id, fontIndex); 473 sizeMenu->setItemParameter(id, fontIndex);
473 sizeMenu->connectItem(id, this, SLOT(setFont(int))); 474 sizeMenu->connectItem(id, this, SLOT(setFont(int)));
474 QString name = s + " " + QString::number(size); 475 QString name = s + " " + QString::number(size);
475 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); 476 fonts.append(new VTFont(name, f, familyNames[j], familyNum, size));
476 if (familyNames[j] == cfgFontName && size == cfgFontSize) 477 if (familyNames[j] == cfgFontName && size == cfgFontSize)
477 { 478 {
478 cfont = fontIndex; 479 cfont = fontIndex;
479 } 480 }
480 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); 481 printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size);
481 fontIndex++; 482 fontIndex++;
482 } 483 }
483 } 484 }
484 if (sizeMenu) 485 if (sizeMenu)
485 { 486 {
486 fontList->insertItem(s, sizeMenu, familyNum + 1000); 487 fontList->insertItem(s, sizeMenu, familyNum + 1000);
487 488
488 familyNum++; 489 familyNum++;
489 } 490 }
490 } 491 }
491 492
492 } 493 }
493 494
494 if (cfont < 0 || cfont >= (int)fonts.count()) 495 if (cfont < 0 || cfont >= (int)fonts.count())
495 { 496 {
496 cfont = 0; 497 cfont = 0;
497 } 498 }
498 499
499 // create terminal emulation framework //////////////////////////////////// 500 // create terminal emulation framework ////////////////////////////////////
500 nsessions = 0; 501 nsessions = 0;
501 502
502 tab = new EKNumTabWidget(this); 503 tab = new EKNumTabWidget(this);
503 // tab->setMargin(tab->margin()-5); 504 // tab->setMargin(tab->margin()-5);
504 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); 505 connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*)));
505 506
506 // create terminal toolbar //////////////////////////////////////////////// 507 // create terminal toolbar ////////////////////////////////////////////////
507 setToolBarsMovable( FALSE ); 508 setToolBarsMovable( FALSE );
508 menuToolBar = new QToolBar( this ); 509 menuToolBar = new QToolBar( this );
509 menuToolBar->setHorizontalStretchable( TRUE ); 510 menuToolBar->setHorizontalStretchable( TRUE );
510 511
511 QMenuBar *menuBar = new QMenuBar( menuToolBar ); 512 QMenuBar *menuBar = new QMenuBar( menuToolBar );
512 513
513 setFont(cfont); 514 setFont(cfont);
514 515
515 configMenu = new QPopupMenu( this); 516 configMenu = new QPopupMenu( this);
516 colorMenu = new QPopupMenu( this); 517 colorMenu = new QPopupMenu( this);
517 scrollMenu = new QPopupMenu( this); 518 scrollMenu = new QPopupMenu( this);
518 editCommandListMenu = new QPopupMenu( this); 519 editCommandListMenu = new QPopupMenu( this);
519 520
520 configMenu->insertItem(tr("Command List"), editCommandListMenu); 521 configMenu->insertItem(tr("Command List"), editCommandListMenu);
521 522
522 bool listHidden; 523 bool listHidden;
523 cfg.setGroup("Menubar"); 524 cfg.setGroup("Menubar");
524 if( cfg.readEntry("Hidden","FALSE") == "TRUE") 525 if( cfg.readEntry("Hidden","FALSE") == "TRUE")
525 { 526 {
526 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); 527 ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" ));
527 listHidden=TRUE; 528 listHidden=TRUE;
528 } 529 }
529 else 530 else
530 { 531 {
531 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); 532 ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" ));
532 listHidden=FALSE; 533 listHidden=FALSE;
533 } 534 }
534 535
535 cfg.setGroup("Tabs"); 536 cfg.setGroup("Tabs");
536 537
537 tabMenu = new QPopupMenu(this); 538 tabMenu = new QPopupMenu(this);
538 tm_bottom = tabMenu->insertItem(tr("Bottom" )); 539 tm_bottom = tabMenu->insertItem(tr("Bottom" ));
539 tm_top = tabMenu->insertItem(tr("Top")); 540 tm_top = tabMenu->insertItem(tr("Top"));
540 tm_hidden = tabMenu->insertItem(tr("Hidden")); 541 tm_hidden = tabMenu->insertItem(tr("Hidden"));
541 542
542 configMenu->insertItem(tr("Tabs"), tabMenu); 543 configMenu->insertItem(tr("Tabs"), tabMenu);
543 544
544 tmp=cfg.readEntry("Position","Top"); 545 tmp=cfg.readEntry("Position","Top");
545 if(tmp=="Top") 546 if(tmp=="Top")
546 { 547 {
547 tab->setTabPosition(QTabWidget::Top); 548 tab->setTabPosition(QTabWidget::Top);
548 tab->getTabBar()->show(); 549 tab->getTabBar()->show();
549 tabPos = tm_top; 550 tabPos = tm_top;
550 } 551 }
551 else if (tmp=="Bottom") 552 else if (tmp=="Bottom")
552 { 553 {
553 tab->setTabPosition(QTabWidget::Bottom); 554 tab->setTabPosition(QTabWidget::Bottom);
554 tab->getTabBar()->show(); 555 tab->getTabBar()->show();
555 tabPos = tm_bottom; 556 tabPos = tm_bottom;
556 } 557 }
557 else 558 else
558 { 559 {
559 tab->getTabBar()->hide(); 560 tab->getTabBar()->hide();
560 tab->setMargin(tab->margin()); 561 tab->setMargin(tab->margin());
561 tabPos = tm_hidden; 562 tabPos = tm_hidden;
562 } 563 }
563 564
564 cm_bw = colorMenu->insertItem(tr( "Black on White")); 565 cm_bw = colorMenu->insertItem(tr( "Black on White"));
565 cm_wb = colorMenu->insertItem(tr( "White on Black")); 566 cm_wb = colorMenu->insertItem(tr( "White on Black"));
566 cm_gb = colorMenu->insertItem(tr( "Green on Black")); 567 cm_gb = colorMenu->insertItem(tr( "Green on Black"));
567 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); 568 // cm_bt = colorMenu->insertItem(tr( "Black on Transparent"));
568 cm_br = colorMenu->insertItem(tr( "Black on Pink")); 569 cm_br = colorMenu->insertItem(tr( "Black on Pink"));
569 cm_rb = colorMenu->insertItem(tr( "Pink on Black")); 570 cm_rb = colorMenu->insertItem(tr( "Pink on Black"));
570 cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); 571 cm_gy = colorMenu->insertItem(tr( "Green on Yellow"));
571 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); 572 cm_bm = colorMenu->insertItem(tr( "Blue on Magenta"));
572 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); 573 cm_mb = colorMenu->insertItem(tr( "Magenta on Blue"));
573 cm_cw = colorMenu->insertItem(tr( "Cyan on White")); 574 cm_cw = colorMenu->insertItem(tr( "Cyan on White"));
574 cm_wc = colorMenu->insertItem(tr( "White on Cyan")); 575 cm_wc = colorMenu->insertItem(tr( "White on Cyan"));
575 cm_bb = colorMenu->insertItem(tr( "Blue on Black")); 576 cm_bb = colorMenu->insertItem(tr( "Blue on Black"));
576 cm_ab = colorMenu->insertItem(tr( "Amber on Black")); 577 cm_ab = colorMenu->insertItem(tr( "Amber on Black"));
577 cm_default = colorMenu->insertItem(tr("default")); 578 cm_default = colorMenu->insertItem(tr("default"));
578 579
579#ifdef QT_QWS_OPIE 580#ifdef QT_QWS_OPIE
580 581
581 colorMenu->insertItem(tr( "Custom")); 582 colorMenu->insertItem(tr( "Custom"));
582#endif 583#endif
583 584
584 configMenu->insertItem(tr( "Colors") ,colorMenu); 585 configMenu->insertItem(tr( "Colors") ,colorMenu);
585 586
586 sessionList = new QPopupMenu(this); 587 sessionList = new QPopupMenu(this);
587 sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, 588 sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this,
588 SLOT(newSession()) ); 589 SLOT(newSession()) );
589 590
590 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 591 // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
591 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 592 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
592 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); 593 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
593 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); 594 connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) ));
594 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); 595 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
595 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); 596 connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
596 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); 597 connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) );
597 598
598 menuBar->insertItem( tr("View"), configMenu ); 599 menuBar->insertItem( tr("View"), configMenu );
599 menuBar->insertItem( tr("Fonts"), fontList ); 600 menuBar->insertItem( tr("Fonts"), fontList );
600 menuBar->insertItem( tr("Sessions"), sessionList ); 601 menuBar->insertItem( tr("Sessions"), sessionList );
601 602
602 toolBar = new QToolBar( this ); 603 toolBar = new QToolBar( this );
603 604
604 QAction *a; 605 QAction *a;
605 606
606 // Button Commands 607 // Button Commands
607 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); 608 a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 );
608 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); 609 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) );
609 a->addTo( toolBar ); 610 a->addTo( toolBar );
610 611
611 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); 612 a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 );
612 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); 613 connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) );
613 a->addTo( toolBar ); 614 a->addTo( toolBar );
614 615
615 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); 616 a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 );
616 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); 617 connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) );
617 a->addTo( toolBar ); 618 a->addTo( toolBar );
618 619
619 620
620 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 621 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
621 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); 622 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar );
622 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 623 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
623 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); 624 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar );
624 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 625 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
625 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); 626 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar );
626 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 627 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
627 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); 628 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar );
628 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 629 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
629 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); 630 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar );
630 631
631 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 632 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
632 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); 633 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) );
633 a->addTo( toolBar ); 634 a->addTo( toolBar );
634 635
635 secondToolBar = new QToolBar( this ); 636 secondToolBar = new QToolBar( this );
636 secondToolBar->setHorizontalStretchable( TRUE ); 637 secondToolBar->setHorizontalStretchable( TRUE );
637 638
638 commonCombo = new QComboBox( secondToolBar ); 639 commonCombo = new QComboBox( secondToolBar );
639 // commonCombo->setMaximumWidth(236); 640 // commonCombo->setMaximumWidth(236);
640 641
641 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); 642 ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) );
642 if( listHidden) 643 if( listHidden)
643 { 644 {
644 secondToolBar->hide(); 645 secondToolBar->hide();
@@ -942,305 +943,305 @@ void Konsole::setFont(int f)
942 } 943 }
943 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); 944 cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily());
944 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); 945 cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize());
945 } 946 }
946} 947}
947 948
948#if 0 949#if 0
949void Konsole::fontChanged(int f) 950void Konsole::fontChanged(int f)
950{ 951{
951 VTFont* font = fonts.at(f); 952 VTFont* font = fonts.at(f);
952 if (font != 0) 953 if (font != 0)
953 { 954 {
954 for(uint i = 0; i < fonts.count(); i++) 955 for(uint i = 0; i < fonts.count(); i++)
955 { 956 {
956 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); 957 fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE);
957 } 958 }
958 959
959 cfont = f; 960 cfont = f;
960 961
961 TEWidget* te = getTe(); 962 TEWidget* te = getTe();
962 if (te != 0) 963 if (te != 0)
963 { 964 {
964 te->setVTFont(font->getFont()); 965 te->setVTFont(font->getFont());
965 } 966 }
966 } 967 }
967} 968}
968#endif 969#endif
969 970
970 971
971void Konsole::enterCommand(int c) 972void Konsole::enterCommand(int c)
972{ 973{
973 TEWidget* te = getTe(); 974 TEWidget* te = getTe();
974 if (te != 0) 975 if (te != 0)
975 { 976 {
976 if(!commonCombo->editable()) 977 if(!commonCombo->editable())
977 { 978 {
978 QString text = commonCombo->text(c); //commonCmds[c]; 979 QString text = commonCombo->text(c); //commonCmds[c];
979 te->emitText(text); 980 te->emitText(text);
980 } 981 }
981 else 982 else
982 { 983 {
983 changeCommand( commonCombo->text(c), c); 984 changeCommand( commonCombo->text(c), c);
984 } 985 }
985 } 986 }
986} 987}
987 988
988void Konsole::hitEnter() 989void Konsole::hitEnter()
989{ 990{
990 TEWidget* te = getTe(); 991 TEWidget* te = getTe();
991 if (te != 0) 992 if (te != 0)
992 { 993 {
993 te->emitText(QString("\r")); 994 te->emitText(QString("\r"));
994 } 995 }
995} 996}
996 997
997void Konsole::hitSpace() 998void Konsole::hitSpace()
998{ 999{
999 TEWidget* te = getTe(); 1000 TEWidget* te = getTe();
1000 if (te != 0) 1001 if (te != 0)
1001 { 1002 {
1002 te->emitText(QString(" ")); 1003 te->emitText(QString(" "));
1003 } 1004 }
1004} 1005}
1005 1006
1006void Konsole::hitTab() 1007void Konsole::hitTab()
1007{ 1008{
1008 TEWidget* te = getTe(); 1009 TEWidget* te = getTe();
1009 if (te != 0) 1010 if (te != 0)
1010 { 1011 {
1011 te->emitText(QString("\t")); 1012 te->emitText(QString("\t"));
1012 } 1013 }
1013} 1014}
1014 1015
1015void Konsole::hitPaste() 1016void Konsole::hitPaste()
1016{ 1017{
1017 TEWidget* te = getTe(); 1018 TEWidget* te = getTe();
1018 if (te != 0) 1019 if (te != 0)
1019 { 1020 {
1020 te->pasteClipboard(); 1021 te->pasteClipboard();
1021 } 1022 }
1022} 1023}
1023 1024
1024void Konsole::hitUp() 1025void Konsole::hitUp()
1025{ 1026{
1026 TEWidget* te = getTe(); 1027 TEWidget* te = getTe();
1027 if (te != 0) 1028 if (te != 0)
1028 { 1029 {
1029 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 1030 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
1030 QApplication::sendEvent( te, &ke ); 1031 QApplication::sendEvent( te, &ke );
1031 } 1032 }
1032} 1033}
1033 1034
1034void Konsole::hitDown() 1035void Konsole::hitDown()
1035{ 1036{
1036 TEWidget* te = getTe(); 1037 TEWidget* te = getTe();
1037 if (te != 0) 1038 if (te != 0)
1038 { 1039 {
1039 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 1040 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
1040 QApplication::sendEvent( te, &ke ); 1041 QApplication::sendEvent( te, &ke );
1041 } 1042 }
1042} 1043}
1043 1044
1044/** 1045/**
1045 This function calculates the size of the external widget 1046 This function calculates the size of the external widget
1046 needed for the internal widget to be 1047 needed for the internal widget to be
1047 */ 1048 */
1048QSize Konsole::calcSize(int columns, int lines) 1049QSize Konsole::calcSize(int columns, int lines)
1049{ 1050{
1050 TEWidget* te = getTe(); 1051 TEWidget* te = getTe();
1051 if (te != 0) 1052 if (te != 0)
1052 { 1053 {
1053 QSize size = te->calcSize(columns, lines); 1054 QSize size = te->calcSize(columns, lines);
1054 return size; 1055 return size;
1055 } 1056 }
1056 else 1057 else
1057 { 1058 {
1058 QSize size; 1059 QSize size;
1059 return size; 1060 return size;
1060 } 1061 }
1061} 1062}
1062 1063
1063/** 1064/**
1064 sets application window to a size based on columns X lines of the te 1065 sets application window to a size based on columns X lines of the te
1065 guest widget. Call with (0,0) for setting default size. 1066 guest widget. Call with (0,0) for setting default size.
1066*/ 1067*/
1067 1068
1068void Konsole::setColLin(int columns, int lines) 1069void Konsole::setColLin(int columns, int lines)
1069{ 1070{
1070 qDebug("konsole::setColLin:: Columns %d", columns); 1071 odebug << "konsole::setColLin:: Columns " << columns << "" << oendl;
1071 1072
1072 if ((columns==0) || (lines==0)) 1073 if ((columns==0) || (lines==0))
1073 { 1074 {
1074 if (defaultSize.isEmpty()) // not in config file : set default value 1075 if (defaultSize.isEmpty()) // not in config file : set default value
1075 { 1076 {
1076 defaultSize = calcSize(80,24); 1077 defaultSize = calcSize(80,24);
1077 // notifySize(24,80); // set menu items (strange arg order !) 1078 // notifySize(24,80); // set menu items (strange arg order !)
1078 } 1079 }
1079 resize(defaultSize); 1080 resize(defaultSize);
1080 } 1081 }
1081 else 1082 else
1082 { 1083 {
1083 resize(calcSize(columns, lines)); 1084 resize(calcSize(columns, lines));
1084 // notifySize(lines,columns); // set menu items (strange arg order !) 1085 // notifySize(lines,columns); // set menu items (strange arg order !)
1085 } 1086 }
1086} 1087}
1087 1088
1088/* 1089/*
1089void Konsole::setFont(int fontno) 1090void Konsole::setFont(int fontno)
1090{ 1091{
1091 QFont f; 1092 QFont f;
1092 if (fontno == 0) 1093 if (fontno == 0)
1093 f = defaultFont = QFont( "Helvetica", 12 ); 1094 f = defaultFont = QFont( "Helvetica", 12 );
1094 else 1095 else
1095 if (fonts[fontno][0] == '-') 1096 if (fonts[fontno][0] == '-')
1096 f.setRawName( fonts[fontno] ); 1097 f.setRawName( fonts[fontno] );
1097 else 1098 else
1098 { 1099 {
1099 f.setFamily(fonts[fontno]); 1100 f.setFamily(fonts[fontno]);
1100 f.setRawMode( TRUE ); 1101 f.setRawMode( TRUE );
1101 } 1102 }
1102 if ( !f.exactMatch() && fontno != 0) 1103 if ( !f.exactMatch() && fontno != 0)
1103 { 1104 {
1104 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 1105 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
1105 QMessageBox(this, msg); 1106 QMessageBox(this, msg);
1106 return; 1107 return;
1107 } 1108 }
1108 if (se) se->setFontNo(fontno); 1109 if (se) se->setFontNo(fontno);
1109 te->setVTFont(f); 1110 te->setVTFont(f);
1110 n_font = fontno; 1111 n_font = fontno;
1111} 1112}
1112*/ 1113*/
1113 1114
1114// --| color selection |------------------------------------------------------- 1115// --| color selection |-------------------------------------------------------
1115 1116
1116void Konsole::changeColumns(int /*columns*/) 1117void Konsole::changeColumns(int /*columns*/)
1117{ //FIXME this seems to cause silliness when reset command is executed 1118{ //FIXME this seems to cause silliness when reset command is executed
1118 // qDebug("change columns"); 1119 // odebug << "change columns" << oendl;
1119 // TEWidget* te = getTe(); 1120 // TEWidget* te = getTe();
1120 // if (te != 0) { 1121 // if (te != 0) {
1121 // setColLin(columns,te->Lines()); 1122 // setColLin(columns,te->Lines());
1122 // te->update(); 1123 // te->update();
1123 // } 1124 // }
1124} 1125}
1125 1126
1126//FIXME: If a child dies during session swap, 1127//FIXME: If a child dies during session swap,
1127// this routine might be called before 1128// this routine might be called before
1128// session swap is completed. 1129// session swap is completed.
1129 1130
1130void Konsole::doneSession(TEWidget* te, int ) 1131void Konsole::doneSession(TEWidget* te, int )
1131{ 1132{
1132 // TEWidget *te = NULL; 1133 // TEWidget *te = NULL;
1133 // if (sess->currentSession == tab->currentPage()) { 1134 // if (sess->currentSession == tab->currentPage()) {
1134 // printf("done current session\n"); 1135 // printf("done current session\n");
1135 // te = getTe(); 1136 // te = getTe();
1136 // } else { 1137 // } else {
1137 // int currentPage = tab->currentPageIndex(); 1138 // int currentPage = tab->currentPageIndex();
1138 // printf("done not current session\n"); 1139 // printf("done not current session\n");
1139 // for(int i = 0; i < nsessions; i++) { 1140 // for(int i = 0; i < nsessions; i++) {
1140 // tab->setCurrentPage(i); 1141 // tab->setCurrentPage(i);
1141 // printf("find session %d tab page %x session %x\n", 1142 // printf("find session %d tab page %x session %x\n",
1142 // i, tab->currentPage(), sess->currentSession); 1143 // i, tab->currentPage(), sess->currentSession);
1143 // if (tab->currentPage() == sess->currentSession) { 1144 // if (tab->currentPage() == sess->currentSession) {
1144 // printf("found session %d\n", i); 1145 // printf("found session %d\n", i);
1145 // te = tab->currentPage(); 1146 // te = tab->currentPage();
1146 // break; 1147 // break;
1147 // } 1148 // }
1148 // } 1149 // }
1149 // tab->setCurrentPage(currentPage); 1150 // tab->setCurrentPage(currentPage);
1150 // } 1151 // }
1151 if (te != 0) 1152 if (te != 0)
1152 { 1153 {
1153 te->currentSession->setConnect(FALSE); 1154 te->currentSession->setConnect(FALSE);
1154 tab->removeTab(te); 1155 tab->removeTab(te);
1155 delete te->currentSession; 1156 delete te->currentSession;
1156 delete te; 1157 delete te;
1157 sessionList->removeItem(nsessions); 1158 sessionList->removeItem(nsessions);
1158 nsessions--; 1159 nsessions--;
1159 } 1160 }
1160 if (nsessions == 0) 1161 if (nsessions == 0)
1161 { 1162 {
1162 close(); 1163 close();
1163 } 1164 }
1164} 1165}
1165 1166
1166void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) 1167void Konsole::changeTitle(TEWidget* te, const QString& newTitle )
1167{ 1168{
1168 if (te == getTe()) 1169 if (te == getTe())
1169 { 1170 {
1170 setCaption( newTitle + " - " + tr( "Konsole " ) ); 1171 setCaption( newTitle + " - " + tr( "Konsole " ) );
1171 } 1172 }
1172} 1173}
1173 1174
1174 1175
1175void Konsole::newSession() 1176void Konsole::newSession()
1176{ 1177{
1177 if(nsessions < 15) 1178 if(nsessions < 15)
1178 { // seems to be something weird about 16 tabs on the Zaurus.... memory? 1179 { // seems to be something weird about 16 tabs on the Zaurus.... memory?
1179 TEWidget* te = new TEWidget(tab); 1180 TEWidget* te = new TEWidget(tab);
1180 Config cfg( "Konsole" ); 1181 Config cfg( "Konsole" );
1181 cfg.setGroup("Menubar"); 1182 cfg.setGroup("Menubar");
1182 1183
1183 // FIXME use more defaults from config file 1184 // FIXME use more defaults from config file
1184 te->useBeep=cfg.readBoolEntry("useBeep",0); 1185 te->useBeep=cfg.readBoolEntry("useBeep",0);
1185 1186
1186 // te->setBackgroundMode(PaletteBase); //we want transparent!! 1187 // te->setBackgroundMode(PaletteBase); //we want transparent!!
1187 1188
1188 cfg.setGroup("Font"); 1189 cfg.setGroup("Font");
1189 QString sn = "Session" + QString::number(nsessions+1); 1190 QString sn = "Session" + QString::number(nsessions+1);
1190 printf("read font session %s\n", sn.latin1()); 1191 printf("read font session %s\n", sn.latin1());
1191 QString fontName = cfg.readEntry("FontName"+sn, 1192 QString fontName = cfg.readEntry("FontName"+sn,
1192 cfg.readEntry("FontName", 1193 cfg.readEntry("FontName",
1193 fonts.at(cfont)->getFamily())); 1194 fonts.at(cfont)->getFamily()));
1194 int fontSize = cfg.readNumEntry("FontSize"+sn, 1195 int fontSize = cfg.readNumEntry("FontSize"+sn,
1195 cfg.readNumEntry("FontSize", 1196 cfg.readNumEntry("FontSize",
1196 fonts.at(cfont)->getSize())); 1197 fonts.at(cfont)->getSize()));
1197 cfont = findFont(fontName, fontSize, false); 1198 cfont = findFont(fontName, fontSize, false);
1198 printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); 1199 printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont);
1199 if (cfont < 0) 1200 if (cfont < 0)
1200 cfont = 0; 1201 cfont = 0;
1201 te->setVTFont(fonts.at(cfont)->getFont()); 1202 te->setVTFont(fonts.at(cfont)->getFont());
1202 1203
1203 tab->addTab(te); 1204 tab->addTab(te);
1204 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 1205 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
1205 te->currentSession = se; 1206 te->currentSession = se;
1206 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); 1207 connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) );
1207 connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, 1208 connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this,
1208 SLOT(changeTitle(TEWidget*,const QString&)) ); 1209 SLOT(changeTitle(TEWidget*,const QString&)) );
1209 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); 1210 connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int)));
1210 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); 1211 connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int)));
1211 connect(te, SIGNAL(newSession()), this, SLOT(newSession())); 1212 connect(te, SIGNAL(newSession()), this, SLOT(newSession()));
1212 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); 1213 connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen()));
1213 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); 1214 connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool)));
1214 se->run(); 1215 se->run();
1215 se->setConnect(TRUE); 1216 se->setConnect(TRUE);
1216 se->setHistory(b_scroll); 1217 se->setHistory(b_scroll);
1217 nsessions++; 1218 nsessions++;
1218 sessionList->insertItem(QString::number(nsessions), nsessions); 1219 sessionList->insertItem(QString::number(nsessions), nsessions);
1219 sessionListSelected(nsessions); 1220 sessionListSelected(nsessions);
1220 doWrap(); 1221 doWrap();
1221 setColor(nsessions-1); 1222 setColor(nsessions-1);
1222 } 1223 }
1223} 1224}
1224 1225
1225TEWidget* Konsole::getTe() 1226TEWidget* Konsole::getTe()
1226{ 1227{
1227 if (nsessions) 1228 if (nsessions)
1228 { 1229 {
1229 return (TEWidget *) tab->currentPage(); 1230 return (TEWidget *) tab->currentPage();
1230 } 1231 }
1231 else 1232 else
1232 { 1233 {
1233 return 0; 1234 return 0;
1234 } 1235 }
1235} 1236}
1236 1237
1237void Konsole::sessionListSelected(int id) 1238void Konsole::sessionListSelected(int id)
1238{ 1239{
1239 if (id < 0) 1240 if (id < 0)
1240 { 1241 {
1241 return; 1242 return;
1242 } 1243 }
1243 QString selected = sessionList->text(id); 1244 QString selected = sessionList->text(id);
1244 EKNumTabBar *tabBar = tab->getTabBar(); 1245 EKNumTabBar *tabBar = tab->getTabBar();
1245 1246
1246 int n = 0; 1247 int n = 0;
@@ -1288,636 +1289,636 @@ void Konsole::changeSession(int delta)
1288 n++; 1289 n++;
1289 } 1290 }
1290 } 1291 }
1291} 1292}
1292 1293
1293void Konsole::switchSession(QWidget* w) 1294void Konsole::switchSession(QWidget* w)
1294{ 1295{
1295 TEWidget* te = (TEWidget *) w; 1296 TEWidget* te = (TEWidget *) w;
1296 QFont teFnt = te->getVTFont(); 1297 QFont teFnt = te->getVTFont();
1297 int familyNum = -1; 1298 int familyNum = -1;
1298 1299
1299 for(uint i = 0; i < fonts.count(); i++) 1300 for(uint i = 0; i < fonts.count(); i++)
1300 { 1301 {
1301 VTFont *fnt = fonts.at(i); 1302 VTFont *fnt = fonts.at(i);
1302 bool cf = fnt->getFont() == teFnt; 1303 bool cf = fnt->getFont() == teFnt;
1303 fontList->setItemChecked(i, cf); 1304 fontList->setItemChecked(i, cf);
1304 if (cf) 1305 if (cf)
1305 { 1306 {
1306 cfont = i; 1307 cfont = i;
1307 familyNum = fnt->getFamilyNum(); 1308 familyNum = fnt->getFamilyNum();
1308 } 1309 }
1309 } 1310 }
1310 for(int i = 0; i < (int)fontList->count(); i++) 1311 for(int i = 0; i < (int)fontList->count(); i++)
1311 { 1312 {
1312 fontList->setItemChecked(i + 1000, i == familyNum); 1313 fontList->setItemChecked(i + 1000, i == familyNum);
1313 } 1314 }
1314 if (! te->currentSession->Title().isEmpty() ) 1315 if (! te->currentSession->Title().isEmpty() )
1315 { 1316 {
1316 setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); 1317 setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) );
1317 } 1318 }
1318 else 1319 else
1319 { 1320 {
1320 setCaption( tr( "Konsole" ) ); 1321 setCaption( tr( "Konsole" ) );
1321 } 1322 }
1322 // colorMenuSelected(te->color_menu_item); 1323 // colorMenuSelected(te->color_menu_item);
1323} 1324}
1324 1325
1325 1326
1326void Konsole::toggleFullScreen() 1327void Konsole::toggleFullScreen()
1327{ 1328{
1328 setFullScreen(! fullscreen); 1329 setFullScreen(! fullscreen);
1329} 1330}
1330 1331
1331void Konsole::setFullScreen ( bool b ) 1332void Konsole::setFullScreen ( bool b )
1332{ 1333{
1333 static QSize normalsize; 1334 static QSize normalsize;
1334 static bool listHidden; 1335 static bool listHidden;
1335 1336
1336 if (b == fullscreen) 1337 if (b == fullscreen)
1337 { 1338 {
1338 return; 1339 return;
1339 } 1340 }
1340 1341
1341 fullscreen = b; 1342 fullscreen = b;
1342 1343
1343 if ( b ) 1344 if ( b )
1344 { 1345 {
1345 if ( !normalsize. isValid ( )) 1346 if ( !normalsize. isValid ( ))
1346 { 1347 {
1347 normalsize = size ( ); 1348 normalsize = size ( );
1348 } 1349 }
1349 1350
1350 setFixedSize ( qApp-> desktop ( )-> size ( )); 1351 setFixedSize ( qApp-> desktop ( )-> size ( ));
1351 showNormal ( ); 1352 showNormal ( );
1352 reparent ( 0, WStyle_Customize | WStyle_NoBorder, 1353 reparent ( 0, WStyle_Customize | WStyle_NoBorder,
1353 QPoint ( 0, 0 )); 1354 QPoint ( 0, 0 ));
1354 showFullScreen ( ); 1355 showFullScreen ( );
1355 1356
1356 menuToolBar->hide(); 1357 menuToolBar->hide();
1357 toolBar->hide(); 1358 toolBar->hide();
1358 listHidden = secondToolBar->isHidden(); 1359 listHidden = secondToolBar->isHidden();
1359 secondToolBar->hide(); 1360 secondToolBar->hide();
1360 // commonCombo->hide(); 1361 // commonCombo->hide();
1361 tab->getTabBar()->hide(); 1362 tab->getTabBar()->hide();
1362 tab->setMargin(tab->margin()); 1363 tab->setMargin(tab->margin());
1363 1364
1364 if (show_fullscreen_msg) 1365 if (show_fullscreen_msg)
1365 { 1366 {
1366 fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, 1367 fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2,
1367 qApp->desktop()->height()/16 - fullscreen_msg->height()/2); 1368 qApp->desktop()->height()/16 - fullscreen_msg->height()/2);
1368 fullscreen_msg->show(); 1369 fullscreen_msg->show();
1369 fullscreen_timer->start(3000, true); 1370 fullscreen_timer->start(3000, true);
1370 show_fullscreen_msg = false; 1371 show_fullscreen_msg = false;
1371 } 1372 }
1372 } 1373 }
1373 else 1374 else
1374 { 1375 {
1375 showNormal ( ); 1376 showNormal ( );
1376 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); 1377 reparent ( 0, WStyle_Customize, QPoint ( 0, 0 ));
1377 resize ( normalsize ); 1378 resize ( normalsize );
1378 showMaximized ( ); 1379 showMaximized ( );
1379 normalsize = QSize ( ); 1380 normalsize = QSize ( );
1380 1381
1381 menuToolBar->show(); 1382 menuToolBar->show();
1382 toolBar->show(); 1383 toolBar->show();
1383 if(! listHidden) 1384 if(! listHidden)
1384 { 1385 {
1385 secondToolBar->show(); 1386 secondToolBar->show();
1386 } 1387 }
1387 // commonCombo->show(); 1388 // commonCombo->show();
1388 menuToolBar->show(); 1389 menuToolBar->show();
1389 if (tabPos != tm_hidden) 1390 if (tabPos != tm_hidden)
1390 { 1391 {
1391 tab->getTabBar()->show(); 1392 tab->getTabBar()->show();
1392 } 1393 }
1393 } 1394 }
1394 tab->setMargin(tab->margin()); // cause setup to run 1395 tab->setMargin(tab->margin()); // cause setup to run
1395} 1396}
1396 1397
1397 1398
1398void Konsole::fullscreenTimeout() 1399void Konsole::fullscreenTimeout()
1399{ 1400{
1400 fullscreen_msg->hide(); 1401 fullscreen_msg->hide();
1401} 1402}
1402 1403
1403void Konsole::colorMenuIsSelected(int iD) 1404void Konsole::colorMenuIsSelected(int iD)
1404{ 1405{
1405 fromMenu = TRUE; 1406 fromMenu = TRUE;
1406 colorMenuSelected(iD); 1407 colorMenuSelected(iD);
1407} 1408}
1408 1409
1409/// ------------------------------- some new stuff by L.J. Potter 1410/// ------------------------------- some new stuff by L.J. Potter
1410 1411
1411 1412
1412void Konsole::colorMenuSelected(int iD) 1413void Konsole::colorMenuSelected(int iD)
1413{ 1414{
1414 // this is NOT pretty, elegant or anything else besides functional 1415 // this is NOT pretty, elegant or anything else besides functional
1415 // QString temp; 1416 // QString temp;
1416 // qDebug( temp.sprintf("colormenu %d", iD)); 1417 // odebug << temp.sprintf("colormenu " << iD) << "" << oendl;
1417 1418
1418 TEWidget* te = getTe(); 1419 TEWidget* te = getTe();
1419 Config cfg( "Konsole" ); 1420 Config cfg( "Konsole" );
1420 cfg.setGroup("Colors"); 1421 cfg.setGroup("Colors");
1421 1422
1422 ColorEntry m_table[TABLE_COLORS]; 1423 ColorEntry m_table[TABLE_COLORS];
1423 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1424 const ColorEntry * defaultCt=te->getdefaultColorTable();
1424 1425
1425 int i; 1426 int i;
1426 1427
1427 // te->color_menu_item = iD; 1428 // te->color_menu_item = iD;
1428 1429
1429 colorMenu->setItemChecked(cm_ab,FALSE); 1430 colorMenu->setItemChecked(cm_ab,FALSE);
1430 colorMenu->setItemChecked(cm_bb,FALSE); 1431 colorMenu->setItemChecked(cm_bb,FALSE);
1431 colorMenu->setItemChecked(cm_wc,FALSE); 1432 colorMenu->setItemChecked(cm_wc,FALSE);
1432 colorMenu->setItemChecked(cm_cw,FALSE); 1433 colorMenu->setItemChecked(cm_cw,FALSE);
1433 colorMenu->setItemChecked(cm_mb,FALSE); 1434 colorMenu->setItemChecked(cm_mb,FALSE);
1434 colorMenu->setItemChecked(cm_bm,FALSE); 1435 colorMenu->setItemChecked(cm_bm,FALSE);
1435 colorMenu->setItemChecked(cm_gy,FALSE); 1436 colorMenu->setItemChecked(cm_gy,FALSE);
1436 colorMenu->setItemChecked(cm_rb,FALSE); 1437 colorMenu->setItemChecked(cm_rb,FALSE);
1437 colorMenu->setItemChecked(cm_br,FALSE); 1438 colorMenu->setItemChecked(cm_br,FALSE);
1438 colorMenu->setItemChecked(cm_wb,FALSE); 1439 colorMenu->setItemChecked(cm_wb,FALSE);
1439 colorMenu->setItemChecked(cm_bw,FALSE); 1440 colorMenu->setItemChecked(cm_bw,FALSE);
1440 colorMenu->setItemChecked(cm_gb,FALSE); 1441 colorMenu->setItemChecked(cm_gb,FALSE);
1441 1442
1442 if(iD==cm_default) 1443 if(iD==cm_default)
1443 { // default default 1444 { // default default
1444 printf("default colors\n"); 1445 printf("default colors\n");
1445 for (i = 0; i < TABLE_COLORS; i++) 1446 for (i = 0; i < TABLE_COLORS; i++)
1446 { 1447 {
1447 m_table[i].color = defaultCt[i].color; 1448 m_table[i].color = defaultCt[i].color;
1448 if(i==1 || i == 11) 1449 if(i==1 || i == 11)
1449 m_table[i].transparent=1; 1450 m_table[i].transparent=1;
1450 colorMenu->setItemChecked(cm_default,TRUE); 1451 colorMenu->setItemChecked(cm_default,TRUE);
1451 } 1452 }
1452 te->setColorTable(m_table); 1453 te->setColorTable(m_table);
1453 } 1454 }
1454 if(iD==cm_gb) 1455 if(iD==cm_gb)
1455 { // green black 1456 { // green black
1456 foreground.setRgb(100,255,100); // (0x18,255,0x18); 1457 foreground.setRgb(100,255,100); // (0x18,255,0x18);
1457 background.setRgb(0x00,0x00,0x00); 1458 background.setRgb(0x00,0x00,0x00);
1458 colorMenu->setItemChecked(cm_gb,TRUE); 1459 colorMenu->setItemChecked(cm_gb,TRUE);
1459 } 1460 }
1460 if(iD==cm_bw) 1461 if(iD==cm_bw)
1461 { // black white 1462 { // black white
1462 foreground.setRgb(0x00,0x00,0x00); 1463 foreground.setRgb(0x00,0x00,0x00);
1463 background.setRgb(0xFF,0xFF,0xFF); 1464 background.setRgb(0xFF,0xFF,0xFF);
1464 colorMenu->setItemChecked(cm_bw,TRUE); 1465 colorMenu->setItemChecked(cm_bw,TRUE);
1465 } 1466 }
1466 if(iD==cm_wb) 1467 if(iD==cm_wb)
1467 { // white black 1468 { // white black
1468 foreground.setRgb(0xFF,0xFF,0xFF); 1469 foreground.setRgb(0xFF,0xFF,0xFF);
1469 background.setRgb(0x00,0x00,0x00); 1470 background.setRgb(0x00,0x00,0x00);
1470 colorMenu->setItemChecked(cm_wb,TRUE); 1471 colorMenu->setItemChecked(cm_wb,TRUE);
1471 } 1472 }
1472 if(iD==cm_br) 1473 if(iD==cm_br)
1473 {// Black, Red 1474 {// Black, Red
1474 foreground.setRgb(0x00,0x00,0x00); 1475 foreground.setRgb(0x00,0x00,0x00);
1475 background.setRgb(255,85,85); //(0xB2,0x18,0x18); 1476 background.setRgb(255,85,85); //(0xB2,0x18,0x18);
1476 colorMenu->setItemChecked(cm_br,TRUE); 1477 colorMenu->setItemChecked(cm_br,TRUE);
1477 } 1478 }
1478 if(iD==cm_rb) 1479 if(iD==cm_rb)
1479 {// Red, Black 1480 {// Red, Black
1480 foreground.setRgb(255,85,85); 1481 foreground.setRgb(255,85,85);
1481 background.setRgb(0x00,0x00,0x00); 1482 background.setRgb(0x00,0x00,0x00);
1482 colorMenu->setItemChecked(cm_rb,TRUE); 1483 colorMenu->setItemChecked(cm_rb,TRUE);
1483 } 1484 }
1484 if(iD==cm_gy) 1485 if(iD==cm_gy)
1485 {// Green, Yellow - is ugly 1486 {// Green, Yellow - is ugly
1486 // foreground.setRgb(0x18,0xB2,0x18); 1487 // foreground.setRgb(0x18,0xB2,0x18);
1487 foreground.setRgb(15,115,0); 1488 foreground.setRgb(15,115,0);
1488 // background.setRgb(0xB2,0x68,0x18); 1489 // background.setRgb(0xB2,0x68,0x18);
1489 background.setRgb(255,255,0); 1490 background.setRgb(255,255,0);
1490 colorMenu->setItemChecked(cm_gy,TRUE); 1491 colorMenu->setItemChecked(cm_gy,TRUE);
1491 } 1492 }
1492 if(iD==cm_bm) 1493 if(iD==cm_bm)
1493 {// Blue, Magenta 1494 {// Blue, Magenta
1494 foreground.setRgb(3,24,132); 1495 foreground.setRgb(3,24,132);
1495 background.setRgb(225,2,255); 1496 background.setRgb(225,2,255);
1496 colorMenu->setItemChecked(cm_bm,TRUE); 1497 colorMenu->setItemChecked(cm_bm,TRUE);
1497 } 1498 }
1498 if(iD==cm_mb) 1499 if(iD==cm_mb)
1499 {// Magenta, Blue 1500 {// Magenta, Blue
1500 foreground.setRgb(225,2,255); 1501 foreground.setRgb(225,2,255);
1501 background.setRgb(3,24,132); 1502 background.setRgb(3,24,132);
1502 colorMenu->setItemChecked(cm_mb,TRUE); 1503 colorMenu->setItemChecked(cm_mb,TRUE);
1503 } 1504 }
1504 if(iD==cm_cw) 1505 if(iD==cm_cw)
1505 {// Cyan, White 1506 {// Cyan, White
1506 foreground.setRgb(8,91,129); 1507 foreground.setRgb(8,91,129);
1507 background.setRgb(0xFF,0xFF,0xFF); 1508 background.setRgb(0xFF,0xFF,0xFF);
1508 colorMenu->setItemChecked(cm_cw,TRUE); 1509 colorMenu->setItemChecked(cm_cw,TRUE);
1509 } 1510 }
1510 if(iD==cm_wc) 1511 if(iD==cm_wc)
1511 {// White, Cyan 1512 {// White, Cyan
1512 background.setRgb(8,91,129); 1513 background.setRgb(8,91,129);
1513 foreground.setRgb(0xFF,0xFF,0xFF); 1514 foreground.setRgb(0xFF,0xFF,0xFF);
1514 colorMenu->setItemChecked(cm_wc,TRUE); 1515 colorMenu->setItemChecked(cm_wc,TRUE);
1515 } 1516 }
1516 if(iD==cm_bb) 1517 if(iD==cm_bb)
1517 {// Black, Blue 1518 {// Black, Blue
1518 background.setRgb(0x00,0x00,0x00); 1519 background.setRgb(0x00,0x00,0x00);
1519 foreground.setRgb(127,147,225); 1520 foreground.setRgb(127,147,225);
1520 colorMenu->setItemChecked(cm_bb,TRUE); 1521 colorMenu->setItemChecked(cm_bb,TRUE);
1521 } 1522 }
1522 if(iD==cm_ab) 1523 if(iD==cm_ab)
1523 {// Black, Gold 1524 {// Black, Gold
1524 background.setRgb(0x00,0x00,0x00); 1525 background.setRgb(0x00,0x00,0x00);
1525 foreground.setRgb(255,215,105); 1526 foreground.setRgb(255,215,105);
1526 colorMenu->setItemChecked(cm_ab,TRUE); 1527 colorMenu->setItemChecked(cm_ab,TRUE);
1527 } 1528 }
1528#ifdef QT_QWS_OPIE 1529#ifdef QT_QWS_OPIE
1529 if(iD==-19) 1530 if(iD==-19)
1530 { 1531 {
1531 // Custom 1532 // Custom
1532 qDebug("do custom"); 1533 odebug << "do custom" << oendl;
1533 if(fromMenu) 1534 if(fromMenu)
1534 { 1535 {
1535 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); 1536 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color");
1536 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, 1537 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
1537 SLOT(changeForegroundColor(const QColor&))); 1538 SLOT(changeForegroundColor(const QColor&)));
1538 penColorPopupMenu->exec(); 1539 penColorPopupMenu->exec();
1539 } 1540 }
1540 if(!fromMenu) 1541 if(!fromMenu)
1541 { 1542 {
1542 foreground.setNamedColor(cfg.readEntry("foreground","")); 1543 foreground.setNamedColor(cfg.readEntry("foreground",""));
1543 background.setNamedColor(cfg.readEntry("background","")); 1544 background.setNamedColor(cfg.readEntry("background",""));
1544 } 1545 }
1545 fromMenu=FALSE; 1546 fromMenu=FALSE;
1546 colorMenu->setItemChecked(-19,TRUE); 1547 colorMenu->setItemChecked(-19,TRUE);
1547 } 1548 }
1548#endif 1549#endif
1549 1550
1550 lastSelectedMenu = iD; 1551 lastSelectedMenu = iD;
1551 1552
1552 setColors(foreground, background); 1553 setColors(foreground, background);
1553 1554
1554 QTabBar *tabBar = tab->getTabBar(); 1555 QTabBar *tabBar = tab->getTabBar();
1555 QString ss = QString("Session%1").arg(tabBar->currentTab()); 1556 QString ss = QString("Session%1").arg(tabBar->currentTab());
1556 // printf("current tab = %d\n", tabBar->currentTab()); 1557 // printf("current tab = %d\n", tabBar->currentTab());
1557 1558
1558 if (tabBar->currentTab() == 0) 1559 if (tabBar->currentTab() == 0)
1559 { 1560 {
1560 cfg.writeEntry("foregroundRed",QString::number(foreground.red())); 1561 cfg.writeEntry("foregroundRed",QString::number(foreground.red()));
1561 cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); 1562 cfg.writeEntry("foregroundGreen",QString::number(foreground.green()));
1562 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); 1563 cfg.writeEntry("foregroundBlue",QString::number(foreground.blue()));
1563 cfg.writeEntry("backgroundRed",QString::number(background.red())); 1564 cfg.writeEntry("backgroundRed",QString::number(background.red()));
1564 cfg.writeEntry("backgroundGreen",QString::number(background.green())); 1565 cfg.writeEntry("backgroundGreen",QString::number(background.green()));
1565 cfg.writeEntry("backgroundBlue",QString::number(background.blue())); 1566 cfg.writeEntry("backgroundBlue",QString::number(background.blue()));
1566 } 1567 }
1567 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); 1568 cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red()));
1568 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); 1569 cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green()));
1569 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); 1570 cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue()));
1570 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); 1571 cfg.writeEntry("backgroundRed"+ss,QString::number(background.red()));
1571 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); 1572 cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green()));
1572 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); 1573 cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue()));
1573 1574
1574 update(); 1575 update();
1575} 1576}
1576 1577
1577void Konsole::setColors(QColor foreground, QColor background) 1578void Konsole::setColors(QColor foreground, QColor background)
1578{ 1579{
1579 int i; 1580 int i;
1580 ColorEntry m_table[TABLE_COLORS]; 1581 ColorEntry m_table[TABLE_COLORS];
1581 TEWidget* te = getTe(); 1582 TEWidget* te = getTe();
1582 const ColorEntry * defaultCt=te->getdefaultColorTable(); 1583 const ColorEntry * defaultCt=te->getdefaultColorTable();
1583 1584
1584 for (i = 0; i < TABLE_COLORS; i++) 1585 for (i = 0; i < TABLE_COLORS; i++)
1585 { 1586 {
1586 if(i==0 || i == 10) 1587 if(i==0 || i == 10)
1587 { 1588 {
1588 m_table[i].color = foreground; 1589 m_table[i].color = foreground;
1589 } 1590 }
1590 else if(i==1 || i == 11) 1591 else if(i==1 || i == 11)
1591 { 1592 {
1592 m_table[i].color = background; 1593 m_table[i].color = background;
1593 m_table[i].transparent=0; 1594 m_table[i].transparent=0;
1594 } 1595 }
1595 else 1596 else
1596 m_table[i].color = defaultCt[i].color; 1597 m_table[i].color = defaultCt[i].color;
1597 } 1598 }
1598 te->setColorTable(m_table); 1599 te->setColorTable(m_table);
1599} 1600}
1600 1601
1601void Konsole::tabMenuSelected(int id) 1602void Konsole::tabMenuSelected(int id)
1602{ 1603{
1603 Config cfg( "Konsole" ); 1604 Config cfg( "Konsole" );
1604 cfg.setGroup("Tabs"); 1605 cfg.setGroup("Tabs");
1605 tabMenu->setItemChecked(tabPos, false); 1606 tabMenu->setItemChecked(tabPos, false);
1606 if (id == tm_bottom) 1607 if (id == tm_bottom)
1607 { 1608 {
1608 printf("set bottom tab\n"); 1609 printf("set bottom tab\n");
1609 tab->getTabBar()->show(); 1610 tab->getTabBar()->show();
1610 tab->setTabPosition(QTabWidget::Bottom); 1611 tab->setTabPosition(QTabWidget::Bottom);
1611 tab->getTabBar()->show(); 1612 tab->getTabBar()->show();
1612 cfg.writeEntry("Position","Bottom"); 1613 cfg.writeEntry("Position","Bottom");
1613 } 1614 }
1614 else if (id == tm_top) 1615 else if (id == tm_top)
1615 { 1616 {
1616 printf("set top tab\n"); 1617 printf("set top tab\n");
1617 tab->getTabBar()->show(); 1618 tab->getTabBar()->show();
1618 tab->setTabPosition(QTabWidget::Bottom); 1619 tab->setTabPosition(QTabWidget::Bottom);
1619 tab->setTabPosition(QTabWidget::Top); 1620 tab->setTabPosition(QTabWidget::Top);
1620 tab->getTabBar()->show(); 1621 tab->getTabBar()->show();
1621 cfg.writeEntry("Position","Top"); 1622 cfg.writeEntry("Position","Top");
1622 } 1623 }
1623 else if (id == tm_hidden) 1624 else if (id == tm_hidden)
1624 { 1625 {
1625 tab->getTabBar()->hide(); 1626 tab->getTabBar()->hide();
1626 tab->setMargin(tab->margin()); 1627 tab->setMargin(tab->margin());
1627 cfg.writeEntry("Position","Hidden"); 1628 cfg.writeEntry("Position","Hidden");
1628 } 1629 }
1629 tabMenu->setItemChecked(id, true); 1630 tabMenu->setItemChecked(id, true);
1630 tabPos = id; 1631 tabPos = id;
1631} 1632}
1632 1633
1633 1634
1634void Konsole::configMenuSelected(int iD) 1635void Konsole::configMenuSelected(int iD)
1635{ 1636{
1636 // QString temp; 1637 // QString temp;
1637 // qDebug( temp.sprintf("configmenu %d",iD)); 1638 // odebug << temp.sprintf("configmenu " << iD) << "" << oendl;
1638 1639
1639 TEWidget* te = getTe(); 1640 TEWidget* te = getTe();
1640 Config cfg( "Konsole" ); 1641 Config cfg( "Konsole" );
1641 cfg.setGroup("Menubar"); 1642 cfg.setGroup("Menubar");
1642 if(iD == cm_wrap) 1643 if(iD == cm_wrap)
1643 { 1644 {
1644 cfg.setGroup("ScrollBar"); 1645 cfg.setGroup("ScrollBar");
1645 bool b=cfg.readBoolEntry("HorzScroll",0); 1646 bool b=cfg.readBoolEntry("HorzScroll",0);
1646 b=!b; 1647 b=!b;
1647 cfg.writeEntry("HorzScroll", b ); 1648 cfg.writeEntry("HorzScroll", b );
1648 cfg.write(); 1649 cfg.write();
1649 doWrap(); 1650 doWrap();
1650 if(cfg.readNumEntry("Position",2) == 0) 1651 if(cfg.readNumEntry("Position",2) == 0)
1651 { 1652 {
1652 te->setScrollbarLocation(1); 1653 te->setScrollbarLocation(1);
1653 } 1654 }
1654 else 1655 else
1655 { 1656 {
1656 te->setScrollbarLocation(0); 1657 te->setScrollbarLocation(0);
1657 } 1658 }
1658 te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1659 te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1659 } 1660 }
1660 if(iD == cm_beep) 1661 if(iD == cm_beep)
1661 { 1662 {
1662 cfg.setGroup("Menubar"); 1663 cfg.setGroup("Menubar");
1663 bool b=cfg.readBoolEntry("useBeep",0); 1664 bool b=cfg.readBoolEntry("useBeep",0);
1664 b=!b; 1665 b=!b;
1665 cfg.writeEntry("useBeep", b ); 1666 cfg.writeEntry("useBeep", b );
1666 cfg.write(); 1667 cfg.write();
1667 configMenu->setItemChecked(cm_beep,b); 1668 configMenu->setItemChecked(cm_beep,b);
1668 te->useBeep=b; 1669 te->useBeep=b;
1669 } 1670 }
1670} 1671}
1671 1672
1672void Konsole::changeCommand(const QString &text, int c) 1673void Konsole::changeCommand(const QString &text, int c)
1673{ 1674{
1674 Config cfg( "Konsole" ); 1675 Config cfg( "Konsole" );
1675 cfg.setGroup("Commands"); 1676 cfg.setGroup("Commands");
1676 if(commonCmds[c] != text) 1677 if(commonCmds[c] != text)
1677 { 1678 {
1678 cfg.writeEntry(QString::number(c),text); 1679 cfg.writeEntry(QString::number(c),text);
1679 commonCombo->clearEdit(); 1680 commonCombo->clearEdit();
1680 commonCombo->setCurrentItem(c); 1681 commonCombo->setCurrentItem(c);
1681 } 1682 }
1682} 1683}
1683 1684
1684void Konsole::setColor(int sess) 1685void Konsole::setColor(int sess)
1685{ 1686{
1686 Config cfg( "Konsole" ); 1687 Config cfg( "Konsole" );
1687 cfg.setGroup("Colors"); 1688 cfg.setGroup("Colors");
1688 QColor foreground, background; 1689 QColor foreground, background;
1689 QString ss = QString("Session") + QString::number(sess); 1690 QString ss = QString("Session") + QString::number(sess);
1690 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, 1691 foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss,
1691 cfg.readNumEntry("foregroundRed",0xff)), 1692 cfg.readNumEntry("foregroundRed",0xff)),
1692 cfg.readNumEntry("foregroundGreen"+ss, 1693 cfg.readNumEntry("foregroundGreen"+ss,
1693 cfg.readNumEntry("foregroundGreen",0xff)), 1694 cfg.readNumEntry("foregroundGreen",0xff)),
1694 cfg.readNumEntry("foregroundBlue"+ss, 1695 cfg.readNumEntry("foregroundBlue"+ss,
1695 cfg.readNumEntry("foregroundBlue",0xff))); 1696 cfg.readNumEntry("foregroundBlue",0xff)));
1696 background.setRgb(cfg.readNumEntry("backgroundRed"+ss, 1697 background.setRgb(cfg.readNumEntry("backgroundRed"+ss,
1697 cfg.readNumEntry("backgroundRed",0)), 1698 cfg.readNumEntry("backgroundRed",0)),
1698 cfg.readNumEntry("backgroundGreen"+ss, 1699 cfg.readNumEntry("backgroundGreen"+ss,
1699 cfg.readNumEntry("backgroundGreen",0)), 1700 cfg.readNumEntry("backgroundGreen",0)),
1700 cfg.readNumEntry("backgroundBlue"+ss, 1701 cfg.readNumEntry("backgroundBlue"+ss,
1701 cfg.readNumEntry("backgroundBlue",0))); 1702 cfg.readNumEntry("backgroundBlue",0)));
1702 setColors(foreground, background); 1703 setColors(foreground, background);
1703} 1704}
1704 1705
1705void Konsole::scrollMenuSelected(int index) 1706void Konsole::scrollMenuSelected(int index)
1706{ 1707{
1707 // qDebug( "scrollbar menu %d",index); 1708 // odebug << "scrollbar menu " << index << "" << oendl;
1708 1709
1709 TEWidget* te = getTe(); 1710 TEWidget* te = getTe();
1710 Config cfg( "Konsole" ); 1711 Config cfg( "Konsole" );
1711 cfg.setGroup("ScrollBar"); 1712 cfg.setGroup("ScrollBar");
1712 1713
1713 if(index == sm_none) 1714 if(index == sm_none)
1714 { 1715 {
1715 te->setScrollbarLocation(0); 1716 te->setScrollbarLocation(0);
1716 cfg.writeEntry("Position",0); 1717 cfg.writeEntry("Position",0);
1717 } 1718 }
1718 else if(index == sm_left) 1719 else if(index == sm_left)
1719 { 1720 {
1720 te->setScrollbarLocation(1); 1721 te->setScrollbarLocation(1);
1721 cfg.writeEntry("Position",1); 1722 cfg.writeEntry("Position",1);
1722 } 1723 }
1723 else if(index == sm_right) 1724 else if(index == sm_right)
1724 { 1725 {
1725 te->setScrollbarLocation(2); 1726 te->setScrollbarLocation(2);
1726 cfg.writeEntry("Position",2); 1727 cfg.writeEntry("Position",2);
1727 } 1728 }
1728 scrollMenu->setItemChecked(sm_none, index == sm_none); 1729 scrollMenu->setItemChecked(sm_none, index == sm_none);
1729 scrollMenu->setItemChecked(sm_left, index == sm_left); 1730 scrollMenu->setItemChecked(sm_left, index == sm_left);
1730 scrollMenu->setItemChecked(sm_right, index == sm_right); 1731 scrollMenu->setItemChecked(sm_right, index == sm_right);
1731} 1732}
1732 1733
1733// case -29: { 1734// case -29: {
1734// bool b=cfg.readBoolEntry("HorzScroll",0); 1735// bool b=cfg.readBoolEntry("HorzScroll",0);
1735// cfg.writeEntry("HorzScroll", !b ); 1736// cfg.writeEntry("HorzScroll", !b );
1736// cfg.write(); 1737// cfg.write();
1737// if(cfg.readNumEntry("Position",2) == 0) { 1738// if(cfg.readNumEntry("Position",2) == 0) {
1738// te->setScrollbarLocation(1); 1739// te->setScrollbarLocation(1);
1739// te->setWrapAt(0); 1740// te->setWrapAt(0);
1740// } else { 1741// } else {
1741// te->setScrollbarLocation(0); 1742// te->setScrollbarLocation(0);
1742// te->setWrapAt(120); 1743// te->setWrapAt(120);
1743// } 1744// }
1744// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1745// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1745// } 1746// }
1746// break; 1747// break;
1747 1748
1748void Konsole::editCommandListMenuSelected(int iD) 1749void Konsole::editCommandListMenuSelected(int iD)
1749{ 1750{
1750 // QString temp; 1751 // QString temp;
1751 // qDebug( temp.sprintf("edit command list %d",iD)); 1752 // odebug << temp.sprintf("edit command list " << iD) << "" << oendl;
1752 1753
1753 // FIXME: more cleanup needed here 1754 // FIXME: more cleanup needed here
1754 1755
1755 1756
1756 TEWidget* te = getTe(); 1757 TEWidget* te = getTe();
1757 Config cfg( "Konsole" ); 1758 Config cfg( "Konsole" );
1758 cfg.setGroup("Menubar"); 1759 cfg.setGroup("Menubar");
1759 if( iD == ec_cmdlist) 1760 if( iD == ec_cmdlist)
1760 { 1761 {
1761 if(!secondToolBar->isHidden()) 1762 if(!secondToolBar->isHidden())
1762 { 1763 {
1763 secondToolBar->hide(); 1764 secondToolBar->hide();
1764 configMenu->changeItem( iD,tr( "Show Command List" )); 1765 configMenu->changeItem( iD,tr( "Show Command List" ));
1765 cfg.writeEntry("Hidden","TRUE"); 1766 cfg.writeEntry("Hidden","TRUE");
1766 configMenu->setItemEnabled(ec_edit ,FALSE); 1767 configMenu->setItemEnabled(ec_edit ,FALSE);
1767 configMenu->setItemEnabled(ec_quick ,FALSE); 1768 configMenu->setItemEnabled(ec_quick ,FALSE);
1768 } 1769 }
1769 else 1770 else
1770 { 1771 {
1771 secondToolBar->show(); 1772 secondToolBar->show();
1772 configMenu->changeItem( iD,tr( "Hide Command List" )); 1773 configMenu->changeItem( iD,tr( "Hide Command List" ));
1773 cfg.writeEntry("Hidden","FALSE"); 1774 cfg.writeEntry("Hidden","FALSE");
1774 configMenu->setItemEnabled(ec_edit ,TRUE); 1775 configMenu->setItemEnabled(ec_edit ,TRUE);
1775 configMenu->setItemEnabled(ec_quick ,TRUE); 1776 configMenu->setItemEnabled(ec_quick ,TRUE);
1776 1777
1777 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") 1778 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE")
1778 { 1779 {
1779 configMenu->setItemChecked(ec_edit,TRUE); 1780 configMenu->setItemChecked(ec_edit,TRUE);
1780 commonCombo->setEditable( TRUE ); 1781 commonCombo->setEditable( TRUE );
1781 } 1782 }
1782 else 1783 else
1783 { 1784 {
1784 configMenu->setItemChecked(ec_edit,FALSE); 1785 configMenu->setItemChecked(ec_edit,FALSE);
1785 commonCombo->setEditable( FALSE ); 1786 commonCombo->setEditable( FALSE );
1786 } 1787 }
1787 } 1788 }
1788 } 1789 }
1789 if( iD == ec_quick) 1790 if( iD == ec_quick)
1790 { 1791 {
1791 cfg.setGroup("Commands"); 1792 cfg.setGroup("Commands");
1792 // qDebug("enableCommandEdit"); 1793 // odebug << "enableCommandEdit" << oendl;
1793 if( !configMenu->isItemChecked(iD) ) 1794 if( !configMenu->isItemChecked(iD) )
1794 { 1795 {
1795 commonCombo->setEditable( TRUE ); 1796 commonCombo->setEditable( TRUE );
1796 configMenu->setItemChecked(iD,TRUE); 1797 configMenu->setItemChecked(iD,TRUE);
1797 commonCombo->setCurrentItem(0); 1798 commonCombo->setCurrentItem(0);
1798 cfg.writeEntry("EditEnabled","TRUE"); 1799 cfg.writeEntry("EditEnabled","TRUE");
1799 } 1800 }
1800 else 1801 else
1801 { 1802 {
1802 commonCombo->setEditable( FALSE ); 1803 commonCombo->setEditable( FALSE );
1803 configMenu->setItemChecked(iD,FALSE); 1804 configMenu->setItemChecked(iD,FALSE);
1804 cfg.writeEntry("EditEnabled","FALSE"); 1805 cfg.writeEntry("EditEnabled","FALSE");
1805 commonCombo->setFocusPolicy(QWidget::NoFocus); 1806 commonCombo->setFocusPolicy(QWidget::NoFocus);
1806 te->setFocus(); 1807 te->setFocus();
1807 } 1808 }
1808 } 1809 }
1809 if(iD == ec_edit) 1810 if(iD == ec_edit)
1810 { 1811 {
1811 // "edit commands" 1812 // "edit commands"
1812 CommandEditDialog *m = new CommandEditDialog(this); 1813 CommandEditDialog *m = new CommandEditDialog(this);
1813 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 1814 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
1814 m->showMaximized(); 1815 m->showMaximized();
1815 } 1816 }
1816 1817
1817} 1818}
1818 1819
1819// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' 1820// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
1820void Konsole::setDocument( const QString &cmd) 1821void Konsole::setDocument( const QString &cmd)
1821{ 1822{
1822 newSession(); 1823 newSession();
1823 TEWidget* te = getTe(); 1824 TEWidget* te = getTe();
1824 if(cmd.find("-e", 0, TRUE) != -1) 1825 if(cmd.find("-e", 0, TRUE) != -1)
1825 { 1826 {
1826 QString cmd2; 1827 QString cmd2;
1827 cmd2=cmd.right(cmd.length()-3)+" &"; 1828 cmd2=cmd.right(cmd.length()-3)+" &";
1828 system(cmd2.latin1()); 1829 system(cmd2.latin1());
1829 if(startUp <= 1 && nsessions < 2) 1830 if(startUp <= 1 && nsessions < 2)
1830 { 1831 {
1831 doneSession(getTe(), 0); 1832 doneSession(getTe(), 0);
1832 exit(0); 1833 exit(0);
1833 } 1834 }
1834 else 1835 else
1835 doneSession(getTe(), 0); 1836 doneSession(getTe(), 0);
1836 } 1837 }
1837 else 1838 else
1838 { 1839 {
1839 if (te != 0) 1840 if (te != 0)
1840 { 1841 {
1841 te->emitText(cmd+"\r"); 1842 te->emitText(cmd+"\r");
1842 } 1843 }
1843 } 1844 }
1844 startUp++; 1845 startUp++;
1845} 1846}
1846 1847
1847 1848
1848// what is the point of this when you can just 1849// what is the point of this when you can just
1849// run commands by using the shell directly?? 1850// run commands by using the shell directly??
1850void Konsole::parseCommandLine() 1851void Konsole::parseCommandLine()
1851{ 1852{
1852 QString cmd; 1853 QString cmd;
1853 // newSession(); 1854 // newSession();
1854 for (int i=1;i< qApp->argc();i++) 1855 for (int i=1;i< qApp->argc();i++)
1855 { 1856 {
1856 if( QString(qApp->argv()[i]) == "-e") 1857 if( QString(qApp->argv()[i]) == "-e")
1857 { 1858 {
1858 i++; 1859 i++;
1859 for ( int j=i;j< qApp->argc();j++) 1860 for ( int j=i;j< qApp->argc();j++)
1860 { 1861 {
1861 cmd+=QString(qApp->argv()[j])+" "; 1862 cmd+=QString(qApp->argv()[j])+" ";
1862 } 1863 }
1863 cmd.stripWhiteSpace(); 1864 cmd.stripWhiteSpace();
1864 system(cmd.latin1()); 1865 system(cmd.latin1());
1865 exit(0);//close(); 1866 exit(0);//close();
1866 } // end -e switch 1867 } // end -e switch
1867 } 1868 }
1868 startUp++; 1869 startUp++;
1869} 1870}
1870 1871
1871void Konsole::changeForegroundColor(const QColor &color) 1872void Konsole::changeForegroundColor(const QColor &color)
1872{ 1873{
1873 Config cfg( "Konsole" ); 1874 Config cfg( "Konsole" );
1874 cfg.setGroup("Colors"); 1875 cfg.setGroup("Colors");
1875 int r, g, b; 1876 int r, g, b;
1876 color.rgb(&r,&g,&b); 1877 color.rgb(&r,&g,&b);
1877 foreground.setRgb(r,g,b); 1878 foreground.setRgb(r,g,b);
1878 1879
1879 cfg.writeEntry("foreground",color.name()); 1880 cfg.writeEntry("foreground",color.name());
1880 qDebug("foreground "+color.name()); 1881 odebug << "foreground "+color.name() << oendl;
1881 cfg.write(); 1882 cfg.write();
1882 1883
1883 qDebug("do other dialog"); 1884 odebug << "do other dialog" << oendl;
1884#ifdef QT_QWS_OPIE 1885#ifdef QT_QWS_OPIE
1885 1886
1886 Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); 1887 Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color");
1887 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, 1888 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
1888 SLOT(changeBackgroundColor(const QColor&))); 1889 SLOT(changeBackgroundColor(const QColor&)));
1889 penColorPopupMenu2->exec(); 1890 penColorPopupMenu2->exec();
1890#endif 1891#endif
1891} 1892}
1892 1893
1893void Konsole::changeBackgroundColor(const QColor &color) 1894void Konsole::changeBackgroundColor(const QColor &color)
1894{ 1895{
1895 1896
1896 qDebug("Change background"); 1897 odebug << "Change background" << oendl;
1897 Config cfg( "Konsole" ); 1898 Config cfg( "Konsole" );
1898 cfg.setGroup("Colors"); 1899 cfg.setGroup("Colors");
1899 int r, g, b; 1900 int r, g, b;
1900 color.rgb(&r,&g,&b); 1901 color.rgb(&r,&g,&b);
1901 background.setRgb(r,g,b); 1902 background.setRgb(r,g,b);
1902 cfg.writeEntry("background",color.name()); 1903 cfg.writeEntry("background",color.name());
1903 qDebug("background "+color.name()); 1904 odebug << "background "+color.name() << oendl;
1904 cfg.write(); 1905 cfg.write();
1905} 1906}
1906 1907
1907void Konsole::doWrap() 1908void Konsole::doWrap()
1908{ 1909{
1909 Config cfg( "Konsole" ); 1910 Config cfg( "Konsole" );
1910 cfg.setGroup("ScrollBar"); 1911 cfg.setGroup("ScrollBar");
1911 TEWidget* te = getTe(); 1912 TEWidget* te = getTe();
1912 if( !cfg.readBoolEntry("HorzScroll",0)) 1913 if( !cfg.readBoolEntry("HorzScroll",0))
1913 { 1914 {
1914 te->setWrapAt(0); 1915 te->setWrapAt(0);
1915 configMenu->setItemChecked( cm_wrap,TRUE); 1916 configMenu->setItemChecked( cm_wrap,TRUE);
1916 } 1917 }
1917 else 1918 else
1918 { 1919 {
1919 // te->setWrapAt(90); 1920 // te->setWrapAt(90);
1920 te->setWrapAt(120); 1921 te->setWrapAt(120);
1921 configMenu->setItemChecked( cm_wrap,FALSE); 1922 configMenu->setItemChecked( cm_wrap,FALSE);
1922 } 1923 }
1923} 1924}
diff --git a/core/apps/embeddedkonsole/main.cpp b/core/apps/embeddedkonsole/main.cpp
index b851d3e..131e782 100644
--- a/core/apps/embeddedkonsole/main.cpp
+++ b/core/apps/embeddedkonsole/main.cpp
@@ -1,85 +1,85 @@
1/* ---------------------------------------------------------------------- */ 1/* ---------------------------------------------------------------------- */
2/* */ 2/* */
3/* [main.C] Konsole */ 3/* [main.C] Konsole */
4/* */ 4/* */
5/* ---------------------------------------------------------------------- */ 5/* ---------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole, an X terminal. */ 9/* This file is part of Konsole, an X terminal. */
10/* */ 10/* */
11/* The material contained in here more or less directly orginates from */ 11/* The material contained in here more or less directly orginates from */
12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
13/* */ 13/* */
14/* ---------------------------------------------------------------------- */ 14/* ---------------------------------------------------------------------- */
15/* */ 15/* */
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17/* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19/* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21 21
22#include "konsole.h" 22#include "konsole.h"
23 23
24#ifdef QT_QWS_OPIE 24#ifdef QT_QWS_OPIE
25 25
26#include <opie2/oapplicationfactory.h> 26#include <opie2/oapplicationfactory.h>
27 27
28/* --| main |------------------------------------------------------ */ 28/* --| main |------------------------------------------------------ */
29using namespace Opie::Core; 29using namespace Opie::Core;
30OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) 30OPIE_EXPORT_APP( OApplicationFactory<Konsole> )
31 31
32#else //for non opie builds 32#else //for non opie builds
33 33
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35 35
36#include <qfile.h> 36#include <qfile.h>
37 37
38#include <unistd.h> 38#include <unistd.h>
39#include <stdio.h> 39#include <stdio.h>
40#include <stdlib.h> 40#include <stdlib.h>
41 41
42#include <pwd.h> 42#include <pwd.h>
43#include <sys/types.h> 43#include <sys/types.h>
44 44
45 45
46/* --| main |------------------------------------------------------ */ 46/* --| main |------------------------------------------------------ */
47 int main(int argc, char* argv[]) { 47 int main(int argc, char* argv[]) {
48 if(setuid(getuid()) !=0) qDebug("setuid failed"); 48 if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl;
49 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges 49 if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges
50 50
51 QPEApplication a( argc, argv ); 51 QPEApplication a( argc, argv );
52#ifdef FAKE_CTRL_AND_ALT 52#ifdef FAKE_CTRL_AND_ALT
53 qDebug("Fake Ctrl and Alt defined"); 53 odebug << "Fake Ctrl and Alt defined" << oendl;
54 QPEApplication::grabKeyboard(); // for CTRL and ALT 54 QPEApplication::grabKeyboard(); // for CTRL and ALT
55#endif 55#endif
56 56
57 QStrList tmp; 57 QStrList tmp;
58 const char* shell = getenv("SHELL"); 58 const char* shell = getenv("SHELL");
59 59
60 if (shell == NULL || *shell == '\0') { 60 if (shell == NULL || *shell == '\0') {
61 struct passwd *ent = 0; 61 struct passwd *ent = 0;
62 uid_t me = getuid(); 62 uid_t me = getuid();
63 shell = "/bin/sh"; 63 shell = "/bin/sh";
64 64
65 while ( (ent = getpwent()) != 0 ) { 65 while ( (ent = getpwent()) != 0 ) {
66 if (ent->pw_uid == me) { 66 if (ent->pw_uid == me) {
67 if (ent->pw_shell != "") 67 if (ent->pw_shell != "")
68 shell = ent->pw_shell; 68 shell = ent->pw_shell;
69 break; 69 break;
70 } 70 }
71 } 71 }
72 endpwent(); 72 endpwent();
73 } 73 }
74 74
75 if( putenv((char*)"COLORTERM=") !=0) 75 if( putenv((char*)"COLORTERM=") !=0)
76 qDebug("putenv failed"); // to trigger mc's color detection 76 odebug << "putenv failed" << oendl; // to trigger mc's color detection
77 77
78 Konsole m( "test", shell, tmp, TRUE ); 78 Konsole m( "test", shell, tmp, TRUE );
79 m.setCaption( Konsole::tr("Terminal") ); 79 m.setCaption( Konsole::tr("Terminal") );
80 a.showMainWidget( &m ); 80 a.showMainWidget( &m );
81 81
82 return a.exec(); 82 return a.exec();
83} 83}
84 84
85#endif 85#endif
diff --git a/core/apps/embeddedkonsole/playlistselection.cpp b/core/apps/embeddedkonsole/playlistselection.cpp
index fc5330f..096d36a 100644
--- a/core/apps/embeddedkonsole/playlistselection.cpp
+++ b/core/apps/embeddedkonsole/playlistselection.cpp
@@ -1,154 +1,157 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qheader.h>
21 20
22#include "playlistselection.h" 21#include "playlistselection.h"
23 22
24#include <stdlib.h> 23/* OPIE */
25 24#include <opie2/odebug.h>
26 25
26/* Qt */
27#include <qheader.h>
27 28
29/* STD */
30#include <stdlib.h>
28 31
29 32
30PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) 33PlayListSelection::PlayListSelection( QWidget *parent, const char *name )
31 : QListView( parent, name ) 34 : QListView( parent, name )
32{ 35{
33 setAllColumnsShowFocus( TRUE ); 36 setAllColumnsShowFocus( TRUE );
34 addColumn( tr( "Command Selection" ) ); 37 addColumn( tr( "Command Selection" ) );
35 header()->hide(); 38 header()->hide();
36 setSorting( -1, FALSE ); 39 setSorting( -1, FALSE );
37} 40}
38 41
39 42
40PlayListSelection::~PlayListSelection() { 43PlayListSelection::~PlayListSelection() {
41} 44}
42 45
43 46
44 47
45void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 48void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
46 if ( event->state() == QMouseEvent::LeftButton ) { 49 if ( event->state() == QMouseEvent::LeftButton ) {
47 QListViewItem *currentItem = selectedItem(); 50 QListViewItem *currentItem = selectedItem();
48 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); 51 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
49 if ( currentItem && currentItem->itemAbove() == itemUnder ) 52 if ( currentItem && currentItem->itemAbove() == itemUnder )
50 moveSelectedUp(); 53 moveSelectedUp();
51 else if ( currentItem && currentItem->itemBelow() == itemUnder ) 54 else if ( currentItem && currentItem->itemBelow() == itemUnder )
52 moveSelectedDown(); 55 moveSelectedDown();
53 } 56 }
54} 57}
55 58
56 59
57const QString *PlayListSelection::current() { 60const QString *PlayListSelection::current() {
58 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); 61 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem();
59 if ( item ) 62 if ( item )
60 return item->file(); 63 return item->file();
61 return NULL; 64 return NULL;
62} 65}
63 66
64 67
65void PlayListSelection::addToSelection( QListViewItem *lnk ) { 68void PlayListSelection::addToSelection( QListViewItem *lnk ) {
66PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) ); 69PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) );
67 QListViewItem *current = selectedItem(); 70 QListViewItem *current = selectedItem();
68 if ( current ) 71 if ( current )
69 item->moveItem( current ); 72 item->moveItem( current );
70 setSelected( item, TRUE ); 73 setSelected( item, TRUE );
71 ensureItemVisible( selectedItem() ); 74 ensureItemVisible( selectedItem() );
72} 75}
73 76
74void PlayListSelection::addStringToSelection (const QString & lnk) { 77void PlayListSelection::addStringToSelection (const QString & lnk) {
75 PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk ) ); 78 PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk ) );
76 QListViewItem *current = selectedItem(); 79 QListViewItem *current = selectedItem();
77 if ( current ) 80 if ( current )
78 item->moveItem( current ); 81 item->moveItem( current );
79 setSelected( item, TRUE ); 82 setSelected( item, TRUE );
80 ensureItemVisible( selectedItem() ); 83 ensureItemVisible( selectedItem() );
81 84
82} 85}
83void PlayListSelection::removeSelected() { 86void PlayListSelection::removeSelected() {
84 qDebug("removeSelected()"); 87 odebug << "removeSelected()" << oendl;
85 QListViewItem *item = selectedItem(); 88 QListViewItem *item = selectedItem();
86 if ( item ) 89 if ( item )
87 delete item; 90 delete item;
88 setSelected( currentItem(), TRUE ); 91 setSelected( currentItem(), TRUE );
89 ensureItemVisible( selectedItem() ); 92 ensureItemVisible( selectedItem() );
90} 93}
91 94
92 95
93void PlayListSelection::moveSelectedUp() { 96void PlayListSelection::moveSelectedUp() {
94 QListViewItem *item = selectedItem(); 97 QListViewItem *item = selectedItem();
95 if ( item && item->itemAbove() ) 98 if ( item && item->itemAbove() )
96 item->itemAbove()->moveItem( item ); 99 item->itemAbove()->moveItem( item );
97 ensureItemVisible( selectedItem() ); 100 ensureItemVisible( selectedItem() );
98} 101}
99 102
100 103
101void PlayListSelection::moveSelectedDown() { 104void PlayListSelection::moveSelectedDown() {
102 QListViewItem *item = selectedItem(); 105 QListViewItem *item = selectedItem();
103 if ( item && item->itemBelow() ) 106 if ( item && item->itemBelow() )
104 item->moveItem( item->itemBelow() ); 107 item->moveItem( item->itemBelow() );
105 ensureItemVisible( selectedItem() ); 108 ensureItemVisible( selectedItem() );
106} 109}
107 110
108 111
109bool PlayListSelection::prev() { 112bool PlayListSelection::prev() {
110 QListViewItem *item = selectedItem(); 113 QListViewItem *item = selectedItem();
111 if ( item && item->itemAbove() ) 114 if ( item && item->itemAbove() )
112 setSelected( item->itemAbove(), TRUE ); 115 setSelected( item->itemAbove(), TRUE );
113 else 116 else
114 return FALSE; 117 return FALSE;
115 ensureItemVisible( selectedItem() ); 118 ensureItemVisible( selectedItem() );
116 return TRUE; 119 return TRUE;
117} 120}
118 121
119 122
120bool PlayListSelection::next() { 123bool PlayListSelection::next() {
121 QListViewItem *item = selectedItem(); 124 QListViewItem *item = selectedItem();
122 if ( item && item->itemBelow() ) 125 if ( item && item->itemBelow() )
123 setSelected( item->itemBelow(), TRUE ); 126 setSelected( item->itemBelow(), TRUE );
124 else 127 else
125 return FALSE; 128 return FALSE;
126 ensureItemVisible( selectedItem() ); 129 ensureItemVisible( selectedItem() );
127 return TRUE; 130 return TRUE;
128} 131}
129 132
130 133
131bool PlayListSelection::first() { 134bool PlayListSelection::first() {
132 QListViewItem *item = firstChild(); 135 QListViewItem *item = firstChild();
133 if ( item ) 136 if ( item )
134 setSelected( item, TRUE ); 137 setSelected( item, TRUE );
135 else 138 else
136 return FALSE; 139 return FALSE;
137 ensureItemVisible( selectedItem() ); 140 ensureItemVisible( selectedItem() );
138 return TRUE; 141 return TRUE;
139} 142}
140 143
141 144
142bool PlayListSelection::last() { 145bool PlayListSelection::last() {
143 QListViewItem *prevItem = NULL; 146 QListViewItem *prevItem = NULL;
144 QListViewItem *item = firstChild(); 147 QListViewItem *item = firstChild();
145 while ( ( item = item->nextSibling() ) ) 148 while ( ( item = item->nextSibling() ) )
146 prevItem = item; 149 prevItem = item;
147 if ( prevItem ) 150 if ( prevItem )
148 setSelected( prevItem, TRUE ); 151 setSelected( prevItem, TRUE );
149 else 152 else
150 return FALSE; 153 return FALSE;
151 ensureItemVisible( selectedItem() ); 154 ensureItemVisible( selectedItem() );
152 return TRUE; 155 return TRUE;
153} 156}
154 157