summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/TODO17
-rw-r--r--libopie/ofileselector.cc191
-rw-r--r--libopie/ofileselector.h37
3 files changed, 233 insertions, 12 deletions
diff --git a/libopie/TODO b/libopie/TODO
new file mode 100644
index 0000000..c1bf6d1
--- a/dev/null
+++ b/libopie/TODO
@@ -0,0 +1,17 @@
1- xmltree done
2
3- tododb
4 - set Alarms
5 - multiple categories
6 - Attendees
7
8- OFileSelector
9 - DocLnk when not in Document Mode
10 - TreeView have a own OFileSelectorItem for this
11 - IconView add a QIconView to the widgetstack
12 - Move OFileSelectorItem to it's own files
13 - add functions to access the member variables
14 - debug
15
16- Clickable labels?
17 Harlekin you wanted them in the libs? \ No newline at end of file
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 128292f..b583125 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -40,4 +40,7 @@
40#include <qdir.h> 40#include <qdir.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qaction.h>
43#include <qpopupmenu.h>
44#include <qcursor.h>
42 45
43#include <qpe/qpeapplication.h> 46#include <qpe/qpeapplication.h>
@@ -48,4 +51,8 @@
48#include <qpe/resource.h> 51#include <qpe/resource.h>
49 52
53#include <unistd.h>
54#include <stdlib.h>
55#include <sys/stat.h>
56
50#include "ofileselector.h" 57#include "ofileselector.h"
51 58
@@ -112,4 +119,5 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString
112 m_dir = true; 119 m_dir = true;
113 m_files = true; 120 m_files = true;
121 m_custom = 0;
114 122
115 if(m_pixmaps == 0 ) // init the pixmaps 123 if(m_pixmaps == 0 ) // init the pixmaps
@@ -179,4 +187,5 @@ void OFileSelector::init()
179 m_lay->addWidget(m_stack ); 187 m_lay->addWidget(m_stack );
180 m_stack->raiseWidget(NORMAL ); 188 m_stack->raiseWidget(NORMAL );
189 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
181 }else { 190 }else {
182 initializeListView(); 191 initializeListView();
@@ -278,8 +287,8 @@ void OFileSelector::setShowFiles(bool files ){
278 reparse(); 287 reparse();
279} 288}
280void OFileSelector::setPopupMenu(const QPopupMenu * ) 289void OFileSelector::setPopupMenu(QPopupMenu *pop )
281{ 290{
282 //delete oldpopup; 291 //delete oldpopup;
283 292 m_custom = pop;
284} 293}
285bool OFileSelector::setPermission( ) const 294bool OFileSelector::setPermission( ) const
@@ -558,5 +567,5 @@ void OFileSelector::slotViewCheck(const QString &view ){
558 m_mimeCheck->insertStringList( m_mimetypes ); 567 m_mimeCheck->insertStringList( m_mimetypes );
559 m_stack->raiseWidget( NORMAL ); 568 m_stack->raiseWidget( NORMAL );
560 569 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
561 570
562 }else if(view == QString::fromLatin1("Files") ){ 571 }else if(view == QString::fromLatin1("Files") ){
@@ -620,4 +629,11 @@ void OFileSelector::initializeListView()
620 header->hide(); 629 header->hide();
621 m_View->setSorting(1 ); 630 m_View->setSorting(1 );
631 // connect now
632 connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) );
633 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
634 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
635 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
636 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
637 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
622}; 638};
623/* If a item is locked depends on the mode 639/* If a item is locked depends on the mode
@@ -677,5 +693,5 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
677 //if( showDirs ) 693 //if( showDirs )
678 { 694 {
679 bool locked; 695 bool locked=false;
680 QString name; 696 QString name;
681 QPixmap pix; 697 QPixmap pix;
@@ -714,4 +730,171 @@ void OFileSelector::setShowDirs(bool dir )
714} 730}
715 731
732void OFileSelector::slotFileSelected(const QString &string )
733{
734 if(m_shLne )
735 m_edit->setText( string );
736
737 emit fileSelected( string );
738 // do AppLnk stuff
739}
740void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
741{
742 slotFileSelected(lnk.name() );
743 emit fileSelected( lnk );
744}
745void OFileSelector::slotSelectionChanged() // get the current items
746 // fixme
747{
748 qWarning("selection changed" );
749}
750void OFileSelector::slotCurrentChanged(QListViewItem *item )
751{
752 qWarning("current changed" );
753 if( item == 0 )
754 return;
755
756 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
757 OFileSelectorItem *sel = (OFileSelectorItem*)item;
758 if(!sel->isDir() ){
759 qWarning("is not dir" );
760 if(m_shLne ){
761 m_edit->setText(sel->text(1) );
762 qWarning("setTexy" );
763 }
764 }
765 }else {
766 qWarning("mode not extended" );
767 }
768}
769// either select or change dir
770void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int )
771{
772 if( item == 0 )
773 return;
774
775 if( button != Qt::LeftButton )
776 return;
777
778 qWarning("clicked" );
779 if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
780 qWarning("inside" );
781 OFileSelectorItem *sel = (OFileSelectorItem*)item;
782 if(!sel->isLocked() ){ // not locked either changedir or open
783 QStringList str = QStringList::split("->", sel->text(1) );
784 if(sel->isDir() ){
785 cd( sel->directory() + "/" + str[0] );
786 }else{
787 qWarning("file" );
788 if(m_shLne )
789 m_edit->setText(str[0] );
790 emit fileSelected(str[0] );
791 // emit DocLnk need to do it
792 }
793 }else{
794 qWarning( "locked" );
795 }
796 };
797}
798void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
799{
800 if( button != Qt::RightButton )
801 return;
802 qWarning("right button" );
803 slotContextMenu(item);
804}
805void OFileSelector::slotContextMenu(QListViewItem *item)
806{
807 qWarning("context menu" );
808 if( m_custom !=0){
809 m_custom->exec();
810 }else{
811 QPopupMenu menu;
812 QAction act;
813 OFileSelectorItem *sel = (OFileSelectorItem*)item;
814 if(sel->isDir() ){
815 act.setText( tr("Change Directory") );
816 act.addTo(&menu );
817 connect(&act, SIGNAL(activated() ),
818 this, SLOT(slotChangedDir() ) );
819 }else{
820 act.setText( tr("Open file" ) );
821 act.addTo( &menu );
822 connect(&act, SIGNAL(activated() ),
823 this, SLOT(slotOpen() ) );
824 }
825 QAction rescan;
826 rescan.setText( tr("Rescan") );
827 rescan.addTo( &menu );
828 connect(&act, SIGNAL(activated() ),
829 this, SLOT(slotRescan() ) );
830
831 QAction rename;
832 rename.setText( tr("Rename") );
833 rename.addTo( &menu );
834 connect(&act, SIGNAL(activated() ),
835 this, SLOT(slotRename() ) );
836
837 menu.insertSeparator();
838 QAction delItem;
839 delItem.setText( tr("Delete") );
840 delItem.addTo(&menu );
841 connect(&act, SIGNAL(activated() ),
842 this, SLOT(slotDelete() ) );
843
844 menu.exec(QCursor::pos() );
845 }
846}
847bool OFileSelector::cd(const QString &str )
848{
849 qWarning(" dir %s", str.latin1() );
850 QDir dir( str);
851 if(dir.exists() ){
852 m_currentDir = str;
853 reparse();
854 return true;
855 }
856 return false;
857}
858
859void OFileSelector::slotChangedDir()
860{
861 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
862 if(sel->isDir() ){
863 QStringList str = QStringList::split("->", sel->text(1) );
864 cd( sel->directory() + "/" + str[0] );
865 }
866}
867void OFileSelector::slotOpen()
868{
869 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
870 if(!sel->isDir() ){
871 QStringList str = QStringList::split("->", sel->text(1) );
872 slotFileSelected( str[0] );
873 }
874}
875void OFileSelector::slotRescan()
876{
877 reparse();
878}
879void OFileSelector::slotRename()
880{
881 // rename inline
882}
883void OFileSelector::slotDelete()
884{
885 qWarning("delete slot" );
886 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
887 QStringList list = QStringList::split("->", sel->text(1) );
888 if( sel->isDir() ){
889 QString str = QString::fromLatin1("rm -rf ") + list[0];
890 ::system(str.utf8().data() );
891 }else{
892 QFile::remove( list[0] );
893 }
894 m_View->takeItem( sel );
895 delete sel;
896}
897
898
716 899
717 900
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 6936773..458e552 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -79,5 +79,5 @@ class OFileSelectorItem : public QListViewItem {
79 mLocked = isLocked; 79 mLocked = isLocked;
80 } 80 }
81 bool locked() const{ 81 bool isLocked() const{
82 return mLocked; 82 return mLocked;
83 } 83 }
@@ -149,5 +149,5 @@ class OFileSelector : public QWidget {
149 bool showFiles()const { return m_files; }; 149 bool showFiles()const { return m_files; };
150 void setShowFiles(bool ); 150 void setShowFiles(bool );
151 151 bool cd(const QString &path );
152 152
153 153
@@ -157,5 +157,5 @@ class OFileSelector : public QWidget {
157 157
158 158
159 void setPopupMenu( const QPopupMenu * ); 159 void setPopupMenu( QPopupMenu * );
160 160
161 void updateLay(); 161 void updateLay();
@@ -192,5 +192,9 @@ class OFileSelector : public QWidget {
192 void init(); 192 void init();
193 void updateMimes(); 193 void updateMimes();
194 int m_mode, m_selector; 194
195 protected:
196
197 private:
198int m_mode, m_selector;
195 QComboBox *m_location, *m_mimeCheck, *m_viewCheck; 199 QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
196 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; 200 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
@@ -213,4 +217,6 @@ class OFileSelector : public QWidget {
213 QHBoxLayout *m_boxView; 217 QHBoxLayout *m_boxView;
214 218
219 QPopupMenu *m_custom;
220
215 QLineEdit *m_edit; 221 QLineEdit *m_edit;
216 QLabel *m_fnLabel; 222 QLabel *m_fnLabel;
@@ -226,11 +232,8 @@ class OFileSelector : public QWidget {
226 bool m_files:1; 232 bool m_files:1;
227 233
228 protected:
229
230 private:
231 // implementation todo 234 // implementation todo
232 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); 235 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE );
233 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); 236 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE );
234 virtual void addSymlink(const QString &mime, QFileInfo *info, bool broken = FALSE ){}; 237 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){};
235 void delItems(); 238 void delItems();
236 void initializeName(); 239 void initializeName();
@@ -244,6 +247,24 @@ class OFileSelector : public QWidget {
244 OFileSelectorPrivate *d; 247 OFileSelectorPrivate *d;
245 static QMap<QString,QPixmap> *m_pixmaps; 248 static QMap<QString,QPixmap> *m_pixmaps;
249
250private slots:
251 void slotFileSelected(const QString & ); // not really meant to be a slot
252 void slotFileBridgeSelected( const DocLnk & );
253 virtual void slotSelectionChanged();
254 virtual void slotCurrentChanged(QListViewItem* );
255 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int);
256 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int );
257 virtual void slotContextMenu( QListViewItem *item);
258 // listview crap see above
259 // PopupMenu crap
260 virtual void slotChangedDir();
261 virtual void slotOpen();
262 virtual void slotRescan();
263 virtual void slotRename();
264 virtual void slotDelete();
265
246}; 266};
247 267
248 268
249#endif 269#endif
270