Diffstat (limited to 'core/apps/embeddedkonsole/commandeditdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialog.cpp | 224 |
1 files changed, 224 insertions, 0 deletions
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp new file mode 100644 index 0000000..e8ef858 --- a/dev/null +++ b/core/apps/embeddedkonsole/commandeditdialog.cpp | |||
@@ -0,0 +1,224 @@ | |||
1 | //comandeditdialog.cpp | ||
2 | |||
3 | #include "commandeditdialog.h" | ||
4 | #include "playlistselection.h" | ||
5 | #include <qstring.h> | ||
6 | #include <qpe/config.h> | ||
7 | #include <qpe/qpetoolbar.h> | ||
8 | #include <qwidget.h> | ||
9 | #include <qpe/qpemenubar.h> | ||
10 | #include <qpe/resource.h> | ||
11 | #include <qlist.h> | ||
12 | #include <qtoolbutton.h> | ||
13 | #include <qvbox.h> | ||
14 | #include <qlistview.h> | ||
15 | #include <qlineedit.h> | ||
16 | #include <qheader.h> | ||
17 | #include <qlabel.h> | ||
18 | #include <qmessagebox.h> | ||
19 | #include "smallcommandeditdialogbase.h" | ||
20 | |||
21 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) | ||
22 | : CommandEditDialogBase(parent, name, TRUE, fl) | ||
23 | |||
24 | { | ||
25 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); | ||
26 | m_SuggestedCommandList->header()->hide(); | ||
27 | m_SuggestedCommandList->setSorting(-1,FALSE); | ||
28 | m_SuggestedCommandList->clearSelection(); | ||
29 | m_SuggestedCommandList->setSorting(0,TRUE); | ||
30 | |||
31 | QListViewItem *item; | ||
32 | |||
33 | |||
34 | item = new QListViewItem( m_SuggestedCommandList,"ls "); | ||
35 | |||
36 | item = new QListViewItem( m_SuggestedCommandList,"cat "); | ||
37 | item = new QListViewItem( m_SuggestedCommandList,"cd "); | ||
38 | item = new QListViewItem( m_SuggestedCommandList,"chmod "); | ||
39 | item = new QListViewItem( m_SuggestedCommandList,"cp "); | ||
40 | item = new QListViewItem( m_SuggestedCommandList,"dc "); | ||
41 | item = new QListViewItem( m_SuggestedCommandList,"df "); | ||
42 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); | ||
43 | item = new QListViewItem( m_SuggestedCommandList,"echo "); | ||
44 | item = new QListViewItem( m_SuggestedCommandList,"export "); | ||
45 | item = new QListViewItem( m_SuggestedCommandList,"env "); | ||
46 | item = new QListViewItem( m_SuggestedCommandList,"find "); | ||
47 | item = new QListViewItem( m_SuggestedCommandList,"free "); | ||
48 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); | ||
49 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); | ||
50 | item = new QListViewItem( m_SuggestedCommandList,"mkdir "); | ||
51 | item = new QListViewItem( m_SuggestedCommandList,"mv "); | ||
52 | item = new QListViewItem( m_SuggestedCommandList,"nc localhost 7776 "); | ||
53 | item = new QListViewItem( m_SuggestedCommandList,"nc localhost 7777 "); | ||
54 | item = new QListViewItem( m_SuggestedCommandList,"nslookup "); | ||
55 | item = new QListViewItem( m_SuggestedCommandList,"ping "); | ||
56 | item = new QListViewItem( m_SuggestedCommandList,"ps aux"); | ||
57 | item = new QListViewItem( m_SuggestedCommandList,"pwd "); | ||
58 | item = new QListViewItem( m_SuggestedCommandList,"rm "); | ||
59 | item = new QListViewItem( m_SuggestedCommandList,"rmdir "); | ||
60 | item = new QListViewItem( m_SuggestedCommandList,"route "); | ||
61 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); | ||
62 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); | ||
63 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); | ||
64 | item = new QListViewItem( m_SuggestedCommandList,"chown "); | ||
65 | item = new QListViewItem( m_SuggestedCommandList,"date "); | ||
66 | item = new QListViewItem( m_SuggestedCommandList,"dd "); | ||
67 | item = new QListViewItem( m_SuggestedCommandList,"df "); | ||
68 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); | ||
69 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); | ||
70 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); | ||
71 | item = new QListViewItem( m_SuggestedCommandList,"kill "); | ||
72 | item = new QListViewItem( m_SuggestedCommandList,"killall "); | ||
73 | item = new QListViewItem( m_SuggestedCommandList,"ln "); | ||
74 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); | ||
75 | item = new QListViewItem( m_SuggestedCommandList,"mount "); | ||
76 | item = new QListViewItem( m_SuggestedCommandList,"more "); | ||
77 | item = new QListViewItem( m_SuggestedCommandList,"sort "); | ||
78 | item = new QListViewItem( m_SuggestedCommandList,"touch "); | ||
79 | item = new QListViewItem( m_SuggestedCommandList,"umount "); | ||
80 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); | ||
81 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); | ||
82 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); | ||
83 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); | ||
84 | m_SuggestedCommandList->sort(); | ||
85 | |||
86 | connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) ); | ||
87 | |||
88 | |||
89 | |||
90 | ToolButton1->setTextLabel("new"); | ||
91 | ToolButton1->setPixmap(Resource::loadPixmap("new")); | ||
92 | ToolButton1->setAutoRaise(TRUE); | ||
93 | ToolButton1->setFocusPolicy(QWidget::NoFocus); | ||
94 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); | ||
95 | |||
96 | ToolButton2->setTextLabel("edit"); | ||
97 | ToolButton2->setPixmap(Resource::loadPixmap("edit")); | ||
98 | ToolButton2->setAutoRaise(TRUE); | ||
99 | ToolButton2->setFocusPolicy(QWidget::NoFocus); | ||
100 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); | ||
101 | |||
102 | ToolButton3->setTextLabel("delete"); | ||
103 | ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); | ||
104 | ToolButton3->setAutoRaise(TRUE); | ||
105 | ToolButton3->setFocusPolicy(QWidget::NoFocus); | ||
106 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); | ||
107 | |||
108 | ToolButton4->setTextLabel("up"); | ||
109 | ToolButton4->setPixmap(Resource::loadPixmap("up")); | ||
110 | ToolButton4->setAutoRaise(TRUE); | ||
111 | ToolButton4->setFocusPolicy(QWidget::NoFocus); | ||
112 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); | ||
113 | |||
114 | ToolButton5->setTextLabel("down"); | ||
115 | ToolButton5->setPixmap(Resource::loadPixmap("down")); | ||
116 | ToolButton5->setAutoRaise(TRUE); | ||
117 | ToolButton5->setFocusPolicy(QWidget::NoFocus); | ||
118 | |||
119 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); | ||
120 | |||
121 | |||
122 | |||
123 | |||
124 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); | ||
125 | if ( current ) | ||
126 | item->moveItem( current ); | ||
127 | m_SuggestedCommandList->setSelected( item, TRUE ); | ||
128 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); | ||
129 | Config cfg("Konsole"); | ||
130 | cfg.setGroup("Commands"); | ||
131 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { | ||
132 | for (int i = 0; i < 100; i++) { | ||
133 | QString tmp; | ||
134 | tmp = cfg.readEntry( QString::number(i),""); | ||
135 | if (!tmp.isEmpty()) | ||
136 | m_PlayListSelection->addStringToSelection(tmp); | ||
137 | } | ||
138 | } else { | ||
139 | |||
140 | m_PlayListSelection->addStringToSelection("ls "); | ||
141 | m_PlayListSelection->addStringToSelection("cardctl eject"); | ||
142 | m_PlayListSelection->addStringToSelection("cat "); | ||
143 | m_PlayListSelection->addStringToSelection("cd "); | ||
144 | m_PlayListSelection->addStringToSelection("chmod "); | ||
145 | m_PlayListSelection->addStringToSelection("cp "); | ||
146 | m_PlayListSelection->addStringToSelection("dc "); | ||
147 | m_PlayListSelection->addStringToSelection("df "); | ||
148 | m_PlayListSelection->addStringToSelection("dmesg"); | ||
149 | m_PlayListSelection->addStringToSelection("echo "); | ||
150 | m_PlayListSelection->addStringToSelection("env"); | ||
151 | m_PlayListSelection->addStringToSelection("find "); | ||
152 | m_PlayListSelection->addStringToSelection("free"); | ||
153 | m_PlayListSelection->addStringToSelection("grep "); | ||
154 | m_PlayListSelection->addStringToSelection("ifconfig "); | ||
155 | m_PlayListSelection->addStringToSelection("ipkg "); | ||
156 | m_PlayListSelection->addStringToSelection("mkdir "); | ||
157 | m_PlayListSelection->addStringToSelection("mv "); | ||
158 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); | ||
159 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); | ||
160 | m_PlayListSelection->addStringToSelection("nslookup "); | ||
161 | m_PlayListSelection->addStringToSelection("ping "); | ||
162 | m_PlayListSelection->addStringToSelection("ps aux"); | ||
163 | m_PlayListSelection->addStringToSelection("pwd "); | ||
164 | m_PlayListSelection->addStringToSelection("rm "); | ||
165 | m_PlayListSelection->addStringToSelection("rmdir "); | ||
166 | m_PlayListSelection->addStringToSelection("route "); | ||
167 | m_PlayListSelection->addStringToSelection("set "); | ||
168 | m_PlayListSelection->addStringToSelection("traceroute"); | ||
169 | |||
170 | } | ||
171 | } | ||
172 | CommandEditDialog::~CommandEditDialog() | ||
173 | { | ||
174 | } | ||
175 | |||
176 | void CommandEditDialog::accept() | ||
177 | { | ||
178 | int i = 0; | ||
179 | Config *cfg = new Config("Konsole"); | ||
180 | cfg->setGroup("Commands"); | ||
181 | cfg->clearGroup(); | ||
182 | |||
183 | QListViewItemIterator it( m_PlayListSelection ); | ||
184 | |||
185 | for ( ; it.current(); ++it ) { | ||
186 | // qDebug(it.current()->text(0)); | ||
187 | cfg->writeEntry(QString::number(i),it.current()->text(0)); | ||
188 | i++; | ||
189 | |||
190 | } | ||
191 | cfg->writeEntry("Commands Set","TRUE"); | ||
192 | // qDebug("CommandEditDialog::accept() - written"); | ||
193 | delete cfg; | ||
194 | emit commandsEdited(); | ||
195 | close(); | ||
196 | |||
197 | |||
198 | |||
199 | |||
200 | |||
201 | } | ||
202 | |||
203 | void CommandEditDialog::showEditDialog() | ||
204 | { | ||
205 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | ||
206 | d->setCaption("Edit command"); | ||
207 | d->TextLabel->setText("Edit command:"); | ||
208 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); | ||
209 | int i = d->exec(); | ||
210 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | ||
211 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); | ||
212 | } | ||
213 | |||
214 | void CommandEditDialog::showAddDialog() | ||
215 | { | ||
216 | |||
217 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | ||
218 | int i = d->exec(); | ||
219 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | ||
220 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); | ||
221 | |||
222 | } | ||
223 | |||
224 | |||