summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-03-31 21:39:01 (UTC)
committer zecke <zecke>2002-03-31 21:39:01 (UTC)
commit66357a57409435e5967887af026bc1cf1d725f56 (patch) (unidiff)
tree1be99ea18dd4c693d68afe473b2676a5d0c60ba5 /libopie
parent7208583b0b7ff339e6019b188332d8bcb8f30973 (diff)
downloadopie-66357a57409435e5967887af026bc1cf1d725f56.zip
opie-66357a57409435e5967887af026bc1cf1d725f56.tar.gz
opie-66357a57409435e5967887af026bc1cf1d725f56.tar.bz2
more functionality
Diffstat (limited to 'libopie') (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
@@ -41,2 +41,5 @@
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qaction.h>
43#include <qpopupmenu.h>
44#include <qcursor.h>
42 45
@@ -49,2 +52,6 @@
49 52
53#include <unistd.h>
54#include <stdlib.h>
55#include <sys/stat.h>
56
50#include "ofileselector.h" 57#include "ofileselector.h"
@@ -113,2 +120,3 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString
113 m_files = true; 120 m_files = true;
121 m_custom = 0;
114 122
@@ -180,2 +188,3 @@ void OFileSelector::init()
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 {
@@ -279,6 +288,6 @@ void OFileSelector::setShowFiles(bool files ){
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}
@@ -559,3 +568,3 @@ void OFileSelector::slotViewCheck(const QString &view ){
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
@@ -621,2 +630,9 @@ void OFileSelector::initializeListView()
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};
@@ -678,3 +694,3 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
678 { 694 {
679 bool locked; 695 bool locked=false;
680 QString name; 696 QString name;
@@ -715,2 +731,169 @@ void OFileSelector::setShowDirs(bool dir )
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
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 6936773..458e552 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -80,3 +80,3 @@ class OFileSelectorItem : public QListViewItem {
80 } 80 }
81 bool locked() const{ 81 bool isLocked() const{
82 return mLocked; 82 return mLocked;
@@ -150,3 +150,3 @@ class OFileSelector : public QWidget {
150 void setShowFiles(bool ); 150 void setShowFiles(bool );
151 151 bool cd(const QString &path );
152 152
@@ -158,3 +158,3 @@ class OFileSelector : public QWidget {
158 158
159 void setPopupMenu( const QPopupMenu * ); 159 void setPopupMenu( QPopupMenu * );
160 160
@@ -193,3 +193,7 @@ class OFileSelector : public QWidget {
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;
@@ -214,2 +218,4 @@ class OFileSelector : public QWidget {
214 218
219 QPopupMenu *m_custom;
220
215 QLineEdit *m_edit; 221 QLineEdit *m_edit;
@@ -227,5 +233,2 @@ class OFileSelector : public QWidget {
227 233
228 protected:
229
230 private:
231 // implementation todo 234 // implementation todo
@@ -233,3 +236,3 @@ class OFileSelector : public QWidget {
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();
@@ -245,2 +248,19 @@ class OFileSelector : public QWidget {
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};
@@ -249 +269,2 @@ class OFileSelector : public QWidget {
249#endif 269#endif
270