author | llornkcor <llornkcor> | 2002-04-28 13:20:23 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-28 13:20:23 (UTC) |
commit | 495103fd36f52dad3a564b924326519c9f52ccaf (patch) (unidiff) | |
tree | 22a26ab944ee236c5df7cc2fe8f394fee7b91236 | |
parent | ee6fdf8783f7a2fa91792e2f0ce0f8350f8cac0d (diff) | |
download | opie-495103fd36f52dad3a564b924326519c9f52ccaf.zip opie-495103fd36f52dad3a564b924326519c9f52ccaf.tar.gz opie-495103fd36f52dad3a564b924326519c9f52ccaf.tar.bz2 |
added qpeDir icon, added ability to execute with 'open'
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 91 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 3 |
2 files changed, 69 insertions, 25 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index bb932c5..ab31c91 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,1480 +1,1523 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #define DEVELOPERS_VERSION | 12 | #define DEVELOPERS_VERSION |
13 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties | 13 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties |
14 | 14 | ||
15 | #include "advancedfm.h" | 15 | #include "advancedfm.h" |
16 | #include "inputDialog.h" | 16 | #include "inputDialog.h" |
17 | #include "filePermissions.h" | 17 | #include "filePermissions.h" |
18 | #include "output.h" | 18 | #include "output.h" |
19 | 19 | ||
20 | #include <qpe/lnkproperties.h> | 20 | #include <qpe/lnkproperties.h> |
21 | #include <qpe/filemanager.h> | 21 | #include <qpe/filemanager.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qcopenvelope_qws.h> | 27 | #include <qpe/qcopenvelope_qws.h> |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #include <qpe/mimetype.h> | 29 | #include <qpe/mimetype.h> |
30 | #include <qpe/applnk.h> | 30 | #include <qpe/applnk.h> |
31 | 31 | ||
32 | //#include <opie/ofileselector.h> | 32 | //#include <opie/ofileselector.h> |
33 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
34 | 34 | ||
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qpushbutton.h> | 36 | #include <qpushbutton.h> |
37 | #include <qtoolbutton.h> | 37 | #include <qtoolbutton.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qstring.h> | 41 | #include <qstring.h> |
42 | #include <qcombobox.h> | 42 | #include <qcombobox.h> |
43 | #include <qpopupmenu.h> | 43 | #include <qpopupmenu.h> |
44 | #include <qlistview.h> | 44 | #include <qlistview.h> |
45 | #include <qmainwindow.h> | 45 | #include <qmainwindow.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qprogressbar.h> | 47 | #include <qprogressbar.h> |
48 | #include <qspinbox.h> | 48 | #include <qspinbox.h> |
49 | #include <qtabwidget.h> | 49 | #include <qtabwidget.h> |
50 | #include <qwidget.h> | 50 | #include <qwidget.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qimage.h> | 52 | #include <qimage.h> |
53 | #include <qpixmap.h> | 53 | #include <qpixmap.h> |
54 | #include <qmessagebox.h> | 54 | #include <qmessagebox.h> |
55 | #include <qlineedit.h> | 55 | #include <qlineedit.h> |
56 | #include <qregexp.h> | 56 | #include <qregexp.h> |
57 | 57 | ||
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #include <stdlib.h> | 59 | #include <stdlib.h> |
60 | #include <sys/stat.h> | 60 | #include <sys/stat.h> |
61 | #include <dirent.h> | 61 | #include <dirent.h> |
62 | #include <stdio.h> | 62 | #include <stdio.h> |
63 | #include <time.h> | 63 | #include <time.h> |
64 | #include <fcntl.h> | 64 | #include <fcntl.h> |
65 | 65 | ||
66 | AdvancedFm::AdvancedFm( ) | 66 | AdvancedFm::AdvancedFm( ) |
67 | : QMainWindow( ) | 67 | : QMainWindow( ) |
68 | { | 68 | { |
69 | setCaption( tr( "AdvancedFm" ) ); | 69 | setCaption( tr( "AdvancedFm" ) ); |
70 | 70 | ||
71 | QGridLayout *layout = new QGridLayout( this ); | 71 | QGridLayout *layout = new QGridLayout( this ); |
72 | layout->setSpacing( 2); | 72 | layout->setSpacing( 2); |
73 | layout->setMargin( 2); | 73 | layout->setMargin( 2); |
74 | 74 | ||
75 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 75 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
76 | 76 | ||
77 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 77 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
78 | // fileMenu = new QPopupMenu( this ); | 78 | // fileMenu = new QPopupMenu( this ); |
79 | fileMenu = new QPopupMenu( this ); | 79 | fileMenu = new QPopupMenu( this ); |
80 | viewMenu = new QPopupMenu( this ); | 80 | viewMenu = new QPopupMenu( this ); |
81 | 81 | ||
82 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); | 82 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); |
83 | 83 | ||
84 | menuBar->insertItem( tr( "File" ), fileMenu); | 84 | menuBar->insertItem( tr( "File" ), fileMenu); |
85 | menuBar->insertItem( tr( "View" ), viewMenu); | 85 | menuBar->insertItem( tr( "View" ), viewMenu); |
86 | 86 | ||
87 | qpeDirButton= new QPushButton(Resource::loadIconSet("go"),"",this,"QPEButton"); | ||
88 | qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); | ||
89 | connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); | ||
90 | qpeDirButton->setFlat(TRUE); | ||
91 | layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); | ||
92 | |||
87 | cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton"); | 93 | cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton"); |
88 | cfButton ->setFixedSize( QSize( 20, 20 ) ); | 94 | cfButton ->setFixedSize( QSize( 20, 20 ) ); |
89 | connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); | 95 | connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); |
90 | cfButton->setFlat(TRUE); | 96 | cfButton->setFlat(TRUE); |
91 | layout->addMultiCellWidget( cfButton , 0, 0, 2, 2); | 97 | layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); |
92 | 98 | ||
93 | sdButton = new QPushButton(Resource::loadIconSet("sdmon/sdcard"),"",this,"SDButton"); | 99 | sdButton = new QPushButton(Resource::loadIconSet("sdmon/sdcard"),"",this,"SDButton"); |
94 | sdButton->setFixedSize( QSize( 20, 20 ) ); | 100 | sdButton->setFixedSize( QSize( 20, 20 ) ); |
95 | connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); | 101 | connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); |
96 | sdButton->setFlat(TRUE); | 102 | sdButton->setFlat(TRUE); |
97 | layout->addMultiCellWidget( sdButton , 0, 0, 3, 3); | 103 | layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); |
98 | 104 | ||
99 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); | 105 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); |
100 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); | 106 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); |
101 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 107 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
102 | cdUpButton ->setFlat(TRUE); | 108 | cdUpButton ->setFlat(TRUE); |
103 | layout->addMultiCellWidget( cdUpButton , 0, 0, 4, 4); | 109 | layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); |
104 | 110 | ||
105 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 111 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
106 | docButton->setFixedSize( QSize( 20, 20 ) ); | 112 | docButton->setFixedSize( QSize( 20, 20 ) ); |
107 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 113 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
108 | docButton->setFlat(TRUE); | 114 | docButton->setFlat(TRUE); |
109 | layout->addMultiCellWidget( docButton, 0, 0, 5, 5); | 115 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6); |
110 | 116 | ||
111 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 117 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
112 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 118 | homeButton->setFixedSize( QSize( 20, 20 ) ); |
113 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 119 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
114 | homeButton->setFlat(TRUE); | 120 | homeButton->setFlat(TRUE); |
115 | layout->addMultiCellWidget( homeButton, 0, 0, 6, 6); | 121 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); |
116 | // fileMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 122 | // fileMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
117 | // fileMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 123 | // fileMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
118 | // fileMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 124 | // fileMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
119 | 125 | ||
120 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 126 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
121 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 127 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
122 | fileMenu->insertSeparator(); | 128 | fileMenu->insertSeparator(); |
123 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); | 129 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); |
124 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); | 130 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); |
125 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); | 131 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); |
126 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); | 132 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); |
127 | fileMenu->insertSeparator(); | 133 | fileMenu->insertSeparator(); |
128 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); | 134 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); |
129 | fileMenu->setCheckable(TRUE); | 135 | fileMenu->setCheckable(TRUE); |
130 | 136 | ||
131 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 137 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
132 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 138 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
133 | viewMenu->insertSeparator(); | 139 | viewMenu->insertSeparator(); |
134 | viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 140 | viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
135 | viewMenu->setCheckable(TRUE); | 141 | viewMenu->setCheckable(TRUE); |
136 | 142 | ||
137 | TabWidget = new QTabWidget( this, "TabWidget" ); | 143 | TabWidget = new QTabWidget( this, "TabWidget" ); |
138 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 6); | 144 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 7); |
139 | 145 | ||
140 | tab = new QWidget( TabWidget, "tab" ); | 146 | tab = new QWidget( TabWidget, "tab" ); |
141 | tabLayout = new QGridLayout( tab ); | 147 | tabLayout = new QGridLayout( tab ); |
142 | tabLayout->setSpacing( 2); | 148 | tabLayout->setSpacing( 2); |
143 | tabLayout->setMargin( 2); | 149 | tabLayout->setMargin( 2); |
144 | 150 | ||
145 | Local_View = new QListView( tab, "Local_View" ); | 151 | Local_View = new QListView( tab, "Local_View" ); |
146 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 152 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
147 | Local_View->addColumn( tr("File"),130); | 153 | Local_View->addColumn( tr("File"),130); |
148 | Local_View->addColumn( tr("Size"),-1); | 154 | Local_View->addColumn( tr("Size"),-1); |
149 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 155 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
150 | Local_View->addColumn( tr("Date"),-1); | 156 | Local_View->addColumn( tr("Date"),-1); |
151 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 157 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
152 | Local_View->setAllColumnsShowFocus(TRUE); | 158 | Local_View->setAllColumnsShowFocus(TRUE); |
153 | Local_View->setMultiSelection( TRUE ); | 159 | Local_View->setMultiSelection( TRUE ); |
154 | Local_View->setSelectionMode(QListView::Extended); | 160 | Local_View->setSelectionMode(QListView::Extended); |
155 | 161 | ||
156 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 162 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
157 | 163 | ||
158 | tabLayout->addWidget( Local_View, 0, 0 ); | 164 | tabLayout->addWidget( Local_View, 0, 0 ); |
159 | 165 | ||
160 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 166 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
161 | this,SLOT( localListClicked(QListViewItem *)) ); | 167 | this,SLOT( localListClicked(QListViewItem *)) ); |
162 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 168 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
163 | this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); | 169 | this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); |
164 | 170 | ||
165 | TabWidget->insertTab( tab, tr("1")); | 171 | TabWidget->insertTab( tab, tr("1")); |
166 | 172 | ||
167 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 173 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
168 | tabLayout_2 = new QGridLayout( tab_2 ); | 174 | tabLayout_2 = new QGridLayout( tab_2 ); |
169 | tabLayout_2->setSpacing( 2); | 175 | tabLayout_2->setSpacing( 2); |
170 | tabLayout_2->setMargin( 2); | 176 | tabLayout_2->setMargin( 2); |
171 | 177 | ||
172 | Remote_View = new QListView( tab_2, "Remote_View" ); | 178 | Remote_View = new QListView( tab_2, "Remote_View" ); |
173 | Remote_View->addColumn( tr("File"),130); | 179 | Remote_View->addColumn( tr("File"),130); |
174 | Remote_View->addColumn( tr("Size"),-1); | 180 | Remote_View->addColumn( tr("Size"),-1); |
175 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 181 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
176 | Remote_View->addColumn( tr("Date"),-1); | 182 | Remote_View->addColumn( tr("Date"),-1); |
177 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 183 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
178 | Remote_View->setAllColumnsShowFocus(TRUE); | 184 | Remote_View->setAllColumnsShowFocus(TRUE); |
179 | Remote_View->setMultiSelection( TRUE ); | 185 | Remote_View->setMultiSelection( TRUE ); |
180 | Remote_View->setSelectionMode(QListView::Extended); | 186 | Remote_View->setSelectionMode(QListView::Extended); |
181 | 187 | ||
182 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 188 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
183 | 189 | ||
184 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 190 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
185 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 191 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
186 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 192 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
187 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 193 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
188 | 194 | ||
189 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 195 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
190 | 196 | ||
191 | TabWidget->insertTab( tab_2, tr( "2")); | 197 | TabWidget->insertTab( tab_2, tr( "2")); |
192 | 198 | ||
193 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 199 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
194 | this,SLOT(tabChanged(QWidget*))); | 200 | this,SLOT(tabChanged(QWidget*))); |
195 | 201 | ||
196 | // tab_3 = new QWidget( TabWidget, "tab_3" ); | 202 | // tab_3 = new QWidget( TabWidget, "tab_3" ); |
197 | // tabLayout_3 = new QGridLayout( tab_3 ); | 203 | // tabLayout_3 = new QGridLayout( tab_3 ); |
198 | // tabLayout_3->setSpacing( 2); | 204 | // tabLayout_3->setSpacing( 2); |
199 | // tabLayout_3->setMargin( 2); | 205 | // tabLayout_3->setMargin( 2); |
200 | 206 | ||
201 | // OFileSelector *fileSelector; | 207 | // OFileSelector *fileSelector; |
202 | // fileSelector = new OFileSelector(tab_3,0,0,"/","","*"); | 208 | // fileSelector = new OFileSelector(tab_3,0,0,"/","","*"); |
203 | // tabLayout_3->addMultiCellWidget( fileSelector, 0, 0, 0, 3 ); | 209 | // tabLayout_3->addMultiCellWidget( fileSelector, 0, 0, 0, 3 ); |
204 | 210 | ||
205 | // TabWidget->insertTab( tab_3, tr( "Files" ) ); | 211 | // TabWidget->insertTab( tab_3, tr( "Files" ) ); |
206 | 212 | ||
207 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 213 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
208 | currentDir.setPath( QDir::currentDirPath()); | 214 | currentDir.setPath( QDir::currentDirPath()); |
209 | 215 | ||
210 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 216 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
211 | currentRemoteDir.setPath( QDir::currentDirPath()); | 217 | currentRemoteDir.setPath( QDir::currentDirPath()); |
212 | 218 | ||
213 | b = TRUE; | 219 | b = TRUE; |
214 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 220 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
215 | currentPathCombo->setEditable(TRUE); | 221 | currentPathCombo->setEditable(TRUE); |
216 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 6); | 222 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7); |
217 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 223 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
218 | 224 | ||
219 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 225 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
220 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 226 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
221 | 227 | ||
222 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 228 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
223 | this,SLOT(currentPathComboChanged())); | 229 | this,SLOT(currentPathComboChanged())); |
224 | 230 | ||
225 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 231 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
226 | 232 | ||
227 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 6); | 233 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7); |
228 | 234 | ||
229 | filterStr="*"; | 235 | filterStr="*"; |
230 | b=FALSE; | 236 | b=FALSE; |
231 | populateLocalView(); | 237 | populateLocalView(); |
232 | populateRemoteView(); | 238 | populateRemoteView(); |
233 | } | 239 | } |
234 | 240 | ||
235 | AdvancedFm::~AdvancedFm() | 241 | AdvancedFm::~AdvancedFm() |
236 | { | 242 | { |
237 | } | 243 | } |
238 | 244 | ||
239 | void AdvancedFm::cleanUp() | 245 | void AdvancedFm::cleanUp() |
240 | { | 246 | { |
241 | QString sfile=QDir::homeDirPath(); | 247 | QString sfile=QDir::homeDirPath(); |
242 | if(sfile.right(1) != "/") | 248 | if(sfile.right(1) != "/") |
243 | sfile+="/._temp"; | 249 | sfile+="/._temp"; |
244 | else | 250 | else |
245 | sfile+="._temp"; | 251 | sfile+="._temp"; |
246 | QFile file( sfile); | 252 | QFile file( sfile); |
247 | if(file.exists()) | 253 | if(file.exists()) |
248 | file.remove(); | 254 | file.remove(); |
249 | } | 255 | } |
250 | 256 | ||
251 | void AdvancedFm::tabChanged(QWidget *w) | 257 | void AdvancedFm::tabChanged(QWidget *w) |
252 | { | 258 | { |
253 | if (TabWidget->currentPageIndex() == 0) { | 259 | if (TabWidget->currentPageIndex() == 0) { |
254 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 260 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
255 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 261 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
256 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 262 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
257 | } | 263 | } |
258 | if (TabWidget->currentPageIndex() == 1) { | 264 | if (TabWidget->currentPageIndex() == 1) { |
259 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 265 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
260 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 266 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
261 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 267 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
262 | } | 268 | } |
263 | } | 269 | } |
264 | 270 | ||
265 | 271 | ||
266 | void AdvancedFm::populateLocalView() | 272 | void AdvancedFm::populateLocalView() |
267 | { | 273 | { |
268 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 274 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
269 | // QListViewItemIterator it( Local_View ); | 275 | // QListViewItemIterator it( Local_View ); |
270 | // for ( ; it.current(); ++it ) { | 276 | // for ( ; it.current(); ++it ) { |
271 | // if ( it.current()->isSelected() ) { | 277 | // if ( it.current()->isSelected() ) { |
272 | // QString strItem = it.current()->text(0); | 278 | // QString strItem = it.current()->text(0); |
273 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | 279 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; |
274 | // QFileInfo fi(localFile); | 280 | // QFileInfo fi(localFile); |
275 | // } | 281 | // } |
276 | // } | 282 | // } |
277 | QPixmap pm; | 283 | QPixmap pm; |
278 | Local_View->clear(); | 284 | Local_View->clear(); |
279 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 285 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
280 | currentDir.setMatchAllDirs(TRUE); | 286 | currentDir.setMatchAllDirs(TRUE); |
281 | currentDir.setNameFilter(filterStr); | 287 | currentDir.setNameFilter(filterStr); |
282 | QString fileL, fileS, fileDate; | 288 | QString fileL, fileS, fileDate; |
283 | // qDebug(currentDir.canonicalPath()); | 289 | // qDebug(currentDir.canonicalPath()); |
284 | 290 | ||
285 | bool isDir=FALSE; | 291 | bool isDir=FALSE; |
286 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 292 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
287 | QFileInfoListIterator it(*list); | 293 | QFileInfoListIterator it(*list); |
288 | QFileInfo *fi; | 294 | QFileInfo *fi; |
289 | while ( (fi=it.current()) ) { | 295 | while ( (fi=it.current()) ) { |
290 | if (fi->isSymLink() ) { | 296 | if (fi->isSymLink() ) { |
291 | QString symLink=fi->readLink(); | 297 | QString symLink=fi->readLink(); |
292 | // qDebug("Symlink detected "+symLink); | 298 | // qDebug("Symlink detected "+symLink); |
293 | QFileInfo sym( symLink); | 299 | QFileInfo sym( symLink); |
294 | fileS.sprintf( "%10li", sym.size() ); | 300 | fileS.sprintf( "%10li", sym.size() ); |
295 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 301 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
296 | fileDate = sym.lastModified().toString(); | 302 | fileDate = sym.lastModified().toString(); |
297 | } else { | 303 | } else { |
298 | fileS.sprintf( "%10li", fi->size() ); | 304 | fileS.sprintf( "%10li", fi->size() ); |
299 | fileL.sprintf( "%s",fi->fileName().data() ); | 305 | fileL.sprintf( "%s",fi->fileName().data() ); |
300 | fileDate= fi->lastModified().toString(); | 306 | fileDate= fi->lastModified().toString(); |
301 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 307 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
302 | fileL+="/"; | 308 | fileL+="/"; |
303 | isDir=TRUE; | 309 | isDir=TRUE; |
304 | // qDebug( fileL); | 310 | // qDebug( fileL); |
305 | } | 311 | } |
306 | } | 312 | } |
307 | if(fileL !="./" && fi->exists()) { | 313 | if(fileL !="./" && fi->exists()) { |
308 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 314 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
309 | |||
310 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 315 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
311 | if( !QDir( fi->filePath() ).isReadable()) | 316 | if( !QDir( fi->filePath() ).isReadable()) |
312 | pm = Resource::loadPixmap( "lockedfolder" ); | 317 | pm = Resource::loadPixmap( "lockedfolder" ); |
313 | else | 318 | else |
314 | pm= Resource::loadPixmap( "folder" ); | 319 | pm= Resource::loadPixmap( "folder" ); |
315 | item->setPixmap( 0,pm ); | 320 | item->setPixmap( 0,pm ); |
316 | } else { | 321 | } else { |
317 | if( !fi->isReadable() ) | 322 | if(fi->isExecutable()) { |
323 | pm = Resource::loadPixmap( "exec"); | ||
324 | item->setPixmap( 0,pm); | ||
325 | } | ||
326 | else if( !fi->isReadable() ) { | ||
318 | pm = Resource::loadPixmap( "locked" ); | 327 | pm = Resource::loadPixmap( "locked" ); |
328 | item->setPixmap( 0,pm); | ||
329 | |||
330 | } | ||
319 | else { | 331 | else { |
320 | MimeType mt(fi->filePath()); | 332 | MimeType mt(fi->filePath()); |
321 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 333 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
322 | if(pm.isNull()) | 334 | if(pm.isNull()) |
323 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 335 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
324 | item->setPixmap( 0,pm); | 336 | item->setPixmap( 0,pm); |
325 | } | 337 | } |
326 | } | 338 | } |
327 | if( fileL.find("->",0,TRUE) != -1) { | 339 | if( fileL.find("->",0,TRUE) != -1) { |
328 | // overlay link image | 340 | // overlay link image |
329 | pm= Resource::loadPixmap( "folder" ); | 341 | pm= Resource::loadPixmap( "folder" ); |
330 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 342 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
331 | QPainter painter( &pm ); | 343 | QPainter painter( &pm ); |
332 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 344 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
333 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 345 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
334 | item->setPixmap( 0, pm); | 346 | item->setPixmap( 0, pm); |
335 | } | 347 | } |
336 | } isDir=FALSE; | 348 | } isDir=FALSE; |
337 | ++it; | 349 | ++it; |
338 | } | 350 | } |
339 | 351 | ||
340 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { | 352 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { |
341 | struct stat buf; | 353 | struct stat buf; |
342 | struct stat st; | 354 | struct stat st; |
343 | dev_t devT; | 355 | dev_t devT; |
344 | mode_t mode; | 356 | mode_t mode; |
345 | DIR *dir; | 357 | DIR *dir; |
346 | int fd = 0; | 358 | int fd = 0; |
347 | struct dirent *mydirent; | 359 | struct dirent *mydirent; |
348 | int i = 1; | 360 | int i = 1; |
349 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 361 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) |
350 | while ((mydirent = readdir(dir)) != NULL) { | 362 | while ((mydirent = readdir(dir)) != NULL) { |
351 | lstat( mydirent->d_name, &buf); | 363 | lstat( mydirent->d_name, &buf); |
352 | qDebug(mydirent->d_name); | 364 | qDebug(mydirent->d_name); |
353 | // mode = buf.st_mode; | 365 | // mode = buf.st_mode; |
354 | fileL.sprintf("%s", mydirent->d_name); | 366 | fileL.sprintf("%s", mydirent->d_name); |
355 | // fileS.sprintf("%d, %d", ); //this isn't correct | 367 | // fileS.sprintf("%d, %d", ); //this isn't correct |
356 | devT = buf.st_dev; | 368 | devT = buf.st_dev; |
357 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 369 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
358 | // fileS.sprintf("%d,%d", devT, devT); | 370 | // fileS.sprintf("%d,%d", devT, devT); |
359 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 371 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
360 | if( fileL.find(".") == -1 ){ | 372 | if( fileL.find(".") == -1 ){ |
361 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 373 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
362 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 374 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
363 | item->setPixmap( 0,pm); | 375 | item->setPixmap( 0,pm); |
364 | } | 376 | } |
365 | } | 377 | } |
366 | 378 | ||
367 | closedir(dir); | 379 | closedir(dir); |
368 | } | 380 | } |
369 | 381 | ||
370 | Local_View->setSorting( 3,FALSE); | 382 | Local_View->setSorting( 3,FALSE); |
371 | fillCombo( (const QString &) currentDir.canonicalPath()); | 383 | fillCombo( (const QString &) currentDir.canonicalPath()); |
372 | } | 384 | } |
373 | 385 | ||
374 | 386 | ||
375 | void AdvancedFm::populateRemoteView() | 387 | void AdvancedFm::populateRemoteView() |
376 | { | 388 | { |
377 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 389 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
378 | // QListViewItemIterator it( Remote_View ); | 390 | // QListViewItemIterator it( Remote_View ); |
379 | // for ( ; it.current(); ++it ) { | 391 | // for ( ; it.current(); ++it ) { |
380 | // if ( it.current()->isSelected() ) { | 392 | // if ( it.current()->isSelected() ) { |
381 | // QString strItem = it.current()->text(0); | 393 | // QString strItem = it.current()->text(0); |
382 | // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; | 394 | // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; |
383 | // QFileInfo fi(localFile); | 395 | // QFileInfo fi(localFile); |
384 | // } | 396 | // } |
385 | // } | 397 | // } |
386 | QPixmap pm; | 398 | QPixmap pm; |
387 | Remote_View->clear(); | 399 | Remote_View->clear(); |
388 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 400 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
389 | currentRemoteDir.setMatchAllDirs(TRUE); | 401 | currentRemoteDir.setMatchAllDirs(TRUE); |
390 | currentRemoteDir.setNameFilter(filterStr); | 402 | currentRemoteDir.setNameFilter(filterStr); |
391 | QString fileL, fileS, fileDate; | 403 | QString fileL, fileS, fileDate; |
392 | bool isDir=FALSE; | 404 | bool isDir=FALSE; |
393 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 405 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
394 | QFileInfoListIterator it(*list); | 406 | QFileInfoListIterator it(*list); |
395 | QFileInfo *fi; | 407 | QFileInfo *fi; |
396 | while ( (fi=it.current()) ) { | 408 | while ( (fi=it.current()) ) { |
397 | if (fi->isSymLink() ){ | 409 | if (fi->isSymLink() ){ |
398 | QString symLink=fi->readLink(); | 410 | QString symLink=fi->readLink(); |
399 | // qDebug("Symlink detected "+symLink); | 411 | // qDebug("Symlink detected "+symLink); |
400 | QFileInfo sym( symLink); | 412 | QFileInfo sym( symLink); |
401 | fileS.sprintf( "%10li", sym.size() ); | 413 | fileS.sprintf( "%10li", sym.size() ); |
402 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 414 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
403 | fileDate = sym.lastModified().toString(); | 415 | fileDate = sym.lastModified().toString(); |
404 | } else { | 416 | } else { |
405 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 417 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
406 | fileS.sprintf( "%10li", fi->size() ); | 418 | fileS.sprintf( "%10li", fi->size() ); |
407 | fileL.sprintf( "%s",fi->fileName().data() ); | 419 | fileL.sprintf( "%s",fi->fileName().data() ); |
408 | fileDate= fi->lastModified().toString(); | 420 | fileDate= fi->lastModified().toString(); |
409 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 421 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
410 | fileL+="/"; | 422 | fileL+="/"; |
411 | isDir=TRUE; | 423 | isDir=TRUE; |
412 | // qDebug( fileL); | 424 | // qDebug( fileL); |
413 | } | 425 | } |
414 | } | 426 | } |
415 | if(fileL !="./" && fi->exists()) { | 427 | if(fileL !="./" && fi->exists()) { |
416 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 428 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
417 | QPixmap pm; | 429 | QPixmap pm; |
418 | 430 | ||
419 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 431 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
420 | if( !QDir( fi->filePath() ).isReadable()) | 432 | if( !QDir( fi->filePath() ).isReadable()) |
421 | pm = Resource::loadPixmap( "lockedfolder" ); | 433 | pm = Resource::loadPixmap( "lockedfolder" ); |
422 | else | 434 | else |
423 | pm= Resource::loadPixmap( "folder" ); | 435 | pm= Resource::loadPixmap( "folder" ); |
424 | item->setPixmap( 0,pm ); | 436 | item->setPixmap( 0,pm ); |
425 | } else { | 437 | } else { |
426 | if( !fi->isReadable() ) | 438 | if(fi->isExecutable()) { |
439 | pm = Resource::loadPixmap( "exec"); | ||
440 | item->setPixmap( 0,pm); | ||
441 | } | ||
442 | else if( !fi->isReadable() ) { | ||
427 | pm = Resource::loadPixmap( "locked" ); | 443 | pm = Resource::loadPixmap( "locked" ); |
428 | else { | 444 | item->setPixmap( 0,pm); |
445 | } else { | ||
429 | MimeType mt(fi->filePath()); | 446 | MimeType mt(fi->filePath()); |
430 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 447 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
431 | if(pm.isNull()) | 448 | if(pm.isNull()) |
432 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 449 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
433 | item->setPixmap( 0,pm); | 450 | item->setPixmap( 0,pm); |
434 | } | 451 | } |
435 | } | 452 | } |
436 | if( fileL.find("->",0,TRUE) != -1) { | 453 | if( fileL.find("->",0,TRUE) != -1) { |
437 | // overlay link image | 454 | // overlay link image |
438 | pm= Resource::loadPixmap( "folder" ); | 455 | pm= Resource::loadPixmap( "folder" ); |
439 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 456 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
440 | QPainter painter( &pm ); | 457 | QPainter painter( &pm ); |
441 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 458 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
442 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 459 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
443 | item->setPixmap( 0, pm); | 460 | item->setPixmap( 0, pm); |
444 | } | 461 | } |
445 | } isDir=FALSE; | 462 | } isDir=FALSE; |
446 | ++it; | 463 | ++it; |
447 | } | 464 | } |
448 | 465 | ||
449 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 466 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
450 | struct stat buf; | 467 | struct stat buf; |
451 | struct stat st; | 468 | struct stat st; |
452 | mode_t mode; | 469 | mode_t mode; |
453 | DIR *dir; | 470 | DIR *dir; |
454 | int fd = 0; | 471 | int fd = 0; |
455 | struct dirent *mydirent; | 472 | struct dirent *mydirent; |
456 | int i = 1; | 473 | int i = 1; |
457 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 474 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
458 | while ((mydirent = readdir(dir)) != NULL) { | 475 | while ((mydirent = readdir(dir)) != NULL) { |
459 | lstat( mydirent->d_name, &buf); | 476 | lstat( mydirent->d_name, &buf); |
460 | qDebug(mydirent->d_name); | 477 | qDebug(mydirent->d_name); |
461 | // mode = buf.st_mode; | 478 | // mode = buf.st_mode; |
462 | fileL.sprintf("%s", mydirent->d_name); | 479 | fileL.sprintf("%s", mydirent->d_name); |
463 | // fileS.sprintf("%d, %d", ); //this isn't correct | 480 | // fileS.sprintf("%d, %d", ); //this isn't correct |
464 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 481 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
465 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 482 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
466 | if( fileL.find(".") == -1 ){ | 483 | if( fileL.find(".") == -1 ){ |
467 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 484 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
468 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 485 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
469 | item->setPixmap( 0,pm); | 486 | item->setPixmap( 0,pm); |
470 | } | 487 | } |
471 | } | 488 | } |
472 | 489 | ||
473 | closedir(dir); | 490 | closedir(dir); |
474 | } | 491 | } |
475 | 492 | ||
476 | Remote_View->setSorting( 3,FALSE); | 493 | Remote_View->setSorting( 3,FALSE); |
477 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | 494 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); |
478 | } | 495 | } |
479 | 496 | ||
480 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) | 497 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) |
481 | { | 498 | { |
482 | if(selectedItem) { | 499 | if(selectedItem) { |
483 | QString strItem=selectedItem->text(0); | 500 | QString strItem=selectedItem->text(0); |
484 | QString strSize=selectedItem->text(1); | 501 | QString strSize=selectedItem->text(1); |
485 | strSize=strSize.stripWhiteSpace(); | 502 | strSize=strSize.stripWhiteSpace(); |
486 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 503 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
487 | // is symlink | 504 | // is symlink |
488 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 505 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
489 | if(QDir(strItem2).exists() ) { | 506 | if(QDir(strItem2).exists() ) { |
490 | currentDir.cd(strItem2, TRUE); | 507 | currentDir.cd(strItem2, TRUE); |
491 | populateLocalView(); | 508 | populateLocalView(); |
492 | } | 509 | } |
493 | } else { // not a symlink | 510 | } else { // not a symlink |
494 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 511 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
495 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 512 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
496 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 513 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
497 | currentDir.cd(strItem,FALSE); | 514 | currentDir.cd(strItem,FALSE); |
498 | populateLocalView(); | 515 | populateLocalView(); |
499 | } else { | 516 | } else { |
500 | currentDir.cdUp(); | 517 | currentDir.cdUp(); |
501 | populateLocalView(); | 518 | populateLocalView(); |
502 | } | 519 | } |
503 | if(QDir(strItem).exists()){ | 520 | if(QDir(strItem).exists()){ |
504 | currentDir.cd(strItem, TRUE); | 521 | currentDir.cd(strItem, TRUE); |
505 | populateLocalView(); | 522 | populateLocalView(); |
506 | } | 523 | } |
507 | } else { | 524 | } else { |
508 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 525 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
509 | if( QFile::exists(strItem ) ) { | 526 | if( QFile::exists(strItem ) ) { |
510 | // qDebug("upload "+strItem); | 527 | // qDebug("upload "+strItem); |
511 | } | 528 | } |
512 | } //end not symlink | 529 | } //end not symlink |
513 | chdir(strItem.latin1()); | 530 | chdir(strItem.latin1()); |
514 | } | 531 | } |
515 | } | 532 | } |
516 | } | 533 | } |
517 | 534 | ||
518 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) | 535 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) |
519 | { | 536 | { |
520 | if(selectedItem) { | 537 | if(selectedItem) { |
521 | QString strItem=selectedItem->text(0); | 538 | QString strItem=selectedItem->text(0); |
522 | QString strSize=selectedItem->text(1); | 539 | QString strSize=selectedItem->text(1); |
523 | strSize=strSize.stripWhiteSpace(); | 540 | strSize=strSize.stripWhiteSpace(); |
524 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 541 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
525 | // is symlink | 542 | // is symlink |
526 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 543 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
527 | if(QDir(strItem2).exists() ) { | 544 | if(QDir(strItem2).exists() ) { |
528 | currentRemoteDir.cd(strItem2, TRUE); | 545 | currentRemoteDir.cd(strItem2, TRUE); |
529 | populateRemoteView(); | 546 | populateRemoteView(); |
530 | } | 547 | } |
531 | } else { // not a symlink | 548 | } else { // not a symlink |
532 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 549 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
533 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { | 550 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { |
534 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 551 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
535 | currentRemoteDir.cd(strItem,FALSE); | 552 | currentRemoteDir.cd(strItem,FALSE); |
536 | populateRemoteView(); | 553 | populateRemoteView(); |
537 | } else { | 554 | } else { |
538 | currentRemoteDir.cdUp(); | 555 | currentRemoteDir.cdUp(); |
539 | populateRemoteView(); | 556 | populateRemoteView(); |
540 | } | 557 | } |
541 | if(QDir(strItem).exists()){ | 558 | if(QDir(strItem).exists()){ |
542 | currentRemoteDir.cd(strItem, TRUE); | 559 | currentRemoteDir.cd(strItem, TRUE); |
543 | populateRemoteView(); | 560 | populateRemoteView(); |
544 | } | 561 | } |
545 | } else { | 562 | } else { |
546 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 563 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
547 | if( QFile::exists(strItem ) ) { | 564 | if( QFile::exists(strItem ) ) { |
548 | // qDebug("upload "+strItem); | 565 | // qDebug("upload "+strItem); |
549 | } | 566 | } |
550 | } //end not symlink | 567 | } //end not symlink |
551 | chdir(strItem.latin1()); | 568 | chdir(strItem.latin1()); |
552 | } | 569 | } |
553 | } | 570 | } |
554 | } | 571 | } |
555 | 572 | ||
556 | void AdvancedFm::doLocalCd() | 573 | void AdvancedFm::doLocalCd() |
557 | { | 574 | { |
558 | localListClicked( Local_View->currentItem()); | 575 | localListClicked( Local_View->currentItem()); |
559 | } | 576 | } |
560 | 577 | ||
561 | void AdvancedFm::doRemoteCd() | 578 | void AdvancedFm::doRemoteCd() |
562 | { | 579 | { |
563 | localListClicked( Remote_View->currentItem()); | 580 | localListClicked( Remote_View->currentItem()); |
564 | } | 581 | } |
565 | 582 | ||
566 | void AdvancedFm::showHidden() | 583 | void AdvancedFm::showHidden() |
567 | { | 584 | { |
568 | if (b) { | 585 | if (b) { |
569 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 586 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
570 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 587 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
571 | // localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 588 | // localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
572 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 589 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
573 | b=FALSE; | 590 | b=FALSE; |
574 | 591 | ||
575 | } else { | 592 | } else { |
576 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 593 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
577 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 594 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
578 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 595 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
579 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 596 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
580 | b=TRUE; | 597 | b=TRUE; |
581 | } | 598 | } |
582 | populateLocalView(); | 599 | populateLocalView(); |
583 | 600 | ||
584 | } | 601 | } |
585 | 602 | ||
586 | void AdvancedFm::showRemoteHidden() | 603 | void AdvancedFm::showRemoteHidden() |
587 | { | 604 | { |
588 | if (b) { | 605 | if (b) { |
589 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 606 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
590 | // viewMenu->setItemChecked(localMenu->idAt(0),TRUE); | 607 | // viewMenu->setItemChecked(localMenu->idAt(0),TRUE); |
591 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 608 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
592 | b=TRUE; | 609 | b=TRUE; |
593 | 610 | ||
594 | } else { | 611 | } else { |
595 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 612 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
596 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 613 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
597 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 614 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
598 | b=FALSE; | 615 | b=FALSE; |
599 | } | 616 | } |
600 | populateRemoteView(); | 617 | populateRemoteView(); |
601 | } | 618 | } |
602 | 619 | ||
603 | void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 620 | void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
604 | { | 621 | { |
605 | switch (mouse) { | 622 | switch (mouse) { |
606 | case 1: | 623 | case 1: |
607 | break; | 624 | break; |
608 | case 2: | 625 | case 2: |
609 | showLocalMenu(item); | 626 | showLocalMenu(item); |
610 | Local_View->clearSelection(); | 627 | Local_View->clearSelection(); |
611 | break; | 628 | break; |
612 | }; | 629 | }; |
613 | } | 630 | } |
614 | 631 | ||
615 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 632 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
616 | { | 633 | { |
617 | switch (mouse) { | 634 | switch (mouse) { |
618 | case 1: | 635 | case 1: |
619 | break; | 636 | break; |
620 | case 2: | 637 | case 2: |
621 | showRemoteMenu(item); | 638 | showRemoteMenu(item); |
622 | Remote_View->clearSelection(); | 639 | Remote_View->clearSelection(); |
623 | break; | 640 | break; |
624 | }; | 641 | }; |
625 | } | 642 | } |
626 | 643 | ||
627 | void AdvancedFm::showLocalMenu(QListViewItem * item) | 644 | void AdvancedFm::showLocalMenu(QListViewItem * item) |
628 | { | 645 | { |
629 | if(item) { | 646 | if(item) { |
630 | QPopupMenu m; | 647 | QPopupMenu m; |
631 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 648 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
632 | m.insertSeparator(); | 649 | m.insertSeparator(); |
633 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 650 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
634 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 651 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
635 | else | 652 | else |
636 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); | 653 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); |
637 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); | 654 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); |
638 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 655 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
639 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 656 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
640 | m.insertSeparator(); | 657 | m.insertSeparator(); |
641 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 658 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
642 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); | 659 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); |
643 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 660 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
644 | m.insertItem( tr( "Move" ), this, SLOT( move() )); | 661 | m.insertItem( tr( "Move" ), this, SLOT( move() )); |
645 | m.insertSeparator(); | 662 | m.insertSeparator(); |
646 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 663 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
647 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 664 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
648 | m.insertSeparator(); | 665 | m.insertSeparator(); |
649 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 666 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
650 | m.insertSeparator(); | 667 | m.insertSeparator(); |
651 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 668 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
652 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 669 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
653 | m.setCheckable(TRUE); | 670 | m.setCheckable(TRUE); |
654 | if (!b) | 671 | if (!b) |
655 | m.setItemChecked(m.idAt(0),TRUE); | 672 | m.setItemChecked(m.idAt(0),TRUE); |
656 | else | 673 | else |
657 | m.setItemChecked(m.idAt(0),FALSE); | 674 | m.setItemChecked(m.idAt(0),FALSE); |
658 | m.exec( QCursor::pos() ); | 675 | m.exec( QCursor::pos() ); |
659 | } | 676 | } |
660 | } | 677 | } |
661 | 678 | ||
662 | void AdvancedFm::showRemoteMenu(QListViewItem * item) | 679 | void AdvancedFm::showRemoteMenu(QListViewItem * item) |
663 | { | 680 | { |
664 | if(item) { | 681 | if(item) { |
665 | QPopupMenu m; | 682 | QPopupMenu m; |
666 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); | 683 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); |
667 | m.insertSeparator(); | 684 | m.insertSeparator(); |
668 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 685 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
669 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 686 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
670 | else | 687 | else |
671 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); | 688 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); |
672 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); | 689 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); |
673 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 690 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
674 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 691 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
675 | m.insertSeparator(); | 692 | m.insertSeparator(); |
676 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 693 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
677 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); | 694 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); |
678 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 695 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
679 | m.insertItem( tr( "Move" ), this, SLOT( move() )); | 696 | m.insertItem( tr( "Move" ), this, SLOT( move() )); |
680 | m.insertSeparator(); | 697 | m.insertSeparator(); |
681 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 698 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
682 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 699 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
683 | m.insertSeparator(); | 700 | m.insertSeparator(); |
684 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 701 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
685 | m.insertSeparator(); | 702 | m.insertSeparator(); |
686 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 703 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
687 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 704 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
688 | m.setCheckable(TRUE); | 705 | m.setCheckable(TRUE); |
689 | if (!b) | 706 | if (!b) |
690 | m.setItemChecked(m.idAt(0),TRUE); | 707 | m.setItemChecked(m.idAt(0),TRUE); |
691 | else | 708 | else |
692 | m.setItemChecked(m.idAt(0),FALSE); | 709 | m.setItemChecked(m.idAt(0),FALSE); |
693 | m.exec( QCursor::pos() ); | 710 | m.exec( QCursor::pos() ); |
694 | } | 711 | } |
695 | } | 712 | } |
696 | 713 | ||
697 | void AdvancedFm::runThis() { | 714 | void AdvancedFm::runThis() { |
698 | // QFileInfo *fi; | 715 | // QFileInfo *fi; |
699 | if (TabWidget->currentPageIndex() == 0) { | 716 | if (TabWidget->currentPageIndex() == 0) { |
700 | QString curFile = Local_View->currentItem()->text(0); | 717 | QString curFile = Local_View->currentItem()->text(0); |
701 | curFile = currentDir.canonicalPath()+"/"+curFile; | 718 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); |
702 | DocLnk nf(curFile); | 719 | if(fileInfo.isExecutable()) { |
703 | QString execStr = nf.exec(); | 720 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
704 | qDebug( execStr); | 721 | e << curFile; |
705 | if( execStr.isEmpty() ) { | ||
706 | } else { | 722 | } else { |
707 | nf.execute(); | 723 | curFile = currentDir.canonicalPath()+"/"+curFile; |
724 | DocLnk nf(curFile); | ||
725 | QString execStr = nf.exec(); | ||
726 | qDebug( execStr); | ||
727 | if( execStr.isEmpty() ) { | ||
728 | } else { | ||
729 | nf.execute(); | ||
730 | } | ||
708 | } | 731 | } |
709 | // MimeType mt( curFile); | 732 | // MimeType mt( curFile); |
710 | } else { | 733 | } else { |
711 | QString curFile = Remote_View->currentItem()->text(0); | 734 | QString curFile = Remote_View->currentItem()->text(0); |
712 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 735 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); |
713 | DocLnk nf(curFile); | 736 | if(fileInfo.isExecutable()) { |
714 | QString execStr = nf.exec(); | 737 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
715 | qDebug(execStr); | 738 | e << curFile; |
716 | if( execStr.isEmpty() ) { | ||
717 | } else { | 739 | } else { |
718 | nf.execute(); | 740 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
741 | DocLnk nf(curFile); | ||
742 | QString execStr = nf.exec(); | ||
743 | qDebug(execStr); | ||
744 | if( execStr.isEmpty() ) { | ||
745 | } else { | ||
746 | nf.execute(); | ||
747 | } | ||
719 | } | 748 | } |
720 | // MimeType mt( curFile); | 749 | // MimeType mt( curFile); |
721 | } | 750 | } |
722 | } | 751 | } |
723 | 752 | ||
724 | void AdvancedFm::runText() { | 753 | void AdvancedFm::runText() { |
725 | if (TabWidget->currentPageIndex() == 0) { | 754 | if (TabWidget->currentPageIndex() == 0) { |
726 | QString curFile = Local_View->currentItem()->text(0); | 755 | QString curFile = Local_View->currentItem()->text(0); |
727 | curFile = currentDir.canonicalPath()+"/"+curFile; | 756 | curFile = currentDir.canonicalPath()+"/"+curFile; |
728 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 757 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
729 | e << curFile; | 758 | e << curFile; |
730 | } else { | 759 | } else { |
731 | QString curFile = Remote_View->currentItem()->text(0); | 760 | QString curFile = Remote_View->currentItem()->text(0); |
732 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 761 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
733 | DocLnk nf(curFile); | 762 | DocLnk nf(curFile); |
734 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 763 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
735 | e << curFile; | 764 | e << curFile; |
736 | } | 765 | } |
737 | } | 766 | } |
738 | 767 | ||
739 | void AdvancedFm::localMakDir() | 768 | void AdvancedFm::localMakDir() |
740 | { | 769 | { |
741 | InputDialog *fileDlg; | 770 | InputDialog *fileDlg; |
742 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 771 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
743 | fileDlg->exec(); | 772 | fileDlg->exec(); |
744 | if( fileDlg->result() == 1 ) { | 773 | if( fileDlg->result() == 1 ) { |
745 | QString filename = fileDlg->LineEdit1->text(); | 774 | QString filename = fileDlg->LineEdit1->text(); |
746 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 775 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
747 | } | 776 | } |
748 | populateLocalView(); | 777 | populateLocalView(); |
749 | } | 778 | } |
750 | 779 | ||
751 | void AdvancedFm::remoteMakDir() | 780 | void AdvancedFm::remoteMakDir() |
752 | { | 781 | { |
753 | InputDialog *fileDlg; | 782 | InputDialog *fileDlg; |
754 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 783 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
755 | fileDlg->exec(); | 784 | fileDlg->exec(); |
756 | if( fileDlg->result() == 1 ) { | 785 | if( fileDlg->result() == 1 ) { |
757 | QString filename = fileDlg->LineEdit1->text(); | 786 | QString filename = fileDlg->LineEdit1->text(); |
758 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | 787 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); |
759 | } | 788 | } |
760 | populateRemoteView(); | 789 | populateRemoteView(); |
761 | } | 790 | } |
762 | 791 | ||
763 | void AdvancedFm::localDelete() | 792 | void AdvancedFm::localDelete() |
764 | { | 793 | { |
765 | QStringList curFileList = getPath(); | 794 | QStringList curFileList = getPath(); |
766 | QString myFile; | 795 | QString myFile; |
767 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 796 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
768 | myFile = (*it); | 797 | myFile = (*it); |
769 | if( myFile.find(" -> ",0,TRUE) != -1) | 798 | if( myFile.find(" -> ",0,TRUE) != -1) |
770 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 799 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
771 | 800 | ||
772 | QString f = currentDir.canonicalPath()+"/"+myFile; | 801 | QString f = currentDir.canonicalPath()+"/"+myFile; |
773 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 802 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
774 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?" | 803 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?" |
775 | ,tr("Yes"),tr("No"),0,0,1) ) { | 804 | ,tr("Yes"),tr("No"),0,0,1) ) { |
776 | case 0: { | 805 | case 0: { |
777 | QString cmd="rmdir -rf "+f; | 806 | QString cmd="rmdir -rf "+f; |
778 | system( cmd.latin1()); | 807 | system( cmd.latin1()); |
779 | populateLocalView(); | 808 | populateLocalView(); |
780 | } | 809 | } |
781 | break; | 810 | break; |
782 | case 1: | 811 | case 1: |
783 | // exit | 812 | // exit |
784 | break; | 813 | break; |
785 | }; | 814 | }; |
786 | 815 | ||
787 | } else { | 816 | } else { |
788 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 817 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
789 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 818 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
790 | case 0: { | 819 | case 0: { |
791 | QString cmd="rm "+f; | 820 | QString cmd="rm "+f; |
792 | QFile file(f); | 821 | QFile file(f); |
793 | file.remove(); | 822 | file.remove(); |
794 | // system( cmd.latin1()); | 823 | // system( cmd.latin1()); |
795 | populateLocalView(); | 824 | populateLocalView(); |
796 | } | 825 | } |
797 | break; | 826 | break; |
798 | case 1: | 827 | case 1: |
799 | // exit | 828 | // exit |
800 | break; | 829 | break; |
801 | }; | 830 | }; |
802 | } | 831 | } |
803 | 832 | ||
804 | } | 833 | } |
805 | } | 834 | } |
806 | 835 | ||
807 | void AdvancedFm::remoteDelete() | 836 | void AdvancedFm::remoteDelete() |
808 | { | 837 | { |
809 | QStringList curFileList = getPath(); | 838 | QStringList curFileList = getPath(); |
810 | QString myFile; | 839 | QString myFile; |
811 | 840 | ||
812 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 841 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
813 | myFile = (*it); | 842 | myFile = (*it); |
814 | if(myFile.find(" -> ",0,TRUE) != -1) | 843 | if(myFile.find(" -> ",0,TRUE) != -1) |
815 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | 844 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); |
816 | QString f = currentRemoteDir.canonicalPath()+"/"+myFile; | 845 | QString f = currentRemoteDir.canonicalPath()+"/"+myFile; |
817 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 846 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
818 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?", | 847 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?", |
819 | tr("Yes"),tr("No"),0,0,1) ) { | 848 | tr("Yes"),tr("No"),0,0,1) ) { |
820 | case 0: { | 849 | case 0: { |
821 | QString cmd="rmdir -rf "+f; | 850 | QString cmd="rmdir -rf "+f; |
822 | system( cmd.latin1()); | 851 | system( cmd.latin1()); |
823 | populateRemoteView(); | 852 | populateRemoteView(); |
824 | } | 853 | } |
825 | break; | 854 | break; |
826 | case 1: | 855 | case 1: |
827 | // exit | 856 | // exit |
828 | break; | 857 | break; |
829 | }; | 858 | }; |
830 | 859 | ||
831 | } else { | 860 | } else { |
832 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 861 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
833 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 862 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
834 | case 0: { | 863 | case 0: { |
835 | QString cmd="rm "+f; | 864 | QString cmd="rm "+f; |
836 | QFile file(f); | 865 | QFile file(f); |
837 | file.remove(); | 866 | file.remove(); |
838 | // system( cmd.latin1()); | 867 | // system( cmd.latin1()); |
839 | populateRemoteView(); | 868 | populateRemoteView(); |
840 | } | 869 | } |
841 | break; | 870 | break; |
842 | case 1: | 871 | case 1: |
843 | // exit | 872 | // exit |
844 | break; | 873 | break; |
845 | }; | 874 | }; |
846 | } | 875 | } |
847 | } | 876 | } |
848 | } | 877 | } |
849 | 878 | ||
850 | void AdvancedFm::localRename() | 879 | void AdvancedFm::localRename() |
851 | { | 880 | { |
852 | QString curFile = Local_View->currentItem()->text(0); | 881 | QString curFile = Local_View->currentItem()->text(0); |
853 | InputDialog *fileDlg; | 882 | InputDialog *fileDlg; |
854 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 883 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
855 | fileDlg->setInputText((const QString &)curFile); | 884 | fileDlg->setInputText((const QString &)curFile); |
856 | fileDlg->exec(); | 885 | fileDlg->exec(); |
857 | if( fileDlg->result() == 1 ) { | 886 | if( fileDlg->result() == 1 ) { |
858 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 887 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
859 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 888 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
860 | if( rename(oldname.latin1(), newName.latin1())== -1) | 889 | if( rename(oldname.latin1(), newName.latin1())== -1) |
861 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 890 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
862 | } | 891 | } |
863 | populateLocalView(); | 892 | populateLocalView(); |
864 | } | 893 | } |
865 | 894 | ||
866 | void AdvancedFm::remoteRename() | 895 | void AdvancedFm::remoteRename() |
867 | { | 896 | { |
868 | QString curFile = Local_View->currentItem()->text(0); | 897 | QString curFile = Local_View->currentItem()->text(0); |
869 | InputDialog *fileDlg; | 898 | InputDialog *fileDlg; |
870 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 899 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
871 | fileDlg->setInputText((const QString &)curFile); | 900 | fileDlg->setInputText((const QString &)curFile); |
872 | fileDlg->exec(); | 901 | fileDlg->exec(); |
873 | if( fileDlg->result() == 1 ) { | 902 | if( fileDlg->result() == 1 ) { |
874 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; | 903 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; |
875 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 904 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
876 | if( rename(oldname.latin1(), newName.latin1())== -1) | 905 | if( rename(oldname.latin1(), newName.latin1())== -1) |
877 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 906 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
878 | } | 907 | } |
879 | populateRemoteView(); | 908 | populateRemoteView(); |
880 | } | 909 | } |
881 | 910 | ||
882 | void AdvancedFm::switchToLocalTab() | 911 | void AdvancedFm::switchToLocalTab() |
883 | { | 912 | { |
884 | TabWidget->setCurrentPage(0); | 913 | TabWidget->setCurrentPage(0); |
885 | Local_View->setFocus(); | 914 | Local_View->setFocus(); |
886 | } | 915 | } |
887 | 916 | ||
888 | void AdvancedFm::switchToRemoteTab() | 917 | void AdvancedFm::switchToRemoteTab() |
889 | { | 918 | { |
890 | TabWidget->setCurrentPage(1); | 919 | TabWidget->setCurrentPage(1); |
891 | Remote_View->setFocus(); | 920 | Remote_View->setFocus(); |
892 | } | 921 | } |
893 | 922 | ||
894 | void AdvancedFm::readConfig() | 923 | void AdvancedFm::readConfig() |
895 | { | 924 | { |
896 | Config cfg("AdvancedFm"); | 925 | Config cfg("AdvancedFm"); |
897 | } | 926 | } |
898 | 927 | ||
899 | void AdvancedFm::writeConfig() | 928 | void AdvancedFm::writeConfig() |
900 | { | 929 | { |
901 | Config cfg("AdvancedFm"); | 930 | Config cfg("AdvancedFm"); |
902 | } | 931 | } |
903 | 932 | ||
904 | void AdvancedFm::currentPathComboChanged() | 933 | void AdvancedFm::currentPathComboChanged() |
905 | { | 934 | { |
906 | if (TabWidget->currentPageIndex() == 0) { | 935 | if (TabWidget->currentPageIndex() == 0) { |
907 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 936 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
908 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 937 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
909 | populateLocalView(); | 938 | populateLocalView(); |
910 | } else { | 939 | } else { |
911 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 940 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
912 | } | 941 | } |
913 | } | 942 | } |
914 | if (TabWidget->currentPageIndex() == 0) { | 943 | if (TabWidget->currentPageIndex() == 0) { |
915 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 944 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
916 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); | 945 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); |
917 | populateRemoteView(); | 946 | populateRemoteView(); |
918 | } else { | 947 | } else { |
919 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 948 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
920 | } | 949 | } |
921 | } | 950 | } |
922 | } | 951 | } |
923 | 952 | ||
924 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 953 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
925 | 954 | ||
926 | if (TabWidget->currentPageIndex() == 0) { | 955 | if (TabWidget->currentPageIndex() == 0) { |
927 | currentPathCombo->lineEdit()->setText( currentPath); | 956 | currentPathCombo->lineEdit()->setText( currentPath); |
928 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 957 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
929 | currentPathCombo->clear(); | 958 | currentPathCombo->clear(); |
930 | localDirPathStringList.prepend( currentPath ); | 959 | localDirPathStringList.prepend( currentPath ); |
931 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 960 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
932 | } | 961 | } |
933 | } else { | 962 | } else { |
934 | currentPathCombo->lineEdit()->setText( currentPath); | 963 | currentPathCombo->lineEdit()->setText( currentPath); |
935 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 964 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
936 | currentPathCombo->clear(); | 965 | currentPathCombo->clear(); |
937 | remoteDirPathStringList.prepend( currentPath ); | 966 | remoteDirPathStringList.prepend( currentPath ); |
938 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 967 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
939 | } | 968 | } |
940 | } | 969 | } |
941 | } | 970 | } |
942 | 971 | ||
943 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 972 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
944 | if (TabWidget->currentPageIndex() == 0) { | 973 | if (TabWidget->currentPageIndex() == 0) { |
945 | chdir( currentPath.latin1() ); | 974 | chdir( currentPath.latin1() ); |
946 | currentDir.cd( currentPath, TRUE); | 975 | currentDir.cd( currentPath, TRUE); |
947 | populateLocalView(); | 976 | populateLocalView(); |
948 | update(); | 977 | update(); |
949 | } else { | 978 | } else { |
950 | chdir( currentPath.latin1() ); | 979 | chdir( currentPath.latin1() ); |
951 | currentRemoteDir.cd( currentPath, TRUE); | 980 | currentRemoteDir.cd( currentPath, TRUE); |
952 | populateRemoteView(); | 981 | populateRemoteView(); |
953 | update(); | 982 | update(); |
954 | } | 983 | } |
955 | } | 984 | } |
956 | 985 | ||
957 | void AdvancedFm::filePerms() { | 986 | void AdvancedFm::filePerms() { |
958 | 987 | ||
959 | QStringList curFileList = getPath(); | 988 | QStringList curFileList = getPath(); |
960 | QString filePath; | 989 | QString filePath; |
961 | 990 | ||
962 | if (TabWidget->currentPageIndex() == 0) { | 991 | if (TabWidget->currentPageIndex() == 0) { |
963 | filePath = currentDir.canonicalPath()+"/"; | 992 | filePath = currentDir.canonicalPath()+"/"; |
964 | } else { | 993 | } else { |
965 | filePath= currentRemoteDir.canonicalPath()+"/"; | 994 | filePath= currentRemoteDir.canonicalPath()+"/"; |
966 | } | 995 | } |
967 | 996 | ||
968 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 997 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
969 | filePermissions *filePerm; | 998 | filePermissions *filePerm; |
970 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 999 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
971 | filePerm->showMaximized(); | 1000 | filePerm->showMaximized(); |
972 | filePerm->exec(); | 1001 | filePerm->exec(); |
973 | if( filePerm) | 1002 | if( filePerm) |
974 | delete filePerm; | 1003 | delete filePerm; |
975 | } | 1004 | } |
976 | } | 1005 | } |
977 | 1006 | ||
978 | void AdvancedFm::doProperties() { | 1007 | void AdvancedFm::doProperties() { |
979 | QStringList curFileList = getPath(); | 1008 | QStringList curFileList = getPath(); |
980 | QString filePath; | 1009 | QString filePath; |
981 | if (TabWidget->currentPageIndex() == 0) { | 1010 | if (TabWidget->currentPageIndex() == 0) { |
982 | filePath = currentDir.canonicalPath()+"/"; | 1011 | filePath = currentDir.canonicalPath()+"/"; |
983 | } else { | 1012 | } else { |
984 | filePath= currentRemoteDir.canonicalPath()+"/"; | 1013 | filePath= currentRemoteDir.canonicalPath()+"/"; |
985 | } | 1014 | } |
986 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1015 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
987 | DocLnk lnk( (filePath+*it)); | 1016 | DocLnk lnk( (filePath+*it)); |
988 | LnkProperties prop( &lnk ); | 1017 | LnkProperties prop( &lnk ); |
989 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 1018 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
990 | prop.showMaximized(); | 1019 | prop.showMaximized(); |
991 | prop.exec(); | 1020 | prop.exec(); |
992 | } | 1021 | } |
993 | } | 1022 | } |
994 | 1023 | ||
995 | QStringList AdvancedFm::getPath() { | 1024 | QStringList AdvancedFm::getPath() { |
996 | QStringList strList; | 1025 | QStringList strList; |
997 | if (TabWidget->currentPageIndex() == 0) { | 1026 | if (TabWidget->currentPageIndex() == 0) { |
998 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 1027 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
999 | QListViewItemIterator it( Local_View ); | 1028 | QListViewItemIterator it( Local_View ); |
1000 | for ( ; it.current(); ++it ) { | 1029 | for ( ; it.current(); ++it ) { |
1001 | if ( it.current()->isSelected() ) { | 1030 | if ( it.current()->isSelected() ) { |
1002 | strList << it.current()->text(0); | 1031 | strList << it.current()->text(0); |
1003 | } | 1032 | } |
1004 | } | 1033 | } |
1005 | return strList; | 1034 | return strList; |
1006 | } else { | 1035 | } else { |
1007 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 1036 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
1008 | QListViewItemIterator it( Remote_View ); | 1037 | QListViewItemIterator it( Remote_View ); |
1009 | for ( ; it.current(); ++it ) { | 1038 | for ( ; it.current(); ++it ) { |
1010 | if ( it.current()->isSelected() ) { | 1039 | if ( it.current()->isSelected() ) { |
1011 | strList << currentDir.canonicalPath()+"/"+ it.current()->text(0); | 1040 | strList << currentDir.canonicalPath()+"/"+ it.current()->text(0); |
1012 | } | 1041 | } |
1013 | } | 1042 | } |
1014 | return strList; | 1043 | return strList; |
1015 | } | 1044 | } |
1016 | return ""; | 1045 | return ""; |
1017 | } | 1046 | } |
1018 | 1047 | ||
1019 | void AdvancedFm::homeButtonPushed() { | 1048 | void AdvancedFm::homeButtonPushed() { |
1020 | QString current = QDir::homeDirPath(); | 1049 | QString current = QDir::homeDirPath(); |
1021 | chdir( current.latin1() ); | 1050 | chdir( current.latin1() ); |
1022 | if (TabWidget->currentPageIndex() == 0) { | 1051 | if (TabWidget->currentPageIndex() == 0) { |
1023 | currentDir.cd( current, TRUE); | 1052 | currentDir.cd( current, TRUE); |
1024 | populateLocalView(); | 1053 | populateLocalView(); |
1025 | } else { | 1054 | } else { |
1026 | currentRemoteDir.cd( current, TRUE); | 1055 | currentRemoteDir.cd( current, TRUE); |
1027 | populateRemoteView(); | 1056 | populateRemoteView(); |
1028 | } | 1057 | } |
1029 | update(); | 1058 | update(); |
1030 | } | 1059 | } |
1031 | 1060 | ||
1032 | void AdvancedFm::docButtonPushed() { | 1061 | void AdvancedFm::docButtonPushed() { |
1033 | QString current = QPEApplication::documentDir(); | 1062 | QString current = QPEApplication::documentDir(); |
1034 | chdir( current.latin1() ); | 1063 | chdir( current.latin1() ); |
1035 | if (TabWidget->currentPageIndex() == 0) { | 1064 | if (TabWidget->currentPageIndex() == 0) { |
1036 | currentDir.cd( current, TRUE); | 1065 | currentDir.cd( current, TRUE); |
1037 | populateLocalView(); | 1066 | populateLocalView(); |
1038 | } else { | 1067 | } else { |
1039 | currentRemoteDir.cd( current, TRUE); | 1068 | currentRemoteDir.cd( current, TRUE); |
1040 | populateRemoteView(); | 1069 | populateRemoteView(); |
1041 | } | 1070 | } |
1042 | update(); | 1071 | update(); |
1043 | } | 1072 | } |
1044 | 1073 | ||
1045 | void AdvancedFm::SDButtonPushed() { | 1074 | void AdvancedFm::SDButtonPushed() { |
1046 | QString current = "/mnt/card"; | 1075 | QString current = "/mnt/card"; |
1047 | chdir( current.latin1() ); | 1076 | chdir( current.latin1() ); |
1048 | if (TabWidget->currentPageIndex() == 0) { | 1077 | if (TabWidget->currentPageIndex() == 0) { |
1049 | currentDir.cd( current, TRUE); | 1078 | currentDir.cd( current, TRUE); |
1050 | populateLocalView(); | 1079 | populateLocalView(); |
1051 | } else { | 1080 | } else { |
1052 | currentRemoteDir.cd( current, TRUE); | 1081 | currentRemoteDir.cd( current, TRUE); |
1053 | populateRemoteView(); | 1082 | populateRemoteView(); |
1054 | } | 1083 | } |
1055 | update(); | 1084 | update(); |
1056 | 1085 | ||
1057 | } | 1086 | } |
1058 | 1087 | ||
1059 | void AdvancedFm::CFButtonPushed() { | 1088 | void AdvancedFm::CFButtonPushed() { |
1060 | QString current = "/mnt/cf"; | 1089 | QString current = "/mnt/cf"; |
1061 | chdir( current.latin1() ); | 1090 | chdir( current.latin1() ); |
1062 | if (TabWidget->currentPageIndex() == 0) { | 1091 | if (TabWidget->currentPageIndex() == 0) { |
1063 | currentDir.cd( current, TRUE); | 1092 | currentDir.cd( current, TRUE); |
1064 | populateLocalView(); | 1093 | populateLocalView(); |
1065 | } else { | 1094 | } else { |
1066 | currentRemoteDir.cd( current, TRUE); | 1095 | currentRemoteDir.cd( current, TRUE); |
1067 | populateRemoteView(); | 1096 | populateRemoteView(); |
1068 | } | 1097 | } |
1069 | update(); | 1098 | update(); |
1070 | 1099 | ||
1071 | } | 1100 | } |
1072 | 1101 | ||
1073 | 1102 | ||
1074 | void AdvancedFm::upDir() | 1103 | void AdvancedFm::upDir() |
1075 | { | 1104 | { |
1076 | if (TabWidget->currentPageIndex() == 0) { | 1105 | if (TabWidget->currentPageIndex() == 0) { |
1077 | QString current = currentDir.canonicalPath(); | 1106 | QString current = currentDir.canonicalPath(); |
1078 | QDir dir(current); | 1107 | QDir dir(current); |
1079 | dir.cdUp(); | 1108 | dir.cdUp(); |
1080 | current = dir.canonicalPath(); | 1109 | current = dir.canonicalPath(); |
1081 | chdir( current.latin1() ); | 1110 | chdir( current.latin1() ); |
1082 | currentDir.cd( current, TRUE); | 1111 | currentDir.cd( current, TRUE); |
1083 | populateLocalView(); | 1112 | populateLocalView(); |
1084 | update(); | 1113 | update(); |
1085 | } else { | 1114 | } else { |
1086 | QString current = currentRemoteDir.canonicalPath(); | 1115 | QString current = currentRemoteDir.canonicalPath(); |
1087 | QDir dir(current); | 1116 | QDir dir(current); |
1088 | dir.cdUp(); | 1117 | dir.cdUp(); |
1089 | current = dir.canonicalPath(); | 1118 | current = dir.canonicalPath(); |
1090 | chdir( current.latin1() ); | 1119 | chdir( current.latin1() ); |
1091 | currentRemoteDir.cd( current, TRUE); | 1120 | currentRemoteDir.cd( current, TRUE); |
1092 | populateRemoteView(); | 1121 | populateRemoteView(); |
1093 | update(); | 1122 | update(); |
1094 | } | 1123 | } |
1095 | } | 1124 | } |
1096 | 1125 | ||
1097 | void AdvancedFm::copy() | 1126 | void AdvancedFm::copy() |
1098 | { | 1127 | { |
1099 | QStringList curFileList = getPath(); | 1128 | QStringList curFileList = getPath(); |
1100 | QString curFile; | 1129 | QString curFile; |
1101 | if (TabWidget->currentPageIndex() == 0) { | 1130 | if (TabWidget->currentPageIndex() == 0) { |
1102 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1131 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1103 | 1132 | ||
1104 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1133 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1105 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1134 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1106 | QFile f(destFile); | 1135 | QFile f(destFile); |
1107 | if( f.exists()) | 1136 | if( f.exists()) |
1108 | f.remove(); | 1137 | f.remove(); |
1109 | if(!copyFile(destFile, curFile) ) | 1138 | if(!copyFile(destFile, curFile) ) |
1110 | qWarning("nothin doing"); | 1139 | qWarning("nothin doing"); |
1111 | } | 1140 | } |
1112 | populateRemoteView(); | 1141 | populateRemoteView(); |
1113 | TabWidget->setCurrentPage(1); | 1142 | TabWidget->setCurrentPage(1); |
1114 | 1143 | ||
1115 | } else { | 1144 | } else { |
1116 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1145 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1117 | 1146 | ||
1118 | QString destFile = currentDir.canonicalPath()+"/"+(*it); | 1147 | QString destFile = currentDir.canonicalPath()+"/"+(*it); |
1119 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1148 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1120 | QFile f(destFile); | 1149 | QFile f(destFile); |
1121 | if( f.exists()) | 1150 | if( f.exists()) |
1122 | f.remove(); | 1151 | f.remove(); |
1123 | if(!copyFile(destFile, curFile) ) | 1152 | if(!copyFile(destFile, curFile) ) |
1124 | qWarning("nothin doing"); | 1153 | qWarning("nothin doing"); |
1125 | } | 1154 | } |
1126 | populateLocalView(); | 1155 | populateLocalView(); |
1127 | TabWidget->setCurrentPage(0); | 1156 | TabWidget->setCurrentPage(0); |
1128 | } | 1157 | } |
1129 | } | 1158 | } |
1130 | 1159 | ||
1131 | void AdvancedFm::copyAs() | 1160 | void AdvancedFm::copyAs() |
1132 | { | 1161 | { |
1133 | QStringList curFileList = getPath(); | 1162 | QStringList curFileList = getPath(); |
1134 | QString curFile; | 1163 | QString curFile; |
1135 | InputDialog *fileDlg; | 1164 | InputDialog *fileDlg; |
1136 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | 1165 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); |
1137 | 1166 | ||
1138 | if (TabWidget->currentPageIndex() == 0) { | 1167 | if (TabWidget->currentPageIndex() == 0) { |
1139 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1168 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1140 | QString destFile = *it; | 1169 | QString destFile = *it; |
1141 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1170 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1142 | // InputDialog *fileDlg; | 1171 | // InputDialog *fileDlg; |
1143 | // fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | 1172 | // fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); |
1144 | fileDlg->setInputText((const QString &) destFile ); | 1173 | fileDlg->setInputText((const QString &) destFile ); |
1145 | fileDlg->exec(); | 1174 | fileDlg->exec(); |
1146 | if( fileDlg->result() == 1 ) { | 1175 | if( fileDlg->result() == 1 ) { |
1147 | QString filename = fileDlg->LineEdit1->text(); | 1176 | QString filename = fileDlg->LineEdit1->text(); |
1148 | destFile = currentRemoteDir.canonicalPath()+"/"+destFile; | 1177 | destFile = currentRemoteDir.canonicalPath()+"/"+destFile; |
1149 | 1178 | ||
1150 | QFile f(destFile); | 1179 | QFile f(destFile); |
1151 | if( f.exists()) | 1180 | if( f.exists()) |
1152 | f.remove(); | 1181 | f.remove(); |
1153 | if(!copyFile(destFile, curFile) ) | 1182 | if(!copyFile(destFile, curFile) ) |
1154 | qWarning("nothin doing"); | 1183 | qWarning("nothin doing"); |
1155 | } | 1184 | } |
1156 | } | 1185 | } |
1157 | 1186 | ||
1158 | populateRemoteView(); | 1187 | populateRemoteView(); |
1159 | TabWidget->setCurrentPage(1); | 1188 | TabWidget->setCurrentPage(1); |
1160 | } else { | 1189 | } else { |
1161 | if (TabWidget->currentPageIndex() == 0) { | 1190 | if (TabWidget->currentPageIndex() == 0) { |
1162 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1191 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1163 | 1192 | ||
1164 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1193 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1165 | QString destFile = *it; | 1194 | QString destFile = *it; |
1166 | fileDlg->setInputText((const QString &) destFile); | 1195 | fileDlg->setInputText((const QString &) destFile); |
1167 | fileDlg->exec(); | 1196 | fileDlg->exec(); |
1168 | if( fileDlg->result() == 1 ) { | 1197 | if( fileDlg->result() == 1 ) { |
1169 | QString filename = fileDlg->LineEdit1->text(); | 1198 | QString filename = fileDlg->LineEdit1->text(); |
1170 | destFile = currentDir.canonicalPath()+"/"+destFile; | 1199 | destFile = currentDir.canonicalPath()+"/"+destFile; |
1171 | 1200 | ||
1172 | QFile f(destFile); | 1201 | QFile f(destFile); |
1173 | if( f.exists()) | 1202 | if( f.exists()) |
1174 | f.remove(); | 1203 | f.remove(); |
1175 | if(!copyFile(destFile, curFile) ) | 1204 | if(!copyFile(destFile, curFile) ) |
1176 | qWarning("nothin doing"); | 1205 | qWarning("nothin doing"); |
1177 | } | 1206 | } |
1178 | } | 1207 | } |
1179 | populateLocalView(); | 1208 | populateLocalView(); |
1180 | TabWidget->setCurrentPage(0); | 1209 | TabWidget->setCurrentPage(0); |
1181 | } | 1210 | } |
1182 | } | 1211 | } |
1183 | } | 1212 | } |
1184 | 1213 | ||
1185 | void AdvancedFm::move() { | 1214 | void AdvancedFm::move() { |
1186 | 1215 | ||
1187 | QStringList curFileList = getPath(); | 1216 | QStringList curFileList = getPath(); |
1188 | QString curFile; | 1217 | QString curFile; |
1189 | // qDebug(curFile); | 1218 | // qDebug(curFile); |
1190 | QString destFile; | 1219 | QString destFile; |
1191 | 1220 | ||
1192 | if (TabWidget->currentPageIndex() == 0) { | 1221 | if (TabWidget->currentPageIndex() == 0) { |
1193 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1222 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1194 | QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; | 1223 | QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; |
1195 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1224 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1196 | qDebug("Destination file is "+destFile); | 1225 | qDebug("Destination file is "+destFile); |
1197 | 1226 | ||
1198 | QFile f(destFile); | 1227 | QFile f(destFile); |
1199 | if( f.exists()) | 1228 | if( f.exists()) |
1200 | f.remove(); | 1229 | f.remove(); |
1201 | if(!copyFile( destFile, curFile) ) { | 1230 | if(!copyFile( destFile, curFile) ) { |
1202 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); | 1231 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); |
1203 | return; | 1232 | return; |
1204 | } | 1233 | } |
1205 | QFile::remove(curFile); | 1234 | QFile::remove(curFile); |
1206 | } | 1235 | } |
1207 | TabWidget->setCurrentPage(1); | 1236 | TabWidget->setCurrentPage(1); |
1208 | } else { | 1237 | } else { |
1209 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1238 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1210 | QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; | 1239 | QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; |
1211 | qDebug("Destination file is "+destFile); | 1240 | qDebug("Destination file is "+destFile); |
1212 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1241 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1213 | 1242 | ||
1214 | QFile f(destFile); | 1243 | QFile f(destFile); |
1215 | if( f.exists()) | 1244 | if( f.exists()) |
1216 | f.remove(); | 1245 | f.remove(); |
1217 | if(!copyFile(destFile, curFile) ) { | 1246 | if(!copyFile(destFile, curFile) ) { |
1218 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); | 1247 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); |
1219 | return; | 1248 | return; |
1220 | } | 1249 | } |
1221 | QFile::remove(curFile); | 1250 | QFile::remove(curFile); |
1222 | TabWidget->setCurrentPage(0); | 1251 | TabWidget->setCurrentPage(0); |
1223 | } | 1252 | } |
1224 | } | 1253 | } |
1225 | populateRemoteView(); | 1254 | populateRemoteView(); |
1226 | populateLocalView(); | 1255 | populateLocalView(); |
1227 | } | 1256 | } |
1228 | 1257 | ||
1229 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) | 1258 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) |
1230 | { | 1259 | { |
1231 | char bf[ 50000 ]; | 1260 | char bf[ 50000 ]; |
1232 | int bytesRead; | 1261 | int bytesRead; |
1233 | bool success = TRUE; | 1262 | bool success = TRUE; |
1234 | struct stat status; | 1263 | struct stat status; |
1235 | 1264 | ||
1236 | QFile s( src ); | 1265 | QFile s( src ); |
1237 | QFile d( dest ); | 1266 | QFile d( dest ); |
1238 | 1267 | ||
1239 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 1268 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
1240 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 1269 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
1241 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 1270 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
1242 | success = FALSE; | 1271 | success = FALSE; |
1243 | break; | 1272 | break; |
1244 | } | 1273 | } |
1245 | } | 1274 | } |
1246 | if( success && (bytesRead > 0) ){ | 1275 | if( success && (bytesRead > 0) ){ |
1247 | d.writeBlock( bf, bytesRead ); | 1276 | d.writeBlock( bf, bytesRead ); |
1248 | } | 1277 | } |
1249 | } else { | 1278 | } else { |
1250 | success = FALSE; | 1279 | success = FALSE; |
1251 | } | 1280 | } |
1252 | 1281 | ||
1253 | // Set file permissions | 1282 | // Set file permissions |
1254 | if( stat( (const char *) src, &status ) == 0 ){ | 1283 | if( stat( (const char *) src, &status ) == 0 ){ |
1255 | chmod( (const char *) dest, status.st_mode ); | 1284 | chmod( (const char *) dest, status.st_mode ); |
1256 | } | 1285 | } |
1257 | 1286 | ||
1258 | return success; | 1287 | return success; |
1259 | } | 1288 | } |
1260 | 1289 | ||
1261 | void AdvancedFm::runCommand() { | 1290 | void AdvancedFm::runCommand() { |
1262 | QString curFile; | 1291 | QString curFile; |
1263 | if (TabWidget->currentPageIndex() == 0) { | 1292 | if (TabWidget->currentPageIndex() == 0) { |
1264 | if( Local_View->currentItem()) | 1293 | if( Local_View->currentItem()) |
1265 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); | 1294 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); |
1266 | } else { | 1295 | } else { |
1267 | if(Remote_View->currentItem()) | 1296 | if(Remote_View->currentItem()) |
1268 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); | 1297 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); |
1269 | } | 1298 | } |
1270 | 1299 | ||
1271 | InputDialog *fileDlg; | 1300 | InputDialog *fileDlg; |
1272 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1301 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1273 | fileDlg->setInputText(curFile); | 1302 | fileDlg->setInputText(curFile); |
1274 | fileDlg->exec(); | 1303 | fileDlg->exec(); |
1275 | QString command; | 1304 | QString command; |
1276 | if( fileDlg->result() == 1 ) { | 1305 | if( fileDlg->result() == 1 ) { |
1277 | command = fileDlg->LineEdit1->text(); | 1306 | command = fileDlg->LineEdit1->text(); |
1278 | 1307 | ||
1279 | int err=0; | 1308 | int err=0; |
1280 | Output *outDlg; | 1309 | Output *outDlg; |
1281 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1310 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1282 | outDlg->showMaximized(); | 1311 | outDlg->showMaximized(); |
1283 | outDlg->show(); | 1312 | outDlg->show(); |
1284 | qApp->processEvents(); | 1313 | qApp->processEvents(); |
1285 | FILE *fp; | 1314 | FILE *fp; |
1286 | char line[130]; | 1315 | char line[130]; |
1287 | sleep(1); | 1316 | sleep(1); |
1288 | // if(command.find("2>",0,TRUE) != -1) | 1317 | // if(command.find("2>",0,TRUE) != -1) |
1289 | command +=" 2>&1"; | 1318 | command +=" 2>&1"; |
1290 | fp = popen( (const char *) command, "r"); | 1319 | fp = popen( (const char *) command, "r"); |
1291 | if ( !fp ) { | 1320 | if ( !fp ) { |
1292 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1321 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1293 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); | 1322 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); |
1294 | pclose(fp); | 1323 | pclose(fp); |
1295 | return; | 1324 | return; |
1296 | } else { | 1325 | } else { |
1297 | while ( fgets( line, sizeof line, fp)) { | 1326 | while ( fgets( line, sizeof line, fp)) { |
1298 | QString lineStr = line; | 1327 | QString lineStr = line; |
1299 | lineStr=lineStr.left(lineStr.length()-1); | 1328 | lineStr=lineStr.left(lineStr.length()-1); |
1300 | outDlg->OutputEdit->append(lineStr); | 1329 | outDlg->OutputEdit->append(lineStr); |
1301 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1330 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1302 | } | 1331 | } |
1303 | } | 1332 | } |
1304 | } | 1333 | } |
1305 | } | 1334 | } |
1306 | 1335 | ||
1307 | void AdvancedFm::runCommandStd() { | 1336 | void AdvancedFm::runCommandStd() { |
1308 | QString curFile; | 1337 | QString curFile; |
1309 | if (TabWidget->currentPageIndex() == 0) { | 1338 | if (TabWidget->currentPageIndex() == 0) { |
1310 | if( Local_View->currentItem()) | 1339 | if( Local_View->currentItem()) |
1311 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); | 1340 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); |
1312 | } else { | 1341 | } else { |
1313 | if(Remote_View->currentItem()) | 1342 | if(Remote_View->currentItem()) |
1314 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); | 1343 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); |
1315 | } | 1344 | } |
1316 | 1345 | ||
1317 | InputDialog *fileDlg; | 1346 | InputDialog *fileDlg; |
1318 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1347 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1319 | fileDlg->setInputText(curFile); | 1348 | fileDlg->setInputText(curFile); |
1320 | fileDlg->exec(); | 1349 | fileDlg->exec(); |
1321 | QString command; | 1350 | QString command; |
1322 | if( fileDlg->result() == 1 ) { | 1351 | if( fileDlg->result() == 1 ) { |
1323 | qApp->processEvents(); | 1352 | qApp->processEvents(); |
1324 | command = fileDlg->LineEdit1->text() + " &"; | 1353 | command = fileDlg->LineEdit1->text() + " &"; |
1325 | system(command.latin1()); | 1354 | system(command.latin1()); |
1326 | } | 1355 | } |
1327 | } | 1356 | } |
1328 | 1357 | ||
1329 | void AdvancedFm::fileStatus() { | 1358 | void AdvancedFm::fileStatus() { |
1330 | QString curFile; | 1359 | QString curFile; |
1331 | if (TabWidget->currentPageIndex() == 0) { | 1360 | if (TabWidget->currentPageIndex() == 0) { |
1332 | curFile = Local_View->currentItem()->text(0); | 1361 | curFile = Local_View->currentItem()->text(0); |
1333 | } else { | 1362 | } else { |
1334 | curFile = Remote_View->currentItem()->text(0); | 1363 | curFile = Remote_View->currentItem()->text(0); |
1335 | } | 1364 | } |
1336 | QString command = " stat -l "+ curFile +" 2>&1"; | 1365 | QString command = " stat -l "+ curFile +" 2>&1"; |
1337 | int err=0; | 1366 | int err=0; |
1338 | Output *outDlg; | 1367 | Output *outDlg; |
1339 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1368 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1340 | outDlg->showMaximized(); | 1369 | outDlg->showMaximized(); |
1341 | outDlg->show(); | 1370 | outDlg->show(); |
1342 | qApp->processEvents(); | 1371 | qApp->processEvents(); |
1343 | FILE *fp; | 1372 | FILE *fp; |
1344 | char line[130]; | 1373 | char line[130]; |
1345 | sleep(1); | 1374 | sleep(1); |
1346 | fp = popen( (const char *) command, "r"); | 1375 | fp = popen( (const char *) command, "r"); |
1347 | if ( !fp ) { | 1376 | if ( !fp ) { |
1348 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1377 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1349 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); | 1378 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); |
1350 | pclose(fp); | 1379 | pclose(fp); |
1351 | return; | 1380 | return; |
1352 | } else { | 1381 | } else { |
1353 | while ( fgets( line, sizeof line, fp)) { | 1382 | while ( fgets( line, sizeof line, fp)) { |
1354 | outDlg->OutputEdit->append(line); | 1383 | outDlg->OutputEdit->append(line); |
1355 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1384 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1356 | 1385 | ||
1357 | } | 1386 | } |
1358 | 1387 | ||
1359 | } | 1388 | } |
1360 | } | 1389 | } |
1361 | 1390 | ||
1362 | void AdvancedFm::mkDir() { | 1391 | void AdvancedFm::mkDir() { |
1363 | if (TabWidget->currentPageIndex() == 0) | 1392 | if (TabWidget->currentPageIndex() == 0) |
1364 | localMakDir(); | 1393 | localMakDir(); |
1365 | else | 1394 | else |
1366 | remoteMakDir(); | 1395 | remoteMakDir(); |
1367 | 1396 | ||
1368 | } | 1397 | } |
1369 | 1398 | ||
1370 | void AdvancedFm::rn() { | 1399 | void AdvancedFm::rn() { |
1371 | if (TabWidget->currentPageIndex() == 0) | 1400 | if (TabWidget->currentPageIndex() == 0) |
1372 | localRename(); | 1401 | localRename(); |
1373 | else | 1402 | else |
1374 | remoteRename(); | 1403 | remoteRename(); |
1375 | 1404 | ||
1376 | } | 1405 | } |
1377 | 1406 | ||
1378 | void AdvancedFm::del() { | 1407 | void AdvancedFm::del() { |
1379 | if (TabWidget->currentPageIndex() == 0) | 1408 | if (TabWidget->currentPageIndex() == 0) |
1380 | localDelete(); | 1409 | localDelete(); |
1381 | else | 1410 | else |
1382 | remoteDelete(); | 1411 | remoteDelete(); |
1383 | } | 1412 | } |
1384 | 1413 | ||
1385 | void AdvancedFm::doAbout() { | 1414 | void AdvancedFm::doAbout() { |
1386 | QMessageBox::message("AdvancedFm","Advanced FileManager\n" | 1415 | QMessageBox::message("AdvancedFm","Advanced FileManager\n" |
1387 | "is copyright 2002 by\n" | 1416 | "is copyright 2002 by\n" |
1388 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1417 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1389 | "and is licensed by the GPL"); | 1418 | "and is licensed by the GPL"); |
1390 | } | 1419 | } |
1391 | 1420 | ||
1392 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) | 1421 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) |
1393 | { | 1422 | { |
1394 | switch ( e->key() ) { | 1423 | switch ( e->key() ) { |
1395 | case Key_Delete: | 1424 | case Key_Delete: |
1396 | del(); | 1425 | del(); |
1397 | break; | 1426 | break; |
1398 | case Key_H: | 1427 | case Key_H: |
1399 | showHidden(); | 1428 | showHidden(); |
1400 | break; | 1429 | break; |
1401 | case Key_E: | 1430 | case Key_E: |
1402 | runThis(); | 1431 | runThis(); |
1403 | break; | 1432 | break; |
1404 | case Key_C: | 1433 | case Key_C: |
1405 | copy(); | 1434 | copy(); |
1406 | break; | 1435 | break; |
1407 | case Key_A: | 1436 | case Key_A: |
1408 | copyAs(); | 1437 | copyAs(); |
1409 | break; | 1438 | break; |
1410 | case Key_M: | 1439 | case Key_M: |
1411 | move(); | 1440 | move(); |
1412 | break; | 1441 | break; |
1413 | case Key_R: | 1442 | case Key_R: |
1414 | rn(); | 1443 | rn(); |
1415 | break; | 1444 | break; |
1416 | case Key_I: | 1445 | case Key_I: |
1417 | fileStatus(); | 1446 | fileStatus(); |
1418 | break; | 1447 | break; |
1419 | case Key_U: | 1448 | case Key_U: |
1420 | upDir(); | 1449 | upDir(); |
1421 | break; | 1450 | break; |
1422 | case Key_P: | 1451 | case Key_P: |
1423 | filePerms(); | 1452 | filePerms(); |
1424 | break; | 1453 | break; |
1425 | case Key_N: | 1454 | case Key_N: |
1426 | mkDir(); | 1455 | mkDir(); |
1427 | break; | 1456 | break; |
1428 | case Key_1: | 1457 | case Key_1: |
1429 | switchToLocalTab(); | 1458 | switchToLocalTab(); |
1430 | break; | 1459 | break; |
1431 | case Key_2: | 1460 | case Key_2: |
1432 | switchToRemoteTab(); | 1461 | switchToRemoteTab(); |
1433 | break; | 1462 | break; |
1434 | case Key_3: | 1463 | case Key_3: |
1435 | CFButtonPushed(); | 1464 | CFButtonPushed(); |
1436 | break; | 1465 | break; |
1437 | case Key_4: | 1466 | case Key_4: |
1438 | SDButtonPushed(); | 1467 | SDButtonPushed(); |
1439 | break; | 1468 | break; |
1440 | case Key_5: | 1469 | case Key_5: |
1441 | homeButtonPushed(); | 1470 | homeButtonPushed(); |
1442 | break; | 1471 | break; |
1443 | case Key_6: | 1472 | case Key_6: |
1444 | docButtonPushed(); | 1473 | docButtonPushed(); |
1445 | break; | 1474 | break; |
1446 | case Key_7: | 1475 | case Key_7: |
1447 | break; | 1476 | break; |
1448 | case Key_8: | 1477 | case Key_8: |
1449 | break; | 1478 | break; |
1450 | case Key_9: | 1479 | case Key_9: |
1451 | break; | 1480 | break; |
1452 | case Key_0: | 1481 | case Key_0: |
1453 | break; | 1482 | break; |
1454 | 1483 | ||
1455 | 1484 | ||
1456 | 1485 | ||
1457 | } | 1486 | } |
1458 | 1487 | ||
1459 | } | 1488 | } |
1460 | 1489 | ||
1461 | void AdvancedFm::mkSym() { | 1490 | void AdvancedFm::mkSym() { |
1462 | QString cmd; | 1491 | QString cmd; |
1463 | if (TabWidget->currentPageIndex() == 0) { | 1492 | if (TabWidget->currentPageIndex() == 0) { |
1464 | QString curFile = Local_View->currentItem()->text(0); | 1493 | QString curFile = Local_View->currentItem()->text(0); |
1465 | if(curFile.right(1) == "/") curFile = curFile.left(curFile.length() - 1); | 1494 | if(curFile.right(1) == "/") curFile = curFile.left(curFile.length() - 1); |
1466 | QString destName = currentRemoteDir.canonicalPath()+"/"+curFile; | 1495 | QString destName = currentRemoteDir.canonicalPath()+"/"+curFile; |
1467 | curFile = currentDir.canonicalPath()+"/"+curFile; | 1496 | curFile = currentDir.canonicalPath()+"/"+curFile; |
1468 | cmd = "ln -s "+curFile+" "+destName; | 1497 | cmd = "ln -s "+curFile+" "+destName; |
1469 | system(cmd.latin1() ); | 1498 | system(cmd.latin1() ); |
1470 | populateRemoteView(); | 1499 | populateRemoteView(); |
1471 | } else { | 1500 | } else { |
1472 | QString curFile = Remote_View->currentItem()->text(0); | 1501 | QString curFile = Remote_View->currentItem()->text(0); |
1473 | if(curFile.right(1) == "/") curFile = curFile.left(curFile.length() - 1); | 1502 | if(curFile.right(1) == "/") curFile = curFile.left(curFile.length() - 1); |
1474 | QString destName = currentDir.canonicalPath()+"/"+curFile; | 1503 | QString destName = currentDir.canonicalPath()+"/"+curFile; |
1475 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 1504 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
1476 | cmd = "ln -s "+curFile+" "+destName; | 1505 | cmd = "ln -s "+curFile+" "+destName; |
1477 | system(cmd.latin1() ); | 1506 | system(cmd.latin1() ); |
1478 | populateLocalView(); | 1507 | populateLocalView(); |
1479 | } | 1508 | } |
1480 | } | 1509 | } |
1510 | |||
1511 | void AdvancedFm::QPEButtonPushed() { | ||
1512 | QString current = QPEApplication::qpeDir(); | ||
1513 | chdir( current.latin1() ); | ||
1514 | if (TabWidget->currentPageIndex() == 0) { | ||
1515 | currentDir.cd( current, TRUE); | ||
1516 | populateLocalView(); | ||
1517 | } else { | ||
1518 | currentRemoteDir.cd( current, TRUE); | ||
1519 | populateRemoteView(); | ||
1520 | } | ||
1521 | update(); | ||
1522 | |||
1523 | } | ||
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index c00713f..5c2719e 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h | |||
@@ -1,123 +1,124 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | opieftp.h | 2 | opieftp.h |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #ifndef ADVANCEDFM_H | 12 | #ifndef ADVANCEDFM_H |
13 | #define ADVANCEDFM_H | 13 | #define ADVANCEDFM_H |
14 | 14 | ||
15 | #include <qvariant.h> | 15 | #include <qvariant.h> |
16 | #include <qdialog.h> | 16 | #include <qdialog.h> |
17 | #include <qmainwindow.h> | 17 | #include <qmainwindow.h> |
18 | #include <qdir.h> | 18 | #include <qdir.h> |
19 | #include <qstring.h> | 19 | #include <qstring.h> |
20 | #include <qpoint.h> | 20 | #include <qpoint.h> |
21 | #include <qstringlist.h> | 21 | #include <qstringlist.h> |
22 | 22 | ||
23 | class QVBoxLayout; | 23 | class QVBoxLayout; |
24 | class QHBoxLayout; | 24 | class QHBoxLayout; |
25 | class QGridLayout; | 25 | class QGridLayout; |
26 | class QComboBox; | 26 | class QComboBox; |
27 | class QListView; | 27 | class QListView; |
28 | class QListviewItem; | 28 | class QListviewItem; |
29 | class QLabel; | 29 | class QLabel; |
30 | class QProgressBar; | 30 | class QProgressBar; |
31 | class QSpinBox; | 31 | class QSpinBox; |
32 | class QTabWidget; | 32 | class QTabWidget; |
33 | class QWidget; | 33 | class QWidget; |
34 | class QPEToolBar; | 34 | class QPEToolBar; |
35 | class QPEMenuBar; | 35 | class QPEMenuBar; |
36 | class QPopupMenu; | 36 | class QPopupMenu; |
37 | class QFile; | 37 | class QFile; |
38 | class QListViewItem; | 38 | class QListViewItem; |
39 | class QLineEdit; | 39 | class QLineEdit; |
40 | class QPushButton; | 40 | class QPushButton; |
41 | 41 | ||
42 | class AdvancedFm : public QMainWindow | 42 | class AdvancedFm : public QMainWindow |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | AdvancedFm(); | 46 | AdvancedFm(); |
47 | ~AdvancedFm(); | 47 | ~AdvancedFm(); |
48 | 48 | ||
49 | QTabWidget *TabWidget; | 49 | QTabWidget *TabWidget; |
50 | QWidget *tab, *tab_2, *tab_3; | 50 | QWidget *tab, *tab_2, *tab_3; |
51 | QListView *Local_View, *Remote_View; | 51 | QListView *Local_View, *Remote_View; |
52 | 52 | ||
53 | QLineEdit *currentPathEdit; | 53 | QLineEdit *currentPathEdit; |
54 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; | 54 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; |
55 | QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton; | 55 | QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
56 | QDir currentDir, currentRemoteDir; | 56 | QDir currentDir, currentRemoteDir; |
57 | QComboBox *currentPathCombo; | 57 | QComboBox *currentPathCombo; |
58 | QString filterStr; | 58 | QString filterStr; |
59 | QListViewItem * item; | 59 | QListViewItem * item; |
60 | bool b; | 60 | bool b; |
61 | int currentServerConfig; | 61 | int currentServerConfig; |
62 | protected slots: | 62 | protected slots: |
63 | void showLocalMenu( QListViewItem *); | 63 | void showLocalMenu( QListViewItem *); |
64 | void showRemoteMenu( QListViewItem *); | 64 | void showRemoteMenu( QListViewItem *); |
65 | void doLocalCd(); | 65 | void doLocalCd(); |
66 | void doRemoteCd(); | 66 | void doRemoteCd(); |
67 | // void copy(); | 67 | // void copy(); |
68 | void mkDir(); | 68 | void mkDir(); |
69 | void del(); | 69 | void del(); |
70 | void rn(); | 70 | void rn(); |
71 | void populateLocalView(); | 71 | void populateLocalView(); |
72 | void populateRemoteView(); | 72 | void populateRemoteView(); |
73 | void showHidden(); | 73 | void showHidden(); |
74 | void showRemoteHidden(); | 74 | void showRemoteHidden(); |
75 | void writeConfig(); | 75 | void writeConfig(); |
76 | void readConfig(); | 76 | void readConfig(); |
77 | void localListClicked(QListViewItem *); | 77 | void localListClicked(QListViewItem *); |
78 | void remoteListClicked(QListViewItem *); | 78 | void remoteListClicked(QListViewItem *); |
79 | void localListPressed( int, QListViewItem *, const QPoint&, int); | 79 | void localListPressed( int, QListViewItem *, const QPoint&, int); |
80 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); | 80 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); |
81 | void localMakDir(); | 81 | void localMakDir(); |
82 | void localDelete(); | 82 | void localDelete(); |
83 | void remoteMakDir(); | 83 | void remoteMakDir(); |
84 | void remoteDelete(); | 84 | void remoteDelete(); |
85 | /* bool remoteDirList(const QString &); */ | 85 | /* bool remoteDirList(const QString &); */ |
86 | /* bool remoteChDir(const QString &); */ | 86 | /* bool remoteChDir(const QString &); */ |
87 | void tabChanged(QWidget*); | 87 | void tabChanged(QWidget*); |
88 | void cleanUp(); | 88 | void cleanUp(); |
89 | void remoteRename(); | 89 | void remoteRename(); |
90 | void localRename(); | 90 | void localRename(); |
91 | void runThis(); | 91 | void runThis(); |
92 | void runText(); | 92 | void runText(); |
93 | void filePerms(); | 93 | void filePerms(); |
94 | void doProperties(); | 94 | void doProperties(); |
95 | void runCommand(); | 95 | void runCommand(); |
96 | void runCommandStd(); | 96 | void runCommandStd(); |
97 | QStringList getPath(); | 97 | QStringList getPath(); |
98 | void mkSym(); | 98 | void mkSym(); |
99 | void switchToLocalTab(); | 99 | void switchToLocalTab(); |
100 | void switchToRemoteTab(); | 100 | void switchToRemoteTab(); |
101 | 101 | ||
102 | protected: | 102 | protected: |
103 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; | 103 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; |
104 | QStringList remoteDirPathStringList, localDirPathStringList; | 104 | QStringList remoteDirPathStringList, localDirPathStringList; |
105 | void keyReleaseEvent( QKeyEvent *); | 105 | void keyReleaseEvent( QKeyEvent *); |
106 | protected slots: | 106 | protected slots: |
107 | void homeButtonPushed(); | 107 | void homeButtonPushed(); |
108 | void docButtonPushed(); | 108 | void docButtonPushed(); |
109 | void SDButtonPushed(); | 109 | void SDButtonPushed(); |
110 | void CFButtonPushed(); | 110 | void CFButtonPushed(); |
111 | void QPEButtonPushed(); | ||
111 | void upDir(); | 112 | void upDir(); |
112 | void currentPathComboChanged(); | 113 | void currentPathComboChanged(); |
113 | void copy(); | 114 | void copy(); |
114 | void copyAs(); | 115 | void copyAs(); |
115 | void currentPathComboActivated(const QString &); | 116 | void currentPathComboActivated(const QString &); |
116 | void fillCombo(const QString &); | 117 | void fillCombo(const QString &); |
117 | bool copyFile( const QString & , const QString & ); | 118 | bool copyFile( const QString & , const QString & ); |
118 | void move(); | 119 | void move(); |
119 | void fileStatus(); | 120 | void fileStatus(); |
120 | void doAbout(); | 121 | void doAbout(); |
121 | }; | 122 | }; |
122 | 123 | ||
123 | #endif // ADVANCEDFM_H | 124 | #endif // ADVANCEDFM_H |