author | zecke <zecke> | 2002-03-31 21:39:01 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-31 21:39:01 (UTC) |
commit | 66357a57409435e5967887af026bc1cf1d725f56 (patch) (unidiff) | |
tree | 1be99ea18dd4c693d68afe473b2676a5d0c60ba5 | |
parent | 7208583b0b7ff339e6019b188332d8bcb8f30973 (diff) | |
download | opie-66357a57409435e5967887af026bc1cf1d725f56.zip opie-66357a57409435e5967887af026bc1cf1d725f56.tar.gz opie-66357a57409435e5967887af026bc1cf1d725f56.tar.bz2 |
more functionality
-rw-r--r-- | libopie/TODO | 17 | ||||
-rw-r--r-- | libopie/ofileselector.cc | 191 | ||||
-rw-r--r-- | libopie/ofileselector.h | 37 |
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 | |||
@@ -30,32 +30,39 @@ | |||
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qhbox.h> | 32 | #include <qhbox.h> |
33 | #include <qvbox.h> | 33 | #include <qvbox.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qwidgetstack.h> | 35 | #include <qwidgetstack.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qcheckbox.h> | 37 | #include <qcheckbox.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qheader.h> | 39 | #include <qheader.h> |
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> |
44 | #include <qpe/fileselector.h> | 47 | #include <qpe/fileselector.h> |
45 | #include <qpe/applnk.h> | 48 | #include <qpe/applnk.h> |
46 | #include <qpe/global.h> | 49 | #include <qpe/global.h> |
47 | #include <qpe/mimetype.h> | 50 | #include <qpe/mimetype.h> |
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 | ||
52 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 59 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
53 | 60 | ||
54 | namespace { | 61 | namespace { |
55 | 62 | ||
56 | int indexByString( const QComboBox *box, const QString &str ){ | 63 | int indexByString( const QComboBox *box, const QString &str ){ |
57 | int index= -1; | 64 | int index= -1; |
58 | for(int i= 0; i < box->count(); i++ ){ | 65 | for(int i= 0; i < box->count(); i++ ){ |
59 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); | 66 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); |
60 | if( str == box->text(i ) ){ | 67 | if( str == box->text(i ) ){ |
61 | index= i; | 68 | index= i; |
@@ -102,24 +109,25 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString | |||
102 | m_lay = 0; | 109 | m_lay = 0; |
103 | m_boxToolbar = 0; | 110 | m_boxToolbar = 0; |
104 | m_boxOk = 0; | 111 | m_boxOk = 0; |
105 | m_edit = 0; | 112 | m_edit = 0; |
106 | 113 | ||
107 | m_fnLabel = 0; | 114 | m_fnLabel = 0; |
108 | m_checkPerm = 0; | 115 | m_checkPerm = 0; |
109 | m_mimeCheck = 0; | 116 | m_mimeCheck = 0; |
110 | m_viewCheck = 0; | 117 | m_viewCheck = 0; |
111 | 118 | ||
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 |
116 | initPics(); | 124 | initPics(); |
117 | 125 | ||
118 | m_lay = new QVBoxLayout(this); | 126 | m_lay = new QVBoxLayout(this); |
119 | init(); | 127 | init(); |
120 | m_edit->setText( fileName ); | 128 | m_edit->setText( fileName ); |
121 | } | 129 | } |
122 | void OFileSelector::initPics() | 130 | void OFileSelector::initPics() |
123 | { | 131 | { |
124 | qWarning("init pics" ); | 132 | qWarning("init pics" ); |
125 | m_pixmaps = new QMap<QString,QPixmap>; | 133 | m_pixmaps = new QMap<QString,QPixmap>; |
@@ -169,24 +177,25 @@ void OFileSelector::init() | |||
169 | 177 | ||
170 | m_stack = new QWidgetStack(this, "wstack" ); | 178 | m_stack = new QWidgetStack(this, "wstack" ); |
171 | if( m_selector == NORMAL ){ | 179 | if( m_selector == NORMAL ){ |
172 | QString currMime; | 180 | QString currMime; |
173 | if( m_mimeCheck != 0 ) | 181 | if( m_mimeCheck != 0 ) |
174 | currMime = m_mimeCheck->currentText(); | 182 | currMime = m_mimeCheck->currentText(); |
175 | 183 | ||
176 | updateMimes(); | 184 | updateMimes(); |
177 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); | 185 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); |
178 | m_stack->addWidget(m_select, NORMAL ); | 186 | m_stack->addWidget(m_select, NORMAL ); |
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(); |
183 | } | 192 | } |
184 | 193 | ||
185 | if(m_shLne ){ | 194 | if(m_shLne ){ |
186 | initializeName(); | 195 | initializeName(); |
187 | } | 196 | } |
188 | 197 | ||
189 | if(m_shPerm ){ | 198 | if(m_shPerm ){ |
190 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); | 199 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); |
191 | m_checkPerm->setChecked( false ); | 200 | m_checkPerm->setChecked( false ); |
192 | m_lay->addWidget(m_checkPerm ); | 201 | m_lay->addWidget(m_checkPerm ); |
@@ -268,28 +277,28 @@ QCheckBox* OFileSelector::permissionCheckbox( ) | |||
268 | { | 277 | { |
269 | return m_checkPerm; | 278 | return m_checkPerm; |
270 | } | 279 | } |
271 | void OFileSelector::setCaseSensetive( bool caSe ) | 280 | void OFileSelector::setCaseSensetive( bool caSe ) |
272 | { | 281 | { |
273 | m_case = caSe; | 282 | m_case = caSe; |
274 | reparse(); | 283 | reparse(); |
275 | } | 284 | } |
276 | void OFileSelector::setShowFiles(bool files ){ | 285 | void OFileSelector::setShowFiles(bool files ){ |
277 | m_files = files; | 286 | m_files = files; |
278 | reparse(); | 287 | reparse(); |
279 | } | 288 | } |
280 | void OFileSelector::setPopupMenu(const QPopupMenu * ) | 289 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) |
281 | { | 290 | { |
282 | //delete oldpopup; | 291 | //delete oldpopup; |
283 | 292 | m_custom = pop; | |
284 | } | 293 | } |
285 | bool OFileSelector::setPermission( ) const | 294 | bool OFileSelector::setPermission( ) const |
286 | { | 295 | { |
287 | if( m_checkPerm == 0 ) | 296 | if( m_checkPerm == 0 ) |
288 | return false; | 297 | return false; |
289 | else | 298 | else |
290 | return m_checkPerm->isChecked(); | 299 | return m_checkPerm->isChecked(); |
291 | } | 300 | } |
292 | void OFileSelector::setPermissionChecked( bool check ) | 301 | void OFileSelector::setPermissionChecked( bool check ) |
293 | { | 302 | { |
294 | if( m_checkPerm == 0 ) | 303 | if( m_checkPerm == 0 ) |
295 | return; | 304 | return; |
@@ -548,25 +557,25 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
548 | if( m_View != 0) // delete 0 shouldn't crash but it did :( | 557 | if( m_View != 0) // delete 0 shouldn't crash but it did :( |
549 | delete m_View; | 558 | delete m_View; |
550 | m_View = 0; | 559 | m_View = 0; |
551 | delete m_select; | 560 | delete m_select; |
552 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime, | 561 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime, |
553 | m_stack,"fileselector", FALSE, FALSE ); | 562 | m_stack,"fileselector", FALSE, FALSE ); |
554 | m_stack->addWidget( m_select, NORMAL ); | 563 | m_stack->addWidget( m_select, NORMAL ); |
555 | m_mimeCheck->clear(); | 564 | m_mimeCheck->clear(); |
556 | m_selector = NORMAL; | 565 | m_selector = NORMAL; |
557 | updateMimes(); | 566 | updateMimes(); |
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") ){ |
563 | // remove from the stack | 572 | // remove from the stack |
564 | delete m_select; | 573 | delete m_select; |
565 | m_select = 0; | 574 | m_select = 0; |
566 | delete m_View; | 575 | delete m_View; |
567 | m_View = 0; | 576 | m_View = 0; |
568 | m_selector = EXTENDED; | 577 | m_selector = EXTENDED; |
569 | // create the ListView or IconView | 578 | // create the ListView or IconView |
570 | initializeListView(); | 579 | initializeListView(); |
571 | 580 | ||
572 | reparse(); | 581 | reparse(); |
@@ -610,24 +619,31 @@ void OFileSelector::initializeListView() | |||
610 | // set up the stuff | 619 | // set up the stuff |
611 | // Pixmap Name Date Size mime | 620 | // Pixmap Name Date Size mime |
612 | //(m_View->header() )->hide(); | 621 | //(m_View->header() )->hide(); |
613 | //m_View->setRootIsDecorated(false); | 622 | //m_View->setRootIsDecorated(false); |
614 | m_View->addColumn(" "); | 623 | m_View->addColumn(" "); |
615 | m_View->addColumn(tr("Name") ); | 624 | m_View->addColumn(tr("Name") ); |
616 | m_View->addColumn(tr("Size") ); | 625 | m_View->addColumn(tr("Size") ); |
617 | m_View->addColumn(tr("Date"), 60 ); | 626 | m_View->addColumn(tr("Date"), 60 ); |
618 | m_View->addColumn(tr("Mime Type") ); | 627 | m_View->addColumn(tr("Mime Type") ); |
619 | QHeader *header = m_View->header(); | 628 | QHeader *header = m_View->header(); |
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 |
624 | if we're in OPEN !isReadable is locked | 640 | if we're in OPEN !isReadable is locked |
625 | if we're in SAVE !isWriteable is locked | 641 | if we're in SAVE !isWriteable is locked |
626 | 642 | ||
627 | 643 | ||
628 | */ | 644 | */ |
629 | 645 | ||
630 | 646 | ||
631 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ | 647 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ |
632 | qWarning("Add Files" ); | 648 | qWarning("Add Files" ); |
633 | if( !m_files ){ | 649 | if( !m_files ){ |
@@ -667,25 +683,25 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ) | |||
667 | } | 683 | } |
668 | new OFileSelectorItem( m_View, pix, name, | 684 | new OFileSelectorItem( m_View, pix, name, |
669 | info->lastModified().toString(), | 685 | info->lastModified().toString(), |
670 | QString::number( info->size() ), | 686 | QString::number( info->size() ), |
671 | dir, locked ); | 687 | dir, locked ); |
672 | } | 688 | } |
673 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | 689 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) |
674 | { | 690 | { |
675 | if(!m_dir ) | 691 | if(!m_dir ) |
676 | return; | 692 | return; |
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; |
682 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | 698 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ |
683 | locked = true; | 699 | locked = true; |
684 | if( symlink ){ | 700 | if( symlink ){ |
685 | pix = (*m_pixmaps)["symlinkedlocked"]; | 701 | pix = (*m_pixmaps)["symlinkedlocked"]; |
686 | }else{ | 702 | }else{ |
687 | pix = Resource::loadPixmap("lockedfolder" ); | 703 | pix = Resource::loadPixmap("lockedfolder" ); |
688 | } | 704 | } |
689 | }else{ | 705 | }else{ |
690 | if( symlink ){ | 706 | if( symlink ){ |
691 | pix = (*m_pixmaps)["dirsymlink" ]; | 707 | pix = (*m_pixmaps)["dirsymlink" ]; |
@@ -704,14 +720,181 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | |||
704 | new OFileSelectorItem(m_View, pix, | 720 | new OFileSelectorItem(m_View, pix, |
705 | name, info->lastModified().toString(), | 721 | name, info->lastModified().toString(), |
706 | QString::number(info->size() ),info->dirPath(true), locked, true ); | 722 | QString::number(info->size() ),info->dirPath(true), locked, true ); |
707 | 723 | ||
708 | } | 724 | } |
709 | } | 725 | } |
710 | void OFileSelector::setShowDirs(bool dir ) | 726 | void OFileSelector::setShowDirs(bool dir ) |
711 | { | 727 | { |
712 | m_dir = dir; | 728 | m_dir = dir; |
713 | reparse(); | 729 | reparse(); |
714 | } | 730 | } |
715 | 731 | ||
732 | void 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 | } | ||
740 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | ||
741 | { | ||
742 | slotFileSelected(lnk.name() ); | ||
743 | emit fileSelected( lnk ); | ||
744 | } | ||
745 | void OFileSelector::slotSelectionChanged() // get the current items | ||
746 | // fixme | ||
747 | { | ||
748 | qWarning("selection changed" ); | ||
749 | } | ||
750 | void 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 | ||
770 | void 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 | } | ||
798 | void 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 | } | ||
805 | void 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 | } | ||
847 | bool 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 | |||
859 | void 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 | } | ||
867 | void 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 | } | ||
875 | void OFileSelector::slotRescan() | ||
876 | { | ||
877 | reparse(); | ||
878 | } | ||
879 | void OFileSelector::slotRename() | ||
880 | { | ||
881 | // rename inline | ||
882 | } | ||
883 | void 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 | |||
@@ -69,25 +69,25 @@ class OFileSelectorItem : public QListViewItem { | |||
69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
70 | const QString &date, const QString &size, const QString &mDir, | 70 | const QString &date, const QString &size, const QString &mDir, |
71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | 71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { |
72 | setPixmap(0, pixmap ); | 72 | setPixmap(0, pixmap ); |
73 | setText(1, path ); | 73 | setText(1, path ); |
74 | setText(2, size ); | 74 | setText(2, size ); |
75 | setText(3, date ); | 75 | setText(3, date ); |
76 | //setText(4, mDir ); | 76 | //setText(4, mDir ); |
77 | m_dir = mDir; | 77 | m_dir = mDir; |
78 | dir = isDir; | 78 | dir = isDir; |
79 | mLocked = isLocked; | 79 | mLocked = isLocked; |
80 | } | 80 | } |
81 | bool locked() const{ | 81 | bool isLocked() const{ |
82 | return mLocked; | 82 | return mLocked; |
83 | } | 83 | } |
84 | QString directory()const{ | 84 | QString directory()const{ |
85 | return m_dir; | 85 | return m_dir; |
86 | } | 86 | } |
87 | bool isDir()const{ | 87 | bool isDir()const{ |
88 | return dir; | 88 | return dir; |
89 | } | 89 | } |
90 | QString path()const{ | 90 | QString path()const{ |
91 | return text(1 ); | 91 | return text(1 ); |
92 | } | 92 | } |
93 | QString key(int id, bool )const { | 93 | QString key(int id, bool )const { |
@@ -139,33 +139,33 @@ class OFileSelector : public QWidget { | |||
139 | void setMode( int ); | 139 | void setMode( int ); |
140 | 140 | ||
141 | bool showDirs()const { return m_dir; } | 141 | bool showDirs()const { return m_dir; } |
142 | void setShowDirs(bool ); | 142 | void setShowDirs(bool ); |
143 | 143 | ||
144 | const QListView* listView() { return m_View; }; | 144 | const QListView* listView() { return m_View; }; |
145 | 145 | ||
146 | bool isCaseSensetive()const { return m_case; } | 146 | bool isCaseSensetive()const { return m_case; } |
147 | void setCaseSensetive(bool caSe ); | 147 | void setCaseSensetive(bool caSe ); |
148 | 148 | ||
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 | ||
154 | int mode()const { return m_mode; }; | 154 | int mode()const { return m_mode; }; |
155 | int selector()const { return m_selector; }; | 155 | int selector()const { return m_selector; }; |
156 | void setSelector( int ); | 156 | void setSelector( int ); |
157 | 157 | ||
158 | 158 | ||
159 | void setPopupMenu( const QPopupMenu * ); | 159 | void setPopupMenu( QPopupMenu * ); |
160 | 160 | ||
161 | void updateLay(); | 161 | void updateLay(); |
162 | 162 | ||
163 | void reparse(); // re reads the dir | 163 | void reparse(); // re reads the dir |
164 | 164 | ||
165 | QString selectedName( )const; | 165 | QString selectedName( )const; |
166 | QStringList selectedNames()const; | 166 | QStringList selectedNames()const; |
167 | 167 | ||
168 | QString selectedPath() const; | 168 | QString selectedPath() const; |
169 | QStringList selectedPaths() const; | 169 | QStringList selectedPaths() const; |
170 | 170 | ||
171 | QString directory()const; | 171 | QString directory()const; |
@@ -182,68 +182,89 @@ class OFileSelector : public QWidget { | |||
182 | void closeMe(); | 182 | void closeMe(); |
183 | void ok(); | 183 | void ok(); |
184 | void cancel(); | 184 | void cancel(); |
185 | 185 | ||
186 | protected slots: | 186 | protected slots: |
187 | void slotOk(); | 187 | void slotOk(); |
188 | void slotCancel(); | 188 | void slotCancel(); |
189 | void slotViewCheck(const QString & ); | 189 | void slotViewCheck(const QString & ); |
190 | void slotMimeCheck(const QString & ); | 190 | void slotMimeCheck(const QString & ); |
191 | protected: | 191 | protected: |
192 | void init(); | 192 | void init(); |
193 | void updateMimes(); | 193 | void updateMimes(); |
194 | int m_mode, m_selector; | 194 | |
195 | protected: | ||
196 | |||
197 | private: | ||
198 | int 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; |
197 | QPushButton *m_reread, *m_up; | 201 | QPushButton *m_reread, *m_up; |
198 | QListView *m_View; | 202 | QListView *m_View; |
199 | QCheckBox *m_checkPerm; | 203 | QCheckBox *m_checkPerm; |
200 | 204 | ||
201 | QString m_currentDir; | 205 | QString m_currentDir; |
202 | QString m_name; | 206 | QString m_name; |
203 | QStringList m_mimetypes; | 207 | QStringList m_mimetypes; |
204 | 208 | ||
205 | FileSelector *m_select; | 209 | FileSelector *m_select; |
206 | QWidgetStack *m_stack; | 210 | QWidgetStack *m_stack; |
207 | QVBoxLayout *m_lay; | 211 | QVBoxLayout *m_lay; |
208 | QGridLayout *m_Oselector; | 212 | QGridLayout *m_Oselector; |
209 | 213 | ||
210 | QHBoxLayout *m_boxToolbar; | 214 | QHBoxLayout *m_boxToolbar; |
211 | QHBoxLayout *m_boxOk; | 215 | QHBoxLayout *m_boxOk; |
212 | QHBoxLayout *m_boxName; | 216 | QHBoxLayout *m_boxName; |
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; |
217 | bool m_shTool:1; | 223 | bool m_shTool:1; |
218 | bool m_shPerm:1; | 224 | bool m_shPerm:1; |
219 | bool m_shLne:1; | 225 | bool m_shLne:1; |
220 | bool m_shChooser:1; | 226 | bool m_shChooser:1; |
221 | bool m_shYesNo:1; | 227 | bool m_shYesNo:1; |
222 | bool m_boCheckPerm:1; | 228 | bool m_boCheckPerm:1; |
223 | bool m_autoMime:1; | 229 | bool m_autoMime:1; |
224 | bool m_case:1; | 230 | bool m_case:1; |
225 | bool m_dir:1; | 231 | bool m_dir:1; |
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(); |
237 | void initializeYes(); | 240 | void initializeYes(); |
238 | void initializeChooser(); | 241 | void initializeChooser(); |
239 | void initializeListView(); | 242 | void initializeListView(); |
240 | void initPics(); | 243 | void initPics(); |
241 | bool compliesMime(const QString &path, const QString &mime); | 244 | bool compliesMime(const QString &path, const QString &mime); |
242 | 245 | ||
243 | class OFileSelectorPrivate; | 246 | class OFileSelectorPrivate; |
244 | OFileSelectorPrivate *d; | 247 | OFileSelectorPrivate *d; |
245 | static QMap<QString,QPixmap> *m_pixmaps; | 248 | static QMap<QString,QPixmap> *m_pixmaps; |
249 | |||
250 | private 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 | |||