summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc89
1 files changed, 49 insertions, 40 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index ce66f51..3a11032 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -57,55 +57,56 @@
#include <stdlib.h>
#include <sys/stat.h>
#include "ofileselector.h"
QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
namespace {
int indexByString( const QComboBox *box, const QString &str ){
int index= -1;
for(int i= 0; i < box->count(); i++ ){
- qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() );
if( str == box->text(i ) ){
index= i;
break;
}
}
return index;
}
};
OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
const QString &fileName, const QStringList &mimetypes ) : QWidget( wid )
{
if(wid!=0)
resize(wid->width(),wid->height());
m_selector = selector;
m_currentDir = dirName;
m_name = fileName;
- requestedMimeTypesList = m_mimetypes = mimetypes;
+ m_mimetypes = mimetypes;
-// if( mimetypes.isEmpty() )
-// m_autoMime = true;
+ if( mimetypes.isEmpty() )
+ m_autoMime = true;
+ qWarning("OFileSelector mimetypes %s", mimetypes.join(" ").latin1() );
m_mode = mode;
m_shTool = true;
m_shPerm = true;
m_shLne = true;
m_shChooser = true;
m_shYesNo = true;
+
// for FILESELECTOR only view is interesting
m_location = 0;
m_homeButton = 0;
m_docButton = 0;
m_hideButton = 0;
m_ok = 0;
m_cancel = 0;
m_reread = 0;
m_up = 0;
m_View = 0;
m_select = 0;
m_stack = 0;
@@ -180,52 +181,56 @@ void OFileSelector::initPics()
void OFileSelector::delItems()
{
QLayoutIterator it = m_lay->iterator();
while ( it.current() != 0 ){
it.deleteCurrent();
}
}
void OFileSelector::init()
{
// qDebug("init");
m_stack = new QWidgetStack(this, "wstack" );
+ if( m_selector == NORMAL ){
QString currMime;
if( m_mimeCheck != 0 )
currMime = m_mimeCheck->currentText();
updateMimes();
- m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE );
+ m_select = new FileSelector( currMime == "All" ? QString::null : currMime ,
+ m_stack, "fileselector", FALSE, FALSE );
m_stack->addWidget(m_select, NORMAL );
m_lay->addWidget(m_stack );
m_stack->raiseWidget(NORMAL );
- connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
+ connect(m_select, SIGNAL(fileSelected( const DocLnk &) ),
+ this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
m_pseudoLayout = 0l;
- if( m_selector != NORMAL ) {
+
+ } else {
initializeListView();
}
if(m_shLne ){
initializeName();
}
if(m_shPerm ){
m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" );
m_checkPerm->setChecked( false );
m_lay->addWidget(m_checkPerm );
}
if( m_shChooser )
initializeChooser();
if(m_shYesNo )
initializeYes();
- m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) );
- reparse();
+ // m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) );
+ // reparse();
}
void OFileSelector::setYesCancelVisible( bool show )
{
if ( show == m_shYesNo )
return;
m_shYesNo = show;
if( !show ){
delete m_ok;
delete m_cancel;
m_ok = 0;
@@ -434,25 +439,28 @@ void OFileSelector::reparse()
continue;
}
MimeType type(fi->filePath() );
if( !m_mimetypes.contains( type.id() ) )
m_mimetypes.append( type.id() );
++it;
}
m_mimetypes.prepend("All" );
m_mimeCheck->insertStringList(m_mimetypes );
// set it to the current mimetype
m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) );
- };
+ }else{
+ m_mimeCheck->clear();
+ m_mimeCheck->insertItem( m_mimetypes.join(";") );
+ }
QDir dir( m_currentDir );
//dir.setFilter(-1 );
int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed;
if( m_case )
sort = QDir::IgnoreCase;
dir.setSorting( sort );
int filter;
/* if( m_dir && !m_files)
filter |= QDir::Dirs;
else if( !m_dir && m_files )
@@ -569,30 +577,30 @@ void OFileSelector::initializeChooser()
m_mimeCheck = new QComboBox(this, "mime check");
m_viewCheck = new QComboBox(this, "view check");
m_boxView->addWidget(m_viewCheck, 0 );
m_boxView->insertSpacing(2, 8 );
m_boxView->addWidget(m_mimeCheck, 0 );
m_lay->addLayout(m_boxView );
m_lay->insertSpacing( 4, 8);
m_viewCheck->insertItem(tr("Documents") );
m_viewCheck->insertItem(tr("Files") );
m_viewCheck->insertItem(tr("All Files") );
-// if(!m_autoMime )
-// m_mimeCheck->insertItem(m_mimetypes.join("," ) );
-// else{ // check
- updateMimes();
- m_mimeCheck->insertStringList( m_mimetypes );
-// }
+ if(!m_autoMime )
+ m_mimeCheck->insertItem(m_mimetypes.join("," ) );
+ else{ // check
+ updateMimes();
+ m_mimeCheck->insertStringList( m_mimetypes );
+ }
connect( m_viewCheck, SIGNAL(activated(const QString &) ),
this, SLOT(slotViewCheck(const QString & ) ) );
connect( m_mimeCheck, SIGNAL(activated(const QString &) ),
this, SLOT(slotMimeCheck(const QString & ) ) );
}
void OFileSelector::slotMimeCheck(const QString &view ){
if(m_selector == NORMAL ){
delete m_select;
m_select = new FileSelector(view == "All" ? QString::null : view
@@ -660,57 +668,58 @@ void OFileSelector::slotViewCheck(const QString &view ){
m_View = 0;
m_selector = EXTENDED_ALL;
initializeListView();
reparse();
}
}
void OFileSelector::updateMimes() // lets check which mode is active
// check the current dir for items then
{
- m_mimetypes.clear();
- m_mimetypes.append("All" );
-// if( m_selector == NORMAL ){
- DocLnkSet set;
- Global::findDocuments(&set, QString::null );
- QListIterator<DocLnk> dit( set.children() );
- for ( ; dit.current(); ++dit ) {
- if( !m_mimetypes.contains((*dit)->type() ) )
- m_mimetypes.append( (*dit)->type() );
- }
-// }else{
- // should be allreday updatet
- // ;
- // }
+ if( m_autoMime ){
+ m_mimetypes.clear();
+ m_mimetypes.append("All" );
+ if( m_selector == NORMAL ){
+ DocLnkSet set;
+ Global::findDocuments(&set, QString::null );
+ QListIterator<DocLnk> dit( set.children() );
+ for ( ; dit.current(); ++dit ) {
+ if( !m_mimetypes.contains((*dit)->type() ) )
+ m_mimetypes.append( (*dit)->type() );
+ }
+ }else{
+ // should be allreday updatet
+ ;
+ }
+ }
}
void OFileSelector::initializeListView()
{
// in the instance that a developer selected the view to be Files or Entended,
// in the initial initialization, you are deleting objects here
// that aren't even existing yet.
// just to make sure but clean it up better FIXME
- // if( m_View) delete m_View;
-// m_View = 0;
-// if(m_boxToolbar) delete m_boxToolbar;
-// if(m_homeButton) delete m_homeButton;
-// if(m_docButton) delete m_docButton;
-// if( m_location) delete m_location;
-// if(m_up) delete m_up;
- //delete m_pseudo;
- //if(m_pseudoLayout!=0 ) // why did you overload malloc
- //delete m_pseudoLayout;
+ delete m_View;
+ m_View = 0;
+ delete m_boxToolbar;
+ delete m_homeButton;
+ delete m_docButton;
+ delete m_location;
+ delete m_up;
+ delete m_pseudo;
+
m_boxToolbar = 0;
m_homeButton = 0;
m_docButton = 0;
m_location = 0;
m_up = 0;
m_pseudo = 0;
m_pseudoLayout = 0;
qDebug(" time for the toolbar ");
m_pseudo = new QWidget(m_stack, "Pseudo Widget");
m_pseudoLayout = new QVBoxLayout(m_pseudo );
if(m_shTool ){
m_boxToolbar = new QHBoxLayout( );