summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp30
-rw-r--r--libopie2/opieui/fileselector/ofileselector.h3
-rw-r--r--libopie2/opieui/fileselector/ofileselector_p.h2
3 files changed, 12 insertions, 23 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index e8d502f..01a51a2 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -147,24 +147,30 @@ void OFileViewInterface::setCurrentFileName( const QString& str )
147} 147}
148 148
149QString OFileViewInterface::currentFileName()const 149QString OFileViewInterface::currentFileName()const
150{ 150{
151 return selector()->m_lneEdit->text(); 151 return selector()->m_lneEdit->text();
152} 152}
153 153
154QString OFileViewInterface::startDirectory()const 154QString OFileViewInterface::startDirectory()const
155{ 155{
156 return selector()->m_startDir; 156 return selector()->m_startDir;
157} 157}
158 158
159bool OFileViewInterface::allItem( const QString& item )const
160{
161 return selector()->m_allList.contains( item );
162}
163
164
159ODocumentFileView::ODocumentFileView( OFileSelector* selector ) 165ODocumentFileView::ODocumentFileView( OFileSelector* selector )
160 :OFileViewInterface( selector ) 166 :OFileViewInterface( selector )
161{ 167{
162 m_selector = 0; 168 m_selector = 0;
163 setName( QObject::tr("Documents") ); 169 setName( QObject::tr("Documents") );
164} 170}
165 171
166ODocumentFileView::~ODocumentFileView() 172ODocumentFileView::~ODocumentFileView()
167{ 173{
168} 174}
169 175
170QString ODocumentFileView::selectedName()const 176QString ODocumentFileView::selectedName()const
@@ -521,32 +527,24 @@ bool OFileViewFileListView::eventFilter (QObject *, QEvent *e)
521 if ( e->type() == QEvent::KeyPress ) 527 if ( e->type() == QEvent::KeyPress )
522 { 528 {
523 QKeyEvent *k = (QKeyEvent *)e; 529 QKeyEvent *k = (QKeyEvent *)e;
524 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 530 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
525 { 531 {
526 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 532 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
527 return true; 533 return true;
528 } 534 }
529 } 535 }
530 return false; 536 return false;
531} 537}
532 538
533/**
534 * @return true if the item show all files or directories
535 */
536bool OFileViewFileListView::allItem( const QString& item )const
537{
538 return m_sel->allItem( item );
539}
540
541void OFileViewFileListView::connectSlots() 539void OFileViewFileListView::connectSlots()
542{ 540{
543 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 541 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
544 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 542 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
545 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), 543 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
546 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); 544 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
547} 545}
548 546
549void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) 547void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
550{ 548{
551 if (!item) 549 if (!item)
552 return; 550 return;
@@ -816,25 +814,25 @@ int OFileViewFileSystem::fileCount()const
816 814
817QWidget* OFileViewFileSystem::widget( QWidget* parent ) 815QWidget* OFileViewFileSystem::widget( QWidget* parent )
818{ 816{
819 if (!m_view ) 817 if (!m_view )
820 { 818 {
821 m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); 819 m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
822 } 820 }
823 return m_view; 821 return m_view;
824} 822}
825 823
826void OFileViewFileSystem::activate( const QString& str ) 824void OFileViewFileSystem::activate( const QString& str )
827{ 825{
828 m_all = m_view->allItem( str ); 826 m_all = allItem( str );
829} 827}
830 828
831 829
832} 830}
833/* Selector */ 831/* Selector */
834/** 832/**
835 * @short new and complete c'tor 833 * @short new and complete c'tor
836 * 834 *
837 * Create a OFileSelector to let the user select a file. It can 835 * Create a OFileSelector to let the user select a file. It can
838 * either be used to open a file, select a save name in a dir or 836 * either be used to open a file, select a save name in a dir or
839 * as a dropin for the FileSelector. 837 * as a dropin for the FileSelector.
840 * 838 *
@@ -866,25 +864,25 @@ OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
866 bool showNew, bool showClose) 864 bool showNew, bool showClose)
867 :QWidget( parent, "OFileSelector" ) 865 :QWidget( parent, "OFileSelector" )
868{ 866{
869 m_current = 0; 867 m_current = 0;
870 m_shNew = showNew; 868 m_shNew = showNew;
871 m_shClose = showClose; 869 m_shClose = showClose;
872 m_mimeType = mimetypes; 870 m_mimeType = mimetypes;
873 m_startDir = dirName; 871 m_startDir = dirName;
874 872
875 m_mode = mode; 873 m_mode = mode;
876 m_selector = sel; 874 m_selector = sel;
877 875
878 m_allList = new QStringList(); 876 m_allList = QStringList();
879 877
880 initUI(); 878 initUI();
881 m_lneEdit->setText( fileName ); 879 m_lneEdit->setText( fileName );
882 initMime(); 880 initMime();
883 initViews(); 881 initViews();
884 882
885 QString str; 883 QString str;
886 switch ( m_selector ) 884 switch ( m_selector )
887 { 885 {
888 default: 886 default:
889 case Normal: 887 case Normal:
890 if ( m_mode == DIRECTORYSELECTOR ) 888 if ( m_mode == DIRECTORYSELECTOR )
@@ -1024,30 +1022,30 @@ void OFileSelector::initViews()
1024 } 1022 }
1025 1023
1026 connect(m_cmbView, SIGNAL(activated(const QString&) ), 1024 connect(m_cmbView, SIGNAL(activated(const QString&) ),
1027 this, SLOT(slotViewChange(const QString&) ) ); 1025 this, SLOT(slotViewChange(const QString&) ) );
1028 1026
1029 /* see above why add both */ 1027 /* see above why add both */
1030 OFileViewInterface* in = new OFileViewFileSystem( this ); 1028 OFileViewInterface* in = new OFileViewFileSystem( this );
1031 1029
1032 if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) 1030 if ( m_mode == OFileSelector::DIRECTORYSELECTOR )
1033 { 1031 {
1034 m_views.insert( QObject::tr("Directories"), in ); 1032 m_views.insert( QObject::tr("Directories"), in );
1035 m_views.insert( QObject::tr("All Directories"), in ); 1033 m_views.insert( QObject::tr("All Directories"), in );
1036 m_allList->append( QObject::tr("All Directories") ); 1034 m_allList.append( QObject::tr("All Directories") );
1037 } else { 1035 } else {
1038 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); 1036 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
1039 m_views.insert( QObject::tr("Files"), in ); 1037 m_views.insert( QObject::tr("Files"), in );
1040 m_views.insert( QObject::tr("All Files"), in ); 1038 m_views.insert( QObject::tr("All Files"), in );
1041 m_allList->append( QObject::tr("All Files") ); 1039 m_allList.append( QObject::tr("All Files") );
1042 } 1040 }
1043} 1041}
1044 1042
1045void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { 1043void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) {
1046 m_viewsPtr.append( iface ); 1044 m_viewsPtr.append( iface );
1047} 1045}
1048 1046
1049 1047
1050/** 1048/**
1051 * d'tor 1049 * d'tor
1052 */ 1050 */
1053OFileSelector::~OFileSelector() 1051OFileSelector::~OFileSelector()
@@ -1149,32 +1147,24 @@ int OFileSelector::mode()const
1149 return m_mode; 1147 return m_mode;
1150} 1148}
1151 1149
1152 1150
1153/** 1151/**
1154 * @return the Selector of the OFileSelector 1152 * @return the Selector of the OFileSelector
1155 */ 1153 */
1156int OFileSelector::selector()const 1154int OFileSelector::selector()const
1157{ 1155{
1158 return m_selector; 1156 return m_selector;
1159} 1157}
1160 1158
1161/**
1162 * @return true if the item show all files or directories
1163 */
1164bool OFileSelector::allItem( const QString& item )const
1165{
1166 return ( m_allList->findIndex( item ) != -1 );
1167}
1168
1169QStringList OFileSelector::currentMimeType()const 1159QStringList OFileSelector::currentMimeType()const
1170{ 1160{
1171 return m_mimeType[m_cmbMime->currentText()]; 1161 return m_mimeType[m_cmbMime->currentText()];
1172} 1162}
1173 1163
1174void OFileSelector::slotMimeTypeChanged() 1164void OFileSelector::slotMimeTypeChanged()
1175{ 1165{
1176 reread(); 1166 reread();
1177} 1167}
1178 1168
1179void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) 1169void OFileSelector::slotDocLnkBridge( const DocLnk& lnk)
1180{ 1170{
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h
index d96712a..d166afd 100644
--- a/libopie2/opieui/fileselector/ofileselector.h
+++ b/libopie2/opieui/fileselector/ofileselector.h
@@ -112,25 +112,24 @@ public:
112 112
113 QString selectedName()const; 113 QString selectedName()const;
114 QString selectedPath()const; 114 QString selectedPath()const;
115 QString directory()const; 115 QString directory()const;
116 116
117 DocLnk selectedDocument()const; 117 DocLnk selectedDocument()const;
118 118
119 int fileCount()const; 119 int fileCount()const;
120 void reread(); 120 void reread();
121 121
122 int mode()const; 122 int mode()const;
123 int selector()const; 123 int selector()const;
124 bool allItem( const QString& )const;
125 124
126 /** 125 /**
127 * Set the Icon visible 126 * Set the Icon visible
128 * @param b Show or Hide the New Button 127 * @param b Show or Hide the New Button
129 */ 128 */
130 void setNewVisible( bool b ); 129 void setNewVisible( bool b );
131 130
132 /** 131 /**
133 * Set the Icon visible 132 * Set the Icon visible
134 */ 133 */
135 void setCloseVisible( bool b ); 134 void setCloseVisible( bool b );
136 135
@@ -204,25 +203,25 @@ private:
204 MimeTypes m_mimeType; // list of mimetypes 203 MimeTypes m_mimeType; // list of mimetypes
205 204
206 QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr 205 QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
207 /* views register themselves automatically */ 206 /* views register themselves automatically */
208 QList<Internal::OFileViewInterface> m_viewsPtr; 207 QList<Internal::OFileViewInterface> m_viewsPtr;
209 QHBox* m_nameBox; // the LineEdit + Label is hold here 208 QHBox* m_nameBox; // the LineEdit + Label is hold here
210 QHBox* m_cmbBox; // this holds the two combo boxes 209 QHBox* m_cmbBox; // this holds the two combo boxes
211 210
212 QString m_startDir; 211 QString m_startDir;
213 int m_mode; 212 int m_mode;
214 int m_selector; 213 int m_selector;
215 214
216 QStringList* m_allList; 215 QStringList m_allList;
217 216
218 struct Data; // used for future versions 217 struct Data; // used for future versions
219 Data *d; 218 Data *d;
220 219
221private slots: 220private slots:
222 void slotMimeTypeChanged(); 221 void slotMimeTypeChanged();
223 222
224 /* will set the text of the lineedit and emit a fileChanged signal */ 223 /* will set the text of the lineedit and emit a fileChanged signal */
225 void slotDocLnkBridge( const DocLnk& ); 224 void slotDocLnkBridge( const DocLnk& );
226 void slotFileBridge( const QString& ); 225 void slotFileBridge( const QString& );
227 void slotViewChange( const QString& ); 226 void slotViewChange( const QString& );
228 227
diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h
index 252a7f5..790d2bd 100644
--- a/libopie2/opieui/fileselector/ofileselector_p.h
+++ b/libopie2/opieui/fileselector/ofileselector_p.h
@@ -66,24 +66,25 @@ class OFileViewInterface
66public: 66public:
67 OFileViewInterface( OFileSelector* selector ); 67 OFileViewInterface( OFileSelector* selector );
68 virtual ~OFileViewInterface(); 68 virtual ~OFileViewInterface();
69 virtual QString selectedName()const = 0; 69 virtual QString selectedName()const = 0;
70 virtual QString selectedPath()const = 0; 70 virtual QString selectedPath()const = 0;
71 virtual QString directory()const = 0; 71 virtual QString directory()const = 0;
72 virtual void reread() = 0; 72 virtual void reread() = 0;
73 virtual int fileCount()const = 0; 73 virtual int fileCount()const = 0;
74 virtual DocLnk selectedDocument()const; 74 virtual DocLnk selectedDocument()const;
75 virtual QWidget* widget( QWidget* parent) = 0; 75 virtual QWidget* widget( QWidget* parent) = 0;
76 virtual void activate( const QString& ); 76 virtual void activate( const QString& );
77 QString name()const; 77 QString name()const;
78 bool allItem( const QString& )const;
78protected: 79protected:
79 OFileSelector* selector()const; 80 OFileSelector* selector()const;
80 void setName( const QString& ); 81 void setName( const QString& );
81 bool showNew()const; 82 bool showNew()const;
82 bool showClose()const; 83 bool showClose()const;
83 MimeTypes mimeTypes()const; 84 MimeTypes mimeTypes()const;
84 QStringList currentMimeType()const; 85 QStringList currentMimeType()const;
85 QString startDirectory()const; 86 QString startDirectory()const;
86protected: 87protected:
87 void ok(); 88 void ok();
88 void cancel(); 89 void cancel();
89 void closeMe(); 90 void closeMe();
@@ -143,25 +144,24 @@ private:
143 144
144class OFileViewFileListView : public QWidget 145class OFileViewFileListView : public QWidget
145{ 146{
146 Q_OBJECT 147 Q_OBJECT
147public: 148public:
148 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); 149 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector );
149 ~OFileViewFileListView(); 150 ~OFileViewFileListView();
150 151
151 OFileSelectorItem* currentItem()const; 152 OFileSelectorItem* currentItem()const;
152 void reread( bool all = false ); 153 void reread( bool all = false );
153 int fileCount()const; 154 int fileCount()const;
154 QString currentDir()const; 155 QString currentDir()const;
155 bool allItem( const QString& )const;
156protected: 156protected:
157 bool eventFilter (QObject *o, QEvent *e); 157 bool eventFilter (QObject *o, QEvent *e);
158private slots: 158private slots:
159 void slotNew(); // will emit newSelected 159 void slotNew(); // will emit newSelected
160 void cdUP(); 160 void cdUP();
161 void cdHome(); 161 void cdHome();
162 void cdDoc(); 162 void cdDoc();
163 void changeDir( const QString& ); 163 void changeDir( const QString& );
164 void slotCurrentChanged( QListViewItem* ); 164 void slotCurrentChanged( QListViewItem* );
165 void slotClicked(int, QListViewItem*, const QPoint&, int ); 165 void slotClicked(int, QListViewItem*, const QPoint&, int );
166 void slotFSActivated(int); 166 void slotFSActivated(int);
167 167