summaryrefslogtreecommitdiff
authorar <ar>2004-09-15 21:11:32 (UTC)
committer ar <ar>2004-09-15 21:11:32 (UTC)
commit6a60be54b98f1eb50df5a37454bb71bd52475f43 (patch) (side-by-side diff)
treeb14d617d0108f9612ce16e95d03c9b55b5d0cbd7
parente3709ce5db7f07cbac94900cb7b66ad3e7a6f791 (diff)
downloadopie-6a60be54b98f1eb50df5a37454bb71bd52475f43.zip
opie-6a60be54b98f1eb50df5a37454bb71bd52475f43.tar.gz
opie-6a60be54b98f1eb50df5a37454bb71bd52475f43.tar.bz2
- implement a QStringList* m_allList for show all files/directories if a "All Item" is selected. (hope the description is not too confused ;) )
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp26
-rw-r--r--libopie2/opieui/fileselector/ofileselector.h3
-rw-r--r--libopie2/opieui/fileselector/ofileselector_p.h1
3 files changed, 27 insertions, 3 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 346eeae..e8d502f 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -509,48 +509,56 @@ int OFileViewFileListView::fileCount()const
QString OFileViewFileListView::currentDir()const
{
return m_currentDir;
}
OFileSelector* OFileViewFileListView::selector()
{
return m_sel;
}
bool OFileViewFileListView::eventFilter (QObject *, QEvent *e)
{
if ( e->type() == QEvent::KeyPress )
{
QKeyEvent *k = (QKeyEvent *)e;
if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
{
slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
return true;
}
}
return false;
}
+/**
+ * @return true if the item show all files or directories
+ */
+bool OFileViewFileListView::allItem( const QString& item )const
+{
+ return m_sel->allItem( item );
+}
+
void OFileViewFileListView::connectSlots()
{
connect(m_view, SIGNAL(clicked(QListViewItem*) ),
this, SLOT(slotCurrentChanged(QListViewItem*) ) );
connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
}
void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
{
if (!item)
return;
#if 0
OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
if (!sel->isDir() )
{
selector()->m_lneEdit->setText( sel->text(1) );
// if in fileselector mode we will emit selected
if ( selector()->mode() == OFileSelector::FileSelector )
{
odebug << "slot Current Changed" << oendl;
QStringList str = QStringList::split("->", sel->text(1) );
@@ -794,51 +802,51 @@ QString OFileViewFileSystem::directory()const
void OFileViewFileSystem::reread()
{
if (!m_view)
return;
m_view->reread( m_all );
}
int OFileViewFileSystem::fileCount()const
{
if (!m_view )
return -1;
return m_view->fileCount();
}
QWidget* OFileViewFileSystem::widget( QWidget* parent )
{
if (!m_view )
{
m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
}
return m_view;
}
-void OFileViewFileSystem::activate( const QString& str)
+void OFileViewFileSystem::activate( const QString& str )
{
- m_all = ( str.find( "All" ) != -1 );
+ m_all = m_view->allItem( str );
}
}
/* Selector */
/**
* @short new and complete c'tor
*
* Create a OFileSelector to let the user select a file. It can
* either be used to open a file, select a save name in a dir or
* as a dropin for the FileSelector.
*
* <pre>
* QMap<QString, QStringList> mimeTypes;
* QStringList types;
* types << "text@slash* ";
* types << "audio@slash*";
* mimeTypes.insert( tr("Audio and Text"), types );
* mimeTypes.insert( tr("All"), "*@slash*);
*
* now you could create your fileselector
* </pre>
*
*
@@ -846,48 +854,50 @@ void OFileViewFileSystem::activate( const QString& str)
* @param mode The mode from the enum Mode (Open,Save,FILESELECTOR)
* @param sel The selector to be used
* @param dirName The name of the dir to start int
* @param fileName The fileName placed in the fileselector lineedit
* @param mimetypes The MimeType map of used mimetypes
* @param showNew Show a New Button. Most likely to be used in the FileSelector view.
* @param showClose Show a Close Button. Most likely to be used in FileSelector view.
*
*/
OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
const QString& dirName, const QString& fileName,
const MimeTypes& mimetypes,
bool showNew, bool showClose)
:QWidget( parent, "OFileSelector" )
{
m_current = 0;
m_shNew = showNew;
m_shClose = showClose;
m_mimeType = mimetypes;
m_startDir = dirName;
m_mode = mode;
m_selector = sel;
+ m_allList = new QStringList();
+
initUI();
m_lneEdit->setText( fileName );
initMime();
initViews();
QString str;
switch ( m_selector )
{
default:
case Normal:
if ( m_mode == DIRECTORYSELECTOR )
str = QObject::tr("Directories");
else
str = QObject::tr("Documents");
m_cmbView->setCurrentItem( 0 );
break;
case Extended:
if ( m_mode == DIRECTORYSELECTOR )
{
str = QObject::tr("Directories");
m_cmbView->setCurrentItem( 0 );
} else {
str = QObject::tr("Files");
m_cmbView->setCurrentItem( 1 );
@@ -1002,52 +1012,54 @@ void OFileSelector::initMime()
}
void OFileSelector::initViews()
{
if ( m_mode == OFileSelector::DIRECTORYSELECTOR )
{
m_cmbView->insertItem( QObject::tr("Directories") );
m_cmbView->insertItem( QObject::tr("All Directories") );
} else {
m_cmbView->insertItem( QObject::tr("Documents") );
m_cmbView->insertItem( QObject::tr("Files") );
m_cmbView->insertItem( QObject::tr("All Files") );
}
connect(m_cmbView, SIGNAL(activated(const QString&) ),
this, SLOT(slotViewChange(const QString&) ) );
/* see above why add both */
OFileViewInterface* in = new OFileViewFileSystem( this );
if ( m_mode == OFileSelector::DIRECTORYSELECTOR )
{
m_views.insert( QObject::tr("Directories"), in );
m_views.insert( QObject::tr("All Directories"), in );
+ m_allList->append( QObject::tr("All Directories") );
} else {
m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
m_views.insert( QObject::tr("Files"), in );
m_views.insert( QObject::tr("All Files"), in );
+ m_allList->append( QObject::tr("All Files") );
}
}
void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) {
m_viewsPtr.append( iface );
}
/**
* d'tor
*/
OFileSelector::~OFileSelector()
{
m_viewsPtr.setAutoDelete( true );
m_viewsPtr.clear();
}
/**
* Convience function for the fileselector
* make sure to delete the DocLnk
*
* @see DocLnk
@@ -1125,86 +1137,94 @@ bool OFileSelector::showClose()const
}
MimeTypes OFileSelector::mimeTypes()const
{
return m_mimeType;
}
/**
* @return the Mode of the OFileSelector
*/
int OFileSelector::mode()const
{
return m_mode;
}
/**
* @return the Selector of the OFileSelector
*/
int OFileSelector::selector()const
{
return m_selector;
}
+/**
+ * @return true if the item show all files or directories
+ */
+bool OFileSelector::allItem( const QString& item )const
+{
+ return ( m_allList->findIndex( item ) != -1 );
+}
+
QStringList OFileSelector::currentMimeType()const
{
return m_mimeType[m_cmbMime->currentText()];
}
void OFileSelector::slotMimeTypeChanged()
{
reread();
}
void OFileSelector::slotDocLnkBridge( const DocLnk& lnk)
{
m_lneEdit->setText( lnk.name() );
emit fileSelected( lnk );
emit fileSelected( lnk.name() );
}
void OFileSelector::slotFileBridge( const QString& str)
{
DocLnk lnk( str );
emit fileSelected( lnk );
}
void OFileSelector::slotViewChange( const QString& view )
{
OFileViewInterface* interface = m_views[view];
if (!interface)
return;
- interface->activate( view );
if (m_current)
m_stack->removeWidget( m_current->widget( m_stack ) );
static int id = 1;
m_stack->addWidget( interface->widget(m_stack), id );
m_stack->raiseWidget( id );
+ interface->activate( view );
interface->reread();
m_current = interface;
id++;
}
void OFileSelector::setNewVisible( bool b )
{
m_shNew = b;
currentView()->reread();
}
void OFileSelector::setCloseVisible( bool b )
{
m_shClose = b;
currentView()->reread();
}
void OFileSelector::setNameVisible( bool b )
{
if ( b )
m_nameBox->show();
else
m_nameBox->hide();
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h
index b1cd405..d96712a 100644
--- a/libopie2/opieui/fileselector/ofileselector.h
+++ b/libopie2/opieui/fileselector/ofileselector.h
@@ -100,48 +100,49 @@ public:
OFileSelector(QWidget* parent, int mode, int selector,
const QString& dirName,
const QString& fileName,
const MimeTypes& mimetypes = MimeTypes(),
bool newVisible = FALSE, bool closeVisible = FALSE );
OFileSelector(const QString& mimeFilter, QWidget* parent,
const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
~OFileSelector();
const DocLnk* selected();
QString selectedName()const;
QString selectedPath()const;
QString directory()const;
DocLnk selectedDocument()const;
int fileCount()const;
void reread();
int mode()const;
int selector()const;
+ bool allItem( const QString& )const;
/**
* Set the Icon visible
* @param b Show or Hide the New Button
*/
void setNewVisible( bool b );
/**
* Set the Icon visible
*/
void setCloseVisible( bool b );
/**
* Set the Name Line visible
*/
void setNameVisible( bool b );
signals:
/**
* dirSelected is emitted whenever changed into a different dir
*/
void dirSelected( const QString& );
/**
@@ -191,43 +192,45 @@ private:
* This happens on creation of a OFileViewInterface
*/
void registerView( const Internal::OFileViewInterface* );
private:
QLineEdit* m_lneEdit; // the LineEdit for the Name
QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
QWidgetStack* m_stack; // our widget stack which will contain the views
Internal::OFileViewInterface* currentView() const; // returns the currentView
Internal::OFileViewInterface* m_current; // here is the view saved
bool m_shNew : 1; // should we show New?
bool m_shClose : 1; // should we show Close?
MimeTypes m_mimeType; // list of mimetypes
QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
/* views register themselves automatically */
QList<Internal::OFileViewInterface> m_viewsPtr;
QHBox* m_nameBox; // the LineEdit + Label is hold here
QHBox* m_cmbBox; // this holds the two combo boxes
QString m_startDir;
int m_mode;
int m_selector;
+ QStringList* m_allList;
+
struct Data; // used for future versions
Data *d;
private slots:
void slotMimeTypeChanged();
/* will set the text of the lineedit and emit a fileChanged signal */
void slotDocLnkBridge( const DocLnk& );
void slotFileBridge( const QString& );
void slotViewChange( const QString& );
bool eventFilter (QObject *o, QEvent *e);
};
}
}
#endif
diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h
index a3ef8e2..252a7f5 100644
--- a/libopie2/opieui/fileselector/ofileselector_p.h
+++ b/libopie2/opieui/fileselector/ofileselector_p.h
@@ -131,48 +131,49 @@ public:
~OFileSelectorItem();
bool isLocked()const;
bool isDir()const;
QString directory()const;
QString path()const;
QString key(int id, bool )const;
private:
bool m_locked : 1;
bool m_isDir : 1;
QString m_dir;
};
class OFileViewFileListView : public QWidget
{
Q_OBJECT
public:
OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector );
~OFileViewFileListView();
OFileSelectorItem* currentItem()const;
void reread( bool all = false );
int fileCount()const;
QString currentDir()const;
+ bool allItem( const QString& )const;
protected:
bool eventFilter (QObject *o, QEvent *e);
private slots:
void slotNew(); // will emit newSelected
void cdUP();
void cdHome();
void cdDoc();
void changeDir( const QString& );
void slotCurrentChanged( QListViewItem* );
void slotClicked(int, QListViewItem*, const QPoint&, int );
void slotFSActivated(int);
protected:
OFileSelector* selector();
private:
QMap<QString, QString> m_dev;
bool m_all : 1;
OFileSelector* m_sel;
QPopupMenu* m_fsPop;
bool compliesMime( const QString& );
QStringList m_mimes; // used in compy mime
QString m_currentDir;
QToolButton *m_btnNew, *m_btnClose;